diff options
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index 71b96c192f..c6680274d5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2257,14 +2257,16 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR_INVALIDDATA; } - if (flags & 0x01) frag->base_data_offset = avio_rb64(pb); - else frag->base_data_offset = frag->moof_offset; - if (flags & 0x02) frag->stsd_id = avio_rb32(pb); - else frag->stsd_id = trex->stsd_id; - - frag->duration = flags & 0x08 ? avio_rb32(pb) : trex->duration; - frag->size = flags & 0x10 ? avio_rb32(pb) : trex->size; - frag->flags = flags & 0x20 ? avio_rb32(pb) : trex->flags; + frag->base_data_offset = flags & MOV_TFHD_BASE_DATA_OFFSET ? + avio_rb64(pb) : frag->moof_offset; + frag->stsd_id = flags & MOV_TFHD_STSD_ID ? avio_rb32(pb) : trex->stsd_id; + + frag->duration = flags & MOV_TFHD_DEFAULT_DURATION ? + avio_rb32(pb) : trex->duration; + frag->size = flags & MOV_TFHD_DEFAULT_SIZE ? + avio_rb32(pb) : trex->size; + frag->flags = flags & MOV_TFHD_DEFAULT_FLAGS ? + avio_rb32(pb) : trex->flags; av_dlog(c->fc, "frag flags 0x%x\n", frag->flags); return 0; } @@ -2353,8 +2355,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); sc->ctts_data = ctts_data; - if (flags & 0x001) data_offset = avio_rb32(pb); - if (flags & 0x004) first_sample_flags = avio_rb32(pb); + if (flags & MOV_TRUN_DATA_OFFSET) data_offset = avio_rb32(pb); + if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb); dts = sc->track_end - sc->time_offset; offset = frag->base_data_offset + data_offset; distance = 0; @@ -2365,14 +2367,15 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) unsigned sample_duration = frag->duration; int keyframe; - if (flags & 0x100) sample_duration = avio_rb32(pb); - if (flags & 0x200) sample_size = avio_rb32(pb); - if (flags & 0x400) sample_flags = avio_rb32(pb); + if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb); + if (flags & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(pb); + if (flags & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(pb); sc->ctts_data[sc->ctts_count].count = 1; - sc->ctts_data[sc->ctts_count].duration = (flags & 0x800) ? avio_rb32(pb) : 0; + sc->ctts_data[sc->ctts_count].duration = (flags & MOV_TRUN_SAMPLE_CTS) ? + avio_rb32(pb) : 0; sc->ctts_count++; if ((keyframe = st->codec->codec_type == AVMEDIA_TYPE_AUDIO || - (flags & 0x004 && !i && !(sample_flags & 0xffff0000)) || sample_flags & 0x2000000)) + (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS && !i && !(sample_flags & ~MOV_FRAG_SAMPLE_FLAG_DEGRADATION_PRIORITY_MASK)) || sample_flags & MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO)) distance = 0; av_add_index_entry(st, offset, dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); |