summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathis Rosenhauer <rosenhauer@dkrz.de>2016-05-12 13:23:18 +0200
committerMathis Rosenhauer <rosenhauer@dkrz.de>2016-05-12 13:23:49 +0200
commite047ec682044d8a25b7111699ec7d977ea065efa (patch)
treefc36ded8047dc9a75b9f37865b3f9e462616c272
parent1e1919a7bfeb49c3ad4381640676a715760653a2 (diff)
downloadlibaec-e047ec682044d8a25b7111699ec7d977ea065efa.tar.gz
libaec-e047ec682044d8a25b7111699ec7d977ea065efa.tar.bz2
libaec-e047ec682044d8a25b7111699ec7d977ea065efa.zip
Fix ROS detection in combination with incomplete RSI
-rw-r--r--src/encode.c6
-rw-r--r--src/encode.h3
2 files changed, 7 insertions, 2 deletions
diff --git a/src/encode.c b/src/encode.c
index aa39f05..5c0a745 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -646,10 +646,10 @@ static int m_check_zero_block(struct aec_stream *strm)
state->zero_ref = state->ref;
state->zero_ref_sample = state->ref_sample;
}
- if (state->blocks_avail == 0
- || (strm->rsi - state->blocks_avail) % 64 == 0) {
+ if (state->blocks_avail == 0 || state->blocks_dispensed % 64 == 0) {
if (state->zero_blocks > 4)
state->zero_blocks = ROS;
+
state->mode = m_encode_zero;
return M_CONTINUE;
}
@@ -728,6 +728,7 @@ static int m_get_block(struct aec_stream *strm)
if (state->blocks_avail == 0) {
state->blocks_avail = strm->rsi - 1;
state->block = state->data_pp;
+ state->blocks_dispensed = 1;
if (strm->avail_in >= state->rsi_len) {
state->get_rsi(strm);
@@ -745,6 +746,7 @@ static int m_get_block(struct aec_stream *strm)
state->uncomp_len = strm->block_size * strm->bits_per_sample;
}
state->block += strm->block_size;
+ state->blocks_dispensed++;
state->blocks_avail--;
return m_check_zero_block(strm);
}
diff --git a/src/encode.h b/src/encode.h
index 7a9f8ea..750acba 100644
--- a/src/encode.h
+++ b/src/encode.h
@@ -94,6 +94,9 @@ struct internal_state {
/* remaining blocks in buffer */
int blocks_avail;
+ /* blocks encoded so far in RSI */
+ int blocks_dispensed;
+
/* current (preprocessed) input block */
uint32_t *block;