From 37e0439e84104b4f7ca9e972fd87af35fbd72af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 5 Jul 2017 00:48:36 +0300 Subject: [PATCH] mxfdemux: Don't include any KLV packets between header metadata and index table segments in calculations Minor fixup of last commit. --- gst/mxf/mxfdemux.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c index 5716f949fe..d796e807b0 100644 --- a/gst/mxf/mxfdemux.c +++ b/gst/mxf/mxfdemux.c @@ -2016,23 +2016,34 @@ read_partition_header (GstMXFDemux * demux) return; } - while (demux->offset < - demux->run_in + - demux->current_partition->partition.this_partition + - demux->current_partition->partition.header_byte_count + - demux->current_partition->partition.index_byte_count) { - if (mxf_is_index_table_segment (&key)) { - gst_mxf_demux_handle_index_table_segment (demux, &key, buf, - demux->offset); - } + while (mxf_is_fill (&key)) { demux->offset += read; - gst_buffer_unref (buf); if (gst_mxf_demux_pull_klv_packet (demux, demux->offset, &key, &buf, &read) != GST_FLOW_OK) return; } + if (demux->current_partition->partition.index_byte_count + && mxf_is_index_table_segment (&key)) { + guint64 index_end_offset = + demux->offset + demux->current_partition->partition.index_byte_count; + + while (demux->offset < index_end_offset) { + if (mxf_is_index_table_segment (&key)) { + gst_mxf_demux_handle_index_table_segment (demux, &key, buf, + demux->offset); + } + demux->offset += read; + + gst_buffer_unref (buf); + if (gst_mxf_demux_pull_klv_packet (demux, demux->offset, &key, &buf, + &read) + != GST_FLOW_OK) + return; + } + } + while (mxf_is_fill (&key)) { demux->offset += read; gst_buffer_unref (buf);