From e6058d3dc30ca8160ebeb8bba562ba08574164bb Mon Sep 17 00:00:00 2001 From: Bin Jin Date: Sat, 5 Dec 2015 19:14:23 +0000 Subject: vo_opengl: make LOOKUP_TEXTURE_SIZE configurable --- DOCS/man/vo.rst | 9 +++++++++ video/out/opengl/video.c | 8 ++++---- video/out/opengl/video.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst index c8f484aa72..56339f1468 100644 --- a/DOCS/man/vo.rst +++ b/DOCS/man/vo.rst @@ -431,6 +431,15 @@ Available video output drivers are: Scale parameter (t). Increasing this makes the window wider. Defaults to 1. + ``scaler-lut-size=<4..10>`` + Set the size of the lookup texture for scaler kernels (default: 8). + The actual size of the texture is ``2^N`` for an option value of ``N``. + So the lookup texture with the default setting uses 256 samples. + + All weights are bilinearly interpolated from those samples, so + increasing the size of lookup table might improve the accuracy of + scaler. + ``scaler-resizes-only`` Disable the scaler if the video image is not resized. In that case, ``bilinear`` is used instead whatever is set with ``scale``. Bilinear diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index de20984cdc..0fdc4df0a2 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -49,9 +49,6 @@ #include "video/out/dither.h" #include "video/out/vo.h" -// Pixel width of 1D lookup textures. -#define LOOKUP_TEXTURE_SIZE 256 - // Maximal number of passes that prescaler can be applied. #define MAX_PRESCALE_PASSES 5 @@ -348,6 +345,7 @@ const struct gl_video_opts gl_video_opts_def = { {{"mitchell", .params={NAN, NAN}}, {.params = {NAN, NAN}}, .clamp = 1, }, // tscale }, + .scaler_lut_size = 8, .alpha_mode = 2, .background = {0, 0, 0, 255}, .gamma = 1.0f, @@ -371,6 +369,7 @@ const struct gl_video_opts gl_video_opts_hq_def = { {{"mitchell", .params={NAN, NAN}}, {.params = {NAN, NAN}}, .clamp = 1, }, // tscale }, + .scaler_lut_size = 8, .alpha_mode = 2, .background = {0, 0, 0, 255}, .gamma = 1.0f, @@ -412,6 +411,7 @@ const struct m_sub_options gl_video_conf = { SCALER_OPTS("dscale", 1), SCALER_OPTS("cscale", 2), SCALER_OPTS("tscale", 3), + OPT_INTRANGE("scaler-lut-size", scaler_lut_size, 0, 4, 10), OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0), OPT_FLAG("linear-scaling", linear_scaling, 0), OPT_FLAG("correct-downscaling", correct_downscaling, 0), @@ -1081,7 +1081,7 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler, gl->BindTexture(target, scaler->gl_lut); - scaler->lut_size = LOOKUP_TEXTURE_SIZE; + scaler->lut_size = 1 << p->opts.scaler_lut_size; float *weights = talloc_array(NULL, float, scaler->lut_size * size); mp_compute_lut(scaler->kernel, scaler->lut_size, weights); diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h index a56c0c1c09..4dab617cda 100644 --- a/video/out/opengl/video.h +++ b/video/out/opengl/video.h @@ -71,6 +71,7 @@ struct scaler { struct gl_video_opts { int dumb_mode; struct scaler_config scaler[4]; + int scaler_lut_size; float gamma; int gamma_auto; int target_prim; -- cgit v1.2.3