From 8edb15d12f08f109a06d65b91c3aeb1a6127de6b Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 7 Aug 2011 12:23:26 +0200 Subject: [PATCH] v4l2src: Use fraction compare util function. Use the fraction compare utility to compare function, not the handcrafted one. The handcrafted one is buggy as it doesn't take into account rounding error. For example comparing a framerate of 20/1 on a camera configured as 30/1 fps would yield true: 1 == (1 * 20)/30 and not re-configure the camera. Fixes #656104 --- sys/v4l2/v4l2src_calls.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c index fb6c37456b..9627dfa766 100644 --- a/sys/v4l2/v4l2src_calls.c +++ b/sys/v4l2/v4l2src_calls.c @@ -202,11 +202,6 @@ too_many_trials: } } -/* Note about fraction simplification - * n1/d1 == n2/d2 is also written as n1 == ( n2 * d1 ) / d2 - */ -#define fractions_are_equal(n1,d1,n2,d2) ((n1) == gst_util_uint64_scale_int((n2), (d1), (d2))) - /****************************************************** * gst_v4l2src_set_capture(): * set capture parameters @@ -242,8 +237,9 @@ gst_v4l2src_set_capture (GstV4l2Src * v4l2src, guint32 pixelformat, } /* Note: V4L2 provides the frame interval, we have the frame rate */ - if (fractions_are_equal (stream.parm.capture.timeperframe.numerator, - stream.parm.capture.timeperframe.denominator, fps_d, fps_n)) { + if (gst_util_fraction_compare (stream.parm.capture.timeperframe.numerator, + stream.parm.capture.timeperframe.denominator, fps_d, fps_n) == 0) { + GST_DEBUG_OBJECT (v4l2src, "Desired framerate already set"); goto already_set; }