qtdemux: Don't assert in prefill mode if a track has no samples at all
Just write it with a duration of 0, no samples, etc.
This commit is contained in:
parent
6ce2a5f7bf
commit
7679412b69
@ -3615,21 +3615,15 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
|
|||||||
for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
|
for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
|
||||||
GstCollectData *cdata = (GstCollectData *) walk->data;
|
GstCollectData *cdata = (GstCollectData *) walk->data;
|
||||||
GstQTPad *qpad = (GstQTPad *) cdata;
|
GstQTPad *qpad = (GstQTPad *) cdata;
|
||||||
const TrakBufferEntryInfo *sample_entry;
|
|
||||||
guint64 block_idx;
|
guint64 block_idx;
|
||||||
AtomSTBL *stbl = &qpad->trak->mdia.minf.stbl;
|
AtomSTBL *stbl = &qpad->trak->mdia.minf.stbl;
|
||||||
|
|
||||||
/* Get the block index of the last sample we wrote, not of the next
|
/* Get the block index of the last sample we wrote, not of the next
|
||||||
* sample we would write */
|
* sample we would write */
|
||||||
block_idx = prefill_get_block_index (qtmux, qpad);
|
block_idx = prefill_get_block_index (qtmux, qpad);
|
||||||
g_assert (block_idx > 0);
|
|
||||||
block_idx--;
|
|
||||||
|
|
||||||
sample_entry =
|
|
||||||
&g_array_index (qpad->samples, TrakBufferEntryInfo, block_idx);
|
|
||||||
|
|
||||||
/* stts */
|
/* stts */
|
||||||
{
|
if (block_idx > 0) {
|
||||||
STTSEntry *entry;
|
STTSEntry *entry;
|
||||||
guint64 nsamples = 0;
|
guint64 nsamples = 0;
|
||||||
gint i, n;
|
gint i, n;
|
||||||
@ -3645,6 +3639,8 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
|
|||||||
nsamples += entry->sample_count;
|
nsamples += entry->sample_count;
|
||||||
}
|
}
|
||||||
g_assert (i < n);
|
g_assert (i < n);
|
||||||
|
} else {
|
||||||
|
stbl->stts.entries.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stsz */
|
/* stsz */
|
||||||
@ -3658,56 +3654,66 @@ gst_qt_mux_stop_file (GstQTMux * qtmux)
|
|||||||
gint i, n;
|
gint i, n;
|
||||||
guint64 nsamples = 0;
|
guint64 nsamples = 0;
|
||||||
gint chunk_index = 0;
|
gint chunk_index = 0;
|
||||||
|
const TrakBufferEntryInfo *sample_entry;
|
||||||
|
|
||||||
n = stbl->stco64.entries.len;
|
if (block_idx > 0) {
|
||||||
for (i = 0; i < n; i++) {
|
sample_entry =
|
||||||
guint64 *entry = &atom_array_index (&stbl->stco64.entries, i);
|
&g_array_index (qpad->samples, TrakBufferEntryInfo,
|
||||||
|
block_idx - 1);
|
||||||
|
|
||||||
if (*entry == sample_entry->chunk_offset) {
|
n = stbl->stco64.entries.len;
|
||||||
stbl->stco64.entries.len = i + 1;
|
for (i = 0; i < n; i++) {
|
||||||
chunk_index = i + 1;
|
guint64 *entry = &atom_array_index (&stbl->stco64.entries, i);
|
||||||
break;
|
|
||||||
|
if (*entry == sample_entry->chunk_offset) {
|
||||||
|
stbl->stco64.entries.len = i + 1;
|
||||||
|
chunk_index = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
g_assert (i < n);
|
||||||
g_assert (i < n);
|
g_assert (chunk_index > 0);
|
||||||
g_assert (chunk_index > 0);
|
|
||||||
|
|
||||||
n = stbl->stsc.entries.len;
|
n = stbl->stsc.entries.len;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
STSCEntry *entry = &atom_array_index (&stbl->stsc.entries, i);
|
STSCEntry *entry = &atom_array_index (&stbl->stsc.entries, i);
|
||||||
|
|
||||||
if (entry->first_chunk >= chunk_index)
|
if (entry->first_chunk >= chunk_index)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
nsamples +=
|
||||||
|
(entry->first_chunk - atom_array_index (&stbl->stsc.entries,
|
||||||
|
i -
|
||||||
|
1).first_chunk) * atom_array_index (&stbl->stsc.entries,
|
||||||
|
i - 1).samples_per_chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_assert (i <= n);
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
STSCEntry *prev_entry =
|
||||||
|
&atom_array_index (&stbl->stsc.entries, i - 1);
|
||||||
nsamples +=
|
nsamples +=
|
||||||
(entry->first_chunk - atom_array_index (&stbl->stsc.entries,
|
(chunk_index -
|
||||||
i -
|
prev_entry->first_chunk) * prev_entry->samples_per_chunk;
|
||||||
1).first_chunk) * atom_array_index (&stbl->stsc.entries,
|
if (qpad->sample_offset - nsamples > 0) {
|
||||||
i - 1).samples_per_chunk;
|
stbl->stsc.entries.len = i;
|
||||||
}
|
atom_stsc_add_new_entry (&stbl->stsc, chunk_index,
|
||||||
}
|
qpad->sample_offset - nsamples);
|
||||||
g_assert (i <= n);
|
} else {
|
||||||
|
stbl->stsc.entries.len = i;
|
||||||
if (i > 0) {
|
stbl->stco64.entries.len--;
|
||||||
STSCEntry *prev_entry =
|
}
|
||||||
&atom_array_index (&stbl->stsc.entries, i - 1);
|
|
||||||
nsamples +=
|
|
||||||
(chunk_index -
|
|
||||||
prev_entry->first_chunk) * prev_entry->samples_per_chunk;
|
|
||||||
if (qpad->sample_offset - nsamples > 0) {
|
|
||||||
stbl->stsc.entries.len = i;
|
|
||||||
atom_stsc_add_new_entry (&stbl->stsc, chunk_index,
|
|
||||||
qpad->sample_offset - nsamples);
|
|
||||||
} else {
|
} else {
|
||||||
stbl->stsc.entries.len = i;
|
/* Everything in a single chunk */
|
||||||
stbl->stco64.entries.len--;
|
stbl->stsc.entries.len = 0;
|
||||||
|
atom_stsc_add_new_entry (&stbl->stsc, chunk_index,
|
||||||
|
qpad->sample_offset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Everything in a single chunk */
|
stbl->stco64.entries.len = 0;
|
||||||
stbl->stsc.entries.len = 0;
|
stbl->stsc.entries.len = 0;
|
||||||
atom_stsc_add_new_entry (&stbl->stsc, chunk_index,
|
|
||||||
qpad->sample_offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user