[vlc-devel] commit: Enabling scaling activation/deactivation (Joseph Tulou )

git version control git at videolan.org
Mon Jan 26 20:28:59 CET 2009


vlc | branch: master | Joseph Tulou <brezhoneg1 at yahoo.fr> | Mon Jan 26 18:12:20 2009 +0100| [7b84cea421f71b3c2885ae721511f465629ef21b] | committer: Jean-Baptiste Kempf 

Enabling scaling activation/deactivation

this patch adds a parameter ( --[no]-scaling) and a toggle hotkey ('o')
At fullscreen, it allows displaying a video at original size surrounded by a black screen.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7b84cea421f71b3c2885ae721511f465629ef21b
---

 include/vlc_keys.h           |    1 +
 modules/control/hotkeys.c    |    5 +++++
 src/libvlc-module.c          |   13 +++++++++++++
 src/video_output/vout_intf.c |   24 ++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index 210d107..f178831 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -309,6 +309,7 @@ typedef enum vlc_key {
     ACTIONID_DISC_MENU,
     ACTIONID_ASPECT_RATIO,
     ACTIONID_CROP,
+    ACTIONID_TOGGLE_SCALING,
     ACTIONID_DEINTERLACE,
     ACTIONID_ZOOM,
     ACTIONID_UNZOOM,
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index d531106..f9c973c 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -609,6 +609,11 @@ static void Run( intf_thread_t *p_intf )
                 }
                 free( val.psz_string );
             }
+            else if( i_action == ACTIONID_TOGGLE_SCALING && p_vout )
+            {
+                bool b_scaling = var_GetBool( p_vout, "scaling" );
+                var_SetBool( p_vout, "scaling", !b_scaling );
+            }
             else if( i_action == ACTIONID_DEINTERLACE && p_vout )
             {
                 vlc_value_t val={0}, val_list, text_list;
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index fa8071c..e88aab8 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -510,6 +510,10 @@ static const char *const ppsz_pos_descriptions[] =
     "aspect, or a float value (1.25, 1.3333, etc.) expressing pixel " \
     "squareness.")
 
+#define SCALING_TEXT N_("Video scaling")
+#define SCALING_LONGTEXT N_( \
+    "This enables upscaling a video in a given window.")
+
 #define CUSTOM_CROP_RATIOS_TEXT N_("Custom crop ratios list")
 #define CUSTOM_CROP_RATIOS_LONGTEXT N_( \
     "Comma seperated list of crop ratios which will be added in the " \
@@ -1344,6 +1348,8 @@ static const char *const ppsz_albumart_descriptions[] =
 #define ASPECT_RATIO_KEY_LONGTEXT N_("Cycle through a predefined list of source aspect ratios.")
 #define CROP_KEY_TEXT N_("Cycle video crop")
 #define CROP_KEY_LONGTEXT N_("Cycle through a predefined list of crop formats.")
+#define TOGGLE_SCALING_KEY_TEXT N_("Toggle upscaling")
+#define TOGGLE_SCALING_KEY_LONGTEXT N_("Activate or deactivate upscaling.")
 #define DEINTERLACE_KEY_TEXT N_("Cycle deinterlace modes")
 #define DEINTERLACE_KEY_LONGTEXT N_("Cycle through deinterlace modes.")
 #define INTF_SHOW_KEY_TEXT N_("Show interface")
@@ -1598,6 +1604,8 @@ vlc_module_begin ()
     add_string( "aspect-ratio", NULL, NULL,
                 ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, false );
         change_safe ()
+    add_bool( "scaling", true, NULL, SCALING_TEXT, SCALING_LONGTEXT, false )
+        change_safe ()
     add_string( "monitor-par", NULL, NULL,
                 MASPECT_RATIO_TEXT, MASPECT_RATIO_LONGTEXT, true );
     add_string( "custom-aspect-ratios", NULL, NULL, CUSTOM_ASPECT_RATIOS_TEXT,
@@ -2125,6 +2133,7 @@ vlc_module_begin ()
 #   define KEY_SUBTITLE_TRACK     's'
 #   define KEY_ASPECT_RATIO       'a'
 #   define KEY_CROP               'c'
+#   define KEY_TOGGLE_SCALING     'o'
 #   define KEY_DEINTERLACE        'd'
 #   define KEY_INTF_SHOW          'i'
 #   define KEY_INTF_HIDE          KEY_MODIFIER_SHIFT|'i'
@@ -2236,6 +2245,7 @@ vlc_module_begin ()
 #   define KEY_SUBTITLE_TRACK     'v'
 #   define KEY_ASPECT_RATIO       'a'
 #   define KEY_CROP               'c'
+#   define KEY_TOGGLE_SCALING     'o'
 #   define KEY_DEINTERLACE        'd'
 #   define KEY_INTF_SHOW          'i'
 #   define KEY_INTF_HIDE          KEY_MODIFIER_SHIFT|'i'
@@ -2393,6 +2403,8 @@ vlc_module_begin ()
              ASPECT_RATIO_KEY_TEXT, ASPECT_RATIO_KEY_LONGTEXT, false );
     add_key( "key-crop", KEY_CROP, NULL,
              CROP_KEY_TEXT, CROP_KEY_LONGTEXT, false );
+    add_key( "key-toggle-scaling", KEY_TOGGLE_SCALING, NULL,
+             TOGGLE_SCALING_KEY_TEXT, TOGGLE_SCALING_KEY_LONGTEXT, false );
     add_key( "key-deinterlace", KEY_DEINTERLACE, NULL,
              DEINTERLACE_KEY_TEXT, DEINTERLACE_KEY_LONGTEXT, false );
     add_key( "key-intf-show", KEY_INTF_SHOW, NULL,
@@ -2669,6 +2681,7 @@ const struct hotkey libvlc_hotkeys[] =
     { "key-subtitle-track", ACTIONID_SUBTITLE_TRACK, 0, },
     { "key-aspect-ratio", ACTIONID_ASPECT_RATIO, 0, },
     { "key-crop", ACTIONID_CROP, 0, },
+    { "key-toggle-scaling", ACTIONID_TOGGLE_SCALING, 0, },
     { "key-deinterlace", ACTIONID_DEINTERLACE, 0, },
     { "key-intf-show", ACTIONID_INTF_SHOW, 0, },
     { "key-intf-hide", ACTIONID_INTF_HIDE, 0, },
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index dccbc7e..d008606 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -65,6 +65,8 @@ static int CropCallback( vlc_object_t *, char const *,
                          vlc_value_t, vlc_value_t, void * );
 static int AspectCallback( vlc_object_t *, char const *,
                            vlc_value_t, vlc_value_t, void * );
+static int ScalingCallback( vlc_object_t *, char const *,
+                            vlc_value_t, vlc_value_t, void * );
 static int OnTopCallback( vlc_object_t *, char const *,
                           vlc_value_t, vlc_value_t, void * );
 static int FullscreenCallback( vlc_object_t *, char const *,
@@ -397,6 +399,15 @@ void vout_IntfInit( vout_thread_t *p_vout )
         var_TriggerCallback( p_vout, "aspect-ratio" );
     free( old_val.psz_string );
 
+    /* Add a variable to indicate if scaling video is activated or not */
+    var_Create( p_vout, "scaling", VLC_VAR_BOOL | VLC_VAR_DOINHERIT
+                | VLC_VAR_ISCOMMAND );
+    text.psz_string = _("Scaling video");
+    var_Change( p_vout, "scaling", VLC_VAR_SETTEXT, &text, NULL );
+    var_AddCallback( p_vout, "scaling", ScalingCallback, NULL );
+    var_Get( p_vout, "scaling", &val );
+    p_vout->b_scale = val.b_bool;
+
     /* Initialize the dimensions of the video window */
     InitWindowSize( p_vout, &p_vout->i_window_width,
                     &p_vout->i_window_height );
@@ -1199,6 +1210,19 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
     return i_ret;
 }
 
+static int ScalingCallback( vlc_object_t *p_this, char const *psz_cmd,
+                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    vout_thread_t *p_vout = (vout_thread_t *)p_this;
+
+    vlc_mutex_lock( &p_vout->change_lock );
+
+    p_vout->b_scale = newval.b_bool;
+    p_vout->i_changes |= VOUT_SIZE_CHANGE;
+
+    vlc_mutex_unlock( &p_vout->change_lock );
+}
+
 static int OnTopCallback( vlc_object_t *p_this, char const *psz_cmd,
                          vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {




More information about the vlc-devel mailing list