[0.11] gst-plugins-bad: interlace: avoid dividing by zero on unkbown framerate
Sebastian Dröge
slomo at kemper.freedesktop.org
Tue Jan 10 06:50:50 PST 2012
Module: gst-plugins-bad
Branch: 0.11
Commit: 1c25aab906041c1aa9bd38db3c9c958ad65a2c05
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=1c25aab906041c1aa9bd38db3c9c958ad65a2c05
Author: Vincent Penquerc'h <vincent.penquerch at collabora.co.uk>
Date: Fri Jan 6 10:39:07 2012 +0000
interlace: avoid dividing by zero on unkbown framerate
If the framerate is unknown, we cannot generate meaningful
buffer timestamps/durations, so set them to _NONE instead of
calculating something wrong and dividing by 0.
---
gst/interlace/gstinterlace.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/gst/interlace/gstinterlace.c b/gst/interlace/gstinterlace.c
index 0e86f85..1665ed7 100644
--- a/gst/interlace/gstinterlace.c
+++ b/gst/interlace/gstinterlace.c
@@ -328,13 +328,19 @@ gst_interlace_decorate_buffer (GstInterlace * interlace, GstBuffer * buf,
int n_fields)
{
/* field duration = src_fps_d / (2 * src_fps_n) */
- GST_BUFFER_TIMESTAMP (buf) = interlace->timebase +
- gst_util_uint64_scale (GST_SECOND,
- interlace->src_fps_d * interlace->fields_since_timebase,
- interlace->src_fps_n * 2);
- GST_BUFFER_DURATION (buf) =
- gst_util_uint64_scale (GST_SECOND, interlace->src_fps_d * n_fields,
- interlace->src_fps_n * 2);
+ if (interlace->src_fps_n == 0) {
+ /* If we don't know the fps, we can't generate timestamps/durations */
+ GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_DURATION (buf) = GST_CLOCK_TIME_NONE;
+ } else {
+ GST_BUFFER_TIMESTAMP (buf) = interlace->timebase +
+ gst_util_uint64_scale (GST_SECOND,
+ interlace->src_fps_d * interlace->fields_since_timebase,
+ interlace->src_fps_n * 2);
+ GST_BUFFER_DURATION (buf) =
+ gst_util_uint64_scale (GST_SECOND, interlace->src_fps_d * n_fields,
+ interlace->src_fps_n * 2);
+ }
/* increment the buffer timestamp by duration for the next buffer */
gst_buffer_set_caps (buf, interlace->srccaps);
More information about the gstreamer-commits
mailing list