From c99d95ac17364c46bc161867d1102361f05a6cc5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 12 Apr 2020 21:55:35 +0200 Subject: vf_format: add gross mechanism for forcing scaler for testing This sucks, but is helpful for testing. Obviously, it would be much nicer if there were a way to specify _all_ scaler options per filter (if the user wanted), instead of always using the global options. But this is "too hard" for now. For testing, it is extremely convenient to select the scaler backend, so add this option, but make clear that it could go away. We'd delete it once there is a better mechanism for this. --- filters/f_autoconvert.c | 2 ++ filters/f_autoconvert.h | 3 +++ filters/f_swscale.c | 4 ++++ filters/f_swscale.h | 3 +++ 4 files changed, 12 insertions(+) (limited to 'filters') diff --git a/filters/f_autoconvert.c b/filters/f_autoconvert.c index 5e0caaf321..7452a13ae8 100644 --- a/filters/f_autoconvert.c +++ b/filters/f_autoconvert.c @@ -244,6 +244,8 @@ static bool build_image_converter(struct mp_autoconvert *c, struct mp_log *log, goto fail; } + sws->force_scaler = c->force_scaler; + int out = mp_sws_find_best_out_format(sws, src_fmt, fmts, num_fmts); if (!out) { mp_err(log, "can't find video conversion for %s\n", diff --git a/filters/f_autoconvert.h b/filters/f_autoconvert.h index 7cb144aa59..6d6660c46a 100644 --- a/filters/f_autoconvert.h +++ b/filters/f_autoconvert.h @@ -1,6 +1,7 @@ #pragma once #include "filter.h" +#include "video/sws_utils.h" struct mp_image; struct mp_image_params; @@ -12,6 +13,8 @@ struct mp_autoconvert { // f->pins[0] is input, f->pins[1] is output struct mp_filter *f; + enum mp_sws_scaler force_scaler; + // If this is set, the callback is invoked (from the process function), and // further data flow is blocked until mp_autoconvert_format_change_continue() // is called. The idea is that you can reselect the output parameters on diff --git a/filters/f_swscale.c b/filters/f_swscale.c index f9af4d18fb..614de1466c 100644 --- a/filters/f_swscale.c +++ b/filters/f_swscale.c @@ -43,6 +43,8 @@ int mp_sws_find_best_out_format(struct mp_sws_filter *sws, int in_format, int *out_formats, int num_out_formats) { + sws->sws->force_scaler = sws->force_scaler; + int best = 0; for (int n = 0; n < num_out_formats; n++) { int out_format = out_formats[n]; @@ -73,6 +75,8 @@ static void process(struct mp_filter *f) if (!mp_pin_can_transfer_data(f->ppins[1], f->ppins[0])) return; + s->sws->force_scaler = s->force_scaler; + struct mp_frame frame = mp_pin_out_read(f->ppins[0]); if (mp_frame_is_signaling(frame)) { mp_pin_in_write(f->ppins[1], frame); diff --git a/filters/f_swscale.h b/filters/f_swscale.h index 861ad029dd..3ee7455ecd 100644 --- a/filters/f_swscale.h +++ b/filters/f_swscale.h @@ -3,6 +3,7 @@ #include #include "video/mp_image.h" +#include "video/sws_utils.h" struct mp_sws_filter { struct mp_filter *f; @@ -11,6 +12,8 @@ struct mp_sws_filter { // If set, force all image params; ignores out_format. bool use_out_params; struct mp_image_params out_params; + // Other options. + enum mp_sws_scaler force_scaler; // private state struct mp_sws_context *sws; struct mp_image_pool *pool; -- cgit v1.2.3