* i420_rgb.c : YUV to bitmap RGB conversion module for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: i420_rgb.c,v 1.1 2002/08/04 17:23:43 sam Exp $
+ * $Id: i420_rgb.c,v 1.4 2003/08/29 18:58:05 fenrir Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* Preamble
*****************************************************************************/
#include <math.h> /* exp(), pow() */
-#include <errno.h> /* ENOMEM */
#include <string.h> /* strerror() */
#include <stdlib.h> /* malloc(), free() */
# include "i420_rgb_c.h"
#endif
+/*****************************************************************************
+ * RGB2PIXEL: assemble RGB components to a pixel value, returns a uint32_t
+ *****************************************************************************/
+#define RGB2PIXEL( p_vout, i_r, i_g, i_b ) \
+ (((((uint32_t)i_r) >> p_vout->output.i_rrshift) \
+ << p_vout->output.i_lrshift) \
+ | ((((uint32_t)i_g) >> p_vout->output.i_rgshift) \
+ << p_vout->output.i_lgshift) \
+ | ((((uint32_t)i_b) >> p_vout->output.i_rbshift) \
+ << p_vout->output.i_lbshift))
+
/*****************************************************************************
* Local and extern prototypes.
*****************************************************************************/
#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
/*****************************************************************************
vlc_module_begin();
#if defined (MODULE_NAME_IS_i420_rgb)
set_description( _("I420,IYUV,YV12 to "
- "RGB,RV15,RV16,RV24,RV32 conversions") );
+ "RGB2,RV15,RV16,RV24,RV32 conversions") );
set_capability( "chroma", 80 );
#elif defined (MODULE_NAME_IS_i420_rgb_mmx)
set_description( _( "MMX I420,IYUV,YV12 to "
break;
#endif
case VLC_FOURCC('R','V','1','5'):
- p_vout->chroma.pf_convert = E_(I420_RGB15);
- break;
-
case VLC_FOURCC('R','V','1','6'):
+#if defined (MODULE_NAME_IS_i420_rgb_mmx)
+ /* If we don't have support for the bitmasks, bail out */
+ if( ( p_vout->output.i_rmask != 0x7c00
+ || p_vout->output.i_gmask != 0x03e0
+ || p_vout->output.i_bmask != 0x001f )
+ && ( p_vout->output.i_rmask != 0xf800
+ || p_vout->output.i_gmask != 0x07e0
+ || p_vout->output.i_bmask != 0x001f ) )
+ {
+ return -1;
+ }
+#endif
p_vout->chroma.pf_convert = E_(I420_RGB16);
break;
case VLC_FOURCC('R','V','2','4'):
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 */
+ if( p_vout->output.i_rmask != 0x00ff0000
+ || p_vout->output.i_gmask != 0x0000ff00
+ || p_vout->output.i_bmask != 0x000000ff )
+ {
+ return -1;
+ }
+#endif
p_vout->chroma.pf_convert = E_(I420_RGB32);
break;
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;
}
/* Build gamma table */
for( i_y = 0; i_y < 256; i_y++ )
{
- pi_table[ i_y ] = pow( (double)i_y / 256, f_gamma ) * 256;
+ pi_table[ i_y ] = (int)( pow( (double)i_y / 256, f_gamma ) * 256 );
}
}
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 );
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 );
}
}
-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 red[ 256 ], green[ 256 ], blue[ 256 ];
unsigned char p_lookup[PALETTE_TABLE_SIZE];
/* This loop calculates the intersection of an YUV box and the RGB cube. */