From 00d7555f3468193a761c0534df6742646b15829c Mon Sep 17 00:00:00 2001 From: Thomas Volkert Date: Wed, 17 Dec 2014 12:04:37 +0100 Subject: wavdec: RIFX file format support Signed-off-by: Michael Niedermayer --- libavformat/riffdec.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'libavformat/riffdec.c') diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index 88e2229..edaf146 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -80,23 +80,37 @@ static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c) } } -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size) +/* "big_endian" values are needed for RIFX file format */ +int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size, int big_endian) { int id; if (size < 14) avpriv_request_sample(codec, "wav header size < 14"); - id = avio_rl16(pb); codec->codec_type = AVMEDIA_TYPE_AUDIO; - codec->channels = avio_rl16(pb); - codec->sample_rate = avio_rl32(pb); - codec->bit_rate = avio_rl32(pb) * 8; - codec->block_align = avio_rl16(pb); + if (!big_endian) { + id = avio_rl16(pb); + codec->channels = avio_rl16(pb); + codec->sample_rate = avio_rl32(pb); + codec->bit_rate = avio_rl32(pb) * 8; + codec->block_align = avio_rl16(pb); + } else { + id = avio_rb16(pb); + codec->channels = avio_rb16(pb); + codec->sample_rate = avio_rb32(pb); + codec->bit_rate = avio_rb32(pb) * 8; + codec->block_align = avio_rb16(pb); + } if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */ codec->bits_per_coded_sample = 8; - } else - codec->bits_per_coded_sample = avio_rl16(pb); + } else { + if (!big_endian) { + codec->bits_per_coded_sample = avio_rl16(pb); + } else { + codec->bits_per_coded_sample = avio_rb16(pb); + } + } if (id == 0xFFFE) { codec->codec_tag = 0; } else { @@ -106,6 +120,10 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size) } if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */ int cbSize = avio_rl16(pb); /* cbSize */ + if (big_endian) { + avpriv_report_missing_feature(codec, "WAVEFORMATEX support for RIFX files\n"); + return AVERROR_PATCHWELCOME; + } size -= 18; cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ -- cgit v1.1