Commit c6f900e1 authored by Gildas Bazin's avatar Gildas Bazin

* the calculation for the initial video window dimensions is now done in
    video_output.c and made available into p_vout->i_window_height/width.
    This allows to get rid of duplicated code and unify the behaviour of
    the video output plugins. (not all the plugins have been modified
    because I didn't want to break anything).

    As a side effect, the --width and --height options are now working, you
    can even use only --width or only --height the other dimension will adapt
    automatically to the video characteristics.
    Note that you need to remove the width/height options from the config file
    or set them to -1 if you want to use the actual video size.
parent fb3f8ba5
......@@ -5,7 +5,7 @@
* thread, and destroy a previously opened video output thread.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.71 2002/01/05 03:49:18 sam Exp $
* $Id: video_output.h,v 1.72 2002/03/21 22:10:32 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -120,6 +120,8 @@ typedef struct vout_thread_s
boolean_t b_scale; /* allow picture scaling */
boolean_t b_fullscreen; /* toogle fullscreen display */
mtime_t render_time; /* last picture render time */
int i_window_width; /* video window width */
int i_window_height; /* video window height */
/* Plugin used and shortcuts to access its capabilities */
struct module_s * p_module;
......
......@@ -2,7 +2,7 @@
* vout_directx.c: Windows DirectX video output display method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: vout_directx.c,v 1.26 2002/03/17 17:00:38 sam Exp $
* $Id: vout_directx.c,v 1.27 2002/03/21 22:10:32 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -142,24 +142,8 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->p_sys->i_lastmoved = mdate();
/* Set main window's size */
if( p_vout->render.i_height * p_vout->render.i_aspect
>= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
{
p_vout->p_sys->i_window_width = p_vout->render.i_height
* p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
p_vout->p_sys->i_window_height = p_vout->render.i_height;
}
else
{
p_vout->p_sys->i_window_width = p_vout->render.i_width;
p_vout->p_sys->i_window_height = p_vout->render.i_width
* VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
}
#if 0
p_vout->p_sys->i_window_width = config_GetIntVariable( "width" );
p_vout->p_sys->i_window_height = config_GetIntVariable( "height" );
#endif
p_vout->p_sys->i_window_width = p_vout->i_window_width;
p_vout->p_sys->i_window_height = p_vout->i_window_height;
/* Set locks and condition variables */
vlc_mutex_init( &p_vout->p_sys->event_thread_lock );
......
......@@ -2,7 +2,7 @@
* xmga.c : X11 MGA plugin for vlc
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xmga.c,v 1.9 2002/03/17 17:00:38 sam Exp $
* $Id: xmga.c,v 1.10 2002/03/21 22:10:33 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -724,33 +724,8 @@ static int CreateWindow( vout_thread_t *p_vout )
boolean_t b_map_notify;
/* Set main window's size */
if( p_vout->render.i_height * p_vout->render.i_aspect
>= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
{
p_vout->p_sys->i_width = p_vout->render.i_height
* p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
p_vout->p_sys->i_height = p_vout->render.i_height;
}
else
{
p_vout->p_sys->i_width = p_vout->render.i_width;
p_vout->p_sys->i_height = p_vout->render.i_width
* VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
}
#if 0
if( p_vout->p_sys->i_width <= 300 && p_vout->p_sys->i_height <= 300 )
{
p_vout->p_sys->i_width <<= 1;
p_vout->p_sys->i_height <<= 1;
}
else if( p_vout->p_sys->i_width <= 400
&& p_vout->p_sys->i_height <= 400 )
{
p_vout->p_sys->i_width += p_vout->p_sys->i_width >> 1;
p_vout->p_sys->i_height += p_vout->p_sys->i_height >> 1;
}
#endif
p_vout->p_sys->i_width = p_vout->i_window_width;
p_vout->p_sys->i_height = p_vout->i_window_height;
/* Prepare window manager hints and properties */
xsize_hints.base_width = p_vout->p_sys->i_width;
......
......@@ -146,10 +146,8 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->p_sys->i_mode =
config_GetIntVariable( "nooverlay" ) ?
MODE_NORMAL_MEM : MODE_VIDEO_OVERLAY;
p_vout->p_sys->dim.w =
config_GetIntVariable( "width" );
p_vout->p_sys->dim.h =
config_GetIntVariable( "height" );
p_vout->p_sys->dim.w = p_vout->i_window_width;
p_vout->p_sys->dim.h = p_vout->i_window_height;
/* init display and create window */
if( QNXInitDisplay( p_vout ) || QNXCreateWnd( p_vout ) )
......
......@@ -2,7 +2,7 @@
* vout_sdl.c: SDL video output display method
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: vout_sdl.c,v 1.86 2002/03/20 14:08:55 sam Exp $
* $Id: vout_sdl.c,v 1.87 2002/03/21 22:10:33 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Pierre Baillet <oct@zoy.org>
......@@ -209,32 +209,9 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->p_sys->b_cursor_autohidden = 0;
p_vout->p_sys->i_lastmoved = mdate();
if( p_vout->render.i_height * p_vout->render.i_aspect
>= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
{
p_vout->p_sys->i_width = p_vout->render.i_height
* p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
p_vout->p_sys->i_height = p_vout->render.i_height;
}
else
{
p_vout->p_sys->i_width = p_vout->render.i_width;
p_vout->p_sys->i_height = p_vout->render.i_width
* VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
}
#if 0
if( p_vout->p_sys->i_width <= 300 && p_vout->p_sys->i_height <= 300 )
{
p_vout->p_sys->i_width <<= 1;
p_vout->p_sys->i_height <<= 1;
}
else if( p_vout->p_sys->i_width <= 400 && p_vout->p_sys->i_height <= 400 )
{
p_vout->p_sys->i_width += p_vout->p_sys->i_width >> 1;
p_vout->p_sys->i_height += p_vout->p_sys->i_height >> 1;
}
#endif
/* Set main window's size */
p_vout->p_sys->i_width = p_vout->i_window_width;
p_vout->p_sys->i_height = p_vout->i_window_height;
if( OpenDisplay( p_vout ) )
{
......
......@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.c,v 1.24 2002/03/17 17:00:38 sam Exp $
* $Id: xcommon.c,v 1.25 2002/03/21 22:10:33 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -953,33 +953,8 @@ static int CreateWindow( vout_thread_t *p_vout )
boolean_t b_map_notify;
/* Set main window's size */
if( p_vout->render.i_height * p_vout->render.i_aspect
>= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
{
p_vout->p_sys->i_width = p_vout->render.i_height
* p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
p_vout->p_sys->i_height = p_vout->render.i_height;
}
else
{
p_vout->p_sys->i_width = p_vout->render.i_width;
p_vout->p_sys->i_height = p_vout->render.i_width
* VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
}
#if 0
if( p_vout->p_sys->i_width <= 300 && p_vout->p_sys->i_height <= 300 )
{
p_vout->p_sys->i_width <<= 1;
p_vout->p_sys->i_height <<= 1;
}
else if( p_vout->p_sys->i_width <= 400
&& p_vout->p_sys->i_height <= 400 )
{
p_vout->p_sys->i_width += p_vout->p_sys->i_width >> 1;
p_vout->p_sys->i_height += p_vout->p_sys->i_height >> 1;
}
#endif
p_vout->p_sys->i_width = p_vout->i_window_width;
p_vout->p_sys->i_height = p_vout->i_window_height;
/* Prepare window manager hints and properties */
xsize_hints.base_width = p_vout->p_sys->i_width;
......@@ -1113,6 +1088,9 @@ static int CreateWindow( vout_thread_t *p_vout )
XMapWindow( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window );
XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window,
ExposureMask );
/* make sure the YUV window will be centered in the next vout_Manage() */
p_vout->i_changes |= VOUT_SIZE_CHANGE;
#endif
/* If the cursor was formerly blank than blank it again */
......
......@@ -4,7 +4,7 @@
* and spawn threads.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: main.c,v 1.166 2002/03/21 07:11:57 gbazin Exp $
* $Id: main.c,v 1.167 2002/03/21 22:10:33 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -305,8 +305,8 @@ ADD_CATEGORY_HINT( "Video", NULL )
ADD_PLUGIN ( "vout", MODULE_CAPABILITY_VOUT, NULL, NULL, VOUT_TEXT, VOUT_LONGTEXT )
ADD_BOOL ( "novideo", NULL, NOVIDEO_TEXT, NOVIDEO_LONGTEXT )
ADD_STRING ( "display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
ADD_INTEGER ( "width", 720, NULL, WIDTH_TEXT, WIDTH_LONGTEXT )
ADD_INTEGER ( "height", 576, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT )
ADD_INTEGER ( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT )
ADD_INTEGER ( "height", -1, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT )
ADD_BOOL ( "grayscale", NULL, GRAYSCALE_TEXT, GRAYSCALE_LONGTEXT )
ADD_BOOL ( "fullscreen", NULL, FULLSCREEN_TEXT, FULLSCREEN_LONGTEXT )
ADD_BOOL ( "nooverlay", NULL, NOOVERLAY_TEXT, NOOVERLAY_LONGTEXT )
......
......@@ -5,7 +5,7 @@
* thread, and destroy a previously oppened video output thread.
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: video_output.c,v 1.168 2002/03/17 17:00:38 sam Exp $
* $Id: video_output.c,v 1.169 2002/03/21 22:10:33 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -53,6 +53,7 @@ static void DestroyThread ( vout_thread_t *p_vout, int i_status );
static int ReduceHeight ( int );
static int BinaryLog ( u32 );
static void MaskToShift ( int *, int *, u32 );
static void InitWindowSize ( vout_thread_t *, int *, int * );
/*****************************************************************************
* vout_InitBank: initialize the video output bank.
......@@ -176,6 +177,11 @@ vout_thread_t * vout_CreateThread ( int *pi_status,
if( config_GetIntVariable( "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( MODULE_CAPABILITY_VOUT, psz_plugin, (void *)p_vout );
......@@ -801,3 +807,50 @@ static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
*pi_right = (8 - i_high + i_low);
}
/*****************************************************************************
* InitWindowSize: find the initial dimensions the video window should have.
*****************************************************************************
* This function will check the "width" and "height" config options and
* will calculate the size that the video window should have.
*****************************************************************************/
static void InitWindowSize( vout_thread_t *p_vout, int *pi_width,
int *pi_height )
{
int i_width, i_height;
i_width = config_GetIntVariable( "width" );
i_height = config_GetIntVariable( "height" );
if( (i_width >= 0) && (i_height >= 0))
{
*pi_width = i_width;
*pi_height = i_height;
return;
}
else if( i_width >= 0 )
{
*pi_width = i_width;
*pi_height = i_width * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
return;
}
else if( i_height >= 0 )
{
*pi_height = i_height;
*pi_width = i_height * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
return;
}
if( p_vout->render.i_height * p_vout->render.i_aspect
>= p_vout->render.i_width * VOUT_ASPECT_FACTOR )
{
*pi_width = p_vout->render.i_height
* p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
*pi_height = p_vout->render.i_height;
}
else
{
*pi_width = p_vout->render.i_width;
*pi_height = p_vout->render.i_width
* VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment