diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2013-10-01 19:11:00 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-10-05 18:38:55 +0200 |
commit | 6b3ff6f91a535d6383f41ca7bdf760165dcb6015 (patch) | |
tree | b25f7e164c6b4ec96e8648eac066cb13aac23a6d /libswscale | |
parent | 258414d0771845d20f646ffe4d4e60f22fba217c (diff) | |
download | ffmpeg-6b3ff6f91a535d6383f41ca7bdf760165dcb6015.tar.gz |
swscale: provide a default scaler if none is set
Lanczos for general case, sinc for upscaling, Gaussian for
downscaling. According to current literature these scalers
should be the best quality-wise algorithms for each case.
Inspired from a patch by wm4 <nfxjfg@googlemail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libswscale')
-rw-r--r-- | libswscale/utils.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c index 27819854e4..2111fc2a62 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -914,7 +914,17 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SWS_SINC | SWS_SPLINE | SWS_BICUBLIN); - if (!i || (i & (i - 1))) { + + /* provide a default scaler if not set by caller */ + if (!i) { + if (dstW < srcW && dstH < srcH) + flags |= SWS_GAUSS; + else if (dstW > srcW && dstH > srcH) + flags |= SWS_SINC; + else + flags |= SWS_LANCZOS; + c->flags = flags; + } else if (i & (i - 1)) { av_log(c, AV_LOG_ERROR, "Exactly one scaler algorithm must be chosen\n"); return AVERROR(EINVAL); |