From c170056111fe0b3c4956a34276b5683e24b8c63c Mon Sep 17 00:00:00 2001 From: Yuriy Vasilev Date: Fri, 10 Sep 2021 16:20:06 +0300 Subject: [PATCH] glamor: xv: add rgb565 This commit adds RGB565 format to XVideo with reuse of RGBA32 shader Reviewed-by: Adam Jackson Signed-off-by: Yuriy Vasilev --- glamor/glamor_xv.c | 13 +++++++++++++ include/fourcc.h | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c index f368c0a9b..d897e9901 100644 --- a/glamor/glamor_xv.c +++ b/glamor/glamor_xv.c @@ -199,6 +199,7 @@ XvImageRec glamor_xv_images[] = { XVIMAGE_NV12, XVIMAGE_UYVY, XVIMAGE_RGB32, + XVIMAGE_RGB565, }; int glamor_xv_num_images = ARRAY_SIZE(glamor_xv_images); @@ -220,6 +221,7 @@ glamor_init_xv_shader(ScreenPtr screen, glamor_port_private *port_priv, int id) glamor_facet_xv_planar = &glamor_facet_xv_uyvy; break; case FOURCC_RGBA32: + case FOURCC_RGB565: glamor_facet_xv_planar = &glamor_facet_xv_rgb_raw; break; default: @@ -250,6 +252,7 @@ glamor_init_xv_shader(ScreenPtr screen, glamor_port_private *port_priv, int id) break; case FOURCC_UYVY: case FOURCC_RGBA32: + case FOURCC_RGB565: sampler_loc = glGetUniformLocation(port_priv->xv_prog.prog, "sampler"); glUniform1i(sampler_loc, 0); break; @@ -376,6 +379,7 @@ glamor_xv_query_image_attributes(int id, offsets[0] = 0; size *= *h; break; + case FOURCC_RGB565: case FOURCC_UYVY: /* UYVU is single-plane really, all tranformation is processed inside a shader */ size = *w * 2; @@ -516,6 +520,7 @@ glamor_xv_render(glamor_port_private *port_priv, int id) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); break; case FOURCC_RGBA32: + case FOURCC_RGB565: glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->fbo->tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -692,6 +697,13 @@ glamor_xv_put_image(glamor_port_private *port_priv, port_priv->src_pix[1] = NULL; port_priv->src_pix[2] = NULL; break; + case FOURCC_RGB565: + port_priv->src_pix[0] = + glamor_create_pixmap(pScreen, width, height, 16, + GLAMOR_CREATE_FBO_NO_FBO); + port_priv->src_pix[1] = NULL; + port_priv->src_pix[2] = NULL; + break; case FOURCC_UYVY: port_priv->src_pix[0] = glamor_create_pixmap(pScreen, width, height, 32, @@ -775,6 +787,7 @@ glamor_xv_put_image(glamor_port_private *port_priv, buf + s2offset, srcPitch); break; case FOURCC_UYVY: + case FOURCC_RGB565: srcPitch = width * 2; full_box.x1 = 0; full_box.y1 = 0; diff --git a/include/fourcc.h b/include/fourcc.h index 582a95afe..83e51a888 100644 --- a/include/fourcc.h +++ b/include/fourcc.h @@ -195,4 +195,24 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ 0 \ } + +#define FOURCC_RGB565 0x36314752 +#define XVIMAGE_RGB565 \ + { \ + FOURCC_RGB565, \ + XvRGB, \ + LSBFirst, \ + {'R','G','1','6', \ + 0x00, 0x00, 0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 16, 0xf800, 0x7e0, 0x1f, \ + 0, 0, 0, \ + 0, 0, 0, \ + 0, 0, 0, \ + {0,0,0,0, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \ + 0 \ + } #endif /* _XF86_FOURCC_H_ */