summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-05-28 13:01:41 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-05-28 13:02:19 +0200
commit579e2b2874aeaa9cfdeed1fd1408767e33a63029 (patch)
tree021938ef7311d1439e74b710d721a8668c41d712
parent1c0ce2d4e0e70fcc42aa73fb5284f621025bb6c4 (diff)
parent23f741f79327e31be7b2a75ebb2e02111e06e52f (diff)
downloadffmpeg-579e2b2874aeaa9cfdeed1fd1408767e33a63029.tar.gz
Merge commit '23f741f79327e31be7b2a75ebb2e02111e06e52f'
* commit '23f741f79327e31be7b2a75ebb2e02111e06e52f': matroskadec: parse the channel layout mask for FLAC Conflicts: libavformat/oggparsevorbis.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/Makefile3
-rw-r--r--libavformat/flacdec.c2
-rw-r--r--libavformat/matroskadec.c38
-rw-r--r--libavformat/oggdec.h3
-rw-r--r--libavformat/oggparsecelt.c2
-rw-r--r--libavformat/oggparseflac.c2
-rw-r--r--libavformat/oggparseogm.c2
-rw-r--r--libavformat/oggparseopus.c2
-rw-r--r--libavformat/oggparsespeex.c2
-rw-r--r--libavformat/oggparsetheora.c2
-rw-r--r--libavformat/oggparsevorbis.c7
-rw-r--r--libavformat/oggparsevp8.c2
12 files changed, 54 insertions, 13 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile
index c2411ca63c..365481ecb2 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -205,7 +205,8 @@ OBJS-$(CONFIG_LXF_DEMUXER) += lxfdec.o
OBJS-$(CONFIG_M4V_DEMUXER) += m4vdec.o rawdec.o
OBJS-$(CONFIG_M4V_MUXER) += rawenc.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \
- isom.o rmsipr.o
+ isom.o rmsipr.o \
+ oggparsevorbis.o vorbiscomment.o
OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \
isom.o avc.o hevc.o \
flacenc_header.o avlanguage.o wv.o
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 880ad35049..d601c753a3 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -138,7 +138,7 @@ static int flac_read_header(AVFormatContext *s)
if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
AVDictionaryEntry *chmask;
- if (ff_vorbis_comment(s, &s->metadata, buffer, metadata_size)) {
+ if (ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1)) {
av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
}
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 77c4eb0f07..65847fa17b 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -56,6 +56,7 @@
#include "internal.h"
#include "isom.h"
#include "matroska.h"
+#include "oggdec.h"
/* For ff_codec_get_id(). */
#include "riff.h"
#include "rmsipr.h"
@@ -1575,6 +1576,7 @@ static int matroska_parse_flac(AVFormatContext *s,
MatroskaTrack *track,
int *offset)
{
+ AVStream *st = track->stream;
uint8_t *p = track->codec_priv.data;
int size = track->codec_priv.size;
@@ -1586,6 +1588,42 @@ static int matroska_parse_flac(AVFormatContext *s,
*offset = 8;
track->codec_priv.size = 8 + FLAC_STREAMINFO_SIZE;
+ p += track->codec_priv.size;
+ size -= track->codec_priv.size;
+
+ /* parse the remaining metadata blocks if present */
+ while (size >= 4) {
+ int block_last, block_type, block_size;
+
+ flac_parse_block_header(p, &block_last, &block_type, &block_size);
+
+ p += 4;
+ size -= 4;
+ if (block_size > size)
+ return 0;
+
+ /* check for the channel mask */
+ if (block_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
+ AVDictionary *dict = NULL;
+ AVDictionaryEntry *chmask;
+
+ ff_vorbis_comment(s, &dict, p, block_size, 0);
+ chmask = av_dict_get(dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
+ if (chmask) {
+ uint64_t mask = strtol(chmask->value, NULL, 0);
+ if (!mask || mask & ~0x3ffffULL) {
+ av_log(s, AV_LOG_WARNING,
+ "Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
+ } else
+ st->codec->channel_layout = mask;
+ }
+ av_dict_free(&dict);
+ }
+
+ p += block_size;
+ size -= block_size;
+ }
+
return 0;
}
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 231b583770..22647e131f 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -129,7 +129,8 @@ extern const struct ogg_codec ff_theora_codec;
extern const struct ogg_codec ff_vorbis_codec;
extern const struct ogg_codec ff_vp8_codec;
-int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size);
+int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m,
+ const uint8_t *buf, int size, int parse_picture);
static inline int
ogg_find_stream (struct ogg * ogg, int serial)
diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c
index d6e9962650..759734cd5d 100644
--- a/libavformat/oggparsecelt.c
+++ b/libavformat/oggparsecelt.c
@@ -76,7 +76,7 @@ static int celt_header(AVFormatContext *s, int idx)
} else if (priv && priv->extra_headers_left) {
/* Extra headers (vorbiscomment) */
- ff_vorbis_comment(s, &st->metadata, p, os->psize);
+ ff_vorbis_comment(s, &st->metadata, p, os->psize, 1);
priv->extra_headers_left--;
return 1;
} else {
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index f69533f6c1..875de2a3b4 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -68,7 +68,7 @@ flac_header (AVFormatContext * s, int idx)
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
- ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 4, os->psize - 4);
+ ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 4, os->psize - 4, 1);
}
return 1;
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index 95369df89e..508a0dc541 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -111,7 +111,7 @@ ogm_header(AVFormatContext *s, int idx)
} else if (bytestream2_peek_byte(&p) == 3) {
bytestream2_skip(&p, 7);
if (bytestream2_get_bytes_left(&p) > 1)
- ff_vorbis_comment(s, &st->metadata, p.buffer, bytestream2_get_bytes_left(&p) - 1);
+ ff_vorbis_comment(s, &st->metadata, p.buffer, bytestream2_get_bytes_left(&p) - 1, 1);
}
return 1;
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index 75c611413e..7dfb13d5d2 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -78,7 +78,7 @@ static int opus_header(AVFormatContext *avf, int idx)
if (priv->need_comments) {
if (os->psize < 8 || memcmp(packet, "OpusTags", 8))
return AVERROR_INVALIDDATA;
- ff_vorbis_comment(avf, &st->metadata, packet + 8, os->psize - 8);
+ ff_vorbis_comment(avf, &st->metadata, packet + 8, os->psize - 8, 1);
priv->need_comments--;
return 1;
}
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index 1b9de9c95b..69dd62dfdc 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -83,7 +83,7 @@ static int speex_header(AVFormatContext *s, int idx) {
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else
- ff_vorbis_comment(s, &st->metadata, p, os->psize);
+ ff_vorbis_comment(s, &st->metadata, p, os->psize, 1);
spxp->seq++;
return 1;
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index 59df17efba..4a8005f108 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -116,7 +116,7 @@ static int theora_header(AVFormatContext *s, int idx)
}
break;
case 0x81:
- ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, os->psize - 7);
+ ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, os->psize - 7, 1);
case 0x82:
if (!thp->version)
return AVERROR_INVALIDDATA;
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 75de0bdde5..51c5eb321f 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -72,7 +72,8 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
}
int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
- const uint8_t *buf, int size)
+ const uint8_t *buf, int size,
+ int parse_picture)
{
const uint8_t *p = buf;
const uint8_t *end = buf + size;
@@ -137,7 +138,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
* 'METADATA_BLOCK_PICTURE'. This is the preferred and
* recommended way of embedding cover art within VorbisComments."
*/
- if (!strcmp(tt, "METADATA_BLOCK_PICTURE")) {
+ if (!strcmp(tt, "METADATA_BLOCK_PICTURE") && parse_picture) {
int ret;
char *pict = av_malloc(vl);
@@ -256,7 +257,7 @@ static int vorbis_update_metadata(AVFormatContext *s, int idx)
/* New metadata packet; release old data. */
av_dict_free(&st->metadata);
ret = ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7,
- os->psize - 8);
+ os->psize - 8, 1);
if (ret < 0)
return ret;
diff --git a/libavformat/oggparsevp8.c b/libavformat/oggparsevp8.c
index 89295c86a6..b3dd7ab840 100644
--- a/libavformat/oggparsevp8.c
+++ b/libavformat/oggparsevp8.c
@@ -64,7 +64,7 @@ static int vp8_header(AVFormatContext *s, int idx)
case 0x02:
if (p[6] != 0x20)
return AVERROR_INVALIDDATA;
- ff_vorbis_comment(s, &st->metadata, p + 7, os->psize - 7);
+ ff_vorbis_comment(s, &st->metadata, p + 7, os->psize - 7, 1);
break;
default:
av_log(s, AV_LOG_ERROR, "Unknown VP8 header type 0x%02X\n", p[5]);