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>
This commit is contained in:
Kacper Michajłow committed 2026-11-02 07:24:04 +00:00
1 parent 18f244a180
commit fa32b71a24
11 files changed
+185 -80

No files matched your search

+5
View File
@@ -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
-32
View File
@@ -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 */
}
-1
View File
@@ -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 */
+1
View File
@@ -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)
{
+54
View File
@@ -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;
}
+26
View File
@@ -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 */
-45
View File
@@ -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 */
}
-2
View File
@@ -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 */
+1
View File
@@ -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)
+71
View File
@@ -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;
}
+27
View File
@@ -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 */