avformat/mov: auodetect "use_mfra_for"

Reviewed-by: Mika Raento <mikie@iki.fi>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-10-13 13:35:33 +02:00
parent 8091fe3071
commit 1b54e6b12b
2 changed files with 28 additions and 2 deletions

View File

@ -254,6 +254,7 @@ enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries); int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries);
void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout); void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout);
#define FF_MOV_FLAG_MFRA_AUTO -1
#define FF_MOV_FLAG_MFRA_DTS 1 #define FF_MOV_FLAG_MFRA_DTS 1
#define FF_MOV_FLAG_MFRA_PTS 2 #define FF_MOV_FLAG_MFRA_PTS 2

View File

@ -3270,6 +3270,28 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0; return 0;
} }
static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int ret;
uint8_t content[16];
if (atom.size < 8)
return 0;
ret = avio_read(pb, content, FFMIN(sizeof(content), atom.size));
if (ret < 0)
return ret;
if ( !c->found_moov
&& !c->found_mdat
&& !memcmp(content, "Anevia\x1A\x1A", 8)
&& c->use_mfra_for == FF_MOV_FLAG_MFRA_AUTO) {
c->use_mfra_for = FF_MOV_FLAG_MFRA_PTS;
}
return 0;
}
static const MOVParseTableEntry mov_default_parse_table[] = { static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('A','C','L','R'), mov_read_avid }, { MKTAG('A','C','L','R'), mov_read_avid },
{ MKTAG('A','P','R','G'), mov_read_avid }, { MKTAG('A','P','R','G'), mov_read_avid },
@ -3338,6 +3360,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('h','v','c','C'), mov_read_glbl }, { MKTAG('h','v','c','C'), mov_read_glbl },
{ MKTAG('u','u','i','d'), mov_read_uuid }, { MKTAG('u','u','i','d'), mov_read_uuid },
{ MKTAG('C','i','n', 0x8e), mov_read_targa_y216 }, { MKTAG('C','i','n', 0x8e), mov_read_targa_y216 },
{ MKTAG('f','r','e','e'), mov_read_free },
{ MKTAG('-','-','-','-'), mov_read_custom }, { MKTAG('-','-','-','-'), mov_read_custom },
{ 0, NULL } { 0, NULL }
}; };
@ -4144,9 +4167,11 @@ static const AVOption options[] = {
0, 1, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM}, 0, 1, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM},
{"use_mfra_for", {"use_mfra_for",
"use mfra for fragment timestamps", "use mfra for fragment timestamps",
offsetof(MOVContext, use_mfra_for), FF_OPT_TYPE_INT, {.i64 = 0}, offsetof(MOVContext, use_mfra_for), FF_OPT_TYPE_INT, {.i64 = FF_MOV_FLAG_MFRA_AUTO},
0, FF_MOV_FLAG_MFRA_PTS, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM, -1, FF_MOV_FLAG_MFRA_PTS, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM,
"use_mfra_for"}, "use_mfra_for"},
{"auto", "auto", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_MFRA_AUTO}, 0, 0,
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM, "use_mfra_for" },
{"dts", "dts", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_MFRA_DTS}, 0, 0, {"dts", "dts", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_MFRA_DTS}, 0, 0,
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM, "use_mfra_for" }, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM, "use_mfra_for" },
{"pts", "pts", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_MFRA_PTS}, 0, 0, {"pts", "pts", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_MFRA_PTS}, 0, 0,