summaryrefslogtreecommitdiff
path: root/libavcodec/adpcm.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-09-09 18:43:19 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-09-29 16:54:00 -0400
commit943f4db5520c741ccc8f991374a608fc14735e14 (patch)
treeca33d96ac9f9051247faf213fe18b57fe354f41f /libavcodec/adpcm.c
parent119974b164dd2d09031c61c87c8c59a1819f3a90 (diff)
adpcm_4xm: process planar packets sequentially rather than simultaneously.
Also properly clip the right channel step_index.
Diffstat (limited to 'libavcodec/adpcm.c')
-rw-r--r--libavcodec/adpcm.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 80e36e536f..57f83a7d61 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -463,30 +463,28 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
}
break;
case CODEC_ID_ADPCM_4XM:
- cs = &(c->status[0]);
- c->status[0].predictor= (int16_t)bytestream_get_le16(&src);
- if(st){
- c->status[1].predictor= (int16_t)bytestream_get_le16(&src);
- }
- c->status[0].step_index= (int16_t)bytestream_get_le16(&src);
- if(st){
- c->status[1].step_index= (int16_t)bytestream_get_le16(&src);
- }
- if (cs->step_index < 0) cs->step_index = 0;
- if (cs->step_index > 88) cs->step_index = 88;
+ for (i = 0; i < avctx->channels; i++)
+ c->status[i].predictor= (int16_t)bytestream_get_le16(&src);
- m= (buf_size - (src - buf))>>st;
- for(i=0; i<m; i++) {
- *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4);
- if (st)
- *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] & 0x0F, 4);
- *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] >> 4, 4);
- if (st)
- *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] >> 4, 4);
+ for (i = 0; i < avctx->channels; i++) {
+ c->status[i].step_index= (int16_t)bytestream_get_le16(&src);
+ c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
}
- src += m<<st;
+ m= (buf_size - (src - buf))>>st;
+ for (i = 0; i < avctx->channels; i++) {
+ samples = (short*)data + i;
+ cs = &c->status[i];
+ for (n = 0; n < m; n++) {
+ uint8_t v = *src++;
+ *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 4);
+ samples += avctx->channels;
+ *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 4);
+ samples += avctx->channels;
+ }
+ }
+ samples -= (avctx->channels - 1);
break;
case CODEC_ID_ADPCM_MS:
if (avctx->block_align != 0 && buf_size > avctx->block_align)