]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/adpcm_ima_amv: restrict to 1 channel
authorZane van Iperen <zane@zanevaniperen.com>
Mon, 2 Nov 2020 05:47:21 +0000 (15:47 +1000)
committerZane van Iperen <zane@zanevaniperen.com>
Mon, 9 Nov 2020 04:58:30 +0000 (14:58 +1000)
The format doesn't allow for anything else.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
libavcodec/adpcm.c
libavcodec/utils.c

index d018c1f91bbe012c3ae702ad6afa75dde4a073e4..7b618dba17f4c0e3721e84cd2a8cf7792f393c63 100644 (file)
@@ -110,6 +110,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
     unsigned int max_channels = 2;
 
     switch(avctx->codec->id) {
+    case AV_CODEC_ID_ADPCM_IMA_AMV:
     case AV_CODEC_ID_ADPCM_IMA_CUNNING:
         max_channels = 1;
         break;
@@ -1681,6 +1682,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
         }
         break;
     case AV_CODEC_ID_ADPCM_IMA_AMV:
+        av_assert0(avctx->channels == 1);
+
         c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
         c->status[0].step_index = bytestream2_get_byteu(&gb);
         bytestream2_skipu(&gb, 5);
@@ -1690,7 +1693,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
             return AVERROR_INVALIDDATA;
         }
 
-        for (n = nb_samples >> (1 - st); n > 0; n--) {
+        for (n = nb_samples >> 1; n > 0; n--) {
             int v = bytestream2_get_byteu(&gb);
 
             *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3);
index db51512e15323bea131a0762478670a94df9644b..008e95c2393fce63cac42cd968952f9caa96195e 100644 (file)
@@ -1696,7 +1696,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
             case AV_CODEC_ID_ADPCM_IMA_SMJPEG:
                 return (frame_bytes - 4) * 2 / ch;
             case AV_CODEC_ID_ADPCM_IMA_AMV:
-                return (frame_bytes - 8) * 2 / ch;
+                return (frame_bytes - 8) * 2;
             case AV_CODEC_ID_ADPCM_THP:
             case AV_CODEC_ID_ADPCM_THP_LE:
                 if (extradata)