Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
libaec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathis Rosenhauer
libaec
Commits
ef5de19b
Commit
ef5de19b
authored
12 years ago
by
Mathis Rosenhauer
Browse files
Options
Downloads
Patches
Plain Diff
Fix crash when input data isn't a multiple of the storage size
parent
24f6bb40
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README
+6
-4
6 additions, 4 deletions
README
src/encode.c
+6
-6
6 additions, 6 deletions
src/encode.c
src/encode.h
+1
-0
1 addition, 0 deletions
src/encode.h
with
13 additions
and
10 deletions
README
+
6
−
4
View file @
ef5de19b
...
...
@@ -124,10 +124,12 @@ sample size storage size
9 - 16 bit 2 bytes
17 - 32 bit 4 bytes (also for 24bit if AEC_DATA_3BYTE is not set)
If you use less bits than the storage size provides, then you have to
make sure that unused bits are not set. Libaec does not check this for
performance reasons and will produce undefined output if unused bits
are set.
If a sample requires less bits than the storage size provides, then
you have to make sure that unused bits are not set. Libaec does not
check this for performance reasons and will produce undefined output
if unused bits are set. All input data must be a multiple of the
storage size in bytes. Remaining bytes which do not form a complete
sample will be ignored.
Libaec accesses next_in and next_out buffers only bytewise. There are
no alignment requirements for these buffers.
...
...
This diff is collapsed.
Click to expand it.
src/encode.c
+
6
−
6
View file @
ef5de19b
...
...
@@ -686,7 +686,7 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
struct
internal_state
*
state
=
strm
->
state
;
do
{
if
(
strm
->
avail_in
>
0
)
{
if
(
strm
->
avail_in
>
=
state
->
bytes_per_sample
)
{
state
->
data_raw
[
state
->
i
]
=
state
->
get_sample
(
strm
);
}
else
{
if
(
state
->
flush
==
AEC_FLUSH
)
{
...
...
@@ -796,7 +796,7 @@ int aec_encode_init(struct aec_stream *strm)
if
(
strm
->
bits_per_sample
<=
24
&&
strm
->
flags
&
AEC_DATA_3BYTE
)
{
state
->
rsi_
le
n
=
3
;
state
->
bytes_per_samp
le
=
3
;
if
(
strm
->
flags
&
AEC_DATA_MSB
)
{
state
->
get_sample
=
aec_get_msb_24
;
state
->
get_rsi
=
aec_get_rsi_msb_24
;
...
...
@@ -805,7 +805,7 @@ int aec_encode_init(struct aec_stream *strm)
state
->
get_rsi
=
aec_get_rsi_lsb_24
;
}
}
else
{
state
->
rsi_
le
n
=
4
;
state
->
bytes_per_samp
le
=
4
;
if
(
strm
->
flags
&
AEC_DATA_MSB
)
{
state
->
get_sample
=
aec_get_msb_32
;
state
->
get_rsi
=
aec_get_rsi_msb_32
;
...
...
@@ -818,7 +818,7 @@ int aec_encode_init(struct aec_stream *strm)
else
if
(
strm
->
bits_per_sample
>
8
)
{
/* 16 bit settings */
state
->
id_len
=
4
;
state
->
rsi_
le
n
=
2
;
state
->
bytes_per_samp
le
=
2
;
if
(
strm
->
flags
&
AEC_DATA_MSB
)
{
state
->
get_sample
=
aec_get_msb_16
;
...
...
@@ -830,12 +830,12 @@ int aec_encode_init(struct aec_stream *strm)
}
else
{
/* 8 bit settings */
state
->
id_len
=
3
;
state
->
rsi_
le
n
=
1
;
state
->
bytes_per_samp
le
=
1
;
state
->
get_sample
=
aec_get_8
;
state
->
get_rsi
=
aec_get_rsi_8
;
}
state
->
rsi_len
*
=
strm
->
rsi
*
strm
->
block_size
;
state
->
rsi_len
=
strm
->
rsi
*
strm
->
block_size
*
state
->
bytes_per_sample
;
if
(
strm
->
flags
&
AEC_DATA_SIGNED
)
{
state
->
xmin
=
-
(
1ULL
<<
(
strm
->
bits_per_sample
-
1
));
...
...
This diff is collapsed.
Click to expand it.
src/encode.h
+
1
−
0
View file @
ef5de19b
...
...
@@ -95,6 +95,7 @@ struct internal_state {
* not */
int
zero_ref
;
/* current zero block has a reference sample */
uint32_t
zero_ref_sample
;
/* reference sample of zero block */
int
bytes_per_sample
;
/* storage size of samples in bytes */
int
zero_blocks
;
/* number of contiguous zero blocks */
int
block_nonzero
;
/* 1 if this is the first non-zero block
* after one or more zero blocks */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment