mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
movenc: Set tfhd default sample flags based on actual samples, if possible
This avoids assuming that e.g. audio samples are marked as sync samples. This allows omitting the sample flags from trun, if the default flags happen to be right for all the samples. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
0ce3a0f9d9
commit
00d751d4fc
@ -2409,6 +2409,12 @@ static int mov_write_mfhd_tag(AVIOContext *pb, MOVMuxContext *mov)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t get_sample_flags(MOVTrack *track, MOVIentry *entry)
|
||||
{
|
||||
return entry->flags & MOV_SYNC_SAMPLE ? MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO :
|
||||
(MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC);
|
||||
}
|
||||
|
||||
static int mov_write_tfhd_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
MOVTrack *track, int64_t moof_offset)
|
||||
{
|
||||
@ -2454,22 +2460,21 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
track->default_size = -1;
|
||||
|
||||
if (flags & MOV_TFHD_DEFAULT_FLAGS) {
|
||||
track->default_sample_flags =
|
||||
track->enc->codec_type == AVMEDIA_TYPE_VIDEO ?
|
||||
(MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC) :
|
||||
MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO;
|
||||
/* Set the default flags based on the second sample, if available.
|
||||
* If the first sample is different, that can be signaled via a separate field. */
|
||||
if (track->entry > 1)
|
||||
track->default_sample_flags = get_sample_flags(track, &track->cluster[1]);
|
||||
else
|
||||
track->default_sample_flags =
|
||||
track->enc->codec_type == AVMEDIA_TYPE_VIDEO ?
|
||||
(MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC) :
|
||||
MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO;
|
||||
avio_wb32(pb, track->default_sample_flags);
|
||||
}
|
||||
|
||||
return update_size(pb, pos);
|
||||
}
|
||||
|
||||
static uint32_t get_sample_flags(MOVTrack *track, MOVIentry *entry)
|
||||
{
|
||||
return entry->flags & MOV_SYNC_SAMPLE ? MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO :
|
||||
(MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC);
|
||||
}
|
||||
|
||||
static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
MOVTrack *track, int moof_size)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user