bitdepth_conversion_vsx.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2017 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VPX_VPX_DSP_PPC_BITDEPTH_CONVERSION_VSX_H_
  11. #define VPX_VPX_DSP_PPC_BITDEPTH_CONVERSION_VSX_H_
  12. #include "./vpx_config.h"
  13. #include "vpx/vpx_integer.h"
  14. #include "vpx_dsp/vpx_dsp_common.h"
  15. #include "vpx_dsp/ppc/types_vsx.h"
  16. // Load 8 16 bit values. If the source is 32 bits then pack down with
  17. // saturation.
  18. static INLINE int16x8_t load_tran_low(int32_t c, const tran_low_t *s) {
  19. #if CONFIG_VP9_HIGHBITDEPTH
  20. int32x4_t u = vec_vsx_ld(c, s);
  21. int32x4_t v = vec_vsx_ld(c, s + 4);
  22. return vec_packs(u, v);
  23. #else
  24. return vec_vsx_ld(c, s);
  25. #endif
  26. }
  27. // Store 8 16 bit values. If the destination is 32 bits then sign extend the
  28. // values by multiplying by 1.
  29. static INLINE void store_tran_low(int16x8_t v, int32_t c, tran_low_t *s) {
  30. #if CONFIG_VP9_HIGHBITDEPTH
  31. const int16x8_t one = vec_splat_s16(1);
  32. const int32x4_t even = vec_mule(v, one);
  33. const int32x4_t odd = vec_mulo(v, one);
  34. const int32x4_t high = vec_mergeh(even, odd);
  35. const int32x4_t low = vec_mergel(even, odd);
  36. vec_vsx_st(high, c, s);
  37. vec_vsx_st(low, c, s + 4);
  38. #else
  39. vec_vsx_st(v, c, s);
  40. #endif
  41. }
  42. #endif // VPX_VPX_DSP_PPC_BITDEPTH_CONVERSION_VSX_H_