diff options
author | Niklas Haas <git@nand.wakku.to> | 2015-01-18 17:41:49 +0100 |
---|---|---|
committer | Niklas Haas <git@nand.wakku.to> | 2015-01-22 19:29:23 +0100 |
commit | 6c250505fedc54a3918788f70445f5fff9d2569a (patch) | |
tree | 001d8de845975c6d24e345925a4515ec655e00ff /video/out/gl_video.c | |
parent | f5e48f023524630d0334b1fbc2f2dc44bbc2819b (diff) | |
download | mpv-6c250505fedc54a3918788f70445f5fff9d2569a.tar.bz2 mpv-6c250505fedc54a3918788f70445f5fff9d2569a.tar.xz |
vo_opengl: unroll ewa_lanczos to avoid looping and unnecessary samples
This speeds up performance by a factor of something like 10%,
since it omits unnecessary checks.
This will also make adding anti-ringing easier.
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r-- | video/out/gl_video.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index c58521ed49..7400ffba0f 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -954,9 +954,29 @@ static void shader_setup_scaler(char **shader, struct scaler *scaler, int pass) APPENDF(shader, "#define DEF_SCALER%d \\\n ", unit); 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)\n", - name, (int)scaler->kernel->radius, lut_tex); + APPENDF(shader, "SAMPLE_CONVOLUTION_POLAR_R(%s, %d, %s, WEIGHTS%d)\n", + name, radius, lut_tex, unit); + + // Pre-compute unrolled weights matrix + APPENDF(shader, "#define WEIGHTS%d(LUT) \\\n ", unit); + for (int y = 1-radius; y <= radius; y++) { + for (int x = 1-radius; x <= radius; x++) { + // Since we can't know the subpixel position in advance, + // assume a worst case scenario. + int yy = y > 0 ? y-1 : y; + int xx = x > 0 ? x-1 : x; + double d = sqrt(xx*xx + yy*yy); + + // Samples outside the radius are unnecessary + if (d < radius) { + APPENDF(shader, "SAMPLE_POLAR(LUT, %f, %d, %d) \\\n ", + (double)radius, x, y); + } + } + } + APPENDF(shader, "\n"); } else { if (size == 2 || size == 6) { snprintf(lut_fn, sizeof(lut_fn), "weights%d", size); |