[vlc-commits] [Git][videolan/vlc][master] codec: avcodec: fix mask mappings for 32 bits RGB

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Aug 15 10:12:03 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
081a0e62 by Francois Cartegnie at 2023-08-15T09:46:39+00:00
codec: avcodec: fix mask mappings for 32 bits RGB

The macros can not handle alpha channel properly,
as it does not only requires reassigning channels
but shifting.

Mapping to/from RGB32 also loses alpha information.

We can not rely on AV native macros for this and
need to declare chroma with fixed alpha position

Could also modify the macro to add left or right
shifts parameters and even less readable for 2 chromas.

- - - - -


1 changed file:

- modules/codec/avcodec/chroma.c


Changes:

=====================================
modules/codec/avcodec/chroma.c
=====================================
@@ -149,13 +149,13 @@ static const struct
     VLC_RGB( VLC_CODEC_RGB15, AV_PIX_FMT_RGB555, AV_PIX_FMT_BGR555, 0x7c00, 0x03e0, 0x001f )
     VLC_RGB( VLC_CODEC_RGB16, AV_PIX_FMT_RGB565, AV_PIX_FMT_BGR565, 0xf800, 0x07e0, 0x001f )
     VLC_RGB( VLC_CODEC_RGB24, AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, 0xff0000, 0x00ff00, 0x0000ff )
+    VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR, 0x00ff0000, 0x0000ff00, 0x000000ff)
+    VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0, 0xff000000, 0x00ff0000, 0x0000ff00)
 
-    VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB32, AV_PIX_FMT_BGR32, 0x00ff0000, 0x0000ff00, 0x000000ff )
-    VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_RGB32_1, AV_PIX_FMT_BGR32_1, 0xff000000, 0x00ff0000, 0x0000ff00 )
-
-#ifdef AV_PIX_FMT_0BGR32
-    VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_0BGR32, AV_PIX_FMT_0RGB32, 0x000000ff, 0x0000ff00, 0x00ff0000 )
-#endif
+    {VLC_CODEC_RGBA, AV_PIX_FMT_RGBA, 0, 0, 0 },
+    {VLC_CODEC_ARGB, AV_PIX_FMT_ARGB, 0, 0, 0 },
+    {VLC_CODEC_BGRA, AV_PIX_FMT_BGRA, 0, 0, 0 },
+    {VLC_CODEC_ABGR, AV_PIX_FMT_ABGR, 0, 0, 0 },
 
 #ifdef WORDS_BIGENDIAN
     {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64BE, 0, 0, 0 },
@@ -167,10 +167,6 @@ static const struct
     {VLC_CODEC_RGBA10, AV_PIX_FMT_X2BGR10, 0, 0, 0 },
 #endif
 
-    {VLC_CODEC_RGBA, AV_PIX_FMT_RGBA, 0, 0, 0 },
-    {VLC_CODEC_ARGB, AV_PIX_FMT_ARGB, 0, 0, 0 },
-    {VLC_CODEC_BGRA, AV_PIX_FMT_BGRA, 0, 0, 0 },
-    {VLC_CODEC_ABGR, AV_PIX_FMT_ABGR, 0, 0, 0 },
     {VLC_CODEC_GREY, AV_PIX_FMT_GRAY8, 0, 0, 0},
 #ifdef AV_PIX_FMT_GRAY10
     {VLC_CODEC_GREY_10L, AV_PIX_FMT_GRAY10LE, 0, 0, 0},



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/081a0e62a0d68a62fd5fe96407eaa15cb4cf367c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/081a0e62a0d68a62fd5fe96407eaa15cb4cf367c
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