summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorPeter Ross <pross@xvid.org>2013-04-20 13:36:46 +0200
committerDiego Biurrun <diego@biurrun.de>2013-04-21 18:20:30 +0200
commita3bf80a5aea577663354bd538e345b283bcb73de (patch)
tree745def9a3680df120073ac292d1bb7abdde720a1 /libavformat
parente544782623caf1eb4b2429e9c4f35d6b627accba (diff)
riff: Perform full lookup on WAVEFORMATEXTENSIBLE subformat guid
Signed-off-by: Luca Barbato <lu_zero@gentoo.org> Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/riff.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 6bf03bbd25..465988c0e0 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -687,7 +687,6 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
id = avio_rl16(pb);
codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->codec_tag = id;
codec->channels = avio_rl16(pb);
codec->sample_rate = avio_rl32(pb);
codec->bit_rate = avio_rl32(pb) * 8;
@@ -696,15 +695,36 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
codec->bits_per_coded_sample = 8;
} else
codec->bits_per_coded_sample = avio_rl16(pb);
+ if (id == 0xFFFE) {
+ codec->codec_tag = 0;
+ } else {
+ codec->codec_tag = id;
+ codec->codec_id = ff_wav_codec_get_id(id,
+ codec->bits_per_coded_sample);
+ }
if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */
int cbSize = avio_rl16(pb); /* cbSize */
size -= 18;
cbSize = FFMIN(size, cbSize);
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
+ ff_asf_guid subformat;
codec->bits_per_coded_sample = avio_rl16(pb);
codec->channel_layout = avio_rl32(pb); /* dwChannelMask */
- id = avio_rl32(pb); /* 4 first bytes of GUID */
- avio_skip(pb, 12); /* skip end of GUID */
+
+ ff_get_guid(pb, &subformat);
+ if (!memcmp(subformat + 4,
+ (const uint8_t[]){ FF_MEDIASUBTYPE_BASE_GUID }, 12)) {
+ codec->codec_tag = AV_RL32(subformat);
+ codec->codec_id = ff_wav_codec_get_id(codec->codec_tag,
+ codec->bits_per_coded_sample);
+ } else {
+ codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids,
+ subformat);
+ if (!codec->codec_id)
+ av_log(codec, AV_LOG_WARNING,
+ "unknown subformat: "FF_PRI_GUID"\n",
+ FF_ARG_GUID(subformat));
+ }
cbSize -= 22;
size -= 22;
}
@@ -723,7 +743,6 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
if (size > 0)
avio_skip(pb, size);
}
- codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {
/* Channels and sample_rate values are those prior to applying SBR
* and/or PS. */