* 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 VideoLAN
- * $Id: video_output.c,v 1.142 2001/10/03 03:32:05 xav Exp $
+ * Copyright (C) 2000-2001 VideoLAN
+ * $Id: video_output.c,v 1.191 2002/08/29 23:53:22 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include "defs.h"
-
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
-#ifndef WIN32
-#include <sys/times.h>
-#endif
+#include <vlc/vlc.h>
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
-#include "modules.h"
+#ifdef HAVE_SYS_TIMES_H
+# include <sys/times.h>
+#endif
#include "video.h"
#include "video_output.h"
-#include "video_text.h"
-#include "video_spu.h"
-#include "video_yuv.h"
-
-#include "intf_msg.h"
-#include "main.h"
+#if defined( SYS_DARWIN )
+#include "darwin_specific.h"
+#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int BinaryLog ( u32 i );
-static void MaskToShift ( int *pi_left, int *pi_right, u32 i_mask );
-static int InitThread ( vout_thread_t *p_vout );
-static void RunThread ( vout_thread_t *p_vout );
-static void ErrorThread ( vout_thread_t *p_vout );
-static void EndThread ( vout_thread_t *p_vout );
-static void DestroyThread ( vout_thread_t *p_vout, int i_status );
-static void Print ( vout_thread_t *p_vout, int i_x, int i_y,
- int i_h_align, int i_v_align,
- unsigned char *psz_text );
-static void SetBuffers ( vout_thread_t *p_vout, void *, void * );
-static void SetBufferArea ( vout_thread_t *p_vout, int i_x, int i_y,
- int i_w, int i_h );
-static void SetBufferPicture ( vout_thread_t *p_vout, picture_t *p_pic );
-static void RenderPicture ( vout_thread_t *p_vout, picture_t *p_pic );
-static void RenderPictureInfo ( vout_thread_t *p_vout, picture_t *p_pic );
-static void RenderSubPicture ( vout_thread_t *p_vout, picture_t *p_pic,
- subpicture_t *p_subpic );
-static int RenderIdle ( vout_thread_t *p_vout );
-static void RenderInfo ( vout_thread_t *p_vout );
-static int Manage ( vout_thread_t *p_vout );
-static int Align ( vout_thread_t *p_vout, int *pi_x,
- int *pi_y, int i_width, int i_height,
- int i_h_align, int i_v_align );
-static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
- u16 *green, u16 *blue, u16 *transp );
+static int InitThread ( vout_thread_t * );
+static void RunThread ( vout_thread_t * );
+static void ErrorThread ( vout_thread_t * );
+static void EndThread ( vout_thread_t * );
+static void DestroyThread ( vout_thread_t * );
-/*****************************************************************************
- * vout_InitBank: initialize the video output bank.
- *****************************************************************************/
-void vout_InitBank ( void )
-{
- p_vout_bank->i_count = 0;
-
- vlc_mutex_init( &p_vout_bank->lock );
-}
-
-/*****************************************************************************
- * vout_EndBank: empty the video output bank.
- *****************************************************************************
- * This function ends all unused video outputs and empties the bank in
- * case of success.
- *****************************************************************************/
-void vout_EndBank ( void )
-{
- /* Ask all remaining video outputs to die */
- while( p_vout_bank->i_count )
- {
- vout_DestroyThread(
- p_vout_bank->pp_vout[ --p_vout_bank->i_count ], NULL );
- }
-
- vlc_mutex_destroy( &p_vout_bank->lock );
-}
+static int ReduceHeight ( int );
+static int BinaryLog ( u32 );
+static void MaskToShift ( int *, int *, u32 );
+static void InitWindowSize ( vout_thread_t *, int *, int * );
/*****************************************************************************
* vout_CreateThread: creates a new video output thread
*****************************************************************************
* This function creates a new video output thread, and returns a pointer
* to its description. On error, it returns NULL.
- * If pi_status is NULL, then the function will block until the thread is ready.
- * If not, it will be updated using one of the THREAD_* constants.
*****************************************************************************/
-vout_thread_t * vout_CreateThread ( int *pi_status, int i_width, int i_height )
+vout_thread_t * __vout_CreateThread ( vlc_object_t *p_parent,
+ int i_width, int i_height,
+ vlc_fourcc_t i_chroma, int i_aspect )
{
vout_thread_t * p_vout; /* thread descriptor */
- int i_status; /* thread status */
- int i_index; /* index for array initialization */
+ int i_index; /* loop variable */
+ char * psz_plugin;
/* Allocate descriptor */
- p_vout = (vout_thread_t *) malloc( sizeof(vout_thread_t) );
+ p_vout = vlc_object_create( p_parent, VLC_OBJECT_VOUT );
if( p_vout == NULL )
{
- intf_ErrMsg( "vout error: vout thread creation returned %s",
- strerror(ENOMEM) );
+ msg_Err( p_parent, "out of memory" );
return( NULL );
}
- /* Choose the best module */
- p_vout->p_module = module_Need( MODULE_CAPABILITY_VOUT, NULL );
-
- if( p_vout->p_module == NULL )
+ /* If the parent is not a VOUT object, that means we are at the start of
+ * the video output pipe */
+ if( p_parent->i_object_type != VLC_OBJECT_VOUT )
{
- intf_ErrMsg( "vout error: no suitable vout module" );
- free( p_vout );
- return( NULL );
+ /* look for the default filter configuration */
+ p_vout->psz_filter_chain = config_GetPsz( p_parent, "filter" );
}
-
-#define f p_vout->p_module->p_functions->vout.functions.vout
- p_vout->pf_create = f.pf_create;
- p_vout->pf_init = f.pf_init;
- p_vout->pf_end = f.pf_end;
- p_vout->pf_destroy = f.pf_destroy;
- p_vout->pf_manage = f.pf_manage;
- p_vout->pf_display = f.pf_display;
- p_vout->pf_setpalette = f.pf_setpalette;
-#undef f
-
- /* Initialize callbacks */
- p_vout->pf_setbuffers = SetBuffers;
-
- if( p_vout->pf_setpalette == NULL )
+ else
{
- p_vout->pf_setpalette = SetPalette;
+ /* continue the parent's filter chain */
+ char *psz_end;
+
+ psz_end = strchr( ((vout_thread_t *)p_parent)->psz_filter_chain, ':' );
+ if( psz_end && *(psz_end+1) )
+ p_vout->psz_filter_chain = strdup( psz_end+1 );
+ else p_vout->psz_filter_chain = NULL;
}
- /* Initialize thread properties - thread id and locks will be initialized
- * later */
- p_vout->b_die = 0;
- p_vout->b_error = 0;
- p_vout->b_active = 0;
- p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
- *p_vout->pi_status = THREAD_CREATE;
-
- /* Initialize some fields used by the system-dependant method - these
- * fields will probably be modified by the method, and are only
- * preferences */
- p_vout->i_changes = 0;
- p_vout->i_width = main_GetIntVariable( VOUT_WIDTH_VAR, 0 );
- if( !p_vout->i_width )
+ /* Choose the video output module */
+ if( !p_vout->psz_filter_chain )
{
- p_vout->i_width = i_width ? i_width : VOUT_WIDTH_DEFAULT;
+ psz_plugin = config_GetPsz( p_parent, "vout" );
}
- p_vout->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR, 0 );
- if( !p_vout->i_height )
+ else
{
- p_vout->i_height = i_height ? i_height : VOUT_HEIGHT_DEFAULT;
+ /* the filter chain is a string list of filters separated by double
+ * colons */
+ char *psz_end;
+
+ psz_end = strchr( p_vout->psz_filter_chain, ':' );
+ if( psz_end )
+ psz_plugin = strndup( p_vout->psz_filter_chain,
+ psz_end - p_vout->psz_filter_chain );
+ else psz_plugin = strdup( p_vout->psz_filter_chain );
}
- p_vout->i_bytes_per_line = p_vout->i_width * 2;
- p_vout->i_screen_depth = main_GetIntVariable( VOUT_DEPTH_VAR,
- VOUT_DEPTH_DEFAULT );
- p_vout->i_bytes_per_pixel = 2;
- p_vout->f_gamma = VOUT_GAMMA_DEFAULT; // FIXME: replace with
- // variable
- p_vout->b_need_render = 1;
- p_vout->b_YCbr = 0;
-
- p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
- VOUT_GRAYSCALE_DEFAULT );
- p_vout->b_info = 0;
- p_vout->b_interface = 0;
- p_vout->b_scale = 1;
- p_vout->b_fullscreen = main_GetIntVariable( VOUT_FULLSCREEN_VAR,
- VOUT_FULLSCREEN_DEFAULT );
-
- intf_WarnMsg( 3, "vout info: asking for %dx%d, %d/%d bpp (%d Bpl)",
- p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
- p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
-
- /* Initialize idle screen */
- p_vout->last_display_date = 0;
- p_vout->last_idle_date = 0;
- p_vout->init_display_date = mdate();
- p_vout->render_time = 10000;
-
- /* Initialize statistics fields */
- p_vout->c_fps_samples = 0;
- p_vout->c_pictures = 0;
- p_vout->c_late_pictures = 0;
- p_vout->c_jitter_samples = 0;
- p_vout->display_jitter = 0;
- p_vout->c_loops = 0;
-
- /* Initialize buffer index */
- p_vout->i_buffer_index = 0;
-
- /* Initialize fonts */
- p_vout->p_default_font = NULL;
- p_vout->p_large_font = NULL;
/* Initialize pictures and subpictures - translation tables and functions
* will be initialized later in InitThread */
- for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
+ for( i_index = 0; i_index < 2 * VOUT_MAX_PICTURES; i_index++)
{
- p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
p_vout->p_picture[i_index].i_status = FREE_PICTURE;
+ p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
}
for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
{
- p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
p_vout->p_subpicture[i_index].i_status = FREE_SUBPICTURE;
+ p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
}
- p_vout->i_pictures = 0;
+ /* No images in the heap */
+ p_vout->i_heap_size = 0;
- /* Create thread and set locks */
- vlc_mutex_init( &p_vout->picture_lock );
- vlc_mutex_init( &p_vout->subpicture_lock );
- vlc_mutex_init( &p_vout->change_lock );
+ /* Initialize the rendering heap */
+ I_RENDERPICTURES = 0;
+ p_vout->render.i_width = i_width;
+ p_vout->render.i_height = i_height;
+ p_vout->render.i_chroma = i_chroma;
+ p_vout->render.i_aspect = i_aspect;
+
+ p_vout->render.i_rmask = 0;
+ p_vout->render.i_gmask = 0;
+ p_vout->render.i_bmask = 0;
+
+ /* Zero the output heap */
+ I_OUTPUTPICTURES = 0;
+ p_vout->output.i_width = 0;
+ p_vout->output.i_height = 0;
+ p_vout->output.i_chroma = 0;
+ p_vout->output.i_aspect = 0;
+
+ p_vout->output.i_rmask = 0;
+ p_vout->output.i_gmask = 0;
+ p_vout->output.i_bmask = 0;
- if( vlc_thread_create( &p_vout->thread_id, "video output",
- (void *) RunThread, (void *) p_vout) )
+ /* Initialize misc stuff */
+ p_vout->i_changes = 0;
+ p_vout->f_gamma = 0;
+ p_vout->b_grayscale = 0;
+ p_vout->b_info = 0;
+ p_vout->b_interface = 0;
+ p_vout->b_scale = 1;
+ p_vout->b_fullscreen = 0;
+ p_vout->render_time = 10;
+ p_vout->c_fps_samples= 0;
+
+ p_vout->i_mouse_x = 0;
+ p_vout->i_mouse_y = 0;
+ p_vout->i_mouse_button = 0;
+
+ /* user requested fullscreen? */
+ if( config_GetInt( p_vout, "fullscreen" ) )
+ {
+ p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
+ }
+
+ /* Initialize the dimensions of the video window */
+ InitWindowSize( p_vout, &p_vout->i_window_width,
+ &p_vout->i_window_height );
+
+
+ p_vout->p_module = module_Need( p_vout,
+ ( p_vout->psz_filter_chain ) ?
+ "video filter" : "video output",
+ psz_plugin );
+
+ if( psz_plugin ) free( psz_plugin );
+ if( p_vout->p_module == NULL )
{
- intf_ErrMsg("vout error: %s", strerror(ENOMEM));
- module_Unneed( p_vout->p_module );
- free( p_vout );
+ msg_Err( p_vout, "no suitable vout module" );
+ vlc_object_destroy( p_vout );
return( NULL );
}
- /* If status is NULL, wait until the thread is created */
- if( pi_status == NULL )
+ /* Create thread and set locks */
+ vlc_mutex_init( p_vout, &p_vout->picture_lock );
+ vlc_mutex_init( p_vout, &p_vout->subpicture_lock );
+ vlc_mutex_init( p_vout, &p_vout->change_lock );
+
+ vlc_object_attach( p_vout, p_parent );
+
+ if( vlc_thread_create( p_vout, "video output", RunThread,
+ VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
{
- do
- {
- msleep( THREAD_SLEEP );
- }while( (i_status != THREAD_READY) && (i_status != THREAD_ERROR)
- && (i_status != THREAD_FATAL) );
- if( i_status != THREAD_READY )
- {
- return( NULL );
- }
+ msg_Err( p_vout, "%s", strerror(ENOMEM) );
+ module_Unneed( p_vout, p_vout->p_module );
+ vlc_object_destroy( p_vout );
+ return NULL;
}
- return( p_vout );
+
+ return p_vout;
}
/*****************************************************************************
* is NULL, it will return once the thread is destroyed. Else, it will be
* update using one of the THREAD_* constants.
*****************************************************************************/
-void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
+void vout_DestroyThread( vout_thread_t *p_vout )
{
- int i_status; /* thread status */
-
- /* Set status */
- intf_DbgMsg("");
- p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
- *p_vout->pi_status = THREAD_DESTROY;
-
/* Request thread destruction */
p_vout->b_die = 1;
+ vlc_thread_join( p_vout );
- /* If status is NULL, wait until thread has been destroyed */
- if( pi_status == NULL )
- {
- do
- {
- msleep( THREAD_SLEEP );
- } while( (i_status != THREAD_OVER) && (i_status != THREAD_ERROR)
- && (i_status != THREAD_FATAL) );
- }
-}
-
-/*****************************************************************************
- * vout_DisplaySubPicture: display a subpicture unit
- *****************************************************************************
- * Remove the reservation flag of a subpicture, which will cause it to be ready
- * for display. The picture does not need to be locked, since it is ignored by
- * the output thread if is reserved.
- *****************************************************************************/
-void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
-{
-#ifdef TRACE_VOUT
- char psz_start[ MSTRTIME_MAX_SIZE ]; /* buffer for date string */
- char psz_stop[ MSTRTIME_MAX_SIZE ]; /* buffer for date string */
-#endif
-
-#ifdef DEBUG
- /* Check if status is valid */
- if( p_subpic->i_status != RESERVED_SUBPICTURE )
- {
- intf_ErrMsg("error: subpicture %p has invalid status %d", p_subpic,
- p_subpic->i_status );
- }
-#endif
-
- /* Remove reservation flag */
- p_subpic->i_status = READY_SUBPICTURE;
-
-#ifdef TRACE_VOUT
- /* Send subpicture information */
- intf_DbgMsg("subpicture %p: type=%d, begin date=%s, end date=%s",
- p_subpic, p_subpic->i_type,
- mstrtime( psz_start, p_subpic->i_start ),
- mstrtime( psz_stop, p_subpic->i_stop ) );
-#endif
+ /* Free structure */
+ vlc_object_destroy( p_vout );
}
/*****************************************************************************
- * vout_CreateSubPicture: allocate a subpicture in the video output heap.
+ * InitThread: initialize video output thread
*****************************************************************************
- * This function create a reserved subpicture in the video output heap.
- * A null pointer is returned if the function fails. This method provides an
- * already allocated zone of memory in the spu data fields. It needs locking
- * since several pictures can be created by several producers threads.
+ * This function is called from RunThread and performs the second step of the
+ * initialization. It returns 0 on success. Note that the thread's flag are not
+ * modified inside this function.
*****************************************************************************/
-subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
- int i_size )
+static int InitThread( vout_thread_t *p_vout )
{
- int i_subpic; /* subpicture index */
- subpicture_t * p_free_subpic = NULL; /* first free subpicture */
- subpicture_t * p_destroyed_subpic = NULL; /* first destroyed subpic */
+ int i, i_pgcd;
- /* Get lock */
- vlc_mutex_lock( &p_vout->subpicture_lock );
+ vlc_mutex_lock( &p_vout->change_lock );
- /*
- * Look for an empty place
- */
- for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
- {
- if( p_vout->p_subpicture[i_subpic].i_status == DESTROYED_SUBPICTURE )
- {
- /* Subpicture is marked for destruction, but is still allocated */
- if( (p_vout->p_subpicture[i_subpic].i_type == i_type) &&
- (p_vout->p_subpicture[i_subpic].i_size >= i_size) )
- {
- /* Memory size do match or is smaller : memory will not be
- * reallocated, and function can end immediately - this is
- * the best possible case, since no memory allocation needs
- * to be done */
- p_vout->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
-#ifdef TRACE_VOUT
- intf_DbgMsg("subpicture %p (in destroyed subpicture slot)",
- &p_vout->p_subpicture[i_subpic] );
+#ifdef STATS
+ p_vout->c_loops = 0;
#endif
- vlc_mutex_unlock( &p_vout->subpicture_lock );
- return( &p_vout->p_subpicture[i_subpic] );
- }
- else if( p_destroyed_subpic == NULL )
- {
- /* Memory size do not match, but subpicture index will be kept
- * in case we find no other place */
- p_destroyed_subpic = &p_vout->p_subpicture[i_subpic];
- }
- }
- else if( (p_free_subpic == NULL) &&
- (p_vout->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE ))
- {
- /* Subpicture is empty and ready for allocation */
- p_free_subpic = &p_vout->p_subpicture[i_subpic];
- }
- }
- /* If no free subpictures are available, use a destroyed subpicture */
- if( (p_free_subpic == NULL) && (p_destroyed_subpic != NULL ) )
+ /* Initialize output method, it allocates direct buffers for us */
+ if( p_vout->pf_init( p_vout ) )
{
- /* No free subpicture or matching destroyed subpictures have been
- * found, but a destroyed subpicture is still avalaible */
- free( p_destroyed_subpic->p_data );
- p_free_subpic = p_destroyed_subpic;
+ vlc_mutex_unlock( &p_vout->change_lock );
+ return( 1 );
}
- /*
- * Prepare subpicture
- */
- if( p_free_subpic != NULL )
+ if( !I_OUTPUTPICTURES )
{
- /* Allocate memory */
- switch( i_type )
- {
- case TEXT_SUBPICTURE: /* text subpicture */
- p_free_subpic->p_data = memalign( 16, i_size + 1 );
- break;
- case DVD_SUBPICTURE: /* DVD subpicture unit */
- p_free_subpic->p_data = memalign( 16, i_size );
- break;
-#ifdef DEBUG
- default:
- intf_ErrMsg("error: unknown subpicture type %d", i_type );
- p_free_subpic->p_data = NULL;
- break;
-#endif
- }
-
- if( p_free_subpic->p_data != NULL )
- {
- /* Copy subpicture information, set some default values */
- p_free_subpic->i_type = i_type;
- p_free_subpic->i_status = RESERVED_SUBPICTURE;
- p_free_subpic->i_size = i_size;
- p_free_subpic->i_x = 0;
- p_free_subpic->i_y = 0;
- p_free_subpic->i_width = 0;
- p_free_subpic->i_height = 0;
- p_free_subpic->i_horizontal_align = CENTER_RALIGN;
- p_free_subpic->i_vertical_align = CENTER_RALIGN;
- }
- else
- {
- /* Memory allocation failed : set subpicture as empty */
- p_free_subpic->i_type = EMPTY_SUBPICTURE;
- p_free_subpic->i_status = FREE_SUBPICTURE;
- p_free_subpic = NULL;
- intf_ErrMsg( "vout error: spu allocation returned %s",
- strerror( ENOMEM ) );
- }
-
-#ifdef TRACE_VOUT
- intf_DbgMsg("subpicture %p (in free subpicture slot)", p_free_subpic );
-#endif
- vlc_mutex_unlock( &p_vout->subpicture_lock );
- return( p_free_subpic );
+ msg_Err( p_vout, "plugin was unable to allocate at least "
+ "one direct buffer" );
+ p_vout->pf_end( p_vout );
+ vlc_mutex_unlock( &p_vout->change_lock );
+ return( 1 );
}
- /* No free or destroyed subpicture could be found */
- intf_DbgMsg( "warning: subpicture heap is full" );
- vlc_mutex_unlock( &p_vout->subpicture_lock );
- return( NULL );
-}
+ msg_Dbg( p_vout, "got %i direct buffer(s)", I_OUTPUTPICTURES );
-/*****************************************************************************
- * vout_DestroySubPicture: remove a subpicture from the heap
- *****************************************************************************
- * This function frees a previously reserved subpicture.
- * It is meant to be used when the construction of a picture aborted.
- * This function does not need locking since reserved subpictures are ignored
- * by the output thread.
- *****************************************************************************/
-void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
-{
-#ifdef DEBUG
- /* Check if status is valid */
- if( p_subpic->i_status != RESERVED_SUBPICTURE )
- {
- intf_ErrMsg("error: subpicture %p has invalid status %d",
- p_subpic, p_subpic->i_status );
- }
-#endif
-
- p_subpic->i_status = DESTROYED_SUBPICTURE;
+ i_pgcd = ReduceHeight( p_vout->render.i_aspect );
+ 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 );
-#ifdef TRACE_VOUT
- intf_DbgMsg("subpicture %p", p_subpic);
-#endif
-}
+ i_pgcd = ReduceHeight( p_vout->output.i_aspect );
+ 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 );
-/*****************************************************************************
- * vout_DisplayPicture: display a picture
- *****************************************************************************
- * Remove the reservation flag of a picture, which will cause it to be ready for
- * display. The picture won't be displayed until vout_DatePicture has been
- * called.
- *****************************************************************************/
-void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
-{
- vlc_mutex_lock( &p_vout->picture_lock );
- switch( p_pic->i_status )
- {
- case RESERVED_PICTURE:
- p_pic->i_status = RESERVED_DISP_PICTURE;
- break;
- case RESERVED_DATED_PICTURE:
- p_pic->i_status = READY_PICTURE;
- break;
-#ifdef DEBUG
- default:
- intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
- break;
-#endif
- }
-
-#ifdef TRACE_VOUT
- intf_DbgMsg("picture %p", p_pic);
-#endif
- vlc_mutex_unlock( &p_vout->picture_lock );
-}
-
-/*****************************************************************************
- * vout_DatePicture: date a picture
- *****************************************************************************
- * Remove the reservation flag of a picture, which will cause it to be ready for
- * display. The picture won't be displayed until vout_DisplayPicture has been
- * called.
- *****************************************************************************/
-void vout_DatePicture( vout_thread_t *p_vout, picture_t *p_pic, mtime_t date )
-{
-#ifdef TRACE_VOUT
- char psz_date[MSTRTIME_MAX_SIZE]; /* date */
-#endif
+ /* Calculate shifts from system-updated masks */
+ MaskToShift( &p_vout->output.i_lrshift, &p_vout->output.i_rrshift,
+ p_vout->output.i_rmask );
+ MaskToShift( &p_vout->output.i_lgshift, &p_vout->output.i_rgshift,
+ p_vout->output.i_gmask );
+ MaskToShift( &p_vout->output.i_lbshift, &p_vout->output.i_rbshift,
+ p_vout->output.i_bmask );
- vlc_mutex_lock( &p_vout->picture_lock );
- p_pic->date = date;
- switch( p_pic->i_status )
+ /* Check whether we managed to create direct buffers similar to
+ * the render buffers, ie same size, chroma and aspect ratio */
+ if( ( p_vout->output.i_width == p_vout->render.i_width )
+ && ( p_vout->output.i_height == p_vout->render.i_height )
+ && ( vout_ChromaCmp( p_vout->output.i_chroma, p_vout->render.i_chroma ) )
+ && ( p_vout->output.i_aspect == p_vout->render.i_aspect ) )
{
- case RESERVED_PICTURE:
- p_pic->i_status = RESERVED_DATED_PICTURE;
- break;
- case RESERVED_DISP_PICTURE:
- p_pic->i_status = READY_PICTURE;
- break;
-#ifdef DEBUG
- default:
- intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
- break;
-#endif
- }
-
-#ifdef TRACE_VOUT
- intf_DbgMsg("picture %p, display date: %s", p_pic, mstrtime( psz_date, p_pic->date) );
-#endif
- vlc_mutex_unlock( &p_vout->picture_lock );
-}
+ /* Cool ! We have direct buffers, we can ask the decoder to
+ * directly decode into them ! Map the first render buffers to
+ * the first direct buffers, but keep the first direct buffer
+ * for memcpy operations */
+ p_vout->b_direct = 1;
-/*****************************************************************************
- * vout_CreatePicture: allocate a picture in the video output heap.
- *****************************************************************************
- * This function create a reserved image in the video output heap.
- * A null pointer is returned if the function fails. This method provides an
- * already allocated zone of memory in the picture data fields. It needs locking
- * since several pictures can be created by several producers threads.
- *****************************************************************************/
-picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
- int i_width, int i_height )
-{
- int i_picture; /* picture index */
- int i_chroma_width = 0; /* chroma width */
- picture_t * p_free_picture = NULL; /* first free picture */
- picture_t * p_destroyed_picture = NULL; /* first destroyed picture */
-
- /* Get lock */
- vlc_mutex_lock( &p_vout->picture_lock );
+ msg_Dbg( p_vout, "direct render, mapping "
+ "render pictures 0-%i to system pictures 1-%i",
+ VOUT_MAX_PICTURES - 2, VOUT_MAX_PICTURES - 1 );
- /*
- * Look for an empty place
- */
- for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
- {
- if( p_vout->p_picture[i_picture].i_status == DESTROYED_PICTURE )
- {
- /* Picture is marked for destruction, but is still allocated - note
- * that if width and type are the same for two pictures, chroma_width
- * should also be the same */
- if( (p_vout->p_picture[i_picture].i_type == i_type) &&
- (p_vout->p_picture[i_picture].i_height == i_height) &&
- (p_vout->p_picture[i_picture].i_width == i_width) )
- {
- /* Memory size do match : memory will not be reallocated, and function
- * can end immediately - this is the best possible case, since no
- * memory allocation needs to be done */
- p_vout->p_picture[i_picture].i_status = RESERVED_PICTURE;
- p_vout->i_pictures++;
-#ifdef TRACE_VOUT
- intf_DbgMsg("picture %p (in destroyed picture slot)",
- &p_vout->p_picture[i_picture] );
-#endif
- vlc_mutex_unlock( &p_vout->picture_lock );
- return( &p_vout->p_picture[i_picture] );
- }
- else if( p_destroyed_picture == NULL )
- {
- /* Memory size do not match, but picture index will be kept in
- * case no other place are left */
- p_destroyed_picture = &p_vout->p_picture[i_picture];
- }
- }
- else if( (p_free_picture == NULL) &&
- (p_vout->p_picture[i_picture].i_status == FREE_PICTURE ))
+ for( i = 1; i < VOUT_MAX_PICTURES; i++ )
{
- /* Picture is empty and ready for allocation */
- p_free_picture = &p_vout->p_picture[i_picture];
+ PP_RENDERPICTURE[ I_RENDERPICTURES ] = &p_vout->p_picture[ i ];
+ I_RENDERPICTURES++;
}
}
-
- /* If no free picture is available, use a destroyed picture */
- if( (p_free_picture == NULL) && (p_destroyed_picture != NULL ) )
+ else
{
- /* No free picture or matching destroyed picture has been found, but
- * a destroyed picture is still avalaible */
- free( p_destroyed_picture->p_data );
- p_free_picture = p_destroyed_picture;
- }
+ /* Rats... Something is wrong here, we could not find an output
+ * plugin able to directly render what we decode. See if we can
+ * find a chroma plugin to do the conversion */
+ p_vout->b_direct = 0;
- /*
- * Prepare picture
- */
- if( p_free_picture != NULL )
- {
- /* Allocate memory */
- switch( i_type )
+ /* Choose the best module */
+ p_vout->chroma.p_module = module_Need( p_vout, "chroma", NULL );
+
+ if( p_vout->chroma.p_module == NULL )
{
- case YUV_420_PICTURE: /* YUV 420: 1,1/4,1/4 samples per pixel */
- i_chroma_width = i_width / 2;
- p_free_picture->p_data = memalign( 16, i_height * i_chroma_width
- * 3 * sizeof( yuv_data_t ) );
- p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
- p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*4/2;
- p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*5/2;
- break;
- case YUV_422_PICTURE: /* YUV 422: 1,1/2,1/2 samples per pixel */
- i_chroma_width = i_width / 2;
- p_free_picture->p_data = memalign( 16, i_height * i_chroma_width
- * 4 * sizeof( yuv_data_t ) );
- p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
- p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
- p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*3;
- break;
- case YUV_444_PICTURE: /* YUV 444: 1,1,1 samples per pixel */
- i_chroma_width = i_width;
- p_free_picture->p_data = memalign( 16, i_height * i_chroma_width
- * 3 * sizeof( yuv_data_t ) );
- p_free_picture->p_y = (yuv_data_t *)p_free_picture->p_data;
- p_free_picture->p_u = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width;
- p_free_picture->p_v = (yuv_data_t *)p_free_picture->p_data +i_height*i_chroma_width*2;
- break;
-#ifdef DEBUG
- default:
- intf_ErrMsg("error: unknown picture type %d", i_type );
- p_free_picture->p_data = NULL;
- break;
-#endif
+ msg_Err( p_vout, "no chroma module for %4.4s to %4.4s",
+ &p_vout->render.i_chroma, &p_vout->output.i_chroma );
+ p_vout->pf_end( p_vout );
+ vlc_mutex_unlock( &p_vout->change_lock );
+ return( 1 );
}
- if( p_free_picture->p_data != NULL )
+ if( I_OUTPUTPICTURES < 2 * VOUT_MAX_PICTURES )
{
- /* Copy picture information, set some default values */
- p_free_picture->i_type = i_type;
- p_free_picture->i_status = RESERVED_PICTURE;
- p_free_picture->i_matrix_coefficients = 1;
- p_free_picture->i_width = i_width;
- p_free_picture->i_height = i_height;
- p_free_picture->i_chroma_width = i_chroma_width;
- p_free_picture->i_size = i_width * i_height;
- p_free_picture->i_chroma_size = i_chroma_width
- * i_height;
- p_free_picture->i_display_horizontal_offset = 0;
- p_free_picture->i_display_vertical_offset = 0;
- p_free_picture->i_display_width = i_width;
- p_free_picture->i_display_height = i_height;
- p_free_picture->i_aspect_ratio = AR_SQUARE_PICTURE;
- p_free_picture->i_refcount = 0;
- p_vout->i_pictures++;
+ msg_Dbg( p_vout, "indirect render, mapping "
+ "render pictures %i-%i to system pictures %i-%i",
+ I_OUTPUTPICTURES - 1, 2 * VOUT_MAX_PICTURES - 2,
+ I_OUTPUTPICTURES, 2 * VOUT_MAX_PICTURES - 1 );
}
else
{
- /* Memory allocation failed : set picture as empty */
- p_free_picture->i_type = EMPTY_PICTURE;
- p_free_picture->i_status = FREE_PICTURE;
- p_free_picture = NULL;
- intf_ErrMsg( "vout error: picture allocation returned %s",
- strerror( ENOMEM ) );
+ /* FIXME: if this happens, we don't have any render pictures left */
+ msg_Dbg( p_vout, "indirect render, no system pictures needed,"
+ " we have %i directbuffers", I_OUTPUTPICTURES );
+ msg_Err( p_vout, "this is a bug!" );
}
-#ifdef TRACE_VOUT
- intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
-#endif
- vlc_mutex_unlock( &p_vout->picture_lock );
-
- return( p_free_picture );
- }
-
- /* No free or destroyed picture could be found */
- intf_DbgMsg( "warning: picture heap is full" );
- vlc_mutex_unlock( &p_vout->picture_lock );
- return( NULL );
-}
-
-/*****************************************************************************
- * vout_DestroyPicture: remove a permanent or reserved picture from the heap
- *****************************************************************************
- * This function frees a previously reserved picture or a permanent
- * picture. It is meant to be used when the construction of a picture aborted.
- * Note that the picture will be destroyed even if it is linked !
- *****************************************************************************/
-void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
-{
- vlc_mutex_lock( &p_vout->picture_lock );
-
-#ifdef DEBUG
- /* Check if picture status is valid */
- if( (p_pic->i_status != RESERVED_PICTURE) &&
- (p_pic->i_status != RESERVED_DATED_PICTURE) &&
- (p_pic->i_status != RESERVED_DISP_PICTURE) )
- {
- intf_ErrMsg("error: picture %p has invalid status %d", p_pic, p_pic->i_status );
- }
-#endif
-
- p_pic->i_status = DESTROYED_PICTURE;
- p_vout->i_pictures--;
-
-#ifdef TRACE_VOUT
- intf_DbgMsg("picture %p", p_pic);
-#endif
-
- vlc_mutex_unlock( &p_vout->picture_lock );
-}
-
-/*****************************************************************************
- * vout_LinkPicture: increment reference counter of a picture
- *****************************************************************************
- * This function increment the reference counter of a picture in the video
- * heap. It needs a lock since several producer threads can access the picture.
- *****************************************************************************/
-void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
-{
- vlc_mutex_lock( &p_vout->picture_lock );
- p_pic->i_refcount++;
-
-#ifdef TRACE_VOUT
- intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
-#endif
-
- vlc_mutex_unlock( &p_vout->picture_lock );
-}
-
-/*****************************************************************************
- * vout_UnlinkPicture: decrement reference counter of a picture
- *****************************************************************************
- * This function decrement the reference counter of a picture in the video heap.
- *****************************************************************************/
-void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
-{
- vlc_mutex_lock( &p_vout->picture_lock );
- p_pic->i_refcount--;
-
-#ifdef TRACE_VOUT
- if( p_pic->i_refcount < 0 )
- {
- intf_DbgMsg("error: refcount < 0");
- p_pic->i_refcount = 0;
- }
-#endif
-
- if( (p_pic->i_refcount == 0) && (p_pic->i_status == DISPLAYED_PICTURE) )
- {
- p_pic->i_status = DESTROYED_PICTURE;
- p_vout->i_pictures--;
- }
-
-#ifdef TRACE_VOUT
- intf_DbgMsg("picture %p refcount=%d", p_pic, p_pic->i_refcount );
-#endif
-
- vlc_mutex_unlock( &p_vout->picture_lock );
-}
-
-/*****************************************************************************
- * vout_Pixel2RGB: return red, green and blue from pixel value
- *****************************************************************************
- * Return color values, in 0-255 range, of the decomposition of a pixel. This
- * is a slow routine and should only be used for initialization phase.
- *****************************************************************************/
-void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
-{
- *pi_red = i_pixel & p_vout->i_red_mask;
- *pi_green = i_pixel & p_vout->i_green_mask;
- *pi_blue = i_pixel & p_vout->i_blue_mask;
-}
-
-/* following functions are local */
-
-/*****************************************************************************
- * BinaryLog: computes the base 2 log of a binary value
- *****************************************************************************
- * This functions is used by MaskToShift, to get a bit index from a binary
- * value.
- *****************************************************************************/
-static int BinaryLog(u32 i)
-{
- int i_log = 0;
-
- if(i & 0xffff0000)
- {
- i_log += 16;
- }
- if(i & 0xff00ff00)
- {
- i_log += 8;
- }
- if(i & 0xf0f0f0f0)
- {
- i_log += 4;
- }
- if(i & 0xcccccccc)
- {
- i_log += 2;
- }
- if(i & 0xaaaaaaaa)
- {
- i_log += 1;
- }
-
- if (i != ((u32)1 << i_log))
- {
- intf_DbgMsg("internal error: binary log overflow");
- }
-
- return( i_log );
-}
-
-/*****************************************************************************
- * MaskToShift: transform a color mask into right and left shifts
- *****************************************************************************
- * This function is used for obtaining color shifts from masks.
- *****************************************************************************/
-static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
-{
- u32 i_low, i_high; /* lower hand higher bits of the mask */
-
- /* Get bits */
- i_low = i_mask & (- i_mask); /* lower bit of the mask */
- i_high = i_mask + i_low; /* higher bit of the mask */
-
- /* Transform bits into an index */
- i_low = BinaryLog (i_low);
- i_high = BinaryLog (i_high);
-
- /* Update pointers and return */
- *pi_left = i_low;
- *pi_right = (8 - i_high + i_low);
-}
-
-/*****************************************************************************
- * InitThread: initialize video output thread
- *****************************************************************************
- * This function is called from RunThread and performs the second step of the
- * initialization. It returns 0 on success. Note that the thread's flag are not
- * modified inside this function.
- *****************************************************************************/
-static int InitThread( vout_thread_t *p_vout )
-{
- /* Update status */
- *p_vout->pi_status = THREAD_START;
-
- vlc_mutex_lock( &p_vout->change_lock );
-
- /* Create and initialize system-dependant method - this function issues its
- * own error messages */
- if( p_vout->pf_create( p_vout ) )
- {
- /* If pf_create has failed then we have to make sure
- * pf_destroy won't be called, because the plugin should have
- * cleaned up all its mess */
- p_vout->pf_destroy = NULL;
- return( 1 );
- }
-
- intf_WarnMsg( 1, "vout: video display initialized (%dx%d, %d/%d bpp)",
- p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
- p_vout->i_bytes_per_pixel * 8 );
-
- intf_WarnMsg( 3, "vout info: got %dx%d, %d/%d bpp (%d Bpl), "
- "masks: 0x%x/0x%x/0x%x",
- p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
- p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
- p_vout->i_red_mask, p_vout->i_green_mask,
- p_vout->i_blue_mask );
-
- /* Calculate shifts from system-updated masks */
- MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
- p_vout->i_red_mask );
- MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
- p_vout->i_green_mask );
- MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
- p_vout->i_blue_mask );
-
- /* Set some useful colors */
- p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
- p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
- p_vout->i_gray_pixel = RGB2PIXEL( p_vout, 128, 128, 128 );
- p_vout->i_blue_pixel = RGB2PIXEL( p_vout, 0, 0, 50 );
-
- /* Load fonts - fonts must be initialized after the system method since
- * they may be dependant on screen depth and other thread properties */
- p_vout->p_default_font = vout_LoadFont( VOUT_DEFAULT_FONT );
- if( p_vout->p_default_font == NULL )
- {
- intf_ErrMsg( "vout error: could not load default font" );
- }
-
- p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
- if( p_vout->p_large_font == NULL )
- {
- intf_ErrMsg( "vout error: could not load large font" );
+ /* Append render buffers after the direct buffers */
+ for( i = I_OUTPUTPICTURES; i < 2 * VOUT_MAX_PICTURES; i++ )
+ {
+ PP_RENDERPICTURE[ I_RENDERPICTURES ] = &p_vout->p_picture[ i ];
+ I_RENDERPICTURES++;
+ }
}
- /* Initialize output method. This function issues its own error messages */
- if( p_vout->pf_init( p_vout ) )
+ /* Link pictures back to their heap */
+ for( i = 0 ; i < I_RENDERPICTURES ; i++ )
{
- /* If pf_init has failed then we have to make sure
- * pf_destroy won't be called, because the plugin should have
- * cleaned up all its mess */
- p_vout->pf_destroy = NULL;
- return( 1 );
+ PP_RENDERPICTURE[ i ]->p_heap = &p_vout->render;
}
- /* Initialize convertion tables and functions */
- if( vout_InitYUV( p_vout ) )
+ for( i = 0 ; i < I_OUTPUTPICTURES ; i++ )
{
- intf_ErrMsg("vout error: can't allocate YUV translation tables");
- p_vout->pf_destroy( p_vout );
- /* Make sure pf_destroy won't be called again */
- p_vout->pf_destroy = NULL;
- return( 1 );
+ PP_OUTPUTPICTURE[ i ]->p_heap = &p_vout->output;
}
- /* Mark thread as running and return */
- p_vout->b_active = 1;
- *p_vout->pi_status = THREAD_READY;
-
-
- intf_DbgMsg("thread ready");
+/* XXX XXX mark thread ready */
return( 0 );
}
static void RunThread( vout_thread_t *p_vout)
{
int i_index; /* index in heap */
+ int i_idle_loops = 0; /* loops without displaying a picture */
mtime_t current_date; /* current date */
mtime_t display_date; /* display date */
- boolean_t b_display; /* display flag */
- picture_t * p_pic; /* picture pointer */
+ picture_t * p_picture; /* picture pointer */
+ picture_t * p_last_picture = NULL; /* last picture */
+ picture_t * p_directbuffer; /* direct buffer to display */
subpicture_t * p_subpic; /* subpicture pointer */
- subpicture_t * p_ephemer; /* youngest ephemer subpicture pointer */
- mtime_t ephemer_date; /* earliest subpicture date */
/*
* Initialize thread
*/
- if( InitThread( p_vout ) )
+ p_vout->b_error = InitThread( p_vout );
+ if( p_vout->b_error )
{
- /* Something bad happened */
- DestroyThread( p_vout, THREAD_ERROR );
+ /* Destroy thread structures allocated by Create and InitThread */
+ DestroyThread( p_vout );
return;
}
+
/*
* Main loop - it is not executed if an error occured during
* initialization
while( (!p_vout->b_die) && (!p_vout->b_error) )
{
/* Initialize loop variables */
- p_vout->p_rendered_pic = NULL;
- p_pic = NULL;
- p_subpic = NULL;
- p_ephemer = NULL;
- ephemer_date = 0;
- display_date = 0;
- current_date = mdate();
+ display_date = 0;
+ current_date = mdate();
+#ifdef STATS
p_vout->c_loops++;
if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
{
- intf_StatMsg( "vout info: picture heap: %d/%d",
- p_vout->i_pictures, VOUT_MAX_PICTURES );
+ msg_Dbg( p_vout, "picture heap: %d/%d",
+ I_RENDERPICTURES, p_vout->i_heap_size );
}
+#endif
/*
* Find the picture to display - this operation does not need lock,
* since only READY_PICTUREs are handled
*/
- for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
+ p_picture = NULL;
+
+ for( i_index = 0; i_index < I_RENDERPICTURES; i_index++ )
{
- if( (p_vout->p_picture[i_index].i_status == READY_PICTURE) &&
- ( (p_pic == NULL) ||
- (p_vout->p_picture[i_index].date < display_date) ) )
+ if( (PP_RENDERPICTURE[i_index]->i_status == READY_PICTURE)
+ && ( (p_picture == NULL) ||
+ (PP_RENDERPICTURE[i_index]->date < display_date) ) )
{
- p_pic = &p_vout->p_picture[i_index];
- display_date = p_pic->date;
+ p_picture = PP_RENDERPICTURE[i_index];
+ display_date = p_picture->date;
}
}
- if( p_pic )
+ if( p_picture != NULL )
{
- p_vout->c_pictures++;
+ /* If we met the last picture, parse again to see whether there is
+ * a more appropriate one. */
+ if( p_picture == p_last_picture )
+ {
+ for( i_index = 0; i_index < I_RENDERPICTURES; i_index++ )
+ {
+ if( (PP_RENDERPICTURE[i_index]->i_status == READY_PICTURE)
+ && (PP_RENDERPICTURE[i_index] != p_last_picture)
+ && ((p_picture == p_last_picture) ||
+ (PP_RENDERPICTURE[i_index]->date < display_date)) )
+ {
+ p_picture = PP_RENDERPICTURE[i_index];
+ display_date = p_picture->date;
+ }
+ }
+ }
+
+ /* If we found better than the last picture, destroy it */
+ if( p_last_picture && p_picture != p_last_picture )
+ {
+ vlc_mutex_lock( &p_vout->picture_lock );
+ if( p_last_picture->i_refcount )
+ {
+ p_last_picture->i_status = DISPLAYED_PICTURE;
+ }
+ else
+ {
+ p_last_picture->i_status = DESTROYED_PICTURE;
+ p_vout->i_heap_size--;
+ }
+ vlc_mutex_unlock( &p_vout->picture_lock );
+ p_last_picture = NULL;
+ }
- /* Computes FPS rate */
- p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ] = display_date;
+ /* Compute FPS rate */
+ p_vout->p_fps_sample[ p_vout->c_fps_samples++ % VOUT_FPS_SAMPLES ]
+ = display_date;
- if( display_date < current_date + p_vout->render_time )
+ if( !p_picture->b_force &&
+ p_picture != p_last_picture &&
+ display_date < current_date + p_vout->render_time )
{
/* Picture is late: it will be destroyed and the thread
- * will sleep and go to next picture */
-
+ * will directly choose the next picture */
vlc_mutex_lock( &p_vout->picture_lock );
- if( p_pic->i_refcount )
+ if( p_picture->i_refcount )
{
- p_pic->i_status = DISPLAYED_PICTURE;
+ /* Pretend we displayed the picture, but don't destroy
+ * it since the decoder might still need it. */
+ p_picture->i_status = DISPLAYED_PICTURE;
}
else
{
- p_pic->i_status = DESTROYED_PICTURE;
- p_vout->i_pictures--;
+ /* Destroy the picture without displaying it */
+ p_picture->i_status = DESTROYED_PICTURE;
+ p_vout->i_heap_size--;
}
+ msg_Warn( p_vout, "late picture skipped (%lld)",
+ current_date - display_date );
vlc_mutex_unlock( &p_vout->picture_lock );
- intf_WarnMsg( 1,
- "vout warning: late picture skipped (%p)", p_pic );
- p_vout->c_late_pictures++;
+ continue;
+ }
+#if 0
+ /* Removed because it causes problems for some people --Meuuh */
+ if( display_date > current_date + VOUT_BOGUS_DELAY )
+ {
+ /* Picture is waaay too early: it will be destroyed */
+ vlc_mutex_lock( &p_vout->picture_lock );
+ if( p_picture->i_refcount )
+ {
+ /* Pretend we displayed the picture, but don't destroy
+ * it since the decoder might still need it. */
+ p_picture->i_status = DISPLAYED_PICTURE;
+ }
+ else
+ {
+ /* Destroy the picture without displaying it */
+ p_picture->i_status = DESTROYED_PICTURE;
+ p_vout->i_heap_size--;
+ }
+ intf_WarnMsg( 1, "vout warning: early picture skipped (%lld)",
+ display_date - current_date );
+ vlc_mutex_unlock( &p_vout->picture_lock );
continue;
}
- else if( display_date > current_date + VOUT_DISPLAY_DELAY )
+#endif
+ if( display_date > current_date + VOUT_DISPLAY_DELAY )
{
/* A picture is ready to be rendered, but its rendering date
* is far from the current one so the thread will perform an
* empty loop as if no picture were found. The picture state
* is unchanged */
- p_pic = NULL;
- display_date = 0;
+ p_picture = NULL;
+ display_date = 0;
}
- }
-
- /*
- * Find the subpictures to display - this operation does not need
- * lock, since only READY_SUBPICTURE are handled. If no picture
- * has been selected, display_date will depend on the subpicture.
- *
- * We also check for ephemer DVD subpictures (subpictures that have
- * to be removed if a newer one is available), which makes it a lot
- * more difficult to guess if a subpicture has to be rendered or not.
- *
- * We get an easily parsable chained list of subpictures which
- * ends with NULL since p_subpic was initialized to NULL.
- */
- for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
- {
- if( p_vout->p_subpicture[i_index].i_status == READY_SUBPICTURE )
+ else if( p_picture == p_last_picture )
{
- /* If it is a DVD subpicture, check its date */
- if( p_vout->p_subpicture[i_index].i_type == DVD_SUBPICTURE )
+ /* We are asked to repeat the previous picture, but we first
+ * wait for a couple of idle loops */
+ if( i_idle_loops < 4 )
{
- if( display_date > p_vout->p_subpicture[i_index].i_stop )
- {
- /* Too late, destroy the subpic */
- vout_DestroySubPicture( p_vout,
- &p_vout->p_subpicture[i_index] );
- continue;
- }
-
- if( display_date < p_vout->p_subpicture[i_index].i_start )
- {
- /* Too early, come back next monday */
- continue;
- }
-
- /* If this is an ephemer subpic, see if it's the
- * youngest we have */
- if( p_vout->p_subpicture[i_index].b_ephemer )
- {
- if( p_ephemer == NULL )
- {
- p_ephemer = &p_vout->p_subpicture[i_index];
- continue;
- }
-
- if( p_vout->p_subpicture[i_index].i_start
- < p_ephemer->i_start )
- {
- /* Link the previous ephemer subpicture and
- * replace it with the current one */
- p_ephemer->p_next = p_subpic;
- p_subpic = p_ephemer;
- p_ephemer = &p_vout->p_subpicture[i_index];
-
- /* If it's the 2nd youngest subpicture,
- * register its date */
- if( !ephemer_date
- || ephemer_date > p_subpic->i_start )
- {
- ephemer_date = p_subpic->i_start;
- }
-
- continue;
- }
- }
-
- p_vout->p_subpicture[i_index].p_next = p_subpic;
- p_subpic = &p_vout->p_subpicture[i_index];
-
- /* If it's the 2nd youngest subpicture, register its date */
- if( !ephemer_date || ephemer_date > p_subpic->i_start )
- {
- ephemer_date = p_subpic->i_start;
- }
+ p_picture = NULL;
+ display_date = 0;
}
- /* If it's not a DVD subpicture, just register it */
else
{
- p_vout->p_subpicture[i_index].p_next = p_subpic;
- p_subpic = &p_vout->p_subpicture[i_index];
+ /*intf_WarnMsg( 6, "vout info: duplicating picture" );*/
}
}
}
- /* If we found an ephemer subpicture, check if it has to be
- * displayed */
- if( p_ephemer != NULL )
+ if( p_picture == NULL )
{
- if( p_ephemer->i_start < ephemer_date )
- {
- /* Ephemer subpicture has lived too long */
- vout_DestroySubPicture( p_vout, p_ephemer );
- }
- else
- {
- /* Ephemer subpicture can still live a bit */
- p_ephemer->p_next = p_subpic;
- p_subpic = p_ephemer;
- }
+ i_idle_loops++;
}
/*
- * Perform rendering, sleep and display rendered picture
+ * Check for subpictures to display
*/
- if( p_pic ) /* picture and perhaps subpicture */
- {
- b_display = p_vout->b_active;
- p_vout->last_display_date = display_date;
- p_vout->p_rendered_pic = p_pic;
-
- /* FIXME: if b_need_render == 0 we need to do something with
- * the subpictures one day. */
-
- if( p_vout->b_need_render && b_display )
- {
- /* Set picture dimensions and clear buffer */
- SetBufferPicture( p_vout, p_pic );
-
- /* Render picture and information */
- RenderPicture( p_vout, p_pic );
- if( p_vout->b_info )
- {
- RenderPictureInfo( p_vout, p_pic );
- RenderInfo( p_vout );
- }
- }
- if( b_display ) /* XXX: quick HACK */
- {
- if( p_subpic )
- {
- RenderSubPicture( p_vout, p_pic, p_subpic );
- }
- }
- }
- else if( p_vout->b_active && p_vout->b_need_render
- && p_vout->init_display_date == 0)
- {
- /* Idle or interface screen alone */
-
- if( p_vout->b_interface && 0 /* && XXX?? intf_change */ )
- {
- /* Interface has changed, so a new rendering is required - force
- * it by setting last idle date to 0 */
- p_vout->last_idle_date = 0;
- }
-
- /* Render idle screen and update idle date, then render interface if
- * required */
- b_display = RenderIdle( p_vout );
- if( b_display )
- {
- p_vout->last_idle_date = current_date;
- }
-
- }
- else
- {
- b_display = 0;
- }
+ p_subpic = vout_SortSubPictures( p_vout, display_date );
+ /*
+ * Perform rendering
+ */
+ p_directbuffer = vout_RenderPicture( p_vout, p_picture, p_subpic );
/*
- * Check for the current time and
- * display splash screen if everything is on time
+ * Call the plugin-specific rendering method if there is one
*/
- if( p_vout->init_display_date > 0 && p_vout->b_need_render )
+ if( p_picture != NULL && p_vout->pf_render )
{
- p_vout->init_display_date = 0;
+ /* Render the direct buffer returned by vout_RenderPicture */
+ p_vout->pf_render( p_vout, p_directbuffer );
}
-
/*
- * Sleep, wake up and display rendered picture
+ * Sleep, wake up
*/
-
if( display_date != 0 )
{
/* Store render time using Bresenham algorithm */
msleep( VOUT_IDLE_SLEEP );
}
- /* On awakening, take back lock and send immediately picture to display,
- * then swap buffers */
+ /* On awakening, take back lock and send immediately picture
+ * to display. */
vlc_mutex_lock( &p_vout->change_lock );
-#ifdef TRACE_VOUT
- intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d", p_pic, p_subpic,
- p_vout->i_buffer_index, b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ );
-#endif
- if( b_display /* && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) */ )
- {
- mtime_t jitter;
-
- p_vout->pf_display( p_vout );
-#ifndef SYS_BEOS
- p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;
-#endif
-
- /* Update statistics */
- jitter = display_date - mdate();
- if( jitter < 0 ) jitter = -jitter;
- p_vout->display_jitter = ((p_vout->display_jitter
- * p_vout->c_jitter_samples) + jitter)
- / (p_vout->c_jitter_samples + 1);
- if( p_vout->c_jitter_samples < MAX_JITTER_SAMPLES )
- {
- p_vout->c_jitter_samples++;
- }
- }
- if( p_pic )
+ /*
+ * Display the previously rendered picture
+ */
+ if( p_picture != NULL )
{
- /* Remove picture from heap */
- vlc_mutex_lock( &p_vout->picture_lock );
- if( p_pic->i_refcount )
- {
- p_pic->i_status = DISPLAYED_PICTURE;
- }
- else
+ /* Display the direct buffer returned by vout_RenderPicture */
+ if( p_vout->pf_display )
{
- p_pic->i_status = DESTROYED_PICTURE;
- p_vout->i_pictures--;
+ p_vout->pf_display( p_vout, p_directbuffer );
}
- vlc_mutex_unlock( &p_vout->picture_lock );
- }
+ /* Reinitialize idle loop count */
+ i_idle_loops = 0;
+
+ /* Tell the vout this was the last picture and that it does not
+ * need to be forced anymore. */
+ p_last_picture = p_picture;
+ p_last_picture->b_force = 0;
+ }
/*
* Check events and manage thread
*/
- if( p_vout->pf_manage( p_vout ) | Manage( p_vout ) )
+ if( p_vout->pf_manage && p_vout->pf_manage( p_vout ) )
{
- /* A fatal error occured, and the thread must terminate immediately
- * without displaying anything - setting b_error to 1 cause the
- * immediate end of the main while() loop. */
+ /* A fatal error occured, and the thread must terminate
+ * immediately, without displaying anything - setting b_error to 1
+ * causes the immediate end of the main while() loop. */
p_vout->b_error = 1;
}
+
+ if( p_vout->i_changes & VOUT_SIZE_CHANGE )
+ {
+ /* this must only happen when the vout plugin is incapable of
+ * rescaling the picture itself. In this case we need to destroy
+ * the current picture buffers and recreate new ones with the right
+ * dimensions */
+ int i;
+
+ p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
+
+ p_vout->pf_end( p_vout );
+ for( i = 0; i < I_OUTPUTPICTURES; i++ )
+ p_vout->p_picture[ i ].i_status = FREE_PICTURE;
+
+ I_OUTPUTPICTURES = 0;
+ if( p_vout->pf_init( p_vout ) )
+ {
+ msg_Err( p_vout, "cannot resize display" );
+ /* FIXME: pf_end will be called again in EndThread() */
+ p_vout->b_error = 1;
+ }
+
+ /* Need to reinitialise the chroma plugin */
+ p_vout->chroma.p_module->pf_deactivate( VLC_OBJECT(p_vout) );
+ p_vout->chroma.p_module->pf_activate( VLC_OBJECT(p_vout) );
+ }
+
}
/*
/* End of thread */
EndThread( p_vout );
- DestroyThread( p_vout, THREAD_OVER );
- intf_DbgMsg( "thread end" );
+
+ /* Destroy thread structures allocated by CreateThread */
+ DestroyThread( p_vout );
}
/*****************************************************************************
{
int i_index; /* index in heap */
- /* Store status */
- *p_vout->pi_status = THREAD_END;
-
- if( p_main->b_stats )
+#ifdef STATS
{
- #ifndef WIN32
struct tms cpu_usage;
times( &cpu_usage );
- intf_StatMsg( "vout info: %d loops consuming user: %d, system: %d",
- p_vout->c_loops, cpu_usage.tms_utime, cpu_usage.tms_stime );
- intf_StatMsg( "vout info: %d pictures received, discarded %d",
- p_vout->c_pictures, p_vout->c_late_pictures );
- intf_StatMsg( "vout info: average display jitter of %lld µs",
- p_vout->display_jitter );
- #endif
+ msg_Dbg( p_vout, "cpu usage (user: %d, system: %d)",
+ cpu_usage.tms_utime, cpu_usage.tms_stime );
+ }
+#endif
+
+ if( !p_vout->b_direct )
+ {
+ module_Unneed( p_vout, p_vout->chroma.p_module );
}
- /* Destroy all remaining pictures and subpictures */
- for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
+ /* Destroy all remaining pictures */
+ for( i_index = 0; i_index < 2 * VOUT_MAX_PICTURES; i_index++ )
{
- if( p_vout->p_picture[i_index].i_status != FREE_PICTURE )
+ if ( p_vout->p_picture[i_index].i_type == MEMORY_PICTURE )
{
- free( p_vout->p_picture[i_index].p_data );
+ free( p_vout->p_picture[i_index].p_data_orig );
}
}
+ /* Destroy all remaining subpictures */
for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
{
if( p_vout->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
{
- free( p_vout->p_subpicture[i_index].p_data );
+ free( p_vout->p_subpicture[i_index].p_sys );
}
}
/* Destroy translation tables */
- vout_EndYUV( p_vout );
p_vout->pf_end( p_vout );
/* Release the change lock */
* This function is called when the thread ends. It frees all ressources
* allocated by CreateThread. Status is available at this stage.
*****************************************************************************/
-static void DestroyThread( vout_thread_t *p_vout, int i_status )
+static void DestroyThread( vout_thread_t *p_vout )
{
- int *pi_status; /* status adress */
-
- /* Store status adress */
- pi_status = p_vout->pi_status;
-
- /* Destroy thread structures allocated by Create and InitThread */
- vout_UnloadFont( p_vout->p_default_font );
- vout_UnloadFont( p_vout->p_large_font );
- if( p_vout->pf_destroy != NULL ) p_vout->pf_destroy( p_vout );
-
/* Destroy the locks */
vlc_mutex_destroy( &p_vout->picture_lock );
vlc_mutex_destroy( &p_vout->subpicture_lock );
vlc_mutex_destroy( &p_vout->change_lock );
/* Release the module */
- module_Unneed( p_vout->p_module );
-
- /* Free structure */
- free( p_vout );
- *pi_status = i_status;
-}
-
-/*****************************************************************************
- * Print: print simple text on a picture
- *****************************************************************************
- * This function will print a simple text on the picture. It is designed to
- * print debugging or general information.
- *****************************************************************************/
-void Print( vout_thread_t *p_vout, int i_x, int i_y, int i_h_align, int i_v_align, unsigned char *psz_text )
-{
- int i_text_height; /* total text height */
- int i_text_width; /* total text width */
-
- /* Update upper left coordinates according to alignment */
- vout_TextSize( p_vout->p_default_font, 0, psz_text, &i_text_width, &i_text_height );
- if( !Align( p_vout, &i_x, &i_y, i_text_width, i_text_height, i_h_align, i_v_align ) )
- {
- /* Set area and print text */
- SetBufferArea( p_vout, i_x, i_y, i_text_width, i_text_height );
- vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
- i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
- p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
- p_vout->i_white_pixel, 0, 0,
- 0, psz_text, 100 );
- }
+ module_Unneed( p_vout, p_vout->p_module );
}
-/*****************************************************************************
- * SetBuffers: set buffers adresses
- *****************************************************************************
- * This function is called by system drivers to set buffers video memory
- * adresses.
- *****************************************************************************/
-static void SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
-{
- /* No picture previously */
- p_vout->p_buffer[0].i_pic_x = 0;
- p_vout->p_buffer[0].i_pic_y = 0;
- p_vout->p_buffer[0].i_pic_width = 0;
- p_vout->p_buffer[0].i_pic_height = 0;
- p_vout->p_buffer[1].i_pic_x = 0;
- p_vout->p_buffer[1].i_pic_y = 0;
- p_vout->p_buffer[1].i_pic_width = 0;
- p_vout->p_buffer[1].i_pic_height = 0;
-
- /* The first area covers all the screen */
- p_vout->p_buffer[0].i_areas = 1;
- p_vout->p_buffer[0].pi_area_begin[0] = 0;
- p_vout->p_buffer[0].pi_area_end[0] = p_vout->i_height - 1;
- p_vout->p_buffer[1].i_areas = 1;
- p_vout->p_buffer[1].pi_area_begin[0] = 0;
- p_vout->p_buffer[1].pi_area_end[0] = p_vout->i_height - 1;
-
- /* Set adresses */
- p_vout->p_buffer[0].p_data = p_buf1;
- p_vout->p_buffer[1].p_data = p_buf2;
-}
+/* following functions are local */
-/*****************************************************************************
- * SetBufferArea: activate an area in current buffer
- *****************************************************************************
- * This function is called when something is rendered on the current buffer.
- * It set the area as active and prepare it to be cleared on next rendering.
- * Pay attention to the fact that in this functions, i_h is in fact the end y
- * coordinate of the new area.
- *****************************************************************************/
-static void SetBufferArea( vout_thread_t *p_vout, int i_x, int i_y, int i_w, int i_h )
+static int ReduceHeight( int i_ratio )
{
- vout_buffer_t * p_buffer; /* current buffer */
- int i_area_begin, i_area_end; /* area vertical extension */
- int i_area, i_area_copy; /* area index */
- int i_area_shift; /* shift distance for areas */
-
- /* Choose buffer and modify h to end of area position */
- p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
- i_h += i_y - 1;
-
- /*
- * Remove part of the area which is inside the picture - this is done
- * by calling again SetBufferArea with the correct areas dimensions.
- */
- if( (i_x >= p_buffer->i_pic_x) && (i_x + i_w <= p_buffer->i_pic_x + p_buffer->i_pic_width) )
- {
- i_area_begin = p_buffer->i_pic_y;
- i_area_end = i_area_begin + p_buffer->i_pic_height - 1;
-
- if( ((i_y >= i_area_begin) && (i_y <= i_area_end)) ||
- ((i_h >= i_area_begin) && (i_h <= i_area_end)) ||
- ((i_y < i_area_begin) && (i_h > i_area_end)) )
- {
- /* Keep the stripe above the picture, if any */
- if( i_y < i_area_begin )
- {
- SetBufferArea( p_vout, i_x, i_y, i_w, i_area_begin - i_y );
- }
- /* Keep the stripe below the picture, if any */
- if( i_h > i_area_end )
- {
- SetBufferArea( p_vout, i_x, i_area_end, i_w, i_h - i_area_end );
- }
- return;
- }
- }
-
- /* Skip some extensions until interesting areas */
- for( i_area = 0;
- (i_area < p_buffer->i_areas) &&
- (p_buffer->pi_area_end[i_area] + 1 <= i_y);
- i_area++ )
- {
- ;
- }
-
- if( i_area == p_buffer->i_areas )
- {
- /* New area is below all existing ones: just add it at the end of the
- * array, if possible - otherwise, append it to the last one */
- if( i_area < VOUT_MAX_AREAS )
- {
- p_buffer->pi_area_begin[i_area] = i_y;
- p_buffer->pi_area_end[i_area] = i_h;
- p_buffer->i_areas++;
- }
- else
- {
-#ifdef TRACE_VOUT
- intf_DbgMsg("area overflow");
-#endif
- p_buffer->pi_area_end[VOUT_MAX_AREAS - 1] = i_h;
- }
- }
- else
+ int i_dummy = VOUT_ASPECT_FACTOR;
+ int i_pgcd = 1;
+
+ if( !i_ratio )
{
- i_area_begin = p_buffer->pi_area_begin[i_area];
- i_area_end = p_buffer->pi_area_end[i_area];
-
- if( i_y < i_area_begin )
- {
- if( i_h >= i_area_begin - 1 )
- {
- /* Extend area above */
- p_buffer->pi_area_begin[i_area] = i_y;
- }
- else
- {
- /* Create a new area above : merge last area if overflow, then
- * move all old areas down */
- if( p_buffer->i_areas == VOUT_MAX_AREAS )
- {
-#ifdef TRACE_VOUT
- intf_DbgMsg("areas overflow");
-#endif
- p_buffer->pi_area_end[VOUT_MAX_AREAS - 2] = p_buffer->pi_area_end[VOUT_MAX_AREAS - 1];
- }
- else
- {
- p_buffer->i_areas++;
- }
- for( i_area_copy = p_buffer->i_areas - 1; i_area_copy > i_area; i_area_copy-- )
- {
- p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy - 1];
- p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy - 1];
- }
- p_buffer->pi_area_begin[i_area] = i_y;
- p_buffer->pi_area_end[i_area] = i_h;
- return;
- }
- }
- if( i_h > i_area_end )
- {
- /* Find further areas which can be merged with the new one */
- for( i_area_copy = i_area + 1;
- (i_area_copy < p_buffer->i_areas) &&
- (p_buffer->pi_area_begin[i_area] <= i_h);
- i_area_copy++ )
- {
- ;
- }
- i_area_copy--;
-
- if( i_area_copy != i_area )
- {
- /* Merge with last possible areas */
- //p_buffer->pi_area_end[i_area] = MAX( i_h, p_buffer->pi_area_end[i_area_copy] );
-
- /* Shift lower areas upward */
- i_area_shift = i_area_copy - i_area;
- p_buffer->i_areas -= i_area_shift;
- for( i_area_copy = i_area + 1; i_area_copy < p_buffer->i_areas; i_area_copy++ )
- {
- p_buffer->pi_area_begin[i_area_copy] = p_buffer->pi_area_begin[i_area_copy + i_area_shift];
- p_buffer->pi_area_end[i_area_copy] = p_buffer->pi_area_end[i_area_copy + i_area_shift];
- }
- }
- else
- {
- /* Extend area below */
- p_buffer->pi_area_end[i_area] = i_h;
- }
- }
+ return i_pgcd;
}
-}
-
-/*****************************************************************************
- * SetBufferPicture: clear buffer and set picture area
- *****************************************************************************
- * This function is called before any rendering. It clears the current
- * rendering buffer and set the new picture area. If the picture pointer is
- * NULL, then no picture area is defined. Floating operations are avoided since
- * some MMX calculations may follow.
- *****************************************************************************/
-static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
-{
- vout_buffer_t * p_buffer; /* current buffer */
- int i_pic_x, i_pic_y; /* picture position */
- int i_pic_width, i_pic_height; /* picture dimensions */
- int i_old_pic_y, i_old_pic_height; /* old picture area */
- int i_vout_width, i_vout_height; /* display dimensions */
- int i_area; /* area index */
- int i_data_index; /* area data index */
- int i_data_size; /* area data size, in 256 bytes blocs */
- u64 * p_data; /* area data, for clearing */
- byte_t * p_data8; /* area data, for clearing (slow) */
-
- /* Choose buffer and set display dimensions */
- p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
- i_vout_width = p_vout->i_width;
- i_vout_height = p_vout->i_height;
-
- /*
- * Computes new picture size
- */
- if( p_pic != NULL )
- {
- /* Try horizontal scaling first - width must be a mutiple of 16 */
- i_pic_width = (( p_vout->b_scale || (p_pic->i_width > i_vout_width)) ?
- i_vout_width : p_pic->i_width) & ~0xf;
- switch( p_pic->i_aspect_ratio )
- {
- case AR_3_4_PICTURE:
- i_pic_height = i_pic_width * 3 / 4;
- break;
- case AR_16_9_PICTURE:
- i_pic_height = i_pic_width * 9 / 16;
- break;
- case AR_221_1_PICTURE:
- i_pic_height = i_pic_width * 100 / 221;
- break;
- case AR_SQUARE_PICTURE:
- default:
- i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
- break;
- }
-
- /* If picture dimensions using horizontal scaling are too large, use
- * vertical scaling. Since width must be a multiple of 16, height is
- * adjusted again after. */
- if( i_pic_height > i_vout_height )
- {
- i_pic_height = ( p_vout->b_scale || (p_pic->i_height > i_vout_height)) ?
- i_vout_height : p_pic->i_height;
- switch( p_pic->i_aspect_ratio )
- {
- case AR_3_4_PICTURE:
- i_pic_width = (i_pic_height * 4 / 3) & ~0xf;
- i_pic_height = i_pic_width * 3 / 4;
- break;
- case AR_16_9_PICTURE:
- i_pic_width = (i_pic_height * 16 / 9) & ~0xf;
- i_pic_height = i_pic_width * 9 / 16;
- break;
- case AR_221_1_PICTURE:
- i_pic_width = (i_pic_height * 221 / 100) & ~0xf;
- i_pic_height = i_pic_width * 100 / 221;
- break;
- case AR_SQUARE_PICTURE:
- default:
- i_pic_width = (p_pic->i_width * i_pic_height / p_pic->i_height) & ~0xf;
- i_pic_height = p_pic->i_height * i_pic_width / p_pic->i_width;
- break;
- }
- }
-
- /* Set picture position */
- i_pic_x = (p_vout->i_width - i_pic_width) / 2;
- i_pic_y = (p_vout->i_height - i_pic_height) / 2;
- }
- else
+ /* VOUT_ASPECT_FACTOR is (2^7 * 3^3 * 5^3), we just check for 2, 3 and 5 */
+ while( !(i_ratio & 1) && !(i_dummy & 1) )
{
- /* No picture: size is 0 */
- i_pic_x = 0;
- i_pic_y = 0;
- i_pic_width = 0;
- i_pic_height = 0;
+ i_ratio >>= 1;
+ i_dummy >>= 1;
+ i_pgcd <<= 1;
}
- /*
- * Set new picture size - if it is smaller than the previous one, clear
- * around it. Since picture are centered, only their size is tested.
- */
- if( (p_buffer->i_pic_width > i_pic_width) || (p_buffer->i_pic_height > i_pic_height) )
+ while( !(i_ratio % 3) && !(i_dummy % 3) )
{
- i_old_pic_y = p_buffer->i_pic_y;
- i_old_pic_height = p_buffer->i_pic_height;
- p_buffer->i_pic_x = i_pic_x;
- p_buffer->i_pic_y = i_pic_y;
- p_buffer->i_pic_width = i_pic_width;
- p_buffer->i_pic_height = i_pic_height;
- SetBufferArea( p_vout, 0, i_old_pic_y, p_vout->i_width, i_old_pic_height );
- }
- else
- {
- p_buffer->i_pic_x = i_pic_x;
- p_buffer->i_pic_y = i_pic_y;
- p_buffer->i_pic_width = i_pic_width;
- p_buffer->i_pic_height = i_pic_height;
+ i_ratio /= 3;
+ i_dummy /= 3;
+ i_pgcd *= 3;
}
- /*
- * Clear areas
- */
- for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
+ while( !(i_ratio % 5) && !(i_dummy % 5) )
{
-#ifdef TRACE_VOUT
- intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d", p_pic,
- p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
-#endif
- i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
- p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
-
- for( i_data_index = i_data_size / 256; i_data_index-- ; )
- {
- /* Clear 256 bytes block */
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- *p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
- }
- for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
- {
- /* Clear remaining 16 bytes blocks */
- *p_data++ = 0; *p_data++ = 0;
- }
- p_data8 = (byte_t *)p_data;
- for( i_data_index = i_data_size % 16; i_data_index--; )
- {
- /* Clear remaining bytes */
- *p_data8++ = 0;
- }
+ i_ratio /= 5;
+ i_dummy /= 5;
+ i_pgcd *= 5;
}
- /*
- * Clear areas array
- */
- p_buffer->i_areas = 0;
+ return i_pgcd;
}
/*****************************************************************************
- * RenderPicture: render a picture
+ * BinaryLog: computes the base 2 log of a binary value
*****************************************************************************
- * This function converts a picture from a video heap to a pixel-encoded image
- * and copies it to the current rendering buffer. No lock is required, since
- * the * rendered picture has been determined as existant, and will only be
- * destroyed by the vout thread later.
+ * This functions is used by MaskToShift, to get a bit index from a binary
+ * value.
*****************************************************************************/
-static void RenderPicture( vout_thread_t *p_vout, picture_t *p_pic )
+static int BinaryLog(u32 i)
{
-#ifdef TRACE_VOUT
- char psz_date[MSTRTIME_MAX_SIZE]; /* picture date */
- mtime_t render_time; /* picture rendering time */
-#endif
- vout_buffer_t * p_buffer; /* rendering buffer */
- byte_t * p_pic_data; /* convertion destination */
-
- /* Get and set rendering information */
- p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
- p_pic_data = p_buffer->p_data +
- p_buffer->i_pic_x * p_vout->i_bytes_per_pixel +
- p_buffer->i_pic_y * p_vout->i_bytes_per_line;
-#ifdef TRACE_VOUT
- render_time = mdate();
-#endif
-
+ int i_log = 0;
+ if( i == 0 ) return -31337;
- /*
- * Choose appropriate rendering function and render picture
- */
- switch( p_pic->i_type )
- {
- case YUV_420_PICTURE:
- p_vout->yuv.pf_yuv420( p_vout, p_pic_data,
- p_pic->p_y, p_pic->p_u, p_pic->p_v,
- p_pic->i_width, p_pic->i_height,
- p_buffer->i_pic_width, p_buffer->i_pic_height,
- p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
- p_pic->i_matrix_coefficients );
- break;
- case YUV_422_PICTURE:
- p_vout->yuv.pf_yuv422( p_vout, p_pic_data,
- p_pic->p_y, p_pic->p_u, p_pic->p_v,
- p_pic->i_width, p_pic->i_height,
- p_buffer->i_pic_width, p_buffer->i_pic_height,
- p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
- p_pic->i_matrix_coefficients );
- break;
- case YUV_444_PICTURE:
- p_vout->yuv.pf_yuv444( p_vout, p_pic_data,
- p_pic->p_y, p_pic->p_u, p_pic->p_v,
- p_pic->i_width, p_pic->i_height,
- p_buffer->i_pic_width, p_buffer->i_pic_height,
- p_vout->i_bytes_per_line / p_vout->i_bytes_per_pixel,
- p_pic->i_matrix_coefficients );
- break;
-#ifdef DEBUG
- default:
- intf_ErrMsg("error: unknown picture type %d", p_pic->i_type );
- break;
-#endif
- }
+ if( i & 0xffff0000 ) i_log += 16;
+ if( i & 0xff00ff00 ) i_log += 8;
+ if( i & 0xf0f0f0f0 ) i_log += 4;
+ if( i & 0xcccccccc ) i_log += 2;
+ if( i & 0xaaaaaaaa ) i_log += 1;
-#ifdef TRACE_VOUT
- /* Print picture date and rendering time */
- intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s", p_pic,
- p_vout->i_buffer_index, (long) (mdate() - render_time),
- mstrtime( psz_date, p_pic->date ));
-#endif
+ return( i_log );
}
/*****************************************************************************
- * RenderPictureInfo: print additionnal information on a picture
+ * MaskToShift: transform a color mask into right and left shifts
*****************************************************************************
- * This function will print information such as fps and other picture
- * dependant information.
+ * This function is used for obtaining color shifts from masks.
*****************************************************************************/
-static void RenderPictureInfo( vout_thread_t *p_vout, picture_t *p_pic )
+static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
{
- char psz_buffer[256]; /* string buffer */
-
- /*
- * Print FPS rate in upper right corner
- */
- if( p_vout->c_fps_samples > VOUT_FPS_SAMPLES )
- {
- long i_fps = VOUT_FPS_SAMPLES * 1000000 * 10 /
- ( p_vout->p_fps_sample[ (p_vout->c_fps_samples - 1)
- % VOUT_FPS_SAMPLES ] -
- p_vout->p_fps_sample[ p_vout->c_fps_samples
- % VOUT_FPS_SAMPLES ] );
- sprintf( psz_buffer, "%li.%i fps", i_fps / 10, (int)i_fps % 10 );
- Print( p_vout, 0, 0, RIGHT_RALIGN, TOP_RALIGN, psz_buffer );
- }
-
- /*
- * Print frames count and loop time in upper left corner
- */
- sprintf( psz_buffer, "%ld frames, render: %ldus",
- (long) p_vout->c_fps_samples, (long) p_vout->render_time );
- Print( p_vout, 0, 0, LEFT_RALIGN, TOP_RALIGN, psz_buffer );
+ u32 i_low, i_high; /* lower hand higher bits of the mask */
- if( p_main->b_stats )
+ if( !i_mask )
{
- /*
- * Print picture information in lower right corner
- */
- sprintf( psz_buffer, "%s picture %dx%d (%dx%d%+d%+d %s) -> %dx%d+%d+%d",
- (p_pic->i_type == YUV_420_PICTURE) ? "4:2:0" :
- ((p_pic->i_type == YUV_422_PICTURE) ? "4:2:2" :
- ((p_pic->i_type == YUV_444_PICTURE) ? "4:4:4" : "ukn-type")),
- p_pic->i_width, p_pic->i_height,
- p_pic->i_display_width, p_pic->i_display_height,
- p_pic->i_display_horizontal_offset, p_pic->i_display_vertical_offset,
- (p_pic->i_aspect_ratio == AR_SQUARE_PICTURE) ? "sq" :
- ((p_pic->i_aspect_ratio == AR_3_4_PICTURE) ? "4:3" :
- ((p_pic->i_aspect_ratio == AR_16_9_PICTURE) ? "16:9" :
- ((p_pic->i_aspect_ratio == AR_221_1_PICTURE) ? "2.21:1" : "ukn-ar" ))),
- p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_width,
- p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height,
- p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_x,
- p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y );
- Print( p_vout, 0, 0, RIGHT_RALIGN, BOTTOM_RALIGN, psz_buffer );
+ *pi_left = *pi_right = 0;
+ return;
}
-}
-
-/*****************************************************************************
- * RenderIdle: render idle picture
- *****************************************************************************
- * This function will print something on the screen. It will return 0 if
- * nothing has been rendered, or 1 if something has been changed on the screen.
- * Note that if you absolutely want something to be printed, you will have
- * to force it by setting the last idle date to 0.
- * Unlike other rendering functions, this one calls the SetBufferPicture
- * function when needed.
- *****************************************************************************/
-int RenderIdle( vout_thread_t *p_vout )
-{
-#if 0
- int i_x = 0, i_y = 0; /* text position */
- int i_width, i_height; /* text size */
- int i_amount = 0; /* amount to draw */
- char *psz_text = "Waiting for stream"; /* text to display */
- char *psz_wtext = "[................]";
-#endif
- mtime_t current_date; /* current date */
-
-
- memset( p_vout->p_buffer[ p_vout->i_buffer_index ].p_data,
- p_vout->i_bytes_per_line * p_vout->i_height, 12);
-
- current_date = mdate();
- if( (current_date - p_vout->last_display_date) > VOUT_IDLE_DELAY
-// && (current_date - p_vout->last_idle_date) > VOUT_IDLE_DELAY
- )
- {
- /* FIXME: idle screen disabled */
-#if 0
- SetBufferPicture( p_vout, NULL );
- vout_TextSize( p_vout->p_large_font, WIDE_TEXT | OUTLINED_TEXT, psz_text,
- &i_width, &i_height );
- if( !Align( p_vout, &i_x, &i_y, i_width, i_height * 2, CENTER_RALIGN, CENTER_RALIGN ) )
- {
- i_amount = (int) ((current_date - p_vout->last_display_date ) / 5000LL);
- vout_Print( p_vout->p_large_font,
- p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
- i_x * p_vout->i_bytes_per_pixel + i_y * p_vout->i_bytes_per_line,
- p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
- p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
- WIDE_TEXT | OUTLINED_TEXT, psz_text, (i_amount / 3 ) %110);
-
- vout_Print( p_vout->p_large_font,
- p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
- i_x * p_vout->i_bytes_per_pixel + (i_y + 16) * p_vout->i_bytes_per_line,
- p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
- p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
- WIDE_TEXT | OUTLINED_TEXT, psz_wtext, (i_amount/5)%110 );
-
-
- SetBufferArea( p_vout, i_x, i_y, i_width, i_height * 2 );
- }
-#endif
- return( 1 );
- }
- return( 0 );
-}
+ /* Get bits */
+ i_low = i_mask & (- i_mask); /* lower bit of the mask */
+ i_high = i_mask + i_low; /* higher bit of the mask */
-/*****************************************************************************
- * RenderInfo: render additionnal information
- *****************************************************************************
- * This function renders information which do not depend on the current
- * picture rendered.
- *****************************************************************************/
-static void RenderInfo( vout_thread_t *p_vout )
-{
-#ifdef DEBUG
- char psz_buffer[256]; /* string buffer */
- int i_ready_pic = 0; /* ready pictures */
- int i_reserved_pic = 0; /* reserved pictures */
- int i_picture; /* picture index */
-#endif
+ /* Transform bits into an index */
+ i_low = BinaryLog (i_low);
+ i_high = BinaryLog (i_high);
-#ifdef DEBUG
- /*
- * Print thread state in lower left corner
- */
- for( i_picture = 0; i_picture < VOUT_MAX_PICTURES; i_picture++ )
- {
- switch( p_vout->p_picture[i_picture].i_status )
- {
- case RESERVED_PICTURE:
- case RESERVED_DATED_PICTURE:
- case RESERVED_DISP_PICTURE:
- i_reserved_pic++;
- break;
- case READY_PICTURE:
- i_ready_pic++;
- break;
- }
- }
- sprintf( psz_buffer, "pic: %d (%d/%d)/%d",
- p_vout->i_pictures, i_reserved_pic, i_ready_pic, VOUT_MAX_PICTURES );
- Print( p_vout, 0, 0, LEFT_RALIGN, BOTTOM_RALIGN, psz_buffer );
-#endif
+ /* Update pointers and return */
+ *pi_left = i_low;
+ *pi_right = (8 - i_high + i_low);
}
/*****************************************************************************
- * RenderSubPicture: render a subpicture
+ * InitWindowSize: find the initial dimensions the video window should have.
*****************************************************************************
- * This function renders a sub picture unit.
+ * This function will check the "width", "height" and "zoom" config options and
+ * will calculate the size that the video window should have.
*****************************************************************************/
-static void RenderSubPicture( vout_thread_t *p_vout, picture_t *p_pic,
- subpicture_t *p_subpic )
+static void InitWindowSize( vout_thread_t *p_vout, int *pi_width,
+ int *pi_height )
{
- p_vout_font_t p_font; /* text font */
- int i_width, i_height; /* subpicture dimensions */
-
- while( p_subpic != NULL )
- {
- switch( p_subpic->i_type )
- {
- case DVD_SUBPICTURE: /* DVD subpicture unit */
- if( p_vout->b_need_render )
- {
- vout_RenderRGBSPU( p_pic, p_subpic,
- &p_vout->p_buffer[ p_vout->i_buffer_index ],
- p_vout->i_bytes_per_pixel,
- p_vout->i_bytes_per_line );
- }
- else
- {
- vout_RenderYUVSPU( p_pic, p_subpic );
- }
- break;
-
- case TEXT_SUBPICTURE: /* single line text */
- /* Select default font if not specified */
- p_font = p_subpic->type.text.p_font;
- if( p_font == NULL )
- {
- p_font = p_vout->p_default_font;
- }
+ int i_width, i_height;
+ double f_zoom;
- /* Compute text size (width and height fields are ignored)
- * and print it */
- vout_TextSize( p_font, p_subpic->type.text.i_style,
- p_subpic->p_data, &i_width, &i_height );
- if( !Align( p_vout, &p_subpic->i_x, &p_subpic->i_y,
- i_width, i_height, p_subpic->i_horizontal_align,
- p_subpic->i_vertical_align ) )
- {
- vout_Print( p_font,
- p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
- p_subpic->i_x * p_vout->i_bytes_per_pixel +
- p_subpic->i_y * p_vout->i_bytes_per_line,
- p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
- p_subpic->type.text.i_char_color,
- p_subpic->type.text.i_border_color,
- p_subpic->type.text.i_bg_color,
- p_subpic->type.text.i_style, p_subpic->p_data, 100 );
- SetBufferArea( p_vout, p_subpic->i_x, p_subpic->i_y,
- i_width, i_height );
- }
- break;
-
- default:
-#ifdef DEBUG
- intf_ErrMsg( "error: unknown subpicture %p type %d",
- p_subpic, p_subpic->i_type );
-#endif
- break;
- }
-
- p_subpic = p_subpic->p_next;
- }
-}
+ i_width = config_GetInt( p_vout, "width" );
+ i_height = config_GetInt( p_vout, "height" );
+ f_zoom = config_GetFloat( p_vout, "zoom" );
-/*****************************************************************************
- * Manage: manage thread
- *****************************************************************************
- * This function will handle changes in thread configuration.
- *****************************************************************************/
-static int Manage( vout_thread_t *p_vout )
-{
-#ifdef TRACE_VOUT
- if( p_vout->i_changes )
+ if( (i_width >= 0) && (i_height >= 0))
{
- intf_DbgMsg("changes: 0x%x (no display: 0x%x)", p_vout->i_changes,
- 0 /* p_vout->i_changes & VOUT_NODISPLAY_CHANGE */ );
+ *pi_width = i_width * f_zoom;
+ *pi_height = i_height * f_zoom;
+ return;
}
-#endif
-
- /* On gamma or grayscale change, rebuild tables */
- if( p_vout->i_changes & (VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
- VOUT_YUV_CHANGE) )
+ else if( i_width >= 0 )
{
- if( vout_ResetYUV( p_vout ) )
- {
- intf_ErrMsg( "vout error: can't rebuild conversion tables" );
- return( 1 );
- }
+ *pi_width = i_width * f_zoom;
+ *pi_height = i_width * f_zoom * VOUT_ASPECT_FACTOR /
+ p_vout->render.i_aspect;
+ return;
}
-
- /* Clear changes flags which does not need management or have been
- * handled */
- p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
- VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
- VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE |
- VOUT_CURSOR_CHANGE | VOUT_FULLSCREEN_CHANGE );
-
- /* Detect unauthorized changes */
- if( p_vout->i_changes )
+ else if( i_height >= 0 )
{
- /* Some changes were not acknowledged by p_vout->pf_manage or this
- * function, it means they should not be authorized */
- intf_ErrMsg( "vout error: unauthorized changes in the vout thread" );
- return( 1 );
+ *pi_height = i_height * f_zoom;
+ *pi_width = i_height * f_zoom * p_vout->render.i_aspect /
+ VOUT_ASPECT_FACTOR;
+ return;
}
- return( 0 );
-}
-
-/*****************************************************************************
- * Align: align a subpicture in the screen
- *****************************************************************************
- * This function is used for rendering text or subpictures. It returns non 0
- * it the final aera is not fully included in display area. Return coordinates
- * are absolute.
- *****************************************************************************/
-static int Align( vout_thread_t *p_vout, int *pi_x, int *pi_y,
- int i_width, int i_height, int i_h_align, int i_v_align )
-{
- /* Align horizontally */
- switch( i_h_align )
+ if( p_vout->render.i_height * p_vout->render.i_aspect
+ >= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
{
- case CENTER_ALIGN:
- *pi_x -= i_width / 2;
- break;
- case CENTER_RALIGN:
- *pi_x += (p_vout->i_width - i_width) / 2;
- break;
- case RIGHT_ALIGN:
- *pi_x -= i_width;
- break;
- case RIGHT_RALIGN:
- *pi_x += p_vout->i_width - i_width;
- break;
+ *pi_width = p_vout->render.i_height * f_zoom
+ * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
+ *pi_height = p_vout->render.i_height * f_zoom;
}
-
- /* Align vertically */
- switch( i_v_align )
+ else
{
- case CENTER_ALIGN:
- *pi_y -= i_height / 2;
- break;
- case CENTER_RALIGN:
- *pi_y += (p_vout->i_height - i_height) / 2;
- break;
- case BOTTOM_ALIGN:
- *pi_y -= i_height;
- break;
- case BOTTOM_RALIGN:
- *pi_y += p_vout->i_height - i_height;
- break;
- case SUBTITLE_RALIGN:
- *pi_y += (p_vout->i_height + p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_y +
- p_vout->p_buffer[ p_vout->i_buffer_index ].i_pic_height - i_height) / 2;
- break;
+ *pi_width = p_vout->render.i_width * f_zoom;
+ *pi_height = p_vout->render.i_width * f_zoom
+ * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
}
-
- /* Return non 0 if clipping failed */
- return( (*pi_x < 0) || (*pi_y < 0) ||
- (*pi_x + i_width > p_vout->i_width) || (*pi_y + i_height > p_vout->i_height) );
-}
-
-/*****************************************************************************
- * SetPalette: sets an 8 bpp palette
- *****************************************************************************
- * This function is just a prototype that does nothing. Architectures that
- * support palette allocation should override it.
- *****************************************************************************/
-static void SetPalette ( p_vout_thread_t p_vout, u16 *red,
- u16 *green, u16 *blue, u16 *transp )
-{
- intf_ErrMsg( "vout error: method does not support palette changing" );
}
-