summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorBin Jin <bjin1990@gmail.com>2014-08-25 22:36:48 +0200
committerwm4 <wm4@nowhere>2014-08-26 22:19:27 +0200
commitf14722a40f46366e4333881ec5d540bca1400280 (patch)
tree05872c144c973ba14ef29ba881954123c7228df6 /video
parenta8b67c66f24700205923959b005b2547490e6c8e (diff)
downloadmpv-f14722a40f46366e4333881ec5d540bca1400280.tar.bz2
mpv-f14722a40f46366e4333881ec5d540bca1400280.tar.xz
vo_opengl: add cparam1 and cparam2 options
Although cscale is rarely used, it's possible that params of cscale are accidentally set to lparam1 and lparam2, which might cause unexpected results.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_video.c32
-rw-r--r--video/out/gl_video.h2
-rw-r--r--video/out/gl_video_shaders.glsl29
3 files changed, 42 insertions, 21 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 9b075baf8a..3478c8afcc 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -288,7 +288,7 @@ static const struct gl_video_opts gl_video_opts_def = {
.fbo_format = GL_RGB,
.scale_sep = 1,
.scalers = { "bilinear", "bilinear" },
- .scaler_params = {NAN, NAN},
+ .scaler_params = {{NAN, NAN}, {NAN, NAN}},
.alpha_mode = 2,
};
@@ -299,7 +299,7 @@ const struct gl_video_opts gl_video_opts_hq_def = {
.fbo_format = GL_RGBA16,
.scale_sep = 1,
.scalers = { "spline36", "bilinear" },
- .scaler_params = {NAN, NAN},
+ .scaler_params = {{NAN, NAN}, {NAN, NAN}},
.alpha_mode = 2,
};
@@ -322,8 +322,10 @@ const struct m_sub_options gl_video_conf = {
{"quadbuffer", GL_3D_QUADBUFFER})),
OPT_STRING_VALIDATE("lscale", scalers[0], 0, validate_scaler_opt),
OPT_STRING_VALIDATE("cscale", scalers[1], 0, validate_scaler_opt),
- OPT_FLOAT("lparam1", scaler_params[0], 0),
- OPT_FLOAT("lparam2", scaler_params[1], 0),
+ OPT_FLOAT("lparam1", scaler_params[0][0], 0),
+ OPT_FLOAT("lparam2", scaler_params[0][1], 0),
+ OPT_FLOAT("cparam1", scaler_params[1][0], 0),
+ OPT_FLOAT("cparam2", scaler_params[1][1], 0),
OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0),
OPT_FLAG("fancy-downscaling", fancy_downscaling, 0),
OPT_FLAG("indirect", indirect, 0),
@@ -673,9 +675,12 @@ static void update_uniforms(struct gl_video *p, GLuint program)
gl->Uniform1f(gl->GetUniformLocation(program, "dither_center"),
p->dither_center);
- float sparam1 = p->opts.scaler_params[0];
- gl->Uniform1f(gl->GetUniformLocation(program, "filter_param1"),
- isnan(sparam1) ? 0.5f : sparam1);
+ float sparam1_l = p->opts.scaler_params[0][0];
+ float sparam1_c = p->opts.scaler_params[1][0];
+ gl->Uniform1f(gl->GetUniformLocation(program, "filter_param1_l"),
+ isnan(sparam1_l) ? 0.5f : sparam1_l);
+ gl->Uniform1f(gl->GetUniformLocation(program, "filter_param1_c"),
+ isnan(sparam1_c) ? 0.5f : sparam1_c);
gl->UseProgram(0);
@@ -817,8 +822,9 @@ static void shader_setup_scaler(char **shader, struct scaler *scaler, int pass)
{
const char *target = scaler->index == 0 ? "SAMPLE_L" : "SAMPLE_C";
if (!scaler->kernel) {
- *shader = talloc_asprintf_append(*shader, "#define %s sample_%s\n",
- target, scaler->name);
+ *shader = talloc_asprintf_append(*shader, "#define %s sample_%s_%c\n",
+ target, scaler->name,
+ "lc"[scaler->index]);
} else {
int size = scaler->kernel->size;
if (pass != -1) {
@@ -1023,13 +1029,13 @@ static void compile_shaders(struct gl_video *p)
// Force using the luma scaler on chroma. If the "indirect" stage is
// used, the actual scaling will happen in the next stage.
shader_def(&header_conv, "SAMPLE_C",
- use_indirect ? "sample_bilinear" : "SAMPLE_L");
+ use_indirect ? "sample_bilinear_l" : "SAMPLE_L");
}
if (use_indirect) {
// We don't use filtering for the Y-plane (luma), because it's never
// scaled in this scenario.
- shader_def(&header_conv, "SAMPLE_L", "sample_bilinear");
+ shader_def(&header_conv, "SAMPLE_L", "sample_bilinear_l");
shader_def_opt(&header_conv, "FIXED_SCALE", true);
header_conv = t_concat(tmp, header, header_conv);
p->indirect_program =
@@ -1107,8 +1113,8 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler)
scaler->kernel = &scaler->kernel_storage;
for (int n = 0; n < 2; n++) {
- if (!isnan(p->opts.scaler_params[n]))
- scaler->kernel->params[n] = p->opts.scaler_params[n];
+ if (!isnan(p->opts.scaler_params[scaler->index][n]))
+ scaler->kernel->params[n] = p->opts.scaler_params[scaler->index][n];
}
update_scale_factor(p, scaler->kernel);
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index 011a62fe5f..c5f2e558c7 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -29,7 +29,7 @@ struct lut3d {
struct gl_video_opts {
char *scalers[2];
- float scaler_params[2];
+ float scaler_params[2][2];
int indirect;
float gamma;
int srgb;
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl
index 6019b78243..3d9d9bf07a 100644
--- a/video/out/gl_video_shaders.glsl
+++ b/video/out/gl_video_shaders.glsl
@@ -158,7 +158,8 @@ uniform float input_gamma;
uniform float conv_gamma;
uniform float dither_quantization;
uniform float dither_center;
-uniform float filter_param1;
+uniform float filter_param1_l;
+uniform float filter_param1_c;
uniform vec2 dither_size;
in vec2 texcoord;
@@ -167,7 +168,7 @@ DECLARE_FRAGPARMS
#define CONV_NV12 1
#define CONV_PLANAR 2
-vec4 sample_bilinear(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {
+vec4 sample_bilinear(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord, float param1) {
return texture(tex, texcoord);
}
@@ -188,7 +189,7 @@ vec4 calcweights(float s) {
return t;
}
-vec4 sample_bicubic_fast(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {
+vec4 sample_bicubic_fast(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord, float param1) {
vec2 pt = 1 / texsize;
vec2 fcoord = fract(texcoord * texsize + vec2(0.5, 0.5));
vec4 parmx = calcweights(fcoord.x);
@@ -323,7 +324,7 @@ SAMPLE_CONVOLUTION_N(sample_convolution16, 16, sampler2D, convolution16, weights
// Unsharp masking
-vec4 sample_sharpen3(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {
+vec4 sample_sharpen3(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord, float param1) {
vec2 pt = 1 / texsize;
vec2 st = pt * 0.5;
vec4 p = texture(tex, texcoord);
@@ -331,10 +332,10 @@ vec4 sample_sharpen3(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {
+ texture(tex, texcoord + st * vec2(+1, -1))
+ texture(tex, texcoord + st * vec2(-1, +1))
+ texture(tex, texcoord + st * vec2(-1, -1));
- return p + (p - 0.25 * sum) * filter_param1;
+ return p + (p - 0.25 * sum) * param1;
}
-vec4 sample_sharpen5(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {
+vec4 sample_sharpen5(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord, float param1) {
vec2 pt = 1 / texsize;
vec2 st1 = pt * 1.2;
vec4 p = texture(tex, texcoord);
@@ -348,9 +349,23 @@ vec4 sample_sharpen5(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {
+ texture(tex, texcoord + st2 * vec2(-1, 0))
+ texture(tex, texcoord + st2 * vec2( 0, -1));
vec4 t = p * 0.859375 + sum2 * -0.1171875 + sum1 * -0.09765625;
- return p + t * filter_param1;
+ return p + t * param1;
}
+#define SAMPLE_FILTER_LC(NAME) \
+ vec4 NAME##_l(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) { \
+ return NAME(tex, texsize, texcoord, filter_param1_l); \
+ } \
+ \
+ vec4 NAME##_c(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) { \
+ return NAME(tex, texsize, texcoord, filter_param1_c); \
+ }
+
+SAMPLE_FILTER_LC(sample_bilinear)
+SAMPLE_FILTER_LC(sample_bicubic_fast)
+SAMPLE_FILTER_LC(sample_sharpen3)
+SAMPLE_FILTER_LC(sample_sharpen5)
+
void main() {
vec2 chr_texcoord = texcoord;
#ifdef USE_RECTANGLE