diff options
author | Rong Yan <rongyan236@gmail.com> | 2014-10-10 08:27:16 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-10 13:32:02 +0200 |
commit | c5ca76ad3b50e0cee1ebacb09e2c030e2c38f8dd (patch) | |
tree | f7ce3406a7aad4b9c7b23e1ff1abd4ec954c04b3 | |
parent | 31dea05170e5c24328133261f689bd32bf950edd (diff) | |
download | ffmpeg-c5ca76ad3b50e0cee1ebacb09e2c030e2c38f8dd.tar.gz |
libavcodec/ppc/mpegvideoencdsp.c : fix pix_norm1_altivec() and pix_sum_altivec() for POWER LE
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/ppc/mpegvideoencdsp.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/libavcodec/ppc/mpegvideoencdsp.c b/libavcodec/ppc/mpegvideoencdsp.c index 00ae2a6f30..e91ba5d25f 100644 --- a/libavcodec/ppc/mpegvideoencdsp.c +++ b/libavcodec/ppc/mpegvideoencdsp.c @@ -31,6 +31,34 @@ #if HAVE_ALTIVEC +#if HAVE_VSX +static int pix_norm1_altivec(uint8_t *pix, int line_size) +{ + int i, s = 0; + const vector unsigned int zero = + (const vector unsigned int) vec_splat_u32(0); + vector unsigned int sv = (vector unsigned int) vec_splat_u32(0); + vector signed int sum; + + for (i = 0; i < 16; i++) { + /* Read the potentially unaligned pixels. */ + //vector unsigned char pixl = vec_ld(0, pix); + //vector unsigned char pixr = vec_ld(15, pix); + //vector unsigned char pixv = vec_perm(pixl, pixr, perm); + vector unsigned char pixv = vec_vsx_ld(0, pix); + + /* Square the values, and add them to our sum. */ + sv = vec_msum(pixv, pixv, sv); + + pix += line_size; + } + /* Sum up the four partial sums, and put the result into s. */ + sum = vec_sums((vector signed int) sv, (vector signed int) zero); + sum = vec_splat(sum, 3); + vec_vsx_st(sum, 0, &s); + return s; +} +#else static int pix_norm1_altivec(uint8_t *pix, int line_size) { int i, s = 0; @@ -58,7 +86,37 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size) return s; } +#endif /* HAVE_VSX */ + +#if HAVE_VSX +static int pix_sum_altivec(uint8_t *pix, int line_size) +{ + int i, s; + const vector unsigned int zero = + (const vector unsigned int) vec_splat_u32(0); + vector unsigned int sad = (vector unsigned int) vec_splat_u32(0); + vector signed int sumdiffs; + + for (i = 0; i < 16; i++) { + /* Read the potentially unaligned 16 pixels into t1. */ + //vector unsigned char pixl = vec_ld(0, pix); + //vector unsigned char pixr = vec_ld(15, pix); + //vector unsigned char t1 = vec_perm(pixl, pixr, perm); + vector unsigned char t1 = vec_vsx_ld(0, pix); + + /* Add each 4 pixel group together and put 4 results into sad. */ + sad = vec_sum4s(t1, sad); + + pix += line_size; + } + /* Sum up the four partial sums, and put the result into s. */ + sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); + sumdiffs = vec_splat(sumdiffs, 3); + vec_vsx_st(sumdiffs, 0, &s); + return s; +} +#else static int pix_sum_altivec(uint8_t *pix, int line_size) { int i, s; @@ -88,6 +146,8 @@ static int pix_sum_altivec(uint8_t *pix, int line_size) return s; } +#endif /* HAVE_VSX */ + #endif /* HAVE_ALTIVEC */ av_cold void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c, |