From bf87d582b1cbbb5604d4e1521c4b674206e605a0 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 9 Apr 2014 22:31:40 +0200 Subject: [PATCH 1/3] Do not allow writing invalid wav channel layouts by default. Neither WMP nor QT play wav files with too large channel layouts. Fixes ticket #3543. --- libavformat/riffenc.c | 4 +++- libavformat/version.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index c3e3e66b37..6c91cb693a 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 fe54380304..3d2bb6d008 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, \ From 2a3ff9fbbacf1429cd5ba2d7604b823c8d16a34f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 9 Apr 2014 22:33:29 +0200 Subject: [PATCH 2/3] Remove an unneeded include of avassert.h from amr.c. --- libavformat/amr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/amr.c b/libavformat/amr.c index db9bb4e59d..0d395c4092 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -26,7 +26,6 @@ Only mono files are supported. */ -#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "avformat.h" #include "internal.h" From cf79f202757b0444f448fe472595ac140d7a3e77 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 9 Apr 2014 22:34:04 +0200 Subject: [PATCH 3/3] Fix a typo in amr.c. --- libavformat/amr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/amr.c b/libavformat/amr.c index 0d395c4092..47c1244b1d 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -115,7 +115,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); } - // FIXME this is wrong, this should rather be in a AVParset + // FIXME this is wrong, this should rather be in a AVParser toc = avio_r8(s->pb); mode = (toc >> 3) & 0x0F;