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.
This commit is contained in:
Vincent Penquerc'h 2012-01-06 10:39:07 +00:00
parent 53735eaa72
commit 1c25aab906

View file

@ -328,13 +328,19 @@ gst_interlace_decorate_buffer (GstInterlace * interlace, GstBuffer * buf,
int n_fields) int n_fields)
{ {
/* field duration = src_fps_d / (2 * src_fps_n) */ /* field duration = src_fps_d / (2 * src_fps_n) */
GST_BUFFER_TIMESTAMP (buf) = interlace->timebase + if (interlace->src_fps_n == 0) {
gst_util_uint64_scale (GST_SECOND, /* If we don't know the fps, we can't generate timestamps/durations */
interlace->src_fps_d * interlace->fields_since_timebase, GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
interlace->src_fps_n * 2); GST_BUFFER_DURATION (buf) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DURATION (buf) = } else {
gst_util_uint64_scale (GST_SECOND, interlace->src_fps_d * n_fields, GST_BUFFER_TIMESTAMP (buf) = interlace->timebase +
interlace->src_fps_n * 2); 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 */ /* increment the buffer timestamp by duration for the next buffer */
gst_buffer_set_caps (buf, interlace->srccaps); gst_buffer_set_caps (buf, interlace->srccaps);