mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-08 13:18:52 +00:00
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
This commit is contained in:
parent
1438bf26ac
commit
8edb15d12f
1 changed files with 3 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue