From 6f7d04be21de7bdfce3c7c38a4d5fae17451b409 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 20 Jul 2015 19:09:22 +0200 Subject: vo_opengl: add temporal-dither-period option This was requested multiple times by users, and it's not hard to implement and/or maintain. --- DOCS/man/vo.rst | 5 +++++ video/out/gl_video.c | 5 ++++- video/out/gl_video.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst index 18a56fe79c..d6d1db60e8 100644 --- a/DOCS/man/vo.rst +++ b/DOCS/man/vo.rst @@ -455,6 +455,11 @@ Available video output drivers are: Unfortunately, this can lead to flicker on LCD displays, since these have a high reaction time. + ``temporal-dither-period=<1-128>`` + Determines how often the dithering pattern is updated when + ``temporal-dither`` is in use. 1 (the default) will update on every + video frame, 2 on every other frame, etc. + ``debug`` Check for OpenGL errors, i.e. call ``glGetError()``. Also request a debug OpenGL context (which does nothing with current graphics drivers diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 6aa5d94a75..8f46daa8d6 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -333,6 +333,7 @@ static const struct packed_fmt_entry mp_packed_formats[] = { const struct gl_video_opts gl_video_opts_def = { .dither_depth = -1, .dither_size = 6, + .temporal_dither_period = 1, .fbo_format = GL_RGBA16, .sigmoid_center = 0.75, .sigmoid_slope = 6.5, @@ -350,6 +351,7 @@ const struct gl_video_opts gl_video_opts_def = { const struct gl_video_opts gl_video_opts_hq_def = { .dither_depth = 0, .dither_size = 6, + .temporal_dither_period = 1, .fbo_format = GL_RGBA16, .fancy_downscaling = 1, .sigmoid_center = 0.75, @@ -438,6 +440,7 @@ const struct m_sub_options gl_video_conf = { ({"fruit", 0}, {"ordered", 1}, {"no", -1})), OPT_INTRANGE("dither-size-fruit", dither_size, 0, 2, 8), OPT_FLAG("temporal-dither", temporal_dither, 0), + OPT_INTRANGE("temporal-dither-period", temporal_dither_period, 0, 1, 128), OPT_CHOICE("alpha", alpha_mode, 0, ({"no", 0}, {"yes", 1}, @@ -1923,7 +1926,7 @@ static void pass_dither(struct gl_video *p) GLSLF("vec2 dither_pos = gl_FragCoord.xy / %d;\n", p->dither_size); if (p->opts.temporal_dither) { - int phase = p->frames_rendered % 8u; + int phase = (p->frames_rendered / p->opts.temporal_dither_period) % 8u; float r = phase * (M_PI / 2); // rotate float m = phase < 4 ? 1 : -1; // mirror diff --git a/video/out/gl_video.h b/video/out/gl_video.h index 840fab211c..0881025a14 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -59,6 +59,7 @@ struct gl_video_opts { int dither_algo; int dither_size; int temporal_dither; + int temporal_dither_period; int fbo_format; int alpha_mode; int chroma_location; -- cgit v1.2.3