From 44fe87153432b17cf048c08ad1ac7fec555a5287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 5 Sep 2022 16:59:12 +0200 Subject: [PATCH] vajpegdec: Check if driver has internal color conversion. Part-of: --- .../gst-plugins-bad/sys/va/gstvajpegdec.c | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c b/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c index d4a18fb2ea..90090189d2 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c @@ -333,6 +333,25 @@ gst_va_jpeg_dec_output_picture (GstJpegDecoder * decoder, return gst_video_decoder_finish_frame (vdec, frame); } +/* @XXX: Checks for drivers that can do color convertion to nv12 + * regardless the input chroma, while it's YUV. */ +static gboolean +has_internal_nv12_color_convertion (GstVaBaseDec * base, GstVideoFormat format) +{ + if (!GST_VA_DISPLAY_IS_IMPLEMENTATION (base->display, INTEL_I965) + && !GST_VA_DISPLAY_IS_IMPLEMENTATION (base->display, INTEL_IHD)) + return FALSE; + + if (base->rt_format != VA_RT_FORMAT_YUV420 + && base->rt_format != VA_RT_FORMAT_YUV422) + return FALSE; + + if (format != GST_VIDEO_FORMAT_NV12) + return FALSE; + + return TRUE; +} + static gboolean gst_va_jpeg_dec_negotiate (GstVideoDecoder * decoder) { @@ -373,11 +392,7 @@ gst_va_jpeg_dec_negotiate (GstVideoDecoder * decoder) if (format == GST_VIDEO_FORMAT_UNKNOWN) return FALSE; - /* @XXX: validate if the preferred format has the same requested - * chroma, except for i965, since NV12 is either for both 4:2:0 and - * 4:2:2 */ - if (!(GST_VA_DISPLAY_IS_IMPLEMENTATION (base->display, INTEL_I965) - && format == GST_VIDEO_FORMAT_NV12) + if (!has_internal_nv12_color_convertion (base, format) && (gst_va_chroma_from_video_format (format) != base->rt_format)) return FALSE;