Commit fa32b71a24 for ffmpeg
commit fa32b71a249a090be759d917ea130c56a3bc6a9a
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Mon Oct 26 16:07:20 2026 +0100
avcodec/ppc: move the VSX code to *_vsx.c
The VSX functions of audiodsp and pixblockdsp are in the AltiVec files,
which without VSX build ff_audiodsp_init_vsx() and
ff_pixblockdsp_init_vsx() with empty bodies that are never called. Move
the VSX functions and their init functions to *_vsx.c files built as
VSX-OBJS, like libavutil/ppc/float_dsp_vsx.c.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
index ce2c2a4c8a..cb37f29f69 100644
--- a/libavcodec/ppc/Makefile
+++ b/libavcodec/ppc/Makefile
@@ -51,3 +51,8 @@ ALTIVEC-OBJS-$(CONFIG_MPEG4_DECODER) += ppc/mpeg4videodsp_altivec.o
ALTIVEC-OBJS-$(CONFIG_SVQ1_ENCODER) += ppc/svq1enc_altivec.o
ALTIVEC-OBJS-$(CONFIG_VORBIS_DECODER) += ppc/vorbisdsp_altivec.o
ALTIVEC-OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o
+
+# VSX optimizations
+# subsystems
+VSX-OBJS-$(CONFIG_AUDIODSP) += ppc/audiodsp_vsx.o
+VSX-OBJS-$(CONFIG_PIXBLOCKDSP) += ppc/pixblockdsp_vsx.o
diff --git a/libavcodec/ppc/audiodsp_altivec.c b/libavcodec/ppc/audiodsp_altivec.c
index 45c537af63..c6878bb973 100644
--- a/libavcodec/ppc/audiodsp_altivec.c
+++ b/libavcodec/ppc/audiodsp_altivec.c
@@ -54,39 +54,7 @@ static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
return ires;
}
-#if HAVE_VSX
-
-static int32_t scalarproduct_int16_vsx(const int16_t *v1, const int16_t *v2, int order)
-{
- int i;
- LOAD_ZERO;
- register vec_s16 vec1;
- register vec_s32 res = vec_splat_s32(0), t;
- int32_t ires;
-
- for (i = 0; i < order; i += 8) {
- vec1 = vec_vsx_ld(0, v1);
- t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
- res = vec_sums(t, res);
- v1 += 8;
- v2 += 8;
- }
- res = vec_splat(res, 3);
- vec_ste(res, 0, &ires);
-
- return ires;
-}
-
-#endif /* HAVE_VSX */
-
av_cold void ff_audiodsp_init_altivec(AudioDSPContext *c)
{
c->scalarproduct_int16 = scalarproduct_int16_altivec;
}
-
-av_cold void ff_audiodsp_init_vsx(AudioDSPContext *c)
-{
-#if HAVE_VSX
- c->scalarproduct_int16 = scalarproduct_int16_vsx;
-#endif /* HAVE_VSX */
-}
diff --git a/libavcodec/ppc/audiodsp_altivec.h b/libavcodec/ppc/audiodsp_altivec.h
index e97c50142a..3613459b35 100644
--- a/libavcodec/ppc/audiodsp_altivec.h
+++ b/libavcodec/ppc/audiodsp_altivec.h
@@ -22,6 +22,5 @@
#include "libavcodec/audiodsp.h"
void ff_audiodsp_init_altivec(AudioDSPContext *c);
-void ff_audiodsp_init_vsx(AudioDSPContext *c);
#endif /* AVCODEC_PPC_AUDIODSP_ALTIVEC_H */
diff --git a/libavcodec/ppc/audiodsp_init.c b/libavcodec/ppc/audiodsp_init.c
index 5de463128a..b2df5bb447 100644
--- a/libavcodec/ppc/audiodsp_init.c
+++ b/libavcodec/ppc/audiodsp_init.c
@@ -23,6 +23,7 @@
#include "libavcodec/audiodsp.h"
#include "audiodsp_altivec.h"
+#include "audiodsp_vsx.h"
av_cold void ff_audiodsp_init_ppc(AudioDSPContext *c)
{
diff --git a/libavcodec/ppc/audiodsp_vsx.c b/libavcodec/ppc/audiodsp_vsx.c
new file mode 100644
index 0000000000..e6972dc610
--- /dev/null
+++ b/libavcodec/ppc/audiodsp_vsx.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007 Luca Barbato <lu_zero@gentoo.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/ppc/util_altivec.h"
+
+#include "libavcodec/audiodsp.h"
+
+#include "audiodsp_vsx.h"
+
+static int32_t scalarproduct_int16_vsx(const int16_t *v1, const int16_t *v2, int order)
+{
+ int i;
+ LOAD_ZERO;
+ register vec_s16 vec1;
+ register vec_s32 res = vec_splat_s32(0), t;
+ int32_t ires;
+
+ for (i = 0; i < order; i += 8) {
+ vec1 = vec_vsx_ld(0, v1);
+ t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
+ res = vec_sums(t, res);
+ v1 += 8;
+ v2 += 8;
+ }
+ res = vec_splat(res, 3);
+ vec_ste(res, 0, &ires);
+
+ return ires;
+}
+
+av_cold void ff_audiodsp_init_vsx(AudioDSPContext *c)
+{
+ c->scalarproduct_int16 = scalarproduct_int16_vsx;
+}
diff --git a/libavcodec/ppc/audiodsp_vsx.h b/libavcodec/ppc/audiodsp_vsx.h
new file mode 100644
index 0000000000..cee6c359af
--- /dev/null
+++ b/libavcodec/ppc/audiodsp_vsx.h
@@ -0,0 +1,26 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_PPC_AUDIODSP_VSX_H
+#define AVCODEC_PPC_AUDIODSP_VSX_H
+
+#include "libavcodec/audiodsp.h"
+
+void ff_audiodsp_init_vsx(AudioDSPContext *c);
+
+#endif /* AVCODEC_PPC_AUDIODSP_VSX_H */
diff --git a/libavcodec/ppc/pixblockdsp_altivec.c b/libavcodec/ppc/pixblockdsp_altivec.c
index d78a5d45aa..893220e8af 100644
--- a/libavcodec/ppc/pixblockdsp_altivec.c
+++ b/libavcodec/ppc/pixblockdsp_altivec.c
@@ -223,40 +223,6 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
#endif /* HAVE_VSX */
-#if HAVE_VSX
-static void get_pixels_vsx(int16_t *restrict block, const uint8_t *pixels,
- ptrdiff_t stride)
-{
- int i;
- for (i = 0; i < 8; i++) {
- vec_s16 shorts = vsx_ld_u8_s16(0, pixels);
-
- vec_vsx_st(shorts, i * 16, block);
-
- pixels += stride;
- }
-}
-
-static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1,
- const uint8_t *s2, ptrdiff_t stride)
-{
- int i;
- vec_s16 shorts1, shorts2;
- for (i = 0; i < 8; i++) {
- shorts1 = vsx_ld_u8_s16(0, s1);
- shorts2 = vsx_ld_u8_s16(0, s2);
-
- shorts1 = vec_sub(shorts1, shorts2);
-
- vec_vsx_st(shorts1, 0, block);
-
- s1 += stride;
- s2 += stride;
- block += 8;
- }
-}
-#endif /* HAVE_VSX */
-
av_cold void ff_pixblockdsp_init_altivec(PixblockDSPContext *c,
unsigned high_bit_depth)
{
@@ -266,14 +232,3 @@ av_cold void ff_pixblockdsp_init_altivec(PixblockDSPContext *c,
c->get_pixels = get_pixels_altivec;
}
}
-
-av_cold void ff_pixblockdsp_init_vsx(PixblockDSPContext *c,
- unsigned high_bit_depth)
-{
-#if HAVE_VSX
- c->diff_pixels = diff_pixels_vsx;
-
- if (!high_bit_depth)
- c->get_pixels = get_pixels_vsx;
-#endif /* HAVE_VSX */
-}
diff --git a/libavcodec/ppc/pixblockdsp_altivec.h b/libavcodec/ppc/pixblockdsp_altivec.h
index 5717ab6a08..4df5101a22 100644
--- a/libavcodec/ppc/pixblockdsp_altivec.h
+++ b/libavcodec/ppc/pixblockdsp_altivec.h
@@ -23,7 +23,5 @@
void ff_pixblockdsp_init_altivec(PixblockDSPContext *c,
unsigned high_bit_depth);
-void ff_pixblockdsp_init_vsx(PixblockDSPContext *c,
- unsigned high_bit_depth);
#endif /* AVCODEC_PPC_PIXBLOCKDSP_ALTIVEC_H */
diff --git a/libavcodec/ppc/pixblockdsp_init.c b/libavcodec/ppc/pixblockdsp_init.c
index c87c96dd1a..8027ab1269 100644
--- a/libavcodec/ppc/pixblockdsp_init.c
+++ b/libavcodec/ppc/pixblockdsp_init.c
@@ -23,6 +23,7 @@
#include "libavcodec/pixblockdsp.h"
#include "pixblockdsp_altivec.h"
+#include "pixblockdsp_vsx.h"
av_cold void ff_pixblockdsp_init_ppc(PixblockDSPContext *c,
unsigned high_bit_depth)
diff --git a/libavcodec/ppc/pixblockdsp_vsx.c b/libavcodec/ppc/pixblockdsp_vsx.c
new file mode 100644
index 0000000000..fd3c112d09
--- /dev/null
+++ b/libavcodec/ppc/pixblockdsp_vsx.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2002 Brian Foley
+ * Copyright (c) 2002 Dieter Shirley
+ * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/ppc/util_altivec.h"
+
+#include "libavcodec/pixblockdsp.h"
+
+#include "pixblockdsp_vsx.h"
+
+static void get_pixels_vsx(int16_t *restrict block, const uint8_t *pixels,
+ ptrdiff_t stride)
+{
+ int i;
+ for (i = 0; i < 8; i++) {
+ vec_s16 shorts = vsx_ld_u8_s16(0, pixels);
+
+ vec_vsx_st(shorts, i * 16, block);
+
+ pixels += stride;
+ }
+}
+
+static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1,
+ const uint8_t *s2, ptrdiff_t stride)
+{
+ int i;
+ vec_s16 shorts1, shorts2;
+ for (i = 0; i < 8; i++) {
+ shorts1 = vsx_ld_u8_s16(0, s1);
+ shorts2 = vsx_ld_u8_s16(0, s2);
+
+ shorts1 = vec_sub(shorts1, shorts2);
+
+ vec_vsx_st(shorts1, 0, block);
+
+ s1 += stride;
+ s2 += stride;
+ block += 8;
+ }
+}
+
+av_cold void ff_pixblockdsp_init_vsx(PixblockDSPContext *c,
+ unsigned high_bit_depth)
+{
+ c->diff_pixels = diff_pixels_vsx;
+
+ if (!high_bit_depth)
+ c->get_pixels = get_pixels_vsx;
+}
diff --git a/libavcodec/ppc/pixblockdsp_vsx.h b/libavcodec/ppc/pixblockdsp_vsx.h
new file mode 100644
index 0000000000..60d38fd747
--- /dev/null
+++ b/libavcodec/ppc/pixblockdsp_vsx.h
@@ -0,0 +1,27 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_PPC_PIXBLOCKDSP_VSX_H
+#define AVCODEC_PPC_PIXBLOCKDSP_VSX_H
+
+#include "libavcodec/pixblockdsp.h"
+
+void ff_pixblockdsp_init_vsx(PixblockDSPContext *c,
+ unsigned high_bit_depth);
+
+#endif /* AVCODEC_PPC_PIXBLOCKDSP_VSX_H */