mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-02-01 21:52:20 +00:00
fmp4mux: Fix decision whether per-sample flags are needed in the trun
Previously it would never use per-sample flags if any later sample needed different flags than the first two. Also comment the code a bit better. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1060>
This commit is contained in:
parent
77d68080e8
commit
1ceaea844a
1 changed files with 10 additions and 4 deletions
|
@ -1760,15 +1760,19 @@ fn analyze_buffers(
|
||||||
|
|
||||||
let f = sample_flags_from_buffer(stream, buffer);
|
let f = sample_flags_from_buffer(stream, buffer);
|
||||||
if first_buffer_flags.is_none() {
|
if first_buffer_flags.is_none() {
|
||||||
|
// First buffer, remember as first buffer flags
|
||||||
first_buffer_flags = Some(f);
|
first_buffer_flags = Some(f);
|
||||||
} else {
|
} else if flags.is_none() {
|
||||||
|
// Second buffer, remember as general flags and if they're
|
||||||
|
// different from the first buffer's flags then also remember
|
||||||
|
// that
|
||||||
flags = Some(f);
|
flags = Some(f);
|
||||||
if Some(f) != first_buffer_flags {
|
if Some(f) != first_buffer_flags {
|
||||||
tr_flags |= FIRST_SAMPLE_FLAGS_PRESENT;
|
tr_flags |= FIRST_SAMPLE_FLAGS_PRESENT;
|
||||||
}
|
}
|
||||||
}
|
} else if Some(f) != flags {
|
||||||
|
// Third or later buffer, and the flags are different than the second buffer's flags.
|
||||||
if flags.is_some() && Some(f) != flags {
|
// In that case each sample will have to store its own flags.
|
||||||
tr_flags &= !FIRST_SAMPLE_FLAGS_PRESENT;
|
tr_flags &= !FIRST_SAMPLE_FLAGS_PRESENT;
|
||||||
tr_flags |= SAMPLE_FLAGS_PRESENT;
|
tr_flags |= SAMPLE_FLAGS_PRESENT;
|
||||||
}
|
}
|
||||||
|
@ -1803,6 +1807,8 @@ fn analyze_buffers(
|
||||||
flags = first_buffer_flags.take();
|
flags = first_buffer_flags.take();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If all but possibly the first buffer had the same flags then only store them once instead of
|
||||||
|
// with every single sample.
|
||||||
if (tr_flags & SAMPLE_FLAGS_PRESENT) == 0 {
|
if (tr_flags & SAMPLE_FLAGS_PRESENT) == 0 {
|
||||||
tf_flags |= DEFAULT_SAMPLE_FLAGS_PRESENT;
|
tf_flags |= DEFAULT_SAMPLE_FLAGS_PRESENT;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue