From 25b37c33ddd7d2e334b792d4d13f5a3d01a99eb0 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 11 Apr 2022 10:32:40 +0200 Subject: [PATCH] mxfdemux: Fix issue with re-syncing In case of re-syncing (i.e. moving to another partition to avoid too much of an interleave), there was previously no checks to figure out whether a given partition was already fully handled (i.e. when coming across it again after a previous resync). In order to handle this at least for single-track partitions, check whether we have reached the essence track duration, and if so skip the partition. Part-of: --- subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c b/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c index 31dc361cce..243f593c86 100644 --- a/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c +++ b/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c @@ -4136,6 +4136,7 @@ gst_mxf_demux_pull_and_handle_klv_packet (GstMXFDemux * demux) /* We entered a new partition */ if (ret == GST_FLOW_OK && mxf_is_partition_pack (&klv.key)) { GstMXFDemuxPartition *partition = demux->current_partition; + gboolean partition_done = FALSE; /* Grab footer metadata if needed */ if (demux->pull_footer_metadata @@ -4178,8 +4179,13 @@ gst_mxf_demux_pull_and_handle_klv_packet (GstMXFDemux * demux) "Track already at another position : %" G_GINT64_FORMAT, partition->single_track->position); if (find_edit_entry (demux, partition->single_track, - partition->single_track->position, FALSE, &entry)) + partition->single_track->position, FALSE, &entry)) { lowest_offset = entry.offset; + } else if (partition->single_track->position >= + partition->single_track->duration) { + GST_DEBUG_OBJECT (demux, "Track fully consumed, partition done"); + partition_done = TRUE; + } } } else { guint i; @@ -4207,14 +4213,15 @@ gst_mxf_demux_pull_and_handle_klv_packet (GstMXFDemux * demux) } } - if (lowest_offset != G_MAXUINT64) { + if (partition_done || lowest_offset != G_MAXUINT64) { GstMXFDemuxPartition *next_partition = NULL; GList *cur_part = g_list_find (demux->partitions, partition); if (cur_part && cur_part->next) next_partition = (GstMXFDemuxPartition *) cur_part->next->data; /* If we have completely processed this partition, skip to next partition */ - if (lowest_offset > next_partition->partition.this_partition) { + if (partition_done + || lowest_offset > next_partition->partition.this_partition) { GST_DEBUG_OBJECT (demux, "Partition entirely processed, skipping to next one"); demux->offset = next_partition->partition.this_partition;