diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2012-03-17 14:54:18 -0700 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2012-03-18 15:33:15 -0700 |
commit | e60d09918cd7032b3f5fa00364812e486f0be568 (patch) | |
tree | 37b92086f877c9118365c99f5ef2b6d7592dc707 /libavcodec/adpcm.c | |
parent | 4a876eba8db8366aa43c63a9dc7e239ad106526e (diff) | |
download | ffmpeg-e60d09918cd7032b3f5fa00364812e486f0be568.tar.gz |
adpcm: convert ea_maxis_xa to bytestream2.
Diffstat (limited to 'libavcodec/adpcm.c')
-rw-r--r-- | libavcodec/adpcm.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index cc56b28993..d5dc8bab70 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -413,7 +413,7 @@ static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf, nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch; break; case CODEC_ID_ADPCM_EA_MAXIS_XA: - nb_samples = ((buf_size - ch) / (2 * ch)) * 2 * ch; + nb_samples = (buf_size - ch) / ch * 2; break; case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: @@ -921,15 +921,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int coeff[2][2], shift[2]; for(channel = 0; channel < avctx->channels; channel++) { + int byte = bytestream2_get_byteu(&gb); for (i=0; i<2; i++) - coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i]; - shift[channel] = 20 - (*src & 0x0F); - src++; + coeff[channel][i] = ea_adpcm_table[(byte >> 4) + 4*i]; + shift[channel] = 20 - (byte & 0x0F); } for (count1 = 0; count1 < nb_samples / 2; count1++) { + int byte[2]; + + byte[0] = bytestream2_get_byteu(&gb); + if (st) byte[1] = bytestream2_get_byteu(&gb); for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */ for(channel = 0; channel < avctx->channels; channel++) { - int32_t sample = sign_extend(src[channel] >> i, 4) << shift[channel]; + int sample = sign_extend(byte[channel] >> i, 4) << shift[channel]; sample = (sample + c->status[channel].sample1 * coeff[channel][0] + c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8; @@ -938,10 +942,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = c->status[channel].sample1; } } - src+=avctx->channels; } - /* consume whole packet */ - src = buf + buf_size; + bytestream2_seek(&gb, 0, SEEK_END); break; } case CODEC_ID_ADPCM_EA_R1: |