lavf/mov: simplify timecode track ref.
There can be only one track reference. The multiple tref handling is handled at a different level.
This commit is contained in:
parent
69a1667b06
commit
8d398f40b4
@ -128,9 +128,7 @@ typedef struct MOVStreamContext {
|
|||||||
unsigned drefs_count;
|
unsigned drefs_count;
|
||||||
MOVDref *drefs;
|
MOVDref *drefs;
|
||||||
int dref_id;
|
int dref_id;
|
||||||
unsigned tref_type;
|
int timecode_track;
|
||||||
unsigned trefs_count;
|
|
||||||
uint32_t *trefs;
|
|
||||||
int wrong_dts; ///< dts are wrong due to huge ctts offset (iMovie files)
|
int wrong_dts; ///< dts are wrong due to huge ctts offset (iMovie files)
|
||||||
int width; ///< tkhd width
|
int width; ///< tkhd width
|
||||||
int height; ///< tkhd height
|
int height; ///< tkhd height
|
||||||
|
@ -2698,24 +2698,12 @@ static int mov_read_chan2(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
|
|
||||||
static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
|
||||||
MOVStreamContext *sc;
|
MOVStreamContext *sc;
|
||||||
|
|
||||||
if (c->fc->nb_streams < 1)
|
if (c->fc->nb_streams < 1)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data;
|
sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data;
|
||||||
|
sc->timecode_track = avio_rb32(pb);
|
||||||
if (atom.size < 4)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
sc->trefs_count = atom.size / 4;
|
|
||||||
sc->trefs = av_malloc(sc->trefs_count * sizeof(*sc->trefs));
|
|
||||||
if (!sc->trefs)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
sc->tref_type = atom.type;
|
|
||||||
for (i = 0; i < sc->trefs_count; i++)
|
|
||||||
sc->trefs[i] = avio_rb32(pb);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3077,7 +3065,6 @@ static int mov_read_close(AVFormatContext *s)
|
|||||||
av_freep(&sc->drefs[j].dir);
|
av_freep(&sc->drefs[j].dir);
|
||||||
}
|
}
|
||||||
av_freep(&sc->drefs);
|
av_freep(&sc->drefs);
|
||||||
av_freep(&sc->trefs);
|
|
||||||
if (sc->pb && sc->pb != s->pb)
|
if (sc->pb && sc->pb != s->pb)
|
||||||
avio_close(sc->pb);
|
avio_close(sc->pb);
|
||||||
sc->pb = NULL;
|
sc->pb = NULL;
|
||||||
@ -3105,17 +3092,15 @@ static int mov_read_close(AVFormatContext *s)
|
|||||||
|
|
||||||
static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
|
static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < s->nb_streams; i++) {
|
for (i = 0; i < s->nb_streams; i++) {
|
||||||
AVStream *st = s->streams[i];
|
AVStream *st = s->streams[i];
|
||||||
MOVStreamContext *sc = st->priv_data;
|
MOVStreamContext *sc = st->priv_data;
|
||||||
|
|
||||||
if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
|
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||||
continue;
|
sc->timecode_track == tmcd_id)
|
||||||
for (j = 0; j < sc->trefs_count; j++)
|
return 1;
|
||||||
if (tmcd_id == sc->trefs[j])
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3178,9 +3163,9 @@ static int mov_read_header(AVFormatContext *s)
|
|||||||
for (i = 0; i < s->nb_streams; i++) {
|
for (i = 0; i < s->nb_streams; i++) {
|
||||||
AVStream *st = s->streams[i];
|
AVStream *st = s->streams[i];
|
||||||
MOVStreamContext *sc = st->priv_data;
|
MOVStreamContext *sc = st->priv_data;
|
||||||
if (sc->tref_type == AV_RL32("tmcd") && sc->trefs_count) {
|
if (sc->timecode_track > 0) {
|
||||||
AVDictionaryEntry *tcr;
|
AVDictionaryEntry *tcr;
|
||||||
int tmcd_st_id = sc->trefs[0] - 1;
|
int tmcd_st_id = sc->timecode_track - 1;
|
||||||
|
|
||||||
if (tmcd_st_id < 0 || tmcd_st_id >= s->nb_streams)
|
if (tmcd_st_id < 0 || tmcd_st_id >= s->nb_streams)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user