Commit af3c8f82 authored by Michael Niedermayer's avatar Michael Niedermayer

adpcmenc:Optimize adpcm_ima_qt_compress_sample()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 35d3d44a
...@@ -274,24 +274,27 @@ static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, sho ...@@ -274,24 +274,27 @@ static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, sho
static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, short sample) static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, short sample)
{ {
int delta = sample - c->prev_sample; int delta = sample - c->prev_sample;
int mask, step = step_table[c->step_index]; int diff, step = step_table[c->step_index];
int diff = step >> 3; int nibble = 8*(delta < 0);
int nibble = 0;
if (delta < 0) { delta= abs(delta);
nibble = 8; diff = delta + (step >> 3);
delta = -delta;
}
for (mask = 4; mask;) {
if (delta >= step) { if (delta >= step) {
nibble |= mask; nibble |= 4;
delta -= step; delta -= step;
diff += step;
} }
step >>= 1; step >>= 1;
mask >>= 1; if (delta >= step) {
nibble |= 2;
delta -= step;
}
step >>= 1;
if (delta >= step) {
nibble |= 1;
delta -= step;
} }
diff -= delta;
if (nibble & 8) if (nibble & 8)
c->prev_sample -= diff; c->prev_sample -= diff;
......
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