diff options
author | Edward Hervey <edward@centricular.com> | 2021-06-21 13:23:13 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2021-07-01 11:04:03 +0200 |
commit | 162e7bd28b19bac786228ec3ab7fd4ea9238cac2 (patch) | |
tree | ed27db6f29cd3b36af8c9595e17daed14159a5bc /gst | |
parent | d9c486352cf1a999050d1ddc1dae4a19d55f1d3c (diff) | |
download | gstreamer-plugins-bad-162e7bd28b19bac786228ec3ab7fd4ea9238cac2.tar.gz |
mxfvanc: Handle empty ANC essence
Not having any *actual* ANC is totally fine and common usage with several MXF
variants.
In order to properly advance the streams, the essence handler returns an empty
GAP buffer which gets converted to a GST_EVENT_GAP.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2345>
Diffstat (limited to 'gst')
-rw-r--r-- | gst/mxf/mxfdemux.c | 15 | ||||
-rw-r--r-- | gst/mxf/mxfvanc.c | 20 |
2 files changed, 33 insertions, 2 deletions
diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c index e5b6ed4db..209887d9e 100644 --- a/gst/mxf/mxfdemux.c +++ b/gst/mxf/mxfdemux.c @@ -2017,7 +2017,20 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux, pad->discont = FALSE; } - ret = gst_pad_push (GST_PAD_CAST (pad), outbuf); + /* Handlers can provide empty GAP buffers to indicate that the parsed + * content was valid but that nothing meaningful needs to be outputted. In + * such cases we send out a GAP event instead */ + if (GST_BUFFER_FLAG_IS_SET (outbuf, GST_BUFFER_FLAG_GAP) && + gst_buffer_get_size (outbuf) == 0) { + GstEvent *gap = gst_event_new_gap (GST_BUFFER_DTS (outbuf), + GST_BUFFER_DURATION (outbuf)); + gst_buffer_unref (outbuf); + GST_DEBUG_OBJECT (pad, + "Replacing empty gap buffer with gap event %" GST_PTR_FORMAT, gap); + gst_pad_push_event (GST_PAD_CAST (pad), gap); + } else { + ret = gst_pad_push (GST_PAD_CAST (pad), outbuf); + } outbuf = NULL; ret = gst_flow_combiner_update_flow (demux->flowcombiner, ret); GST_LOG_OBJECT (demux, "combined return %s", gst_flow_get_name (ret)); diff --git a/gst/mxf/mxfvanc.c b/gst/mxf/mxfvanc.c index 62a83d559..f9342465f 100644 --- a/gst/mxf/mxfvanc.c +++ b/gst/mxf/mxfvanc.c @@ -116,7 +116,7 @@ mxf_vanc_handle_essence_element (const MXFUL * key, GstBuffer * buffer, return GST_FLOW_ERROR; } - if (gst_buffer_get_size (buffer) < 18) { + if (gst_buffer_get_size (buffer) < 2) { GST_ERROR ("Invalid VANC essence element size"); gst_buffer_unref (buffer); return GST_FLOW_ERROR; @@ -126,6 +126,24 @@ mxf_vanc_handle_essence_element (const MXFUL * key, GstBuffer * buffer, gst_byte_reader_init (&reader, map.data, map.size); num_packets = gst_byte_reader_get_uint16_be_unchecked (&reader); + if (num_packets == 0) { + /* SMPTE 436-1:2013 5.5 The Number of VI Lines or ANC Packets Property + * + * One of the properties in the VI Element is the “Number of Lines” which is + * the number of the VI lines contained in this VI Element. This number can + * be zero if the current VI Element does not have any VI lines in the + * payload space. This capability can be used so every Content Package in a + * file can have a VI Element even if the video stream does not have VI + * lines with every frame (or field.) + * + * The same scheme can be used for ANC packets. + */ + + *outbuf = gst_buffer_new (); + GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_GAP); + ret = GST_FLOW_OK; + goto out; + } for (i = 0; i < num_packets; i++) { G_GNUC_UNUSED guint16 line_num; G_GNUC_UNUSED guint8 wrapping_type; |