+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
+}
+
+/*****************************************************************************
+ * Return the best suited FourCC value for a given chroma. We use this
+ * because a decoder may output FOURCC_IYUV, which is exactly the same as
+ * FOURCC_I420, but X servers usually know FOURCC_I420 and not FOURCC_IYUV.
+ *****************************************************************************/
+static __inline__ u32 BestChroma( u32 i_chroma )
+{
+ /* XXX: don't forget to update vout_Init if you change this */
+ switch( i_chroma )
+ {
+ /* These ones are almost the same */
+ case FOURCC_I420:
+ case FOURCC_IYUV:
+ case FOURCC_YV12:
+ return SDL_YV12_OVERLAY;
+
+ /* These ones are all the same */
+ case FOURCC_UYVY:
+ case FOURCC_UYNV:
+ case FOURCC_Y422:
+ return SDL_UYVY_OVERLAY;
+
+ /* These ones are all the same */
+ case FOURCC_YUY2:
+ case FOURCC_YUNV:
+ return SDL_YUY2_OVERLAY;
+
+ /* We know this one */
+ case FOURCC_YVYU:
+ return SDL_YVYU_OVERLAY;
+
+ /* This is seldom supported, but we know how to convert it */
+ case FOURCC_I422:
+ return SDL_YUY2_OVERLAY;
+
+ /* We don't know this chroma, but maybe SDL does */
+ default:
+ return i_chroma;
+ }
+}
+
+/*****************************************************************************
+ * 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 );
+
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
+ *****************************************************************************/
+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 );
+}