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
11 #ifndef VPX_VPX_DSP_PPC_BITDEPTH_CONVERSION_VSX_H_
12 #define VPX_VPX_DSP_PPC_BITDEPTH_CONVERSION_VSX_H_
13
14 #include "./vpx_config.h"
15 #include "vpx/vpx_integer.h"
16 #include "vpx_dsp/vpx_dsp_common.h"
17 #include "vpx_dsp/ppc/types_vsx.h"
18
19 // Load 8 16 bit values. If the source is 32 bits then pack down with
20 // saturation.
load_tran_low(int32_t c,const tran_low_t * s)21 static INLINE int16x8_t load_tran_low(int32_t c, const tran_low_t *s) {
22 #if CONFIG_VP9_HIGHBITDEPTH
23 int32x4_t u = vec_vsx_ld(c, s);
24 int32x4_t v = vec_vsx_ld(c, s + 4);
25 return vec_packs(u, v);
26 #else
27 return vec_vsx_ld(c, s);
28 #endif
29 }
30
31 // Store 8 16 bit values. If the destination is 32 bits then sign extend the
32 // values by multiplying by 1.
store_tran_low(int16x8_t v,int32_t c,tran_low_t * s)33 static INLINE void store_tran_low(int16x8_t v, int32_t c, tran_low_t *s) {
34 #if CONFIG_VP9_HIGHBITDEPTH
35 const int16x8_t one = vec_splat_s16(1);
36 const int32x4_t even = vec_mule(v, one);
37 const int32x4_t odd = vec_mulo(v, one);
38 const int32x4_t high = vec_mergeh(even, odd);
39 const int32x4_t low = vec_mergel(even, odd);
40 vec_vsx_st(high, c, s);
41 vec_vsx_st(low, c, s + 4);
42 #else
43 vec_vsx_st(v, c, s);
44 #endif
45 }
46
47 #endif // VPX_VPX_DSP_PPC_BITDEPTH_CONVERSION_VSX_H_
48