Commit 07672a42 authored by Pierre Baillet's avatar Pierre Baillet

- partial SDL YUV support (green stream for now, please help me !)

- "y" key switch between SDL and vlc YUV
- autodetection of Overlay support
- soon to come, colors :P
parent b185a7ee
...@@ -73,7 +73,8 @@ typedef struct vout_sys_s ...@@ -73,7 +73,8 @@ typedef struct vout_sys_s
/* local prototype */ /* local prototype */
void intf_SDL_Keymap( intf_thread_t * p_intf ); void intf_SDL_Keymap( intf_thread_t * p_intf );
void intf_SDL_Fullscreen(intf_thread_t * p_intf); void intf_SDL_Fullscreen(intf_thread_t * p_intf);
void intf_SDL_YUVSwitch(intf_thread_t * p_intf);
/***************************************************************************** /*****************************************************************************
* intf_SDLCreate: initialize and create SDL interface * intf_SDLCreate: initialize and create SDL interface
...@@ -159,7 +160,9 @@ void intf_SDLManage( intf_thread_t *p_intf ) ...@@ -159,7 +160,9 @@ void intf_SDLManage( intf_thread_t *p_intf )
case SDLK_f: case SDLK_f:
intf_SDL_Fullscreen(p_intf); intf_SDL_Fullscreen(p_intf);
break; break;
case SDLK_y:
intf_SDL_YUVSwitch(p_intf);
break;
default : default :
if( intf_ProcessKey( p_intf, (char ) i_key ) ) if( intf_ProcessKey( p_intf, (char ) i_key ) )
{ {
...@@ -179,6 +182,12 @@ void intf_SDLManage( intf_thread_t *p_intf ) ...@@ -179,6 +182,12 @@ void intf_SDLManage( intf_thread_t *p_intf )
} }
} }
void intf_SDL_YUVSwitch(intf_thread_t * p_intf)
{
p_intf->p_vout->b_need_render = 1 - p_intf->p_vout->b_need_render;
intf_DbgMsg( "need render now : '%d'",p_intf->p_vout->b_need_render);
}
void intf_SDL_Fullscreen(intf_thread_t * p_intf) void intf_SDL_Fullscreen(intf_thread_t * p_intf)
{ {
SDL_Rect clipping_rect; SDL_Rect clipping_rect;
......
...@@ -73,6 +73,7 @@ static void SDLCloseDisplay ( vout_thread_t *p_vout ); ...@@ -73,6 +73,7 @@ static void SDLCloseDisplay ( vout_thread_t *p_vout );
int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display, int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
int i_root_window, void *p_data ) int i_root_window, void *p_data )
{ {
SDL_Overlay * screen;
/* Allocate structure */ /* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL ) if( p_vout->p_sys == NULL )
...@@ -89,6 +90,20 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display, ...@@ -89,6 +90,20 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
free( p_vout->p_sys ); free( p_vout->p_sys );
return( 1 ); return( 1 );
} }
screen = SDL_CreateYUVOverlay(
10,
10,
SDL_IYUV_OVERLAY,
p_vout->p_sys->p_display
);
intf_ErrMsg("[YUV acceleration] : %d",screen->hw_overlay);
if(screen->hw_overlay)
{
//hw_acceleration !
p_vout->b_need_render = 0;
}
return( 0 ); return( 0 );
} }
...@@ -156,32 +171,56 @@ void vout_SDLDisplay( vout_thread_t *p_vout ) ...@@ -156,32 +171,56 @@ void vout_SDLDisplay( vout_thread_t *p_vout )
{ {
SDL_Overlay * screen; SDL_Overlay * screen;
SDL_Rect disp; SDL_Rect disp;
if(1) if(p_vout->b_need_render)
{ {
/* Change display frame */ /* Change display frame */
if( p_vout->p_sys->b_must_acquire ) if( p_vout->p_sys->b_must_acquire )
{ {
SDL_Flip( p_vout->p_sys->p_display ); SDL_Flip( p_vout->p_sys->p_display );
/* Swap buffers and change write frame */ //Swap buffers and change write frame
SDL_LockSurface ( p_vout->p_sys->p_display ); SDL_LockSurface ( p_vout->p_sys->p_display );
} }
} } else {
else
{
/* /*
* p_vout->yuv.p_buffer contains the YUV buffer to render * p_vout->yuv.p_buffer contains the YUV buffer to render
*/ */
screen = SDL_CreateYUVOverlay( p_vout->i_width, p_vout->i_height , SDL_IYUV_OVERLAY, p_vout->p_sys->p_display ); screen = SDL_CreateYUVOverlay(
screen->pixels = p_vout->yuv.p_buffer; p_vout->p_rendered_pic->i_width,
p_vout->p_rendered_pic->i_height,
SDL_IYUV_OVERLAY,
p_vout->p_sys->p_display
);
SDL_LockYUVOverlay(screen);
//* screen->pixels = calloc( p_vout->i_width * p_vout->i_height * 3, 1);
//*screen->pixels = p_vout->yuv.p_buffer;
/* *screen->pixels = malloc( p_vout->i_width * p_vout->i_height * 3 );
memcpy( *screen->pixels, p_vout->p_rendered_pic->p_y, p_vout->i_width * p_vout->i_height );
memcpy( *screen->pixels + p_vout->i_width * p_vout->i_height,
p_vout->p_rendered_pic->p_u,
p_vout->i_width * p_vout->i_height );
memcpy( *screen->pixels + p_vout->i_width * p_vout->i_height * 2,
p_vout->p_rendered_pic->p_v,
p_vout->i_width * p_vout->i_height ); */
// *screen->pixels = p_vout->p_rendered_pic->p_y;
*screen->pixels = p_vout->p_rendered_pic->p_data;
disp.x = 0; disp.x = 0;
disp.y = 0; disp.y = 0;
disp.w = p_vout->i_width; disp.w = p_vout->i_width;
disp.h = p_vout->i_height; disp.h = p_vout->i_height;
SDL_UnlockYUVOverlay(screen);
SDL_DisplayYUVOverlay( screen , &disp ); SDL_DisplayYUVOverlay( screen , &disp );
} // free(* screen -> pixels);
SDL_FreeYUVOverlay(screen);
}
} }
/* following functions are local */ /* following functions are local */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment