oggdemux: Allow start clipping for Opus

The granulepos does not have the pre-skip subtracted while timestamps do,
and the last granulepos will be shorter by the number of samples that should
be dropped because of padding in the end.

As such, extrapolating the granule of the beginning of the first frame will
lead to a negative value, which is not a problem but intentional.

https://bugzilla.gnome.org/show_bug.cgi?id=757153
This commit is contained in:
Sebastian Dröge 2015-11-02 11:19:23 +02:00
parent 1f2fdd3789
commit 8a3be7323a
3 changed files with 3 additions and 10 deletions

View file

@ -1058,14 +1058,8 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet)
if (granule >= pad->map.accumulated_granule)
start_granule = granule - pad->map.accumulated_granule;
else {
if (pad->map.forbid_start_clamping) {
GST_ERROR_OBJECT (ogg, "Start of stream maps to negative time");
return GST_FLOW_ERROR;
} else {
start_granule = 0;
}
}
else
start_granule = 0;
pad->start_time = gst_ogg_stream_granule_to_time (&pad->map,
start_granule);
@ -1294,6 +1288,7 @@ gst_ogg_demux_setup_first_granule (GstOggDemux * ogg, GstOggPad * pad,
GST_DEBUG_OBJECT (pad,
"This page completes %d packets, granule %" G_GINT64_FORMAT, packets,
granule);
if (packets > 0) {
ogg_stream_state os;
ogg_packet op;

View file

@ -2000,7 +2000,6 @@ setup_opus_mapper (GstOggStream * pad, ogg_packet * packet)
pad->granuleshift = 0;
pad->n_header_packets = 2;
pad->first_granpos = -1;
pad->forbid_start_clamping = TRUE;
/* pre-skip is in samples at 48000 Hz, which matches granule one for one */
pad->granule_offset = -GST_READ_UINT16_LE (packet->packet + 10);

View file

@ -70,7 +70,6 @@ struct _GstOggStream
gint bitrate;
guint64 total_time;
gboolean is_sparse;
gboolean forbid_start_clamping;
GstCaps *caps;