v4l2object: Need keep same transfer as input caps.

GST_VIDEO_TRANSFER_BT2020_12 and GST_VIDEO_TRANSFER_BT2020_10 will
be mapped to V4L2_XFER_FUNC_709. Need check input caps when map
V4L2_XFER_FUNC_709 back to GST_VIDEO_TRANSFER_BT2020_12 and
GST_VIDEO_TRANSFER_BT2020_10

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/816
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/841>
This commit is contained in:
Bing Song 2020-12-15 10:41:40 +08:00 committed by Kevin Song
parent 706d91371c
commit b87db31fbe
2 changed files with 13 additions and 6 deletions

View file

@ -2024,8 +2024,8 @@ gst_v4l2_object_get_interlace_mode (enum v4l2_field field,
}
static gboolean
gst_v4l2_object_get_colorspace (struct v4l2_format *fmt,
GstVideoColorimetry * cinfo)
gst_v4l2_object_get_colorspace (GstV4l2Object * v4l2object,
struct v4l2_format *fmt, GstVideoColorimetry * cinfo)
{
gboolean is_rgb =
gst_v4l2_object_v4l2fourcc_is_rgb (fmt->fmt.pix.pixelformat);
@ -2183,6 +2183,9 @@ gst_v4l2_object_get_colorspace (struct v4l2_format *fmt,
cinfo->transfer = GST_VIDEO_TRANSFER_BT2020_12;
else
cinfo->transfer = GST_VIDEO_TRANSFER_BT709;
if (v4l2object->transfer)
cinfo->transfer = v4l2object->transfer;
break;
case V4L2_XFER_FUNC_SRGB:
cinfo->transfer = GST_VIDEO_TRANSFER_SRGB;
@ -2356,7 +2359,7 @@ gst_v4l2_object_add_colorspace (GstV4l2Object * v4l2object, GstStructure * s,
/* step 1: get device default colorspace and insert it first as
* it should be the preferred one */
if (gst_v4l2_object_try_fmt (v4l2object, &fmt) == 0) {
if (gst_v4l2_object_get_colorspace (&fmt, &cinfo))
if (gst_v4l2_object_get_colorspace (v4l2object, &fmt, &cinfo))
gst_v4l2_object_fill_colorimetry_list (&list, &cinfo);
}
@ -2384,7 +2387,7 @@ gst_v4l2_object_add_colorspace (GstV4l2Object * v4l2object, GstStructure * s,
colorspace = fmt.fmt.pix.colorspace;
if (colorspace == req_cspace) {
if (gst_v4l2_object_get_colorspace (&fmt, &cinfo))
if (gst_v4l2_object_get_colorspace (v4l2object, &fmt, &cinfo))
gst_v4l2_object_fill_colorimetry_list (&list, &cinfo);
}
}
@ -3470,6 +3473,7 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
gst_video_info_init (&info);
gst_video_alignment_reset (&align);
v4l2object->transfer = GST_VIDEO_TRANSFER_UNKNOWN;
if (!gst_v4l2_object_get_caps_info (v4l2object, caps, &fmtdesc, &info))
goto invalid_caps;
@ -3584,7 +3588,9 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
transfer = V4L2_XFER_FUNC_NONE;
break;
case GST_VIDEO_TRANSFER_BT2020_12:
case GST_VIDEO_TRANSFER_BT2020_10:
case GST_VIDEO_TRANSFER_BT709:
v4l2object->transfer = info.colorimetry.transfer;
transfer = V4L2_XFER_FUNC_709;
break;
case GST_VIDEO_TRANSFER_SMPTE240M:
@ -3785,7 +3791,7 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
goto invalid_field;
}
if (gst_v4l2_object_get_colorspace (&format, &info.colorimetry)) {
if (gst_v4l2_object_get_colorspace (v4l2object, &format, &info.colorimetry)) {
if (gst_structure_has_field (s, "colorimetry")) {
if (!gst_v4l2_video_colorimetry_matches (&info.colorimetry,
gst_structure_get_string (s, "colorimetry")))
@ -4180,7 +4186,7 @@ gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object, GstVideoInfo * info)
gst_video_info_set_interlaced_format (info, format, interlace_mode, width,
height);
gst_v4l2_object_get_colorspace (&fmt, &info->colorimetry);
gst_v4l2_object_get_colorspace (v4l2object, &fmt, &info->colorimetry);
gst_v4l2_object_save_format (v4l2object, fmtdesc, &fmt, info, &align);

View file

@ -143,6 +143,7 @@ struct _GstV4l2Object {
struct v4l2_format format;
GstVideoInfo info;
GstVideoAlignment align;
GstVideoTransferFunction transfer;
/* Features */
gboolean need_video_meta;