diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-05-31 23:43:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-05-31 23:55:32 +0200 |
commit | 1ff47770ca500abf47761b581e366f3c0b528a30 (patch) | |
tree | 691a3cc137b7331cb7316845948e947e3f5257d2 | |
parent | 1046b6b09326f143f0785cbec461dc7726eece8c (diff) | |
parent | d0bf20a4f25ac5de021c860a0c8ad05638ee2078 (diff) | |
download | ffmpeg-1ff47770ca500abf47761b581e366f3c0b528a30.tar.gz |
Merge commit 'd0bf20a4f25ac5de021c860a0c8ad05638ee2078'
* commit 'd0bf20a4f25ac5de021c860a0c8ad05638ee2078':
ppc: vsx: Implement diff_pixels and get_pixels
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/ppc/pixblockdsp.c | 44 | ||||
-rw-r--r-- | libavutil/ppc/util_altivec.h | 12 |
2 files changed, 56 insertions, 0 deletions
diff --git a/libavcodec/ppc/pixblockdsp.c b/libavcodec/ppc/pixblockdsp.c index 72519949a8..d82c0ea23e 100644 --- a/libavcodec/ppc/pixblockdsp.c +++ b/libavcodec/ppc/pixblockdsp.c @@ -228,6 +228,40 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, #endif /* HAVE_ALTIVEC */ +#if HAVE_VSX +static void get_pixels_vsx(int16_t *restrict block, const uint8_t *pixels, + int line_size) +{ + 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 += line_size; + } +} + +static void diff_pixels_vsx(int16_t *restrict block, const uint8_t *s1, + const uint8_t *s2, int 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_ppc(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) @@ -242,4 +276,14 @@ av_cold void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, c->get_pixels = get_pixels_altivec; } #endif /* HAVE_ALTIVEC */ + +#if HAVE_VSX + if (!PPC_VSX(av_get_cpu_flags())) + return; + + c->diff_pixels = diff_pixels_vsx; + + if (!high_bit_depth) + c->get_pixels = get_pixels_vsx; +#endif /* HAVE_VSX */ } diff --git a/libavutil/ppc/util_altivec.h b/libavutil/ppc/util_altivec.h index 0db58730fe..5527740010 100644 --- a/libavutil/ppc/util_altivec.h +++ b/libavutil/ppc/util_altivec.h @@ -162,4 +162,16 @@ static inline vec_u8 load_with_perm_vec(int offset, const uint8_t *src, vec_u8 p #endif /* HAVE_ALTIVEC */ +#if HAVE_VSX +#if HAVE_BIGENDIAN +#define vsx_ld_u8_s16(off, p) \ + ((vec_s16)vec_mergeh((vec_u8)vec_splat_u8(0), \ + (vec_u8)vec_vsx_ld((off), (p)))) +#else +#define vsx_ld_u8_s16(off, p) \ + ((vec_s16)vec_mergeh((vec_u8)vec_vsx_ld((off), (p)), \ + (vec_u8)vec_splat_u8(0))) +#endif /* HAVE_BIGENDIAN */ +#endif /* HAVE_VSX */ + #endif /* AVUTIL_PPC_UTIL_ALTIVEC_H */ |