From 7d01a16f643520b99db25db6042a3afacdc040ab Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Tue, 19 Jul 2016 20:12:33 +0200 Subject: vo_opengl: add a tscale=linear direct implementation This uses GLSL mix() instead of going through an indirect texture access. Easy to implement and might require less resources on some devices, since the oversample code was already essentially just a special case of this. Could be made the new default (as per issue #2685), but that should be done in a separate commit. --- video/out/opengl/video.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 468bee90b5..df43836c14 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -59,6 +59,7 @@ static const char *const fixed_scale_filters[] = { }; static const char *const fixed_tscale_filters[] = { "oversample", + "linear", NULL }; @@ -2525,9 +2526,10 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, struct scaler *tscale = &p->scaler[SCALER_TSCALE]; reinit_scaler(p, tscale, &p->opts.scaler[SCALER_TSCALE], 1, tscale_sizes); bool oversample = strcmp(tscale->conf.kernel.name, "oversample") == 0; + bool linear = strcmp(tscale->conf.kernel.name, "linear") == 0; int size; - if (oversample) { + if (oversample || linear) { size = 2; } else { assert(tscale->kernel && !tscale->kernel->polar); @@ -2612,8 +2614,9 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, } } - // Blend the frames together if (oversample) { + // Oversample uses the frame area as mix ratio, not the the vsync + // position itself double vsync_dist = t->vsync_interval / t->ideal_frame_duration, threshold = tscale->conf.kernel.params[0]; threshold = isnan(threshold) ? 0.0 : threshold; @@ -2621,6 +2624,10 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, mix = mix <= 0 + threshold ? 0 : mix; mix = mix >= 1 - threshold ? 1 : mix; mix = 1 - mix; + } + + // Blend the frames together + if (oversample || linear) { gl_sc_uniform_f(p->sc, "inter_coeff", mix); GLSL(color = mix(texture(texture0, texcoord0), texture(texture1, texcoord1), @@ -3489,7 +3496,7 @@ void gl_video_configure_queue(struct gl_video *p, struct vo *vo) radius = radius > 0 ? radius : p->opts.scaler[SCALER_TSCALE].radius; queue_size += 1 + ceil(radius); } else { - // Oversample case + // Oversample/linear case queue_size += 2; } } -- cgit v1.2.3