]> git.sesse.net Git - vlc/commitdiff
* the calculation for the initial video window dimensions is now done in
authorGildas Bazin <gbazin@videolan.org>
Thu, 21 Mar 2002 22:10:33 +0000 (22:10 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 21 Mar 2002 22:10:33 +0000 (22:10 +0000)
    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.

include/video_output.h
plugins/directx/vout_directx.c
plugins/mga/xmga.c
plugins/qnx/vout_qnx.c
plugins/sdl/vout_sdl.c
plugins/x11/xcommon.c
src/interface/main.c
src/video_output/video_output.c

index 858a3b603cf4d0ec6ac033c2c2ffeb26ab4395be..5916d85e87cec29b0855d116d125db8a1e404021 100644 (file)
@@ -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>
  *
@@ -110,7 +110,7 @@ typedef struct vout_thread_s
     vlc_mutex_t         change_lock;                   /* thread change lock */
     int *               pi_status;                  /* temporary status flag */
     p_vout_sys_t        p_sys;                       /* system output method */
-                                                                   
+
     /* Current display properties */
     u16                 i_changes;             /* changes made to the thread */
     float               f_gamma;                                    /* gamma */
@@ -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;
index f15268a2ee3cbdc054c395ae944a9ce5c2350226..e91a40594935ec700bd566159663361dc2df8876 100644 (file)
@@ -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 );
index d21cdf9974b8322434875a9b7489f44895b256fb..4801544146c336cfab0b5d9b37c8518bb003dc7a 100644 (file)
@@ -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;
index eb42220275ac63d7cb6b14b3e9d60b74c9119f53..6dcee12f2a8f8cdd97271103ca86334c38a50c03 100644 (file)
@@ -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 ) )
index 446f23b2c86b3bb44fe36d268c306bd9077f4bdc..89ae03cc7f3dcc4cb725671684bd2a390bf19ae5 100644 (file)
@@ -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 ) )
     {
index a0f54ad4ab7eceb27a1f5692481b502e516e0d23..960512392b77a6109096e7c101e3a12910e2d618 100644 (file)
@@ -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 */
index 9ef46add7343170036435b80ab918062d5c10ac1..7fa536864c064bcaf7a71dca0d117592916040d7 100644 (file)
@@ -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 )
index 56d065bf9a681ff690ae5456208b7c175b3cfec4..bfc8c259c36b120610b9dbb3b2c662e2291367aa 100644 (file)
@@ -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;
+    }
+}