[vlc-commits] [Git][videolan/vlc][master] 14 commits: fourcc: add common 8-bit RGB without a mask
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Sep 15 06:04:45 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
3a40b06c by Steve Lhomme at 2023-09-15T05:45:05+00:00
fourcc: add common 8-bit RGB without a mask
They correspond to libavutil AV_PIX_FMT_RGB8, AV_PIX_FMT_BGR8
and V4L2_PIX_FMT_RGB332/DRM_FORMAT_RGB332.
- - - - -
2208f418 by Steve Lhomme at 2023-09-15T05:45:05+00:00
avcodec/chroma: map common RGB8 formats to libavutil ones
They have the same definition
- - - - -
e32e6ef1 by Steve Lhomme at 2023-09-15T05:45:05+00:00
avcodec/fourcc: map RGB8 formats to AV_CODEC_ID_RAWVIDEO
Just like VLC_CODEC_RGB8+mask.
- - - - -
f70f81c9 by Steve Lhomme at 2023-09-15T05:45:05+00:00
drm/fourcc: map RGB8 chromas
The memory layout is deduced from the name, not the doc [1].
[1] https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/drm_fourcc.c
- - - - -
c5eb7a00 by Steve Lhomme at 2023-09-15T05:45:05+00:00
access/v4l2: map V4L2_PIX_FMT_RGB332 to VLC_CODEC_RGB332
It corresponds to the same memory layout [1]
[1] https://www.kernel.org/doc/html/v4.15/media/uapi/v4l/pixfmt-packed-rgb.html
- - - - -
afba13d5 by Steve Lhomme at 2023-09-15T05:45:05+00:00
access: replace RGB8+mask with RGB233
This corresponds to the format with the default mask "0xC0, 0x38, 0x07".
- - - - -
4219688d by Steve Lhomme at 2023-09-15T05:45:05+00:00
screen/win32: use VLC_CODEC_RGB233 instead of VLC_CODEC_RGB8+mask
This is the chroma 8-bit RGB used by Windows
(mapped to AV_PIX_FMT_RGB8 in libavdevice).
- - - - -
444a2973 by Steve Lhomme at 2023-09-15T05:45:05+00:00
wingdi: use VLC_CODEC_RGB233 instead of VLC_CODEC_RGB8+mask
This is the chroma 8-bit RGB used by Windows
(mapped to AV_PIX_FMT_RGB8 in libavdevice).
- - - - -
ee35bf4b by Steve Lhomme at 2023-09-15T05:45:05+00:00
libplacebo: handle RGB233/BGR233/RGB332 instead of VLC_CODEC_RGB8+mask
- - - - -
271e8d7d by Steve Lhomme at 2023-09-15T05:45:05+00:00
screen/xcb: use VLC_CODEC_RGB233 with fixed mask instead of VLC_CODEC_RGB8+mask
This corresponds to the default mask.
- - - - -
78e8e114 by Steve Lhomme at 2023-09-15T05:45:05+00:00
xwd: use VLC_CODEC_RGB233 with fixed mask instead of VLC_CODEC_RGB8+mask
This corresponds to the default mask. libavcodec doesn't map it. It's
either a palette or a greyscale.
- - - - -
2a99faf4 by Steve Lhomme at 2023-09-15T05:45:05+00:00
xcb: map 8-bit True Color to VLC_CODEC_RGB233
It's the default mask for VLC_CODEC_RGB8+mask and corresponds to the same
mapping as libavdevice (AV_PIX_FMT_RGB8).
- - - - -
08b2de5f by Steve Lhomme at 2023-09-15T05:45:05+00:00
i420_rgb: handle common 8-bit RGB chromas like VLC_CODEC_RGB8+mask
- - - - -
709141fd by Steve Lhomme at 2023-09-15T05:45:05+00:00
fourcc: fallback to common RGB8 chromas instead of VLC_CODEC_RGB8+mask
We won't know the VLC_CODEC_RGB8 mask if it's selected.
The pp_RGB_fallback list suspiciously contains many times the same chroma.
- - - - -
16 changed files:
- include/vlc_fourcc.h
- modules/access/screen/win32.c
- modules/access/screen/xcb.c
- modules/access/shm.c
- modules/access/v4l2/video.c
- modules/access/vnc.c
- modules/codec/avcodec/chroma.c
- modules/codec/avcodec/fourcc.c
- modules/codec/xwd.c
- modules/video_chroma/i420_rgb.c
- modules/video_output/drm/fourcc.c
- modules/video_output/libplacebo/utils.c
- modules/video_output/win32/wingdi.c
- modules/video_output/xcb/pictures.c
- src/misc/fourcc.c
- src/misc/fourcc_list.h
Changes:
=====================================
include/vlc_fourcc.h
=====================================
@@ -363,6 +363,13 @@
/* 32-bit BGR, in memory address order: "XBGR" ignoring the x component */
#define VLC_CODEC_XBGR VLC_FOURCC('X','B','G','R')
+/* 8-bit RGB "R3G3B2" */
+#define VLC_CODEC_RGB332 VLC_FOURCC('R','3','3','2')
+/* 8-bit RGB "R2G3B3" */
+#define VLC_CODEC_RGB233 VLC_FOURCC('R','2','3','3')
+/* 8-bit BGR "B2G3R3" */
+#define VLC_CODEC_BGR233 VLC_FOURCC('B','2','3','3')
+
/* 32-bit RGBA, in memory address order: "RGBA" */
#define VLC_CODEC_RGBA VLC_FOURCC('R','G','B','A')
/* 32-bit ARGB, in memory address order: "ARGB" */
=====================================
modules/access/screen/win32.c
=====================================
@@ -128,7 +128,7 @@ int screen_InitCaptureGDI( demux_t *p_demux )
switch( i_bits_per_pixel )
{
case 8: /* FIXME: set the palette */
- i_chroma = VLC_CODEC_RGB8; break;
+ i_chroma = VLC_CODEC_RGB233; break;
case 15:
case 16: /* Yes it is really 15 bits (when using BI_RGB) */
i_chroma = VLC_CODEC_RGB15; break;
=====================================
modules/access/screen/xcb.c
=====================================
@@ -549,7 +549,7 @@ static es_out_id_t *InitES (demux_t *demux, uint_fast16_t width,
break;
case 8: /* XXX: screw grey scale! */
if (fmt->bits_per_pixel == 8)
- chroma = VLC_CODEC_RGB8;
+ chroma = VLC_CODEC_RGB233;
break;
}
if (chroma != 0)
=====================================
modules/access/shm.c
=====================================
@@ -164,7 +164,7 @@ static int Open (vlc_object_t *obj)
chroma = VLC_CODEC_RGB15; bpp = 16;
break;
case 8:
- chroma = VLC_CODEC_RGB8; bpp = 8;
+ chroma = VLC_CODEC_RGB233; bpp = 8;
break;
case 0:
chroma = VLC_CODEC_XWD; bpp = 0;
=====================================
modules/access/v4l2/video.c
=====================================
@@ -626,7 +626,7 @@ static const vlc_v4l2_fmt_t v4l2_fmts[] =
{ V4L2_PIX_FMT_RGB555, VLC_CODEC_RGB15, 2, 0x001F, 0x03E0, 0x7C00 },
// { V4L2_PIX_FMT_RGB555X, },
#endif
-// { V4L2_PIX_FMT_RGB332, VLC_CODEC_RGB8, 1, 0xC0, 0x38, 0x07 },
+ { V4L2_PIX_FMT_RGB332, VLC_CODEC_RGB332, 1, 0, 0, 0 },
/* Bayer (sub-sampled RGB). Not supported. */
// { V4L2_PIX_FMT_SBGGR16, }
=====================================
modules/access/vnc.c
=====================================
@@ -158,7 +158,7 @@ static rfbBool mallocFrameBufferHandler( rfbClient* p_client )
switch( i_bits_per_pixel )
{
case 8:
- i_chroma = VLC_CODEC_RGB8;
+ i_chroma = VLC_CODEC_RGB233;
break;
default:
case 16:
=====================================
modules/codec/avcodec/chroma.c
=====================================
@@ -140,6 +140,9 @@ static const struct
{VLC_CODEC_YVYU, AV_PIX_FMT_YVYU422, 0, 0, 0 },
/* Packed RGB formats */
+ {VLC_CODEC_RGB233, AV_PIX_FMT_RGB8, 0, 0, 0 },
+ {VLC_CODEC_BGR233, AV_PIX_FMT_BGR8, 0, 0, 0 },
+
VLC_RGB( VLC_CODEC_RGB8, AV_PIX_FMT_RGB8, AV_PIX_FMT_BGR8, 0xC0, 0x38, 0x07 )
VLC_RGB( VLC_CODEC_RGB15, AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555, 0x7c00, 0x03e0, 0x001f )
=====================================
modules/codec/avcodec/fourcc.c
=====================================
@@ -65,6 +65,9 @@ static const struct vlc_avcodec_fourcc video_codecs[] =
{ VLC_CODEC_RGB24, AV_CODEC_ID_RAWVIDEO },
{ VLC_CODEC_RGB16, AV_CODEC_ID_RAWVIDEO },
{ VLC_CODEC_RGB8, AV_CODEC_ID_RAWVIDEO },
+ { VLC_CODEC_RGB332, AV_CODEC_ID_RAWVIDEO },
+ { VLC_CODEC_RGB233, AV_CODEC_ID_RAWVIDEO },
+ { VLC_CODEC_BGR233, AV_CODEC_ID_RAWVIDEO },
{ VLC_CODEC_RGBA, AV_CODEC_ID_RAWVIDEO },
{ VLC_CODEC_ARGB, AV_CODEC_ID_RAWVIDEO },
{ VLC_CODEC_ABGR, AV_CODEC_ID_RAWVIDEO },
=====================================
modules/codec/xwd.c
=====================================
@@ -64,7 +64,7 @@ static int Decode (decoder_t *dec, block_t *block)
{
case 8:
if (ntohl(hdr->bits_per_pixel) == 8)
- chroma = VLC_CODEC_RGB8;
+ chroma = VLC_CODEC_RGB233;
break;
case 15:
if (ntohl(hdr->bits_per_pixel) == 16)
=====================================
modules/video_chroma/i420_rgb.c
=====================================
@@ -171,6 +171,9 @@ static int Activate( filter_t *p_filter )
return VLC_EGENERIC;
break;
#else
+ case VLC_CODEC_RGB233:
+ case VLC_CODEC_RGB332:
+ case VLC_CODEC_BGR233:
case VLC_CODEC_RGB8:
p_filter->ops = &I420_RGB8_ops;
break;
@@ -201,6 +204,9 @@ static int Activate( filter_t *p_filter )
switch( p_filter->fmt_out.video.i_chroma )
{
#ifdef PLUGIN_PLAIN
+ case VLC_CODEC_RGB233:
+ case VLC_CODEC_RGB332:
+ case VLC_CODEC_BGR233:
case VLC_CODEC_RGB8:
p_sys->i_bytespp = 1;
break;
@@ -282,6 +288,36 @@ static void SetYUV( filter_t *p_filter, const video_format_t *vfmt )
unsigned i_rgshift = 8 - vlc_popcount(vfmt->i_gmask);
unsigned i_rbshift = 8 - vlc_popcount(vfmt->i_bmask);
+ switch (p_filter->fmt_out.video.i_chroma)
+ {
+ case VLC_CODEC_RGB233:
+ i_lrshift = 6;
+ i_lgshift = 3;
+ i_lbshift = 0;
+ i_rrshift = 6;
+ i_rgshift = 5;
+ i_rbshift = 5;
+ break;
+ case VLC_CODEC_BGR233:
+ i_lbshift = 6;
+ i_lgshift = 3;
+ i_lrshift = 0;
+ i_rbshift = 6;
+ i_rgshift = 5;
+ i_rrshift = 5;
+ break;
+ case VLC_CODEC_RGB332:
+ i_lrshift = 5;
+ i_lgshift = 2;
+ i_lbshift = 0;
+ i_rrshift = 5;
+ i_rgshift = 5;
+ i_rbshift = 6;
+ break;
+ default:
+ break;
+ }
+
/*
* Set pointers and build YUV tables
*/
@@ -289,6 +325,9 @@ static void SetYUV( filter_t *p_filter, const video_format_t *vfmt )
/* Color: build red, green and blue tables */
switch( p_filter->fmt_out.video.i_chroma )
{
+ case VLC_CODEC_RGB233:
+ case VLC_CODEC_RGB332:
+ case VLC_CODEC_BGR233:
case VLC_CODEC_RGB8:
p_sys->p_rgb8 = (uint8_t *)p_sys->p_base;
Set8bppPalette( p_filter, p_sys->p_rgb8 );
=====================================
modules/video_output/drm/fourcc.c
=====================================
@@ -118,9 +118,6 @@ static const struct {
uint32_t green; /**< Little endian green mask */
uint32_t blue; /**< Little endian blue mask */
} rgb_fourcc_list[] = {
- /* 8-bit RGB */
- { DRM_FORMAT_RGB332, VLC_CODEC_RGB8, 0xD0, 0x16, 0x03 },
- { DRM_FORMAT_BGR233, VLC_CODEC_RGB8, 0x07, 0x28, 0xC0 },
#ifdef WORDS_BIGENDIAN
/* 24-bit RGB */
{ DRM_FORMAT_RGB888, VLC_CODEC_RGB24, 0x0000FF, 0x00FF00, 0xFF0000 },
@@ -172,6 +169,10 @@ static const struct {
{ DRM_FORMAT_ABGR2101010, VLC_CODEC_RGBA10 },
#endif
+ /* 8-bit RGB */
+ { DRM_FORMAT_RGB332, VLC_CODEC_RGB332 },
+ { DRM_FORMAT_BGR233, VLC_CODEC_BGR233 },
+
/* Packed YUV formats */
/* DRM uses big-endian for YUY2, otherwise little endian. */
{ DRM_FORMAT_YUYV, VLC_CODEC_YUYV },
=====================================
modules/video_output/libplacebo/utils.c
=====================================
@@ -191,7 +191,9 @@ static const struct { vlc_fourcc_t fcc; struct fmt_desc desc; } formats[] = {
{ VLC_CODEC_NV24, {SEMIPLANAR(2, 8, _444)} },
{ VLC_CODEC_NV42, {SEMIPLANAR(2, 8, _444)} },
- { VLC_CODEC_RGB8, {PACKED(3, 2, 2)} },
+ { VLC_CODEC_RGB233, {PACKED(3, 2, 2)} },
+ { VLC_CODEC_BGR233, {PACKED(3, 2, 2)} },
+ { VLC_CODEC_RGB332, {PACKED(3, 2, 2)} },
{ VLC_CODEC_RGB15, {PACKED(3, 5, 1)} },
{ VLC_CODEC_RGB16, {PACKED(3, 5, 1)} },
{ VLC_CODEC_RGB24, {PACKED(3, 8, 0)} },
@@ -298,7 +300,23 @@ static void FillDesc(vlc_fourcc_t fcc, const struct fmt_desc *desc,
data[0].component_size[1] += 1;
break;
- case VLC_CODEC_RGB8:
+ case VLC_CODEC_RGB233:
+ // 2:3:3 instead of 2:2:2
+ data[0].component_size[1] += 1;
+ data[0].component_size[2] += 1;
+ break;
+
+ case VLC_CODEC_BGR233:
+ // 2:3:3 instead of 2:2:2
+ data[0].component_size[1] += 1;
+ data[0].component_size[2] += 1;
+ // Packed BGR
+ data[0].component_map[0] = 2;
+ data[0].component_map[1] = 1;
+ data[0].component_map[2] = 0;
+ break;
+
+ case VLC_CODEC_RGB332:
// 3:3:2 instead of 2:2:2
data[0].component_size[0] += 1;
data[0].component_size[1] += 1;
=====================================
modules/video_output/win32/wingdi.c
=====================================
@@ -264,7 +264,7 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
msg_Dbg(vd, "GDI depth is %i", i_depth);
switch (i_depth) {
case 8:
- fmt->i_chroma = VLC_CODEC_RGB8;
+ fmt->i_chroma = VLC_CODEC_RGB233;
break;
case 15:
fmt->i_chroma = VLC_CODEC_RGB15;
=====================================
modules/video_output/xcb/pictures.c
=====================================
@@ -126,7 +126,7 @@ bool vlc_xcb_VisualToFormat(const xcb_setup_t *setup, uint_fast8_t depth,
if (fmt->bits_per_pixel != 8)
return false;
if (vt->_class == XCB_VISUAL_CLASS_TRUE_COLOR)
- f->i_chroma = VLC_CODEC_RGB8;
+ f->i_chroma = VLC_CODEC_RGB233;
else
f->i_chroma = VLC_CODEC_GREY;
break;
=====================================
src/misc/fourcc.c
=====================================
@@ -573,7 +573,9 @@ static const vlc_fourcc_t p_RGB32_fallback[] = {
VLC_CODEC_RGB24,
VLC_CODEC_RGB16,
VLC_CODEC_RGB15,
- VLC_CODEC_RGB8,
+ VLC_CODEC_RGB233,
+ VLC_CODEC_BGR233,
+ VLC_CODEC_RGB332,
0,
};
static const vlc_fourcc_t p_RGB24_fallback[] = {
@@ -581,7 +583,9 @@ static const vlc_fourcc_t p_RGB24_fallback[] = {
VLC_CODEC_RGB32,
VLC_CODEC_RGB16,
VLC_CODEC_RGB15,
- VLC_CODEC_RGB8,
+ VLC_CODEC_RGB233,
+ VLC_CODEC_BGR233,
+ VLC_CODEC_RGB332,
0,
};
static const vlc_fourcc_t p_RGB16_fallback[] = {
@@ -589,7 +593,9 @@ static const vlc_fourcc_t p_RGB16_fallback[] = {
VLC_CODEC_RGB24,
VLC_CODEC_RGB32,
VLC_CODEC_RGB15,
- VLC_CODEC_RGB8,
+ VLC_CODEC_RGB233,
+ VLC_CODEC_BGR233,
+ VLC_CODEC_RGB332,
0,
};
static const vlc_fourcc_t p_RGB15_fallback[] = {
@@ -597,11 +603,15 @@ static const vlc_fourcc_t p_RGB15_fallback[] = {
VLC_CODEC_RGB16,
VLC_CODEC_RGB24,
VLC_CODEC_RGB32,
- VLC_CODEC_RGB8,
+ VLC_CODEC_RGB233,
+ VLC_CODEC_BGR233,
+ VLC_CODEC_RGB332,
0,
};
static const vlc_fourcc_t p_RGB8_fallback[] = {
- VLC_CODEC_RGB8,
+ VLC_CODEC_RGB233,
+ VLC_CODEC_BGR233,
+ VLC_CODEC_RGB332,
VLC_CODEC_RGB15,
VLC_CODEC_RGB16,
VLC_CODEC_RGB24,
@@ -790,6 +800,8 @@ static const struct
{ { VLC_CODEC_YUYV, VLC_CODEC_YVYU,
VLC_CODEC_UYVY, VLC_CODEC_VYUY }, PACKED_FMT(2, 16) },
{ { VLC_CODEC_YUV2 }, PACKED_FMT(2, 16) },
+ { { VLC_CODEC_RGB233, VLC_CODEC_BGR233,
+ VLC_CODEC_RGB332, 0 }, PACKED_FMT(1, 8) },
{ { VLC_CODEC_RGB8, VLC_CODEC_GREY,
VLC_CODEC_YUVP, VLC_CODEC_RGBP }, PACKED_FMT(1, 8) },
=====================================
src/misc/fourcc_list.h
=====================================
@@ -807,6 +807,12 @@ static const staticentry_t p_list_video[] = {
B(VLC_CODEC_RGB8, "8 bits RGB"),
A("RGB2"),
+ B(VLC_CODEC_RGB233, "8 bits RGB 2:3:3"),
+ A("R233"),
+ B(VLC_CODEC_RGB332, "8 bits RGB 3:3:2"),
+ A("R332"),
+ B(VLC_CODEC_BGR233, "8 bits BGR 2:3:3"),
+ A("B233"),
B(VLC_CODEC_RGB15, "15 bits RGB"),
A("RV15"),
B(VLC_CODEC_RGB16, "16 bits RGB"),
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/06fc45ca02e30d59dfcfa4d3e409c41cb926f067...709141fd7afa5d5b7cfdd775360fdc152525eefa
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/06fc45ca02e30d59dfcfa4d3e409c41cb926f067...709141fd7afa5d5b7cfdd775360fdc152525eefa
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list