aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mov.c
diff options
context:
space:
mode:
authorClément Bœsch <clement.boesch@smartjog.com>2012-06-04 12:06:23 +0200
committerClément Bœsch <ubitux@gmail.com>2012-06-11 07:40:58 +0200
commit20e46aafbd27e2bcd51fb5310757ee920e258634 (patch)
tree753059fd81b4fc4850785c1f684540ccd32cdca3 /libavformat/mov.c
parent1ec23d9c02079bae2ee02a3efe7da6f628781f82 (diff)
downloadffmpeg-20e46aafbd27e2bcd51fb5310757ee920e258634.tar.gz
mov: export orphan tmcd track metadata to global format metadata.
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3ac1230b23..5eeb3571f5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2872,6 +2872,42 @@ static int mov_read_close(AVFormatContext *s)
return 0;
}
+static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
+{
+ int i, j;
+
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+ MOVStreamContext *sc = st->priv_data;
+
+ if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
+ continue;
+ for (j = 0; j < sc->trefs_count; j++)
+ if (tmcd_id == sc->trefs[j])
+ return 1;
+ }
+ return 0;
+}
+
+/* look for a tmcd track not referenced by any video track, and export it globally */
+static void export_orphan_timecode(AVFormatContext *s)
+{
+ int i;
+
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+
+ if (st->codec->codec_tag == MKTAG('t','m','c','d') &&
+ !tmcd_is_referenced(s, i + 1)) {
+ AVDictionaryEntry *tcr = av_dict_get(st->metadata, "timecode", NULL, 0);
+ if (tcr) {
+ av_dict_set(&s->metadata, "timecode", tcr->value, 0);
+ break;
+ }
+ }
+ }
+}
+
static int mov_read_header(AVFormatContext *s)
{
MOVContext *mov = s->priv_data;
@@ -2922,6 +2958,7 @@ static int mov_read_header(AVFormatContext *s)
av_dict_set(&st->metadata, "timecode", tcr->value, 0);
}
}
+ export_orphan_timecode(s);
if (mov->trex_data) {
for (i = 0; i < s->nb_streams; i++) {