summaryrefslogtreecommitdiffstats
path: root/video/sws_utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-12 21:55:35 +0200
committerwm4 <wm4@nowhere>2020-04-13 15:56:27 +0200
commitc99d95ac17364c46bc161867d1102361f05a6cc5 (patch)
tree25b1033cbd19b87ec076f1c91b26677a07788772 /video/sws_utils.c
parent28f2d7454d5ea997dec691376ebcdf4c4e0454b4 (diff)
downloadmpv-c99d95ac17364c46bc161867d1102361f05a6cc5.tar.bz2
mpv-c99d95ac17364c46bc161867d1102361f05a6cc5.tar.xz
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.
Diffstat (limited to 'video/sws_utils.c')
-rw-r--r--video/sws_utils.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/video/sws_utils.c b/video/sws_utils.c
index ee37fc4f91..1a29d87308 100644
--- a/video/sws_utils.c
+++ b/video/sws_utils.c
@@ -124,18 +124,30 @@ bool mp_sws_supported_format(int imgfmt)
&& sws_isSupportedOutput(av_format);
}
+static bool allow_zimg(struct mp_sws_context *ctx)
+{
+ return ctx->force_scaler == MP_SWS_ZIMG ||
+ (ctx->force_scaler == MP_SWS_AUTO && ctx->allow_zimg);
+}
+
+static bool allow_sws(struct mp_sws_context *ctx)
+{
+ return ctx->force_scaler == MP_SWS_SWS || ctx->force_scaler == MP_SWS_AUTO;
+}
+
bool mp_sws_supports_formats(struct mp_sws_context *ctx,
int imgfmt_out, int imgfmt_in)
{
#if HAVE_ZIMG
- if (ctx->allow_zimg) {
+ if (allow_zimg(ctx)) {
if (mp_zimg_supports_in_format(imgfmt_in) &&
mp_zimg_supports_out_format(imgfmt_out))
return true;
}
#endif
- return sws_isSupportedInput(imgfmt2pixfmt(imgfmt_in)) &&
+ return allow_sws(ctx) &&
+ sws_isSupportedInput(imgfmt2pixfmt(imgfmt_in)) &&
sws_isSupportedOutput(imgfmt2pixfmt(imgfmt_out));
}
@@ -158,6 +170,7 @@ static bool cache_valid(struct mp_sws_context *ctx)
ctx->contrast == old->contrast &&
ctx->saturation == old->saturation &&
ctx->allow_zimg == old->allow_zimg &&
+ ctx->force_scaler == old->force_scaler &&
(!ctx->opts_cache || !m_config_cache_update(ctx->opts_cache));
}
@@ -232,7 +245,7 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
ctx->zimg_ok = false;
#if HAVE_ZIMG
- if (ctx->allow_zimg) {
+ if (allow_zimg(ctx)) {
ctx->zimg->log = ctx->log;
ctx->zimg->src = *src;
ctx->zimg->dst = *dst;
@@ -245,6 +258,11 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
}
#endif
+ if (!allow_sws(ctx)) {
+ MP_ERR(ctx, "No scaler.\n");
+ return -1;
+ }
+
ctx->sws = sws_alloc_context();
if (!ctx->sws)
return -1;