Skip to content

gallium: vl: Fix YUY2 and UYVY format mapping

Nicolas Dufresne requested to merge ndufresne/mesa:main into main

As implemented in src/gallium/frontends/dri/dri2.c:

static const struct dri2_format_mapping r8g8_r8b8_mapping = {
   DRM_FORMAT_YUYV,
   __DRI_IMAGE_FORMAT_NONE,
   __DRI_IMAGE_COMPONENTS_Y_XUXV,
   PIPE_FORMAT_R8G8_R8B8_UNORM, 2,
   { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88 },
     { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888 } }
};

static const struct dri2_format_mapping g8r8_b8r8_mapping = {
   DRM_FORMAT_UYVY,
   __DRI_IMAGE_FORMAT_NONE,
   __DRI_IMAGE_COMPONENTS_Y_XUXV,
   PIPE_FORMAT_G8R8_B8R8_UNORM, 2,
   { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88 },
     { 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR8888 } }
};

YUYV should map to PIPE_FORMAT_R8G8_R8B8_UNORM while UYVY to PIPE_FORMAT_G8R8_B8R8_UNORM. This is inverted in the video library. This bug became visible after fixing the swizzling for these formats.

Drafted in reply to @sathishs to !20815 (comment 1866482) but could not test it. Suggested tests are:

gst-launch-1.0 -v videotestsrc num-buffers=100 ! video/x-raw,width=800,height=640, format=YUY2 ! vaapisink 
gst-launch-1.0 -v videotestsrc num-buffers=100 ! video/x-raw,width=800,height=640, format=UYVY ! vaapisink 

Fixes: dc2119bf ("util/format: Fix wrong colors when importing YUYV and UYVY")

Signed-off-by: Nicolas Dufresne nicolas.dufresne@collabora.com

Edited by Nicolas Dufresne

Merge request reports