diff -ur mplayer-cvs/libmpcodecs/vf_eq2.c mplayer-dev/libmpcodecs/vf_eq2.c --- mplayer-cvs/libmpcodecs/vf_eq2.c 2003-03-17 21:53:02.000000000 +0100 +++ mplayer-dev/libmpcodecs/vf_eq2.c 2003-10-15 10:35:31.000000000 +0200 @@ -21,6 +21,9 @@ #include "mp_image.h" #include "vf.h" +#include "m_option.h" +#include "m_struct.h" + #ifdef USE_SETLOCALE #include #endif @@ -40,8 +43,6 @@ } eq2_param_t; typedef struct vf_priv_s { - eq2_param_t param[3]; - double contrast; double brightness; double saturation; @@ -51,12 +52,26 @@ double ggamma; double bgamma; + eq2_param_t param[3]; + unsigned buf_w[3]; unsigned buf_h[3]; unsigned char *buf[3]; } vf_eq2_t; +static vf_eq2_t vf_eq2_dflt = { + 1.0, + 0.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + /* remaining fields are initialized at run time */ +}; + + static void create_lut (eq2_param_t *par) { @@ -396,14 +411,17 @@ { unsigned i; vf_eq2_t *eq2; - double par[7]; vf->control = control; vf->query_format = query_format; vf->put_image = put_image; vf->uninit = uninit; - vf->priv = (vf_eq2_t *) malloc (sizeof (vf_eq2_t)); + if (vf->priv == NULL) { + vf->priv = (vf_eq2_t *) malloc (sizeof (vf_eq2_t)); + memcpy (vf->priv, &vf_eq2_dflt, sizeof (vf_eq2_t)); + } + eq2 = vf->priv; for (i = 0; i < 3; i++) { @@ -418,16 +436,9 @@ eq2->param[i].lut_clean = 0; } - eq2->contrast = 1.0; - eq2->brightness = 0.0; - eq2->saturation = 1.0; - - eq2->gamma = 1.0; - eq2->rgamma = 1.0; - eq2->ggamma = 1.0; - eq2->bgamma = 1.0; - if (args != NULL) { + double par[7]; + par[0] = 1.0; par[1] = 1.0; par[2] = 0.0; @@ -445,24 +456,48 @@ setlocale (LC_NUMERIC, ""); #endif + eq2->gamma = par[0]; + eq2->brightness = par[1]; + eq2->contrast = par[2]; + eq2->saturation = par[3]; + eq2->rgamma = par[4]; eq2->ggamma = par[5]; eq2->bgamma = par[6]; - - set_gamma (eq2, par[0]); - set_contrast (eq2, par[1]); - set_brightness (eq2, par[2]); - set_saturation (eq2, par[3]); } + set_gamma (eq2, eq2->gamma); + set_contrast (eq2, eq2->contrast); + set_brightness (eq2, eq2->brightness); + set_saturation (eq2, eq2->saturation); + return 1; } +#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) +static m_option_t vf_opts_fields[] = { + {"gamma", ST_OFF(gamma), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.001, 1000.0, NULL}, + {"brightness", ST_OFF(brightness), CONF_TYPE_DOUBLE, 0, 0.0, 0.0, NULL}, + {"contrast", ST_OFF(contrast), CONF_TYPE_DOUBLE, 0, 0.0, 0.0, NULL}, + {"saturation", ST_OFF(saturation), CONF_TYPE_DOUBLE, M_OPT_MIN, 0.0, 0.0, NULL}, + {"gamma_red", ST_OFF(rgamma), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.001, 1000.0, NULL}, + {"gamma_green", ST_OFF(ggamma), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.001, 1000.0, NULL}, + {"gamma_blue", ST_OFF(bgamma), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.001, 1000.0, NULL}, + { NULL, NULL, 0, 0, 0, 0, NULL } +}; + +static m_struct_t vf_opts = { + "eq2", + sizeof (vf_eq2_t), + &vf_eq2_dflt, + vf_opts_fields +}; + vf_info_t vf_info_eq2 = { "Software equalizer", "eq2", "Hampa Hug, Daniel Moreno, Richard Felker", "", &open, - NULL + &vf_opts }; diff -ur mplayer-cvs/m_option.c mplayer-dev/m_option.c --- mplayer-cvs/m_option.c 2003-09-05 18:31:33.000000000 +0200 +++ mplayer-dev/m_option.c 2003-10-15 08:03:01.000000000 +0200 @@ -243,6 +243,49 @@ NULL }; + +// Double + +#undef VAL +#define VAL(x) (*(double*)(x)) + +static +int parse_double (m_option_t *opt, char *name, char *param, void *dst, int src) +{ + int r; + float val; + + /* parse_double() calls parse_float(). better would be the other way around. */ + r = parse_float (opt, name, param, &val, src); + + if ((r == 1) && (dst != NULL)) { + VAL(dst) = val; + } + + return (r); +} + +static +char *print_double (m_option_t *opt, void *val) +{ + opt = NULL; + return dup_printf ("%f", VAL(val)); +} + +m_option_type_t m_option_type_double = { + "Double", + "floating point number or ratio (numerator[:/]denominator)", + sizeof(double), + 0, + parse_double, + print_double, + copy_opt, + copy_opt, + NULL, + NULL +}; + + ///////////// Position #undef VAL #define VAL(x) (*(off_t*)(x)) diff -ur mplayer-cvs/m_option.h mplayer-dev/m_option.h --- mplayer-cvs/m_option.h 2003-08-27 01:49:19.000000000 +0200 +++ mplayer-dev/m_option.h 2003-10-14 14:05:54.000000000 +0200 @@ -11,6 +11,7 @@ extern m_option_type_t m_option_type_flag; extern m_option_type_t m_option_type_int; extern m_option_type_t m_option_type_float; +extern m_option_type_t m_option_type_double; extern m_option_type_t m_option_type_string; extern m_option_type_t m_option_type_string_list; extern m_option_type_t m_option_type_position; @@ -78,6 +79,7 @@ #define CONF_TYPE_FLAG (&m_option_type_flag) #define CONF_TYPE_INT (&m_option_type_int) #define CONF_TYPE_FLOAT (&m_option_type_float) +#define CONF_TYPE_DOUBLE (&m_option_type_double) #define CONF_TYPE_STRING (&m_option_type_string) #define CONF_TYPE_FUNC (&m_option_type_func) #define CONF_TYPE_FUNC_PARAM (&m_option_type_func_param)