1 /*
2 * Copyright (c) 2018, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11 #ifndef AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_SSE2_H_
12 #define AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_SSE2_H_
13
14 #include <immintrin.h>
15
16 #include "config/aom_config.h"
17 #include "config/av1_rtcd.h"
18
19 #include "aom/aom_integer.h"
20 #include "aom_dsp/x86/transpose_sse2.h"
21 #include "aom_dsp/x86/txfm_common_sse2.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 void av1_fdct8x32_new_sse2(const __m128i *input, __m128i *output,
28 int8_t cos_bit);
29 void av1_fdct8x64_new_sse2(const __m128i *input, __m128i *output,
30 int8_t cos_bit);
31
fidentity4x4_new_sse2(const __m128i * const input,__m128i * const output,const int8_t cos_bit)32 static INLINE void fidentity4x4_new_sse2(const __m128i *const input,
33 __m128i *const output,
34 const int8_t cos_bit) {
35 (void)cos_bit;
36 const __m128i one = _mm_set1_epi16(1);
37
38 for (int i = 0; i < 4; ++i) {
39 const __m128i a = _mm_unpacklo_epi16(input[i], one);
40 const __m128i b = scale_round_sse2(a, NewSqrt2);
41 output[i] = _mm_packs_epi32(b, b);
42 }
43 }
44
fidentity8x4_new_sse2(const __m128i * const input,__m128i * const output,const int8_t cos_bit)45 static INLINE void fidentity8x4_new_sse2(const __m128i *const input,
46 __m128i *const output,
47 const int8_t cos_bit) {
48 (void)cos_bit;
49 const __m128i one = _mm_set1_epi16(1);
50
51 for (int i = 0; i < 4; ++i) {
52 const __m128i a_lo = _mm_unpacklo_epi16(input[i], one);
53 const __m128i a_hi = _mm_unpackhi_epi16(input[i], one);
54 const __m128i b_lo = scale_round_sse2(a_lo, NewSqrt2);
55 const __m128i b_hi = scale_round_sse2(a_hi, NewSqrt2);
56 output[i] = _mm_packs_epi32(b_lo, b_hi);
57 }
58 }
59
fidentity8x8_new_sse2(const __m128i * input,__m128i * output,int8_t cos_bit)60 static INLINE void fidentity8x8_new_sse2(const __m128i *input, __m128i *output,
61 int8_t cos_bit) {
62 (void)cos_bit;
63
64 output[0] = _mm_adds_epi16(input[0], input[0]);
65 output[1] = _mm_adds_epi16(input[1], input[1]);
66 output[2] = _mm_adds_epi16(input[2], input[2]);
67 output[3] = _mm_adds_epi16(input[3], input[3]);
68 output[4] = _mm_adds_epi16(input[4], input[4]);
69 output[5] = _mm_adds_epi16(input[5], input[5]);
70 output[6] = _mm_adds_epi16(input[6], input[6]);
71 output[7] = _mm_adds_epi16(input[7], input[7]);
72 }
73
fidentity8x16_new_sse2(const __m128i * input,__m128i * output,int8_t cos_bit)74 static INLINE void fidentity8x16_new_sse2(const __m128i *input, __m128i *output,
75 int8_t cos_bit) {
76 (void)cos_bit;
77 const __m128i one = _mm_set1_epi16(1);
78
79 for (int i = 0; i < 16; ++i) {
80 const __m128i a_lo = _mm_unpacklo_epi16(input[i], one);
81 const __m128i a_hi = _mm_unpackhi_epi16(input[i], one);
82 const __m128i b_lo = scale_round_sse2(a_lo, 2 * NewSqrt2);
83 const __m128i b_hi = scale_round_sse2(a_hi, 2 * NewSqrt2);
84 output[i] = _mm_packs_epi32(b_lo, b_hi);
85 }
86 }
87
fidentity8x32_new_sse2(const __m128i * input,__m128i * output,int8_t cos_bit)88 static INLINE void fidentity8x32_new_sse2(const __m128i *input, __m128i *output,
89 int8_t cos_bit) {
90 (void)cos_bit;
91 for (int i = 0; i < 32; ++i) {
92 output[i] = _mm_slli_epi16(input[i], 2);
93 }
94 }
95
96 static const transform_1d_sse2 col_txfm8x32_arr[TX_TYPES] = {
97 av1_fdct8x32_new_sse2, // DCT_DCT
98 NULL, // ADST_DCT
99 NULL, // DCT_ADST
100 NULL, // ADST_ADST
101 NULL, // FLIPADST_DCT
102 NULL, // DCT_FLIPADST
103 NULL, // FLIPADST_FLIPADST
104 NULL, // ADST_FLIPADST
105 NULL, // FLIPADST_ADST
106 fidentity8x32_new_sse2, // IDTX
107 av1_fdct8x32_new_sse2, // V_DCT
108 fidentity8x32_new_sse2, // H_DCT
109 NULL, // V_ADST
110 NULL, // H_ADST
111 NULL, // V_FLIPADST
112 NULL // H_FLIPADST
113 };
114
115 #ifdef __cplusplus
116 }
117 #endif
118
119 #endif // AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_SSE2_H_
120