[vlc-commits] [Git][videolan/vlc][master] 4 commits: bitmapinfoheader: document the RGB15/RGB16 mask

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Sep 2 11:00:24 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
85904d14 by Steve Lhomme at 2023-09-02T10:39:45+00:00
bitmapinfoheader: document the RGB15/RGB16 mask

- - - - -
f89c66b9 by Steve Lhomme at 2023-09-02T10:39:45+00:00
bitmapinfoheader: pass the video_format_t to set the chroma+mask

It is suspicious that we first set the mask and then we call
video_format_FixRgb() which will overwrite the values we just wrote.

The RGB16/RGB16 masks are the same but RGB24/RGB32 are not.

- - - - -
16f95826 by Steve Lhomme at 2023-09-02T10:39:45+00:00
bitmapinfoheader: remove RGBA with mask

VLC_CODEC_RGBA doesn't use a mask because it's implied by the fixed layout.
The tests against a VLC_CODEC_RGBA video_format_t masks will always fail.

- - - - -
6b8870cc by Steve Lhomme at 2023-09-02T10:39:45+00:00
bitmapinfoheader: remove always false test

The BGRA and ARGB would always fail. And now RGBA always fails too.

- - - - -


1 changed file:

- modules/demux/avi/bitmapinfoheader.h


Changes:

=====================================
modules/demux/avi/bitmapinfoheader.h
=====================================
@@ -44,10 +44,10 @@ static const struct
     vlc_fourcc_t codec;
     uint32_t i_rmask, i_gmask, i_bmask;
 } bitmap_rgb_masks[] = {
-    { VLC_CODEC_RGB15,      0x7c00,
+    { VLC_CODEC_RGB15,      0x7c00, /* R5G5B5 */
                             0x03e0,
                             0x001f, },
-    { VLC_CODEC_RGB16,      0xf800,
+    { VLC_CODEC_RGB16,      0xf800, /* R5G6B5 */
                             0x07e0,
                             0x001f, },
     { VLC_CODEC_RGB24,      0x000000ff, /* BGR (see biBitCount) */
@@ -56,22 +56,19 @@ static const struct
     { VLC_CODEC_RGB32,      0x0000ff00, /* This is in BGR0 format */
                             0x00ff0000,
                             0xff000000U, },
-    { VLC_CODEC_RGBA,       0x0000ff00, /* This is in BGRA format */
-                            0x00ff0000,
-                            0xff000000U, },
 };
 
-static inline void SetBitmapRGBMasks( vlc_fourcc_t i_fourcc, es_format_t *fmt )
+static inline void SetBitmapRGBMasks( vlc_fourcc_t i_fourcc, video_format_t *fmt )
 {
     for( size_t i=0; i<ARRAY_SIZE(bitmap_rgb_masks); i++ )
     {
         if( bitmap_rgb_masks[i].codec == i_fourcc )
         {
-            fmt->video.i_rmask = bitmap_rgb_masks[i].i_rmask;
-            fmt->video.i_gmask = bitmap_rgb_masks[i].i_gmask;
-            fmt->video.i_bmask = bitmap_rgb_masks[i].i_bmask;
-            fmt->video.i_chroma = i_fourcc;
-            video_format_FixRgb( &fmt->video );
+            fmt->i_rmask = bitmap_rgb_masks[i].i_rmask;
+            fmt->i_gmask = bitmap_rgb_masks[i].i_gmask;
+            fmt->i_bmask = bitmap_rgb_masks[i].i_bmask;
+            fmt->i_chroma = i_fourcc;
+            video_format_FixRgb( fmt );
             break;
         }
     }
@@ -117,19 +114,19 @@ static inline int ParseBitmapInfoHeader( VLC_BITMAPINFOHEADER *p_bih, size_t i_b
         {
             case 32:
                 fmt->i_codec = VLC_CODEC_RGB32;
-                SetBitmapRGBMasks( fmt->i_codec, fmt );
+                SetBitmapRGBMasks( fmt->i_codec, &fmt->video );
                 break;
             case 24:
                 fmt->i_codec = VLC_CODEC_RGB24; /* BGR (see biBitCount) */
-                SetBitmapRGBMasks( fmt->i_codec, fmt );
+                SetBitmapRGBMasks( fmt->i_codec, &fmt->video );
                 break;
             case 16:
                 fmt->i_codec = VLC_CODEC_RGB16; /* RGB (5,6,5 bits) */
-                SetBitmapRGBMasks( fmt->i_codec, fmt );
+                SetBitmapRGBMasks( fmt->i_codec, &fmt->video );
                 break;
             case 15: /* RGB (B least 5 bits) */
                 fmt->i_codec = VLC_CODEC_RGB15;
-                SetBitmapRGBMasks( fmt->i_codec, fmt );
+                SetBitmapRGBMasks( fmt->i_codec, &fmt->video );
                 break;
             case 9: /* <- TODO check that */
                 fmt->i_codec = VLC_CODEC_I410;
@@ -160,7 +157,7 @@ static inline int ParseBitmapInfoHeader( VLC_BITMAPINFOHEADER *p_bih, size_t i_b
                         fmt->i_codec = VLC_CODEC_BGRA;
                 }
             }
-            SetBitmapRGBMasks( fmt->i_codec, fmt ); /* override default masks shifts */
+            SetBitmapRGBMasks( fmt->i_codec, &fmt->video ); /* override default masks shifts */
         }
         else if( fmt->i_codec == VLC_CODEC_RGBP )
         {
@@ -201,7 +198,7 @@ static inline int ParseBitmapInfoHeader( VLC_BITMAPINFOHEADER *p_bih, size_t i_b
         }
 
         /* Shitty VLC muxed files storing chroma in biCompression */
-        SetBitmapRGBMasks( fmt->i_codec, fmt );
+        SetBitmapRGBMasks( fmt->i_codec, &fmt->video );
     }
 
     video_format_Setup( &fmt->video, fmt->i_codec,
@@ -237,7 +234,7 @@ static inline VLC_BITMAPINFOHEADER * CreateBitmapInfoHeader( const es_format_t *
         case VLC_CODEC_RGBA:
         case VLC_CODEC_ARGB:
             biBitCount = 32;
-            biCompression = MatchBitmapRGBMasks( fmt ) ? BI_RGB : BI_BITFIELDS;
+            biCompression = BI_BITFIELDS;
             b_has_alpha = true;
             break;
         case VLC_CODEC_RGB24:



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d379959582948258005c9f7f0594972b5f144490...6b8870cc47629dd3fe765a64aff38cce3b3e461b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d379959582948258005c9f7f0594972b5f144490...6b8870cc47629dd3fe765a64aff38cce3b3e461b
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