]> git.sesse.net Git - vlc/blobdiff - modules/video_chroma/i420_rgb.c
modules/gui/wxwindows/iteminfo.cpp:
[vlc] / modules / video_chroma / i420_rgb.c
index 00ce159b1d9f35703c2a28b97c01e87f7c8c3bf7..850d14bdfad6544de2d248391a559862dfb1f85c 100644 (file)
@@ -1,16 +1,16 @@
 /*****************************************************************************
  * i420_rgb.c : YUV to bitmap RGB conversion module for vlc
  *****************************************************************************
- * Copyright (C) 2000, 2001 VideoLAN
- * $Id: i420_rgb.c,v 1.3 2002/11/25 19:29:10 sam Exp $
+ * Copyright (C) 2000, 2001, 2004 VideoLAN
+ * $Id: i420_rgb.c,v 1.7 2004/01/31 05:53:35 rocky Exp $
  *
- * Authors: Samuel Hocevar <sam@zoy.org>
+ * Author: Sam Hocevar <sam@zoy.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -56,7 +56,7 @@ static void Deactivate ( vlc_object_t * );
 #if defined (MODULE_NAME_IS_i420_rgb)
 static void SetGammaTable       ( int *pi_table, double f_gamma );
 static void SetYUV              ( vout_thread_t * );
-static void Set8bppPalette      ( vout_thread_t *, u8 * );
+static void Set8bppPalette      ( vout_thread_t *, uint8_t * );
 #endif
 
 /*****************************************************************************
@@ -122,7 +122,9 @@ static int Activate( vlc_object_t *p_this )
                     p_vout->chroma.pf_convert = E_(I420_RGB16);
                     break;
 
+#ifndef WIN32 /* Hmmm, is there only X11 using 32bits per pixel for RV24 ? */
                 case VLC_FOURCC('R','V','2','4'):
+#endif
                 case VLC_FOURCC('R','V','3','2'):
 #if defined (MODULE_NAME_IS_i420_rgb_mmx)
                     /* If we don't have support for the bitmasks, bail out */
@@ -144,7 +146,7 @@ static int Activate( vlc_object_t *p_this )
         default:
             return -1;
     }
-    
+
     p_vout->chroma.p_sys = malloc( sizeof( chroma_sys_t ) );
     if( p_vout->chroma.p_sys == NULL )
     {
@@ -195,14 +197,14 @@ static int Activate( vlc_object_t *p_this )
     switch( p_vout->output.i_chroma )
     {
     case VLC_FOURCC('R','G','B','2'):
-        i_tables_size = sizeof( u8 ) * PALETTE_TABLE_SIZE;
+        i_tables_size = sizeof( uint8_t ) * PALETTE_TABLE_SIZE;
         break;
     case VLC_FOURCC('R','V','1','5'):
     case VLC_FOURCC('R','V','1','6'):
-        i_tables_size = sizeof( u16 ) * RGB_TABLE_SIZE;
+        i_tables_size = sizeof( uint16_t ) * RGB_TABLE_SIZE;
         break;
     default: /* RV24, RV32 */
-        i_tables_size = sizeof( u32 ) * RGB_TABLE_SIZE;
+        i_tables_size = sizeof( uint32_t ) * RGB_TABLE_SIZE;
         break;
     }
 
@@ -218,7 +220,7 @@ static int Activate( vlc_object_t *p_this )
     SetYUV( p_vout );
 #endif
 
-    return 0; 
+    return 0;
 }
 
 /*****************************************************************************
@@ -277,13 +279,13 @@ static void SetYUV( vout_thread_t *p_vout )
     switch( p_vout->output.i_chroma )
     {
     case VLC_FOURCC('R','G','B','2'):
-        p_vout->chroma.p_sys->p_rgb8 = (u8 *)p_vout->chroma.p_sys->p_base;
+        p_vout->chroma.p_sys->p_rgb8 = (uint8_t *)p_vout->chroma.p_sys->p_base;
         Set8bppPalette( p_vout, p_vout->chroma.p_sys->p_rgb8 );
         break;
 
     case VLC_FOURCC('R','V','1','5'):
     case VLC_FOURCC('R','V','1','6'):
-        p_vout->chroma.p_sys->p_rgb16 = (u16 *)p_vout->chroma.p_sys->p_base;
+        p_vout->chroma.p_sys->p_rgb16 = (uint16_t *)p_vout->chroma.p_sys->p_base;
         for( i_index = 0; i_index < RED_MARGIN; i_index++ )
         {
             p_vout->chroma.p_sys->p_rgb16[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
@@ -309,7 +311,7 @@ static void SetYUV( vout_thread_t *p_vout )
 
     case VLC_FOURCC('R','V','2','4'):
     case VLC_FOURCC('R','V','3','2'):
-        p_vout->chroma.p_sys->p_rgb32 = (u32 *)p_vout->chroma.p_sys->p_base;
+        p_vout->chroma.p_sys->p_rgb32 = (uint32_t *)p_vout->chroma.p_sys->p_base;
         for( i_index = 0; i_index < RED_MARGIN; i_index++ )
         {
             p_vout->chroma.p_sys->p_rgb32[RED_OFFSET - RED_MARGIN + i_index] = RGB2PIXEL( p_vout, pi_gamma[0], 0, 0 );
@@ -335,14 +337,17 @@ static void SetYUV( vout_thread_t *p_vout )
     }
 }
 
-static void Set8bppPalette( vout_thread_t *p_vout, u8 *p_rgb8 )
+static void Set8bppPalette( vout_thread_t *p_vout, uint8_t *p_rgb8 )
 {
     #define CLIP( x ) ( ((x < 0) ? 0 : (x > 255) ? 255 : x) << 8 )
 
     int y,u,v;
     int r,g,b;
     int i = 0, j = 0;
-    u16 red[ 256 ], green[ 256 ], blue[ 256 ];
+    uint16_t *p_cmap_r=p_vout->chroma.p_sys->p_rgb_r;
+    uint16_t *p_cmap_g=p_vout->chroma.p_sys->p_rgb_g;
+    uint16_t *p_cmap_b=p_vout->chroma.p_sys->p_rgb_b;
+
     unsigned char p_lookup[PALETTE_TABLE_SIZE];
 
     /* This loop calculates the intersection of an YUV box and the RGB cube. */
@@ -369,9 +374,15 @@ static void Set8bppPalette( vout_thread_t *p_vout, u8 *p_rgb8 )
                     }
 
                     /* Clip the colors */
-                    red[ j ] = CLIP( r );
-                    green[ j ] = CLIP( g );
-                    blue[ j ] = CLIP( b );
+                    p_cmap_r[ j ] = CLIP( r );
+                    p_cmap_g[ j ] = CLIP( g );
+                    p_cmap_b[ j ] = CLIP( b );
+
+#if 0
+                   printf("+++Alloc RGB cmap %d (%d, %d, %d)\n", j,
+                          p_cmap_r[ j ] >>8, p_cmap_g[ j ] >>8, 
+                          p_cmap_b[ j ] >>8);
+#endif
 
                     /* Allocate color */
                     p_lookup[ i ] = 1;
@@ -388,7 +399,7 @@ static void Set8bppPalette( vout_thread_t *p_vout, u8 *p_rgb8 )
     }
 
     /* The colors have been allocated, we can set the palette */
-    p_vout->output.pf_setpalette( p_vout, red, green, blue );
+    p_vout->output.pf_setpalette( p_vout, p_cmap_r, p_cmap_g, p_cmap_b );
 
 #if 0
     /* There will eventually be a way to know which colors