summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-22 12:53:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-04-22 12:53:58 +0200
commit645d0384e85bb40b2307c559d0cfc914438e5bff (patch)
treeb5027c9055731c5ecc6063a258bd98aef1a94f57 /libavformat
parent51286aaffcad24c1ee134bbcea5202e7e5950cc8 (diff)
parentb845f5e97b655de0a191f736594777fec9754cf5 (diff)
Merge commit 'b845f5e97b655de0a191f736594777fec9754cf5'
* commit 'b845f5e97b655de0a191f736594777fec9754cf5': riff: Factor out WAVEFORMATEX parsing Conflicts: libavformat/riff.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/riff.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/libavformat/riff.c b/libavformat/riff.c
index b9957e698b..7ad96a8a76 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -752,6 +752,31 @@ void ff_riff_write_info(AVFormatContext *s)
* WAVEFORMATEX adds 'WORD cbSize' and basically makes itself
* an openended structure.
*/
+
+static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c)
+{
+ ff_asf_guid subformat;
+ int bps = avio_rl16(pb);
+ if (bps)
+ c->bits_per_coded_sample = bps;
+
+ c->channel_layout = avio_rl32(pb); /* dwChannelMask */
+
+ ff_get_guid(pb, &subformat);
+ if (!memcmp(subformat + 4,
+ (const uint8_t[]){ FF_MEDIASUBTYPE_BASE_GUID }, 12)) {
+ c->codec_tag = AV_RL32(subformat);
+ c->codec_id = ff_wav_codec_get_id(c->codec_tag,
+ c->bits_per_coded_sample);
+ } else {
+ c->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
+ if (!c->codec_id)
+ av_log(c, AV_LOG_WARNING,
+ "unknown subformat:"FF_PRI_GUID"\n",
+ FF_ARG_GUID(subformat));
+ }
+}
+
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
{
int id;
@@ -778,26 +803,7 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
size -= 18;
cbSize = FFMIN(size, cbSize);
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
- ff_asf_guid subformat;
- int bps = avio_rl16(pb);
- if (bps)
- codec->bits_per_coded_sample = bps;
- codec->channel_layout = avio_rl32(pb); /* dwChannelMask */
-
- 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));
- }
+ parse_waveformatex(pb, codec);
cbSize -= 22;
size -= 22;
}