mxfdemux: Check validity of interleaved File Package

As specified by the S377 MXF core specification, if a file package has
interleaved content, then all tracks must be using the same Edit Rate

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2378>
This commit is contained in:
Edward Hervey 2021-07-05 07:42:39 +02:00 committed by GStreamer Marge Bot
parent 65a78effdb
commit 49b061241e
3 changed files with 34 additions and 0 deletions

View file

@ -677,6 +677,7 @@ gst_mxf_demux_update_essence_tracks (GstMXFDemux * demux)
i++) {
MXFMetadataEssenceContainerData *edata;
MXFMetadataSourcePackage *package;
MXFFraction common_rate = { 0, 0 };
if (demux->preface->content_storage->essence_container_data[i] == NULL)
continue;
@ -714,6 +715,34 @@ gst_mxf_demux_update_essence_tracks (GstMXFDemux * demux)
continue;
}
if (package->is_interleaved) {
/*
* S377-1:2019 "9.4.2 The MXF timing model"
*
* The value of Edit Rate shall be identical for every timeline Essence
* Track of the Top-Level File Package.
*
* The value of Edit Rate of the timeline Essence Tracks of one
* Top-Level File Package need not match the Edit Rate of the Essence
* Tracks of the other Top-Level File Packages.
*
* S377-1:2019 "9.5.5 Top-Level File Packages"
*
*12. All Essence Tracks of a Top-Level File Package **shall** have the
* same value of Edit Rate. All other Tracks of a Top-Level File
* Package **should** have the same value of Edit Rate as the
* Essence Tracks.
*/
if (common_rate.n == 0 && common_rate.d == 0) {
common_rate = track->edit_rate;
} else if (common_rate.n * track->edit_rate.d !=
common_rate.d * track->edit_rate.n) {
GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL),
("Interleaved File Package doesn't have identical edit rate on all tracks."));
return GST_FLOW_ERROR;
}
}
for (k = 0; k < demux->essence_tracks->len; k++) {
GstMXFDemuxEssenceTrack *tmp =
&g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack,

View file

@ -2247,6 +2247,8 @@ mxf_metadata_source_package_resolve (MXFMetadataBase * m, GHashTable * metadata)
d = MXF_METADATA_FILE_DESCRIPTOR (current);
self->is_interleaved = MXF_IS_METADATA_MULTIPLE_DESCRIPTOR (self->descriptor);
for (i = 0; i < package->n_tracks; i++) {
if (!package->tracks[i])
continue;

View file

@ -509,6 +509,9 @@ struct _MXFMetadataSourcePackage
MXFMetadataGenericDescriptor *descriptor;
gboolean top_level;
/* TRUE if descriptor is multi-descriptor, i.e. content is interleaved */
gboolean is_interleaved;
};
typedef enum {