Commit e2efb20b authored by Mathis Rosenhauer's avatar Mathis Rosenhauer Committed by Thomas Jahns

killed loop + other simplifications

parent 8c6bc974
......@@ -463,16 +463,18 @@ static int m_flush_block_resumable(struct aec_stream *strm)
*/
struct internal_state *state = strm->state;
while(state->cds_buf + state->i < state->cds) {
if (strm->avail_out == 0)
return M_EXIT;
*strm->next_out++ = state->cds_buf[state->i];
strm->avail_out--;
state->i++;
int n = MIN(state->cds - state->cds_buf - state->i, strm->avail_out);
memcpy(strm->next_out, state->cds_buf + state->i, n);
strm->next_out += n;
strm->avail_out -= n;
state->i += n;
if (strm->avail_out == 0) {
return M_EXIT;
} else {
state->mode = m_get_block;
return M_CONTINUE;
}
state->mode = m_get_block;
return M_CONTINUE;
}
static int m_flush_block(struct aec_stream *strm)
......@@ -654,7 +656,6 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
to full RSI.
*/
int j;
struct internal_state *state = strm->state;
do {
......@@ -663,15 +664,11 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
} else {
if (state->flush == AEC_FLUSH) {
if (state->i > 0) {
for (j = state->i; j < strm->rsi * strm->block_size; j++)
state->data_raw[j] = state->data_raw[state->i - 1];
state->i = strm->rsi * strm->block_size;
do
state->data_raw[state->i] =
state->data_raw[state->i - 1];
while(++state->i < strm->rsi * strm->block_size);
} else {
if (state->zero_blocks) {
state->mode = m_encode_zero;
return M_CONTINUE;
}
emit(state, 0, state->bits);
if (strm->avail_out > 0) {
if (!state->direct_out)
......
......@@ -64,6 +64,7 @@
#define M_CONTINUE 1
#define M_EXIT 0
#define MIN(a, b) (((a) < (b))? (a): (b))
struct internal_state {
int (*mode)(struct aec_stream *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment