* vout_sdl.c: SDL video output display method
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: vout_sdl.c,v 1.75 2002/01/02 14:37:42 sam Exp $
+ * $Id: vout_sdl.c,v 1.85 2002/03/18 19:14:52 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Pierre Baillet <oct@zoy.org>
#include "stream_control.h" /* needed by input_ext-intf.h... */
#include "input_ext-intf.h"
-#define SDL_MAX_DIRECTBUFFERS 5
+#define SDL_MAX_DIRECTBUFFERS 10
#define SDL_DEFAULT_BPP 16
/*****************************************************************************
typedef struct vout_sys_s
{
SDL_Surface * p_display; /* display device */
- SDL_Overlay * p_overlay; /* An overlay we keep to grab the XVideo port */
int i_width;
int i_height;
+ /* For YUV output */
+ SDL_Overlay * p_overlay; /* An overlay we keep to grab the XVideo port */
+
+ /* For RGB output */
int i_surfaces;
boolean_t b_cursor;
} picture_sys_t;
+/*****************************************************************************
+ * Seeking function TODO: put this in a generic location !
+ *****************************************************************************/
+static __inline__ void vout_Seek( off_t i_seek )
+{
+ off_t i_tell;
+
+ vlc_mutex_lock( &p_input_bank->lock );
+ if( p_input_bank->pp_input[0] != NULL )
+ {
+#define S p_input_bank->pp_input[0]->stream
+ i_tell = S.p_selected_area->i_tell + i_seek * (off_t)50 * S.i_mux_rate;
+
+ i_tell = ( i_tell <= 0 /*S.p_selected_area->i_start*/ )
+ ? 0 /*S.p_selected_area->i_start*/
+ : ( i_tell >= S.p_selected_area->i_size )
+ ? S.p_selected_area->i_size
+ : i_tell;
+
+ input_Seek( p_input_bank->pp_input[0], i_tell );
+#undef S
+ }
+ vlc_mutex_unlock( &p_input_bank->lock );
+}
+
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-static int vout_Probe ( probedata_t *p_data );
static int vout_Create ( struct vout_thread_s * );
static int vout_Init ( struct vout_thread_s * );
static void vout_End ( struct vout_thread_s * );
static void vout_Destroy ( struct vout_thread_s * );
static int vout_Manage ( struct vout_thread_s * );
+static void vout_Render ( struct vout_thread_s *, struct picture_s * );
static void vout_Display ( struct vout_thread_s *, struct picture_s * );
-static int SDLOpenDisplay ( vout_thread_t *p_vout );
-static void SDLCloseDisplay ( vout_thread_t *p_vout );
-static int SDLNewPicture ( vout_thread_t *p_vout, picture_t *p_pic );
+static int OpenDisplay ( struct vout_thread_s * );
+static void CloseDisplay ( struct vout_thread_s * );
+static int NewPicture ( struct vout_thread_s *, struct picture_s * );
+static void SetPalette ( struct vout_thread_s *, u16 *, u16 *, u16 * );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
*****************************************************************************/
void _M( vout_getfunctions )( function_list_t * p_function_list )
{
- p_function_list->pf_probe = vout_Probe;
p_function_list->functions.vout.pf_create = vout_Create;
p_function_list->functions.vout.pf_init = vout_Init;
p_function_list->functions.vout.pf_end = vout_End;
p_function_list->functions.vout.pf_destroy = vout_Destroy;
p_function_list->functions.vout.pf_manage = vout_Manage;
+ p_function_list->functions.vout.pf_render = vout_Render;
p_function_list->functions.vout.pf_display = vout_Display;
- p_function_list->functions.vout.pf_setpalette = NULL;
-}
-
-/*****************************************************************************
- * vout_Probe: probe the video driver and return a score
- *****************************************************************************
- * This function tries to initialize SDL and returns a score to the
- * plugin manager so that it can select the best plugin.
- *****************************************************************************/
-static int vout_Probe( probedata_t *p_data )
-{
- if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
- {
- return( 0 );
- }
-
- return( 100 );
}
/*****************************************************************************
*****************************************************************************/
static int vout_Create( vout_thread_t *p_vout )
{
+ char *psz_method;
+
+ if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
+ {
+ return( 1 );
+ }
+
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
return( 1 );
}
+ psz_method = config_GetPszVariable( "vout" );
+ if( psz_method )
+ {
+ while( *psz_method && *psz_method != ':' )
+ {
+ psz_method++;
+ }
+
+ if( *psz_method )
+ {
+ setenv( "SDL_VIDEODRIVER", psz_method + 1, 1 );
+ }
+ }
+
/* Initialize library */
if( SDL_Init( SDL_INIT_VIDEO
#ifndef WIN32
return( 1 );
}
- p_vout->p_sys->b_cursor = 1; /* TODO should be done with a main_GetInt.. */
+ p_vout->p_sys->b_cursor = 1;
p_vout->p_sys->b_cursor_autohidden = 0;
p_vout->p_sys->i_lastmoved = mdate();
}
#endif
- if( SDLOpenDisplay( p_vout ) )
+ if( OpenDisplay( p_vout ) )
{
intf_ErrMsg( "vout error: can't set up SDL (%s)", SDL_GetError() );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
I_OUTPUTPICTURES = 0;
/* Initialize the output structure */
- switch( p_vout->render.i_chroma )
+ if( p_vout->p_sys->p_overlay == NULL )
{
- case FOURCC_I420:
- case FOURCC_IYUV:
- case FOURCC_YV12:
- p_vout->output.i_chroma = p_vout->render.i_chroma;
- p_vout->output.i_width = p_vout->render.i_width;
- p_vout->output.i_height = p_vout->render.i_height;
- p_vout->output.i_aspect = p_vout->render.i_aspect;
- break;
-
- default:
- /* All we have is a 16bpp image with square pixels */
- /* FIXME: and if screen depth != 16 ?! */
- p_vout->output.i_chroma = FOURCC_BI_BITFIELDS | DEPTH_16BPP;
- p_vout->output.i_width = p_vout->p_sys->i_width;
- p_vout->output.i_height = p_vout->p_sys->i_height;
- p_vout->output.i_aspect = p_vout->p_sys->i_width
- * VOUT_ASPECT_FACTOR / p_vout->p_sys->i_height;
- break;
+ /* All we have is an RGB image with square pixels */
+ p_vout->output.i_width = p_vout->p_sys->i_width;
+ p_vout->output.i_height = p_vout->p_sys->i_height;
+ p_vout->output.i_aspect = p_vout->p_sys->i_width
+ * VOUT_ASPECT_FACTOR
+ / p_vout->p_sys->i_height;
+ }
+ else
+ {
+ /* We may need to convert the chroma, but at least we keep the
+ * aspect ratio */
+ p_vout->output.i_width = p_vout->render.i_width;
+ p_vout->output.i_height = p_vout->render.i_height;
+ p_vout->output.i_aspect = p_vout->render.i_aspect;
}
/* Try to initialize SDL_MAX_DIRECTBUFFERS direct buffers */
}
/* Allocate the picture if we found one */
- if( p_pic == NULL || SDLNewPicture( p_vout, p_pic ) )
+ if( p_pic == NULL || NewPicture( p_vout, p_pic ) )
{
break;
}
- p_pic->i_status = DESTROYED_PICTURE;
- p_pic->i_type = DIRECT_PICTURE;
-
- p_pic->i_left_margin =
- p_pic->i_right_margin =
- p_pic->i_top_margin =
- p_pic->i_bottom_margin = 0;
+ p_pic->i_status = DESTROYED_PICTURE;
+ p_pic->i_type = DIRECT_PICTURE;
PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
for( i_index = I_OUTPUTPICTURES ; i_index ; )
{
i_index--;
- switch( p_vout->output.i_chroma )
+ if( p_vout->p_sys->p_overlay == NULL )
{
- case FOURCC_I420:
- case FOURCC_IYUV:
- case FOURCC_YV12:
- SDL_UnlockYUVOverlay(
- PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
- SDL_FreeYUVOverlay(
- PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
- break;
-
- default:
- /* RGB picture */
- break;
+ /* RGB picture */
+ }
+ else
+ {
+ SDL_UnlockYUVOverlay(
+ PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
+ SDL_FreeYUVOverlay(
+ PP_OUTPUTPICTURE[ i_index ]->p_sys->p_overlay );
}
free( PP_OUTPUTPICTURE[ i_index ]->p_sys );
}
*****************************************************************************/
static void vout_Destroy( vout_thread_t *p_vout )
{
- SDLCloseDisplay( p_vout );
+ CloseDisplay( p_vout );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
free( p_vout->p_sys );
}
-static __inline__ void vout_Seek( off_t i_seek )
-{
-#define area p_main->p_intf->p_input->stream.p_selected_area
- off_t i_tell = area->i_tell;
-
- i_tell += i_seek * (off_t)50 * p_main->p_intf->p_input->stream.i_mux_rate;
-
- i_tell = ( i_tell <= area->i_start ) ? area->i_start
- : ( i_tell >= area->i_size ) ? area->i_size
- : i_tell;
-
- input_Seek( p_main->p_intf->p_input, i_tell );
-#undef area
-}
-
/*****************************************************************************
* vout_Manage: handle Sys events
*****************************************************************************
case SDL_VIDEORESIZE: /* Resizing of window */
p_vout->p_sys->i_width = event.resize.w;
p_vout->p_sys->i_height = event.resize.h;
- SDLCloseDisplay( p_vout );
- SDLOpenDisplay( p_vout );
+ CloseDisplay( p_vout );
+ OpenDisplay( p_vout );
break;
case SDL_MOUSEMOTION:
/* In this part we will eventually manage
* clicks for DVD navigation for instance. For the
* moment just pause the stream. */
- input_SetStatus( p_main->p_intf->p_input, INPUT_STATUS_PAUSE );
+ input_SetStatus( p_input_bank->pp_input[0],
+ INPUT_STATUS_PAUSE );
break;
case 4:
switch( event.key.keysym.sym )
{
case SDLK_q: /* quit */
- case SDLK_ESCAPE:
+ case SDLK_ESCAPE:
p_main->p_intf->b_die = 1;
break;
case SDLK_F9: network_ChannelJoin( 9 ); break;
default:
- intf_DbgMsg( "unhandled key %i", event.key.keysym.sym );
break;
}
break;
return( 0 );
}
+/*****************************************************************************
+ * vout_Render: render previously calculated output
+ *****************************************************************************/
+static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
+{
+ ;
+}
+
/*****************************************************************************
* vout_Display: displays previously rendered output
*****************************************************************************
disp.w = w;
disp.h = h;
- switch( p_vout->output.i_chroma )
+ if( p_vout->p_sys->p_overlay == NULL )
{
- case FOURCC_I420:
- case FOURCC_IYUV:
- case FOURCC_YV12:
- SDL_UnlockYUVOverlay( p_pic->p_sys->p_overlay);
- SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
- SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
- break;
-
- default:
- /* RGB picture */
- SDL_Flip(p_vout->p_sys->p_display);
- break;
+ /* RGB picture */
+ SDL_Flip( p_vout->p_sys->p_display );
+ }
+ else
+ {
+ /* Overlay picture */
+ SDL_UnlockYUVOverlay( p_pic->p_sys->p_overlay);
+ SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
+ SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
}
}
/* following functions are local */
/*****************************************************************************
- * SDLOpenDisplay: open and initialize SDL device
+ * OpenDisplay: open and initialize SDL device
*****************************************************************************
* Open and initialize display according to preferences specified in the vout
* thread fields.
*****************************************************************************/
-static int SDLOpenDisplay( vout_thread_t *p_vout )
+static int OpenDisplay( vout_thread_t *p_vout )
{
Uint32 i_flags;
int i_bpp;
SDL_LockSurface( p_vout->p_sys->p_display );
+ /* Choose the chroma we will try first. */
+ switch( p_vout->render.i_chroma )
+ {
+ case FOURCC_YUY2:
+ case FOURCC_YUNV:
+ p_vout->output.i_chroma = SDL_YUY2_OVERLAY;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_UYNV:
+ case FOURCC_Y422:
+ p_vout->output.i_chroma = SDL_UYVY_OVERLAY;
+ break;
+ case FOURCC_YVYU:
+ p_vout->output.i_chroma = SDL_YVYU_OVERLAY;
+ break;
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ case FOURCC_IYUV:
+ default:
+ p_vout->output.i_chroma = SDL_YV12_OVERLAY;
+ break;
+ }
+
p_vout->p_sys->p_overlay =
- SDL_CreateYUVOverlay( 32, 32, SDL_YV12_OVERLAY,
+ SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
p_vout->p_sys->p_display );
+ /* FIXME: if the first overlay we find is software, don't stop,
+ * because we may find a hardware one later ... */
+ /* If this best choice failed, fall back to other chromas */
if( p_vout->p_sys->p_overlay == NULL )
{
- intf_ErrMsg( "vout error: cannot set overlay" );
- SDL_UnlockSurface( p_vout->p_sys->p_display );
- SDL_FreeSurface( p_vout->p_sys->p_display );
- return( 1 );
+ p_vout->output.i_chroma = SDL_IYUV_OVERLAY;
+ p_vout->p_sys->p_overlay =
+ SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
+ p_vout->p_sys->p_display );
+ }
+
+ if( p_vout->p_sys->p_overlay == NULL )
+ {
+ p_vout->output.i_chroma = SDL_YV12_OVERLAY;
+ p_vout->p_sys->p_overlay =
+ SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
+ p_vout->p_sys->p_display );
}
- if( p_vout->p_sys->p_overlay->hw_overlay )
+ if( p_vout->p_sys->p_overlay == NULL )
{
- SDL_WM_SetCaption( VOUT_TITLE " (hardware SDL output)",
- VOUT_TITLE " (hardware SDL output)" );
+ p_vout->output.i_chroma = SDL_YUY2_OVERLAY;
+ p_vout->p_sys->p_overlay =
+ SDL_CreateYUVOverlay( 32, 32, p_vout->output.i_chroma,
+ p_vout->p_sys->p_display );
+ }
+
+ if( p_vout->p_sys->p_overlay == NULL )
+ {
+ intf_WarnMsg( 3, "vout warning: no SDL overlay for 0x%.8x (%4.4s)",
+ p_vout->render.i_chroma,
+ (char*)&p_vout->render.i_chroma );
+
+ switch( p_vout->p_sys->p_display->format->BitsPerPixel )
+ {
+ case 8:
+ p_vout->output.i_chroma = FOURCC_RGB2;
+ p_vout->output.pf_setpalette = SetPalette;
+ break;
+ case 15:
+ p_vout->output.i_chroma = FOURCC_RV15;
+ break;
+ case 16:
+ p_vout->output.i_chroma = FOURCC_RV16;
+ break;
+ case 24:
+ p_vout->output.i_chroma = FOURCC_RV24;
+ break;
+ case 32:
+ p_vout->output.i_chroma = FOURCC_RV32;
+ break;
+ default:
+ intf_ErrMsg( "vout error: unknown screen depth" );
+ SDL_UnlockSurface( p_vout->p_sys->p_display );
+ SDL_FreeSurface( p_vout->p_sys->p_display );
+ return( -1 );
+ }
+
+ p_vout->output.i_rmask = p_vout->p_sys->p_display->format->Rmask;
+ p_vout->output.i_gmask = p_vout->p_sys->p_display->format->Gmask;
+ p_vout->output.i_bmask = p_vout->p_sys->p_display->format->Bmask;
+
+ SDL_WM_SetCaption( VOUT_TITLE " (software RGB SDL output)",
+ VOUT_TITLE " (software RGB SDL output)" );
}
else
{
- SDL_WM_SetCaption( VOUT_TITLE " (software SDL output)",
- VOUT_TITLE " (software SDL output)" );
+ if( p_vout->p_sys->p_overlay->hw_overlay )
+ {
+ SDL_WM_SetCaption( VOUT_TITLE " (hardware YUV SDL output)",
+ VOUT_TITLE " (hardware YUV SDL output)" );
+ }
+ else
+ {
+ SDL_WM_SetCaption( VOUT_TITLE " (software YUV SDL output)",
+ VOUT_TITLE " (software YUV SDL output)" );
+ }
}
SDL_EventState( SDL_KEYUP, SDL_IGNORE ); /* ignore keys up */
}
/*****************************************************************************
- * SDLCloseDisplay: close and reset SDL device
+ * CloseDisplay: close and reset SDL device
*****************************************************************************
- * This function returns all resources allocated by SDLOpenDisplay and restore
+ * This function returns all resources allocated by OpenDisplay and restore
* the original state of the device.
*****************************************************************************/
-static void SDLCloseDisplay( vout_thread_t *p_vout )
+static void CloseDisplay( vout_thread_t *p_vout )
{
SDL_FreeYUVOverlay( p_vout->p_sys->p_overlay );
SDL_UnlockSurface ( p_vout->p_sys->p_display );
}
/*****************************************************************************
- * SDLNewPicture: allocate a picture
+ * NewPicture: allocate a picture
*****************************************************************************
* Returns 0 on success, -1 otherwise
*****************************************************************************/
-static int SDLNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
+static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
-#define P p_pic->planes
int i_width = p_vout->output.i_width;
int i_height = p_vout->output.i_height;
- switch( p_vout->output.i_chroma )
+ if( p_vout->p_sys->p_overlay == NULL )
{
- case FOURCC_I420:
- case FOURCC_IYUV:
- case FOURCC_YV12:
- p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
+ /* RGB picture */
+ if( p_vout->p_sys->i_surfaces )
+ {
+ /* We already allocated this surface, return */
+ return -1;
+ }
- if( p_pic->p_sys == NULL )
- {
- return -1;
- }
+ p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
- p_pic->p_sys->p_overlay =
- SDL_CreateYUVOverlay( i_width, i_height,
- SDL_YV12_OVERLAY,
- p_vout->p_sys->p_display );
+ if( p_pic->p_sys == NULL )
+ {
+ return -1;
+ }
- if( p_pic->p_sys->p_overlay == NULL )
- {
- free( p_pic->p_sys );
- return -1;
- }
+ switch( p_vout->p_sys->p_display->format->BitsPerPixel )
+ {
+ case 8:
+ p_pic->p->i_pixel_bytes = 1;
+ break;
+ case 15:
+ case 16:
+ p_pic->p->i_pixel_bytes = 2;
+ break;
+ case 24:
+ case 32:
+ p_pic->p->i_pixel_bytes = 4;
+ break;
+ default:
+ return( -1 );
+ }
- SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
+ p_pic->p->p_pixels = p_vout->p_sys->p_display->pixels;
+ p_pic->p->i_lines = p_vout->p_sys->p_display->h;
+ p_pic->p->i_pitch = p_vout->p_sys->p_display->pitch;
- /* FIXME: try to get the right i_bytes value from p_overlay */
- P[ Y_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[ 0 ];
- P[ Y_PLANE ].i_bytes = i_width * i_height;
- P[ Y_PLANE ].i_line_bytes = i_width;
+ if( p_pic->p->i_pitch ==
+ p_pic->p->i_pixel_bytes * p_vout->p_sys->p_display->w )
+ {
+ p_pic->p->b_margin = 0;
+ }
+ else
+ {
+ p_pic->p->b_margin = 1;
+ p_pic->p->b_hidden = 1;
+ p_pic->p->i_visible_bytes =
+ p_pic->p->i_pixel_bytes * p_vout->p_sys->p_display->w;
+ }
- P[ U_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[ 2 ];
- P[ U_PLANE ].i_bytes = i_width * i_height / 4;
- P[ U_PLANE ].i_line_bytes = i_width / 2;
+ p_vout->p_sys->i_surfaces++;
- P[ V_PLANE ].p_data = p_pic->p_sys->p_overlay->pixels[ 1 ];
- P[ V_PLANE ].i_bytes = i_width * i_height / 4;
- P[ V_PLANE ].i_line_bytes = i_width / 2;
+ p_pic->i_planes = 1;
+ }
+ else
+ {
+ p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
- p_pic->i_planes = 3;
+ if( p_pic->p_sys == NULL )
+ {
+ return -1;
+ }
- return 0;
+ p_pic->p_sys->p_overlay =
+ SDL_CreateYUVOverlay( i_width, i_height,
+ p_vout->output.i_chroma,
+ p_vout->p_sys->p_display );
- case FOURCC_BI_BITFIELDS | DEPTH_16BPP:
- if( p_vout->p_sys->i_surfaces )
- {
- /* We already allocated this surface, return */
- return -1;
- }
+ if( p_pic->p_sys->p_overlay == NULL )
+ {
+ free( p_pic->p_sys );
+ return -1;
+ }
- p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
+ SDL_LockYUVOverlay( p_pic->p_sys->p_overlay );
- if( p_pic->p_sys == NULL )
- {
- return -1;
- }
+ p_pic->Y_PIXELS = p_pic->p_sys->p_overlay->pixels[0];
+ p_pic->p[Y_PLANE].i_lines = p_pic->p_sys->p_overlay->h;
+ p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[0];
- P[ MAIN_PLANE ].p_data = p_vout->p_sys->p_display->pixels;
- P[ MAIN_PLANE ].i_bytes = 2 * i_width * i_height;
- P[ MAIN_PLANE ].i_line_bytes = 2 * i_width;
+ switch( p_vout->output.i_chroma )
+ {
+ case SDL_YV12_OVERLAY:
+ p_pic->p[Y_PLANE].i_pixel_bytes = 1;
+ p_pic->p[Y_PLANE].b_margin = 0;
+
+ p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
+ p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
+ p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
+ p_pic->p[U_PLANE].i_pixel_bytes = 1;
+ p_pic->p[U_PLANE].b_margin = 0;
+
+ p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
+ p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
+ p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
+ p_pic->p[V_PLANE].i_pixel_bytes = 1;
+ p_pic->p[V_PLANE].b_margin = 0;
- p_vout->p_sys->i_surfaces++;
+ p_pic->i_planes = 3;
+ break;
- p_pic->i_planes = 1;
+ case SDL_IYUV_OVERLAY:
+ p_pic->p[Y_PLANE].i_pixel_bytes = 1;
+ p_pic->p[Y_PLANE].b_margin = 0;
- return 0;
+ p_pic->U_PIXELS = p_pic->p_sys->p_overlay->pixels[1];
+ p_pic->p[U_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
+ p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[1];
+ p_pic->p[U_PLANE].i_pixel_bytes = 1;
+ p_pic->p[U_PLANE].b_margin = 0;
+
+ p_pic->V_PIXELS = p_pic->p_sys->p_overlay->pixels[2];
+ p_pic->p[V_PLANE].i_lines = p_pic->p_sys->p_overlay->h / 2;
+ p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_overlay->pitches[2];
+ p_pic->p[V_PLANE].i_pixel_bytes = 1;
+ p_pic->p[V_PLANE].b_margin = 0;
+
+ p_pic->i_planes = 3;
+ break;
default:
- /* Unknown chroma, tell the guy to get lost */
- p_pic->i_planes = 0;
+ p_pic->p[Y_PLANE].i_pixel_bytes = 2;
+ p_pic->p[Y_PLANE].b_margin = 0;
- return -1;
+ p_pic->i_planes = 1;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
+ * SetPalette: sets an 8 bpp palette
+ *****************************************************************************/
+static void SetPalette( vout_thread_t *p_vout, u16 *red, u16 *green, u16 *blue )
+{
+ SDL_Color colors[256];
+ int i;
+
+ /* Fill colors with color information */
+ for( i = 0; i < 256; i++ )
+ {
+ colors[ i ].r = red[ i ] >> 8;
+ colors[ i ].g = green[ i ] >> 8;
+ colors[ i ].b = blue[ i ] >> 8;
+ }
+
+ /* Set palette */
+ if( SDL_SetColors( p_vout->p_sys->p_display, colors, 0, 256 ) == 0 )
+ {
+ intf_ErrMsg( "vout error: failed setting palette" );
}
-#undef P
}