v4l2: Add protection when set decoder capture fps accroding to output fps

Some v4l2 drivers don't have the capacity to change framerate. There is
chance to make decoder capture fps to be 0/0 if numerator and denominator
returned by G_PARM ioctl are both 0. It causes critical warning
"passed '0' as denominator for `GstFraction'".

In order to fix this, add protection when set decoder capture fps according
to output fps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1048>
This commit is contained in:
Hou Qi 2021-08-09 10:46:30 +08:00 committed by GStreamer Marge Bot
parent 9a216d0ffa
commit 0e7a485528

View file

@ -2229,8 +2229,9 @@ gst_v4l2_object_get_streamparm (GstV4l2Object * v4l2object, GstVideoInfo * info)
GST_WARNING_OBJECT (v4l2object->dbg_obj, "VIDIOC_G_PARM failed");
return FALSE;
}
if (v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE
|| v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if ((streamparm.parm.capture.timeperframe.numerator != 0)
&& (v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE
|| v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
GST_VIDEO_INFO_FPS_N (info) =
streamparm.parm.capture.timeperframe.denominator;
GST_VIDEO_INFO_FPS_D (info) =
@ -4239,7 +4240,8 @@ gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object, GstVideoInfo * info)
gst_v4l2_object_get_colorspace (v4l2object, &fmt, &info->colorimetry);
gst_v4l2_object_get_streamparm (v4l2object, info);
if ((info->fps_n == 0) && (v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE
if ((info->fps_n == 0 && v4l2object->info.fps_d != 0)
&& (v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE
|| v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
info->fps_d = v4l2object->info.fps_d;
info->fps_n = v4l2object->info.fps_n;