[FFmpeg-devel] [patch 4/4] Fix bug for POWERLE: libswscale/ppc/swscale_altivec.c
Michael Niedermayer
michaelni at gmx.at
Fri Nov 7 18:54:22 CET 2014
On Fri, Nov 07, 2014 at 05:43:22PM +0800, rongyan wrote:
> Hi,
> There are 4 patches presented to fix bugs for POWER8 little endian. I will send 4 patches in 4 different email. This is the fourth.
>
> It fixed the function hScale_altivec_real(), yuv2planeX_16_altivec(), yuv2planeX_8().
>
> The fate test result on POWER BE and POWER LE after merge these 4 patches are attached here to facilitate the review:
>
> The passed test cases change from 1679/2182 to 2010/2236.
>
>
>
>
> Rong Yan
>
>
> ------------------
> The world has enough for everyone's need, but not enough for everyone's greed.
> swscale_altivec.c | 142 +++++++++++++++++++-----------------------------------
> 1 file changed, 50 insertions(+), 92 deletions(-)
> 0c364d48e08b7df42bee5e269fe46b2d7be0f4b9 0004-libswscale-ppc-swscale_altivec.c-fix-hScale_altivec_.patch
> From 9ec626726d1cc30db54390ee81f52cfe53ebeedf Mon Sep 17 00:00:00 2001
> From: Rong Yan <rongyan236 at gmail.com>
> Date: Fri, 7 Nov 2014 09:09:09 +0000
> Subject: [PATCH 4/4] libswscale/ppc/swscale_altivec.c : fix
> hScale_altivec_real() yuv2planeX_16_altivec() yuv2planeX_8() for POWER LE
>
> ---
> libswscale/ppc/swscale_altivec.c | 142 ++++++++++++++-------------------------
> 1 file changed, 50 insertions(+), 92 deletions(-)
>
> diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c
> index 86f40ab..1673b8b 100644
> --- a/libswscale/ppc/swscale_altivec.c
> +++ b/libswscale/ppc/swscale_altivec.c
> @@ -29,20 +29,30 @@
> #include "libavutil/attributes.h"
> #include "libavutil/cpu.h"
> #include "yuv2rgb_altivec.h"
> +#include "libavutil/ppc/util_altivec.h"
>
> #if HAVE_ALTIVEC
> #define vzero vec_splat_s32(0)
>
> -#define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do { \
> - vector signed short l2 = vec_ld(((x) << 1) + 16, src); \
> - vector signed short ls = vec_perm(l1, l2, perm); \
> - vector signed int i1 = vec_mule(filter, ls); \
> - vector signed int i2 = vec_mulo(filter, ls); \
> - vector signed int vf1 = vec_mergeh(i1, i2); \
> - vector signed int vf2 = vec_mergel(i1, i2); \
> - d1 = vec_add(d1, vf1); \
> - d2 = vec_add(d2, vf2); \
> - l1 = l2; \
> +#if HAVE_BIGENDIAN
> +#define GET_VF(a, b) {\
> + a = vec_mergeh(i1, i2);\
> + b = vec_mergel(i1, i2);\
> + }
> +#else
> +#define GET_VF(a, b) {\
> + a = vec_mergel(i2, i1);\
> + b = vec_mergeh(i2, i1);\
> + }
> +#endif
> +
> +#define yuv2planeX_8(d1, d2, l1, src, x, filter) do {\
> + vector signed int i1 = vec_mule(filter, l1);\
> + vector signed int i2 = vec_mulo(filter, l1);\
> + vector signed int vf1, vf2;\
> + GET_VF(vf1, vf2);\
> + d1 = vec_add(d1, vf1);\
> + d2 = vec_add(d2, vf2);\
> } while (0)
>
> static void yuv2planeX_16_altivec(const int16_t *filter, int filterSize,
> @@ -66,16 +76,13 @@ static void yuv2planeX_16_altivec(const int16_t *filter, int filterSize,
> vo4 = vec_ld(48, val);
>
> for (j = 0; j < filterSize; j++) {
> - vector signed short l1, vLumFilter = vec_ld(j << 1, filter);
> - vector unsigned char perm, perm0 = vec_lvsl(j << 1, filter);
> - vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
> + vector signed short l1, l2;
> + vector signed short vLumFilter = (vector signed short)unaligned_load(j << 1, filter);
> vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter
> -
> - perm = vec_lvsl(x << 1, src[j]);
> - l1 = vec_ld(x << 1, src[j]);
> -
> - yuv2planeX_8(vo1, vo2, l1, src[j], x, perm, vLumFilter);
> - yuv2planeX_8(vo3, vo4, l1, src[j], x + 8, perm, vLumFilter);
> + l1 = (vector signed short)unaligned_load(x << 1, src[j]);
> + l2 = (vector signed short)unaligned_load(((x) << 1) + 16, src[j]);
> + yuv2planeX_8(vo1, vo2, l1, src[j], x, vLumFilter);
> + yuv2planeX_8(vo3, vo4, l2, src[j], x + 8, vLumFilter);
> }
i belive this uses more vec_ld() on big endian than before.
i counted 4 before and 6 after the change
this would likely slow big endian down
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141107/ee450cff/attachment.asc>
More information about the ffmpeg-devel
mailing list