[vlc-commits] access: dshow: set proper RGB masks

Francois Cartegnie git at videolan.org
Sun Aug 12 17:52:19 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Aug 12 17:43:17 2018 +0200| [5ab1d9aa72842c399b0c8340ebe2b7ce91298355] | committer: Francois Cartegnie

access: dshow: set proper RGB masks

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ab1d9aa72842c399b0c8340ebe2b7ce91298355
---

 modules/access/dshow/dshow.cpp | 42 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp
index 68a379f1cf..7ef825339a 100644
--- a/modules/access/dshow/dshow.cpp
+++ b/modules/access/dshow/dshow.cpp
@@ -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 false;
+    }
+    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 )
             {



More information about the vlc-commits mailing list