summaryrefslogtreecommitdiff
path: root/libavformat/riff.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/riff.c')
-rw-r--r--libavformat/riff.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/libavformat/riff.c b/libavformat/riff.c
index e17980a00a..cea8c1349a 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -2,20 +2,20 @@
* RIFF codec tags
* Copyright (c) 2000 Fabrice Bellard
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -40,6 +40,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_H263, MKTAG('L', '2', '6', '3') },
{ CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') },
{ CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') },
+ { CODEC_ID_H263, MKTAG('M', '2', '6', '3') },
{ CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
{ CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */
{ CODEC_ID_H261, MKTAG('H', '2', '6', '1') },
@@ -83,6 +84,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') },
{ CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') },
{ CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */
+ { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'X') },
{ CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
{ CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') },
{ CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') },
@@ -107,6 +109,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') },
{ CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') }, /* Canopus DV */
{ CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') }, /* Canopus DV */
+ { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', '5') }, /* Canopus DV */
{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') },
{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') },
{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') },
@@ -148,6 +151,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') },
{ CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') },
{ CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') }, /* Paradigm Matrix M-JPEG Codec */
+ { CODEC_ID_MJPEG, MKTAG('M', 'M', 'J', 'P') },
{ CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
{ CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
{ CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
@@ -180,6 +184,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', 'B') },
{ CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'V', '9') },
{ CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') },
+ { CODEC_ID_RAWVIDEO, MKTAG('a', 'u', 'v', '2') },
{ CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') },
{ CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') },
{ CODEC_ID_R210, MKTAG('r', '2', '1', '0') },
@@ -321,6 +326,14 @@ const AVCodecTag ff_codec_wav_tags[] = {
{ CODEC_ID_NONE, 0 },
};
+const AVCodecGuid ff_codec_wav_guids[] = {
+ {CODEC_ID_AC3, {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
+ {CODEC_ID_ATRAC3P, {0xBF,0xAA,0x23,0xE9,0x58,0xCB,0x71,0x44,0xA1,0x19,0xFF,0xFA,0x01,0xE4,0xCE,0x62}},
+ {CODEC_ID_EAC3, {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}},
+ {CODEC_ID_MP2, {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
+ {CODEC_ID_NONE}
+};
+
#if CONFIG_MUXERS
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{
@@ -486,7 +499,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;
@@ -495,15 +507,29 @@ 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;
}
@@ -520,7 +546,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 == CODEC_ID_AAC_LATM) {
/* channels and sample_rate values are those prior to applying SBR and/or PS */
codec->channels = 0;
@@ -590,3 +615,19 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz
*au_scale /= gcd;
*au_rate /= gcd;
}
+
+void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
+{
+ assert(sizeof(*g) == 16);
+ avio_read(s, *g, sizeof(*g));
+}
+
+enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
+{
+ int i;
+ for (i = 0; guids[i].id != CODEC_ID_NONE; i++) {
+ if (!ff_guidcmp(guids[i].guid, guid))
+ return guids[i].id;
+ }
+ return CODEC_ID_NONE;
+}