mxfdemux: Refactor index table and offset handling
authorEdward Hervey <edward@centricular.com>
Thu, 1 Jul 2021 06:35:01 +0000 (08:35 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Wed, 21 Jul 2021 14:33:19 +0000 (14:33 +0000)
commitac483b238455000917f5489574e24d2c20dfc0b4
tree049a7f20e235f31d8b4183f73ca7bc2222861019
parentc24d48765dd1236795c8c00343962a13f53885a4
mxfdemux: Refactor index table and offset handling

* Streamline offset <=> entry handling. Historically the demuxer didn't support
information from index tables and stored the discovered information in an array
per track. When index table support was added, a parallel system was setup for
that relationship. This commit unifies this into one system with the
`find_edit_entry()` and `find_entry_for_offset()` functions.

* By extension, per-track offset entry tables are only created/used if no index
table is present for those tracks.

* Use index table information as-is. The index table system from MXF is quite
complex and there are various ways to use the information contained
within. Instead of converting that information we store the data from the tables
as-is and extract the needed information when needed.

* Handle index tables without entries (i.e. all content package units are of the
same size).

* Allow collecting index table segments as we go instead of only once if a
random-index-pack is present. This also improves support of some files in
push-mode.

* When searching for keyframe entries, use the keyframe_offset if
present (speeds up searching).

* For interleaved content (i.e. several tracks in the sample essence container),
we use a system to be able to identify the position of each track in the delta
entries of index tables.

* Handle temporal offset only on tracks which *do* need it (as specified in the
delta entries of the index tables). If present, those offsets are stored in a
pre-processed table which allows computing PTS from DTS with a simple offset.

* Add a quirk for files which are known to be have wrongly stored temporal
offsets.

* Overall opens the way to handle more types of MXF files, especially those with
non-frame-wrapping.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2371>
gst/mxf/mxfdemux.c
gst/mxf/mxfdemux.h
gst/mxf/mxftypes.c
gst/mxf/mxftypes.h