mxfvanc: Handle empty VANC packets

Some XDCAM recorders store empty packets for VANC, and don't even include the
2byte length.

Handle them in the same way as VANC packets with 0 packets.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2122>
This commit is contained in:
Edward Hervey 2022-04-06 11:21:25 +02:00 committed by GStreamer Marge Bot
parent af71adf315
commit 80e83089b5

View file

@ -116,7 +116,9 @@ mxf_vanc_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
if (gst_buffer_get_size (buffer) < 2) { /* Either there is no data or there is at least room for the 16bit length,
* therefore the only invalid packet length is 1 */
if (gst_buffer_get_size (buffer) == 1) {
GST_ERROR ("Invalid VANC essence element size"); GST_ERROR ("Invalid VANC essence element size");
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
@ -125,6 +127,11 @@ mxf_vanc_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
gst_buffer_map (buffer, &map, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
gst_byte_reader_init (&reader, map.data, map.size); gst_byte_reader_init (&reader, map.data, map.size);
/* Some XDCAM recorders store empty vanc packets (without even the
* length). Treat them as gaps */
if (map.size == 0)
goto no_data;
num_packets = gst_byte_reader_get_uint16_be_unchecked (&reader); num_packets = gst_byte_reader_get_uint16_be_unchecked (&reader);
if (num_packets == 0) { if (num_packets == 0) {
/* SMPTE 436-1:2013 5.5 The Number of VI Lines or ANC Packets Property /* SMPTE 436-1:2013 5.5 The Number of VI Lines or ANC Packets Property