qtdemux: Always use `tfdt` if available in BYTE segments
authorSebastian Dröge <sebastian@centricular.com>
Fri, 16 Dec 2022 15:27:33 +0000 (17:27 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 17 Dec 2022 17:26:19 +0000 (19:26 +0200)
commit066558cba1b24416dfdf8bb9dfead1ca0fce5058
tree50596cbde7caca8ede1dcafe7bc950b45c17c382
parentf8b732563bd7f3147e97da8a42aeea7119d5fe32
qtdemux: Always use `tfdt` if available in BYTE segments

This reverts the decision from
  https://bugzilla.gnome.org/show_bug.cgi?id=754230
where it was decided that we rather play safe and only use the `tfdt` if
it is "significantly different" to the sum of sample durations.

As the specification says

    If the time expressed in the track fragment decode time (‘tfdt’) box
    exceeds the sum of the durations of the samples in the preceding
    movie and movie fragments, then the duration of the last sample
    preceding this track fragment is extended such that the sum now
    equals the time given in this box.

we have to use the `tfdt` in general to allow for it to signal gaps in
the stream.

A muxer producing fragments might not yet know the full duration of the
last sample of a previous fragment if the next fragment starts with a
gap, and knowing the actual start of the next fragment would potentially
require to violate latency requirements.

Additionally, the existence of `tfdt` allows to avoid accumulating
rounding errors from summing up the durations.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3586>
subprojects/gst-plugins-good/gst/isomp4/qtdemux.c