mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-29 18:48:44 +00:00
oggdemux: fix clipping more samples than exist in the first packet
This can happen in Opus (and maybe other codecs ?), and would cause failure to play. https://bugzilla.gnome.org/show_bug.cgi?id=782157
This commit is contained in:
parent
4fdb5ab675
commit
523e98396f
2 changed files with 21 additions and 17 deletions
|
@ -736,9 +736,15 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
|
|||
}
|
||||
if (pad->map.audio_clipping
|
||||
&& pad->current_granule - duration < -pad->map.granule_offset) {
|
||||
if (pad->current_granule >= -pad->map.granule_offset)
|
||||
clip_start = -pad->map.granule_offset;
|
||||
else
|
||||
if (pad->current_granule >= -pad->map.granule_offset) {
|
||||
guint64 already_removed =
|
||||
pad->current_granule >
|
||||
duration ? pad->current_granule - duration : 0;
|
||||
clip_start =
|
||||
already_removed >
|
||||
-pad->map.granule_offset ? 0 : -pad->map.granule_offset -
|
||||
already_removed;
|
||||
} else
|
||||
clip_start = pad->current_granule;
|
||||
}
|
||||
} else {
|
||||
|
@ -747,9 +753,15 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
|
|||
|
||||
if (pad->map.audio_clipping
|
||||
&& pad->current_granule - duration < -pad->map.granule_offset) {
|
||||
if (pad->current_granule >= -pad->map.granule_offset)
|
||||
clip_start = -pad->map.granule_offset;
|
||||
else
|
||||
if (pad->current_granule >= -pad->map.granule_offset) {
|
||||
guint64 already_removed =
|
||||
pad->current_granule >
|
||||
duration ? pad->current_granule - duration : 0;
|
||||
clip_start =
|
||||
already_removed >
|
||||
-pad->map.granule_offset ? 0 : -pad->map.granule_offset -
|
||||
already_removed;
|
||||
} else
|
||||
clip_start = pad->current_granule;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2030,21 +2030,13 @@ granulepos_to_granule_opus (GstOggStream * pad, gint64 granulepos)
|
|||
if (granulepos == -1)
|
||||
return -1;
|
||||
|
||||
/* We must reject some particular cases for the first granpos */
|
||||
|
||||
if (pad->first_granpos < 0 || granulepos < pad->first_granpos)
|
||||
pad->first_granpos = granulepos;
|
||||
|
||||
if (pad->first_granpos == granulepos) {
|
||||
if (granulepos < -pad->granule_offset) {
|
||||
GST_ERROR ("Invalid Opus stream: first granulepos (%" G_GINT64_FORMAT
|
||||
") less than preskip (%" G_GINT64_FORMAT ")", granulepos,
|
||||
-pad->granule_offset);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (granulepos < -pad->granule_offset)
|
||||
return 0;
|
||||
|
||||
return granulepos;
|
||||
return granulepos + pad->granule_offset;
|
||||
}
|
||||
|
||||
static gint64
|
||||
|
|
Loading…
Reference in a new issue