[vlc-commits] commit: Add adjust filter features to libvlc_media_player/libvlc_video ( Frank Enderle )
git at videolan.org
git at videolan.org
Thu Jun 24 02:17:47 CEST 2010
vlc | branch: master | Frank Enderle <frank.enderle at anamica.de> | Thu Jun 24 03:16:04 2010 +0300| [a8fbe67ffbd0299169317074bdab82a84d35dc3b] | committer: 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: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a8fbe67ffbd0299169317074bdab82a84d35dc3b
---
include/vlc/libvlc_media_player.h | 52 +++++++++++++++++++++
src/control/media_player.c | 6 +++
src/control/video.c | 90 +++++++++++++++++++++++++++++++++++++
src/libvlc.sym | 6 +++
4 files changed, 154 insertions(+), 0 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 7881971..0c1a4ef 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -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 );
+/** 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 */
/** \defgroup libvlc_audio LibVLC audio controls
diff --git a/src/control/media_player.c b/src/control/media_player.c
index 5b33293..a9104ee 100644
--- a/src/control/media_player.c
+++ b/src/control/media_player.c
@@ -411,6 +411,12 @@ libvlc_media_player_new( libvlc_instance_t *instance )
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, "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 */
var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
var_Create (mp, "volume-muted", VLC_VAR_BOOL);
diff --git a/src/control/video.c b/src/control/video.c
index ebdafa1..09070e3 100644
--- a/src/control/video.c
+++ b/src/control/video.c
@@ -672,6 +672,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
set_string( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, const char *restrict psz_value )
{
@@ -821,3 +861,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) );
+}
diff --git a/src/libvlc.sym b/src/libvlc.sym
index d46a177..0cddd65 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -162,6 +162,9 @@ libvlc_set_log_verbosity
libvlc_toggle_fullscreen
libvlc_toggle_teletext
libvlc_track_description_release
+libvlc_video_get_adjust_bool
+libvlc_video_get_adjust_float
+libvlc_video_get_adjust_int
libvlc_video_get_aspect_ratio
libvlc_video_get_chapter_description
libvlc_video_get_crop_geometry
@@ -181,6 +184,9 @@ libvlc_video_get_track
libvlc_video_get_track_count
libvlc_video_get_track_description
libvlc_video_get_width
+libvlc_video_set_adjust_bool
+libvlc_video_set_adjust_float
+libvlc_video_set_adjust_int
libvlc_video_set_aspect_ratio
libvlc_video_set_crop_geometry
libvlc_video_set_deinterlace
More information about the vlc-commits
mailing list