According to various literature, Lanczos and Sinc are better for downscaling, 
while Spline and Gaussian so they are set in case these condistions are found.

Inspired from a patch by wm4 <[email protected]>
---
Now without silliness, please disregard the previous version.
Vittorio

 libswscale/utils.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 2781985..7d35f16 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -914,6 +914,17 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter 
*srcFilter,
                  SWS_SINC          |
                  SWS_SPLINE        |
                  SWS_BICUBLIN);
+
+    /* 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;
+
     if (!i || (i & (i - 1))) {
         av_log(c, AV_LOG_ERROR,
                "Exactly one scaler algorithm must be chosen\n");
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to