]> git.sesse.net Git - vlc/blobdiff - modules/video_chroma/i420_rgb.h
Removes trailing spaces. Removes tabs.
[vlc] / modules / video_chroma / i420_rgb.h
index dcd929de79e8712bb8e2a2586bddf88bf340b748..109ea96becce563e5b6a72c86109302f4ca34b76 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * i420_rgb.h : YUV to bitmap RGB conversion module for vlc
  *****************************************************************************
- * Copyright (C) 2000 VideoLAN
- * $Id: i420_rgb.h,v 1.1 2002/08/04 17:23:43 sam Exp $
+ * Copyright (C) 2000, 2004 the VideoLAN team
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -10,7 +10,7 @@
  * 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
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-/*****************************************************************************
+/** Number of entries in RGB palette/colormap */
+#define CMAP_RGB2_SIZE 256
+
+/**
  * chroma_sys_t: chroma method descriptor
- *****************************************************************************
+
  * This structure is part of the chroma transformation descriptor, it
  * describes the yuv2rgb specific properties.
- *****************************************************************************/
+ */
 struct chroma_sys_t
 {
-    u8  *p_buffer;
+    uint8_t  *p_buffer;
     int *p_offset;
 
 #ifdef MODULE_NAME_IS_i420_rgb
-    /* Pre-calculated conversion tables */
-    void *p_base;                          /* base for all conversion tables */
-    u8   *p_rgb8;                                        /* RGB 8 bits table */
-    u16  *p_rgb16;                                      /* RGB 16 bits table */
-    u32  *p_rgb32;                                      /* RGB 32 bits table */
+    /**< Pre-calculated conversion tables */
+    void *p_base;                      /**< base for all conversion tables */
+    uint8_t   *p_rgb8;                 /**< RGB 8 bits table */
+    uint16_t  *p_rgb16;                /**< RGB 16 bits table */
+    uint32_t  *p_rgb32;                /**< RGB 32 bits table */
+
+    /**< To get RGB value for palette entry i, use (p_rgb_r[i], p_rgb_g[i],
+       p_rgb_b[i]). Note these are 16 bits per pixel. For 8bpp entries,
+       shift right 8 bits.
+    */
+    uint16_t  p_rgb_r[CMAP_RGB2_SIZE];  /**< Red values of palette */
+    uint16_t  p_rgb_g[CMAP_RGB2_SIZE];  /**< Green values of palette */
+    uint16_t  p_rgb_b[CMAP_RGB2_SIZE];  /**< Blue values of palette */
 #endif
 };
 
@@ -45,11 +56,18 @@ struct chroma_sys_t
  * Prototypes
  *****************************************************************************/
 #ifdef MODULE_NAME_IS_i420_rgb
-void E_(I420_RGB8) ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_RGB8)         ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_RGB16_dither) ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_RGB16)        ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_RGB32)        ( vout_thread_t *, picture_t *, picture_t * );
+#else // if defined(MODULE_NAME_IS_i420_rgb_mmx)
+void E_(I420_R5G5B5)       ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_R5G6B5)       ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_A8R8G8B8)     ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_R8G8B8A8)     ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_B8G8R8A8)     ( vout_thread_t *, picture_t *, picture_t * );
+void E_(I420_A8B8G8R8)     ( vout_thread_t *, picture_t *, picture_t * );
 #endif
-void E_(I420_RGB15)( vout_thread_t *, picture_t *, picture_t * );
-void E_(I420_RGB16)( vout_thread_t *, picture_t *, picture_t * );
-void E_(I420_RGB32)( vout_thread_t *, picture_t *, picture_t * );
 
 /*****************************************************************************
  * CONVERT_*_PIXEL: pixel conversion macros
@@ -75,6 +93,22 @@ void E_(I420_RGB32)( vout_thread_t *, picture_t *, picture_t * );
     i_blue =    (U_BLUE_COEF * i_uval) >> SHIFT;                              \
     CONVERT_Y_PIXEL( BPP )                                                    \
 
+#define CONVERT_Y_PIXEL_DITHER( BPP )                                         \
+    /* Only Y sample is present */                                            \
+    p_ybase = p_yuv + *p_y++;                                                 \
+    *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128+p_dither[i_real_y])>>SHIFT) + i_red] |     \
+        p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128+p_dither[i_real_y])>>SHIFT)       \
+        + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128+p_dither[i_real_y])>>SHIFT) + i_blue];
+
+#define CONVERT_YUV_PIXEL_DITHER( BPP )                                       \
+    /* Y, U and V samples are present */                                      \
+    i_uval =    *p_u++;                                                       \
+    i_vval =    *p_v++;                                                       \
+    i_red =     (V_RED_COEF * i_vval) >> SHIFT;                               \
+    i_green =   (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT;     \
+    i_blue =    (U_BLUE_COEF * i_uval) >> SHIFT;                              \
+    CONVERT_Y_PIXEL_DITHER( BPP )                                             \
+
 #define CONVERT_4YUV_PIXEL( CHROMA )                                          \
     *p_pic++ = p_lookup[                                                      \
         (((*p_y++ + dither10[i_real_y]) >> 4) << 7)                           \
@@ -159,13 +193,13 @@ void E_(I420_RGB32)( vout_thread_t *, picture_t *, picture_t * );
         {                                                                     \
             *p_pic++ = *p_buffer;   p_buffer += *p_offset++;                  \
         }                                                                     \
-        p_pic += i_right_margin;                                              \
+        p_pic = (void*)((uint8_t*)p_pic + i_right_margin );                   \
     }                                                                         \
     else                                                                      \
     {                                                                         \
         /* No scaling, conversion has been done directly in picture memory.   \
          * Increment of picture pointer to end of line is still needed */     \
-        (u8*)p_pic += p_dest->p->i_pitch;                                     \
+        p_pic = (void*)((uint8_t*)p_pic + p_dest->p->i_pitch );               \
     }                                                                         \
 
 /*****************************************************************************
@@ -197,7 +231,7 @@ void E_(I420_RGB32)( vout_thread_t *, picture_t *, picture_t * );
         }                                                                     \
     }                                                                         \
     /* Increment of picture pointer to end of line is still needed */         \
-    p_pic += i_right_margin;                                                  \
+    p_pic = (void*)((uint8_t*)p_pic + i_right_margin );                       \
                                                                               \
     /* Increment the Y coordinate in the matrix, modulo 4 */                  \
     i_real_y = (i_real_y + 1) & 0x3;                                          \
@@ -249,9 +283,9 @@ void E_(I420_RGB32)( vout_thread_t *, picture_t *, picture_t * );
         while( (i_scale_count -= p_vout->render.i_height) > 0 )               \
         {                                                                     \
             /* Height increment: copy previous picture line */                \
-            p_vout->p_vlc->pf_memcpy( p_pic, p_pic_start,                     \
+            p_vout->p_libvlc->pf_memcpy( p_pic, p_pic_start,                     \
                                       p_vout->output.i_width * BPP );         \
-            (u8*)p_pic += p_dest->p->i_pitch;                                 \
+            p_pic = (void*)((uint8_t*)p_pic + p_dest->p->i_pitch );           \
         }                                                                     \
         i_scale_count += p_vout->output.i_height;                             \
         break;                                                                \