From 8a3be7323a2ebde4febe0597acc96cb0fb6ea1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 2 Nov 2015 11:19:23 +0200 Subject: [PATCH] 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 --- ext/ogg/gstoggdemux.c | 11 +++-------- ext/ogg/gstoggstream.c | 1 - ext/ogg/gstoggstream.h | 1 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 0264469820..165420c80e 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -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; diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c index d0d50d90fa..241c9fffb8 100644 --- a/ext/ogg/gstoggstream.c +++ b/ext/ogg/gstoggstream.c @@ -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); diff --git a/ext/ogg/gstoggstream.h b/ext/ogg/gstoggstream.h index 06e2907351..26dc8e0610 100644 --- a/ext/ogg/gstoggstream.h +++ b/ext/ogg/gstoggstream.h @@ -70,7 +70,6 @@ struct _GstOggStream gint bitrate; guint64 total_time; gboolean is_sparse; - gboolean forbid_start_clamping; GstCaps *caps;