]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/adpcm: take into account block_align when decoding ADPCM_PSX
authorPaul B Mahol <onemda@gmail.com>
Fri, 11 Sep 2020 11:28:12 +0000 (13:28 +0200)
committerPaul B Mahol <onemda@gmail.com>
Sat, 12 Sep 2020 12:52:31 +0000 (14:52 +0200)
Should reduce decoding overhead.

libavcodec/adpcm.c

index 71e37efde74daabbf48940df3014aa96f577285f..e409a3aa6a7321979a45ff96fc46fb9cb56ba8cc 100644 (file)
@@ -1966,11 +1966,13 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
         }
         break;
     case AV_CODEC_ID_ADPCM_PSX:
+        for (int block = 0; block < avpkt->size / FFMAX(avctx->block_align, 16 * avctx->channels); block++) {
+            int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * avctx->channels) / (16 * avctx->channels);
         for (channel = 0; channel < avctx->channels; channel++) {
-            samples = samples_p[channel];
+            samples = samples_p[channel] + block * nb_samples_per_block;
 
             /* Read in every sample for this channel.  */
-            for (i = 0; i < nb_samples / 28; i++) {
+            for (i = 0; i < nb_samples_per_block / 28; i++) {
                 int filter, shift, flag, byte;
 
                 filter = bytestream2_get_byteu(&gb);
@@ -2001,6 +2003,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
                 }
             }
         }
+        }
         break;
     case AV_CODEC_ID_ADPCM_ARGO:
         /*