summaryrefslogtreecommitdiffstats
path: root/video/sws_utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-30 00:31:10 +0200
committerwm4 <wm4@nowhere>2013-09-30 00:45:58 +0200
commit00d41cc5b065cc809ab64901aca3dcaae8035869 (patch)
treebd7bdfd1ece9ee986f6429d4d998e0e2d20db5c9 /video/sws_utils.c
parent9488d312c11ab1b4267b33eb85adcb28b25a45ba (diff)
downloadmpv-00d41cc5b065cc809ab64901aca3dcaae8035869.tar.bz2
mpv-00d41cc5b065cc809ab64901aca3dcaae8035869.tar.xz
vf_scale: factor out libswscale equalizer control
Will be used by vo_x11.
Diffstat (limited to 'video/sws_utils.c')
-rw-r--r--video/sws_utils.c28
1 files changed, 28 insertions, 0 deletions
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