[vlc-devel] [PATCH] Implementation of hotkeys option to make movie rotation( 90, 180, 270 degrees + flip horizontal/vertical + transpose/antitranspose) possible during playback.
Stefanos Orovas
stef.orovas at gmail.com
Tue Dec 17 15:53:58 CET 2013
Hi, first of all thanks for the warnings and sorry for the code, it is my
first attempt to join the vlc project.
That's a lot of keys. I think it would make more sense to have a single
> key iterating through the different modes
>
I think you are right. Maybe the right way would be to create one hotkey
for all the transformations. I have changed it to one hotkey that iterates
through the possible transform types (90, 180, 270, hflip, vflip,
transpose, antitranspose). I didn't send the patch because i need some help
with the following warning you sent me.
-----------------------------------------------------------------------------------------------------------------------------------
var_SetString( p_vout, "video-filter", "transform");
config_PutPsz( p_intf, "video-filter", "transform");
I realized that if there more than one filter then the "video-filter"
string puts all the filters separated with ":". For example if there are
puzzle, adjust and transform applied then if i use *char *video_filter =
var_GetString(p_vout,"video-filter");* then *video_filter* gets the value
"puzzle:adjust:transform".
So i understand that just putting *var_SetString( p_vout, "video-filter",
"transform"); *will change the whole configuration. So i will try to pass
the correct string to the function *var_SetString *and *config_PutPsz. *
Are my thoughts right? Or are there any other problems that i didn't notice
about the use of *var_SetString* and *config_PutPsz* functions?
Thanks again for the help!
2013/12/13 Rémi Denis-Courmont <remi at remlab.net>
> On Fri, 13 Dec 2013 18:15:03 +0200, Stefanos Orovas
> <stef.orovas at gmail.com>
> wrote:
> > From: Stefanos Orovas <stef.orovas at gmail.com>
> >
> > ---
> > include/vlc_keys.h | 8 ++
> > modules/control/hotkeys.c | 100
> > +++++++++++++++++++++++-
> > modules/gui/qt4/components/extended_panels.cpp | 13 +--
> > src/config/core.c | 3 +-
> > src/config/keys.c | 7 ++
> > src/libvlc-module.c | 46 +++++++++++
> > 6 files changed, 165 insertions(+), 12 deletions(-)
> >
> > diff --git a/include/vlc_keys.h b/include/vlc_keys.h
> > index aafa589..6c015c2 100644
> > --- a/include/vlc_keys.h
> > +++ b/include/vlc_keys.h
> > @@ -204,6 +204,14 @@ typedef enum vlc_action {
> > ACTIONID_LOOP,
> > ACTIONID_WALLPAPER,
> > ACTIONID_LEAVE_FULLSCREEN,
> > + /* Transform */
> > + ACTIONID_ROTATE_90_DEGREES,
> > + ACTIONID_ROTATE_180_DEGREES,
> > + ACTIONID_ROTATE_270_DEGREES,
> > + ACTIONID_FLIP_HORIZONTALLY,
> > + ACTIONID_FLIP_VERTICALLY,
> > + ACTIONID_TRANSPOSE,
> > + ACTIONID_ANTITRANSPOSE,
> > /* Zoom */
> > ACTIONID_ZOOM_QUARTER,
> > ACTIONID_ZOOM_HALF,
> > diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
> > index ec21bec..b0d60c0 100644
> > --- a/modules/control/hotkeys.c
> > +++ b/modules/control/hotkeys.c
> > @@ -877,7 +877,105 @@ static int PutAction( intf_thread_t *p_intf, int
> > i_action )
> > var_SetFloat( p_vout, "scale", f_scalefactor );
> > }
> > break;
> > -
> > + case ACTIONID_ROTATE_90_DEGREES:
> > + if( p_vout )
> > + {
> > + char *video_filter = var_GetString(p_vout,"video-filter");
> > + char *transform_type = config_GetPsz(p_vout,
> "transform-type");
> > + if (strcmp(video_filter,"transform") == 0 &&
>
> This won't work. There could be more than one video filter, including
> transform. And it will crash if there are no filters.
>
> > strcmp(transform_type,"90") == 0) { // already transformed
> > + var_SetString( p_vout, "video-filter", "");
>
> Same problem here.
>
> > + } else {
> > + config_PutPsz( p_intf, "transform-type", "90");
> > + config_PutPsz( p_intf, "video-filter", "transform");
>
> This will clobber the configuration. Please don't do this.
>
> > + var_SetString( p_vout, "video-filter", "transform");
> > + // vlc_object_release( p_vout );
> > + }
>
> And then, the code is highly repetitive. Please refactor.
>
> > + }
> > + break;
> > + case ACTIONID_ROTATE_180_DEGREES:
> > + if( p_vout )
> > + {
> > + char *video_filter = var_GetString(p_vout,"video-filter");
> > + char *transform_type = config_GetPsz(p_vout,
> "transform-type");
> > + if (strcmp(video_filter,"transform") == 0 &&
> > strcmp(transform_type,"180") == 0) { // already transformed
> > + var_SetString( p_vout, "video-filter", "");
> > + } else {
> > + config_PutPsz( p_intf, "transform-type", "180");
> > + config_PutPsz( p_intf, "video-filter", "transform");
> > + var_SetString( p_vout, "video-filter", "transform");
> > + }
> > + }
> > + break;
> > + case ACTIONID_ROTATE_270_DEGREES:
> > + if( p_vout )
> > + {
> > + char *video_filter = var_GetString(p_vout,"video-filter");
> > + char *transform_type = config_GetPsz(p_vout,
> "transform-type");
> > + if (strcmp(video_filter,"transform") == 0 &&
> > strcmp(transform_type,"270") == 0) { // already transformed
> > + var_SetString( p_vout, "video-filter", "");
> > + } else {
> > + config_PutPsz( p_intf, "transform-type", "270");
> > + config_PutPsz( p_intf, "video-filter",
> "transform");
> > + var_SetString( p_vout, "video-filter",
> "transform");
> > + }
> > + }
> > + break;
> > + case ACTIONID_FLIP_HORIZONTALLY:
> > + if( p_vout )
> > + {
> > + char *video_filter = var_GetString(p_vout,"video-filter");
> > + char *transform_type = config_GetPsz(p_vout,
> "transform-type");
> > + if (strcmp(video_filter,"transform") == 0 &&
> > strcmp(transform_type,"hflip") == 0) { // already transformed
> > + var_SetString( p_vout, "video-filter", "");
> > + } else {
> > + config_PutPsz( p_intf, "transform-type", "hflip");
> > + config_PutPsz( p_intf, "video-filter",
> "transform");
> > + var_SetString( p_vout, "video-filter",
> "transform");
> > + }
> > + }
> > + break;
> > + case ACTIONID_FLIP_VERTICALLY:
> > + if( p_vout )
> > + {
> > + char *video_filter = var_GetString(p_vout,"video-filter");
> > + char *transform_type = config_GetPsz(p_vout,
> "transform-type");
> > + if (strcmp(video_filter,"transform") == 0 &&
> > strcmp(transform_type,"vflip") == 0) { // already transformed
> > + var_SetString( p_vout, "video-filter", "");
> > + } else {
> > + config_PutPsz( p_intf, "transform-type", "vflip");
> > + config_PutPsz( p_intf, "video-filter",
> "transform");
> > + var_SetString( p_vout, "video-filter",
> "transform");
> > + }
> > + }
> > + break;
> > + case ACTIONID_TRANSPOSE:
> > + if( p_vout )
> > + {
> > + char *video_filter = var_GetString(p_vout,"video-filter");
> > + char *transform_type = config_GetPsz(p_vout,
> "transform-type");
> > + if (strcmp(video_filter,"transform") == 0 &&
> > strcmp(transform_type,"transpose") == 0) { // already transformed
> > + var_SetString( p_vout, "video-filter", "");
> > + } else {
> > + config_PutPsz( p_intf, "transform-type",
> "transpose");
> > + config_PutPsz( p_intf, "video-filter",
> "transform");
> > + var_SetString( p_vout, "video-filter",
> "transform");
> > + }
> > + }
> > + break;
> > + case ACTIONID_ANTITRANSPOSE:
> > + if( p_vout )
> > + {
> > + char *video_filter = var_GetString(p_vout,"video-filter");
> > + char *transform_type = config_GetPsz(p_vout,
> "transform-type");
> > + if (strcmp(video_filter,"transform") == 0 &&
> > strcmp(transform_type,"antitranspose") == 0) { // already transformed
> > + var_SetString( p_vout, "video-filter", "");
> > + } else {
> > + config_PutPsz( p_intf, "transform-type",
> > "antitranspose");
> > + config_PutPsz( p_intf, "video-filter",
> "transform");
> > + var_SetString( p_vout, "video-filter",
> "transform");
> > + }
> > + }
> > + break;
> > case ACTIONID_ZOOM_QUARTER:
> > case ACTIONID_ZOOM_HALF:
> > case ACTIONID_ZOOM_ORIGINAL:
> > diff --git a/modules/gui/qt4/components/extended_panels.cpp
> > b/modules/gui/qt4/components/extended_panels.cpp
> > index 3604034..6e8545a 100644
> > --- a/modules/gui/qt4/components/extended_panels.cpp
> > +++ b/modules/gui/qt4/components/extended_panels.cpp
> > @@ -358,7 +358,6 @@ static void ChangeVFiltersString( struct
> intf_thread_t
> > *p_intf, const char *psz_
> > {
> > char *psz_string;
> > const char *psz_filter_type;
> > -
> > module_t *p_obj = module_find( psz_name );
> > if( !p_obj )
> > {
> > @@ -387,11 +386,9 @@ static void ChangeVFiltersString( struct
> > intf_thread_t *p_intf, const char *psz_
> > msg_Err( p_intf, "Unknown video filter type." );
> > return;
> > }
> > -
> > psz_string = ChangeFiltersString( p_intf, psz_filter_type,
> psz_name,
> > b_add );
> > if( !psz_string )
> > return;
> > -
> > /* Vout is not kept, so put that in the config */
> > config_PutPsz( p_intf, psz_filter_type, psz_string );
> >
> > @@ -499,9 +496,7 @@ void ExtVideo::initComboBoxItems( QObject *widget )
> > void ExtVideo::setWidgetValue( QObject *widget )
> > {
> > QString module = ModuleFromWidgetName( widget->parent() );
> > - //std::cout << "Module name: " << module.toStdString() <<
> std::endl;
> > QString option = OptionFromWidgetName( widget );
> > - //std::cout << "Option name: " << option.toStdString() <<
> std::endl;
> >
> > vlc_object_t *p_obj = ( vlc_object_t * )
> > vlc_object_find_name( p_intf->p_libvlc, qtu( module ) );
> > @@ -591,9 +586,9 @@ void ExtVideo::setWidgetValue( QObject *widget )
> > void ExtVideo::updateFilterOptions()
> > {
> > QString module = ModuleFromWidgetName( sender()->parent() );
> > - //msg_Dbg( p_intf, "Module name: %s", qtu( module ) );
> > + msg_Dbg( p_intf, "Module name: %s", qtu( module ) );
> > QString option = OptionFromWidgetName( sender() );
> > - //msg_Dbg( p_intf, "Option name: %s", qtu( option ) );
> > + msg_Dbg( p_intf, "Option name: %s", qtu( option ) );
> >
> > vlc_object_t *p_obj = ( vlc_object_t * )
> > vlc_object_find_name( p_intf->p_libvlc, qtu( module ) );
> > @@ -681,8 +676,8 @@ void ExtVideo::updateFilterOptions()
> > msg_Warn( p_intf, "Module %s's %s variable isn't a command.
> > Brute-restarting the filter.",
> > qtu( module ),
> > qtu( option ) );
> > - ChangeVFiltersString( p_intf, qtu( module ), false );
> > - ChangeVFiltersString( p_intf, qtu( module ), true );
> > + ChangeVFiltersString( p_intf, qtu( module ), false );
> > + ChangeVFiltersString( p_intf, qtu( module ), true );
> > }
> >
> > if( p_obj ) vlc_object_release( p_obj );
> > diff --git a/src/config/core.c b/src/config/core.c
> > index 9882c52..6e85fa5 100644
> > --- a/src/config/core.c
> > +++ b/src/config/core.c
> > @@ -218,10 +218,9 @@ void config_PutPsz( vlc_object_t *p_this,
> > const char *psz_name, const char *psz_value )
> > {
> > module_config_t *p_config;
> > -
> > +
> > p_config = config_FindConfig( p_this, psz_name );
> >
> > -
> > /* sanity checks */
> > if( !p_config )
> > {
> > diff --git a/src/config/keys.c b/src/config/keys.c
> > index 07c0d75..aa20d5a 100644
> > --- a/src/config/keys.c
> > +++ b/src/config/keys.c
> > @@ -270,6 +270,7 @@ struct action
> > static const struct action actions[] =
> > {
> > /* *MUST* be sorted (ASCII order) */
> > + { "antitranspose", ACTIONID_ANTITRANSPOSE, },
> > { "aspect-ratio", ACTIONID_ASPECT_RATIO, },
> > { "audio-track", ACTIONID_AUDIO_TRACK, },
> > { "audiodelay-down", ACTIONID_AUDIODELAY_DOWN, },
> > @@ -288,6 +289,8 @@ static const struct action actions[] =
> > { "deinterlace-mode", ACTIONID_DEINTERLACE_MODE, },
> > { "disc-menu", ACTIONID_DISC_MENU, },
> > { "faster", ACTIONID_FASTER, },
> > + { "flip-horizontally", ACTIONID_FLIP_HORIZONTALLY, },
> > + { "flip-vertically", ACTIONID_FLIP_VERTICALLY, },
> > { "frame-next", ACTIONID_FRAME_NEXT, },
> > { "incr-scalefactor", ACTIONID_SCALE_UP, },
> > { "intf-boss", ACTIONID_INTF_BOSS, },
> > @@ -332,6 +335,9 @@ static const struct action actions[] =
> > { "rate-normal", ACTIONID_RATE_NORMAL, },
> > { "rate-slower-fine", ACTIONID_RATE_SLOWER_FINE, },
> > { "record", ACTIONID_RECORD, },
> > + { "rotate-180-degrees", ACTIONID_ROTATE_180_DEGREES, },
> > + { "rotate-270-degrees", ACTIONID_ROTATE_270_DEGREES, },
> > + { "rotate-90-degrees", ACTIONID_ROTATE_90_DEGREES, },
> > { "set-bookmark1", ACTIONID_SET_BOOKMARK1, },
> > { "set-bookmark10", ACTIONID_SET_BOOKMARK10, },
> > { "set-bookmark2", ACTIONID_SET_BOOKMARK2, },
> > @@ -358,6 +364,7 @@ static const struct action actions[] =
> > { "title-prev", ACTIONID_TITLE_PREV, },
> > { "toggle-autoscale", ACTIONID_TOGGLE_AUTOSCALE, },
> > { "toggle-fullscreen", ACTIONID_TOGGLE_FULLSCREEN, },
> > + { "transpose", ACTIONID_TRANSPOSE, },
> > { "uncrop-bottom", ACTIONID_UNCROP_BOTTOM, },
> > { "uncrop-left", ACTIONID_UNCROP_LEFT, },
> > { "uncrop-right", ACTIONID_UNCROP_RIGHT, },
> > diff --git a/src/libvlc-module.c b/src/libvlc-module.c
> > index 7c7126a..045236d 100644
> > --- a/src/libvlc-module.c
> > +++ b/src/libvlc-module.c
> > @@ -1321,6 +1321,27 @@ static const char *const mouse_wheel_texts[] =
> > #define AUDIODELAY_DOWN_KEY_TEXT N_("Audio delay down")
> > #define AUDIODELAY_DOWN_KEY_LONGTEXT N_("Select the key to decrease the
> > audio delay.")
> >
> > +#define ROTATE_90_DEGREES_TEXT N_("Rotate video 90 degrees")
> > +#define ROTATE_90_DEGREES_LONGTEXT N_("Select the key to rotate the
> video
> > by 90 degrees.")
> > +
> > +#define ROTATE_180_DEGREES_TEXT N_("Rotate video 180 degrees")
> > +#define ROTATE_180_DEGREES_LONGTEXT N_("Select the key to rotate the
> > video by 180 degrees.")
> > +
> > +#define ROTATE_270_DEGREES_TEXT N_("Rotate video 270 degrees")
> > +#define ROTATE_270_DEGREES_LONGTEXT N_("Select the key to rotate the
> > video by 270 degrees.")
> > +
> > +#define FLIP_HORIZONTALLY_TEXT N_("Flip video horizontally")
> > +#define FLIP_HORIZONTALLY_LONGTEXT N_("Select the key to flip the video
> > horizontally.")
> > +
> > +#define FLIP_VERTICALLY_TEXT N_("Flip video vertically")
> > +#define FLIP_VERTICALLY_LONGTEXT N_("Select the key to flip the video
> > vertically.")
> > +
> > +#define TRANSPOSE_TEXT N_("Transpose video")
> > +#define TRANSPOSE_LONGTEXT N_("Select the key to transpose the video.")
> > +
> > +#define ANTITRANSPOSE_TEXT N_("Anti-transpose video")
> > +#define ANTITRANSPOSE_LONGTEXT N_("Select the key to anti-transpose the
> > video.")
> > +
> > #define ZOOM_QUARTER_KEY_TEXT N_("1:4 Quarter")
> > #define ZOOM_HALF_KEY_TEXT N_("1:2 Half")
> > #define ZOOM_ORIGINAL_KEY_TEXT N_("1:1 Original")
> > @@ -2354,6 +2375,16 @@ vlc_module_begin ()
> > # define KEY_CROP_RIGHT "Alt+f"
> > # define KEY_UNCROP_RIGHT "Alt+Shift+f"
> >
> > +/* Transforming */
> > +# define KEY_ROTATE_90_DEGREES "Alt+Ctrl+9"
> > +# define KEY_ROTATE_180_DEGREES "Alt+Ctrl+8"
> > +# define KEY_ROTATE_270_DEGREES "Alt+Ctrl+7"
> > +# define KEY_FLIP_HORIZONTALLY "Alt+Ctrl+6"
> > +# define KEY_FLIP_VERTICALLY "Alt+Ctrl+5"
> > +# define KEY_TRANSPOSE "Alt+Ctrl+4"
> > +# define KEY_ANTITRANSPOSE "Alt+Ctrl+3"
> > +
> > +
> > /* Zooming */
> > # define KEY_ZOOM_QUARTER "Alt+1"
> > # define KEY_ZOOM_HALF "Alt+2"
> > @@ -2544,6 +2575,21 @@ vlc_module_begin ()
> > RANDOM_KEY_TEXT, RANDOM_KEY_LONGTEXT, false )
> > add_key( "key-loop", KEY_LOOP,
> > LOOP_KEY_TEXT, LOOP_KEY_LONGTEXT, false )
> > +
> > + add_key( "key-rotate-90-degrees", KEY_ROTATE_90_DEGREES,
> > + ROTATE_90_DEGREES_TEXT, ROTATE_90_DEGREES_LONGTEXT, false)
> > + add_key( "key-rotate-180-degrees", KEY_ROTATE_180_DEGREES,
> > + ROTATE_180_DEGREES_TEXT, ROTATE_180_DEGREES_LONGTEXT,
> false )
> > + add_key( "key-rotate-270-degrees", KEY_ROTATE_270_DEGREES,
> > + ROTATE_270_DEGREES_TEXT, ROTATE_270_DEGREES_LONGTEXT,
> false )
> > + add_key( "key-flip-horizontally", KEY_FLIP_HORIZONTALLY,
> > + FLIP_HORIZONTALLY_TEXT, FLIP_HORIZONTALLY_LONGTEXT, false
> )
> > + add_key( "key-flip-vertically", KEY_FLIP_VERTICALLY,
> > + FLIP_VERTICALLY_TEXT, FLIP_VERTICALLY_LONGTEXT, false )
> > + add_key( "key-transpose", KEY_TRANSPOSE,
> > + TRANSPOSE_TEXT, TRANSPOSE_LONGTEXT, false )
> > + add_key( "key-antitranspose", KEY_ANTITRANSPOSE,
> > + ANTITRANSPOSE_TEXT, ANTITRANSPOSE_LONGTEXT, false )
>
> That's a lot of keys. I think it would make more sense to have a single
> key iterating through the different modes.
>
> >
> > set_section ( N_("Zoom" ), NULL )
> > add_key( "key-zoom-quarter", KEY_ZOOM_QUARTER,
>
> --
> Rémi Denis-Courmont
> Sent from my collocated server
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20131217/84acaf31/attachment.html>
More information about the vlc-devel
mailing list