mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
ext/theora/theoradec.c: Calculate buffer duration correctly to generate a perfect stream (#433888).
Original commit message from CVS: 2007-04-27 Julien MOUTTE <julien@moutte.net> * ext/theora/theoradec.c: (_theora_granule_time), (theora_dec_push_forward), (theora_handle_data_packet), (theora_dec_decode_buffer): Calculate buffer duration correctly to generate a perfect stream (#433888). * gst/audioresample/gstaudioresample.c: (audioresample_check_discont): Glib provides ABS.
This commit is contained in:
parent
f23356bd8f
commit
d299d1c063
3 changed files with 28 additions and 9 deletions
|
@ -1,3 +1,12 @@
|
|||
2007-04-27 Julien MOUTTE <julien@moutte.net>
|
||||
|
||||
* ext/theora/theoradec.c: (_theora_granule_time),
|
||||
(theora_dec_push_forward), (theora_handle_data_packet),
|
||||
(theora_dec_decode_buffer): Calculate buffer duration correctly
|
||||
to generate a perfect stream (#433888).
|
||||
* gst/audioresample/gstaudioresample.c:
|
||||
(audioresample_check_discont): Glib provides ABS.
|
||||
|
||||
2007-04-27 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_get_rb),
|
||||
|
|
|
@ -230,7 +230,7 @@ _theora_granule_frame (GstTheoraDec * dec, gint64 granulepos)
|
|||
static GstClockTime
|
||||
_theora_granule_time (GstTheoraDec * dec, gint64 granulepos)
|
||||
{
|
||||
gint framecount;
|
||||
gint64 framecount;
|
||||
|
||||
/* invalid granule results in invalid time */
|
||||
if (granulepos == -1)
|
||||
|
@ -936,6 +936,10 @@ theora_dec_push_forward (GstTheoraDec * dec, GstBuffer * buf)
|
|||
|
||||
GST_DEBUG_OBJECT (dec, "patch buffer %lld %lld", size, time);
|
||||
GST_BUFFER_TIMESTAMP (buffer) = time;
|
||||
/* Next timestamp - this one is duration */
|
||||
GST_BUFFER_DURATION (buffer) =
|
||||
(outtime - gst_util_uint64_scale_int ((size - 1) * GST_SECOND,
|
||||
dec->info.fps_denominator, dec->info.fps_numerator)) - time;
|
||||
|
||||
if (dec->discont) {
|
||||
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
|
||||
|
@ -1103,9 +1107,16 @@ theora_handle_data_packet (GstTheoraDec * dec, ogg_packet * packet,
|
|||
if (dec->frame_nr != -1)
|
||||
dec->frame_nr++;
|
||||
GST_BUFFER_OFFSET_END (out) = dec->frame_nr;
|
||||
GST_BUFFER_DURATION (out) =
|
||||
gst_util_uint64_scale_int (GST_SECOND, dec->info.fps_denominator,
|
||||
dec->info.fps_numerator);
|
||||
if (dec->granulepos != -1) {
|
||||
gint64 cf = _theora_granule_frame (dec, dec->granulepos) + 1;
|
||||
|
||||
GST_BUFFER_DURATION (out) = gst_util_uint64_scale_int (cf * GST_SECOND,
|
||||
dec->info.fps_denominator, dec->info.fps_numerator) - outtime;
|
||||
} else {
|
||||
GST_BUFFER_DURATION (out) =
|
||||
gst_util_uint64_scale_int (GST_SECOND, dec->info.fps_denominator,
|
||||
dec->info.fps_numerator);
|
||||
}
|
||||
GST_BUFFER_TIMESTAMP (out) = outtime;
|
||||
|
||||
if (dec->segment.rate >= 0.0)
|
||||
|
@ -1190,8 +1201,9 @@ theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf)
|
|||
dec->last_timestamp = -1;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (dec, "header=%02x packetno=%lld, outtime=%" GST_TIME_FORMAT,
|
||||
packet.bytes ? packet.packet[0] : -1, packet.packetno,
|
||||
GST_DEBUG_OBJECT (dec, "header=%02x packetno=%lld, granule pos=%"
|
||||
G_GINT64_FORMAT ", outtime=%" GST_TIME_FORMAT,
|
||||
packet.bytes ? packet.packet[0] : -1, packet.packetno, packet.granulepos,
|
||||
GST_TIME_ARGS (dec->last_timestamp));
|
||||
|
||||
/* switch depending on packet type. A zero byte packet is always a data
|
||||
|
|
|
@ -575,8 +575,6 @@ audioresample_do_output (GstAudioresample * audioresample, GstBuffer * outbuf)
|
|||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
/* llabs() is C99, so we might not have it; just use a simple macro... */
|
||||
#define LLABS(x) ((x>0)?x:-x)
|
||||
static gboolean
|
||||
audioresample_check_discont (GstAudioresample * audioresample,
|
||||
GstClockTime timestamp)
|
||||
|
@ -592,7 +590,7 @@ audioresample_check_discont (GstAudioresample * audioresample,
|
|||
GstClockTimeDiff diff = timestamp -
|
||||
(audioresample->prev_ts + audioresample->prev_duration);
|
||||
|
||||
if (LLABS (diff) > GST_SECOND / audioresample->i_rate) {
|
||||
if (ABS (diff) > GST_SECOND / audioresample->i_rate) {
|
||||
GST_WARNING_OBJECT (audioresample,
|
||||
"encountered timestamp discontinuity of %" G_GINT64_FORMAT, diff);
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in a new issue