glamor: xv: add rgb565

This commit adds RGB565 format to XVideo with reuse of RGBA32 shader

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Yuriy Vasilev <uuvasiliev@yandex.ru>
This commit is contained in:
Yuriy Vasilev 2021-09-10 16:20:06 +03:00 committed by Konstantin
parent 15412e78c8
commit c170056111
2 changed files with 33 additions and 0 deletions

View File

@ -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;

View File

@ -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_ */