Commit 14cd9a22 authored by Frank Enderle's avatar Frank Enderle Committed by Rémi Denis-Courmont

Add adjust filter features to libvlc_media_player/libvlc_video

This patch exposes the adjust module to libvlc_media_player/libvlc_video
and adds a frequently requested featureset: to manipulate brightness,
contrast, gamma, saturation and hue through libvlc. The patch introduces
a new set of functions analogous to
libvlc_video_{get,set}_{marq,logo}_*, hence the use of the function set
should be self explanatory.

New Functions:

* value = libvlc_video_get_adjust_int( p_mi, option );
* libvlc_video_set_adjust_int( p_mi, option, value );
* value = libvlc_video_get_adjust_float( p_mi, option );
* libvlc_video_set_adjust_float( p_mi, option, value );

New Options:

* libvlc_adjust_Enable
* libvlc_adjust_Contrast
* libvlc_adjust_Brightness
* libvlc_adjust_Hue
* libvlc_adjust_Saturation
* libvlc_adjust_Gamma
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
(cherry picked from commit a8fbe67ffbd0299169317074bdab82a84d35dc3b)

Fix symbols after [a8fbe67ffbd0299169317074bdab82a84d35dc3b]
parent 47473ed2
...@@ -925,6 +925,58 @@ VLC_PUBLIC_API void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi, ...@@ -925,6 +925,58 @@ VLC_PUBLIC_API void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
unsigned option, const char *psz_value ); unsigned option, const char *psz_value );
/** option values for libvlc_video_{get,set}_adjust_{int,float,bool} */
enum libvlc_video_adjust_option_t {
libvlc_adjust_Enable = 0,
libvlc_adjust_Contrast,
libvlc_adjust_Brightness,
libvlc_adjust_Hue,
libvlc_adjust_Saturation,
libvlc_adjust_Gamma,
};
/**
* Get integer adjust option.
*
* \param p_mi libvlc media player instance
* \param option adjust option to get, values of libvlc_video_adjust_option_t
*/
VLC_PUBLIC_API int libvlc_video_get_adjust_int( libvlc_media_player_t *p_mi,
unsigned option );
/**
* Set adjust option as integer. Options that take a different type value
* are ignored.
* Passing libvlc_adjust_enable as option value has the side effect of
* starting (arg !0) or stopping (arg 0) the adjust filter.
*
* \param p_mi libvlc media player instance
* \param option adust option to set, values of libvlc_video_adjust_option_t
* \param value adjust option value
*/
VLC_PUBLIC_API void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
unsigned option, int value );
/**
* Get float adjust option.
*
* \param p_mi libvlc media player instance
* \param option adjust option to get, values of libvlc_video_adjust_option_t
*/
VLC_PUBLIC_API float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
unsigned option );
/**
* Set adjust option as float. Options that take a different type value
* are ignored.
*
* \param p_mi libvlc media player instance
* \param option adust option to set, values of libvlc_video_adjust_option_t
* \param value adjust option value
*/
VLC_PUBLIC_API void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
unsigned option, float value );
/** @} video */ /** @} video */
/** \defgroup libvlc_audio LibVLC audio controls /** \defgroup libvlc_audio LibVLC audio controls
......
...@@ -415,6 +415,12 @@ libvlc_media_player_new( libvlc_instance_t *instance ) ...@@ -415,6 +415,12 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create (mp, "logo-opacity", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); var_Create (mp, "logo-opacity", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_Create (mp, "logo-position", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); var_Create (mp, "logo-position", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_Create (mp, "contrast", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
var_Create (mp, "brightness", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
var_Create (mp, "hue", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_Create (mp, "saturation", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
var_Create (mp, "gamma", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
/* Audio */ /* Audio */
var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT); var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
var_Create (mp, "volume-muted", VLC_VAR_BOOL); var_Create (mp, "volume-muted", VLC_VAR_BOOL);
......
...@@ -669,6 +669,46 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -669,6 +669,46 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name,
} }
static void
set_float( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, float value )
{
if( !opt ) return;
if( opt->type != VLC_VAR_FLOAT )
{
libvlc_printerr( "Invalid argument to %s in %s", name, "set float" );
return;
}
var_SetFloat( p_mi, opt->name, value );
vlc_object_t *object = get_object( p_mi, name );
if( object )
{
var_SetFloat(object, opt->name, value );
vlc_object_release( object );
}
}
static float
get_float( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt )
{
if( !opt ) return 0.0;
if( opt->type != VLC_VAR_FLOAT )
{
libvlc_printerr( "Invalid argument to %s in %s", name, "get float" );
return 0.0;
}
return var_GetFloat( p_mi, opt->name );
}
static void static void
set_string( libvlc_media_player_t *p_mi, const char *restrict name, set_string( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, const char *restrict psz_value ) const opt_t *restrict opt, const char *restrict psz_value )
...@@ -819,3 +859,53 @@ int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi, ...@@ -819,3 +859,53 @@ int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
} }
/* adjust module support */
static opt_t *
adjust_option_bynumber( unsigned option )
{
static const opt_t optlist[] =
{
{ "adjust", 0 },
{ "contrast", VLC_VAR_FLOAT },
{ "brightness", VLC_VAR_FLOAT },
{ "hue", VLC_VAR_INTEGER },
{ "saturation", VLC_VAR_FLOAT },
{ "gamma", VLC_VAR_FLOAT },
};
enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
opt_t *r = option < num_opts ? optlist+option : NULL;
if( !r )
libvlc_printerr( "Unknown adjust option" );
return r;
}
void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
unsigned option, int value )
{
set_int( p_mi, "adjust", adjust_option_bynumber(option), value );
}
int libvlc_video_get_adjust_int( libvlc_media_player_t *p_mi,
unsigned option )
{
return get_int( p_mi, "adjust", adjust_option_bynumber(option) );
}
void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
unsigned option, float value )
{
set_float( p_mi, "adjust", adjust_option_bynumber(option), value );
}
float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
unsigned option )
{
return get_float( p_mi, "adjust", adjust_option_bynumber(option) );
}
...@@ -162,6 +162,8 @@ libvlc_set_log_verbosity ...@@ -162,6 +162,8 @@ libvlc_set_log_verbosity
libvlc_toggle_fullscreen libvlc_toggle_fullscreen
libvlc_toggle_teletext libvlc_toggle_teletext
libvlc_track_description_release libvlc_track_description_release
libvlc_video_get_adjust_float
libvlc_video_get_adjust_int
libvlc_video_get_aspect_ratio libvlc_video_get_aspect_ratio
libvlc_video_get_chapter_description libvlc_video_get_chapter_description
libvlc_video_get_crop_geometry libvlc_video_get_crop_geometry
...@@ -181,6 +183,8 @@ libvlc_video_get_track ...@@ -181,6 +183,8 @@ libvlc_video_get_track
libvlc_video_get_track_count libvlc_video_get_track_count
libvlc_video_get_track_description libvlc_video_get_track_description
libvlc_video_get_width libvlc_video_get_width
libvlc_video_set_adjust_float
libvlc_video_set_adjust_int
libvlc_video_set_aspect_ratio libvlc_video_set_aspect_ratio
libvlc_video_set_crop_geometry libvlc_video_set_crop_geometry
libvlc_video_set_deinterlace libvlc_video_set_deinterlace
......
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