Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
libaec
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mathis Rosenhauer
libaec
Commits
fca3dc1f
Commit
fca3dc1f
authored
Oct 23, 2012
by
Mathis Rosenhauer
Committed by
Thomas Jahns
Feb 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decoder: turn FSM switch into functions
parent
ec53d5ad
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
653 additions
and
321 deletions
+653
-321
src/Makefile.am
src/Makefile.am
+2
-2
src/decode.c
src/decode.c
+514
-318
src/decode.h
src/decode.h
+46
-0
tests/check_aec.c
tests/check_aec.c
+87
-0
tests/check_aec.h
tests/check_aec.h
+2
-0
tests/check_code_options.c
tests/check_code_options.c
+2
-1
No files found.
src/Makefile.am
View file @
fca3dc1f
lib_LTLIBRARIES
=
libaec.la libsz.la
libaec_la_SOURCES
=
encode.c encode_accessors.c decode.c
encode.h
\
encode
_accessors
.h
libaec_la_SOURCES
=
encode.c encode_accessors.c decode.c
\
encode
.h encode_accessors.h decode
.h
libsz_la_SOURCES
=
sz_compat.c
libsz_la_LIBADD
=
libaec.la
...
...
src/decode.c
View file @
fca3dc1f
This diff is collapsed.
Click to expand it.
src/decode.h
0 → 100644
View file @
fca3dc1f
#ifndef DECODE_H
#define DECODE_H
#include <config.h>
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#include "libaec.h"
#define M_CONTINUE 1
#define M_EXIT 0
#define SAFE (strm->avail_in >= state->in_blklen \
&& strm->avail_out >= state->out_blklen)
#define ROS 5
#define MIN(a, b) (((a) < (b))? (a): (b))
struct
internal_state
{
int
(
*
mode
)(
struct
aec_stream
*
);
int
id
;
/* option ID */
int
id_len
;
/* bit length of code option identification key */
int
(
**
id_table
)(
struct
aec_stream
*
);
/* table maps IDs to states */
void
(
*
put_sample
)(
struct
aec_stream
*
,
int64_t
);
int
ref_int
;
/* reference sample is every ref_int samples */
int64_t
last_out
;
/* previous output for post-processing */
int64_t
xmin
;
/* minimum integer for post-processing */
int64_t
xmax
;
/* maximum integer for post-processing */
int
in_blklen
;
/* length of uncompressed input block
should be the longest possible block */
int
out_blklen
;
/* length of output block in bytes */
int
n
,
i
;
/* counter for samples */
int64_t
*
block
;
/* block buffer for split-sample options */
int
se
;
/* set if second extension option is selected */
uint64_t
acc
;
/* accumulator for currently used bit sequence */
int
bitp
;
/* bit pointer to the next unused bit in accumulator */
int
fs
;
/* last fundamental sequence in accumulator */
int
ref
;
/* 1 if current block has reference sample */
int
pp
;
/* 1 if postprocessor has to be used */
int
byte_per_sample
;
size_t
samples_out
;
}
decode_state
;
#endif
/* DECODE_H */
tests/check_aec.c
View file @
fca3dc1f
...
...
@@ -58,6 +58,93 @@ int update_state(struct test_state *state)
return
0
;
}
int
encode_decode_small
(
struct
test_state
*
state
)
{
int
status
,
i
,
to
,
Bps
;
struct
aec_stream
*
strm
=
state
->
strm
;
strm
->
avail_out
=
state
->
cbuf_len
;
strm
->
next_out
=
state
->
cbuf
;
status
=
aec_encode_init
(
strm
);
if
(
status
!=
AEC_OK
)
{
printf
(
"Init failed.
\n
"
);
return
99
;
}
Bps
=
strm
->
bit_per_sample
/
8
;
for
(
i
=
0
;
i
<
state
->
ibuf_len
/
Bps
;
i
++
)
{
strm
->
avail_in
=
Bps
;
strm
->
next_in
=
state
->
ubuf
+
i
*
Bps
;
status
=
aec_encode
(
strm
,
AEC_NO_FLUSH
);
if
(
status
!=
AEC_OK
)
{
printf
(
"Encode failed.
\n
"
);
return
99
;
}
}
status
=
aec_encode
(
strm
,
AEC_FLUSH
);
if
(
status
!=
AEC_OK
)
{
printf
(
"Encode failed.
\n
"
);
return
99
;
}
aec_encode_end
(
strm
);
strm
->
avail_out
=
state
->
buf_len
;
strm
->
next_out
=
state
->
obuf
;
to
=
strm
->
total_out
;
status
=
aec_decode_init
(
strm
);
if
(
status
!=
AEC_OK
)
{
printf
(
"Init failed.
\n
"
);
return
99
;
}
for
(
i
=
0
;
i
<
to
;
i
++
)
{
strm
->
avail_in
=
1
;
strm
->
next_in
=
state
->
cbuf
+
i
;
status
=
aec_decode
(
strm
,
AEC_NO_FLUSH
);
if
(
status
!=
AEC_OK
)
{
printf
(
"Decode failed.
\n
"
);
return
99
;
}
}
status
=
aec_decode
(
strm
,
AEC_FLUSH
);
if
(
status
!=
AEC_OK
)
{
printf
(
"Decode failed.
\n
"
);
return
99
;
}
if
(
memcmp
(
state
->
ubuf
,
state
->
obuf
,
state
->
ibuf_len
))
{
printf
(
"FAIL: Uncompressed output differs from input.
\n
"
);
printf
(
"
\n
uncompressed buf"
);
for
(
i
=
0
;
i
<
80
;
i
++
)
{
if
(
i
%
8
==
0
)
printf
(
"
\n
"
);
printf
(
"%02x "
,
state
->
ubuf
[
i
]);
}
printf
(
"
\n\n
compressed buf len %i"
,
to
);
for
(
i
=
0
;
i
<
80
;
i
++
)
{
if
(
i
%
8
==
0
)
printf
(
"
\n
"
);
printf
(
"%02x "
,
state
->
cbuf
[
i
]);
}
printf
(
"
\n\n
decompressed buf"
);
for
(
i
=
0
;
i
<
80
;
i
++
)
{
if
(
i
%
8
==
0
)
printf
(
"
\n
"
);
printf
(
"%02x "
,
state
->
obuf
[
i
]);
}
printf
(
"
\n
"
);
return
99
;
}
aec_decode_end
(
strm
);
return
0
;
}
int
encode_decode
(
struct
test_state
*
state
)
{
int
status
,
i
,
to
;
...
...
tests/check_aec.h
View file @
fca3dc1f
...
...
@@ -3,6 +3,7 @@
#include "libaec.h"
struct
test_state
{
int
(
*
codec
)(
struct
test_state
*
state
);
int
id_len
;
int
byte_per_sample
;
unsigned
char
*
ubuf
;
...
...
@@ -18,6 +19,7 @@ struct test_state {
};
int
update_state
(
struct
test_state
*
state
);
int
encode_decode_small
(
struct
test_state
*
state
);
int
encode_decode
(
struct
test_state
*
state
);
...
...
tests/check_code_options.c
View file @
fca3dc1f
...
...
@@ -20,7 +20,7 @@ int check_block_sizes(struct test_state *state, int id, int id_len)
for
(
rsi
=
1
;
rsi
<=
max_rsi
;
rsi
++
)
{
state
->
strm
->
rsi
=
rsi
;
status
=
encode_decode
(
state
);
status
=
state
->
codec
(
state
);
if
(
status
)
return
status
;
...
...
@@ -212,6 +212,7 @@ int main (void)
strm
.
flags
=
AEC_DATA_PREPROCESS
;
state
.
strm
=
&
strm
;
state
.
codec
=
encode_decode_small
;
printf
(
"----------------------------
\n
"
);
printf
(
"Checking LSB first, unsigned
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment