mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
ext/theora/theoradec.c: Better clipping.
Original commit message from CVS: * ext/theora/theoradec.c: (clip_buffer): Better clipping.
This commit is contained in:
parent
843202b51c
commit
5f3f10861e
2 changed files with 31 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2006-07-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/theora/theoradec.c: (clip_buffer):
|
||||||
|
Better clipping.
|
||||||
|
|
||||||
2006-07-21 Wim Taymans <wim@fluendo.com>
|
2006-07-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst-libs/gst/audio/gstaudiosink.c: (audioringbuffer_thread_func),
|
* gst-libs/gst/audio/gstaudiosink.c: (audioringbuffer_thread_func),
|
||||||
|
|
|
@ -865,35 +865,45 @@ header_read_error:
|
||||||
|
|
||||||
/* returns TRUE if buffer is within segment, else FALSE.
|
/* returns TRUE if buffer is within segment, else FALSE.
|
||||||
* if Buffer is on segment border, it's timestamp and duration will be clipped */
|
* if Buffer is on segment border, it's timestamp and duration will be clipped */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
clip_buffer (GstTheoraDec * dec, GstBuffer * buf)
|
clip_buffer (GstTheoraDec * dec, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
gboolean res = FALSE;
|
gboolean res = TRUE;
|
||||||
|
GstClockTime in_ts, in_dur, stop;
|
||||||
gint64 cstart, cstop;
|
gint64 cstart, cstop;
|
||||||
|
|
||||||
|
in_ts = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
in_dur = GST_BUFFER_DURATION (buf);
|
||||||
|
|
||||||
GST_LOG_OBJECT (dec,
|
GST_LOG_OBJECT (dec,
|
||||||
"timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
|
"timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur));
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
|
||||||
|
|
||||||
if (dec->segment.format != GST_FORMAT_TIME) {
|
/* can't clip without TIME segment */
|
||||||
res = TRUE;
|
if (dec->segment.format != GST_FORMAT_TIME)
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(gst_segment_clip (&dec->segment, GST_FORMAT_TIME,
|
|
||||||
GST_BUFFER_TIMESTAMP (buf),
|
|
||||||
GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf),
|
|
||||||
&cstart, &cstop)))
|
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
|
/* we need a start time */
|
||||||
|
if (!GST_CLOCK_TIME_IS_VALID (in_ts))
|
||||||
|
goto beach;
|
||||||
|
|
||||||
|
/* generate valid stop, if duration unknown, we have unknown stop */
|
||||||
|
stop =
|
||||||
|
GST_CLOCK_TIME_IS_VALID (in_dur) ? (in_ts + in_dur) : GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
|
/* now clip */
|
||||||
|
if (!(res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME,
|
||||||
|
in_ts, stop, &cstart, &cstop)))
|
||||||
|
goto beach;
|
||||||
|
|
||||||
|
/* update timestamp and possibly duration if the clipped stop time is
|
||||||
|
* valid */
|
||||||
GST_BUFFER_TIMESTAMP (buf) = cstart;
|
GST_BUFFER_TIMESTAMP (buf) = cstart;
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (cstop))
|
||||||
GST_BUFFER_DURATION (buf) = cstop - cstart;
|
GST_BUFFER_DURATION (buf) = cstop - cstart;
|
||||||
res = TRUE;
|
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
GST_LOG_OBJECT (dec, "dropping : %d", res);
|
GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue