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
51bf2653
Commit
51bf2653
authored
Nov 05, 2012
by
Mathis Rosenhauer
Committed by
Thomas Jahns
Feb 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer output and filter in one go
parent
874139b8
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
348 additions
and
229 deletions
+348
-229
src/decode.c
src/decode.c
+265
-205
src/decode.h
src/decode.h
+8
-4
tests/check_aec.c
tests/check_aec.c
+72
-17
tests/check_aec.h
tests/check_aec.h
+1
-1
tests/check_buffer_sizes.c
tests/check_buffer_sizes.c
+2
-2
No files found.
src/decode.c
View file @
51bf2653
This diff is collapsed.
Click to expand it.
src/decode.h
View file @
51bf2653
...
...
@@ -12,8 +12,8 @@
#define M_CONTINUE 1
#define M_EXIT 0
#define SAFE
(strm->avail_in >= state->in_blklen
\
&& strm->avail_out >= state->out_blklen)
#define SAFE
(strm) (strm->avail_in >= strm->state->in_blklen
\
&& strm->avail_out >= st
rm->st
ate->out_blklen)
#define ROS 5
#define MIN(a, b) (((a) < (b))? (a): (b))
...
...
@@ -23,7 +23,7 @@ struct internal_state {
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
);
void
(
*
flush_output
)(
struct
aec_stream
*
);
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 */
...
...
@@ -40,8 +40,12 @@ struct internal_state {
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
;
int
*
se_table
;
uint32_t
*
buf_out
;
uint32_t
buf_next_out
;
uint32_t
buf_size
;
uint32_t
flush_start
;
uint32_t
flush_end
;
}
decode_state
;
#endif
/* DECODE_H */
tests/check_aec.c
View file @
51bf2653
...
...
@@ -60,27 +60,51 @@ int update_state(struct test_state *state)
int
encode_decode_small
(
struct
test_state
*
state
)
{
int
status
,
i
,
to
,
Bps
;
int
status
,
i
,
compressed_size
;
int
n_in
,
avail_in
,
avail_out
,
total_out
;
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
;
n_in
=
0
;
avail_in
=
1
;
avail_out
=
1
;
total_out
=
0
;
strm
->
next_in
=
state
->
ubuf
;
strm
->
avail_in
=
state
->
byte_per_sample
;
strm
->
avail_out
=
1
;
strm
->
next_out
=
state
->
cbuf
;
while
((
avail_in
||
avail_out
)
&&
total_out
<
state
->
cbuf_len
)
{
if
(
strm
->
avail_in
==
0
&&
avail_in
)
{
n_in
+=
state
->
byte_per_sample
;
if
(
n_in
<
state
->
buf_len
)
{
strm
->
avail_in
=
state
->
byte_per_sample
;
strm
->
next_in
=
state
->
ubuf
+
n_in
;
}
else
{
avail_in
=
0
;
}
}
status
=
aec_encode
(
strm
,
AEC_NO_FLUSH
);
if
(
status
!=
AEC_OK
)
{
printf
(
"
En
code failed.
\n
"
);
printf
(
"
De
code failed.
\n
"
);
return
99
;
}
if
(
strm
->
total_out
-
total_out
>
0
&&
total_out
<
state
->
cbuf_len
)
{
total_out
=
strm
->
total_out
;
strm
->
avail_out
=
1
;
strm
->
next_out
=
state
->
cbuf
+
total_out
;
avail_out
=
1
;
}
else
{
avail_out
=
0
;
}
}
status
=
aec_encode
(
strm
,
AEC_FLUSH
);
...
...
@@ -91,9 +115,13 @@ int encode_decode_small(struct test_state *state)
aec_encode_end
(
strm
);
strm
->
avail_out
=
state
->
buf_len
;
compressed_size
=
strm
->
total_out
;
strm
->
avail_in
=
1
;
strm
->
next_in
=
state
->
cbuf
;
strm
->
avail_out
=
state
->
byte_per_sample
;
strm
->
next_out
=
state
->
obuf
;
to
=
strm
->
total_out
;
status
=
aec_decode_init
(
strm
);
if
(
status
!=
AEC_OK
)
{
...
...
@@ -101,14 +129,41 @@ int encode_decode_small(struct test_state *state)
return
99
;
}
for
(
i
=
0
;
i
<
to
;
i
++
)
{
strm
->
avail_in
=
1
;
strm
->
next_in
=
state
->
cbuf
+
i
;
n_in
=
0
;
avail_in
=
1
;
avail_out
=
1
;
total_out
=
0
;
strm
->
next_in
=
state
->
cbuf
;
strm
->
avail_in
=
1
;
strm
->
avail_out
=
state
->
byte_per_sample
;
strm
->
next_out
=
state
->
obuf
;
while
((
avail_in
||
avail_out
)
&&
total_out
<
state
->
buf_len
)
{
if
(
strm
->
avail_in
==
0
&&
avail_in
)
{
n_in
++
;
if
(
n_in
<
compressed_size
)
{
strm
->
avail_in
=
1
;
strm
->
next_in
=
state
->
cbuf
+
n_in
;
}
else
{
avail_in
=
0
;
}
}
status
=
aec_decode
(
strm
,
AEC_NO_FLUSH
);
if
(
status
!=
AEC_OK
)
{
printf
(
"Decode failed.
\n
"
);
return
99
;
}
if
(
strm
->
total_out
-
total_out
>
0
&&
total_out
<
state
->
buf_len
)
{
total_out
=
strm
->
total_out
;
strm
->
avail_out
=
state
->
byte_per_sample
;
strm
->
next_out
=
state
->
obuf
+
total_out
;
avail_out
=
1
;
}
else
{
avail_out
=
0
;
}
}
status
=
aec_decode
(
strm
,
AEC_FLUSH
);
...
...
@@ -126,7 +181,7 @@ int encode_decode_small(struct test_state *state)
printf
(
"
\n
"
);
printf
(
"%02x "
,
state
->
ubuf
[
i
]);
}
printf
(
"
\n\n
compressed buf len %i"
,
to
);
printf
(
"
\n\n
compressed buf len %i"
,
compressed_size
);
for
(
i
=
0
;
i
<
80
;
i
++
)
{
if
(
i
%
8
==
0
)
printf
(
"
\n
"
);
...
...
@@ -135,7 +190,7 @@ int encode_decode_small(struct test_state *state)
printf
(
"
\n\n
decompressed buf"
);
for
(
i
=
0
;
i
<
80
;
i
++
)
{
if
(
i
%
8
==
0
)
printf
(
"
\n
"
);
printf
(
"
\n
%04i "
,
i
);
printf
(
"%02x "
,
state
->
obuf
[
i
]);
}
printf
(
"
\n
"
);
...
...
@@ -145,7 +200,7 @@ int encode_decode_small(struct test_state *state)
return
0
;
}
int
encode_decode
(
struct
test_state
*
state
)
int
encode_decode
_large
(
struct
test_state
*
state
)
{
int
status
,
i
,
to
;
struct
aec_stream
*
strm
=
state
->
strm
;
...
...
tests/check_aec.h
View file @
51bf2653
...
...
@@ -20,7 +20,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
);
int
encode_decode
_large
(
struct
test_state
*
state
);
#endif
/* CHECK_AEC_H */
tests/check_buffer_sizes.c
View file @
51bf2653
...
...
@@ -15,7 +15,7 @@ int check_block_sizes(struct test_state *state)
state
->
strm
->
block_size
=
bs
;
state
->
strm
->
rsi
=
state
->
buf_len
/
(
bs
*
state
->
byte_per_sample
);
status
=
encode_decode
(
state
);
status
=
encode_decode
_large
(
state
);
if
(
status
)
return
status
;
}
...
...
@@ -32,7 +32,7 @@ int check_block_sizes_short(struct test_state *state)
state
->
strm
->
block_size
=
bs
;
state
->
strm
->
rsi
=
state
->
buf_len
/
(
bs
*
state
->
byte_per_sample
);
state
->
ibuf_len
=
state
->
buf_len
-
2
*
bs
+
4
;
status
=
encode_decode
(
state
);
status
=
encode_decode
_large
(
state
);
if
(
status
)
return
status
;
if
(
state
->
strm
->
total_out
!=
state
->
buf_len
)
{
...
...
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