#include <stdlib.h> /* free() */
#include <string.h>
-
-#ifdef HAVE_SYS_TIMES_H
-# include <sys/times.h>
-#endif
-
#include <vlc_vout.h>
#include <vlc_filter.h>
static void CleanThread ( vout_thread_t * );
static void EndThread ( vout_thread_t * );
-static void AspectRatio ( int, int *, int * );
-
static void VideoFormatImportRgb( video_format_t *, const picture_heap_t * );
static void PictureHeapFixRgb( picture_heap_t * );
static int video_filter_buffer_allocation_init( filter_t *p_filter, void *p_data )
{
- p_filter->pf_vout_buffer_new = video_new_buffer_filter;
- p_filter->pf_vout_buffer_del = video_del_buffer_filter;
+ p_filter->pf_video_buffer_new = video_new_buffer_filter;
+ p_filter->pf_video_buffer_del = video_del_buffer_filter;
p_filter->p_owner = p_data; /* p_vout */
return VLC_SUCCESS;
}
else
{
/* This video output is cool! Hijack it. */
- if( p_vout->fmt_render.i_aspect != p_fmt->i_aspect )
- {
- /* Correct aspect ratio on change
- * FIXME factorize this code with other aspect ration related code */
- unsigned int i_sar_num;
- unsigned int i_sar_den;
- unsigned int i_aspect;
-
- i_aspect = p_fmt->i_aspect;
- vlc_ureduce( &i_sar_num, &i_sar_den,
- p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
+ /* Correct aspect ratio on change
+ * FIXME factorize this code with other aspect ration related code */
+ unsigned int i_sar_num;
+ unsigned int i_sar_den;
+ vlc_ureduce( &i_sar_num, &i_sar_den,
+ p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
#if 0
- /* What's that, it does not seems to be used correcly everywhere
- * beside the previous p_vout->fmt_render.i_aspect != p_fmt->i_aspect
- * should be fixed to use it too then */
- if( p_vout->i_par_num > 0 && p_vout->i_par_den > 0 )
- {
- i_sar_num *= p_vout->i_par_den;
- i_sar_den *= p_vout->i_par_num;
- i_aspect = i_aspect * p_vout->i_par_den / p_vout->i_par_num;
- }
+ /* What's that, it does not seems to be used correcly everywhere */
+ if( p_vout->i_par_num > 0 && p_vout->i_par_den > 0 )
+ {
+ i_sar_num *= p_vout->i_par_den;
+ i_sar_den *= p_vout->i_par_num;
+ }
#endif
- if( i_sar_num > 0 && i_sar_den > 0 && i_aspect > 0 )
- {
- p_vout->fmt_in.i_sar_num = i_sar_num;
- p_vout->fmt_in.i_sar_den = i_sar_den;
- p_vout->fmt_in.i_aspect = i_aspect;
-
- p_vout->fmt_render.i_sar_num = i_sar_num;
- p_vout->fmt_render.i_sar_den = i_sar_den;
- p_vout->fmt_render.i_aspect = i_aspect;
-
- p_vout->render.i_aspect = i_aspect;
-
- p_vout->i_changes |= VOUT_ASPECT_CHANGE;
-
- }
+ if( i_sar_num > 0 && i_sar_den > 0 &&
+ ( i_sar_num != p_vout->fmt_render.i_sar_num ||
+ i_sar_den != p_vout->fmt_render.i_sar_den ) )
+ {
+ p_vout->fmt_in.i_sar_num = i_sar_num;
+ p_vout->fmt_in.i_sar_den = i_sar_den;
+
+ p_vout->fmt_render.i_sar_num = i_sar_num;
+ p_vout->fmt_render.i_sar_den = i_sar_den;
+
+ p_vout->render.i_aspect = (int64_t)i_sar_num *
+ p_vout->fmt_render.i_width *
+ VOUT_ASPECT_FACTOR /
+ i_sar_den /
+ p_vout->fmt_render.i_height;
+ p_vout->i_changes |= VOUT_ASPECT_CHANGE;
}
vlc_mutex_unlock( &p_vout->change_lock );
unsigned int i_width = p_fmt->i_width;
unsigned int i_height = p_fmt->i_height;
vlc_fourcc_t i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, p_fmt->i_chroma );
- unsigned int i_aspect = p_fmt->i_aspect;
config_chain_t *p_cfg;
char *psz_parser;
char *psz_name;
- if( i_width <= 0 || i_height <= 0 || i_aspect <= 0 )
+ if( i_width <= 0 || i_height <= 0 )
return NULL;
vlc_ureduce( &p_fmt->i_sar_num, &p_fmt->i_sar_den,
p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
if( p_fmt->i_sar_num <= 0 || p_fmt->i_sar_den <= 0 )
return NULL;
+ unsigned int i_aspect = (int64_t)p_fmt->i_sar_num *
+ i_width *
+ VOUT_ASPECT_FACTOR /
+ p_fmt->i_sar_den /
+ i_height;
/* Allocate descriptor */
static const char typename[] = "video output";
/* Choose the video output module */
if( !p_vout->p->psz_filter_chain || !*p_vout->p->psz_filter_chain )
{
- psz_parser = var_CreateGetString( p_vout, "vout" );
+ psz_parser = NULL;
}
else
{
free( p_vout->p );
-#ifndef __APPLE__
- vout_thread_t *p_another_vout;
-
- /* This is a dirty hack mostly for Linux, where there is no way to get the
- * GUI back if you closed it while playing video. This is solved in
- * Mac OS X, where we have this novelty called menubar, that will always
- * allow you access to the applications main functionality. They should try
- * that on linux sometime. */
- p_another_vout = vlc_object_find( p_this->p_libvlc,
- VLC_OBJECT_VOUT, FIND_ANYWHERE );
- if( p_another_vout == NULL )
- var_SetBool( p_this->p_libvlc, "intf-show", true );
- else
- vlc_object_release( p_another_vout );
-#endif
}
/* */
{
assert( psz_title );
- if( !config_GetInt( p_vout, "osd" ) )
+ if( !var_InheritBool( p_vout, "osd" ) )
return;
vlc_mutex_lock( &p_vout->change_lock );
static int InitThread( vout_thread_t *p_vout )
{
- int i, i_aspect_x, i_aspect_y;
+ int i;
/* Initialize output method, it allocates direct buffers for us */
if( p_vout->pf_init( p_vout ) )
msg_Dbg( p_vout, "got %i direct buffer(s)", I_OUTPUTPICTURES );
- AspectRatio( p_vout->fmt_render.i_aspect, &i_aspect_x, &i_aspect_y );
-
- AspectRatio( p_vout->fmt_in.i_aspect, &i_aspect_x, &i_aspect_y );
-
if( !p_vout->fmt_out.i_width || !p_vout->fmt_out.i_height )
{
p_vout->fmt_out.i_width = p_vout->fmt_out.i_visible_width =
p_vout->output.i_height;
p_vout->fmt_out.i_x_offset = p_vout->fmt_out.i_y_offset = 0;
- p_vout->fmt_out.i_aspect = p_vout->output.i_aspect;
p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
}
if( !p_vout->fmt_out.i_sar_num || !p_vout->fmt_out.i_sar_num )
{
- p_vout->fmt_out.i_sar_num = p_vout->fmt_out.i_aspect *
+ p_vout->fmt_out.i_sar_num = p_vout->output.i_aspect *
p_vout->fmt_out.i_height;
p_vout->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR *
p_vout->fmt_out.i_width;
vlc_ureduce( &p_vout->fmt_out.i_sar_num, &p_vout->fmt_out.i_sar_den,
p_vout->fmt_out.i_sar_num, p_vout->fmt_out.i_sar_den, 0 );
- AspectRatio( p_vout->fmt_out.i_aspect, &i_aspect_x, &i_aspect_y );
-
/* FIXME removed the need of both fmt_* and heap infos */
/* Calculate shifts from system-updated masks */
PictureHeapFixRgb( &p_vout->render );
/* print some usefull debug info about different vout formats
*/
- msg_Dbg( p_vout, "pic render sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, ar %i:%i, sar %i:%i, msk r0x%x g0x%x b0x%x",
+ msg_Dbg( p_vout, "pic render sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, sar %i:%i, msk r0x%x g0x%x b0x%x",
p_vout->fmt_render.i_width, p_vout->fmt_render.i_height,
p_vout->fmt_render.i_x_offset, p_vout->fmt_render.i_y_offset,
p_vout->fmt_render.i_visible_width,
p_vout->fmt_render.i_visible_height,
(char*)&p_vout->fmt_render.i_chroma,
- i_aspect_x, i_aspect_y,
p_vout->fmt_render.i_sar_num, p_vout->fmt_render.i_sar_den,
p_vout->fmt_render.i_rmask, p_vout->fmt_render.i_gmask, p_vout->fmt_render.i_bmask );
- msg_Dbg( p_vout, "pic in sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, ar %i:%i, sar %i:%i, msk r0x%x g0x%x b0x%x",
+ msg_Dbg( p_vout, "pic in sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, sar %i:%i, msk r0x%x g0x%x b0x%x",
p_vout->fmt_in.i_width, p_vout->fmt_in.i_height,
p_vout->fmt_in.i_x_offset, p_vout->fmt_in.i_y_offset,
p_vout->fmt_in.i_visible_width,
p_vout->fmt_in.i_visible_height,
(char*)&p_vout->fmt_in.i_chroma,
- i_aspect_x, i_aspect_y,
p_vout->fmt_in.i_sar_num, p_vout->fmt_in.i_sar_den,
p_vout->fmt_in.i_rmask, p_vout->fmt_in.i_gmask, p_vout->fmt_in.i_bmask );
- msg_Dbg( p_vout, "pic out sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, ar %i:%i, sar %i:%i, msk r0x%x g0x%x b0x%x",
+ msg_Dbg( p_vout, "pic out sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, sar %i:%i, msk r0x%x g0x%x b0x%x",
p_vout->fmt_out.i_width, p_vout->fmt_out.i_height,
p_vout->fmt_out.i_x_offset, p_vout->fmt_out.i_y_offset,
p_vout->fmt_out.i_visible_width,
p_vout->fmt_out.i_visible_height,
(char*)&p_vout->fmt_out.i_chroma,
- i_aspect_x, i_aspect_y,
p_vout->fmt_out.i_sar_num, p_vout->fmt_out.i_sar_den,
p_vout->fmt_out.i_rmask, p_vout->fmt_out.i_gmask, p_vout->fmt_out.i_bmask );
*****************************************************************************/
static void EndThread( vout_thread_t *p_vout )
{
-#ifdef STATS
- {
- struct tms cpu_usage;
- times( &cpu_usage );
-
- msg_Dbg( p_vout, "cpu usage (user: %d, system: %d)",
- cpu_usage.tms_utime, cpu_usage.tms_stime );
- }
-#endif
-
/* FIXME does that function *really* need to be called inside the thread ? */
/* Detach subpicture unit from both input and vout */
return VLC_EGENERIC;
}
- p_chroma->pf_vout_buffer_new = ChromaGetPicture;
+ p_chroma->pf_video_buffer_new = ChromaGetPicture;
return VLC_SUCCESS;
}
}
/* following functions are local */
-static void AspectRatio( int i_aspect, int *i_aspect_x, int *i_aspect_y )
-{
- const int i_pgcd = i_aspect ? GCD( i_aspect, VOUT_ASPECT_FACTOR ) : 1;
- *i_aspect_x = i_aspect / i_pgcd;
- *i_aspect_y = VOUT_ASPECT_FACTOR / i_pgcd;
-}
/**
* This function copies all RGB informations from a picture_heap_t into