From b3e788d3f462e4f8acaf4ea9bf0cb07f8d622c7c Mon Sep 17 00:00:00 2001 From: Bin Jin Date: Tue, 26 Aug 2014 00:41:30 +0200 Subject: vo_opengl: add radius options for filters Add two new options, make it possible for user to set the radius for some of the filters with no fixed radius. Also add three new filters with the new radius parameter supported. --- video/out/filter_kernels.c | 5 +++++ video/out/filter_kernels.h | 2 +- video/out/gl_video.c | 10 ++++++++++ video/out/gl_video.h | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) (limited to 'video') diff --git a/video/out/filter_kernels.c b/video/out/filter_kernels.c index c8efbe5731..66116ce18b 100644 --- a/video/out/filter_kernels.c +++ b/video/out/filter_kernels.c @@ -56,6 +56,8 @@ const struct filter_kernel *mp_find_filter_kernel(const char *name) bool mp_init_filter(struct filter_kernel *filter, const int *sizes, double inv_scale) { + if (filter->radius < 0) + filter->radius = 2.0; // only downscaling requires widening the filter filter->inv_scale = inv_scale >= 1.0 ? inv_scale : 1.0; double support = filter->radius * filter->inv_scale; @@ -294,11 +296,14 @@ const struct filter_kernel mp_filter_kernels[] = { {"sinc2", 2, sinc}, {"sinc3", 3, sinc}, {"sinc4", 4, sinc}, + {"sinc", -1, sinc}, {"lanczos2", 2, lanczos}, {"lanczos3", 3, lanczos}, {"lanczos4", 4, lanczos}, + {"lanczos", -1, lanczos}, {"blackman2", 2, blackman}, {"blackman3", 3, blackman}, {"blackman4", 4, blackman}, + {"blackman", -1, blackman}, {0} }; diff --git a/video/out/filter_kernels.h b/video/out/filter_kernels.h index 46a392c40a..f9a413b9f7 100644 --- a/video/out/filter_kernels.h +++ b/video/out/filter_kernels.h @@ -23,7 +23,7 @@ struct filter_kernel { const char *name; - double radius; + double radius; // A negative value will use user specified radius instead. double (*weight)(struct filter_kernel *kernel, double x); // The filter params can be changed at runtime. Only used by some filters. diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 3478c8afcc..359013a6e6 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -289,6 +289,7 @@ static const struct gl_video_opts gl_video_opts_def = { .scale_sep = 1, .scalers = { "bilinear", "bilinear" }, .scaler_params = {{NAN, NAN}, {NAN, NAN}}, + .scaler_radius = {NAN, NAN}, .alpha_mode = 2, }; @@ -300,6 +301,7 @@ const struct gl_video_opts gl_video_opts_hq_def = { .scale_sep = 1, .scalers = { "spline36", "bilinear" }, .scaler_params = {{NAN, NAN}, {NAN, NAN}}, + .scaler_radius = {NAN, NAN}, .alpha_mode = 2, }; @@ -326,6 +328,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_FLAG("scaler-resizes-only", scaler_resizes_only, 0), OPT_FLAG("fancy-downscaling", fancy_downscaling, 0), OPT_FLAG("indirect", indirect, 0), @@ -1117,6 +1121,12 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler) scaler->kernel->params[n] = p->opts.scaler_params[scaler->index][n]; } + if (scaler->kernel->radius < 0) { + float radius = p->opts.scaler_radius[scaler->index]; + if (!isnan(radius)) + scaler->kernel->radius = radius; + } + update_scale_factor(p, scaler->kernel); int size = scaler->kernel->size; diff --git a/video/out/gl_video.h b/video/out/gl_video.h index c5f2e558c7..8ea5d3420f 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -30,6 +30,7 @@ struct lut3d { struct gl_video_opts { char *scalers[2]; float scaler_params[2][2]; + float scaler_radius[2]; int indirect; float gamma; int srgb; -- cgit v1.2.3