From 115b165b98c02646c81f8562e2f8e315ee4a7388 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 6 Dec 2014 01:45:39 +0100 Subject: vo_opengl: extend filter size to 32 Also replace the weights calculations for 8/12/16 with the generic weight function definition macro. (The weights 2/4/6 follow slightly different rules.) --- video/out/gl_video.c | 7 ++++--- video/out/gl_video_shaders.glsl | 43 ++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'video') diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 07ba0bd602..c3bd88a21c 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -81,10 +81,11 @@ const struct lut_tex_format lut_tex_formats[] = { [8] = {2, GL_RGBA16F, GL_RGBA}, [12] = {3, GL_RGBA16F, GL_RGBA}, [16] = {4, GL_RGBA16F, GL_RGBA}, + [32] = {8, GL_RGBA16F, GL_RGBA}, }; // must be sorted, and terminated with 0 -static const int filter_sizes[] = {2, 4, 6, 8, 12, 16, 0}; +static const int filter_sizes[] = {2, 4, 6, 8, 12, 16, 32, 0}; struct vertex { float position[2]; @@ -335,8 +336,8 @@ const struct m_sub_options gl_video_conf = { 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_FLOATRANGE("lradius", scaler_radius[0], 0, 1.0, 8.0), - OPT_FLOATRANGE("cradius", scaler_radius[1], 0, 1.0, 8.0), + OPT_FLOATRANGE("lradius", scaler_radius[0], 0, 1.0, 16.0), + OPT_FLOATRANGE("cradius", scaler_radius[1], 0, 1.0, 16.0), OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0), OPT_FLAG("fancy-downscaling", fancy_downscaling, 0), OPT_FLAG("indirect", indirect, 0), diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index ff2a019b30..9998badbca 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -237,29 +237,24 @@ float[6] weights6(sampler2D lookup, float f) { return float[6](c1.r, c1.g, c1.b, c2.r, c2.g, c2.b); } -float[8] weights8(sampler2D lookup, float f) { - vec4 c1 = texture(lookup, vec2(0.25, f)); - vec4 c2 = texture(lookup, vec2(0.75, f)); - return float[8](c1.r, c1.g, c1.b, c1.a, c2.r, c2.g, c2.b, c2.a); -} - -float[12] weights12(sampler2D lookup, float f) { - vec4 c1 = texture(lookup, vec2(1.0/6.0, f)); - vec4 c2 = texture(lookup, vec2(0.5, f)); - vec4 c3 = texture(lookup, vec2(5.0/6.0, f)); - return float[12](c1.r, c1.g, c1.b, c1.a, - c2.r, c2.g, c2.b, c2.a, - c3.r, c3.g, c3.b, c3.a); -} +#define WEIGHTS_N(NAME, N) \ + float[N] NAME(sampler2D lookup, float f) { \ + float r[N]; \ + for (int n = 0; n < N / 4; n++) { \ + vec4 c = texture(lookup, \ + vec2(1.0 / (N / 2) + n / float(N / 4), f)); \ + r[n * 4 + 0] = c.r; \ + r[n * 4 + 1] = c.g; \ + r[n * 4 + 2] = c.b; \ + r[n * 4 + 3] = c.a; \ + } \ + return r; \ + } -float[16] weights16(sampler2D lookup, float f) { - vec4 c1 = texture(lookup, vec2(0.125, f)); - vec4 c2 = texture(lookup, vec2(0.375, f)); - vec4 c3 = texture(lookup, vec2(0.625, f)); - vec4 c4 = texture(lookup, vec2(0.875, f)); - return float[16](c1.r, c1.g, c1.b, c1.a, c2.r, c2.g, c2.b, c2.a, - c3.r, c3.g, c3.b, c3.a, c4.r, c4.g, c4.b, c4.a); -} +WEIGHTS_N(weights8, 8) +WEIGHTS_N(weights12, 12) +WEIGHTS_N(weights16, 16) +WEIGHTS_N(weights32, 32) #define CONVOLUTION_SEP_N(NAME, N) \ vec4 NAME(VIDEO_SAMPLER tex, vec2 texcoord, vec2 pt, float weights[N]) {\ @@ -276,6 +271,7 @@ CONVOLUTION_SEP_N(convolution_sep6, 6) CONVOLUTION_SEP_N(convolution_sep8, 8) CONVOLUTION_SEP_N(convolution_sep12, 12) CONVOLUTION_SEP_N(convolution_sep16, 16) +CONVOLUTION_SEP_N(convolution_sep32, 32) // The dir parameter is (0, 1) or (1, 0), and we expect the shader compiler to // remove all the redundant multiplications and additions. @@ -295,6 +291,7 @@ SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep6, 6, sampler2D, convolution_sep6 SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep8, 8, sampler2D, convolution_sep8, weights8) SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep12, 12, sampler2D, convolution_sep12, weights12) SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep16, 16, sampler2D, convolution_sep16, weights16) +SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep32, 32, sampler2D, convolution_sep32, weights32) #define CONVOLUTION_N(NAME, N) \ @@ -316,6 +313,7 @@ CONVOLUTION_N(convolution6, 6) CONVOLUTION_N(convolution8, 8) CONVOLUTION_N(convolution12, 12) CONVOLUTION_N(convolution16, 16) +CONVOLUTION_N(convolution32, 32) #define SAMPLE_CONVOLUTION_N(NAME, N, SAMPLERT, CONV_FUNC, WEIGHTS_FUNC) \ vec4 NAME(SAMPLERT lookup, VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {\ @@ -333,6 +331,7 @@ SAMPLE_CONVOLUTION_N(sample_convolution6, 6, sampler2D, convolution6, weights6) SAMPLE_CONVOLUTION_N(sample_convolution8, 8, sampler2D, convolution8, weights8) SAMPLE_CONVOLUTION_N(sample_convolution12, 12, sampler2D, convolution12, weights12) SAMPLE_CONVOLUTION_N(sample_convolution16, 16, sampler2D, convolution16, weights16) +SAMPLE_CONVOLUTION_N(sample_convolution32, 32, sampler2D, convolution32, weights32) // Unsharp masking -- cgit v1.2.3