diff mbox series

[FFmpeg-devel,3/5] avcodec/adpcm_swf: set block_align when encoding

Message ID 20201016062049.2746-4-zane@zanevaniperen.com
State Superseded
Headers show
Series Fix adpcm_swf support in WAV.
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Zane van Iperen Oct. 16, 2020, 6:22 a.m. UTC
Allows it to be muxed to WAVs.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavcodec/adpcmenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Anton Khirnov Oct. 19, 2020, 2:11 p.m. UTC | #1
Quoting Zane van Iperen (2020-10-16 08:22:41)
> Allows it to be muxed to WAVs.
> 
> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
> ---
>  libavcodec/adpcmenc.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Looks sane
diff mbox series

Patch

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 24bd31c4a9..00c7df3cd1 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -144,6 +144,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 = BLKSIZE * 2 / avctx->channels;
@@ -540,9 +541,7 @@  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 ||
+    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