From 80e83089b58335bfdf3733f9982098c1ea5dbb5d Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 6 Apr 2022 11:21:25 +0200 Subject: [PATCH] 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: --- subprojects/gst-plugins-bad/gst/mxf/mxfvanc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/gst/mxf/mxfvanc.c b/subprojects/gst-plugins-bad/gst/mxf/mxfvanc.c index d2530e09a4..69279c30a6 100644 --- a/subprojects/gst-plugins-bad/gst/mxf/mxfvanc.c +++ b/subprojects/gst-plugins-bad/gst/mxf/mxfvanc.c @@ -116,7 +116,9 @@ mxf_vanc_handle_essence_element (const MXFUL * key, GstBuffer * buffer, 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_buffer_unref (buffer); 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_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); if (num_packets == 0) { /* SMPTE 436-1:2013 5.5 The Number of VI Lines or ANC Packets Property