summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathis Rosenhauer <rosenhauer@dkrz.de>2012-09-24 17:45:54 +0200
committerThomas Jahns <jahns@dkrz.de>2013-02-19 11:32:59 +0100
commit3ae7b4214db148d788b851ce369fa51f63a8778b (patch)
tree41cc1f9d6594efcd4d9e771befe6fd65878ffee7
parent5cea8bc429310224cbab1722d24f033e32798afb (diff)
downloadlibaec-3ae7b4214db148d788b851ce369fa51f63a8778b.tar.gz
libaec-3ae7b4214db148d788b851ce369fa51f63a8778b.tar.bz2
libaec-3ae7b4214db148d788b851ce369fa51f63a8778b.zip
Fixed two bugs introduced through refactoring
-rw-r--r--src/encode.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/encode.c b/src/encode.c
index d16d2c6..1f6aaf9 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -223,44 +223,38 @@ static int m_get_block(struct aec_stream *strm)
return M_CONTINUE;
}
-static int input_empty(struct aec_stream *strm)
+static int m_get_block_cautious(struct aec_stream *strm)
{
int j;
struct internal_state *state = strm->state;
- if (state->flush == AEC_FLUSH) {
- if (state->i > 0) {
- for (j = state->i; j < strm->rsi * strm->block_size; j++)
- state->block_buf[j] = state->block_buf[state->i - 1];
- state->i = strm->rsi * strm->block_size;
+ do {
+ if (strm->avail_in > 0) {
+ state->block_buf[state->i] = state->get_sample(strm);
} else {
- if (state->zero_blocks) {
- state->mode = m_encode_zero;
- return M_CONTINUE;
+ if (state->flush == AEC_FLUSH) {
+ if (state->i > 0) {
+ for (j = state->i; j < strm->rsi * strm->block_size; j++)
+ state->block_buf[j] = state->block_buf[state->i - 1];
+ state->i = strm->rsi * strm->block_size;
+ } else {
+ if (state->zero_blocks) {
+ state->mode = m_encode_zero;
+ return M_CONTINUE;
+ }
+
+ emit(state, 0, state->bit_p);
+ if (state->direct_out == 0)
+ *strm->next_out++ = *state->cds_p;
+ strm->avail_out--;
+ strm->total_out++;
+
+ return M_EXIT;
+ }
+ } else {
+ return M_EXIT;
}
-
- emit(state, 0, state->bit_p);
- if (state->direct_out == 0)
- *strm->next_out++ = *state->cds_p;
- strm->avail_out--;
- strm->total_out++;
-
- return M_EXIT;
}
- }
-
- return M_EXIT;
-}
-
-static int m_get_block_cautious(struct aec_stream *strm)
-{
- struct internal_state *state = strm->state;
-
- do {
- if (strm->avail_in > 0)
- state->block_buf[state->i] = state->get_sample(strm);
- else
- return input_empty(strm);
} while (++state->i < strm->rsi * strm->block_size);
state->blocks_avail = strm->rsi - 1;
@@ -366,7 +360,6 @@ static int count_splitting_option(struct aec_stream *strm)
larger binary part. So we know that the CDS for k+1 will be
larger than for k without actually computing the length. An
analogue check can be done for decreasing k.
-
*/
int k, k_min;
@@ -403,8 +396,9 @@ static int count_splitting_option(struct aec_stream *strm)
k = state->k - 1;
dir = 0;
no_turn = 1;
+ } else {
+ k++;
}
- k++;
} else {
if (fs_len >= this_bs || k == 0)
break;