Merge commit '5b41eb91e0083755de8c35e8cd005896ec3ab31f'
* commit '5b41eb91e0083755de8c35e8cd005896ec3ab31f': mov: Parse tmcd extradata Conflicts: libavformat/mov.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
d3ff77023e
@ -1485,6 +1485,33 @@ static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb,
|
|||||||
st->codec->height = sc->height;
|
st->codec->height = sc->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
|
||||||
|
AVStream *st, MOVStreamContext *sc,
|
||||||
|
int size)
|
||||||
|
{
|
||||||
|
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
|
||||||
|
st->codec->extradata_size = size;
|
||||||
|
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
if (!st->codec->extradata)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
avio_read(pb, st->codec->extradata, size);
|
||||||
|
if (size > 16) {
|
||||||
|
MOVStreamContext *tmcd_ctx = st->priv_data;
|
||||||
|
int val;
|
||||||
|
val = AV_RB32(st->codec->extradata + 4);
|
||||||
|
tmcd_ctx->tmcd_flags = val;
|
||||||
|
if (val & 1)
|
||||||
|
st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE;
|
||||||
|
st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */
|
||||||
|
st->codec->time_base.num = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* other codec type, just skip (rtp, mp4s ...) */
|
||||||
|
avio_skip(pb, size);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
|
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
|
||||||
AVStream *st, MOVStreamContext *sc)
|
AVStream *st, MOVStreamContext *sc)
|
||||||
{
|
{
|
||||||
@ -1598,7 +1625,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
|
|||||||
pseudo_stream_id++) {
|
pseudo_stream_id++) {
|
||||||
//Parsing Sample description table
|
//Parsing Sample description table
|
||||||
enum AVCodecID id;
|
enum AVCodecID id;
|
||||||
int dref_id = 1;
|
int ret, dref_id = 1;
|
||||||
MOVAtom a = { AV_RL32("stsd") };
|
MOVAtom a = { AV_RL32("stsd") };
|
||||||
int64_t start_pos = avio_tell(pb);
|
int64_t start_pos = avio_tell(pb);
|
||||||
int64_t size = avio_rb32(pb); /* size */
|
int64_t size = avio_rb32(pb); /* size */
|
||||||
@ -1637,26 +1664,14 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
|
|||||||
mov_parse_stsd_subtitle(c, pb, st, sc,
|
mov_parse_stsd_subtitle(c, pb, st, sc,
|
||||||
size - (avio_tell(pb) - start_pos));
|
size - (avio_tell(pb) - start_pos));
|
||||||
} else {
|
} else {
|
||||||
if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
|
ret = mov_parse_stsd_data(c, pb, st, sc,
|
||||||
MOVStreamContext *tmcd_ctx = st->priv_data;
|
size - (avio_tell(pb) - start_pos));
|
||||||
int val;
|
if (ret < 0)
|
||||||
avio_rb32(pb); /* reserved */
|
return ret;
|
||||||
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 */
|
|
||||||
avio_rb32(pb); /* frame duration */
|
|
||||||
st->codec->time_base.den = avio_r8(pb); /* number of frame */
|
|
||||||
st->codec->time_base.num = 1;
|
|
||||||
}
|
|
||||||
/* other codec type, just skip (rtp, mp4s, ...) */
|
|
||||||
avio_skip(pb, size - (avio_tell(pb) - start_pos));
|
|
||||||
}
|
}
|
||||||
/* this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...) */
|
/* this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...) */
|
||||||
a.size = size - (avio_tell(pb) - start_pos);
|
a.size = size - (avio_tell(pb) - start_pos);
|
||||||
if (a.size > 8) {
|
if (a.size > 8) {
|
||||||
int ret;
|
|
||||||
if ((ret = mov_read_default(c, pb, a)) < 0)
|
if ((ret = mov_read_default(c, pb, a)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else if (a.size > 0)
|
} else if (a.size > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user