[vlc-commits] [Git][videolan/vlc][master] 3 commits: wingdi: always use BI_RGB

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Sep 15 12:57:25 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0685aff0 by Steve Lhomme at 2023-09-15T12:35:10+00:00
wingdi: always use BI_RGB

We pick the input format, so we can use BI_RGB for each of them and
set the proper mask to use on input.

8-bit RGB is supposed to use a palette so was already broken.

16-bit is actually using 15 bits [1] [2]:

> If the biCompression member of the BITMAPHEADER structure is BI_RGB,
> the bmiColors member of BITMAPINFO is NULL. Each WORD in the bitmap
> array represents a single pixel. The relative intensities of red, green, and
> blue are represented with five bits for each color component. The value
> for blue is in the least significant five bits, followed by five bits each for
> green and red. The most significant bit is not used.

[1] https://learn.microsoft.com/en-us/previous-versions/dd183376(v=vs.85)
[2] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv5header

- - - - -
bd25a5bc by Steve Lhomme at 2023-09-15T12:35:10+00:00
wingdi: remove 16 bits depth

GetDeviceCaps(BITSPIXEL) doesn't differentiate between 15 and 16 bit depth
and returns 16 [1]. It's OK because we use the same mask for both
as BI_RGB is only using 15 bits for 16 bits.

[1] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getdevicecaps#return-value

- - - - -
4ea5d3b9 by Steve Lhomme at 2023-09-15T12:35:10+00:00
windgi: request the proper VLC_CODEC_BGRX

VLC_CODEC_BGRA is supported but the alpha is discarded.
Since we will most likely use a converter between the decoder and
our display module, it's better not to request a fake alpha component.

We allow keeping VLC_CODEC_BGRA if that's what the source provides.

- - - - -


1 changed file:

- modules/video_output/win32/wingdi.c


Changes:

=====================================
modules/video_output/win32/wingdi.c
=====================================
@@ -67,16 +67,7 @@ typedef struct vout_display_sys_t
 
     plane_t    pic_buf;
 
-    union {
-        BITMAPINFO bmiInfo;
-        struct
-        {
-            BITMAPINFOHEADER bmiHeader;
-            RGBQUAD          red;
-            RGBQUAD          green;
-            RGBQUAD          blue;
-        } bi_rgb;
-    };
+    BITMAPINFO bmiInfo;
 } vout_display_sys_t;
 
 static void           Display(vout_display_t *, picture_t *);
@@ -100,7 +91,7 @@ static int ChangeSize(vout_display_t *vd, HDC hdc)
     video_format_t fmt_rot;
     video_format_ApplyRotation(&fmt_rot, vd->source);
 
-    BITMAPINFOHEADER *bih = &sys->bi_rgb.bmiHeader;
+    BITMAPINFOHEADER *bih = &sys->bmiInfo.bmiHeader;
     if (bih->biWidth  != (LONG)fmt_rot.i_visible_width ||
         bih->biHeight != -(LONG)fmt_rot.i_visible_height)
     {
@@ -265,44 +256,45 @@ static int Init(vout_display_t *vd, video_format_t *fmt)
     switch (i_depth) {
     case 8:
         fmt->i_chroma = VLC_CODEC_RGB233;
-        break;
-    case 15:
-        fmt->i_chroma = VLC_CODEC_RGB15;
+        fmt->i_rmask  = 0;
+        fmt->i_gmask  = 0;
+        fmt->i_bmask  = 0;
         break;
     case 16:
-        fmt->i_chroma = VLC_CODEC_RGB16;
+        fmt->i_chroma = VLC_CODEC_RGB15;
+        fmt->i_rmask  = 0x1f << 10;
+        fmt->i_gmask  = 0x3f << 5;
+        fmt->i_bmask  = 0x1f << 0;
         break;
     case 24:
         fmt->i_chroma = VLC_CODEC_RGB24;
+        fmt->i_rmask  = 0xff << 16;
+        fmt->i_gmask  = 0xff << 8;
+        fmt->i_bmask  = 0x1f << 0;
         break;
-    case 32: // BGRX
-        fmt->i_chroma = VLC_CODEC_BGRA;
+    case 32:
+        if (vd->source->i_chroma == VLC_CODEC_BGRA)
+            fmt->i_chroma = VLC_CODEC_BGRA;
+        else
+            fmt->i_chroma = VLC_CODEC_BGRX;
+        fmt->i_rmask  = 0;
+        fmt->i_gmask  = 0;
+        fmt->i_bmask  = 0;
         break;
     default:
         msg_Err(vd, "screen depth %i not supported", i_depth);
         ReleaseDC(CommonVideoHWND(&sys->area), window_dc);
         return VLC_EGENERIC;
     }
-    fmt->i_rmask  = 0;
-    fmt->i_gmask  = 0;
-    fmt->i_bmask  = 0;
-    video_format_FixRgb(fmt);
 
     /* Initialize offscreen bitmap */
     sys->bmiInfo.bmiHeader = (BITMAPINFOHEADER) {
         .biSize         = sizeof(BITMAPINFOHEADER),
         .biPlanes       = 1,
         .biBitCount     = i_depth,
-        .biCompression  = (i_depth == 15 ||
-                           i_depth == 16) ? BI_BITFIELDS : BI_RGB,
+        .biCompression  = BI_RGB,
     };
 
-    if (i_depth > 8) {
-        *((DWORD*)&sys->bi_rgb.red)   = fmt->i_rmask;
-        *((DWORD*)&sys->bi_rgb.green) = fmt->i_gmask;
-        *((DWORD*)&sys->bi_rgb.blue)  = fmt->i_bmask;
-    }
-
     sys->off_dc = CreateCompatibleDC(window_dc);
 
     int err = ChangeSize(vd, window_dc);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5964ac1b8adee2d3c99bea62009fc83fce525fc4...4ea5d3b9ac4cc7938cadd3a849303bf8bd5fcfda

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5964ac1b8adee2d3c99bea62009fc83fce525fc4...4ea5d3b9ac4cc7938cadd3a849303bf8bd5fcfda
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