Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathis Rosenhauer
libaec
Commits
bc5254df
Commit
bc5254df
authored
Dec 05, 2012
by
Mathis Rosenhauer
Committed by
Thomas Jahns
Feb 19, 2013
Browse files
Avoid double zero-checking block after zero blocks
parent
90e25ec4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/encode.c
View file @
bc5254df
...
...
@@ -425,6 +425,31 @@ static int assess_se_option(uint64_t limit, struct aec_stream *strm)
return
len
;
}
static
void
init_output
(
struct
aec_stream
*
strm
)
{
/**
Direct output to next_out if next_out can hold a Coded Data
Set, use internal buffer otherwise.
*/
struct
internal_state
*
state
=
strm
->
state
;
if
(
strm
->
avail_out
>
state
->
cds_len
)
{
if
(
!
state
->
direct_out
)
{
state
->
direct_out
=
1
;
*
strm
->
next_out
=
*
state
->
cds
;
state
->
cds
=
strm
->
next_out
;
}
}
else
{
if
(
state
->
zero_blocks
==
0
||
state
->
direct_out
)
{
/* copy leftover from last block */
*
state
->
cds_buf
=
*
state
->
cds
;
state
->
cds
=
state
->
cds_buf
;
}
state
->
direct_out
=
0
;
}
}
/*
*
* FSM functions
...
...
@@ -596,10 +621,9 @@ static int m_check_zero_block(struct aec_stream *strm)
if
(
state
->
zero_blocks
)
{
/* The current block isn't zero but we have to emit a
* previous zero block first. The current block will be
* handled later.
*
flagged and
handled later.
*/
state
->
block
-=
strm
->
block_size
;
state
->
blocks_avail
++
;
state
->
block_nonzero
=
1
;
state
->
mode
=
m_encode_zero
;
return
M_CONTINUE
;
}
...
...
@@ -682,19 +706,12 @@ static int m_get_block(struct aec_stream *strm)
struct
internal_state
*
state
=
strm
->
state
;
if
(
strm
->
avail_out
>
state
->
cds_len
)
{
if
(
!
state
->
direct_out
)
{
state
->
direct_out
=
1
;
*
strm
->
next_out
=
*
state
->
cds
;
state
->
cds
=
strm
->
next_out
;
}
}
else
{
if
(
state
->
zero_blocks
==
0
||
state
->
direct_out
)
{
/* copy leftover from last block */
*
state
->
cds_buf
=
*
state
->
cds
;
state
->
cds
=
state
->
cds_buf
;
}
state
->
direct_out
=
0
;
init_output
(
strm
);
if
(
state
->
block_nonzero
)
{
state
->
block_nonzero
=
0
;
state
->
mode
=
m_select_code_option
;
return
M_CONTINUE
;
}
if
(
state
->
blocks_avail
==
0
)
{
...
...
src/encode.h
View file @
bc5254df
...
...
@@ -95,6 +95,8 @@ struct internal_state {
int
zero_ref
;
/* current zero block has a reference sample */
int64_t
zero_ref_sample
;
/* reference sample of zero block */
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 */
int
k
;
/* splitting position */
int
kmax
;
/* maximum number for k depending on id_len */
int
flush
;
/* flush option copied from argument */
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment