|
|
@ -1287,48 +1287,47 @@ static int adpcm_decode_frame(AVCodecContext *avctx, |
|
|
|
signmask = 1 << (nb_bits-1); |
|
|
|
signmask = 1 << (nb_bits-1); |
|
|
|
|
|
|
|
|
|
|
|
while (get_bits_count(&gb) <= size - 22*avctx->channels) { |
|
|
|
while (get_bits_count(&gb) <= size - 22*avctx->channels) { |
|
|
|
for (i = 0; i < avctx->channels; i++) { |
|
|
|
|
|
|
|
*samples++ = c->status[i].predictor = get_sbits(&gb, 16); |
|
|
|
|
|
|
|
c->status[i].step_index = get_bits(&gb, 6); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < avctx->channels; i++) { |
|
|
|
for (i = 0; i < avctx->channels; i++) { |
|
|
|
// similar to IMA adpcm
|
|
|
|
*samples++ = c->status[i].predictor = get_sbits(&gb, 16); |
|
|
|
int delta = get_bits(&gb, nb_bits); |
|
|
|
c->status[i].step_index = get_bits(&gb, 6); |
|
|
|
int step = step_table[c->status[i].step_index]; |
|
|
|
} |
|
|
|
long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
|
|
|
|
|
|
|
|
int k = k0; |
|
|
|
for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) { |
|
|
|
|
|
|
|
int i; |
|
|
|
do { |
|
|
|
|
|
|
|
if (delta & k) |
|
|
|
for (i = 0; i < avctx->channels; i++) { |
|
|
|
vpdiff += step; |
|
|
|
// similar to IMA adpcm
|
|
|
|
step >>= 1; |
|
|
|
int delta = get_bits(&gb, nb_bits); |
|
|
|
k >>= 1; |
|
|
|
int step = step_table[c->status[i].step_index]; |
|
|
|
} while(k); |
|
|
|
long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
|
|
|
|
vpdiff += step; |
|
|
|
int k = k0; |
|
|
|
|
|
|
|
|
|
|
|
if (delta & signmask) |
|
|
|
do { |
|
|
|
c->status[i].predictor -= vpdiff; |
|
|
|
if (delta & k) |
|
|
|
else |
|
|
|
vpdiff += step; |
|
|
|
c->status[i].predictor += vpdiff; |
|
|
|
step >>= 1; |
|
|
|
|
|
|
|
k >>= 1; |
|
|
|
c->status[i].step_index += table[delta & (~signmask)]; |
|
|
|
} while(k); |
|
|
|
|
|
|
|
vpdiff += step; |
|
|
|
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); |
|
|
|
|
|
|
|
c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767); |
|
|
|
if (delta & signmask) |
|
|
|
|
|
|
|
c->status[i].predictor -= vpdiff; |
|
|
|
*samples++ = c->status[i].predictor; |
|
|
|
else |
|
|
|
if (samples >= samples_end) { |
|
|
|
c->status[i].predictor += vpdiff; |
|
|
|
av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); |
|
|
|
|
|
|
|
return -1; |
|
|
|
c->status[i].step_index += table[delta & (~signmask)]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); |
|
|
|
|
|
|
|
c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*samples++ = c->status[i].predictor; |
|
|
|
|
|
|
|
if (samples >= samples_end) { |
|
|
|
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
src += buf_size; |
|
|
|
src += buf_size; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|