Commit 14047fa1 authored by Sam Hocevar's avatar Sam Hocevar

  * Filter plugins. Not very polished (please don't look at how the dates are
    calculated!), but worth a try. Use the following flags:
     "--filter invert" for inverse video
     "--filter bob" for BOB deinterlacing
  * Fixed a potential segfault if the subtitle stream was encountered
    before the video stream.
  * Misc vout4 fixes.
parent 97cba428
......@@ -26,6 +26,7 @@ PLUGINS_DIR := ac3_adec \
dvdread \
esd \
fb \
filter \
ggi \
glide \
gtk \
......@@ -54,7 +55,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
alsa/alsa \
arts/arts \
beos/beos \
chroma/yuv2rgb8 \
chroma/chroma_yv12_rgb8 \
directx/directx \
dsp/dsp \
dummy/dummy \
......@@ -63,6 +64,8 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
dvdread/dvdread \
esd/esd \
fb/fb \
filter/filter_bob \
filter/filter_invert \
ggi/ggi \
glide/glide \
gtk/gnome \
......@@ -320,7 +323,6 @@ snapshot-common:
-type d -name CVS -o -name '.*' -o -name '*.[o]' | \
while read i ; do rm -Rf $$i ; done
# Copy gettext stuff
mkdir tmp/vlc/po
cp po/*.po tmp/vlc/po
for i in Makefile.in.in POTFILES.in ; do cp po/$$i tmp/vlc/po ; done
# Copy misc files
......
......@@ -95,7 +95,6 @@ LIB_RC = @LIB_RC@
LIB_SDL = @LIB_SDL@
LIB_X11 = @LIB_X11@
LIB_XVIDEO = @LIB_XVIDEO@
LIB_YUV = @LIB_YUV@
#
# CFLAGS for special cases
......
This diff is collapsed.
......@@ -146,7 +146,6 @@ AC_TYPE_SIGNAL
AC_CHECK_LIB(dl,dlopen,LIB="${LIB} -ldl")
AC_CHECK_LIB(m,cos,LIB_IMDCT="${LIB_IMDCT} -lm")
AC_CHECK_LIB(m,pow,
LIB_YUV="${LIB_YUV} -lm"
LIB_IMDCT="${LIB_IMDCT} -lm"
LIB_IMDCT3DN="${LIB_IMDCT3DN} -lm"
LIB_IMDCTSSE="${LIB_IMDCTSSE} -lm"
......@@ -310,9 +309,8 @@ ARCH=${target_cpu}
dnl
dnl default modules
dnl
#BUILTINS="${BUILTINS} mpeg_es mpeg_ps mpeg_ts memcpy yuv2rgb8 idct idctclassic motion imdct downmix mpeg_adec lpcm_adec ac3_adec mpeg_vdec"
BUILTINS="${BUILTINS} mpeg_es mpeg_ps mpeg_ts memcpy idct idctclassic motion imdct downmix mpeg_adec lpcm_adec ac3_adec mpeg_vdec"
PLUGINS="${PLUGINS} ac3_spdif spudec"
PLUGINS="${PLUGINS} ac3_spdif spudec chroma_yv12_rgb8 filter_bob filter_invert"
dnl
dnl Accelerated modules
......@@ -1280,7 +1278,6 @@ AC_SUBST(LIB_RC)
AC_SUBST(LIB_SDL)
AC_SUBST(LIB_X11)
AC_SUBST(LIB_XVIDEO)
AC_SUBST(LIB_YUV)
AC_SUBST(CFLAGS_VLC)
AC_SUBST(CFLAGS_ALTIVEC)
......@@ -1345,7 +1342,7 @@ which modules get compiled as plugins.
"
if test x${HAVE_VLC} = x1
then
echo "To build vlc and its plugins, type \`make vlc'."
echo "To build vlc and its plugins, type \`make vlc plugins'."
fi
if test x${HAVE_LIBDVDCSS} = x1
then
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.58 2001/12/13 12:47:17 sam Exp $
* $Id: common.h,v 1.59 2001/12/16 16:18:36 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -542,26 +542,30 @@ typedef struct module_symbols_s
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, int, int );
struct subpicture_s * (* vout_CreateSubPicture) ( struct vout_thread_s *,
int, int );
struct picture_s * ( * vout_CreatePicture ) ( struct vout_thread_s * );
void ( * vout_DestroyThread ) ( struct vout_thread_s *, int * );
void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
struct picture_s * ( * vout_CreatePicture )
( struct vout_thread_s *,
boolean_t, boolean_t, boolean_t );
void ( * vout_DisplayPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_DestroyPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_LinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_DatePicture ) ( struct vout_thread_s *p_vout,
struct picture_s *p_pic, mtime_t );
void ( * vout_DatePicture ) ( struct vout_thread_s *,
struct picture_s *, mtime_t );
void ( * vout_PlacePicture ) ( struct vout_thread_s *, int, int,
int *, int *, int *, int * );
struct subpicture_s * (* vout_CreateSubPicture)
( struct vout_thread_s *, int, int );
void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
u32 ( * UnalignedShowBits ) ( struct bit_stream_s *, unsigned int );
void ( * UnalignedRemoveBits ) ( struct bit_stream_s * );
......
......@@ -325,6 +325,10 @@
#define VOUT_METHOD_VAR "vlc_vout"
#define VOUT_METHOD_DEFAULT "x11"
/* Environment variable containing the display method */
#define VOUT_FILTER_VAR "vlc_filter"
#define VOUT_FILTER_DEFAULT "x11"
/* Environment variable containing the motion compensation method */
#define MOTION_METHOD_VAR "vlc_motion"
......@@ -346,6 +350,9 @@
#define VOUT_DEPTH_VAR "vlc_depth"
#define VOUT_DEPTH_DEFAULT 15
/* Multiplier value for aspect ratio calculation */
#define VOUT_ASPECT_FACTOR (2*2*2*2*2*2*2*3*3*3*5*5*5)
/* Maximum width of a scaled source picture - this should be relatively high,
* since higher stream values will result in no display at all. */
#define VOUT_MAX_WIDTH 4096
......@@ -414,6 +421,12 @@
/* Better be in advance when awakening than late... */
#define VOUT_MWAIT_TOLERANCE ((int)(0.020*CLOCK_FREQ))
/* Time to sleep when waiting for a buffer (from vout or the video fifo).
* It should be approximately the time needed to perform a complete picture
* loop. Since it only happens when the video heap is full, it does not need
* to be too low, even if it blocks the decoder. */
#define VOUT_OUTMEM_SLEEP ((int)(0.020*CLOCK_FREQ))
/* The default video output window title */
#define VOUT_TITLE "VideoLAN Client @VLC_VERSION@"
......@@ -430,12 +443,6 @@
#define VPAR_IDLE_SLEEP ((int)(0.010*CLOCK_FREQ))
/* Time to sleep when waiting for a buffer (from vout or the video fifo).
* It should be approximately the time needed to perform a complete picture
* loop. Since it only happens when the video heap is full, it does not need
* to be too low, even if it blocks the decoder. */
#define VPAR_OUTMEM_SLEEP ((int)(0.020*CLOCK_FREQ))
/* Optimization level, from 0 to 2 - 1 is generally a good compromise. Remember
* that raising this level dramatically lengthens the compilation time. */
#ifdef RELEASE
......
......@@ -87,6 +87,7 @@
(p_symbols)->aout_CreateFifo = aout_CreateFifo; \
(p_symbols)->aout_DestroyFifo = aout_DestroyFifo; \
(p_symbols)->vout_CreateThread = vout_CreateThread; \
(p_symbols)->vout_DestroyThread = vout_DestroyThread; \
(p_symbols)->vout_CreateSubPicture = vout_CreateSubPicture; \
(p_symbols)->vout_DestroySubPicture = vout_DestroySubPicture; \
(p_symbols)->vout_DisplaySubPicture = vout_DisplaySubPicture; \
......@@ -197,6 +198,7 @@
# define aout_DestroyFifo p_symbols->aout_DestroyFifo
# define vout_CreateThread p_symbols->vout_CreateThread
# define vout_DestroyThread p_symbols->vout_DestroyThread
# define vout_CreateSubPicture p_symbols->vout_CreateSubPicture
# define vout_DestroySubPicture p_symbols->vout_DestroySubPicture
# define vout_DisplaySubPicture p_symbols->vout_DisplaySubPicture
......
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.34 2001/12/13 12:47:17 sam Exp $
* $Id: video.h,v 1.35 2001/12/16 16:18:36 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -39,6 +39,7 @@ typedef struct plane_s
{
pixel_data_t *p_data;
int i_bytes;
int i_line_bytes;
} plane_t;
/*****************************************************************************
......@@ -82,7 +83,7 @@ typedef struct picture_s
/* Picture dynamic properties - those properties can be changed by the
* decoder */
boolean_t b_progressive_frame; /* is it a progressive frame ? */
boolean_t b_progressive; /* is it a progressive frame ? */
boolean_t b_repeat_first_field; /* RFF bit */
boolean_t b_top_field_first; /* which field is first */
......
......@@ -5,7 +5,7 @@
* thread, and destroy a previously oppenned video output thread.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.65 2001/12/13 12:47:17 sam Exp $
* $Id: video_output.h,v 1.66 2001/12/16 16:18:36 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -193,7 +193,8 @@ vout_fifo_t * vout_CreateFifo ( void );
void vout_DestroyFifo ( vout_fifo_t * );
void vout_FreeFifo ( vout_fifo_t * );
picture_t * vout_CreatePicture ( vout_thread_t * );
picture_t * vout_CreatePicture ( vout_thread_t *,
boolean_t, boolean_t, boolean_t );
void vout_DestroyPicture ( vout_thread_t *, picture_t * );
void vout_DisplayPicture ( vout_thread_t *, picture_t * );
void vout_DatePicture ( vout_thread_t *, picture_t *, mtime_t );
......
......@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_adec.c,v 1.7 2001/12/10 04:53:10 sam Exp $
* $Id: ac3_adec.c,v 1.8 2001/12/16 16:18:36 sam Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -81,13 +81,13 @@ void _M( adec_getfunctions )( function_list_t * p_function_list )
* Build configuration tree.
*****************************************************************************/
MODULE_CONFIG_START
ADD_WINDOW( "Configuration for ac3 decoder module" )
ADD_WINDOW( "Configuration for AC3 decoder module" )
ADD_COMMENT( "Nothing to configure" )
MODULE_CONFIG_STOP
MODULE_INIT_START
p_module->i_capabilities = MODULE_CAPABILITY_DEC;
p_module->psz_longname = "Ac3 sofware decoder";
p_module->psz_longname = "AC3 sofware decoder";
MODULE_INIT_STOP
MODULE_ACTIVATE_START
......
......@@ -7,12 +7,12 @@
# Objects
#
PLUGIN_YUV2RGB8 = yuv2rgb8.o #common.o
PLUGIN_YV12_RGB8 = yv12_rgb8.o
BUILTIN_YUV2RGB8 = $(PLUGIN_YUV2RGB8:%.o=BUILTIN_%.o)
BUILTIN_YV12_RGB8 = $(PLUGIN_YV12_RGB8:%.o=BUILTIN_%.o)
PLUGIN_C = $(PLUGIN_YUV2RGB8)
BUILTIN_C = $(BUILTIN_YUV2RGB8)
PLUGIN_C = $(PLUGIN_YV12_RGB8)
BUILTIN_C = $(BUILTIN_YV12_RGB8)
ALL_OBJ = $(PLUGIN_C) $(BUILTIN_C)
#
......@@ -25,10 +25,10 @@ include ../../Makefile.modules
# Real targets
#
../yuv2rgb8.so: $(PLUGIN_YUV2RGB8)
../chroma_yv12_rgb8.so: $(PLUGIN_YV12_RGB8)
$(CC) -o $@ $^ $(PLCFLAGS)
../yuv2rgb8.a: $(BUILTIN_YUV2RGB8)
../chroma_yv12_rgb8.a: $(BUILTIN_YV12_RGB8)
ar r $@ $^
$(RANLIB) $@
/*****************************************************************************
* chroma_common.h: YUV transformation functions
* Provides functions to perform the YUV conversion. The functions provided here
* are a complete and portable C implementation, and may be replaced in certain
* case by optimized functions.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: chroma_common.h,v 1.1 2001/12/16 16:18:36 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
* 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 GNU
* General Public License for more details.
*
* 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-1307, USA.
*****************************************************************************/
/*****************************************************************************
* Constants
*****************************************************************************/
/* Margins and offsets in conversion tables - Margins are used in case a RGB
* RGB conversion would give a value outside the 0-255 range. Offsets have been
* calculated to avoid using the same cache line for 2 tables. conversion tables
* are 2*MARGIN + 256 long and stores pixels.*/
#define RED_MARGIN 178
#define GREEN_MARGIN 135
#define BLUE_MARGIN 224
#define RED_OFFSET 1501 /* 1323 to 1935 */
#define GREEN_OFFSET 135 /* 0 to 526 */
#define BLUE_OFFSET 818 /* 594 to 1298 */
#define RGB_TABLE_SIZE 1935 /* total table size */
#define GRAY_MARGIN 384
#define GRAY_TABLE_SIZE 1024 /* total table size */
#define PALETTE_TABLE_SIZE 2176 /* YUV -> 8bpp palette lookup table */
/* macros used for YUV pixel conversions */
#define SHIFT 20
#define U_GREEN_COEF ((int)(-0.391 * (1<<SHIFT) / 1.164))
#define U_BLUE_COEF ((int)(2.018 * (1<<SHIFT) / 1.164))
#define V_RED_COEF ((int)(1.596 * (1<<SHIFT) / 1.164))
#define V_GREEN_COEF ((int)(-0.813 * (1<<SHIFT) / 1.164))
/*****************************************************************************
* Extern prototypes
*****************************************************************************/
void _M( SetOffset )( int i_width, int i_height, int i_pic_width,
int i_pic_height, boolean_t *pb_h_scaling,
int *pi_v_scaling, int *p_offset, boolean_t b_double );
/*****************************************************************************
* common.c: Chroma transformation functions
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: common.c,v 1.1 2001/12/16 16:18:36 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
* 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 GNU
* General Public License for more details.
*
* 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-1307, USA.
*****************************************************************************/
#define MODULE_NAME yuv
#include "modules_inner.h"
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "defs.h"
#include <math.h> /* exp(), pow() */
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
#include <string.h> /* strerror() */
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "video.h"
#include "video_output.h"
#include "video_common.h"
#include "intf_msg.h"
#include "modules.h"
#include "modules_export.h"
static int yuv_Probe ( probedata_t *p_data );
static int yuv_Init ( vout_thread_t *p_vout );
static int yuv_Reset ( vout_thread_t *p_vout );
static void yuv_End ( vout_thread_t *p_vout );
static void SetGammaTable ( int *pi_table, double f_gamma );
static void SetYUV ( vout_thread_t *p_vout );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
void _M( yuv_getfunctions )( function_list_t * p_function_list )
{
p_function_list->pf_probe = yuv_Probe;
p_function_list->functions.yuv.pf_init = yuv_Init;
p_function_list->functions.yuv.pf_reset = yuv_Reset;
p_function_list->functions.yuv.pf_end = yuv_End;
}
/*****************************************************************************
* yuv_Probe: tests probe the audio device and return a score
*****************************************************************************
* This function tries to open the DSP and returns a score to the plugin
* manager so that it can choose the most appropriate one.
*****************************************************************************/
static int yuv_Probe( probedata_t *p_data )
{
if( TestMethod( YUV_METHOD_VAR, "yuv" ) )
{
return( 999 );
}
/* This module always works */
return( 50 );
}
/*****************************************************************************
* yuv_Init: allocate and initialize translations tables
*****************************************************************************
* This function will allocate memory to store translation tables, depending
* of the screen depth.
*****************************************************************************/
static int yuv_Init( vout_thread_t *p_vout )
{
size_t tables_size; /* tables size, in bytes */
/* Computes tables size - 3 Bpp use 32 bits pixel entries in tables */
switch( p_vout->i_bytes_per_pixel )
{
case 1:
tables_size = sizeof( u8 )
* (p_vout->b_grayscale ? GRAY_TABLE_SIZE : PALETTE_TABLE_SIZE);
break;
case 2:
tables_size = sizeof( u16 )
* (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
break;
case 3:
case 4:
default:
tables_size = sizeof( u32 )
* (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
break;
}
/* Allocate memory */
p_vout->yuv.p_base = malloc( tables_size );
if( p_vout->yuv.p_base == NULL )
{
intf_ErrMsg("error: %s", strerror(ENOMEM));
return( 1 );
}
/* Allocate memory for conversion buffer and offset array */
p_vout->yuv.p_buffer = malloc( VOUT_MAX_WIDTH * p_vout->i_bytes_per_pixel );
if( p_vout->yuv.p_buffer == NULL )
{
intf_ErrMsg("error: %s", strerror(ENOMEM));
free( p_vout->yuv.p_base );
return( 1 );
}
/* In 8bpp we have a twice as big offset table because we also
* need the offsets for U and V (not only Y) */
p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) *
( ( p_vout->i_bytes_per_pixel == 1 ) ? 2 : 1 ) );
if( p_vout->yuv.p_offset == NULL )
{
intf_ErrMsg("error: %s", strerror(ENOMEM));
free( p_vout->yuv.p_base );
free( p_vout->yuv.p_buffer );
return( 1 );
}
/* Initialize tables */
SetYUV( p_vout );
return( 0 );
}
/*****************************************************************************
* yuv_End: destroy translations tables
*****************************************************************************
* Free memory allocated by yuv_CCreate.
*****************************************************************************/
static void yuv_End( vout_thread_t *p_vout )
{
free( p_vout->yuv.p_base );
free( p_vout->yuv.p_buffer );
free( p_vout->yuv.p_offset );
}
/*****************************************************************************
* yuv_Reset: re-initialize translations tables
*****************************************************************************
* This function will initialize the tables allocated by vout_CreateTables and
* set functions pointers.
*****************************************************************************/
static int yuv_Reset( vout_thread_t *p_vout )
{
yuv_End( p_vout );
return( yuv_Init( p_vout ) );
}
/*****************************************************************************
* SetGammaTable: return intensity table transformed by gamma curve.
*****************************************************************************
* pi_table is a table of 256 entries from 0 to 255.
*****************************************************************************/
static void SetGammaTable( int *pi_table, double f_gamma )
{
int i_y; /* base intensity */
/* Use exp(gamma) instead of gamma */
f_gamma = exp( f_gamma );
/* Build gamma table */
for( i_y = 0; i_y < 256; i_y++ )
{
pi_table[ i_y ] = pow( (double)i_y / 256, f_gamma ) * 256;
}
}
/*****************************************************************************
* SetYUV: compute tables and set function pointers
*****************************************************************************/
static void SetYUV( vout_thread_t *p_vout )
{
int pi_gamma[256]; /* gamma table */
int i_index; /* index in tables */
/* Build gamma table */
SetGammaTable( pi_gamma, p_vout->f_gamma );
/*
* Set pointers and build YUV tables
*/
if( p_vout->b_grayscale )
{
/* Grayscale: build gray table */
switch( p_vout->i_bytes_per_pixel )
{
case 1:
{
u16 bright[256], transp[256];
p_vout->yuv.yuv.p_gray8 = (u8 *)p_vout->yuv.p_base + GRAY_MARGIN;
for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
{
p_vout->yuv.yuv.p_gray8[ -i_index ] = RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
p_vout->yuv.yuv.p_gray8[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
}
for( i_index = 0; i_index < 256; i_index++)
{
p_vout->yuv.yuv.p_gray8[ i_index ] = pi_gamma[ i_index ];
bright[ i_index ] = i_index << 8;
transp[ i_index ] = 0;
}
/* the colors have been allocated, we can set the palette */
p_vout->pf_setpalette( p_vout, bright, bright, bright, transp );
p_vout->i_white_pixel = 0xff;
p_vout->i_black_pixel = 0x00;
p_vout->i_gray_pixel = 0x44;
p_vout->i_blue_pixel = 0x3b;
break;
}
case 2:
p_vout->yuv.yuv.p_gray16 = (u16 *)p_vout->yuv.p_base + GRAY_MARGIN;
for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
{
p_vout->yuv.yuv.p_gray16[ -i_index ] = RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
p_vout->yuv.yuv.p_gray16[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
}
for( i_index = 0; i_index < 256; i_index++)
{
p_vout->yuv.yuv.p_gray16[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
}
break;
case 3:
case 4:
p_vout->yuv.yuv.p_gray32 = (u32 *)p_vout->yuv.p_base + GRAY_MARGIN;
for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
{
p_vout->yuv.yuv.p_gray32[ -i_index ] = RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
p_vout->yuv.yuv.p_gray32[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
}
for( i_index = 0; i_index < 256; i_index++)
{
p_vout->yuv.yuv.p_gray32[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
}
break;
}
}
else
{
/* Color: build red, green and blue tables */
switch( p_vout->i_bytes_per_pixel )
{
case 1:
{
#define RGB_MIN 0
#define RGB_MAX 255
#define CLIP( x ) ( ((x < 0) ? 0 : (x > 255) ? 255 : x) << 8 )
int y,u,v;
int r,g,b;
int uvr, uvg, uvb;
int i = 0, j = 0;
u16 red[256], green[256], blue[256], transp[256];
unsigned char lookup[PALETTE_TABLE_SIZE];
p_vout->yuv.yuv.p_rgb8 = (u8 *)p_vout->yuv.p_base;
/* this loop calculates the intersection of an YUV box
* and the RGB cube. */
for ( y = 0; y <= 256; y += 16 )
{
for ( u = 0; u <= 256; u += 32 )
for ( v = 0; v <= 256; v += 32 )
{
uvr = (V_RED_COEF*(v-128)) >> SHIFT;
uvg = (U_GREEN_COEF*(u-128) + V_GREEN_COEF*(v-128)) >> SHIFT;
uvb = (U_BLUE_COEF*(u-128)) >> SHIFT;
r = y + uvr;
g = y + uvg;
b = y + uvb;
if( r >= RGB_MIN && g >= RGB_MIN && b >= RGB_MIN
&& r <= RGB_MAX && g <= RGB_MAX && b <= RGB_MAX )
{
/* this one should never happen unless someone fscked up my code */
if(j == 256) { intf_ErrMsg( "vout error: no colors left to build palette" ); break; }
/* clip the colors */
red[j] = CLIP( r );
green[j] = CLIP( g );
blue[j] = CLIP( b );
transp[j] = 0;
/* allocate color */
lookup[i] = 1;
p_vout->yuv.yuv.p_rgb8[i++] = j;
j++;
}
else
{
lookup[i] = 0;
p_vout->yuv.yuv.p_rgb8[i++] = 0;
}
}
i += 128-81;
}
/* the colors have been allocated, we can set the palette */
/* there will eventually be a way to know which colors
* couldn't be allocated and try to find a replacement */
p_vout->pf_setpalette( p_vout, red, green, blue, transp );
p_vout->i_white_pixel = 0xff;
p_vout->i_black_pixel = 0x00;
p_vout->i_gray_pixel = 0x44;
p_vout->i_blue_pixel = 0x3b;