summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2017-06-15 11:50:44 +0300
committerSebastian Dröge <sebastian@centricular.com>2017-06-15 12:12:33 +0300
commit94f9a1ad2b001d28bde1f1d22d19e542fcb88ed0 (patch)
tree5ccada7188fb8fa8fec7be6f4b23234ed775eab0
parenta6aed59d73384abbddb5a179c3236abf89b65c0a (diff)
downloadgstreamer-plugins-good-94f9a1ad2b001d28bde1f1d22d19e542fcb88ed0.tar.gz
qtmux: Un-merge the last two stsc entries after serializing
The last entry will most likely get new samples added to it in "robust" muxing mode, changing the samples_per_chunk and thus making it wrong to keep the last two entries merged. It will run into an assertion later when adding a new sample to the chunk. Thanks to gdiener@cardinalpeak.com for the analysis of the bug and proposal for a solution.
-rw-r--r--gst/isomp4/atoms.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c
index b288215d7..769f7056b 100644
--- a/gst/isomp4/atoms.c
+++ b/gst/isomp4/atoms.c
@@ -2210,6 +2210,7 @@ atom_stsc_copy_data (AtomSTSC * stsc, guint8 ** buffer, guint64 * size,
{
guint64 original_offset = *offset;
guint i, len;
+ gboolean last_entries_merged = FALSE;
if (!atom_full_copy_data (&stsc->header, buffer, size, offset)) {
return 0;
@@ -2221,6 +2222,7 @@ atom_stsc_copy_data (AtomSTSC * stsc, guint8 ** buffer, guint64 * size,
((atom_array_index (&stsc->entries, len - 1)).samples_per_chunk ==
(atom_array_index (&stsc->entries, len - 2)).samples_per_chunk)) {
stsc->entries.len--;
+ last_entries_merged = TRUE;
}
prop_copy_uint32 (atom_array_get_len (&stsc->entries), buffer, size, offset);
@@ -2237,6 +2239,15 @@ atom_stsc_copy_data (AtomSTSC * stsc, guint8 ** buffer, guint64 * size,
}
atom_write_size (buffer, size, offset, original_offset);
+
+ /* Need to add the last entry again as in "robust" muxing mode we will most
+ * likely add new samples to the last chunk, thus making the
+ * samples_per_chunk in the last one different to the second to last one,
+ * and thus making it wrong to keep them merged
+ */
+ if (last_entries_merged)
+ stsc->entries.len++;
+
return *offset - original_offset;
}