summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/filter/vf_scale.c25
-rw-r--r--video/sws_utils.c28
-rw-r--r--video/sws_utils.h4
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