diff mbox series

[FFmpeg-devel,v2,1/6] avformat/riff: prevent muxing adpcm_swf with a variable block size

Message ID 20201019224335.11874-2-zane@zanevaniperen.com
State Accepted
Headers show
Series Fix adpcm_swf support in WAV. | expand

Checks

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

Commit Message

Zane van Iperen Oct. 19, 2020, 10:44 p.m. UTC
Prefer to error than to create a broken file. Closes ticket #5829.

Effectively disables remuxing adpcm_swf from flv -> wav.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavformat/riffenc.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 04a21fcffa..33e0b6fc0a 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -65,6 +65,12 @@  int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
     if (!par->codec_tag || par->codec_tag > 0xffff)
         return -1;
 
+    if (par->codec_id == AV_CODEC_ID_ADPCM_SWF && par->block_align == 0) {
+        av_log(s, AV_LOG_ERROR, "%s can only be written to WAVE with a constant frame size\n",
+               avcodec_get_name(s->streams[0]->codecpar->codec_id));
+        return AVERROR(EINVAL);
+    }
+
     /* We use the known constant frame size for the codec if known, otherwise
      * fall back on using AVCodecContext.frame_size, which is not as reliable
      * for indicating packet duration. */