gstreamer/gst/isomp4
Alicia Boya García 5fcb7f715a qtmux: round to nearest when computing mehd and tkhd duration
This fixes a bug where in some files mehd.fragment_duration is one unit
less than the actual duration of the fragmented movie, as explained below:

mehd.fragment_duration is computed by scaling the end timestamp of
the last frame of the movie in (in nanoseconds) by the movie timescale.

In some situations, the end timestamp is innacurate due to lossy conversion to
fixed point required by GstBuffer upstream.

Take for instance a movie with 3 frames at exactly 3 fps.

$ gst-launch-1.0 -v videotestsrc num-buffers=3 \
  ! video/x-raw, framerate="(fraction)3/1" \
  ! x264enc \
  ! fakesink silent=false

dts: 999:59:59.333333334,  pts: 1000:00:00.000000000, duration: 0:00:00.333333333
dts: 999:59:59.666666667,  pts: 1000:00:00.666666666, duration: 0:00:00.333333334
dts: 1000:00:00.000000000, pts: 1000:00:00.333333333, duration: 0:00:00.333333333

The end timestamp is calculated by qtmux in this way:

end timestamp = last frame DTS + last frame DUR - first frame DTS =
  = 1000:00:00.000000000 + 0:00:00.333333333 - 999:59:59.333333334 =
  = 0:00:00.999999999

qtmux needs to round this timestamp to the declared movie timescale, which can
ameliorate this distortion, but it's important that round-neareast is used;
otherwise it would backfire badly.

Take for example a movie with a timescale of 30 units/s.

0.999999999 s * 30 units/s = 29.999999970 units

A round-floor (as it was done before this patch) would set fragment_duration to
29 units, amplifying the original distorsion from 1 nanosecond up to 33
milliseconds less than the correct value. The greatest distortion would occur
in the case where timescale = framerate, where an entire frame duration would
be subtracted.

Also, rounding is added to tkhd duration computation too, which
potentially has the same problem.

https://bugzilla.gnome.org/show_bug.cgi?id=793959
2018-10-27 13:12:56 +01:00
..
atoms.c qtmux: round to nearest when computing mehd and tkhd duration 2018-10-27 13:12:56 +01:00
atoms.h isomp4: qtmux: Add Closed Caption support 2018-04-23 15:58:10 +02:00
atomsrecovery.c gst-plugins-good: atoms_recovery: Handled buffer mapping failure 2017-10-24 22:04:27 -07:00
atomsrecovery.h atomsrecovery: read from mdat only what is on headers 2017-10-24 21:33:25 -07:00
descriptors.c qtdemux: Fix calcuation of descriptor length 2013-12-23 15:09:49 +01:00
descriptors.h Fix FSF address 2012-11-04 00:07:18 +00:00
fourcc.h qtdemux: Recognize more AV1 atoms 2018-07-26 14:14:53 -04:00
gstisoff.c qtdemux: Apply qtdemux debug category to gstisoff 2018-01-29 18:40:02 +00:00
gstisoff.h isomp4: Redefine gst_isoff_ symbols to gst_isoff_qt_ 2015-02-17 12:31:06 +01:00
gstqtmoovrecover.c atomsrecovery: read from mdat only what is on headers 2017-10-24 21:33:25 -07:00
gstqtmoovrecover.h Fix FSF address 2012-11-04 00:07:18 +00:00
gstqtmux-doc.c docs: remove outdated and pointless 'Last reviewed' lines from docs 2014-04-26 23:35:17 +01:00
gstqtmux-doc.h isomp4mux: fix copy and paste 2014-02-18 22:35:45 +01:00
gstqtmux.c qtmux: round to nearest when computing mehd and tkhd duration 2018-10-27 13:12:56 +01:00
gstqtmux.h qtmux: Add property for providing a threshold after which we create an edit list for gaps at the start 2018-10-22 12:29:23 +01:00
GstQTMux.prs qtmux: Implement the preset interface. 2016-09-01 13:16:49 +03:00
gstqtmuxmap.c qtmux: Implement muxing of AV1 into MP4 files 2018-07-26 14:14:53 -04:00
gstqtmuxmap.h isomp4: qtmux: Add Closed Caption support 2018-04-23 15:58:10 +02:00
gstrtpxqtdepay.c good: use new gst_element_class_add_static_pad_template() 2016-03-24 14:32:20 +02:00
gstrtpxqtdepay.h Fix FSF address 2012-11-04 00:07:18 +00:00
isomp4-plugin.c Don't use setlocale in plugins() 2013-09-01 21:18:38 +01:00
LEGAL quicktime: rename plugin to isomp4 2011-04-30 17:58:02 +01:00
Makefile.am qtdemux: Apply qtdemux debug category to gstisoff 2018-01-29 18:40:02 +00:00
meson.build Meson: Generate pc file for all plugins in good 2018-04-25 11:07:06 +01:00
properties.c Fix FSF address 2012-11-04 00:07:18 +00:00
properties.h docs: fix "Symbol name not found at the start of the comment block" 2015-07-07 17:12:02 +02:00
qtatomparser.h Fix FSF address 2012-11-04 00:07:18 +00:00
qtdemux.c qtdemux: Fix build with GLib versions < 2.54 2018-10-20 12:38:32 +01:00
qtdemux.h qtdemux: Use GPtrArray to store QtDemuxStream structure 2018-10-19 14:44:43 +02:00
qtdemux_debug.h qtdemux: Apply qtdemux debug category to gstisoff 2018-01-29 18:40:02 +00:00
qtdemux_dump.c qtdemux: Add initial support for AV1 demuxing 2018-07-26 14:14:53 -04:00
qtdemux_dump.h isomp4: Add gmhd/gmin debugging 2018-01-31 19:12:48 +01:00
qtdemux_lang.c qtdemux: Apply qtdemux debug category to gstisoff 2018-01-29 18:40:02 +00:00
qtdemux_lang.h Fix FSF address 2012-11-04 00:07:18 +00:00
qtdemux_types.c qtdemux: Recognize more AV1 atoms 2018-07-26 14:14:53 -04:00
qtdemux_types.h qtdemux: handle default-base-is-moof flag 2015-08-05 18:12:45 -03:00
qtpalette.h Fix FSF address 2012-11-04 00:07:18 +00:00