fmp4mux: Fix usage of first_sample_flags/default_sample_flags

Previously first_sample_flags was never used so if the first sample was
a keyframe and all others not then each sample got its own flags.
This commit is contained in:
Sebastian Dröge 2022-05-27 11:05:36 +03:00
parent 51c7d0652e
commit 6edb188899

View file

@ -1624,12 +1624,11 @@ fn analyze_buffers(
let f = sample_flags_from_buffer(buffer, intra_only);
if first_buffer_flags.is_none() {
first_buffer_flags = Some(f);
} else {
flags = Some(f);
} else if flags.is_none() {
if Some(f) != first_buffer_flags {
tr_flags |= FIRST_SAMPLE_FLAGS_PRESENT;
}
flags = Some(f);
}
if flags.is_some() && Some(f) != flags {
@ -1686,6 +1685,13 @@ fn analyze_buffers(
duration = None;
}
// If there is only a single buffer use its flags as default sample flags
// instead of first sample flags.
if flags.is_none() && first_buffer_flags.is_some() {
tr_flags &= !FIRST_SAMPLE_FLAGS_PRESENT;
flags = first_buffer_flags.take();
}
if (tr_flags & SAMPLE_FLAGS_PRESENT) == 0 {
tf_flags |= DEFAULT_SAMPLE_FLAGS_PRESENT;
} else {