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

killed loop + other simplifications

parent 8c6bc974
...@@ -463,16 +463,18 @@ static int m_flush_block_resumable(struct aec_stream *strm) ...@@ -463,16 +463,18 @@ static int m_flush_block_resumable(struct aec_stream *strm)
*/ */
struct internal_state *state = strm->state; struct internal_state *state = strm->state;
while(state->cds_buf + state->i < state->cds) { int n = MIN(state->cds - state->cds_buf - state->i, strm->avail_out);
if (strm->avail_out == 0) memcpy(strm->next_out, state->cds_buf + state->i, n);
return M_EXIT; strm->next_out += n;
strm->avail_out -= n;
*strm->next_out++ = state->cds_buf[state->i]; state->i += n;
strm->avail_out--;
state->i++; 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) static int m_flush_block(struct aec_stream *strm)
...@@ -654,7 +656,6 @@ static int m_get_rsi_resumable(struct aec_stream *strm) ...@@ -654,7 +656,6 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
to full RSI. to full RSI.
*/ */
int j;
struct internal_state *state = strm->state; struct internal_state *state = strm->state;
do { do {
...@@ -663,15 +664,11 @@ static int m_get_rsi_resumable(struct aec_stream *strm) ...@@ -663,15 +664,11 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
} else { } else {
if (state->flush == AEC_FLUSH) { if (state->flush == AEC_FLUSH) {
if (state->i > 0) { if (state->i > 0) {
for (j = state->i; j < strm->rsi * strm->block_size; j++) do
state->data_raw[j] = state->data_raw[state->i - 1]; state->data_raw[state->i] =
state->i = strm->rsi * strm->block_size; state->data_raw[state->i - 1];
while(++state->i < strm->rsi * strm->block_size);
} else { } else {
if (state->zero_blocks) {
state->mode = m_encode_zero;
return M_CONTINUE;
}
emit(state, 0, state->bits); emit(state, 0, state->bits);
if (strm->avail_out > 0) { if (strm->avail_out > 0) {
if (!state->direct_out) if (!state->direct_out)
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#define M_CONTINUE 1 #define M_CONTINUE 1
#define M_EXIT 0 #define M_EXIT 0
#define MIN(a, b) (((a) < (b))? (a): (b))
struct internal_state { struct internal_state {
int (*mode)(struct aec_stream *); 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