[FFmpeg-cvslog] sws/utils.c: Do not uselessly call initFilter() when unscaling

Tomas Härdin git at videolan.org
Wed Feb 8 16:54:29 EET 2023


ffmpeg | branch: master | Tomas Härdin <git at haerdin.se> | Tue Jan 31 16:33:21 2023 +0100| [a678b0c252473831c346d21f9412679ef789bf91] | committer: Tomas Härdin

sws/utils.c: Do not uselessly call initFilter() when unscaling

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a678b0c252473831c346d21f9412679ef789bf91
---

 libswscale/utils.c | 62 +++++++++++++++++++++++++++---------------------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 90734f66ef..925c536bf1 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1701,6 +1701,37 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
         }
     }
 
+    /* alpha blend special case, note this has been split via cascaded contexts if its scaled */
+    if (unscaled && !usesHFilter && !usesVFilter &&
+        c->alphablend != SWS_ALPHA_BLEND_NONE &&
+        isALPHA(srcFormat) &&
+        (c->srcRange == c->dstRange || isAnyRGB(dstFormat)) &&
+        alphaless_fmt(srcFormat) == dstFormat
+    ) {
+        c->convert_unscaled = ff_sws_alphablendaway;
+
+        if (flags & SWS_PRINT_INFO)
+            av_log(c, AV_LOG_INFO,
+                    "using alpha blendaway %s -> %s special converter\n",
+                    av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
+        return 0;
+    }
+
+    /* unscaled special cases */
+    if (unscaled && !usesHFilter && !usesVFilter &&
+        (c->srcRange == c->dstRange || isAnyRGB(dstFormat) ||
+         isFloat(srcFormat) || isFloat(dstFormat))){
+        ff_get_unscaled_swscale(c);
+
+        if (c->convert_unscaled) {
+            if (flags & SWS_PRINT_INFO)
+                av_log(c, AV_LOG_INFO,
+                       "using unscaled %s -> %s special converter\n",
+                       av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
+            return 0;
+        }
+    }
+
 #if HAVE_MMAP && HAVE_MPROTECT && defined(MAP_ANONYMOUS)
 #define USE_MMAP 1
 #else
@@ -1905,37 +1936,6 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
                c->chrXInc, c->chrYInc);
     }
 
-    /* alpha blend special case, note this has been split via cascaded contexts if its scaled */
-    if (unscaled && !usesHFilter && !usesVFilter &&
-        c->alphablend != SWS_ALPHA_BLEND_NONE &&
-        isALPHA(srcFormat) &&
-        (c->srcRange == c->dstRange || isAnyRGB(dstFormat)) &&
-        alphaless_fmt(srcFormat) == dstFormat
-    ) {
-        c->convert_unscaled = ff_sws_alphablendaway;
-
-        if (flags & SWS_PRINT_INFO)
-            av_log(c, AV_LOG_INFO,
-                    "using alpha blendaway %s -> %s special converter\n",
-                    av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
-        return 0;
-    }
-
-    /* unscaled special cases */
-    if (unscaled && !usesHFilter && !usesVFilter &&
-        (c->srcRange == c->dstRange || isAnyRGB(dstFormat) ||
-         isFloat(srcFormat) || isFloat(dstFormat))){
-        ff_get_unscaled_swscale(c);
-
-        if (c->convert_unscaled) {
-            if (flags & SWS_PRINT_INFO)
-                av_log(c, AV_LOG_INFO,
-                       "using unscaled %s -> %s special converter\n",
-                       av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
-            return 0;
-        }
-    }
-
     ff_sws_init_scale(c);
 
     return ff_init_filters(c);



More information about the ffmpeg-cvslog mailing list