You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/mov.c: require tfhd to begin parsing trun
Detecting missing tfhd avoids re-using tfhd track info from the previous moof. For files with multiple tracks, this may make a mess of the avindex and fragindex, which can later trigger av_assert0 in mov_read_trun(). Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
7cab5471b2
commit
3ea87e5d9e
@@ -87,6 +87,7 @@ typedef struct MOVAtom {
|
|||||||
struct MOVParseTableEntry;
|
struct MOVParseTableEntry;
|
||||||
|
|
||||||
typedef struct MOVFragment {
|
typedef struct MOVFragment {
|
||||||
|
int found_tfhd;
|
||||||
unsigned track_id;
|
unsigned track_id;
|
||||||
uint64_t base_data_offset;
|
uint64_t base_data_offset;
|
||||||
uint64_t moof_offset;
|
uint64_t moof_offset;
|
||||||
|
@@ -1366,6 +1366,9 @@ static void fix_frag_index_entries(MOVFragmentIndex *frag_index, int index,
|
|||||||
|
|
||||||
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||||
{
|
{
|
||||||
|
// Set by mov_read_tfhd(). mov_read_trun() will reject files missing tfhd.
|
||||||
|
c->fragment.found_tfhd = 0;
|
||||||
|
|
||||||
if (!c->has_looked_for_mfra && c->use_mfra_for > 0) {
|
if (!c->has_looked_for_mfra && c->use_mfra_for > 0) {
|
||||||
c->has_looked_for_mfra = 1;
|
c->has_looked_for_mfra = 1;
|
||||||
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
||||||
@@ -4544,6 +4547,8 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
MOVTrackExt *trex = NULL;
|
MOVTrackExt *trex = NULL;
|
||||||
int flags, track_id, i;
|
int flags, track_id, i;
|
||||||
|
|
||||||
|
c->fragment.found_tfhd = 1;
|
||||||
|
|
||||||
avio_r8(pb); /* version */
|
avio_r8(pb); /* version */
|
||||||
flags = avio_rb24(pb);
|
flags = avio_rb24(pb);
|
||||||
|
|
||||||
@@ -4679,6 +4684,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
AVIndexEntry *new_entries;
|
AVIndexEntry *new_entries;
|
||||||
MOVFragmentStreamInfo * frag_stream_info;
|
MOVFragmentStreamInfo * frag_stream_info;
|
||||||
|
|
||||||
|
if (!frag->found_tfhd) {
|
||||||
|
av_log(c->fc, AV_LOG_ERROR, "trun track id unknown, no tfhd was found\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < c->fc->nb_streams; i++) {
|
for (i = 0; i < c->fc->nb_streams; i++) {
|
||||||
if (c->fc->streams[i]->id == frag->track_id) {
|
if (c->fc->streams[i]->id == frag->track_id) {
|
||||||
st = c->fc->streams[i];
|
st = c->fc->streams[i];
|
||||||
|
Reference in New Issue
Block a user