Commit 24f6bb40 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer Committed by Thomas Jahns

turn emitblock_fs macro into function

parent bd88807b
...@@ -128,36 +128,31 @@ static inline void copy64(uint8_t *dst, uint64_t src) ...@@ -128,36 +128,31 @@ static inline void copy64(uint8_t *dst, uint64_t src)
dst[7] = src; dst[7] = src;
} }
#define EMITBLOCK_FS(ref) \ static inline void emitblock_fs(struct aec_stream *strm, int k, int ref)
static inline void emitblock_fs_##ref(struct aec_stream *strm, \ {
int k) \ int i;
{ \ int used; /* used bits in 64 bit accumulator */
int i; \ uint64_t acc; /* accumulator */
int used; /* used bits in 64 bit accumulator */ \ struct internal_state *state = strm->state;
uint64_t acc; /* accumulator */ \
struct internal_state *state = strm->state; \ acc = (uint64_t)*state->cds << 56;
\ used = 7 - state->bits;
acc = (uint64_t)*state->cds << 56; \
used = 7 - state->bits; \ for (i = ref; i < strm->block_size; i++) {
\ used += (state->block[i] >> k) + 1;
for (i = ref; i < strm->block_size; i++) { \ if (used > 63) {
used += (state->block[i] >> k) + 1; \ copy64(state->cds, acc);
if (used > 63) { \ state->cds += 8;
copy64(state->cds, acc); \ acc = 0;
state->cds += 8; \ used &= 0x3f;
acc = 0; \ }
used &= 0x3f; \ acc |= 1ULL << (63 - used);
} \
acc |= 1ULL << (63 - used); \
} \
\
copy64(state->cds, acc); \
state->cds += used >> 3; \
state->bits = 7 - (used & 7); \
} }
EMITBLOCK_FS(0); copy64(state->cds, acc);
EMITBLOCK_FS(1); state->cds += used >> 3;
state->bits = 7 - (used & 7);
}
static inline void emitblock(struct aec_stream *strm, int k, int ref) static inline void emitblock(struct aec_stream *strm, int k, int ref)
{ {
...@@ -550,18 +545,11 @@ static int m_encode_splitting(struct aec_stream *strm) ...@@ -550,18 +545,11 @@ static int m_encode_splitting(struct aec_stream *strm)
emit(state, k + 1, state->id_len); emit(state, k + 1, state->id_len);
if (state->ref) if (state->ref)
{
emit(state, state->block[0], strm->bits_per_sample); emit(state, state->block[0], strm->bits_per_sample);
emitblock_fs_1(strm, k);
if (k) emitblock_fs(strm, k, state->ref);
emitblock(strm, k, 1); if (k)
} emitblock(strm, k, state->ref);
else
{
emitblock_fs_0(strm, k);
if (k)
emitblock(strm, k, 0);
}
return m_flush_block(strm); return m_flush_block(strm);
} }
......
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