adpcm: convert ima_ws to bytestream2.

This commit is contained in:
Ronald S. Bultje
2012-03-17 14:17:48 -07:00
parent 74d7ac95fb
commit 16b7a5e241

View File

@ -809,28 +809,29 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
} }
break; break;
case CODEC_ID_ADPCM_IMA_WS: case CODEC_ID_ADPCM_IMA_WS:
for (channel = 0; channel < avctx->channels; channel++) { if (c->vqa_version == 3) {
const uint8_t *src0; for (channel = 0; channel < avctx->channels; channel++) {
int src_stride; int16_t *smp = samples + channel;
int16_t *smp = samples + channel;
if (c->vqa_version == 3) { for (n = nb_samples / 2; n > 0; n--) {
src0 = src + channel * buf_size / 2; int v = bytestream2_get_byteu(&gb);
src_stride = 1; *smp = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
} else { smp += avctx->channels;
src0 = src + channel; *smp = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
src_stride = avctx->channels; smp += avctx->channels;
}
} }
} else {
for (n = nb_samples / 2; n > 0; n--) { for (n = nb_samples / 2; n > 0; n--) {
uint8_t v = *src0; for (channel = 0; channel < avctx->channels; channel++) {
src0 += src_stride; int v = bytestream2_get_byteu(&gb);
*smp = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
smp += avctx->channels; samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
*smp = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); }
smp += avctx->channels; samples += avctx->channels;
} }
} }
src = buf + buf_size; bytestream2_seek(&gb, 0, SEEK_END);
break; break;
case CODEC_ID_ADPCM_XA: case CODEC_ID_ADPCM_XA:
while (buf_size >= 128) { while (buf_size >= 128) {