[vlc-commits] [Git][videolan/vlc][master] 2 commits: bitmapinfoheader: don't read/write the reserved RGBQUAD field in palette

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Oct 14 14:34:52 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0a4bb395 by Steve Lhomme at 2023-10-14T14:18:19+00:00
bitmapinfoheader: don't read/write the reserved RGBQUAD field in palette

The palette is appended as RGBQUAD after the BITMAPINFO [1] [2].
The RGBQUAD 4th value is reserved and should be 0 [3].

So we write it as 0 and read it as 0xFF (fully opaque RGBA). If the
palette had alpha information it will be lost on writing.

[1] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader
[2] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfo
[3] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-rgbquad

- - - - -
6d542301 by Steve Lhomme at 2023-10-14T14:18:19+00:00
demux: mock: document the format of the palettes defined

- - - - -


2 changed files:

- modules/demux/avi/bitmapinfoheader.h
- modules/demux/mock.c


Changes:

=====================================
modules/demux/avi/bitmapinfoheader.h
=====================================
@@ -200,8 +200,9 @@ static inline int ParseBitmapInfoHeader( const VLC_BITMAPINFOHEADER *p_bih, size
                 fmt->video.p_palette->i_entries = __MIN(i_bihextra/4, 256);
                 for( int k = 0; k < fmt->video.p_palette->i_entries; k++ )
                 {
-                    for( int j = 0; j < 4; j++ )
+                    for( int j = 0; j < 3; j++ )
                         fmt->video.p_palette->palette[k][j] = p_bihextra[4*k+j];
+                    fmt->video.p_palette->palette[k][3] = 0xFF;
                 }
             }
         }
@@ -350,7 +351,11 @@ static inline int CreateBitmapInfoHeader( const es_format_t *fmt,
     else if( fmt->i_codec == VLC_CODEC_RGBP )
     {
         for( int i = 0; i < fmt->video.p_palette->i_entries; i++ )
-            memcpy( &p_bmiColors[i * 4], fmt->video.p_palette->palette[i], 4 );
+        {
+            for( int j = 0; i < 3; i++ )
+                p_bmiColors[i * 4 + j] = fmt->video.p_palette->palette[i][j];
+            p_bmiColors[i * 4 + 3] = 0;
+        }
         p_bih->biClrUsed = fmt->video.p_palette->i_entries;
     }
     else if( fmt->i_extra )


=====================================
modules/demux/mock.c
=====================================
@@ -42,11 +42,13 @@ enum
     PALETTE_BLACK,
 };
 
+// packed RGBA in memory order
 const uint8_t rgbpal[4][4] = {[PALETTE_RED] =   { 0xFF, 0x00, 0x00, 0xFF },
                               [PALETTE_GREEN] = { 0x00, 0xFF, 0x00, 0xFF },
                               [PALETTE_BLUE] =  { 0x00, 0x00, 0xFF, 0xFF },
                               [PALETTE_BLACK] = { 0x00, 0x00, 0x00, 0xFF }};
 
+// packed YUVA in memory order
 const uint8_t yuvpal[4][4] = {[PALETTE_RED] =   { 0x4C, 0x54, 0xFF, 0xFF },
                               [PALETTE_GREEN] = { 0x95, 0x2B, 0x15, 0xFF },
                               [PALETTE_BLUE] =  { 0x1D, 0xFF, 0x6B, 0xFF },



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2706a5a5c77a86987143999a08f6988626299477...6d542301912554e797bf9ae09d95dfc49e1a84e8

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