Skip to content

v4l2object: Improve colorspace handling to support uvc device

Qi Hou requested to merge (removed):uvc into master

v4l2 encoder won't probe all colorspace, range, matrix and transfer combination to save initialization time for low-speed devices. YUV format supported gst colorimetry list of v4l2 encoder is like below if driver try_fmt doesn't set default colorimetry.

colorimetry=(string){2:4:5:4, smpte240m, bt709, 2:4:5:2, 2:4:5:3, 1:4:7:1, 2:4:7:1, 2:4:12:8, bt2020, 2:0:0:0 }

But uvc driver which is also open source sets below v4l2 colorimetry when try_fmt. And unfortunately this v4l2 default value is not in above colorimetry list after mapping to gst colorimetry. It causes not-negotiated and encoding with uvc camera can't work.

`format->colorspace = uvc_colorspace(buffer[3]); ------- V4L2_COLORSPACE_SRGB (8)

format->xfer_func = uvc_xfer_func(buffer[4]); ------- V4L2_XFER_FUNC_709 (1)

format->ycbcr_enc = uvc_ycbcr_enc(buffer[5]); ------- V4L2_YCBCR_ENC_601 (1)`

Take desired 1:4:7:1 as example, v4l2 colorimetry returned from uvc driver will map to 1:4:5:1 gst colorimetry. Since gst has limitation, we may need to allow this 1:4:5:1 in gst to support uvc device.

Edited by Qi Hou

Merge request reports

Loading