[FFmpeg-cvslog] adpcm: convert adpcm_4xm to bytestream2.

Ronald S. Bultje git at videolan.org
Tue Mar 20 00:16:49 CET 2012


ffmpeg | branch: master | Ronald S. Bultje <rsbultje at gmail.com> | Sat Mar 17 12:55:07 2012 -0700| [689be85a9aa9323ff498519a6de5d86138a06eed] | committer: Ronald S. Bultje

adpcm: convert adpcm_4xm to bytestream2.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=689be85a9aa9323ff498519a6de5d86138a06eed
---

 libavcodec/adpcm.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 9fd5724..ed6d0c5 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -647,18 +647,22 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
         break;
     case CODEC_ID_ADPCM_4XM:
         for (i = 0; i < avctx->channels; i++)
-            c->status[i].predictor= (int16_t)bytestream_get_le16(&src);
+            c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
 
         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);
+            c->status[i].step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
+            if (c->status[i].step_index > 88u) {
+                av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
+                       i, c->status[i].step_index);
+                return AVERROR_INVALIDDATA;
+            }
         }
 
         for (i = 0; i < avctx->channels; i++) {
             samples = (short *)c->frame.data[0] + i;
             cs = &c->status[i];
-            for (n = nb_samples >> 1; n > 0; n--, src++) {
-                uint8_t v = *src;
+            for (n = nb_samples >> 1; n > 0; n--) {
+                int v = bytestream2_get_byteu(&gb);
                 *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 4);
                 samples += avctx->channels;
                 *samples = adpcm_ima_expand_nibble(cs, v >> 4  , 4);



More information about the ffmpeg-cvslog mailing list