Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathis Rosenhauer
libaec
Commits
5c932b03
Commit
5c932b03
authored
Jul 25, 2012
by
Mathis Rosenhauer
Browse files
Faster decoding if buffer space available
parent
d991d495
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
src/Makefile
View file @
5c932b03
...
...
@@ -13,9 +13,12 @@ clean:
rm
-f
mytest ../data/ae_out
$(objects)
test
:
mytest
./mytest < ../data/example_data.szip
>
../data/ae_out
./mytest 1 1 < ../data/example_data.szip
>
../data/ae_out
diff ../data/ae_out ../data/example_data
./mytest 9478 16384 < ../data/example_data.szip
>
../data/ae_out
diff ../data/ae_out ../data/example_data
vtest
:
mytest
valgrind
-v
./mytest < example_data.szip
>
ae_out
diff ae_out example_data
valgrind
-v
./mytest < ../data/example_data.szip
>
../data/ae_out
diff ../data/ae_out ../data/example_data
src/aecd.h
View file @
5c932b03
...
...
@@ -7,7 +7,7 @@ struct internal_state;
typedef
struct
_ae_stream
{
uint8_t
*
next_in
;
const
uint8_t
*
next_in
;
size_t
avail_in
;
/* number of bytes available at next_in */
size_t
total_in
;
/* total number of input bytes read so far */
...
...
@@ -15,12 +15,12 @@ typedef struct _ae_stream
size_t
avail_out
;
/* remaining free space at next_out */
size_t
total_out
;
/* total number of bytes output so far */
uint32_t
bit_per_sample
;
/* resolution in bits per sample (n = 1,..., 32) */
uint32_t
block_size
;
/* block size in samples (J = 8 or 16) */
uint32_t
segment_size
;
/* set of blocks between consecutive reference samples */
uint8_t
pp
;
/* pre/post-processor used? */
uint32_t
bit_per_sample
;
/* resolution in bits per sample (n = 1,..., 32) */
uint32_t
block_size
;
/* block size in samples (J = 8 or 16) */
uint32_t
segment_size
;
/* set of blocks between consecutive reference samples */
uint8_t
pp
;
/* pre/post-processor used? */
struct
internal_state
*
state
;
struct
internal_state
*
state
;
}
ae_stream
;
typedef
ae_stream
*
ae_streamp
;
...
...
src/aed.c
View file @
5c932b03
This diff is collapsed.
Click to expand it.
src/mytest.c
View file @
5c932b03
...
...
@@ -10,74 +10,85 @@
int
main
(
int
argc
,
char
*
argv
[])
{
ae_stream
strm
;
int
c
,
i
,
n
,
status
,
todo
;
uint8_t
*
in
;
uint32_t
*
out
;
size_t
total_out
;
ae_stream
strm
;
int
c
,
i
,
n
,
status
,
todo
;
uint8_t
*
in
;
uint32_t
*
out
;
size_t
total_out
;
int
chunk_in
,
chunk_out
;
in
=
(
uint8_t
*
)
malloc
(
ALL_IN
);
out
=
(
uint32_t
*
)
malloc
(
CHUNK_OUT
*
sizeof
(
uint32_t
));
if
(
in
==
NULL
||
out
==
NULL
)
return
1
;
chunk_in
=
CHUNK_IN
;
chunk_out
=
CHUNK_OUT
;
if
(
argc
==
3
)
{
chunk_in
=
atoi
(
argv
[
1
]);
chunk_out
=
atoi
(
argv
[
2
]);
}
n
=
0
;
while
((
c
=
getc
(
stdin
))
!=
EOF
)
{
*
in
++
=
c
;
n
++
;
}
in
-=
n
;
fprintf
(
stderr
,
"chunk_in: %i
\n
chunk_out: %i
\n
"
,
chunk_in
,
chunk_out
);
in
=
(
uint8_t
*
)
malloc
(
ALL_IN
);
out
=
(
uint32_t
*
)
malloc
(
chunk_out
*
sizeof
(
uint32_t
));
if
(
in
==
NULL
||
out
==
NULL
)
return
1
;
strm
.
bit_per_sample
=
8
;
strm
.
block_size
=
8
;
strm
.
segment_size
=
2
;
strm
.
pp
=
1
;
n
=
0
;
while
((
c
=
getc
(
stdin
))
!=
EOF
)
{
*
in
++
=
c
;
n
++
;
}
in
-=
n
;
if
(
ae_decode_init
(
&
strm
)
!=
AE_OK
)
return
1
;
strm
.
next_in
=
in
;
strm
.
avail_in
=
CHUNK_IN
;
strm
.
next_out
=
out
;
strm
.
avail_out
=
CHUNK_OUT
;
todo
=
1
;
total_out
=
0
;
while
(
todo
)
{
todo
=
0
;
if
((
status
=
ae_decode
(
&
strm
,
0
))
!=
AE_OK
)
{
fprintf
(
stderr
,
"error is %i
\n
"
,
status
);
return
1
;
}
fprintf
(
stderr
,
"avail in %li total in %li avail out %li total out %lx
\n
"
,
strm
.
avail_in
,
strm
.
total_in
,
strm
.
avail_out
,
strm
.
total_out
);
strm
.
bit_per_sample
=
8
;
strm
.
block_size
=
8
;
strm
.
segment_size
=
2
;
strm
.
pp
=
1
;
if
(
strm
.
avail_in
==
0
&&
strm
.
total_in
<
ALL_IN
)
{
in
+=
CHUNK_IN
;
if
(
ae_decode_init
(
&
strm
)
!=
AE_OK
)
return
1
;
strm
.
next_in
=
in
;
strm
.
avail_in
=
chunk_in
;
strm
.
next_out
=
out
;
strm
.
avail_out
=
chunk_out
;
todo
=
1
;
total_out
=
0
;
while
(
todo
)
{
todo
=
0
;
if
((
status
=
ae_decode
(
&
strm
,
0
))
!=
AE_OK
)
{
fprintf
(
stderr
,
"error is %i
\n
"
,
status
);
return
1
;
}
// fprintf(stderr, "avail in %li total in %li avail out %li total out %lx\n", strm.avail_in, strm.total_in, strm.avail_out, strm.total_out);
strm
.
next_in
=
in
;
if
(
ALL_IN
-
strm
.
total_in
<
CHUNK_IN
)
strm
.
avail_in
=
ALL_IN
-
strm
.
total_in
;
else
strm
.
avail_in
=
CHUNK_IN
;
todo
=
1
;
}
if
(
strm
.
avail_in
==
0
&&
strm
.
total_in
<
ALL_IN
)
{
in
+=
chunk_in
;
if
(
strm
.
total_out
-
total_out
>
0
)
{
for
(
i
=
0
;
i
<
strm
.
total_out
-
total_out
;
i
++
)
{
putc
(
out
[
i
],
stdout
);
}
total_out
=
strm
.
total_out
;
strm
.
next_out
=
out
;
strm
.
avail_out
=
CHUNK_OUT
;
todo
=
1
;
}
}
strm
.
next_in
=
in
;
if
(
ALL_IN
-
strm
.
total_in
<
chunk_in
)
strm
.
avail_in
=
ALL_IN
-
strm
.
total_in
;
else
strm
.
avail_in
=
chunk_in
;
todo
=
1
;
}
return
0
;
if
(
strm
.
total_out
-
total_out
>
0
)
{
for
(
i
=
0
;
i
<
strm
.
total_out
-
total_out
;
i
++
)
{
putc
(
out
[
i
],
stdout
);
}
total_out
=
strm
.
total_out
;
strm
.
next_out
=
out
;
strm
.
avail_out
=
chunk_out
;
todo
=
1
;
}
}
return
0
;
}
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