[FFmpeg-devel] [PATCH]Do not allow writing invalid wav channel layouts by default

Carl Eugen Hoyos cehoyos at ag.or.at
Wed Apr 9 21:16:09 CEST 2014


Hi!

Neither WMP nor QT play wav files if the channel layout is set to an 
unspecifed value (like downmix as defined in FFmpeg). Attached 
patch makes sure that such invalid channel masks are only written 
with -strict -1.

This addresses ticket #3543.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index c3e3e66..6c91cb6 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -172,12 +172,14 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
     }
     /* write WAVEFORMATEXTENSIBLE extensions */
     if (waveformatextensible) {
+        int write_channel_mask = enc->strict_std_compliance < FF_COMPLIANCE_NORMAL ||
+                                 enc->channel_layout < 0x40000;
         /* 22 is WAVEFORMATEXTENSIBLE size */
         avio_wl16(pb, riff_extradata - riff_extradata_start + 22);
         /* ValidBitsPerSample || SamplesPerBlock || Reserved */
         avio_wl16(pb, bps);
         /* dwChannelMask */
-        avio_wl32(pb, enc->channel_layout);
+        avio_wl32(pb, write_channel_mask ? enc->channel_layout : 0);
         /* GUID + next 3 */
         if (enc->codec_id == AV_CODEC_ID_EAC3) {
             ff_put_guid(pb, get_codec_guid(enc->codec_id, ff_codec_wav_guids));
diff --git a/libavformat/version.h b/libavformat/version.h
index fe54380..3d2bb6d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 55
 #define LIBAVFORMAT_VERSION_MINOR 36
-#define LIBAVFORMAT_VERSION_MICRO 102
+#define LIBAVFORMAT_VERSION_MICRO 103
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \


More information about the ffmpeg-devel mailing list