]> git.sesse.net Git - vlc/commitdiff
add --screen-aspect-ratio option (user support at its best ...)
authorAntoine Cellerier <dionoea@videolan.org>
Thu, 11 Aug 2005 20:41:26 +0000 (20:41 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Thu, 11 Aug 2005 20:41:26 +0000 (20:41 +0000)
src/libvlc.h
src/video_output/video_output.c
src/video_output/vout_intf.c

index 3374d8afd666bcd8fe11cc93054c22f6cbfa625a..ccbe52d8fc5b10ef59edb1d5c7f6c08def303445 100644 (file)
@@ -275,6 +275,12 @@ static char *ppsz_align_descriptions[] =
     "aspect, or a float value (1.25, 1.3333, etc.) expressing pixel " \
     "squareness.")
 
+#define SASPECT_RATIO_TEXT N_("Screen aspect ratio")
+#define SASPECT_RATIO_LONGTEXT N_( \
+    "This will force the scree aspect ratio. Default screen aspect ratio" \
+    "is 4:3. Setting the screen aspect ratio to 4:3 will have no effect," \
+    "other settings (like 16:9) will change the image.")
+
 #define SKIP_FRAMES_TEXT N_("Skip frames")
 #define SKIP_FRAMES_LONGTEXT N_( \
     "Disable this option to disable frame drops on MPEG-2 streams.")
@@ -991,6 +997,8 @@ vlc_module_begin();
     add_integer( "video-y", -1, NULL, VIDEOY_TEXT, VIDEOY_LONGTEXT, VLC_TRUE );
     add_string( "aspect-ratio", "", NULL,
                ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, VLC_FALSE );
+    add_string( "screen-aspect-ratio", "", NULL,
+               SASPECT_RATIO_TEXT, SASPECT_RATIO_LONGTEXT, VLC_FALSE );
     add_bool( "video-deco", 1, NULL, VIDEO_DECO_TEXT,
               VIDEO_DECO_LONGTEXT, VLC_TRUE );
     add_string( "video-title", NULL, NULL, VIDEO_TITLE_TEXT,
index 3f800ea6eb71800e9563bd513f55b08882956f49..91db4cf6d32ae0ccc5179fee93b96f0ab20a846a 100644 (file)
@@ -216,7 +216,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
     input_thread_t * p_input_thread;
     int              i_index;                               /* loop variable */
     char           * psz_plugin;
-    vlc_value_t      val, text;
+    vlc_value_t      val, val2, text;
 
     unsigned int i_width = p_fmt->i_width;
     unsigned int i_height = p_fmt->i_height;
@@ -316,25 +316,49 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
      * the video output pipe */
     if( p_parent->i_object_type != VLC_OBJECT_VOUT )
     {
+        int i_screen_aspect_x = 4 , i_screen_aspect_y = 3;
         var_Get( p_vout, "aspect-ratio", &val );
+        var_Get( p_vout, "screen-aspect-ratio", &val2 );
+
+        if( val2.psz_string )
+        {
+            char *psz_parser = strchr( val2.psz_string, ':' );
+            if( psz_parser )
+            {
+                *psz_parser++ = '\0';
+                i_screen_aspect_x = atoi( val2.psz_string );
+                i_screen_aspect_y = atoi( psz_parser );
+            } else {
+                AspectRatio( VOUT_ASPECT_FACTOR * atof( val2.psz_string ),
+                                 &i_screen_aspect_x, &i_screen_aspect_y );
+            }
+
+            free( val2.psz_string );
+        }
 
         /* Check whether the user tried to override aspect ratio */
         if( val.psz_string )
         {
             unsigned int i_new_aspect = i_aspect;
             char *psz_parser = strchr( val.psz_string, ':' );
+                int i_aspect_x, i_aspect_y;
+                AspectRatio( i_aspect, &i_aspect_x, &i_aspect_y );
 
             if( psz_parser )
             {
                 *psz_parser++ = '\0';
-                i_new_aspect = atoi( val.psz_string ) * VOUT_ASPECT_FACTOR
-                                                      / atoi( psz_parser );
+                i_new_aspect = atoi( val.psz_string )
+                               * VOUT_ASPECT_FACTOR / atoi( psz_parser );
             }
             else
             {
-                i_new_aspect = VOUT_ASPECT_FACTOR
-                                       * atof( val.psz_string );
+                if( atof( val.psz_string ) != 0 )
+                {
+                i_new_aspect = VOUT_ASPECT_FACTOR * atof( val.psz_string );
+                }
             }
+            i_new_aspect = (int)((float)i_new_aspect
+                * (float)i_screen_aspect_y*4.0/((float)i_screen_aspect_x*3.0));
 
             free( val.psz_string );
 
index f04e0bb6ba4406d1f732ca547b719a7abea24609..d886a5bdb17f350979f8dbd773f001a7c739f42e 100644 (file)
@@ -177,6 +177,8 @@ void vout_IntfInit( vout_thread_t *p_vout )
     var_Create( p_vout, "snapshot-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "snapshot-format", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "screen-aspect-ratio",
+                                      VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );