mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
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.
This commit is contained in:
parent
f53c7f1a78
commit
7d01a16f64
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user