diff options
author | wm4 <wm4@nowhere> | 2014-02-27 00:53:41 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-02-27 00:53:41 +0100 |
commit | 8a51a6b79c2790d97aed2dd107ed1f3a70f95236 (patch) | |
tree | f5439ac4a681911123d45be8c6a65ecfbb58a490 /video/out | |
parent | 6119cf13bed2689d025c15e6b7d874e44b39ef08 (diff) | |
download | mpv-8a51a6b79c2790d97aed2dd107ed1f3a70f95236.tar.bz2 mpv-8a51a6b79c2790d97aed2dd107ed1f3a70f95236.tar.xz |
vo_opengl: change gamma suboption to take a value
The previous version of the gamma suboption was pretty useless. It could
be used to disable delayed gamma enabling, which is a mechanism to avoid
having to adjust gamma in the shader by default.
Repurpose the suboption and allow setting an exact gamma value with it.
You can already override gamma with the --gamma option as well as the
gamma input property, but these use a weird curve to create the
impression of a linear perceived brightness change when changing the
value. This suboption now allows setting an exact gamma value.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gl_video.c | 13 | ||||
-rw-r--r-- | video/out/gl_video.h | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index af1d3e166b..dbd54913ed 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -304,7 +304,7 @@ static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt, #define OPT_BASE_STRUCT struct gl_video_opts const struct m_sub_options gl_video_conf = { .opts = (m_option_t[]) { - OPT_FLAG("gamma", gamma, 0), + OPT_FLOATRANGE("gamma", gamma, 0, 0.0, 10.0), OPT_FLAG("srgb", srgb, 0), OPT_FLAG("npot", npot, 0), OPT_FLAG("pbo", pbo, 0), @@ -566,10 +566,11 @@ static void update_uniforms(struct gl_video *p, GLuint program) gl->Uniform1f(gl->GetUniformLocation(program, "conv_gamma"), p->conv_gamma); + float gamma = p->opts.gamma ? p->opts.gamma : 1.0; gl->Uniform3f(gl->GetUniformLocation(program, "inv_gamma"), - 1.0 / cparams.rgamma, - 1.0 / cparams.ggamma, - 1.0 / cparams.bgamma); + 1.0 / (cparams.rgamma * gamma), + 1.0 / (cparams.ggamma * gamma), + 1.0 / (cparams.bgamma * gamma)); for (int n = 0; n < p->plane_count; n++) { char textures_n[32]; @@ -889,7 +890,7 @@ static void compile_shaders(struct gl_video *p) shader_def(&header_conv, "USE_ALPHA_BLEND", "1"); shader_def_opt(&header_final, "USE_LINEAR_CONV_INV", p->use_lut_3d); - shader_def_opt(&header_final, "USE_GAMMA_POW", p->opts.gamma); + shader_def_opt(&header_final, "USE_GAMMA_POW", p->opts.gamma > 0); shader_def_opt(&header_final, "USE_3DLUT", p->use_lut_3d); shader_def_opt(&header_final, "USE_SRGB", p->opts.srgb); shader_def_opt(&header_final, "USE_DITHER", p->dither_texture != 0); @@ -2205,7 +2206,7 @@ bool gl_video_set_equalizer(struct gl_video *p, const char *name, int val) if (mp_csp_equalizer_set(&p->video_eq, name, val) >= 0) { if (!p->opts.gamma && p->video_eq.values[MP_CSP_EQ_GAMMA] != 0) { MP_VERBOSE(p, "Auto-enabling gamma.\n"); - p->opts.gamma = true; + p->opts.gamma = 1.0f; compile_shaders(p); } update_all_uniforms(p); diff --git a/video/out/gl_video.h b/video/out/gl_video.h index a4f864a9dd..e997e88fb6 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -31,7 +31,7 @@ struct gl_video_opts { char *scalers[2]; float scaler_params[2]; int indirect; - int gamma; + float gamma; int srgb; int scale_sep; int fancy_downscaling; |