[FFmpeg-devel] [PATCH 07/11] mov: honor tmcd flags while extracting timecode meta.
Clément Bœsch
ubitux at gmail.com
Mon Jan 16 17:30:10 CET 2012
From: Clément Bœsch <clement.boesch at smartjog.com>
---
libavformat/isom.h | 1 +
libavformat/mov.c | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 8f92cae..52ce585 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -127,6 +127,7 @@ typedef struct MOVStreamContext {
int dts_shift; ///< dts shift when ctts is negative
uint32_t palette[256];
int has_palette;
+ uint32_t tmcd_flags; ///< tmcd track flags
} MOVStreamContext;
typedef struct MOVContext {
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 407df4e..1677094 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1382,9 +1382,11 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
st->codec->height = sc->height;
} else {
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
+ MOVStreamContext *tmcd_ctx = st->priv_data;
int val;
avio_rb32(pb); /* reserved */
val = avio_rb32(pb); /* flags */
+ tmcd_ctx->tmcd_flags = val;
if (val & 1)
st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE;
avio_rb32(pb); /* time scale */
@@ -2632,13 +2634,12 @@ finish:
}
static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st,
- uint32_t value)
+ uint32_t value, int flags)
{
AVTimecode tc;
char buf[AVTIMECODE_STR_LEN];
AVRational rate = {st->codec->time_base.den,
st->codec->time_base.num};
- int flags = st->codec->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE ? AVTIMECODE_FLAG_DROPFRAME : 0;
int ret = av_init_timecode(s, &tc, rate, flags, 0);
if (ret < 0)
return ret;
@@ -2650,6 +2651,7 @@ static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st,
static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
{
MOVStreamContext *sc = st->priv_data;
+ int flags = 0;
int64_t cur_pos = avio_tell(sc->pb);
uint32_t value;
@@ -2659,12 +2661,16 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
avio_seek(sc->pb, st->index_entries->pos, SEEK_SET);
value = avio_rb32(s->pb);
+ if (sc->tmcd_flags & 0x0001) flags |= AVTIMECODE_FLAG_DROPFRAME;
+ if (sc->tmcd_flags & 0x0002) flags |= AVTIMECODE_FLAG_24HOURSMAX;
+ if (sc->tmcd_flags & 0x0004) flags |= AVTIMECODE_FLAG_NEGATIVEOK;
+
/* Assume Counter flag is set to 1 in tmcd track (even though it is likely
* not the case) and thus assume "frame number format" instead of QT one.
* No sample with tmcd track can be found with a QT timecode at the moment,
* despite what the tmcd track "suggests" (Counter flag set to 0 means QT
* format). */
- parse_timecode_in_framenum_format(s, st, value);
+ parse_timecode_in_framenum_format(s, st, value, flags);
avio_seek(sc->pb, cur_pos, SEEK_SET);
return 0;
--
1.7.7.3
More information about the ffmpeg-devel
mailing list