[FFmpeg-devel] [PATCH 2/3] Revert "swscale: fix sws_setColorspaceDetails after sws_init_context"

Michael Niedermayer michael at niedermayer.cc
Tue Feb 20 04:49:21 EET 2024


Suggested by: Niklas Haas in Ticket10824

Fixes: Assertion failure
Fixes: Ticket10824

This reverts commit cedf589c09c567b72bf4c1a58db53d94622567e1.
---
 libswscale/swscale.c |  2 +-
 libswscale/utils.c   | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 7bea5147db..fe0e74f871 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1017,7 +1017,7 @@ static int scale_internal(SwsContext *c,
     reset_ptr(src2, c->srcFormat);
     reset_ptr((void*)dst2, c->dstFormat);
 
-    if (c->convert_unscaled && !c->lumConvertRange && !c->chrConvertRange) {
+    if (c->convert_unscaled) {
         int offset  = srcSliceY_internal;
         int slice_h = srcSliceH;
 
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 4dc0fbfefb..d27128e42f 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1713,26 +1713,30 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
     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,
-                    "alpha blendaway %s -> %s special converter is available\n",
+                    "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) {
+    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,
-                       "unscaled %s -> %s special converter is available\n",
+                       "using unscaled %s -> %s special converter\n",
                        av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
+            return 0;
         }
     }
 
-- 
2.17.1



More information about the ffmpeg-devel mailing list