Skip to content

Commit

Permalink
movdec: Parse the dvc1 atom
Browse files Browse the repository at this point in the history
Normally, the actual payload data contains sequence headers, too,
and the parser can extract this and set it as extradata. However,
the data in the dvc1 atom is the "official" extradata for the file.

This is required for proper stream copy of vc1 from ismv to ismv.

Signed-off-by: Martin Storsjö <martin@martin.st>
  • Loading branch information
mstorsjo committed Feb 2, 2012
1 parent cd2f98f commit 89415b8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libavformat/mov.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,32 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}

static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
uint8_t profile_level;

if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];

if (atom.size >= (1<<28) || atom.size < 7)
return AVERROR_INVALIDDATA;

profile_level = avio_r8(pb);
if (profile_level & 0xf0 != 0xc0)
return 0;

av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size - 7 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 7;
avio_seek(pb, 6, SEEK_CUR);
avio_read(pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}

/**
* An strf atom is a BITMAPINFOHEADER struct. This struct is 40 bytes itself,
* but can have extradata appended at the end after the 40 bytes belonging
Expand Down Expand Up @@ -2435,6 +2461,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('w','f','e','x'), mov_read_wfex },
{ MKTAG('c','m','o','v'), mov_read_cmov },
{ MKTAG('c','h','a','n'), mov_read_chan }, /* channel layout */
{ MKTAG('d','v','c','1'), mov_read_dvc1 },
{ 0, NULL }
};

Expand Down

0 comments on commit 89415b8

Please sign in to comment.