* It includes functions allowing to open a new thread, send pictures to a
* thread, and destroy a previously oppened video output thread.
*****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: video_output.c,v 1.235 2003/09/14 13:54:43 sigmunau Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
static void MaskToShift ( int *, int *, uint32_t );
static void InitWindowSize ( vout_thread_t *, int *, int * );
+void vout_IntfInit( vout_thread_t * );
+
/* Object variables callbacks */
static int FullscreenCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int DeinterlaceCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static int FilterCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+
+/**
+ * vout_AspectRatio
+ *
+ * Set the i_aspect_x and i_aspect_y from i_aspect.
+ */
+void vout_AspectRatio( unsigned int i_aspect,
+ /*out*/ unsigned int *i_aspect_x,
+ /*out*/ unsigned int *i_aspect_y )
+{
+ unsigned int i_pgcd = ReduceHeight( i_aspect );
+ *i_aspect_x = i_aspect / i_pgcd;
+ *i_aspect_y = VOUT_ASPECT_FACTOR / i_pgcd;
+}
/*****************************************************************************
* vout_Request: find a video output thread, create one, or destroy one.
vlc_object_t *p_playlist;
p_playlist = vlc_object_find( p_this,
- VLC_OBJECT_PLAYLIST, FIND_PARENT );
+ VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
}
else
{
- msg_Dbg( p_this, "cannot find playlist destroying vout" );
+ msg_Dbg( p_this, "cannot find playlist, destroying vout" );
vlc_object_detach( p_vout );
vout_Destroy( p_vout );
}
p_vout->render_time = 10;
p_vout->c_fps_samples = 0;
p_vout->b_filter_change = 0;
+ p_vout->pf_control = 0;
/* Mouse coordinates */
var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-moved", VLC_VAR_BOOL );
var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER );
- var_Create( p_vout, "key-pressed", VLC_VAR_STRING );
var_Create( p_vout, "intf-change", VLC_VAR_BOOL );
val.b_bool = VLC_TRUE;
/* Attach the new object now so we can use var inheritance below */
vlc_object_attach( p_vout, p_parent );
- /* Create a few object variables we'll need later on */
- var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
- var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
- var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
- var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
- var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+ /* Take care of some "interface/control" related initialisations */
+ vout_IntfInit( p_vout );
p_vout->b_override_aspect = VLC_FALSE;
if( i_new_aspect && i_new_aspect != i_aspect )
{
- int i_pgcd = ReduceHeight( i_new_aspect );
+ unsigned int i_aspect_x, i_aspect_y;
+
+ vout_AspectRatio( i_new_aspect, &i_aspect_x, &i_aspect_y );
msg_Dbg( p_vout, "overriding source aspect ratio to %i:%i",
- i_new_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
+ i_aspect_x, i_aspect_y );
p_vout->render.i_aspect = i_new_aspect;
/* Create the vout thread */
p_vout->p_module = module_Need( p_vout,
- ( p_vout->psz_filter_chain &&
- *p_vout->psz_filter_chain ) ?
- "video filter" : "video output",
- psz_plugin );
+ ( p_vout->psz_filter_chain && *p_vout->psz_filter_chain ) ?
+ "video filter" : "video output", psz_plugin, 0 );
if( psz_plugin ) free( psz_plugin );
if( p_vout->p_module == NULL )
return NULL;
}
- p_vout->p_text_renderer_module = module_Need( p_vout, "text renderer",
- NULL );
+ p_vout->p_text_renderer_module =
+ module_Need( p_vout, "text renderer", NULL, 0 );
if( p_vout->p_text_renderer_module == NULL )
{
- msg_Warn( p_vout, "no suitable text renderer module" );
- p_vout->pf_add_string = NULL;
+ msg_Warn( p_vout, "no suitable text renderer module" );
+ p_vout->pf_add_string = NULL;
}
/* Create a few object variables for interface interaction */
if( var_Get( p_vout, "deinterlace-mode", &val ) == VLC_SUCCESS )
{
var_Set( p_vout, "deinterlace", val );
+ if( val.psz_string ) free( val.psz_string );
}
var_AddCallback( p_vout, "deinterlace", DeinterlaceCallback, NULL );
+
+ var_Create( p_vout, "filter", VLC_VAR_STRING );
+ text.psz_string = _("Filters");
+ var_Change( p_vout, "filter", VLC_VAR_SETTEXT, &text, NULL );
+ var_Change( p_vout, "filter", VLC_VAR_INHERITVALUE, &val, NULL );
+ if( val.psz_string )
+ {
+ var_Set( p_vout, "filter", val );
+ free( val.psz_string );
+ }
+ var_AddCallback( p_vout, "filter", FilterCallback, NULL );
+
/* Calculate delay created by internal caching */
p_input_thread = (input_thread_t *)vlc_object_find( p_vout,
VLC_OBJECT_INPUT, FIND_ANYWHERE );
* update using one of the THREAD_* constants.
*****************************************************************************/
void vout_Destroy( vout_thread_t *p_vout )
-{
+{
vlc_object_t *p_playlist;
-
+
/* Request thread destruction */
p_vout->b_die = VLC_TRUE;
vlc_thread_join( p_vout );
var_Destroy( p_vout, "intf-change" );
- p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
+ p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
+ if( p_vout->psz_filter_chain ) free( p_vout->psz_filter_chain );
+
/* Free structure */
vlc_object_destroy( p_vout );
/* If it was the last vout, tell the interface to show up */
if( p_playlist != NULL )
{
- vout_thread_t *p_another_vout = vlc_object_find( p_playlist,
+ vout_thread_t *p_another_vout = vlc_object_find( p_playlist,
VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_another_vout == NULL )
{
*****************************************************************************/
static int InitThread( vout_thread_t *p_vout )
{
- int i, i_pgcd;
+ int i;
+ unsigned int i_aspect_x, i_aspect_y;
vlc_mutex_lock( &p_vout->change_lock );
if( i_new_aspect && i_new_aspect != p_vout->output.i_aspect )
{
- int i_pgcd = ReduceHeight( i_new_aspect );
+ vout_AspectRatio( i_new_aspect, &i_aspect_x, &i_aspect_y );
+
msg_Dbg( p_vout, "output ratio forced to %i:%i\n",
- i_new_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
+ i_aspect_x, i_aspect_y );
p_vout->output.i_aspect = i_new_aspect;
}
}
}
#endif
- i_pgcd = ReduceHeight( p_vout->render.i_aspect );
+ vout_AspectRatio( p_vout->render.i_aspect, &i_aspect_x, &i_aspect_y );
msg_Dbg( p_vout,
"picture in %ix%i, chroma 0x%.8x (%4.4s), aspect ratio %i:%i",
p_vout->render.i_width, p_vout->render.i_height,
p_vout->render.i_chroma, (char*)&p_vout->render.i_chroma,
- p_vout->render.i_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
+ i_aspect_x, i_aspect_y );
- i_pgcd = ReduceHeight( p_vout->output.i_aspect );
+ vout_AspectRatio( p_vout->output.i_aspect, &i_aspect_x, &i_aspect_y );
msg_Dbg( p_vout,
"picture out %ix%i, chroma 0x%.8x (%4.4s), aspect ratio %i:%i",
p_vout->output.i_width, p_vout->output.i_height,
p_vout->output.i_chroma, (char*)&p_vout->output.i_chroma,
- p_vout->output.i_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd );
+ i_aspect_x, i_aspect_y );
/* Calculate shifts from system-updated masks */
MaskToShift( &p_vout->output.i_lrshift, &p_vout->output.i_rrshift,
p_vout->b_direct = 0;
/* Choose the best module */
- p_vout->chroma.p_module = module_Need( p_vout, "chroma", NULL );
+ p_vout->chroma.p_module = module_Need( p_vout, "chroma", NULL, 0 );
if( p_vout->chroma.p_module == NULL )
{
vlc_mutex_unlock( &p_vout->change_lock );
/* Sleep a while or until a given date */
- if( display_date != 0 && p_vout->psz_filter_chain == NULL )
+ if( display_date != 0 )
{
- mwait( display_date - VOUT_MWAIT_TOLERANCE );
+ /* If there are filters in the chain, better give them the picture
+ * in advance */
+ if( !p_vout->psz_filter_chain || !*p_vout->psz_filter_chain )
+ {
+ mwait( display_date - VOUT_MWAIT_TOLERANCE );
+ }
}
else
{
p_vout->chroma.p_module->pf_activate( VLC_OBJECT(p_vout) );
}
}
+
+ if( p_vout->i_changes & VOUT_PICTURE_BUFFERS_CHANGE )
+ {
+ /* This happens when the picture buffers need to be recreated.
+ * This is useful on multimonitor displays for instance.
+ *
+ * Warning: This only works when the vout creates only 1 picture
+ * buffer!! */
+ p_vout->i_changes &= ~VOUT_PICTURE_BUFFERS_CHANGE;
+
+ if( !p_vout->b_direct )
+ {
+ module_Unneed( p_vout, p_vout->chroma.p_module );
+ }
+
+ vlc_mutex_lock( &p_vout->picture_lock );
+
+ p_vout->pf_end( p_vout );
+
+ I_OUTPUTPICTURES = I_RENDERPICTURES = 0;
+
+ p_vout->b_error = InitThread( p_vout );
+
+ vlc_mutex_unlock( &p_vout->picture_lock );
+ }
}
/*
{
module_Unneed( p_vout, p_vout->chroma.p_module );
}
-
+
/* Destroy all remaining pictures */
for( i_index = 0; i_index < 2 * VOUT_MAX_PICTURES; i_index++ )
{
if( p_vout->p_text_renderer_module )
module_Unneed( p_vout, p_vout->p_text_renderer_module );
-
+
/* Destroy translation tables */
p_vout->pf_end( p_vout );
{
int i_dummy = VOUT_ASPECT_FACTOR;
int i_pgcd = 1;
-
+
if( !i_ratio )
{
return i_pgcd;
for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
{
- if( ( ES->i_cat == VIDEO_ES ) && ES->p_decoder_fifo != NULL )
+ if( ( ES->i_cat == VIDEO_ES ) && ES->p_dec != NULL )
+ {
+ input_UnselectES( p_input, ES );
+ input_SelectES( p_input, ES );
+ }
+#undef ES
+ }
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+ vlc_object_release( p_input );
+
+ val.b_bool = VLC_TRUE;
+ var_Set( p_vout, "intf-change", val );
+ return VLC_SUCCESS;
+}
+
+static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ vout_thread_t *p_vout = (vout_thread_t *)p_this;
+ input_thread_t *p_input;
+ vlc_value_t val;
+ unsigned int i;
+
+ p_input = (input_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INPUT,
+ FIND_PARENT );
+
+ if (!p_input)
+ {
+ msg_Err( p_vout, "Input not found" );
+ return( VLC_EGENERIC );
+ }
+ /* Restart the video stream */
+ vlc_mutex_lock( &p_input->stream.stream_lock );
+
+ p_vout->b_filter_change = VLC_TRUE;
+
+#define ES p_input->stream.pp_es[i]
+
+ for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
+ {
+ if( ( ES->i_cat == VIDEO_ES ) && ES->p_dec != NULL )
{
input_UnselectES( p_input, ES );
input_SelectES( p_input, ES );
var_Set( p_vout, "intf-change", val );
return VLC_SUCCESS;
}
+