This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 76cb5691e84a53c9a6173c0e784525e5670b6b76
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Tue Feb 24 15:16:35 2026 +0100
Commit:     Andreas Rheinhardt <[email protected]>
CommitDate: Sat Feb 28 09:56:01 2026 +0100

    swscale/utils: Move altivec init/free code to yuv2rgb_altivec.c
    
    This is in preparation for removing the util_altivec.h inclusion
    in swscale_internal.h, which causes problems (on PPC) because
    it redefines bool to something different from stdbool.h.
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libswscale/ppc/yuv2rgb_altivec.c | 31 +++++++++++++++++++++++++++++++
 libswscale/swscale_internal.h    |  3 +++
 libswscale/utils.c               | 24 ++++--------------------
 3 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index a6b6650e02..3efb33d22e 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -96,6 +96,8 @@
 #include "libswscale/swscale_internal.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
+#include "libavutil/error.h"
+#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "yuv2rgb_altivec.h"
@@ -871,4 +873,33 @@ YUV2PACKEDX_WRAPPER(rgba,  AV_PIX_FMT_RGBA);
 YUV2PACKEDX_WRAPPER(rgb24, AV_PIX_FMT_RGB24);
 YUV2PACKEDX_WRAPPER(bgr24, AV_PIX_FMT_BGR24);
 
+av_cold int ff_sws_init_altivec_bufs(SwsInternal *c)
+{
+    const SwsContext *const sws = &c->opts;
+
+    c->vYCoeffsBank = av_malloc_array(sws->dst_h, c->vLumFilterSize * 
sizeof(*c->vYCoeffsBank));
+    c->vCCoeffsBank = av_malloc_array(c->chrDstH, c->vChrFilterSize * 
sizeof(*c->vCCoeffsBank));
+    if (!c->vYCoeffsBank || !c->vCCoeffsBank)
+        return AVERROR(ENOMEM);
+
+    for (int i = 0; i < c->vLumFilterSize * sws->dst_h; ++i) {
+        short *p = (short *)&c->vYCoeffsBank[i];
+        for (int j = 0; j < 8; ++j)
+            p[j] = c->vLumFilter[i];
+    }
+
+    for (int i = 0; i < c->vChrFilterSize * c->chrDstH; ++i) {
+        short *p = (short *)&c->vCCoeffsBank[i];
+        for (int j = 0; j < 8; ++j)
+            p[j] = c->vChrFilter[i];
+    }
+
+    return 0;
+}
+
+av_cold void ff_sws_free_altivec_bufs(SwsInternal *c)
+{
+    av_freep(&c->vYCoeffsBank);
+    av_freep(&c->vCCoeffsBank);
+}
 #endif /* HAVE_ALTIVEC */
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 81ec5ef0cc..d9fddb271b 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -1039,6 +1039,9 @@ void ff_sws_init_swscale_arm(SwsInternal *c);
 void ff_sws_init_swscale_loongarch(SwsInternal *c);
 void ff_sws_init_swscale_riscv(SwsInternal *c);
 
+int ff_sws_init_altivec_bufs(SwsInternal *c);
+void ff_sws_free_altivec_bufs(SwsInternal *c);
+
 void ff_hyscale_fast_c(SwsInternal *c, int16_t *dst, int dstWidth,
                        const uint8_t *src, int srcW, int xInc);
 void ff_hcscale_fast_c(SwsInternal *c, int16_t *dst1, int16_t *dst2,
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 42b49a5cd5..4e6e503b75 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1729,24 +1729,9 @@ av_cold int ff_sws_init_single_context(SwsContext *sws, 
SwsFilter *srcFilter,
             goto fail;
 
 #if HAVE_ALTIVEC
-        c->vYCoeffsBank = av_malloc_array(sws->dst_h, c->vLumFilterSize * 
sizeof(*c->vYCoeffsBank));
-        c->vCCoeffsBank = av_malloc_array(c->chrDstH, c->vChrFilterSize * 
sizeof(*c->vCCoeffsBank));
-        if (c->vYCoeffsBank == NULL || c->vCCoeffsBank == NULL)
-            goto nomem;
-
-        for (i = 0; i < c->vLumFilterSize * sws->dst_h; i++) {
-            int j;
-            short *p = (short *)&c->vYCoeffsBank[i];
-            for (j = 0; j < 8; j++)
-                p[j] = c->vLumFilter[i];
-        }
-
-        for (i = 0; i < c->vChrFilterSize * c->chrDstH; i++) {
-            int j;
-            short *p = (short *)&c->vCCoeffsBank[i];
-            for (j = 0; j < 8; j++)
-                p[j] = c->vChrFilter[i];
-        }
+        ret = ff_sws_init_altivec_bufs(c);
+        if (ret < 0)
+            goto fail;
 #endif
     }
 
@@ -2290,8 +2275,7 @@ void sws_freeContext(SwsContext *sws)
     av_freep(&c->hLumFilter);
     av_freep(&c->hChrFilter);
 #if HAVE_ALTIVEC
-    av_freep(&c->vYCoeffsBank);
-    av_freep(&c->vCCoeffsBank);
+    ff_sws_free_altivec_bufs(c);
 #endif
 
     av_freep(&c->vLumFilterPos);

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to