mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-28 05:30:34 +00:00
mov: Use defines for tfhd flags
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
6d702dc072
commit
73328f24fa
@ -157,6 +157,13 @@ void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
|
||||
#define MP4DecSpecificDescrTag 0x05
|
||||
#define MP4SLDescrTag 0x06
|
||||
|
||||
#define MOV_TFHD_BASE_DATA_OFFSET 0x01
|
||||
#define MOV_TFHD_STSD_ID 0x02
|
||||
#define MOV_TFHD_DEFAULT_DURATION 0x08
|
||||
#define MOV_TFHD_DEFAULT_SIZE 0x10
|
||||
#define MOV_TFHD_DEFAULT_FLAGS 0x20
|
||||
#define MOV_TFHD_DURATION_IS_EMPTY 0x010000
|
||||
|
||||
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
|
||||
enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
|
||||
|
||||
|
@ -2167,14 +2167,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->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 & 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->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;
|
||||
}
|
||||
|
@ -2179,19 +2179,19 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVTrack *track,
|
||||
int64_t moof_offset)
|
||||
{
|
||||
int64_t pos = avio_tell(pb);
|
||||
/* default-sample-size + default-sample-duration + base-data-offset */
|
||||
uint32_t flags = 0x19;
|
||||
uint32_t flags = MOV_TFHD_DEFAULT_SIZE | MOV_TFHD_DEFAULT_DURATION |
|
||||
MOV_TFHD_BASE_DATA_OFFSET;
|
||||
if (!track->entry) {
|
||||
flags |= 0x010000; /* duration-is-empty */
|
||||
flags |= MOV_TFHD_DURATION_IS_EMPTY;
|
||||
} else {
|
||||
flags |= 0x20; /* default-sample-flags-present */
|
||||
flags |= MOV_TFHD_DEFAULT_FLAGS;
|
||||
}
|
||||
|
||||
/* Don't set a default sample size, the silverlight player refuses
|
||||
* to play files with that set. Don't set a default sample duration,
|
||||
* WMP freaks out if it is set. */
|
||||
if (track->mode == MODE_ISM)
|
||||
flags &= ~0x18;
|
||||
flags &= ~(MOV_TFHD_DEFAULT_SIZE | MOV_TFHD_DEFAULT_DURATION);
|
||||
|
||||
avio_wb32(pb, 0); /* size placeholder */
|
||||
ffio_wfourcc(pb, "tfhd");
|
||||
@ -2199,19 +2199,19 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVTrack *track,
|
||||
avio_wb24(pb, flags);
|
||||
|
||||
avio_wb32(pb, track->track_id); /* track-id */
|
||||
if (flags & 0x01)
|
||||
if (flags & MOV_TFHD_BASE_DATA_OFFSET)
|
||||
avio_wb64(pb, moof_offset);
|
||||
if (flags & 0x08) {
|
||||
if (flags & MOV_TFHD_DEFAULT_DURATION) {
|
||||
track->default_duration = track->audio_vbr ? track->enc->frame_size : 1;
|
||||
avio_wb32(pb, track->default_duration);
|
||||
}
|
||||
if (flags & 0x10) {
|
||||
if (flags & MOV_TFHD_DEFAULT_SIZE) {
|
||||
track->default_size = track->entry ? track->cluster[0].size : 1;
|
||||
avio_wb32(pb, track->default_size);
|
||||
} else
|
||||
track->default_size = -1;
|
||||
|
||||
if (flags & 0x20) {
|
||||
if (flags & MOV_TFHD_DEFAULT_FLAGS) {
|
||||
track->default_sample_flags =
|
||||
track->enc->codec_type == AVMEDIA_TYPE_VIDEO ?
|
||||
0x01010000 : 0x02000000;
|
||||
|
Loading…
Reference in New Issue
Block a user