]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/adpcm_swf: set block_align when encoding
authorZane van Iperen <zane@zanevaniperen.com>
Fri, 16 Oct 2020 03:51:58 +0000 (13:51 +1000)
committerZane van Iperen <zane@zanevaniperen.com>
Wed, 21 Oct 2020 01:26:38 +0000 (11:26 +1000)
Allows it to be muxed to WAVs.

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

index b2be83b84e34a4402c699d175f11f1d0a3ccc42a..9e0bb831e8eb165e1e7b0b113b9cb474d6206a20 100644 (file)
@@ -154,6 +154,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
             return AVERROR(EINVAL);
         }
         avctx->frame_size = 512 * (avctx->sample_rate / 11025);
+        avctx->block_align = (2 + avctx->channels * (22 + 4 * (avctx->frame_size - 1)) + 7) / 8;
         break;
     case AV_CODEC_ID_ADPCM_IMA_SSI:
         avctx->frame_size  = s->block_size * 2 / avctx->channels;
@@ -550,10 +551,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     samples_p = (int16_t **)frame->extended_data;
     st = avctx->channels == 2;
 
-    if (avctx->codec_id == AV_CODEC_ID_ADPCM_SWF)
-        pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) + 7) / 8;
-    else if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
-             avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM)
+    if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
+        avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM)
         pkt_size = (frame->nb_samples * avctx->channels) / 2;
     else
         pkt_size = avctx->block_align;