access: dshow: set proper RGB masks
authorFrancois Cartegnie <fcvlcdev@free.fr>
Sun, 12 Aug 2018 15:43:17 +0000 (17:43 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sun, 12 Aug 2018 16:10:25 +0000 (18:10 +0200)
modules/access/dshow/dshow.cpp

index 68a379f..2a4183c 100644 (file)
@@ -623,6 +623,40 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
     return VLC_SUCCESS;
 }
 
+static void SetRGBMasks( vlc_fourcc_t i_fourcc, es_format_t *fmt )
+{
+    switch( i_fourcc )
+    {
+        case VLC_CODEC_RGB15:
+            fmt->video.i_rmask = 0x7c00;
+            fmt->video.i_gmask = 0x03e0;
+            fmt->video.i_bmask = 0x001f;
+            break;
+        case VLC_CODEC_RGB16:
+            fmt->video.i_rmask = 0xf800;
+            fmt->video.i_gmask = 0x07e0;
+            fmt->video.i_bmask = 0x001f;
+            break;
+        case VLC_CODEC_RGB24:
+            /* This is in BGR format */
+            fmt->video.i_bmask = 0x00ff0000;
+            fmt->video.i_gmask = 0x0000ff00;
+            fmt->video.i_rmask = 0x000000ff;
+            break;
+        case VLC_CODEC_RGB32:
+        case VLC_CODEC_RGBA:
+            /* This is in BGRx format */
+            fmt->video.i_bmask = 0xff000000;
+            fmt->video.i_gmask = 0x00ff0000;
+            fmt->video.i_rmask = 0x0000ff00;
+            break;
+        default:
+            return;
+    }
+    fmt->video.i_chroma = i_fourcc;
+    video_format_FixRgb( &fmt->video );
+}
+
 /*****************************************************************************
  * DemuxOpen: open direct show device as an access_demux module
  *****************************************************************************/
@@ -701,13 +735,7 @@ static int DemuxOpen( vlc_object_t *p_this )
             }
 
             /* Setup rgb mask for RGB formats */
-            if( p_stream->i_fourcc == VLC_CODEC_RGB24 )
-            {
-                /* This is in BGR format */
-                fmt.video.i_bmask = 0x00ff0000;
-                fmt.video.i_gmask = 0x0000ff00;
-                fmt.video.i_rmask = 0x000000ff;
-            }
+            SetRGBMasks( p_stream->i_fourcc, &fmt );
 
             if( p_stream->header.video.AvgTimePerFrame )
             {