diff options
author | Niklas Haas <git@nand.wakku.to> | 2015-01-18 18:57:12 +0100 |
---|---|---|
committer | Niklas Haas <git@nand.wakku.to> | 2015-01-22 19:39:58 +0100 |
commit | 2d182fdea0a068cbbbe88b575963cbb480444f31 (patch) | |
tree | 407176b7db120a82106ccb05dbdce06917c635f8 /video/out/gl_video.c | |
parent | 6c250505fedc54a3918788f70445f5fff9d2569a (diff) | |
download | mpv-2d182fdea0a068cbbbe88b575963cbb480444f31.tar.bz2 mpv-2d182fdea0a068cbbbe88b575963cbb480444f31.tar.xz |
vo_opengl: implement naive anti-ringing
This is not quite the same thing as madVR's antiringing algorithm, but
it essentially does something similar.
Porting madVR's approach to elliptic coordinates will take some amount
of thought.
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r-- | video/out/gl_video.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 7400ffba0f..ddccd3a3e5 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -105,6 +105,7 @@ struct scaler { int index; const char *name; float params[2]; + float antiring; struct filter_kernel *kernel; GLuint gl_lut; const char *lut_name; @@ -367,6 +368,8 @@ const struct m_sub_options gl_video_conf = { OPT_FLOAT("cparam2", scaler_params[1][1], 0), OPT_FLOATRANGE("lradius", scaler_radius[0], 0, 1.0, 16.0), OPT_FLOATRANGE("cradius", scaler_radius[1], 0, 1.0, 16.0), + OPT_FLOATRANGE("lantiring", scaler_antiring[0], 0, 0.0, 1.0), + OPT_FLOATRANGE("cantiring", scaler_antiring[1], 0, 0.0, 1.0), OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0), OPT_FLAG("fancy-downscaling", fancy_downscaling, 0), OPT_FLAG("sigmoid-upscaling", sigmoid_upscaling, 0), @@ -955,9 +958,9 @@ static void shader_setup_scaler(char **shader, struct scaler *scaler, int pass) char lut_fn[40]; if (scaler->kernel->polar) { int radius = (int)scaler->kernel->radius; - // SAMPLE_CONVOLUTION_POLAR_R(NAME, R, LUT) - APPENDF(shader, "SAMPLE_CONVOLUTION_POLAR_R(%s, %d, %s, WEIGHTS%d)\n", - name, radius, lut_tex, unit); + // SAMPLE_CONVOLUTION_POLAR_R(NAME, R, LUT, WEIGHTS_FN, ANTIRING) + APPENDF(shader, "SAMPLE_CONVOLUTION_POLAR_R(%s, %d, %s, WEIGHTS%d, %f)\n", + name, radius, lut_tex, unit, scaler->antiring); // Pre-compute unrolled weights matrix APPENDF(shader, "#define WEIGHTS%d(LUT) \\\n ", unit); @@ -971,7 +974,12 @@ static void shader_setup_scaler(char **shader, struct scaler *scaler, int pass) // Samples outside the radius are unnecessary if (d < radius) { - APPENDF(shader, "SAMPLE_POLAR(LUT, %f, %d, %d) \\\n ", + APPENDF(shader, "SAMPLE_POLAR_%s(LUT, %f, %d, %d) \\\n ", + // The center 4 coefficients are the primary + // contributors, used to clamp the result for + // anti-ringing + (x >= 0 && y >= 0 && x <= 1 && y <= 1) + ? "PRIMARY" : "HELPER", (double)radius, x, y); } } @@ -1316,6 +1324,8 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler) scaler->kernel->params[n] = p->opts.scaler_params[scaler->index][n]; } + scaler->antiring = p->opts.scaler_antiring[scaler->index]; + if (scaler->kernel->radius < 0) { float radius = p->opts.scaler_radius[scaler->index]; if (!isnan(radius)) |