diff options
author | wm4 <wm4@nowhere> | 2013-09-30 00:31:10 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-09-30 00:45:58 +0200 |
commit | 00d41cc5b065cc809ab64901aca3dcaae8035869 (patch) | |
tree | bd7bdfd1ece9ee986f6429d4d998e0e2d20db5c9 | |
parent | 9488d312c11ab1b4267b33eb85adcb28b25a45ba (diff) | |
download | mpv-00d41cc5b065cc809ab64901aca3dcaae8035869.tar.bz2 mpv-00d41cc5b065cc809ab64901aca3dcaae8035869.tar.xz |
vf_scale: factor out libswscale equalizer control
Will be used by vo_x11.
-rw-r--r-- | video/filter/vf_scale.c | 25 | ||||
-rw-r--r-- | video/sws_utils.c | 28 | ||||
-rw-r--r-- | video/sws_utils.h | 4 |
3 files changed, 34 insertions, 23 deletions
diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index 618460965a..3184194a33 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -353,37 +353,16 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) static int control(struct vf_instance *vf, int request, void *data) { - int r; - vf_equalizer_t *eq; struct mp_sws_context *sws = vf->priv->sws; switch (request) { case VFCTRL_GET_EQUALIZER: - eq = data; - if (!strcmp(eq->item, "brightness")) - eq->value = ((sws->brightness * 100) + (1 << 15)) >> 16; - else if (!strcmp(eq->item, "contrast")) - eq->value = (((sws->contrast * 100) + (1 << 15)) >> 16) - 100; - else if (!strcmp(eq->item, "saturation")) - eq->value = (((sws->saturation * 100) + (1 << 15)) >> 16) - 100; - else + if (mp_sws_get_vf_equalizer(sws, data) < 1) break; return CONTROL_TRUE; case VFCTRL_SET_EQUALIZER: - eq = data; - if (!strcmp(eq->item, "brightness")) - sws->brightness = ((eq->value << 16) + 50) / 100; - else if (!strcmp(eq->item, "contrast")) - sws->contrast = (((eq->value + 100) << 16) + 50) / 100; - else if (!strcmp(eq->item, "saturation")) - sws->saturation = (((eq->value + 100) << 16) + 50) / 100; - else + if (mp_sws_get_vf_equalizer(sws, data) < 1) break; - - r = mp_sws_reinit(sws); - if (r < 0) - break; - return CONTROL_TRUE; default: break; diff --git a/video/sws_utils.c b/video/sws_utils.c index 7adecc49fc..bc9c408b3e 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -29,6 +29,7 @@ #include "fmt-conversion.h" #include "csputils.h" #include "mpvcore/mp_msg.h" +#include "video/filter/vf.h" //global sws_flags from the command line int sws_flags = 2; @@ -309,4 +310,31 @@ void mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src, talloc_free(ctx); } +int mp_sws_get_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq) +{ + if (!strcmp(eq->item, "brightness")) + eq->value = ((sws->brightness * 100) + (1 << 15)) >> 16; + else if (!strcmp(eq->item, "contrast")) + eq->value = (((sws->contrast * 100) + (1 << 15)) >> 16) - 100; + else if (!strcmp(eq->item, "saturation")) + eq->value = (((sws->saturation * 100) + (1 << 15)) >> 16) - 100; + else + return 0; + return 1; +} + +int mp_sws_set_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq) +{ + if (!strcmp(eq->item, "brightness")) + sws->brightness = ((eq->value << 16) + 50) / 100; + else if (!strcmp(eq->item, "contrast")) + sws->contrast = (((eq->value + 100) << 16) + 50) / 100; + else if (!strcmp(eq->item, "saturation")) + sws->saturation = (((eq->value + 100) << 16) + 50) / 100; + else + return 0; + + return mp_sws_reinit(sws) >= 0 ? 1 : -1; +} + // vim: ts=4 sw=4 et tw=80 diff --git a/video/sws_utils.h b/video/sws_utils.h index 647cae2281..6183d5e88e 100644 --- a/video/sws_utils.h +++ b/video/sws_utils.h @@ -53,6 +53,10 @@ void mp_sws_set_from_cmdline(struct mp_sws_context *ctx); int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst, struct mp_image *src); +struct vf_seteq; +int mp_sws_set_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq); +int mp_sws_get_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq); + #endif /* MP_SWS_UTILS_H */ // vim: ts=4 sw=4 et tw=80 |