From 8059457afb7d06d87d2be52a34df9072bb2b3ed0 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 10 Oct 2022 19:02:20 +0200 Subject: [PATCH] video: add support for a/xbgr8888 formats --- src/format.rs | 29 +++++++++++++++++++++++++++-- src/render/gl/sys.rs | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/format.rs b/src/format.rs index 3ae453f3..a9d32d18 100644 --- a/src/format.rs +++ b/src/format.rs @@ -1,9 +1,10 @@ use { crate::{ pipewire::pw_pod::{ - SPA_VIDEO_FORMAT_BGRx, SpaVideoFormat, SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_NV12, + SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx, SpaVideoFormat, SPA_VIDEO_FORMAT_BGRA, + SPA_VIDEO_FORMAT_NV12, SPA_VIDEO_FORMAT_RGBA, }, - render::sys::{GLint, GL_BGRA_EXT, GL_UNSIGNED_BYTE}, + render::sys::{GLint, GL_BGRA_EXT, GL_RGBA, GL_UNSIGNED_BYTE}, utils::debug_fn::debug_fn, }, ahash::AHashMap, @@ -107,6 +108,30 @@ pub static FORMATS: &[Format] = &[ shm_supported: true, pipewire: SPA_VIDEO_FORMAT_BGRx, }, + Format { + name: "abgr8888", + bpp: 4, + gl_format: GL_RGBA, + gl_type: GL_UNSIGNED_BYTE, + drm: fourcc_code('A', 'B', '2', '4'), + wl_id: None, + external_only_guess: false, + has_alpha: true, + shm_supported: true, + pipewire: SPA_VIDEO_FORMAT_RGBA, + }, + Format { + name: "xbgr8888", + bpp: 4, + gl_format: GL_RGBA, + gl_type: GL_UNSIGNED_BYTE, + drm: fourcc_code('X', 'B', '2', '4'), + wl_id: None, + external_only_guess: false, + has_alpha: false, + shm_supported: true, + pipewire: SPA_VIDEO_FORMAT_RGBx, + }, Format { name: "nv12", bpp: 1, // wrong but only used for shm diff --git a/src/render/gl/sys.rs b/src/render/gl/sys.rs index 006ce516..7c04973e 100644 --- a/src/render/gl/sys.rs +++ b/src/render/gl/sys.rs @@ -13,6 +13,7 @@ pub type GLuint = c::c_uint; egl_transparent!(GLeglImageOES); +pub const GL_RGBA: GLint = 0x1908; pub const GL_BGRA_EXT: GLint = 0x80E1; pub const GL_CLAMP_TO_EDGE: GLint = 0x812F; pub const GL_COLOR_ATTACHMENT0: GLenum = 0x8CE0;