mirror of https://github.com/mpv-player/mpv
vo_opengl: add temporal-dither-period option
This was requested multiple times by users, and it's not hard to implement and/or maintain.
This commit is contained in:
parent
b11fd7fd2d
commit
6f7d04be21
|
@ -455,6 +455,11 @@ Available video output drivers are:
|
||||||
Unfortunately, this can lead to flicker on LCD displays, since these
|
Unfortunately, this can lead to flicker on LCD displays, since these
|
||||||
have a high reaction time.
|
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``
|
``debug``
|
||||||
Check for OpenGL errors, i.e. call ``glGetError()``. Also request a
|
Check for OpenGL errors, i.e. call ``glGetError()``. Also request a
|
||||||
debug OpenGL context (which does nothing with current graphics drivers
|
debug OpenGL context (which does nothing with current graphics drivers
|
||||||
|
|
|
@ -333,6 +333,7 @@ static const struct packed_fmt_entry mp_packed_formats[] = {
|
||||||
const struct gl_video_opts gl_video_opts_def = {
|
const struct gl_video_opts gl_video_opts_def = {
|
||||||
.dither_depth = -1,
|
.dither_depth = -1,
|
||||||
.dither_size = 6,
|
.dither_size = 6,
|
||||||
|
.temporal_dither_period = 1,
|
||||||
.fbo_format = GL_RGBA16,
|
.fbo_format = GL_RGBA16,
|
||||||
.sigmoid_center = 0.75,
|
.sigmoid_center = 0.75,
|
||||||
.sigmoid_slope = 6.5,
|
.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 = {
|
const struct gl_video_opts gl_video_opts_hq_def = {
|
||||||
.dither_depth = 0,
|
.dither_depth = 0,
|
||||||
.dither_size = 6,
|
.dither_size = 6,
|
||||||
|
.temporal_dither_period = 1,
|
||||||
.fbo_format = GL_RGBA16,
|
.fbo_format = GL_RGBA16,
|
||||||
.fancy_downscaling = 1,
|
.fancy_downscaling = 1,
|
||||||
.sigmoid_center = 0.75,
|
.sigmoid_center = 0.75,
|
||||||
|
@ -438,6 +440,7 @@ const struct m_sub_options gl_video_conf = {
|
||||||
({"fruit", 0}, {"ordered", 1}, {"no", -1})),
|
({"fruit", 0}, {"ordered", 1}, {"no", -1})),
|
||||||
OPT_INTRANGE("dither-size-fruit", dither_size, 0, 2, 8),
|
OPT_INTRANGE("dither-size-fruit", dither_size, 0, 2, 8),
|
||||||
OPT_FLAG("temporal-dither", temporal_dither, 0),
|
OPT_FLAG("temporal-dither", temporal_dither, 0),
|
||||||
|
OPT_INTRANGE("temporal-dither-period", temporal_dither_period, 0, 1, 128),
|
||||||
OPT_CHOICE("alpha", alpha_mode, 0,
|
OPT_CHOICE("alpha", alpha_mode, 0,
|
||||||
({"no", 0},
|
({"no", 0},
|
||||||
{"yes", 1},
|
{"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);
|
GLSLF("vec2 dither_pos = gl_FragCoord.xy / %d;\n", p->dither_size);
|
||||||
|
|
||||||
if (p->opts.temporal_dither) {
|
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 r = phase * (M_PI / 2); // rotate
|
||||||
float m = phase < 4 ? 1 : -1; // mirror
|
float m = phase < 4 ? 1 : -1; // mirror
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ struct gl_video_opts {
|
||||||
int dither_algo;
|
int dither_algo;
|
||||||
int dither_size;
|
int dither_size;
|
||||||
int temporal_dither;
|
int temporal_dither;
|
||||||
|
int temporal_dither_period;
|
||||||
int fbo_format;
|
int fbo_format;
|
||||||
int alpha_mode;
|
int alpha_mode;
|
||||||
int chroma_location;
|
int chroma_location;
|
||||||
|
|
Loading…
Reference in New Issue