1 /* 2 * Copyright (c) 2012 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 #include <emmintrin.h> // SSE2 12 #include "vp9/common/vp9_idct.h" // for cospi constants 13 #include "vpx_ports/mem.h" 14 15 #if FDCT32x32_HIGH_PRECISION 16 static INLINE __m128i k_madd_epi32(__m128i a, __m128i b) { 17 __m128i buf0, buf1; 18 buf0 = _mm_mul_epu32(a, b); 19 a = _mm_srli_epi64(a, 32); 20 b = _mm_srli_epi64(b, 32); 21 buf1 = _mm_mul_epu32(a, b); 22 return _mm_add_epi64(buf0, buf1); 23 } 24 25 static INLINE __m128i k_packs_epi64(__m128i a, __m128i b) { 26 __m128i buf0 = _mm_shuffle_epi32(a, _MM_SHUFFLE(0, 0, 2, 0)); 27 __m128i buf1 = _mm_shuffle_epi32(b, _MM_SHUFFLE(0, 0, 2, 0)); 28 return _mm_unpacklo_epi64(buf0, buf1); 29 } 30 #endif 31 32 void FDCT32x32_2D(const int16_t *input, 33 int16_t *output_org, int stride) { 34 // Calculate pre-multiplied strides 35 const int str1 = stride; 36 const int str2 = 2 * stride; 37 const int str3 = 2 * stride + str1; 38 // We need an intermediate buffer between passes. 39 DECLARE_ALIGNED(16, int16_t, intermediate[32 * 32]); 40 // Constants 41 // When we use them, in one case, they are all the same. In all others 42 // it's a pair of them that we need to repeat four times. This is done 43 // by constructing the 32 bit constant corresponding to that pair. 44 const __m128i k__cospi_p16_p16 = _mm_set1_epi16(+cospi_16_64); 45 const __m128i k__cospi_p16_m16 = pair_set_epi16(+cospi_16_64, -cospi_16_64); 46 const __m128i k__cospi_m08_p24 = pair_set_epi16(-cospi_8_64, cospi_24_64); 47 const __m128i k__cospi_m24_m08 = pair_set_epi16(-cospi_24_64, -cospi_8_64); 48 const __m128i k__cospi_p24_p08 = pair_set_epi16(+cospi_24_64, cospi_8_64); 49 const __m128i k__cospi_p12_p20 = pair_set_epi16(+cospi_12_64, cospi_20_64); 50 const __m128i k__cospi_m20_p12 = pair_set_epi16(-cospi_20_64, cospi_12_64); 51 const __m128i k__cospi_m04_p28 = pair_set_epi16(-cospi_4_64, cospi_28_64); 52 const __m128i k__cospi_p28_p04 = pair_set_epi16(+cospi_28_64, cospi_4_64); 53 const __m128i k__cospi_m28_m04 = pair_set_epi16(-cospi_28_64, -cospi_4_64); 54 const __m128i k__cospi_m12_m20 = pair_set_epi16(-cospi_12_64, -cospi_20_64); 55 const __m128i k__cospi_p30_p02 = pair_set_epi16(+cospi_30_64, cospi_2_64); 56 const __m128i k__cospi_p14_p18 = pair_set_epi16(+cospi_14_64, cospi_18_64); 57 const __m128i k__cospi_p22_p10 = pair_set_epi16(+cospi_22_64, cospi_10_64); 58 const __m128i k__cospi_p06_p26 = pair_set_epi16(+cospi_6_64, cospi_26_64); 59 const __m128i k__cospi_m26_p06 = pair_set_epi16(-cospi_26_64, cospi_6_64); 60 const __m128i k__cospi_m10_p22 = pair_set_epi16(-cospi_10_64, cospi_22_64); 61 const __m128i k__cospi_m18_p14 = pair_set_epi16(-cospi_18_64, cospi_14_64); 62 const __m128i k__cospi_m02_p30 = pair_set_epi16(-cospi_2_64, cospi_30_64); 63 const __m128i k__cospi_p31_p01 = pair_set_epi16(+cospi_31_64, cospi_1_64); 64 const __m128i k__cospi_p15_p17 = pair_set_epi16(+cospi_15_64, cospi_17_64); 65 const __m128i k__cospi_p23_p09 = pair_set_epi16(+cospi_23_64, cospi_9_64); 66 const __m128i k__cospi_p07_p25 = pair_set_epi16(+cospi_7_64, cospi_25_64); 67 const __m128i k__cospi_m25_p07 = pair_set_epi16(-cospi_25_64, cospi_7_64); 68 const __m128i k__cospi_m09_p23 = pair_set_epi16(-cospi_9_64, cospi_23_64); 69 const __m128i k__cospi_m17_p15 = pair_set_epi16(-cospi_17_64, cospi_15_64); 70 const __m128i k__cospi_m01_p31 = pair_set_epi16(-cospi_1_64, cospi_31_64); 71 const __m128i k__cospi_p27_p05 = pair_set_epi16(+cospi_27_64, cospi_5_64); 72 const __m128i k__cospi_p11_p21 = pair_set_epi16(+cospi_11_64, cospi_21_64); 73 const __m128i k__cospi_p19_p13 = pair_set_epi16(+cospi_19_64, cospi_13_64); 74 const __m128i k__cospi_p03_p29 = pair_set_epi16(+cospi_3_64, cospi_29_64); 75 const __m128i k__cospi_m29_p03 = pair_set_epi16(-cospi_29_64, cospi_3_64); 76 const __m128i k__cospi_m13_p19 = pair_set_epi16(-cospi_13_64, cospi_19_64); 77 const __m128i k__cospi_m21_p11 = pair_set_epi16(-cospi_21_64, cospi_11_64); 78 const __m128i k__cospi_m05_p27 = pair_set_epi16(-cospi_5_64, cospi_27_64); 79 const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32(DCT_CONST_ROUNDING); 80 const __m128i kZero = _mm_set1_epi16(0); 81 const __m128i kOne = _mm_set1_epi16(1); 82 // Do the two transform/transpose passes 83 int pass; 84 for (pass = 0; pass < 2; ++pass) { 85 // We process eight columns (transposed rows in second pass) at a time. 86 int column_start; 87 for (column_start = 0; column_start < 32; column_start += 8) { 88 __m128i step1[32]; 89 __m128i step2[32]; 90 __m128i step3[32]; 91 __m128i out[32]; 92 // Stage 1 93 // Note: even though all the loads below are aligned, using the aligned 94 // intrinsic make the code slightly slower. 95 if (0 == pass) { 96 const int16_t *in = &input[column_start]; 97 // step1[i] = (in[ 0 * stride] + in[(32 - 1) * stride]) << 2; 98 // Note: the next four blocks could be in a loop. That would help the 99 // instruction cache but is actually slower. 100 { 101 const int16_t *ina = in + 0 * str1; 102 const int16_t *inb = in + 31 * str1; 103 __m128i *step1a = &step1[ 0]; 104 __m128i *step1b = &step1[31]; 105 const __m128i ina0 = _mm_loadu_si128((const __m128i *)(ina)); 106 const __m128i ina1 = _mm_loadu_si128((const __m128i *)(ina + str1)); 107 const __m128i ina2 = _mm_loadu_si128((const __m128i *)(ina + str2)); 108 const __m128i ina3 = _mm_loadu_si128((const __m128i *)(ina + str3)); 109 const __m128i inb3 = _mm_loadu_si128((const __m128i *)(inb - str3)); 110 const __m128i inb2 = _mm_loadu_si128((const __m128i *)(inb - str2)); 111 const __m128i inb1 = _mm_loadu_si128((const __m128i *)(inb - str1)); 112 const __m128i inb0 = _mm_loadu_si128((const __m128i *)(inb)); 113 step1a[ 0] = _mm_add_epi16(ina0, inb0); 114 step1a[ 1] = _mm_add_epi16(ina1, inb1); 115 step1a[ 2] = _mm_add_epi16(ina2, inb2); 116 step1a[ 3] = _mm_add_epi16(ina3, inb3); 117 step1b[-3] = _mm_sub_epi16(ina3, inb3); 118 step1b[-2] = _mm_sub_epi16(ina2, inb2); 119 step1b[-1] = _mm_sub_epi16(ina1, inb1); 120 step1b[-0] = _mm_sub_epi16(ina0, inb0); 121 step1a[ 0] = _mm_slli_epi16(step1a[ 0], 2); 122 step1a[ 1] = _mm_slli_epi16(step1a[ 1], 2); 123 step1a[ 2] = _mm_slli_epi16(step1a[ 2], 2); 124 step1a[ 3] = _mm_slli_epi16(step1a[ 3], 2); 125 step1b[-3] = _mm_slli_epi16(step1b[-3], 2); 126 step1b[-2] = _mm_slli_epi16(step1b[-2], 2); 127 step1b[-1] = _mm_slli_epi16(step1b[-1], 2); 128 step1b[-0] = _mm_slli_epi16(step1b[-0], 2); 129 } 130 { 131 const int16_t *ina = in + 4 * str1; 132 const int16_t *inb = in + 27 * str1; 133 __m128i *step1a = &step1[ 4]; 134 __m128i *step1b = &step1[27]; 135 const __m128i ina0 = _mm_loadu_si128((const __m128i *)(ina)); 136 const __m128i ina1 = _mm_loadu_si128((const __m128i *)(ina + str1)); 137 const __m128i ina2 = _mm_loadu_si128((const __m128i *)(ina + str2)); 138 const __m128i ina3 = _mm_loadu_si128((const __m128i *)(ina + str3)); 139 const __m128i inb3 = _mm_loadu_si128((const __m128i *)(inb - str3)); 140 const __m128i inb2 = _mm_loadu_si128((const __m128i *)(inb - str2)); 141 const __m128i inb1 = _mm_loadu_si128((const __m128i *)(inb - str1)); 142 const __m128i inb0 = _mm_loadu_si128((const __m128i *)(inb)); 143 step1a[ 0] = _mm_add_epi16(ina0, inb0); 144 step1a[ 1] = _mm_add_epi16(ina1, inb1); 145 step1a[ 2] = _mm_add_epi16(ina2, inb2); 146 step1a[ 3] = _mm_add_epi16(ina3, inb3); 147 step1b[-3] = _mm_sub_epi16(ina3, inb3); 148 step1b[-2] = _mm_sub_epi16(ina2, inb2); 149 step1b[-1] = _mm_sub_epi16(ina1, inb1); 150 step1b[-0] = _mm_sub_epi16(ina0, inb0); 151 step1a[ 0] = _mm_slli_epi16(step1a[ 0], 2); 152 step1a[ 1] = _mm_slli_epi16(step1a[ 1], 2); 153 step1a[ 2] = _mm_slli_epi16(step1a[ 2], 2); 154 step1a[ 3] = _mm_slli_epi16(step1a[ 3], 2); 155 step1b[-3] = _mm_slli_epi16(step1b[-3], 2); 156 step1b[-2] = _mm_slli_epi16(step1b[-2], 2); 157 step1b[-1] = _mm_slli_epi16(step1b[-1], 2); 158 step1b[-0] = _mm_slli_epi16(step1b[-0], 2); 159 } 160 { 161 const int16_t *ina = in + 8 * str1; 162 const int16_t *inb = in + 23 * str1; 163 __m128i *step1a = &step1[ 8]; 164 __m128i *step1b = &step1[23]; 165 const __m128i ina0 = _mm_loadu_si128((const __m128i *)(ina)); 166 const __m128i ina1 = _mm_loadu_si128((const __m128i *)(ina + str1)); 167 const __m128i ina2 = _mm_loadu_si128((const __m128i *)(ina + str2)); 168 const __m128i ina3 = _mm_loadu_si128((const __m128i *)(ina + str3)); 169 const __m128i inb3 = _mm_loadu_si128((const __m128i *)(inb - str3)); 170 const __m128i inb2 = _mm_loadu_si128((const __m128i *)(inb - str2)); 171 const __m128i inb1 = _mm_loadu_si128((const __m128i *)(inb - str1)); 172 const __m128i inb0 = _mm_loadu_si128((const __m128i *)(inb)); 173 step1a[ 0] = _mm_add_epi16(ina0, inb0); 174 step1a[ 1] = _mm_add_epi16(ina1, inb1); 175 step1a[ 2] = _mm_add_epi16(ina2, inb2); 176 step1a[ 3] = _mm_add_epi16(ina3, inb3); 177 step1b[-3] = _mm_sub_epi16(ina3, inb3); 178 step1b[-2] = _mm_sub_epi16(ina2, inb2); 179 step1b[-1] = _mm_sub_epi16(ina1, inb1); 180 step1b[-0] = _mm_sub_epi16(ina0, inb0); 181 step1a[ 0] = _mm_slli_epi16(step1a[ 0], 2); 182 step1a[ 1] = _mm_slli_epi16(step1a[ 1], 2); 183 step1a[ 2] = _mm_slli_epi16(step1a[ 2], 2); 184 step1a[ 3] = _mm_slli_epi16(step1a[ 3], 2); 185 step1b[-3] = _mm_slli_epi16(step1b[-3], 2); 186 step1b[-2] = _mm_slli_epi16(step1b[-2], 2); 187 step1b[-1] = _mm_slli_epi16(step1b[-1], 2); 188 step1b[-0] = _mm_slli_epi16(step1b[-0], 2); 189 } 190 { 191 const int16_t *ina = in + 12 * str1; 192 const int16_t *inb = in + 19 * str1; 193 __m128i *step1a = &step1[12]; 194 __m128i *step1b = &step1[19]; 195 const __m128i ina0 = _mm_loadu_si128((const __m128i *)(ina)); 196 const __m128i ina1 = _mm_loadu_si128((const __m128i *)(ina + str1)); 197 const __m128i ina2 = _mm_loadu_si128((const __m128i *)(ina + str2)); 198 const __m128i ina3 = _mm_loadu_si128((const __m128i *)(ina + str3)); 199 const __m128i inb3 = _mm_loadu_si128((const __m128i *)(inb - str3)); 200 const __m128i inb2 = _mm_loadu_si128((const __m128i *)(inb - str2)); 201 const __m128i inb1 = _mm_loadu_si128((const __m128i *)(inb - str1)); 202 const __m128i inb0 = _mm_loadu_si128((const __m128i *)(inb)); 203 step1a[ 0] = _mm_add_epi16(ina0, inb0); 204 step1a[ 1] = _mm_add_epi16(ina1, inb1); 205 step1a[ 2] = _mm_add_epi16(ina2, inb2); 206 step1a[ 3] = _mm_add_epi16(ina3, inb3); 207 step1b[-3] = _mm_sub_epi16(ina3, inb3); 208 step1b[-2] = _mm_sub_epi16(ina2, inb2); 209 step1b[-1] = _mm_sub_epi16(ina1, inb1); 210 step1b[-0] = _mm_sub_epi16(ina0, inb0); 211 step1a[ 0] = _mm_slli_epi16(step1a[ 0], 2); 212 step1a[ 1] = _mm_slli_epi16(step1a[ 1], 2); 213 step1a[ 2] = _mm_slli_epi16(step1a[ 2], 2); 214 step1a[ 3] = _mm_slli_epi16(step1a[ 3], 2); 215 step1b[-3] = _mm_slli_epi16(step1b[-3], 2); 216 step1b[-2] = _mm_slli_epi16(step1b[-2], 2); 217 step1b[-1] = _mm_slli_epi16(step1b[-1], 2); 218 step1b[-0] = _mm_slli_epi16(step1b[-0], 2); 219 } 220 } else { 221 int16_t *in = &intermediate[column_start]; 222 // step1[i] = in[ 0 * 32] + in[(32 - 1) * 32]; 223 // Note: using the same approach as above to have common offset is 224 // counter-productive as all offsets can be calculated at compile 225 // time. 226 // Note: the next four blocks could be in a loop. That would help the 227 // instruction cache but is actually slower. 228 { 229 __m128i in00 = _mm_loadu_si128((const __m128i *)(in + 0 * 32)); 230 __m128i in01 = _mm_loadu_si128((const __m128i *)(in + 1 * 32)); 231 __m128i in02 = _mm_loadu_si128((const __m128i *)(in + 2 * 32)); 232 __m128i in03 = _mm_loadu_si128((const __m128i *)(in + 3 * 32)); 233 __m128i in28 = _mm_loadu_si128((const __m128i *)(in + 28 * 32)); 234 __m128i in29 = _mm_loadu_si128((const __m128i *)(in + 29 * 32)); 235 __m128i in30 = _mm_loadu_si128((const __m128i *)(in + 30 * 32)); 236 __m128i in31 = _mm_loadu_si128((const __m128i *)(in + 31 * 32)); 237 step1[ 0] = _mm_add_epi16(in00, in31); 238 step1[ 1] = _mm_add_epi16(in01, in30); 239 step1[ 2] = _mm_add_epi16(in02, in29); 240 step1[ 3] = _mm_add_epi16(in03, in28); 241 step1[28] = _mm_sub_epi16(in03, in28); 242 step1[29] = _mm_sub_epi16(in02, in29); 243 step1[30] = _mm_sub_epi16(in01, in30); 244 step1[31] = _mm_sub_epi16(in00, in31); 245 } 246 { 247 __m128i in04 = _mm_loadu_si128((const __m128i *)(in + 4 * 32)); 248 __m128i in05 = _mm_loadu_si128((const __m128i *)(in + 5 * 32)); 249 __m128i in06 = _mm_loadu_si128((const __m128i *)(in + 6 * 32)); 250 __m128i in07 = _mm_loadu_si128((const __m128i *)(in + 7 * 32)); 251 __m128i in24 = _mm_loadu_si128((const __m128i *)(in + 24 * 32)); 252 __m128i in25 = _mm_loadu_si128((const __m128i *)(in + 25 * 32)); 253 __m128i in26 = _mm_loadu_si128((const __m128i *)(in + 26 * 32)); 254 __m128i in27 = _mm_loadu_si128((const __m128i *)(in + 27 * 32)); 255 step1[ 4] = _mm_add_epi16(in04, in27); 256 step1[ 5] = _mm_add_epi16(in05, in26); 257 step1[ 6] = _mm_add_epi16(in06, in25); 258 step1[ 7] = _mm_add_epi16(in07, in24); 259 step1[24] = _mm_sub_epi16(in07, in24); 260 step1[25] = _mm_sub_epi16(in06, in25); 261 step1[26] = _mm_sub_epi16(in05, in26); 262 step1[27] = _mm_sub_epi16(in04, in27); 263 } 264 { 265 __m128i in08 = _mm_loadu_si128((const __m128i *)(in + 8 * 32)); 266 __m128i in09 = _mm_loadu_si128((const __m128i *)(in + 9 * 32)); 267 __m128i in10 = _mm_loadu_si128((const __m128i *)(in + 10 * 32)); 268 __m128i in11 = _mm_loadu_si128((const __m128i *)(in + 11 * 32)); 269 __m128i in20 = _mm_loadu_si128((const __m128i *)(in + 20 * 32)); 270 __m128i in21 = _mm_loadu_si128((const __m128i *)(in + 21 * 32)); 271 __m128i in22 = _mm_loadu_si128((const __m128i *)(in + 22 * 32)); 272 __m128i in23 = _mm_loadu_si128((const __m128i *)(in + 23 * 32)); 273 step1[ 8] = _mm_add_epi16(in08, in23); 274 step1[ 9] = _mm_add_epi16(in09, in22); 275 step1[10] = _mm_add_epi16(in10, in21); 276 step1[11] = _mm_add_epi16(in11, in20); 277 step1[20] = _mm_sub_epi16(in11, in20); 278 step1[21] = _mm_sub_epi16(in10, in21); 279 step1[22] = _mm_sub_epi16(in09, in22); 280 step1[23] = _mm_sub_epi16(in08, in23); 281 } 282 { 283 __m128i in12 = _mm_loadu_si128((const __m128i *)(in + 12 * 32)); 284 __m128i in13 = _mm_loadu_si128((const __m128i *)(in + 13 * 32)); 285 __m128i in14 = _mm_loadu_si128((const __m128i *)(in + 14 * 32)); 286 __m128i in15 = _mm_loadu_si128((const __m128i *)(in + 15 * 32)); 287 __m128i in16 = _mm_loadu_si128((const __m128i *)(in + 16 * 32)); 288 __m128i in17 = _mm_loadu_si128((const __m128i *)(in + 17 * 32)); 289 __m128i in18 = _mm_loadu_si128((const __m128i *)(in + 18 * 32)); 290 __m128i in19 = _mm_loadu_si128((const __m128i *)(in + 19 * 32)); 291 step1[12] = _mm_add_epi16(in12, in19); 292 step1[13] = _mm_add_epi16(in13, in18); 293 step1[14] = _mm_add_epi16(in14, in17); 294 step1[15] = _mm_add_epi16(in15, in16); 295 step1[16] = _mm_sub_epi16(in15, in16); 296 step1[17] = _mm_sub_epi16(in14, in17); 297 step1[18] = _mm_sub_epi16(in13, in18); 298 step1[19] = _mm_sub_epi16(in12, in19); 299 } 300 } 301 // Stage 2 302 { 303 step2[ 0] = _mm_add_epi16(step1[0], step1[15]); 304 step2[ 1] = _mm_add_epi16(step1[1], step1[14]); 305 step2[ 2] = _mm_add_epi16(step1[2], step1[13]); 306 step2[ 3] = _mm_add_epi16(step1[3], step1[12]); 307 step2[ 4] = _mm_add_epi16(step1[4], step1[11]); 308 step2[ 5] = _mm_add_epi16(step1[5], step1[10]); 309 step2[ 6] = _mm_add_epi16(step1[6], step1[ 9]); 310 step2[ 7] = _mm_add_epi16(step1[7], step1[ 8]); 311 step2[ 8] = _mm_sub_epi16(step1[7], step1[ 8]); 312 step2[ 9] = _mm_sub_epi16(step1[6], step1[ 9]); 313 step2[10] = _mm_sub_epi16(step1[5], step1[10]); 314 step2[11] = _mm_sub_epi16(step1[4], step1[11]); 315 step2[12] = _mm_sub_epi16(step1[3], step1[12]); 316 step2[13] = _mm_sub_epi16(step1[2], step1[13]); 317 step2[14] = _mm_sub_epi16(step1[1], step1[14]); 318 step2[15] = _mm_sub_epi16(step1[0], step1[15]); 319 } 320 { 321 const __m128i s2_20_0 = _mm_unpacklo_epi16(step1[27], step1[20]); 322 const __m128i s2_20_1 = _mm_unpackhi_epi16(step1[27], step1[20]); 323 const __m128i s2_21_0 = _mm_unpacklo_epi16(step1[26], step1[21]); 324 const __m128i s2_21_1 = _mm_unpackhi_epi16(step1[26], step1[21]); 325 const __m128i s2_22_0 = _mm_unpacklo_epi16(step1[25], step1[22]); 326 const __m128i s2_22_1 = _mm_unpackhi_epi16(step1[25], step1[22]); 327 const __m128i s2_23_0 = _mm_unpacklo_epi16(step1[24], step1[23]); 328 const __m128i s2_23_1 = _mm_unpackhi_epi16(step1[24], step1[23]); 329 const __m128i s2_20_2 = _mm_madd_epi16(s2_20_0, k__cospi_p16_m16); 330 const __m128i s2_20_3 = _mm_madd_epi16(s2_20_1, k__cospi_p16_m16); 331 const __m128i s2_21_2 = _mm_madd_epi16(s2_21_0, k__cospi_p16_m16); 332 const __m128i s2_21_3 = _mm_madd_epi16(s2_21_1, k__cospi_p16_m16); 333 const __m128i s2_22_2 = _mm_madd_epi16(s2_22_0, k__cospi_p16_m16); 334 const __m128i s2_22_3 = _mm_madd_epi16(s2_22_1, k__cospi_p16_m16); 335 const __m128i s2_23_2 = _mm_madd_epi16(s2_23_0, k__cospi_p16_m16); 336 const __m128i s2_23_3 = _mm_madd_epi16(s2_23_1, k__cospi_p16_m16); 337 const __m128i s2_24_2 = _mm_madd_epi16(s2_23_0, k__cospi_p16_p16); 338 const __m128i s2_24_3 = _mm_madd_epi16(s2_23_1, k__cospi_p16_p16); 339 const __m128i s2_25_2 = _mm_madd_epi16(s2_22_0, k__cospi_p16_p16); 340 const __m128i s2_25_3 = _mm_madd_epi16(s2_22_1, k__cospi_p16_p16); 341 const __m128i s2_26_2 = _mm_madd_epi16(s2_21_0, k__cospi_p16_p16); 342 const __m128i s2_26_3 = _mm_madd_epi16(s2_21_1, k__cospi_p16_p16); 343 const __m128i s2_27_2 = _mm_madd_epi16(s2_20_0, k__cospi_p16_p16); 344 const __m128i s2_27_3 = _mm_madd_epi16(s2_20_1, k__cospi_p16_p16); 345 // dct_const_round_shift 346 const __m128i s2_20_4 = _mm_add_epi32(s2_20_2, k__DCT_CONST_ROUNDING); 347 const __m128i s2_20_5 = _mm_add_epi32(s2_20_3, k__DCT_CONST_ROUNDING); 348 const __m128i s2_21_4 = _mm_add_epi32(s2_21_2, k__DCT_CONST_ROUNDING); 349 const __m128i s2_21_5 = _mm_add_epi32(s2_21_3, k__DCT_CONST_ROUNDING); 350 const __m128i s2_22_4 = _mm_add_epi32(s2_22_2, k__DCT_CONST_ROUNDING); 351 const __m128i s2_22_5 = _mm_add_epi32(s2_22_3, k__DCT_CONST_ROUNDING); 352 const __m128i s2_23_4 = _mm_add_epi32(s2_23_2, k__DCT_CONST_ROUNDING); 353 const __m128i s2_23_5 = _mm_add_epi32(s2_23_3, k__DCT_CONST_ROUNDING); 354 const __m128i s2_24_4 = _mm_add_epi32(s2_24_2, k__DCT_CONST_ROUNDING); 355 const __m128i s2_24_5 = _mm_add_epi32(s2_24_3, k__DCT_CONST_ROUNDING); 356 const __m128i s2_25_4 = _mm_add_epi32(s2_25_2, k__DCT_CONST_ROUNDING); 357 const __m128i s2_25_5 = _mm_add_epi32(s2_25_3, k__DCT_CONST_ROUNDING); 358 const __m128i s2_26_4 = _mm_add_epi32(s2_26_2, k__DCT_CONST_ROUNDING); 359 const __m128i s2_26_5 = _mm_add_epi32(s2_26_3, k__DCT_CONST_ROUNDING); 360 const __m128i s2_27_4 = _mm_add_epi32(s2_27_2, k__DCT_CONST_ROUNDING); 361 const __m128i s2_27_5 = _mm_add_epi32(s2_27_3, k__DCT_CONST_ROUNDING); 362 const __m128i s2_20_6 = _mm_srai_epi32(s2_20_4, DCT_CONST_BITS); 363 const __m128i s2_20_7 = _mm_srai_epi32(s2_20_5, DCT_CONST_BITS); 364 const __m128i s2_21_6 = _mm_srai_epi32(s2_21_4, DCT_CONST_BITS); 365 const __m128i s2_21_7 = _mm_srai_epi32(s2_21_5, DCT_CONST_BITS); 366 const __m128i s2_22_6 = _mm_srai_epi32(s2_22_4, DCT_CONST_BITS); 367 const __m128i s2_22_7 = _mm_srai_epi32(s2_22_5, DCT_CONST_BITS); 368 const __m128i s2_23_6 = _mm_srai_epi32(s2_23_4, DCT_CONST_BITS); 369 const __m128i s2_23_7 = _mm_srai_epi32(s2_23_5, DCT_CONST_BITS); 370 const __m128i s2_24_6 = _mm_srai_epi32(s2_24_4, DCT_CONST_BITS); 371 const __m128i s2_24_7 = _mm_srai_epi32(s2_24_5, DCT_CONST_BITS); 372 const __m128i s2_25_6 = _mm_srai_epi32(s2_25_4, DCT_CONST_BITS); 373 const __m128i s2_25_7 = _mm_srai_epi32(s2_25_5, DCT_CONST_BITS); 374 const __m128i s2_26_6 = _mm_srai_epi32(s2_26_4, DCT_CONST_BITS); 375 const __m128i s2_26_7 = _mm_srai_epi32(s2_26_5, DCT_CONST_BITS); 376 const __m128i s2_27_6 = _mm_srai_epi32(s2_27_4, DCT_CONST_BITS); 377 const __m128i s2_27_7 = _mm_srai_epi32(s2_27_5, DCT_CONST_BITS); 378 // Combine 379 step2[20] = _mm_packs_epi32(s2_20_6, s2_20_7); 380 step2[21] = _mm_packs_epi32(s2_21_6, s2_21_7); 381 step2[22] = _mm_packs_epi32(s2_22_6, s2_22_7); 382 step2[23] = _mm_packs_epi32(s2_23_6, s2_23_7); 383 step2[24] = _mm_packs_epi32(s2_24_6, s2_24_7); 384 step2[25] = _mm_packs_epi32(s2_25_6, s2_25_7); 385 step2[26] = _mm_packs_epi32(s2_26_6, s2_26_7); 386 step2[27] = _mm_packs_epi32(s2_27_6, s2_27_7); 387 } 388 389 #if !FDCT32x32_HIGH_PRECISION 390 // dump the magnitude by half, hence the intermediate values are within 391 // the range of 16 bits. 392 if (1 == pass) { 393 __m128i s3_00_0 = _mm_cmplt_epi16(step2[ 0], kZero); 394 __m128i s3_01_0 = _mm_cmplt_epi16(step2[ 1], kZero); 395 __m128i s3_02_0 = _mm_cmplt_epi16(step2[ 2], kZero); 396 __m128i s3_03_0 = _mm_cmplt_epi16(step2[ 3], kZero); 397 __m128i s3_04_0 = _mm_cmplt_epi16(step2[ 4], kZero); 398 __m128i s3_05_0 = _mm_cmplt_epi16(step2[ 5], kZero); 399 __m128i s3_06_0 = _mm_cmplt_epi16(step2[ 6], kZero); 400 __m128i s3_07_0 = _mm_cmplt_epi16(step2[ 7], kZero); 401 __m128i s2_08_0 = _mm_cmplt_epi16(step2[ 8], kZero); 402 __m128i s2_09_0 = _mm_cmplt_epi16(step2[ 9], kZero); 403 __m128i s3_10_0 = _mm_cmplt_epi16(step2[10], kZero); 404 __m128i s3_11_0 = _mm_cmplt_epi16(step2[11], kZero); 405 __m128i s3_12_0 = _mm_cmplt_epi16(step2[12], kZero); 406 __m128i s3_13_0 = _mm_cmplt_epi16(step2[13], kZero); 407 __m128i s2_14_0 = _mm_cmplt_epi16(step2[14], kZero); 408 __m128i s2_15_0 = _mm_cmplt_epi16(step2[15], kZero); 409 __m128i s3_16_0 = _mm_cmplt_epi16(step1[16], kZero); 410 __m128i s3_17_0 = _mm_cmplt_epi16(step1[17], kZero); 411 __m128i s3_18_0 = _mm_cmplt_epi16(step1[18], kZero); 412 __m128i s3_19_0 = _mm_cmplt_epi16(step1[19], kZero); 413 __m128i s3_20_0 = _mm_cmplt_epi16(step2[20], kZero); 414 __m128i s3_21_0 = _mm_cmplt_epi16(step2[21], kZero); 415 __m128i s3_22_0 = _mm_cmplt_epi16(step2[22], kZero); 416 __m128i s3_23_0 = _mm_cmplt_epi16(step2[23], kZero); 417 __m128i s3_24_0 = _mm_cmplt_epi16(step2[24], kZero); 418 __m128i s3_25_0 = _mm_cmplt_epi16(step2[25], kZero); 419 __m128i s3_26_0 = _mm_cmplt_epi16(step2[26], kZero); 420 __m128i s3_27_0 = _mm_cmplt_epi16(step2[27], kZero); 421 __m128i s3_28_0 = _mm_cmplt_epi16(step1[28], kZero); 422 __m128i s3_29_0 = _mm_cmplt_epi16(step1[29], kZero); 423 __m128i s3_30_0 = _mm_cmplt_epi16(step1[30], kZero); 424 __m128i s3_31_0 = _mm_cmplt_epi16(step1[31], kZero); 425 426 step2[ 0] = _mm_sub_epi16(step2[ 0], s3_00_0); 427 step2[ 1] = _mm_sub_epi16(step2[ 1], s3_01_0); 428 step2[ 2] = _mm_sub_epi16(step2[ 2], s3_02_0); 429 step2[ 3] = _mm_sub_epi16(step2[ 3], s3_03_0); 430 step2[ 4] = _mm_sub_epi16(step2[ 4], s3_04_0); 431 step2[ 5] = _mm_sub_epi16(step2[ 5], s3_05_0); 432 step2[ 6] = _mm_sub_epi16(step2[ 6], s3_06_0); 433 step2[ 7] = _mm_sub_epi16(step2[ 7], s3_07_0); 434 step2[ 8] = _mm_sub_epi16(step2[ 8], s2_08_0); 435 step2[ 9] = _mm_sub_epi16(step2[ 9], s2_09_0); 436 step2[10] = _mm_sub_epi16(step2[10], s3_10_0); 437 step2[11] = _mm_sub_epi16(step2[11], s3_11_0); 438 step2[12] = _mm_sub_epi16(step2[12], s3_12_0); 439 step2[13] = _mm_sub_epi16(step2[13], s3_13_0); 440 step2[14] = _mm_sub_epi16(step2[14], s2_14_0); 441 step2[15] = _mm_sub_epi16(step2[15], s2_15_0); 442 step1[16] = _mm_sub_epi16(step1[16], s3_16_0); 443 step1[17] = _mm_sub_epi16(step1[17], s3_17_0); 444 step1[18] = _mm_sub_epi16(step1[18], s3_18_0); 445 step1[19] = _mm_sub_epi16(step1[19], s3_19_0); 446 step2[20] = _mm_sub_epi16(step2[20], s3_20_0); 447 step2[21] = _mm_sub_epi16(step2[21], s3_21_0); 448 step2[22] = _mm_sub_epi16(step2[22], s3_22_0); 449 step2[23] = _mm_sub_epi16(step2[23], s3_23_0); 450 step2[24] = _mm_sub_epi16(step2[24], s3_24_0); 451 step2[25] = _mm_sub_epi16(step2[25], s3_25_0); 452 step2[26] = _mm_sub_epi16(step2[26], s3_26_0); 453 step2[27] = _mm_sub_epi16(step2[27], s3_27_0); 454 step1[28] = _mm_sub_epi16(step1[28], s3_28_0); 455 step1[29] = _mm_sub_epi16(step1[29], s3_29_0); 456 step1[30] = _mm_sub_epi16(step1[30], s3_30_0); 457 step1[31] = _mm_sub_epi16(step1[31], s3_31_0); 458 459 step2[ 0] = _mm_add_epi16(step2[ 0], kOne); 460 step2[ 1] = _mm_add_epi16(step2[ 1], kOne); 461 step2[ 2] = _mm_add_epi16(step2[ 2], kOne); 462 step2[ 3] = _mm_add_epi16(step2[ 3], kOne); 463 step2[ 4] = _mm_add_epi16(step2[ 4], kOne); 464 step2[ 5] = _mm_add_epi16(step2[ 5], kOne); 465 step2[ 6] = _mm_add_epi16(step2[ 6], kOne); 466 step2[ 7] = _mm_add_epi16(step2[ 7], kOne); 467 step2[ 8] = _mm_add_epi16(step2[ 8], kOne); 468 step2[ 9] = _mm_add_epi16(step2[ 9], kOne); 469 step2[10] = _mm_add_epi16(step2[10], kOne); 470 step2[11] = _mm_add_epi16(step2[11], kOne); 471 step2[12] = _mm_add_epi16(step2[12], kOne); 472 step2[13] = _mm_add_epi16(step2[13], kOne); 473 step2[14] = _mm_add_epi16(step2[14], kOne); 474 step2[15] = _mm_add_epi16(step2[15], kOne); 475 step1[16] = _mm_add_epi16(step1[16], kOne); 476 step1[17] = _mm_add_epi16(step1[17], kOne); 477 step1[18] = _mm_add_epi16(step1[18], kOne); 478 step1[19] = _mm_add_epi16(step1[19], kOne); 479 step2[20] = _mm_add_epi16(step2[20], kOne); 480 step2[21] = _mm_add_epi16(step2[21], kOne); 481 step2[22] = _mm_add_epi16(step2[22], kOne); 482 step2[23] = _mm_add_epi16(step2[23], kOne); 483 step2[24] = _mm_add_epi16(step2[24], kOne); 484 step2[25] = _mm_add_epi16(step2[25], kOne); 485 step2[26] = _mm_add_epi16(step2[26], kOne); 486 step2[27] = _mm_add_epi16(step2[27], kOne); 487 step1[28] = _mm_add_epi16(step1[28], kOne); 488 step1[29] = _mm_add_epi16(step1[29], kOne); 489 step1[30] = _mm_add_epi16(step1[30], kOne); 490 step1[31] = _mm_add_epi16(step1[31], kOne); 491 492 step2[ 0] = _mm_srai_epi16(step2[ 0], 2); 493 step2[ 1] = _mm_srai_epi16(step2[ 1], 2); 494 step2[ 2] = _mm_srai_epi16(step2[ 2], 2); 495 step2[ 3] = _mm_srai_epi16(step2[ 3], 2); 496 step2[ 4] = _mm_srai_epi16(step2[ 4], 2); 497 step2[ 5] = _mm_srai_epi16(step2[ 5], 2); 498 step2[ 6] = _mm_srai_epi16(step2[ 6], 2); 499 step2[ 7] = _mm_srai_epi16(step2[ 7], 2); 500 step2[ 8] = _mm_srai_epi16(step2[ 8], 2); 501 step2[ 9] = _mm_srai_epi16(step2[ 9], 2); 502 step2[10] = _mm_srai_epi16(step2[10], 2); 503 step2[11] = _mm_srai_epi16(step2[11], 2); 504 step2[12] = _mm_srai_epi16(step2[12], 2); 505 step2[13] = _mm_srai_epi16(step2[13], 2); 506 step2[14] = _mm_srai_epi16(step2[14], 2); 507 step2[15] = _mm_srai_epi16(step2[15], 2); 508 step1[16] = _mm_srai_epi16(step1[16], 2); 509 step1[17] = _mm_srai_epi16(step1[17], 2); 510 step1[18] = _mm_srai_epi16(step1[18], 2); 511 step1[19] = _mm_srai_epi16(step1[19], 2); 512 step2[20] = _mm_srai_epi16(step2[20], 2); 513 step2[21] = _mm_srai_epi16(step2[21], 2); 514 step2[22] = _mm_srai_epi16(step2[22], 2); 515 step2[23] = _mm_srai_epi16(step2[23], 2); 516 step2[24] = _mm_srai_epi16(step2[24], 2); 517 step2[25] = _mm_srai_epi16(step2[25], 2); 518 step2[26] = _mm_srai_epi16(step2[26], 2); 519 step2[27] = _mm_srai_epi16(step2[27], 2); 520 step1[28] = _mm_srai_epi16(step1[28], 2); 521 step1[29] = _mm_srai_epi16(step1[29], 2); 522 step1[30] = _mm_srai_epi16(step1[30], 2); 523 step1[31] = _mm_srai_epi16(step1[31], 2); 524 } 525 #endif 526 527 #if FDCT32x32_HIGH_PRECISION 528 if (pass == 0) { 529 #endif 530 // Stage 3 531 { 532 step3[0] = _mm_add_epi16(step2[(8 - 1)], step2[0]); 533 step3[1] = _mm_add_epi16(step2[(8 - 2)], step2[1]); 534 step3[2] = _mm_add_epi16(step2[(8 - 3)], step2[2]); 535 step3[3] = _mm_add_epi16(step2[(8 - 4)], step2[3]); 536 step3[4] = _mm_sub_epi16(step2[(8 - 5)], step2[4]); 537 step3[5] = _mm_sub_epi16(step2[(8 - 6)], step2[5]); 538 step3[6] = _mm_sub_epi16(step2[(8 - 7)], step2[6]); 539 step3[7] = _mm_sub_epi16(step2[(8 - 8)], step2[7]); 540 } 541 { 542 const __m128i s3_10_0 = _mm_unpacklo_epi16(step2[13], step2[10]); 543 const __m128i s3_10_1 = _mm_unpackhi_epi16(step2[13], step2[10]); 544 const __m128i s3_11_0 = _mm_unpacklo_epi16(step2[12], step2[11]); 545 const __m128i s3_11_1 = _mm_unpackhi_epi16(step2[12], step2[11]); 546 const __m128i s3_10_2 = _mm_madd_epi16(s3_10_0, k__cospi_p16_m16); 547 const __m128i s3_10_3 = _mm_madd_epi16(s3_10_1, k__cospi_p16_m16); 548 const __m128i s3_11_2 = _mm_madd_epi16(s3_11_0, k__cospi_p16_m16); 549 const __m128i s3_11_3 = _mm_madd_epi16(s3_11_1, k__cospi_p16_m16); 550 const __m128i s3_12_2 = _mm_madd_epi16(s3_11_0, k__cospi_p16_p16); 551 const __m128i s3_12_3 = _mm_madd_epi16(s3_11_1, k__cospi_p16_p16); 552 const __m128i s3_13_2 = _mm_madd_epi16(s3_10_0, k__cospi_p16_p16); 553 const __m128i s3_13_3 = _mm_madd_epi16(s3_10_1, k__cospi_p16_p16); 554 // dct_const_round_shift 555 const __m128i s3_10_4 = _mm_add_epi32(s3_10_2, k__DCT_CONST_ROUNDING); 556 const __m128i s3_10_5 = _mm_add_epi32(s3_10_3, k__DCT_CONST_ROUNDING); 557 const __m128i s3_11_4 = _mm_add_epi32(s3_11_2, k__DCT_CONST_ROUNDING); 558 const __m128i s3_11_5 = _mm_add_epi32(s3_11_3, k__DCT_CONST_ROUNDING); 559 const __m128i s3_12_4 = _mm_add_epi32(s3_12_2, k__DCT_CONST_ROUNDING); 560 const __m128i s3_12_5 = _mm_add_epi32(s3_12_3, k__DCT_CONST_ROUNDING); 561 const __m128i s3_13_4 = _mm_add_epi32(s3_13_2, k__DCT_CONST_ROUNDING); 562 const __m128i s3_13_5 = _mm_add_epi32(s3_13_3, k__DCT_CONST_ROUNDING); 563 const __m128i s3_10_6 = _mm_srai_epi32(s3_10_4, DCT_CONST_BITS); 564 const __m128i s3_10_7 = _mm_srai_epi32(s3_10_5, DCT_CONST_BITS); 565 const __m128i s3_11_6 = _mm_srai_epi32(s3_11_4, DCT_CONST_BITS); 566 const __m128i s3_11_7 = _mm_srai_epi32(s3_11_5, DCT_CONST_BITS); 567 const __m128i s3_12_6 = _mm_srai_epi32(s3_12_4, DCT_CONST_BITS); 568 const __m128i s3_12_7 = _mm_srai_epi32(s3_12_5, DCT_CONST_BITS); 569 const __m128i s3_13_6 = _mm_srai_epi32(s3_13_4, DCT_CONST_BITS); 570 const __m128i s3_13_7 = _mm_srai_epi32(s3_13_5, DCT_CONST_BITS); 571 // Combine 572 step3[10] = _mm_packs_epi32(s3_10_6, s3_10_7); 573 step3[11] = _mm_packs_epi32(s3_11_6, s3_11_7); 574 step3[12] = _mm_packs_epi32(s3_12_6, s3_12_7); 575 step3[13] = _mm_packs_epi32(s3_13_6, s3_13_7); 576 } 577 { 578 step3[16] = _mm_add_epi16(step2[23], step1[16]); 579 step3[17] = _mm_add_epi16(step2[22], step1[17]); 580 step3[18] = _mm_add_epi16(step2[21], step1[18]); 581 step3[19] = _mm_add_epi16(step2[20], step1[19]); 582 step3[20] = _mm_sub_epi16(step1[19], step2[20]); 583 step3[21] = _mm_sub_epi16(step1[18], step2[21]); 584 step3[22] = _mm_sub_epi16(step1[17], step2[22]); 585 step3[23] = _mm_sub_epi16(step1[16], step2[23]); 586 step3[24] = _mm_sub_epi16(step1[31], step2[24]); 587 step3[25] = _mm_sub_epi16(step1[30], step2[25]); 588 step3[26] = _mm_sub_epi16(step1[29], step2[26]); 589 step3[27] = _mm_sub_epi16(step1[28], step2[27]); 590 step3[28] = _mm_add_epi16(step2[27], step1[28]); 591 step3[29] = _mm_add_epi16(step2[26], step1[29]); 592 step3[30] = _mm_add_epi16(step2[25], step1[30]); 593 step3[31] = _mm_add_epi16(step2[24], step1[31]); 594 } 595 596 // Stage 4 597 { 598 step1[ 0] = _mm_add_epi16(step3[ 3], step3[ 0]); 599 step1[ 1] = _mm_add_epi16(step3[ 2], step3[ 1]); 600 step1[ 2] = _mm_sub_epi16(step3[ 1], step3[ 2]); 601 step1[ 3] = _mm_sub_epi16(step3[ 0], step3[ 3]); 602 step1[ 8] = _mm_add_epi16(step3[11], step2[ 8]); 603 step1[ 9] = _mm_add_epi16(step3[10], step2[ 9]); 604 step1[10] = _mm_sub_epi16(step2[ 9], step3[10]); 605 step1[11] = _mm_sub_epi16(step2[ 8], step3[11]); 606 step1[12] = _mm_sub_epi16(step2[15], step3[12]); 607 step1[13] = _mm_sub_epi16(step2[14], step3[13]); 608 step1[14] = _mm_add_epi16(step3[13], step2[14]); 609 step1[15] = _mm_add_epi16(step3[12], step2[15]); 610 } 611 { 612 const __m128i s1_05_0 = _mm_unpacklo_epi16(step3[6], step3[5]); 613 const __m128i s1_05_1 = _mm_unpackhi_epi16(step3[6], step3[5]); 614 const __m128i s1_05_2 = _mm_madd_epi16(s1_05_0, k__cospi_p16_m16); 615 const __m128i s1_05_3 = _mm_madd_epi16(s1_05_1, k__cospi_p16_m16); 616 const __m128i s1_06_2 = _mm_madd_epi16(s1_05_0, k__cospi_p16_p16); 617 const __m128i s1_06_3 = _mm_madd_epi16(s1_05_1, k__cospi_p16_p16); 618 // dct_const_round_shift 619 const __m128i s1_05_4 = _mm_add_epi32(s1_05_2, k__DCT_CONST_ROUNDING); 620 const __m128i s1_05_5 = _mm_add_epi32(s1_05_3, k__DCT_CONST_ROUNDING); 621 const __m128i s1_06_4 = _mm_add_epi32(s1_06_2, k__DCT_CONST_ROUNDING); 622 const __m128i s1_06_5 = _mm_add_epi32(s1_06_3, k__DCT_CONST_ROUNDING); 623 const __m128i s1_05_6 = _mm_srai_epi32(s1_05_4, DCT_CONST_BITS); 624 const __m128i s1_05_7 = _mm_srai_epi32(s1_05_5, DCT_CONST_BITS); 625 const __m128i s1_06_6 = _mm_srai_epi32(s1_06_4, DCT_CONST_BITS); 626 const __m128i s1_06_7 = _mm_srai_epi32(s1_06_5, DCT_CONST_BITS); 627 // Combine 628 step1[5] = _mm_packs_epi32(s1_05_6, s1_05_7); 629 step1[6] = _mm_packs_epi32(s1_06_6, s1_06_7); 630 } 631 { 632 const __m128i s1_18_0 = _mm_unpacklo_epi16(step3[18], step3[29]); 633 const __m128i s1_18_1 = _mm_unpackhi_epi16(step3[18], step3[29]); 634 const __m128i s1_19_0 = _mm_unpacklo_epi16(step3[19], step3[28]); 635 const __m128i s1_19_1 = _mm_unpackhi_epi16(step3[19], step3[28]); 636 const __m128i s1_20_0 = _mm_unpacklo_epi16(step3[20], step3[27]); 637 const __m128i s1_20_1 = _mm_unpackhi_epi16(step3[20], step3[27]); 638 const __m128i s1_21_0 = _mm_unpacklo_epi16(step3[21], step3[26]); 639 const __m128i s1_21_1 = _mm_unpackhi_epi16(step3[21], step3[26]); 640 const __m128i s1_18_2 = _mm_madd_epi16(s1_18_0, k__cospi_m08_p24); 641 const __m128i s1_18_3 = _mm_madd_epi16(s1_18_1, k__cospi_m08_p24); 642 const __m128i s1_19_2 = _mm_madd_epi16(s1_19_0, k__cospi_m08_p24); 643 const __m128i s1_19_3 = _mm_madd_epi16(s1_19_1, k__cospi_m08_p24); 644 const __m128i s1_20_2 = _mm_madd_epi16(s1_20_0, k__cospi_m24_m08); 645 const __m128i s1_20_3 = _mm_madd_epi16(s1_20_1, k__cospi_m24_m08); 646 const __m128i s1_21_2 = _mm_madd_epi16(s1_21_0, k__cospi_m24_m08); 647 const __m128i s1_21_3 = _mm_madd_epi16(s1_21_1, k__cospi_m24_m08); 648 const __m128i s1_26_2 = _mm_madd_epi16(s1_21_0, k__cospi_m08_p24); 649 const __m128i s1_26_3 = _mm_madd_epi16(s1_21_1, k__cospi_m08_p24); 650 const __m128i s1_27_2 = _mm_madd_epi16(s1_20_0, k__cospi_m08_p24); 651 const __m128i s1_27_3 = _mm_madd_epi16(s1_20_1, k__cospi_m08_p24); 652 const __m128i s1_28_2 = _mm_madd_epi16(s1_19_0, k__cospi_p24_p08); 653 const __m128i s1_28_3 = _mm_madd_epi16(s1_19_1, k__cospi_p24_p08); 654 const __m128i s1_29_2 = _mm_madd_epi16(s1_18_0, k__cospi_p24_p08); 655 const __m128i s1_29_3 = _mm_madd_epi16(s1_18_1, k__cospi_p24_p08); 656 // dct_const_round_shift 657 const __m128i s1_18_4 = _mm_add_epi32(s1_18_2, k__DCT_CONST_ROUNDING); 658 const __m128i s1_18_5 = _mm_add_epi32(s1_18_3, k__DCT_CONST_ROUNDING); 659 const __m128i s1_19_4 = _mm_add_epi32(s1_19_2, k__DCT_CONST_ROUNDING); 660 const __m128i s1_19_5 = _mm_add_epi32(s1_19_3, k__DCT_CONST_ROUNDING); 661 const __m128i s1_20_4 = _mm_add_epi32(s1_20_2, k__DCT_CONST_ROUNDING); 662 const __m128i s1_20_5 = _mm_add_epi32(s1_20_3, k__DCT_CONST_ROUNDING); 663 const __m128i s1_21_4 = _mm_add_epi32(s1_21_2, k__DCT_CONST_ROUNDING); 664 const __m128i s1_21_5 = _mm_add_epi32(s1_21_3, k__DCT_CONST_ROUNDING); 665 const __m128i s1_26_4 = _mm_add_epi32(s1_26_2, k__DCT_CONST_ROUNDING); 666 const __m128i s1_26_5 = _mm_add_epi32(s1_26_3, k__DCT_CONST_ROUNDING); 667 const __m128i s1_27_4 = _mm_add_epi32(s1_27_2, k__DCT_CONST_ROUNDING); 668 const __m128i s1_27_5 = _mm_add_epi32(s1_27_3, k__DCT_CONST_ROUNDING); 669 const __m128i s1_28_4 = _mm_add_epi32(s1_28_2, k__DCT_CONST_ROUNDING); 670 const __m128i s1_28_5 = _mm_add_epi32(s1_28_3, k__DCT_CONST_ROUNDING); 671 const __m128i s1_29_4 = _mm_add_epi32(s1_29_2, k__DCT_CONST_ROUNDING); 672 const __m128i s1_29_5 = _mm_add_epi32(s1_29_3, k__DCT_CONST_ROUNDING); 673 const __m128i s1_18_6 = _mm_srai_epi32(s1_18_4, DCT_CONST_BITS); 674 const __m128i s1_18_7 = _mm_srai_epi32(s1_18_5, DCT_CONST_BITS); 675 const __m128i s1_19_6 = _mm_srai_epi32(s1_19_4, DCT_CONST_BITS); 676 const __m128i s1_19_7 = _mm_srai_epi32(s1_19_5, DCT_CONST_BITS); 677 const __m128i s1_20_6 = _mm_srai_epi32(s1_20_4, DCT_CONST_BITS); 678 const __m128i s1_20_7 = _mm_srai_epi32(s1_20_5, DCT_CONST_BITS); 679 const __m128i s1_21_6 = _mm_srai_epi32(s1_21_4, DCT_CONST_BITS); 680 const __m128i s1_21_7 = _mm_srai_epi32(s1_21_5, DCT_CONST_BITS); 681 const __m128i s1_26_6 = _mm_srai_epi32(s1_26_4, DCT_CONST_BITS); 682 const __m128i s1_26_7 = _mm_srai_epi32(s1_26_5, DCT_CONST_BITS); 683 const __m128i s1_27_6 = _mm_srai_epi32(s1_27_4, DCT_CONST_BITS); 684 const __m128i s1_27_7 = _mm_srai_epi32(s1_27_5, DCT_CONST_BITS); 685 const __m128i s1_28_6 = _mm_srai_epi32(s1_28_4, DCT_CONST_BITS); 686 const __m128i s1_28_7 = _mm_srai_epi32(s1_28_5, DCT_CONST_BITS); 687 const __m128i s1_29_6 = _mm_srai_epi32(s1_29_4, DCT_CONST_BITS); 688 const __m128i s1_29_7 = _mm_srai_epi32(s1_29_5, DCT_CONST_BITS); 689 // Combine 690 step1[18] = _mm_packs_epi32(s1_18_6, s1_18_7); 691 step1[19] = _mm_packs_epi32(s1_19_6, s1_19_7); 692 step1[20] = _mm_packs_epi32(s1_20_6, s1_20_7); 693 step1[21] = _mm_packs_epi32(s1_21_6, s1_21_7); 694 step1[26] = _mm_packs_epi32(s1_26_6, s1_26_7); 695 step1[27] = _mm_packs_epi32(s1_27_6, s1_27_7); 696 step1[28] = _mm_packs_epi32(s1_28_6, s1_28_7); 697 step1[29] = _mm_packs_epi32(s1_29_6, s1_29_7); 698 } 699 // Stage 5 700 { 701 step2[4] = _mm_add_epi16(step1[5], step3[4]); 702 step2[5] = _mm_sub_epi16(step3[4], step1[5]); 703 step2[6] = _mm_sub_epi16(step3[7], step1[6]); 704 step2[7] = _mm_add_epi16(step1[6], step3[7]); 705 } 706 { 707 const __m128i out_00_0 = _mm_unpacklo_epi16(step1[0], step1[1]); 708 const __m128i out_00_1 = _mm_unpackhi_epi16(step1[0], step1[1]); 709 const __m128i out_08_0 = _mm_unpacklo_epi16(step1[2], step1[3]); 710 const __m128i out_08_1 = _mm_unpackhi_epi16(step1[2], step1[3]); 711 const __m128i out_00_2 = _mm_madd_epi16(out_00_0, k__cospi_p16_p16); 712 const __m128i out_00_3 = _mm_madd_epi16(out_00_1, k__cospi_p16_p16); 713 const __m128i out_16_2 = _mm_madd_epi16(out_00_0, k__cospi_p16_m16); 714 const __m128i out_16_3 = _mm_madd_epi16(out_00_1, k__cospi_p16_m16); 715 const __m128i out_08_2 = _mm_madd_epi16(out_08_0, k__cospi_p24_p08); 716 const __m128i out_08_3 = _mm_madd_epi16(out_08_1, k__cospi_p24_p08); 717 const __m128i out_24_2 = _mm_madd_epi16(out_08_0, k__cospi_m08_p24); 718 const __m128i out_24_3 = _mm_madd_epi16(out_08_1, k__cospi_m08_p24); 719 // dct_const_round_shift 720 const __m128i out_00_4 = _mm_add_epi32(out_00_2, k__DCT_CONST_ROUNDING); 721 const __m128i out_00_5 = _mm_add_epi32(out_00_3, k__DCT_CONST_ROUNDING); 722 const __m128i out_16_4 = _mm_add_epi32(out_16_2, k__DCT_CONST_ROUNDING); 723 const __m128i out_16_5 = _mm_add_epi32(out_16_3, k__DCT_CONST_ROUNDING); 724 const __m128i out_08_4 = _mm_add_epi32(out_08_2, k__DCT_CONST_ROUNDING); 725 const __m128i out_08_5 = _mm_add_epi32(out_08_3, k__DCT_CONST_ROUNDING); 726 const __m128i out_24_4 = _mm_add_epi32(out_24_2, k__DCT_CONST_ROUNDING); 727 const __m128i out_24_5 = _mm_add_epi32(out_24_3, k__DCT_CONST_ROUNDING); 728 const __m128i out_00_6 = _mm_srai_epi32(out_00_4, DCT_CONST_BITS); 729 const __m128i out_00_7 = _mm_srai_epi32(out_00_5, DCT_CONST_BITS); 730 const __m128i out_16_6 = _mm_srai_epi32(out_16_4, DCT_CONST_BITS); 731 const __m128i out_16_7 = _mm_srai_epi32(out_16_5, DCT_CONST_BITS); 732 const __m128i out_08_6 = _mm_srai_epi32(out_08_4, DCT_CONST_BITS); 733 const __m128i out_08_7 = _mm_srai_epi32(out_08_5, DCT_CONST_BITS); 734 const __m128i out_24_6 = _mm_srai_epi32(out_24_4, DCT_CONST_BITS); 735 const __m128i out_24_7 = _mm_srai_epi32(out_24_5, DCT_CONST_BITS); 736 // Combine 737 out[ 0] = _mm_packs_epi32(out_00_6, out_00_7); 738 out[16] = _mm_packs_epi32(out_16_6, out_16_7); 739 out[ 8] = _mm_packs_epi32(out_08_6, out_08_7); 740 out[24] = _mm_packs_epi32(out_24_6, out_24_7); 741 } 742 { 743 const __m128i s2_09_0 = _mm_unpacklo_epi16(step1[ 9], step1[14]); 744 const __m128i s2_09_1 = _mm_unpackhi_epi16(step1[ 9], step1[14]); 745 const __m128i s2_10_0 = _mm_unpacklo_epi16(step1[10], step1[13]); 746 const __m128i s2_10_1 = _mm_unpackhi_epi16(step1[10], step1[13]); 747 const __m128i s2_09_2 = _mm_madd_epi16(s2_09_0, k__cospi_m08_p24); 748 const __m128i s2_09_3 = _mm_madd_epi16(s2_09_1, k__cospi_m08_p24); 749 const __m128i s2_10_2 = _mm_madd_epi16(s2_10_0, k__cospi_m24_m08); 750 const __m128i s2_10_3 = _mm_madd_epi16(s2_10_1, k__cospi_m24_m08); 751 const __m128i s2_13_2 = _mm_madd_epi16(s2_10_0, k__cospi_m08_p24); 752 const __m128i s2_13_3 = _mm_madd_epi16(s2_10_1, k__cospi_m08_p24); 753 const __m128i s2_14_2 = _mm_madd_epi16(s2_09_0, k__cospi_p24_p08); 754 const __m128i s2_14_3 = _mm_madd_epi16(s2_09_1, k__cospi_p24_p08); 755 // dct_const_round_shift 756 const __m128i s2_09_4 = _mm_add_epi32(s2_09_2, k__DCT_CONST_ROUNDING); 757 const __m128i s2_09_5 = _mm_add_epi32(s2_09_3, k__DCT_CONST_ROUNDING); 758 const __m128i s2_10_4 = _mm_add_epi32(s2_10_2, k__DCT_CONST_ROUNDING); 759 const __m128i s2_10_5 = _mm_add_epi32(s2_10_3, k__DCT_CONST_ROUNDING); 760 const __m128i s2_13_4 = _mm_add_epi32(s2_13_2, k__DCT_CONST_ROUNDING); 761 const __m128i s2_13_5 = _mm_add_epi32(s2_13_3, k__DCT_CONST_ROUNDING); 762 const __m128i s2_14_4 = _mm_add_epi32(s2_14_2, k__DCT_CONST_ROUNDING); 763 const __m128i s2_14_5 = _mm_add_epi32(s2_14_3, k__DCT_CONST_ROUNDING); 764 const __m128i s2_09_6 = _mm_srai_epi32(s2_09_4, DCT_CONST_BITS); 765 const __m128i s2_09_7 = _mm_srai_epi32(s2_09_5, DCT_CONST_BITS); 766 const __m128i s2_10_6 = _mm_srai_epi32(s2_10_4, DCT_CONST_BITS); 767 const __m128i s2_10_7 = _mm_srai_epi32(s2_10_5, DCT_CONST_BITS); 768 const __m128i s2_13_6 = _mm_srai_epi32(s2_13_4, DCT_CONST_BITS); 769 const __m128i s2_13_7 = _mm_srai_epi32(s2_13_5, DCT_CONST_BITS); 770 const __m128i s2_14_6 = _mm_srai_epi32(s2_14_4, DCT_CONST_BITS); 771 const __m128i s2_14_7 = _mm_srai_epi32(s2_14_5, DCT_CONST_BITS); 772 // Combine 773 step2[ 9] = _mm_packs_epi32(s2_09_6, s2_09_7); 774 step2[10] = _mm_packs_epi32(s2_10_6, s2_10_7); 775 step2[13] = _mm_packs_epi32(s2_13_6, s2_13_7); 776 step2[14] = _mm_packs_epi32(s2_14_6, s2_14_7); 777 } 778 { 779 step2[16] = _mm_add_epi16(step1[19], step3[16]); 780 step2[17] = _mm_add_epi16(step1[18], step3[17]); 781 step2[18] = _mm_sub_epi16(step3[17], step1[18]); 782 step2[19] = _mm_sub_epi16(step3[16], step1[19]); 783 step2[20] = _mm_sub_epi16(step3[23], step1[20]); 784 step2[21] = _mm_sub_epi16(step3[22], step1[21]); 785 step2[22] = _mm_add_epi16(step1[21], step3[22]); 786 step2[23] = _mm_add_epi16(step1[20], step3[23]); 787 step2[24] = _mm_add_epi16(step1[27], step3[24]); 788 step2[25] = _mm_add_epi16(step1[26], step3[25]); 789 step2[26] = _mm_sub_epi16(step3[25], step1[26]); 790 step2[27] = _mm_sub_epi16(step3[24], step1[27]); 791 step2[28] = _mm_sub_epi16(step3[31], step1[28]); 792 step2[29] = _mm_sub_epi16(step3[30], step1[29]); 793 step2[30] = _mm_add_epi16(step1[29], step3[30]); 794 step2[31] = _mm_add_epi16(step1[28], step3[31]); 795 } 796 // Stage 6 797 { 798 const __m128i out_04_0 = _mm_unpacklo_epi16(step2[4], step2[7]); 799 const __m128i out_04_1 = _mm_unpackhi_epi16(step2[4], step2[7]); 800 const __m128i out_20_0 = _mm_unpacklo_epi16(step2[5], step2[6]); 801 const __m128i out_20_1 = _mm_unpackhi_epi16(step2[5], step2[6]); 802 const __m128i out_12_0 = _mm_unpacklo_epi16(step2[5], step2[6]); 803 const __m128i out_12_1 = _mm_unpackhi_epi16(step2[5], step2[6]); 804 const __m128i out_28_0 = _mm_unpacklo_epi16(step2[4], step2[7]); 805 const __m128i out_28_1 = _mm_unpackhi_epi16(step2[4], step2[7]); 806 const __m128i out_04_2 = _mm_madd_epi16(out_04_0, k__cospi_p28_p04); 807 const __m128i out_04_3 = _mm_madd_epi16(out_04_1, k__cospi_p28_p04); 808 const __m128i out_20_2 = _mm_madd_epi16(out_20_0, k__cospi_p12_p20); 809 const __m128i out_20_3 = _mm_madd_epi16(out_20_1, k__cospi_p12_p20); 810 const __m128i out_12_2 = _mm_madd_epi16(out_12_0, k__cospi_m20_p12); 811 const __m128i out_12_3 = _mm_madd_epi16(out_12_1, k__cospi_m20_p12); 812 const __m128i out_28_2 = _mm_madd_epi16(out_28_0, k__cospi_m04_p28); 813 const __m128i out_28_3 = _mm_madd_epi16(out_28_1, k__cospi_m04_p28); 814 // dct_const_round_shift 815 const __m128i out_04_4 = _mm_add_epi32(out_04_2, k__DCT_CONST_ROUNDING); 816 const __m128i out_04_5 = _mm_add_epi32(out_04_3, k__DCT_CONST_ROUNDING); 817 const __m128i out_20_4 = _mm_add_epi32(out_20_2, k__DCT_CONST_ROUNDING); 818 const __m128i out_20_5 = _mm_add_epi32(out_20_3, k__DCT_CONST_ROUNDING); 819 const __m128i out_12_4 = _mm_add_epi32(out_12_2, k__DCT_CONST_ROUNDING); 820 const __m128i out_12_5 = _mm_add_epi32(out_12_3, k__DCT_CONST_ROUNDING); 821 const __m128i out_28_4 = _mm_add_epi32(out_28_2, k__DCT_CONST_ROUNDING); 822 const __m128i out_28_5 = _mm_add_epi32(out_28_3, k__DCT_CONST_ROUNDING); 823 const __m128i out_04_6 = _mm_srai_epi32(out_04_4, DCT_CONST_BITS); 824 const __m128i out_04_7 = _mm_srai_epi32(out_04_5, DCT_CONST_BITS); 825 const __m128i out_20_6 = _mm_srai_epi32(out_20_4, DCT_CONST_BITS); 826 const __m128i out_20_7 = _mm_srai_epi32(out_20_5, DCT_CONST_BITS); 827 const __m128i out_12_6 = _mm_srai_epi32(out_12_4, DCT_CONST_BITS); 828 const __m128i out_12_7 = _mm_srai_epi32(out_12_5, DCT_CONST_BITS); 829 const __m128i out_28_6 = _mm_srai_epi32(out_28_4, DCT_CONST_BITS); 830 const __m128i out_28_7 = _mm_srai_epi32(out_28_5, DCT_CONST_BITS); 831 // Combine 832 out[ 4] = _mm_packs_epi32(out_04_6, out_04_7); 833 out[20] = _mm_packs_epi32(out_20_6, out_20_7); 834 out[12] = _mm_packs_epi32(out_12_6, out_12_7); 835 out[28] = _mm_packs_epi32(out_28_6, out_28_7); 836 } 837 { 838 step3[ 8] = _mm_add_epi16(step2[ 9], step1[ 8]); 839 step3[ 9] = _mm_sub_epi16(step1[ 8], step2[ 9]); 840 step3[10] = _mm_sub_epi16(step1[11], step2[10]); 841 step3[11] = _mm_add_epi16(step2[10], step1[11]); 842 step3[12] = _mm_add_epi16(step2[13], step1[12]); 843 step3[13] = _mm_sub_epi16(step1[12], step2[13]); 844 step3[14] = _mm_sub_epi16(step1[15], step2[14]); 845 step3[15] = _mm_add_epi16(step2[14], step1[15]); 846 } 847 { 848 const __m128i s3_17_0 = _mm_unpacklo_epi16(step2[17], step2[30]); 849 const __m128i s3_17_1 = _mm_unpackhi_epi16(step2[17], step2[30]); 850 const __m128i s3_18_0 = _mm_unpacklo_epi16(step2[18], step2[29]); 851 const __m128i s3_18_1 = _mm_unpackhi_epi16(step2[18], step2[29]); 852 const __m128i s3_21_0 = _mm_unpacklo_epi16(step2[21], step2[26]); 853 const __m128i s3_21_1 = _mm_unpackhi_epi16(step2[21], step2[26]); 854 const __m128i s3_22_0 = _mm_unpacklo_epi16(step2[22], step2[25]); 855 const __m128i s3_22_1 = _mm_unpackhi_epi16(step2[22], step2[25]); 856 const __m128i s3_17_2 = _mm_madd_epi16(s3_17_0, k__cospi_m04_p28); 857 const __m128i s3_17_3 = _mm_madd_epi16(s3_17_1, k__cospi_m04_p28); 858 const __m128i s3_18_2 = _mm_madd_epi16(s3_18_0, k__cospi_m28_m04); 859 const __m128i s3_18_3 = _mm_madd_epi16(s3_18_1, k__cospi_m28_m04); 860 const __m128i s3_21_2 = _mm_madd_epi16(s3_21_0, k__cospi_m20_p12); 861 const __m128i s3_21_3 = _mm_madd_epi16(s3_21_1, k__cospi_m20_p12); 862 const __m128i s3_22_2 = _mm_madd_epi16(s3_22_0, k__cospi_m12_m20); 863 const __m128i s3_22_3 = _mm_madd_epi16(s3_22_1, k__cospi_m12_m20); 864 const __m128i s3_25_2 = _mm_madd_epi16(s3_22_0, k__cospi_m20_p12); 865 const __m128i s3_25_3 = _mm_madd_epi16(s3_22_1, k__cospi_m20_p12); 866 const __m128i s3_26_2 = _mm_madd_epi16(s3_21_0, k__cospi_p12_p20); 867 const __m128i s3_26_3 = _mm_madd_epi16(s3_21_1, k__cospi_p12_p20); 868 const __m128i s3_29_2 = _mm_madd_epi16(s3_18_0, k__cospi_m04_p28); 869 const __m128i s3_29_3 = _mm_madd_epi16(s3_18_1, k__cospi_m04_p28); 870 const __m128i s3_30_2 = _mm_madd_epi16(s3_17_0, k__cospi_p28_p04); 871 const __m128i s3_30_3 = _mm_madd_epi16(s3_17_1, k__cospi_p28_p04); 872 // dct_const_round_shift 873 const __m128i s3_17_4 = _mm_add_epi32(s3_17_2, k__DCT_CONST_ROUNDING); 874 const __m128i s3_17_5 = _mm_add_epi32(s3_17_3, k__DCT_CONST_ROUNDING); 875 const __m128i s3_18_4 = _mm_add_epi32(s3_18_2, k__DCT_CONST_ROUNDING); 876 const __m128i s3_18_5 = _mm_add_epi32(s3_18_3, k__DCT_CONST_ROUNDING); 877 const __m128i s3_21_4 = _mm_add_epi32(s3_21_2, k__DCT_CONST_ROUNDING); 878 const __m128i s3_21_5 = _mm_add_epi32(s3_21_3, k__DCT_CONST_ROUNDING); 879 const __m128i s3_22_4 = _mm_add_epi32(s3_22_2, k__DCT_CONST_ROUNDING); 880 const __m128i s3_22_5 = _mm_add_epi32(s3_22_3, k__DCT_CONST_ROUNDING); 881 const __m128i s3_17_6 = _mm_srai_epi32(s3_17_4, DCT_CONST_BITS); 882 const __m128i s3_17_7 = _mm_srai_epi32(s3_17_5, DCT_CONST_BITS); 883 const __m128i s3_18_6 = _mm_srai_epi32(s3_18_4, DCT_CONST_BITS); 884 const __m128i s3_18_7 = _mm_srai_epi32(s3_18_5, DCT_CONST_BITS); 885 const __m128i s3_21_6 = _mm_srai_epi32(s3_21_4, DCT_CONST_BITS); 886 const __m128i s3_21_7 = _mm_srai_epi32(s3_21_5, DCT_CONST_BITS); 887 const __m128i s3_22_6 = _mm_srai_epi32(s3_22_4, DCT_CONST_BITS); 888 const __m128i s3_22_7 = _mm_srai_epi32(s3_22_5, DCT_CONST_BITS); 889 const __m128i s3_25_4 = _mm_add_epi32(s3_25_2, k__DCT_CONST_ROUNDING); 890 const __m128i s3_25_5 = _mm_add_epi32(s3_25_3, k__DCT_CONST_ROUNDING); 891 const __m128i s3_26_4 = _mm_add_epi32(s3_26_2, k__DCT_CONST_ROUNDING); 892 const __m128i s3_26_5 = _mm_add_epi32(s3_26_3, k__DCT_CONST_ROUNDING); 893 const __m128i s3_29_4 = _mm_add_epi32(s3_29_2, k__DCT_CONST_ROUNDING); 894 const __m128i s3_29_5 = _mm_add_epi32(s3_29_3, k__DCT_CONST_ROUNDING); 895 const __m128i s3_30_4 = _mm_add_epi32(s3_30_2, k__DCT_CONST_ROUNDING); 896 const __m128i s3_30_5 = _mm_add_epi32(s3_30_3, k__DCT_CONST_ROUNDING); 897 const __m128i s3_25_6 = _mm_srai_epi32(s3_25_4, DCT_CONST_BITS); 898 const __m128i s3_25_7 = _mm_srai_epi32(s3_25_5, DCT_CONST_BITS); 899 const __m128i s3_26_6 = _mm_srai_epi32(s3_26_4, DCT_CONST_BITS); 900 const __m128i s3_26_7 = _mm_srai_epi32(s3_26_5, DCT_CONST_BITS); 901 const __m128i s3_29_6 = _mm_srai_epi32(s3_29_4, DCT_CONST_BITS); 902 const __m128i s3_29_7 = _mm_srai_epi32(s3_29_5, DCT_CONST_BITS); 903 const __m128i s3_30_6 = _mm_srai_epi32(s3_30_4, DCT_CONST_BITS); 904 const __m128i s3_30_7 = _mm_srai_epi32(s3_30_5, DCT_CONST_BITS); 905 // Combine 906 step3[17] = _mm_packs_epi32(s3_17_6, s3_17_7); 907 step3[18] = _mm_packs_epi32(s3_18_6, s3_18_7); 908 step3[21] = _mm_packs_epi32(s3_21_6, s3_21_7); 909 step3[22] = _mm_packs_epi32(s3_22_6, s3_22_7); 910 // Combine 911 step3[25] = _mm_packs_epi32(s3_25_6, s3_25_7); 912 step3[26] = _mm_packs_epi32(s3_26_6, s3_26_7); 913 step3[29] = _mm_packs_epi32(s3_29_6, s3_29_7); 914 step3[30] = _mm_packs_epi32(s3_30_6, s3_30_7); 915 } 916 // Stage 7 917 { 918 const __m128i out_02_0 = _mm_unpacklo_epi16(step3[ 8], step3[15]); 919 const __m128i out_02_1 = _mm_unpackhi_epi16(step3[ 8], step3[15]); 920 const __m128i out_18_0 = _mm_unpacklo_epi16(step3[ 9], step3[14]); 921 const __m128i out_18_1 = _mm_unpackhi_epi16(step3[ 9], step3[14]); 922 const __m128i out_10_0 = _mm_unpacklo_epi16(step3[10], step3[13]); 923 const __m128i out_10_1 = _mm_unpackhi_epi16(step3[10], step3[13]); 924 const __m128i out_26_0 = _mm_unpacklo_epi16(step3[11], step3[12]); 925 const __m128i out_26_1 = _mm_unpackhi_epi16(step3[11], step3[12]); 926 const __m128i out_02_2 = _mm_madd_epi16(out_02_0, k__cospi_p30_p02); 927 const __m128i out_02_3 = _mm_madd_epi16(out_02_1, k__cospi_p30_p02); 928 const __m128i out_18_2 = _mm_madd_epi16(out_18_0, k__cospi_p14_p18); 929 const __m128i out_18_3 = _mm_madd_epi16(out_18_1, k__cospi_p14_p18); 930 const __m128i out_10_2 = _mm_madd_epi16(out_10_0, k__cospi_p22_p10); 931 const __m128i out_10_3 = _mm_madd_epi16(out_10_1, k__cospi_p22_p10); 932 const __m128i out_26_2 = _mm_madd_epi16(out_26_0, k__cospi_p06_p26); 933 const __m128i out_26_3 = _mm_madd_epi16(out_26_1, k__cospi_p06_p26); 934 const __m128i out_06_2 = _mm_madd_epi16(out_26_0, k__cospi_m26_p06); 935 const __m128i out_06_3 = _mm_madd_epi16(out_26_1, k__cospi_m26_p06); 936 const __m128i out_22_2 = _mm_madd_epi16(out_10_0, k__cospi_m10_p22); 937 const __m128i out_22_3 = _mm_madd_epi16(out_10_1, k__cospi_m10_p22); 938 const __m128i out_14_2 = _mm_madd_epi16(out_18_0, k__cospi_m18_p14); 939 const __m128i out_14_3 = _mm_madd_epi16(out_18_1, k__cospi_m18_p14); 940 const __m128i out_30_2 = _mm_madd_epi16(out_02_0, k__cospi_m02_p30); 941 const __m128i out_30_3 = _mm_madd_epi16(out_02_1, k__cospi_m02_p30); 942 // dct_const_round_shift 943 const __m128i out_02_4 = _mm_add_epi32(out_02_2, k__DCT_CONST_ROUNDING); 944 const __m128i out_02_5 = _mm_add_epi32(out_02_3, k__DCT_CONST_ROUNDING); 945 const __m128i out_18_4 = _mm_add_epi32(out_18_2, k__DCT_CONST_ROUNDING); 946 const __m128i out_18_5 = _mm_add_epi32(out_18_3, k__DCT_CONST_ROUNDING); 947 const __m128i out_10_4 = _mm_add_epi32(out_10_2, k__DCT_CONST_ROUNDING); 948 const __m128i out_10_5 = _mm_add_epi32(out_10_3, k__DCT_CONST_ROUNDING); 949 const __m128i out_26_4 = _mm_add_epi32(out_26_2, k__DCT_CONST_ROUNDING); 950 const __m128i out_26_5 = _mm_add_epi32(out_26_3, k__DCT_CONST_ROUNDING); 951 const __m128i out_06_4 = _mm_add_epi32(out_06_2, k__DCT_CONST_ROUNDING); 952 const __m128i out_06_5 = _mm_add_epi32(out_06_3, k__DCT_CONST_ROUNDING); 953 const __m128i out_22_4 = _mm_add_epi32(out_22_2, k__DCT_CONST_ROUNDING); 954 const __m128i out_22_5 = _mm_add_epi32(out_22_3, k__DCT_CONST_ROUNDING); 955 const __m128i out_14_4 = _mm_add_epi32(out_14_2, k__DCT_CONST_ROUNDING); 956 const __m128i out_14_5 = _mm_add_epi32(out_14_3, k__DCT_CONST_ROUNDING); 957 const __m128i out_30_4 = _mm_add_epi32(out_30_2, k__DCT_CONST_ROUNDING); 958 const __m128i out_30_5 = _mm_add_epi32(out_30_3, k__DCT_CONST_ROUNDING); 959 const __m128i out_02_6 = _mm_srai_epi32(out_02_4, DCT_CONST_BITS); 960 const __m128i out_02_7 = _mm_srai_epi32(out_02_5, DCT_CONST_BITS); 961 const __m128i out_18_6 = _mm_srai_epi32(out_18_4, DCT_CONST_BITS); 962 const __m128i out_18_7 = _mm_srai_epi32(out_18_5, DCT_CONST_BITS); 963 const __m128i out_10_6 = _mm_srai_epi32(out_10_4, DCT_CONST_BITS); 964 const __m128i out_10_7 = _mm_srai_epi32(out_10_5, DCT_CONST_BITS); 965 const __m128i out_26_6 = _mm_srai_epi32(out_26_4, DCT_CONST_BITS); 966 const __m128i out_26_7 = _mm_srai_epi32(out_26_5, DCT_CONST_BITS); 967 const __m128i out_06_6 = _mm_srai_epi32(out_06_4, DCT_CONST_BITS); 968 const __m128i out_06_7 = _mm_srai_epi32(out_06_5, DCT_CONST_BITS); 969 const __m128i out_22_6 = _mm_srai_epi32(out_22_4, DCT_CONST_BITS); 970 const __m128i out_22_7 = _mm_srai_epi32(out_22_5, DCT_CONST_BITS); 971 const __m128i out_14_6 = _mm_srai_epi32(out_14_4, DCT_CONST_BITS); 972 const __m128i out_14_7 = _mm_srai_epi32(out_14_5, DCT_CONST_BITS); 973 const __m128i out_30_6 = _mm_srai_epi32(out_30_4, DCT_CONST_BITS); 974 const __m128i out_30_7 = _mm_srai_epi32(out_30_5, DCT_CONST_BITS); 975 // Combine 976 out[ 2] = _mm_packs_epi32(out_02_6, out_02_7); 977 out[18] = _mm_packs_epi32(out_18_6, out_18_7); 978 out[10] = _mm_packs_epi32(out_10_6, out_10_7); 979 out[26] = _mm_packs_epi32(out_26_6, out_26_7); 980 out[ 6] = _mm_packs_epi32(out_06_6, out_06_7); 981 out[22] = _mm_packs_epi32(out_22_6, out_22_7); 982 out[14] = _mm_packs_epi32(out_14_6, out_14_7); 983 out[30] = _mm_packs_epi32(out_30_6, out_30_7); 984 } 985 { 986 step1[16] = _mm_add_epi16(step3[17], step2[16]); 987 step1[17] = _mm_sub_epi16(step2[16], step3[17]); 988 step1[18] = _mm_sub_epi16(step2[19], step3[18]); 989 step1[19] = _mm_add_epi16(step3[18], step2[19]); 990 step1[20] = _mm_add_epi16(step3[21], step2[20]); 991 step1[21] = _mm_sub_epi16(step2[20], step3[21]); 992 step1[22] = _mm_sub_epi16(step2[23], step3[22]); 993 step1[23] = _mm_add_epi16(step3[22], step2[23]); 994 step1[24] = _mm_add_epi16(step3[25], step2[24]); 995 step1[25] = _mm_sub_epi16(step2[24], step3[25]); 996 step1[26] = _mm_sub_epi16(step2[27], step3[26]); 997 step1[27] = _mm_add_epi16(step3[26], step2[27]); 998 step1[28] = _mm_add_epi16(step3[29], step2[28]); 999 step1[29] = _mm_sub_epi16(step2[28], step3[29]); 1000 step1[30] = _mm_sub_epi16(step2[31], step3[30]); 1001 step1[31] = _mm_add_epi16(step3[30], step2[31]); 1002 } 1003 // Final stage --- outputs indices are bit-reversed. 1004 { 1005 const __m128i out_01_0 = _mm_unpacklo_epi16(step1[16], step1[31]); 1006 const __m128i out_01_1 = _mm_unpackhi_epi16(step1[16], step1[31]); 1007 const __m128i out_17_0 = _mm_unpacklo_epi16(step1[17], step1[30]); 1008 const __m128i out_17_1 = _mm_unpackhi_epi16(step1[17], step1[30]); 1009 const __m128i out_09_0 = _mm_unpacklo_epi16(step1[18], step1[29]); 1010 const __m128i out_09_1 = _mm_unpackhi_epi16(step1[18], step1[29]); 1011 const __m128i out_25_0 = _mm_unpacklo_epi16(step1[19], step1[28]); 1012 const __m128i out_25_1 = _mm_unpackhi_epi16(step1[19], step1[28]); 1013 const __m128i out_01_2 = _mm_madd_epi16(out_01_0, k__cospi_p31_p01); 1014 const __m128i out_01_3 = _mm_madd_epi16(out_01_1, k__cospi_p31_p01); 1015 const __m128i out_17_2 = _mm_madd_epi16(out_17_0, k__cospi_p15_p17); 1016 const __m128i out_17_3 = _mm_madd_epi16(out_17_1, k__cospi_p15_p17); 1017 const __m128i out_09_2 = _mm_madd_epi16(out_09_0, k__cospi_p23_p09); 1018 const __m128i out_09_3 = _mm_madd_epi16(out_09_1, k__cospi_p23_p09); 1019 const __m128i out_25_2 = _mm_madd_epi16(out_25_0, k__cospi_p07_p25); 1020 const __m128i out_25_3 = _mm_madd_epi16(out_25_1, k__cospi_p07_p25); 1021 const __m128i out_07_2 = _mm_madd_epi16(out_25_0, k__cospi_m25_p07); 1022 const __m128i out_07_3 = _mm_madd_epi16(out_25_1, k__cospi_m25_p07); 1023 const __m128i out_23_2 = _mm_madd_epi16(out_09_0, k__cospi_m09_p23); 1024 const __m128i out_23_3 = _mm_madd_epi16(out_09_1, k__cospi_m09_p23); 1025 const __m128i out_15_2 = _mm_madd_epi16(out_17_0, k__cospi_m17_p15); 1026 const __m128i out_15_3 = _mm_madd_epi16(out_17_1, k__cospi_m17_p15); 1027 const __m128i out_31_2 = _mm_madd_epi16(out_01_0, k__cospi_m01_p31); 1028 const __m128i out_31_3 = _mm_madd_epi16(out_01_1, k__cospi_m01_p31); 1029 // dct_const_round_shift 1030 const __m128i out_01_4 = _mm_add_epi32(out_01_2, k__DCT_CONST_ROUNDING); 1031 const __m128i out_01_5 = _mm_add_epi32(out_01_3, k__DCT_CONST_ROUNDING); 1032 const __m128i out_17_4 = _mm_add_epi32(out_17_2, k__DCT_CONST_ROUNDING); 1033 const __m128i out_17_5 = _mm_add_epi32(out_17_3, k__DCT_CONST_ROUNDING); 1034 const __m128i out_09_4 = _mm_add_epi32(out_09_2, k__DCT_CONST_ROUNDING); 1035 const __m128i out_09_5 = _mm_add_epi32(out_09_3, k__DCT_CONST_ROUNDING); 1036 const __m128i out_25_4 = _mm_add_epi32(out_25_2, k__DCT_CONST_ROUNDING); 1037 const __m128i out_25_5 = _mm_add_epi32(out_25_3, k__DCT_CONST_ROUNDING); 1038 const __m128i out_07_4 = _mm_add_epi32(out_07_2, k__DCT_CONST_ROUNDING); 1039 const __m128i out_07_5 = _mm_add_epi32(out_07_3, k__DCT_CONST_ROUNDING); 1040 const __m128i out_23_4 = _mm_add_epi32(out_23_2, k__DCT_CONST_ROUNDING); 1041 const __m128i out_23_5 = _mm_add_epi32(out_23_3, k__DCT_CONST_ROUNDING); 1042 const __m128i out_15_4 = _mm_add_epi32(out_15_2, k__DCT_CONST_ROUNDING); 1043 const __m128i out_15_5 = _mm_add_epi32(out_15_3, k__DCT_CONST_ROUNDING); 1044 const __m128i out_31_4 = _mm_add_epi32(out_31_2, k__DCT_CONST_ROUNDING); 1045 const __m128i out_31_5 = _mm_add_epi32(out_31_3, k__DCT_CONST_ROUNDING); 1046 const __m128i out_01_6 = _mm_srai_epi32(out_01_4, DCT_CONST_BITS); 1047 const __m128i out_01_7 = _mm_srai_epi32(out_01_5, DCT_CONST_BITS); 1048 const __m128i out_17_6 = _mm_srai_epi32(out_17_4, DCT_CONST_BITS); 1049 const __m128i out_17_7 = _mm_srai_epi32(out_17_5, DCT_CONST_BITS); 1050 const __m128i out_09_6 = _mm_srai_epi32(out_09_4, DCT_CONST_BITS); 1051 const __m128i out_09_7 = _mm_srai_epi32(out_09_5, DCT_CONST_BITS); 1052 const __m128i out_25_6 = _mm_srai_epi32(out_25_4, DCT_CONST_BITS); 1053 const __m128i out_25_7 = _mm_srai_epi32(out_25_5, DCT_CONST_BITS); 1054 const __m128i out_07_6 = _mm_srai_epi32(out_07_4, DCT_CONST_BITS); 1055 const __m128i out_07_7 = _mm_srai_epi32(out_07_5, DCT_CONST_BITS); 1056 const __m128i out_23_6 = _mm_srai_epi32(out_23_4, DCT_CONST_BITS); 1057 const __m128i out_23_7 = _mm_srai_epi32(out_23_5, DCT_CONST_BITS); 1058 const __m128i out_15_6 = _mm_srai_epi32(out_15_4, DCT_CONST_BITS); 1059 const __m128i out_15_7 = _mm_srai_epi32(out_15_5, DCT_CONST_BITS); 1060 const __m128i out_31_6 = _mm_srai_epi32(out_31_4, DCT_CONST_BITS); 1061 const __m128i out_31_7 = _mm_srai_epi32(out_31_5, DCT_CONST_BITS); 1062 // Combine 1063 out[ 1] = _mm_packs_epi32(out_01_6, out_01_7); 1064 out[17] = _mm_packs_epi32(out_17_6, out_17_7); 1065 out[ 9] = _mm_packs_epi32(out_09_6, out_09_7); 1066 out[25] = _mm_packs_epi32(out_25_6, out_25_7); 1067 out[ 7] = _mm_packs_epi32(out_07_6, out_07_7); 1068 out[23] = _mm_packs_epi32(out_23_6, out_23_7); 1069 out[15] = _mm_packs_epi32(out_15_6, out_15_7); 1070 out[31] = _mm_packs_epi32(out_31_6, out_31_7); 1071 } 1072 { 1073 const __m128i out_05_0 = _mm_unpacklo_epi16(step1[20], step1[27]); 1074 const __m128i out_05_1 = _mm_unpackhi_epi16(step1[20], step1[27]); 1075 const __m128i out_21_0 = _mm_unpacklo_epi16(step1[21], step1[26]); 1076 const __m128i out_21_1 = _mm_unpackhi_epi16(step1[21], step1[26]); 1077 const __m128i out_13_0 = _mm_unpacklo_epi16(step1[22], step1[25]); 1078 const __m128i out_13_1 = _mm_unpackhi_epi16(step1[22], step1[25]); 1079 const __m128i out_29_0 = _mm_unpacklo_epi16(step1[23], step1[24]); 1080 const __m128i out_29_1 = _mm_unpackhi_epi16(step1[23], step1[24]); 1081 const __m128i out_05_2 = _mm_madd_epi16(out_05_0, k__cospi_p27_p05); 1082 const __m128i out_05_3 = _mm_madd_epi16(out_05_1, k__cospi_p27_p05); 1083 const __m128i out_21_2 = _mm_madd_epi16(out_21_0, k__cospi_p11_p21); 1084 const __m128i out_21_3 = _mm_madd_epi16(out_21_1, k__cospi_p11_p21); 1085 const __m128i out_13_2 = _mm_madd_epi16(out_13_0, k__cospi_p19_p13); 1086 const __m128i out_13_3 = _mm_madd_epi16(out_13_1, k__cospi_p19_p13); 1087 const __m128i out_29_2 = _mm_madd_epi16(out_29_0, k__cospi_p03_p29); 1088 const __m128i out_29_3 = _mm_madd_epi16(out_29_1, k__cospi_p03_p29); 1089 const __m128i out_03_2 = _mm_madd_epi16(out_29_0, k__cospi_m29_p03); 1090 const __m128i out_03_3 = _mm_madd_epi16(out_29_1, k__cospi_m29_p03); 1091 const __m128i out_19_2 = _mm_madd_epi16(out_13_0, k__cospi_m13_p19); 1092 const __m128i out_19_3 = _mm_madd_epi16(out_13_1, k__cospi_m13_p19); 1093 const __m128i out_11_2 = _mm_madd_epi16(out_21_0, k__cospi_m21_p11); 1094 const __m128i out_11_3 = _mm_madd_epi16(out_21_1, k__cospi_m21_p11); 1095 const __m128i out_27_2 = _mm_madd_epi16(out_05_0, k__cospi_m05_p27); 1096 const __m128i out_27_3 = _mm_madd_epi16(out_05_1, k__cospi_m05_p27); 1097 // dct_const_round_shift 1098 const __m128i out_05_4 = _mm_add_epi32(out_05_2, k__DCT_CONST_ROUNDING); 1099 const __m128i out_05_5 = _mm_add_epi32(out_05_3, k__DCT_CONST_ROUNDING); 1100 const __m128i out_21_4 = _mm_add_epi32(out_21_2, k__DCT_CONST_ROUNDING); 1101 const __m128i out_21_5 = _mm_add_epi32(out_21_3, k__DCT_CONST_ROUNDING); 1102 const __m128i out_13_4 = _mm_add_epi32(out_13_2, k__DCT_CONST_ROUNDING); 1103 const __m128i out_13_5 = _mm_add_epi32(out_13_3, k__DCT_CONST_ROUNDING); 1104 const __m128i out_29_4 = _mm_add_epi32(out_29_2, k__DCT_CONST_ROUNDING); 1105 const __m128i out_29_5 = _mm_add_epi32(out_29_3, k__DCT_CONST_ROUNDING); 1106 const __m128i out_03_4 = _mm_add_epi32(out_03_2, k__DCT_CONST_ROUNDING); 1107 const __m128i out_03_5 = _mm_add_epi32(out_03_3, k__DCT_CONST_ROUNDING); 1108 const __m128i out_19_4 = _mm_add_epi32(out_19_2, k__DCT_CONST_ROUNDING); 1109 const __m128i out_19_5 = _mm_add_epi32(out_19_3, k__DCT_CONST_ROUNDING); 1110 const __m128i out_11_4 = _mm_add_epi32(out_11_2, k__DCT_CONST_ROUNDING); 1111 const __m128i out_11_5 = _mm_add_epi32(out_11_3, k__DCT_CONST_ROUNDING); 1112 const __m128i out_27_4 = _mm_add_epi32(out_27_2, k__DCT_CONST_ROUNDING); 1113 const __m128i out_27_5 = _mm_add_epi32(out_27_3, k__DCT_CONST_ROUNDING); 1114 const __m128i out_05_6 = _mm_srai_epi32(out_05_4, DCT_CONST_BITS); 1115 const __m128i out_05_7 = _mm_srai_epi32(out_05_5, DCT_CONST_BITS); 1116 const __m128i out_21_6 = _mm_srai_epi32(out_21_4, DCT_CONST_BITS); 1117 const __m128i out_21_7 = _mm_srai_epi32(out_21_5, DCT_CONST_BITS); 1118 const __m128i out_13_6 = _mm_srai_epi32(out_13_4, DCT_CONST_BITS); 1119 const __m128i out_13_7 = _mm_srai_epi32(out_13_5, DCT_CONST_BITS); 1120 const __m128i out_29_6 = _mm_srai_epi32(out_29_4, DCT_CONST_BITS); 1121 const __m128i out_29_7 = _mm_srai_epi32(out_29_5, DCT_CONST_BITS); 1122 const __m128i out_03_6 = _mm_srai_epi32(out_03_4, DCT_CONST_BITS); 1123 const __m128i out_03_7 = _mm_srai_epi32(out_03_5, DCT_CONST_BITS); 1124 const __m128i out_19_6 = _mm_srai_epi32(out_19_4, DCT_CONST_BITS); 1125 const __m128i out_19_7 = _mm_srai_epi32(out_19_5, DCT_CONST_BITS); 1126 const __m128i out_11_6 = _mm_srai_epi32(out_11_4, DCT_CONST_BITS); 1127 const __m128i out_11_7 = _mm_srai_epi32(out_11_5, DCT_CONST_BITS); 1128 const __m128i out_27_6 = _mm_srai_epi32(out_27_4, DCT_CONST_BITS); 1129 const __m128i out_27_7 = _mm_srai_epi32(out_27_5, DCT_CONST_BITS); 1130 // Combine 1131 out[ 5] = _mm_packs_epi32(out_05_6, out_05_7); 1132 out[21] = _mm_packs_epi32(out_21_6, out_21_7); 1133 out[13] = _mm_packs_epi32(out_13_6, out_13_7); 1134 out[29] = _mm_packs_epi32(out_29_6, out_29_7); 1135 out[ 3] = _mm_packs_epi32(out_03_6, out_03_7); 1136 out[19] = _mm_packs_epi32(out_19_6, out_19_7); 1137 out[11] = _mm_packs_epi32(out_11_6, out_11_7); 1138 out[27] = _mm_packs_epi32(out_27_6, out_27_7); 1139 } 1140 #if FDCT32x32_HIGH_PRECISION 1141 } else { 1142 __m128i lstep1[64], lstep2[64], lstep3[64]; 1143 __m128i u[32], v[32], sign[16]; 1144 const __m128i K32One = _mm_set_epi32(1, 1, 1, 1); 1145 // start using 32-bit operations 1146 // stage 3 1147 { 1148 // expanding to 32-bit length priori to addition operations 1149 lstep2[ 0] = _mm_unpacklo_epi16(step2[ 0], kZero); 1150 lstep2[ 1] = _mm_unpackhi_epi16(step2[ 0], kZero); 1151 lstep2[ 2] = _mm_unpacklo_epi16(step2[ 1], kZero); 1152 lstep2[ 3] = _mm_unpackhi_epi16(step2[ 1], kZero); 1153 lstep2[ 4] = _mm_unpacklo_epi16(step2[ 2], kZero); 1154 lstep2[ 5] = _mm_unpackhi_epi16(step2[ 2], kZero); 1155 lstep2[ 6] = _mm_unpacklo_epi16(step2[ 3], kZero); 1156 lstep2[ 7] = _mm_unpackhi_epi16(step2[ 3], kZero); 1157 lstep2[ 8] = _mm_unpacklo_epi16(step2[ 4], kZero); 1158 lstep2[ 9] = _mm_unpackhi_epi16(step2[ 4], kZero); 1159 lstep2[10] = _mm_unpacklo_epi16(step2[ 5], kZero); 1160 lstep2[11] = _mm_unpackhi_epi16(step2[ 5], kZero); 1161 lstep2[12] = _mm_unpacklo_epi16(step2[ 6], kZero); 1162 lstep2[13] = _mm_unpackhi_epi16(step2[ 6], kZero); 1163 lstep2[14] = _mm_unpacklo_epi16(step2[ 7], kZero); 1164 lstep2[15] = _mm_unpackhi_epi16(step2[ 7], kZero); 1165 lstep2[ 0] = _mm_madd_epi16(lstep2[ 0], kOne); 1166 lstep2[ 1] = _mm_madd_epi16(lstep2[ 1], kOne); 1167 lstep2[ 2] = _mm_madd_epi16(lstep2[ 2], kOne); 1168 lstep2[ 3] = _mm_madd_epi16(lstep2[ 3], kOne); 1169 lstep2[ 4] = _mm_madd_epi16(lstep2[ 4], kOne); 1170 lstep2[ 5] = _mm_madd_epi16(lstep2[ 5], kOne); 1171 lstep2[ 6] = _mm_madd_epi16(lstep2[ 6], kOne); 1172 lstep2[ 7] = _mm_madd_epi16(lstep2[ 7], kOne); 1173 lstep2[ 8] = _mm_madd_epi16(lstep2[ 8], kOne); 1174 lstep2[ 9] = _mm_madd_epi16(lstep2[ 9], kOne); 1175 lstep2[10] = _mm_madd_epi16(lstep2[10], kOne); 1176 lstep2[11] = _mm_madd_epi16(lstep2[11], kOne); 1177 lstep2[12] = _mm_madd_epi16(lstep2[12], kOne); 1178 lstep2[13] = _mm_madd_epi16(lstep2[13], kOne); 1179 lstep2[14] = _mm_madd_epi16(lstep2[14], kOne); 1180 lstep2[15] = _mm_madd_epi16(lstep2[15], kOne); 1181 1182 lstep3[ 0] = _mm_add_epi32(lstep2[14], lstep2[ 0]); 1183 lstep3[ 1] = _mm_add_epi32(lstep2[15], lstep2[ 1]); 1184 lstep3[ 2] = _mm_add_epi32(lstep2[12], lstep2[ 2]); 1185 lstep3[ 3] = _mm_add_epi32(lstep2[13], lstep2[ 3]); 1186 lstep3[ 4] = _mm_add_epi32(lstep2[10], lstep2[ 4]); 1187 lstep3[ 5] = _mm_add_epi32(lstep2[11], lstep2[ 5]); 1188 lstep3[ 6] = _mm_add_epi32(lstep2[ 8], lstep2[ 6]); 1189 lstep3[ 7] = _mm_add_epi32(lstep2[ 9], lstep2[ 7]); 1190 lstep3[ 8] = _mm_sub_epi32(lstep2[ 6], lstep2[ 8]); 1191 lstep3[ 9] = _mm_sub_epi32(lstep2[ 7], lstep2[ 9]); 1192 lstep3[10] = _mm_sub_epi32(lstep2[ 4], lstep2[10]); 1193 lstep3[11] = _mm_sub_epi32(lstep2[ 5], lstep2[11]); 1194 lstep3[12] = _mm_sub_epi32(lstep2[ 2], lstep2[12]); 1195 lstep3[13] = _mm_sub_epi32(lstep2[ 3], lstep2[13]); 1196 lstep3[14] = _mm_sub_epi32(lstep2[ 0], lstep2[14]); 1197 lstep3[15] = _mm_sub_epi32(lstep2[ 1], lstep2[15]); 1198 } 1199 { 1200 const __m128i s3_10_0 = _mm_unpacklo_epi16(step2[13], step2[10]); 1201 const __m128i s3_10_1 = _mm_unpackhi_epi16(step2[13], step2[10]); 1202 const __m128i s3_11_0 = _mm_unpacklo_epi16(step2[12], step2[11]); 1203 const __m128i s3_11_1 = _mm_unpackhi_epi16(step2[12], step2[11]); 1204 const __m128i s3_10_2 = _mm_madd_epi16(s3_10_0, k__cospi_p16_m16); 1205 const __m128i s3_10_3 = _mm_madd_epi16(s3_10_1, k__cospi_p16_m16); 1206 const __m128i s3_11_2 = _mm_madd_epi16(s3_11_0, k__cospi_p16_m16); 1207 const __m128i s3_11_3 = _mm_madd_epi16(s3_11_1, k__cospi_p16_m16); 1208 const __m128i s3_12_2 = _mm_madd_epi16(s3_11_0, k__cospi_p16_p16); 1209 const __m128i s3_12_3 = _mm_madd_epi16(s3_11_1, k__cospi_p16_p16); 1210 const __m128i s3_13_2 = _mm_madd_epi16(s3_10_0, k__cospi_p16_p16); 1211 const __m128i s3_13_3 = _mm_madd_epi16(s3_10_1, k__cospi_p16_p16); 1212 // dct_const_round_shift 1213 const __m128i s3_10_4 = _mm_add_epi32(s3_10_2, k__DCT_CONST_ROUNDING); 1214 const __m128i s3_10_5 = _mm_add_epi32(s3_10_3, k__DCT_CONST_ROUNDING); 1215 const __m128i s3_11_4 = _mm_add_epi32(s3_11_2, k__DCT_CONST_ROUNDING); 1216 const __m128i s3_11_5 = _mm_add_epi32(s3_11_3, k__DCT_CONST_ROUNDING); 1217 const __m128i s3_12_4 = _mm_add_epi32(s3_12_2, k__DCT_CONST_ROUNDING); 1218 const __m128i s3_12_5 = _mm_add_epi32(s3_12_3, k__DCT_CONST_ROUNDING); 1219 const __m128i s3_13_4 = _mm_add_epi32(s3_13_2, k__DCT_CONST_ROUNDING); 1220 const __m128i s3_13_5 = _mm_add_epi32(s3_13_3, k__DCT_CONST_ROUNDING); 1221 lstep3[20] = _mm_srai_epi32(s3_10_4, DCT_CONST_BITS); 1222 lstep3[21] = _mm_srai_epi32(s3_10_5, DCT_CONST_BITS); 1223 lstep3[22] = _mm_srai_epi32(s3_11_4, DCT_CONST_BITS); 1224 lstep3[23] = _mm_srai_epi32(s3_11_5, DCT_CONST_BITS); 1225 lstep3[24] = _mm_srai_epi32(s3_12_4, DCT_CONST_BITS); 1226 lstep3[25] = _mm_srai_epi32(s3_12_5, DCT_CONST_BITS); 1227 lstep3[26] = _mm_srai_epi32(s3_13_4, DCT_CONST_BITS); 1228 lstep3[27] = _mm_srai_epi32(s3_13_5, DCT_CONST_BITS); 1229 } 1230 { 1231 lstep2[40] = _mm_unpacklo_epi16(step2[20], kZero); 1232 lstep2[41] = _mm_unpackhi_epi16(step2[20], kZero); 1233 lstep2[42] = _mm_unpacklo_epi16(step2[21], kZero); 1234 lstep2[43] = _mm_unpackhi_epi16(step2[21], kZero); 1235 lstep2[44] = _mm_unpacklo_epi16(step2[22], kZero); 1236 lstep2[45] = _mm_unpackhi_epi16(step2[22], kZero); 1237 lstep2[46] = _mm_unpacklo_epi16(step2[23], kZero); 1238 lstep2[47] = _mm_unpackhi_epi16(step2[23], kZero); 1239 lstep2[48] = _mm_unpacklo_epi16(step2[24], kZero); 1240 lstep2[49] = _mm_unpackhi_epi16(step2[24], kZero); 1241 lstep2[50] = _mm_unpacklo_epi16(step2[25], kZero); 1242 lstep2[51] = _mm_unpackhi_epi16(step2[25], kZero); 1243 lstep2[52] = _mm_unpacklo_epi16(step2[26], kZero); 1244 lstep2[53] = _mm_unpackhi_epi16(step2[26], kZero); 1245 lstep2[54] = _mm_unpacklo_epi16(step2[27], kZero); 1246 lstep2[55] = _mm_unpackhi_epi16(step2[27], kZero); 1247 lstep2[40] = _mm_madd_epi16(lstep2[40], kOne); 1248 lstep2[41] = _mm_madd_epi16(lstep2[41], kOne); 1249 lstep2[42] = _mm_madd_epi16(lstep2[42], kOne); 1250 lstep2[43] = _mm_madd_epi16(lstep2[43], kOne); 1251 lstep2[44] = _mm_madd_epi16(lstep2[44], kOne); 1252 lstep2[45] = _mm_madd_epi16(lstep2[45], kOne); 1253 lstep2[46] = _mm_madd_epi16(lstep2[46], kOne); 1254 lstep2[47] = _mm_madd_epi16(lstep2[47], kOne); 1255 lstep2[48] = _mm_madd_epi16(lstep2[48], kOne); 1256 lstep2[49] = _mm_madd_epi16(lstep2[49], kOne); 1257 lstep2[50] = _mm_madd_epi16(lstep2[50], kOne); 1258 lstep2[51] = _mm_madd_epi16(lstep2[51], kOne); 1259 lstep2[52] = _mm_madd_epi16(lstep2[52], kOne); 1260 lstep2[53] = _mm_madd_epi16(lstep2[53], kOne); 1261 lstep2[54] = _mm_madd_epi16(lstep2[54], kOne); 1262 lstep2[55] = _mm_madd_epi16(lstep2[55], kOne); 1263 1264 lstep1[32] = _mm_unpacklo_epi16(step1[16], kZero); 1265 lstep1[33] = _mm_unpackhi_epi16(step1[16], kZero); 1266 lstep1[34] = _mm_unpacklo_epi16(step1[17], kZero); 1267 lstep1[35] = _mm_unpackhi_epi16(step1[17], kZero); 1268 lstep1[36] = _mm_unpacklo_epi16(step1[18], kZero); 1269 lstep1[37] = _mm_unpackhi_epi16(step1[18], kZero); 1270 lstep1[38] = _mm_unpacklo_epi16(step1[19], kZero); 1271 lstep1[39] = _mm_unpackhi_epi16(step1[19], kZero); 1272 lstep1[56] = _mm_unpacklo_epi16(step1[28], kZero); 1273 lstep1[57] = _mm_unpackhi_epi16(step1[28], kZero); 1274 lstep1[58] = _mm_unpacklo_epi16(step1[29], kZero); 1275 lstep1[59] = _mm_unpackhi_epi16(step1[29], kZero); 1276 lstep1[60] = _mm_unpacklo_epi16(step1[30], kZero); 1277 lstep1[61] = _mm_unpackhi_epi16(step1[30], kZero); 1278 lstep1[62] = _mm_unpacklo_epi16(step1[31], kZero); 1279 lstep1[63] = _mm_unpackhi_epi16(step1[31], kZero); 1280 lstep1[32] = _mm_madd_epi16(lstep1[32], kOne); 1281 lstep1[33] = _mm_madd_epi16(lstep1[33], kOne); 1282 lstep1[34] = _mm_madd_epi16(lstep1[34], kOne); 1283 lstep1[35] = _mm_madd_epi16(lstep1[35], kOne); 1284 lstep1[36] = _mm_madd_epi16(lstep1[36], kOne); 1285 lstep1[37] = _mm_madd_epi16(lstep1[37], kOne); 1286 lstep1[38] = _mm_madd_epi16(lstep1[38], kOne); 1287 lstep1[39] = _mm_madd_epi16(lstep1[39], kOne); 1288 lstep1[56] = _mm_madd_epi16(lstep1[56], kOne); 1289 lstep1[57] = _mm_madd_epi16(lstep1[57], kOne); 1290 lstep1[58] = _mm_madd_epi16(lstep1[58], kOne); 1291 lstep1[59] = _mm_madd_epi16(lstep1[59], kOne); 1292 lstep1[60] = _mm_madd_epi16(lstep1[60], kOne); 1293 lstep1[61] = _mm_madd_epi16(lstep1[61], kOne); 1294 lstep1[62] = _mm_madd_epi16(lstep1[62], kOne); 1295 lstep1[63] = _mm_madd_epi16(lstep1[63], kOne); 1296 1297 lstep3[32] = _mm_add_epi32(lstep2[46], lstep1[32]); 1298 lstep3[33] = _mm_add_epi32(lstep2[47], lstep1[33]); 1299 1300 lstep3[34] = _mm_add_epi32(lstep2[44], lstep1[34]); 1301 lstep3[35] = _mm_add_epi32(lstep2[45], lstep1[35]); 1302 lstep3[36] = _mm_add_epi32(lstep2[42], lstep1[36]); 1303 lstep3[37] = _mm_add_epi32(lstep2[43], lstep1[37]); 1304 lstep3[38] = _mm_add_epi32(lstep2[40], lstep1[38]); 1305 lstep3[39] = _mm_add_epi32(lstep2[41], lstep1[39]); 1306 lstep3[40] = _mm_sub_epi32(lstep1[38], lstep2[40]); 1307 lstep3[41] = _mm_sub_epi32(lstep1[39], lstep2[41]); 1308 lstep3[42] = _mm_sub_epi32(lstep1[36], lstep2[42]); 1309 lstep3[43] = _mm_sub_epi32(lstep1[37], lstep2[43]); 1310 lstep3[44] = _mm_sub_epi32(lstep1[34], lstep2[44]); 1311 lstep3[45] = _mm_sub_epi32(lstep1[35], lstep2[45]); 1312 lstep3[46] = _mm_sub_epi32(lstep1[32], lstep2[46]); 1313 lstep3[47] = _mm_sub_epi32(lstep1[33], lstep2[47]); 1314 lstep3[48] = _mm_sub_epi32(lstep1[62], lstep2[48]); 1315 lstep3[49] = _mm_sub_epi32(lstep1[63], lstep2[49]); 1316 lstep3[50] = _mm_sub_epi32(lstep1[60], lstep2[50]); 1317 lstep3[51] = _mm_sub_epi32(lstep1[61], lstep2[51]); 1318 lstep3[52] = _mm_sub_epi32(lstep1[58], lstep2[52]); 1319 lstep3[53] = _mm_sub_epi32(lstep1[59], lstep2[53]); 1320 lstep3[54] = _mm_sub_epi32(lstep1[56], lstep2[54]); 1321 lstep3[55] = _mm_sub_epi32(lstep1[57], lstep2[55]); 1322 lstep3[56] = _mm_add_epi32(lstep2[54], lstep1[56]); 1323 lstep3[57] = _mm_add_epi32(lstep2[55], lstep1[57]); 1324 lstep3[58] = _mm_add_epi32(lstep2[52], lstep1[58]); 1325 lstep3[59] = _mm_add_epi32(lstep2[53], lstep1[59]); 1326 lstep3[60] = _mm_add_epi32(lstep2[50], lstep1[60]); 1327 lstep3[61] = _mm_add_epi32(lstep2[51], lstep1[61]); 1328 lstep3[62] = _mm_add_epi32(lstep2[48], lstep1[62]); 1329 lstep3[63] = _mm_add_epi32(lstep2[49], lstep1[63]); 1330 } 1331 1332 // stage 4 1333 { 1334 // expanding to 32-bit length priori to addition operations 1335 lstep2[16] = _mm_unpacklo_epi16(step2[ 8], kZero); 1336 lstep2[17] = _mm_unpackhi_epi16(step2[ 8], kZero); 1337 lstep2[18] = _mm_unpacklo_epi16(step2[ 9], kZero); 1338 lstep2[19] = _mm_unpackhi_epi16(step2[ 9], kZero); 1339 lstep2[28] = _mm_unpacklo_epi16(step2[14], kZero); 1340 lstep2[29] = _mm_unpackhi_epi16(step2[14], kZero); 1341 lstep2[30] = _mm_unpacklo_epi16(step2[15], kZero); 1342 lstep2[31] = _mm_unpackhi_epi16(step2[15], kZero); 1343 lstep2[16] = _mm_madd_epi16(lstep2[16], kOne); 1344 lstep2[17] = _mm_madd_epi16(lstep2[17], kOne); 1345 lstep2[18] = _mm_madd_epi16(lstep2[18], kOne); 1346 lstep2[19] = _mm_madd_epi16(lstep2[19], kOne); 1347 lstep2[28] = _mm_madd_epi16(lstep2[28], kOne); 1348 lstep2[29] = _mm_madd_epi16(lstep2[29], kOne); 1349 lstep2[30] = _mm_madd_epi16(lstep2[30], kOne); 1350 lstep2[31] = _mm_madd_epi16(lstep2[31], kOne); 1351 1352 lstep1[ 0] = _mm_add_epi32(lstep3[ 6], lstep3[ 0]); 1353 lstep1[ 1] = _mm_add_epi32(lstep3[ 7], lstep3[ 1]); 1354 lstep1[ 2] = _mm_add_epi32(lstep3[ 4], lstep3[ 2]); 1355 lstep1[ 3] = _mm_add_epi32(lstep3[ 5], lstep3[ 3]); 1356 lstep1[ 4] = _mm_sub_epi32(lstep3[ 2], lstep3[ 4]); 1357 lstep1[ 5] = _mm_sub_epi32(lstep3[ 3], lstep3[ 5]); 1358 lstep1[ 6] = _mm_sub_epi32(lstep3[ 0], lstep3[ 6]); 1359 lstep1[ 7] = _mm_sub_epi32(lstep3[ 1], lstep3[ 7]); 1360 lstep1[16] = _mm_add_epi32(lstep3[22], lstep2[16]); 1361 lstep1[17] = _mm_add_epi32(lstep3[23], lstep2[17]); 1362 lstep1[18] = _mm_add_epi32(lstep3[20], lstep2[18]); 1363 lstep1[19] = _mm_add_epi32(lstep3[21], lstep2[19]); 1364 lstep1[20] = _mm_sub_epi32(lstep2[18], lstep3[20]); 1365 lstep1[21] = _mm_sub_epi32(lstep2[19], lstep3[21]); 1366 lstep1[22] = _mm_sub_epi32(lstep2[16], lstep3[22]); 1367 lstep1[23] = _mm_sub_epi32(lstep2[17], lstep3[23]); 1368 lstep1[24] = _mm_sub_epi32(lstep2[30], lstep3[24]); 1369 lstep1[25] = _mm_sub_epi32(lstep2[31], lstep3[25]); 1370 lstep1[26] = _mm_sub_epi32(lstep2[28], lstep3[26]); 1371 lstep1[27] = _mm_sub_epi32(lstep2[29], lstep3[27]); 1372 lstep1[28] = _mm_add_epi32(lstep3[26], lstep2[28]); 1373 lstep1[29] = _mm_add_epi32(lstep3[27], lstep2[29]); 1374 lstep1[30] = _mm_add_epi32(lstep3[24], lstep2[30]); 1375 lstep1[31] = _mm_add_epi32(lstep3[25], lstep2[31]); 1376 } 1377 { 1378 // to be continued... 1379 // 1380 const __m128i k32_p16_p16 = pair_set_epi32(cospi_16_64, cospi_16_64); 1381 const __m128i k32_p16_m16 = pair_set_epi32(cospi_16_64, -cospi_16_64); 1382 1383 u[0] = _mm_unpacklo_epi32(lstep3[12], lstep3[10]); 1384 u[1] = _mm_unpackhi_epi32(lstep3[12], lstep3[10]); 1385 u[2] = _mm_unpacklo_epi32(lstep3[13], lstep3[11]); 1386 u[3] = _mm_unpackhi_epi32(lstep3[13], lstep3[11]); 1387 1388 // TODO(jingning): manually inline k_madd_epi32_ to further hide 1389 // instruction latency. 1390 v[ 0] = k_madd_epi32(u[0], k32_p16_m16); 1391 v[ 1] = k_madd_epi32(u[1], k32_p16_m16); 1392 v[ 2] = k_madd_epi32(u[2], k32_p16_m16); 1393 v[ 3] = k_madd_epi32(u[3], k32_p16_m16); 1394 v[ 4] = k_madd_epi32(u[0], k32_p16_p16); 1395 v[ 5] = k_madd_epi32(u[1], k32_p16_p16); 1396 v[ 6] = k_madd_epi32(u[2], k32_p16_p16); 1397 v[ 7] = k_madd_epi32(u[3], k32_p16_p16); 1398 1399 u[0] = k_packs_epi64(v[0], v[1]); 1400 u[1] = k_packs_epi64(v[2], v[3]); 1401 u[2] = k_packs_epi64(v[4], v[5]); 1402 u[3] = k_packs_epi64(v[6], v[7]); 1403 1404 v[0] = _mm_add_epi32(u[0], k__DCT_CONST_ROUNDING); 1405 v[1] = _mm_add_epi32(u[1], k__DCT_CONST_ROUNDING); 1406 v[2] = _mm_add_epi32(u[2], k__DCT_CONST_ROUNDING); 1407 v[3] = _mm_add_epi32(u[3], k__DCT_CONST_ROUNDING); 1408 1409 lstep1[10] = _mm_srai_epi32(v[0], DCT_CONST_BITS); 1410 lstep1[11] = _mm_srai_epi32(v[1], DCT_CONST_BITS); 1411 lstep1[12] = _mm_srai_epi32(v[2], DCT_CONST_BITS); 1412 lstep1[13] = _mm_srai_epi32(v[3], DCT_CONST_BITS); 1413 } 1414 { 1415 const __m128i k32_m08_p24 = pair_set_epi32(-cospi_8_64, cospi_24_64); 1416 const __m128i k32_m24_m08 = pair_set_epi32(-cospi_24_64, -cospi_8_64); 1417 const __m128i k32_p24_p08 = pair_set_epi32(cospi_24_64, cospi_8_64); 1418 1419 u[ 0] = _mm_unpacklo_epi32(lstep3[36], lstep3[58]); 1420 u[ 1] = _mm_unpackhi_epi32(lstep3[36], lstep3[58]); 1421 u[ 2] = _mm_unpacklo_epi32(lstep3[37], lstep3[59]); 1422 u[ 3] = _mm_unpackhi_epi32(lstep3[37], lstep3[59]); 1423 u[ 4] = _mm_unpacklo_epi32(lstep3[38], lstep3[56]); 1424 u[ 5] = _mm_unpackhi_epi32(lstep3[38], lstep3[56]); 1425 u[ 6] = _mm_unpacklo_epi32(lstep3[39], lstep3[57]); 1426 u[ 7] = _mm_unpackhi_epi32(lstep3[39], lstep3[57]); 1427 u[ 8] = _mm_unpacklo_epi32(lstep3[40], lstep3[54]); 1428 u[ 9] = _mm_unpackhi_epi32(lstep3[40], lstep3[54]); 1429 u[10] = _mm_unpacklo_epi32(lstep3[41], lstep3[55]); 1430 u[11] = _mm_unpackhi_epi32(lstep3[41], lstep3[55]); 1431 u[12] = _mm_unpacklo_epi32(lstep3[42], lstep3[52]); 1432 u[13] = _mm_unpackhi_epi32(lstep3[42], lstep3[52]); 1433 u[14] = _mm_unpacklo_epi32(lstep3[43], lstep3[53]); 1434 u[15] = _mm_unpackhi_epi32(lstep3[43], lstep3[53]); 1435 1436 v[ 0] = k_madd_epi32(u[ 0], k32_m08_p24); 1437 v[ 1] = k_madd_epi32(u[ 1], k32_m08_p24); 1438 v[ 2] = k_madd_epi32(u[ 2], k32_m08_p24); 1439 v[ 3] = k_madd_epi32(u[ 3], k32_m08_p24); 1440 v[ 4] = k_madd_epi32(u[ 4], k32_m08_p24); 1441 v[ 5] = k_madd_epi32(u[ 5], k32_m08_p24); 1442 v[ 6] = k_madd_epi32(u[ 6], k32_m08_p24); 1443 v[ 7] = k_madd_epi32(u[ 7], k32_m08_p24); 1444 v[ 8] = k_madd_epi32(u[ 8], k32_m24_m08); 1445 v[ 9] = k_madd_epi32(u[ 9], k32_m24_m08); 1446 v[10] = k_madd_epi32(u[10], k32_m24_m08); 1447 v[11] = k_madd_epi32(u[11], k32_m24_m08); 1448 v[12] = k_madd_epi32(u[12], k32_m24_m08); 1449 v[13] = k_madd_epi32(u[13], k32_m24_m08); 1450 v[14] = k_madd_epi32(u[14], k32_m24_m08); 1451 v[15] = k_madd_epi32(u[15], k32_m24_m08); 1452 v[16] = k_madd_epi32(u[12], k32_m08_p24); 1453 v[17] = k_madd_epi32(u[13], k32_m08_p24); 1454 v[18] = k_madd_epi32(u[14], k32_m08_p24); 1455 v[19] = k_madd_epi32(u[15], k32_m08_p24); 1456 v[20] = k_madd_epi32(u[ 8], k32_m08_p24); 1457 v[21] = k_madd_epi32(u[ 9], k32_m08_p24); 1458 v[22] = k_madd_epi32(u[10], k32_m08_p24); 1459 v[23] = k_madd_epi32(u[11], k32_m08_p24); 1460 v[24] = k_madd_epi32(u[ 4], k32_p24_p08); 1461 v[25] = k_madd_epi32(u[ 5], k32_p24_p08); 1462 v[26] = k_madd_epi32(u[ 6], k32_p24_p08); 1463 v[27] = k_madd_epi32(u[ 7], k32_p24_p08); 1464 v[28] = k_madd_epi32(u[ 0], k32_p24_p08); 1465 v[29] = k_madd_epi32(u[ 1], k32_p24_p08); 1466 v[30] = k_madd_epi32(u[ 2], k32_p24_p08); 1467 v[31] = k_madd_epi32(u[ 3], k32_p24_p08); 1468 1469 u[ 0] = k_packs_epi64(v[ 0], v[ 1]); 1470 u[ 1] = k_packs_epi64(v[ 2], v[ 3]); 1471 u[ 2] = k_packs_epi64(v[ 4], v[ 5]); 1472 u[ 3] = k_packs_epi64(v[ 6], v[ 7]); 1473 u[ 4] = k_packs_epi64(v[ 8], v[ 9]); 1474 u[ 5] = k_packs_epi64(v[10], v[11]); 1475 u[ 6] = k_packs_epi64(v[12], v[13]); 1476 u[ 7] = k_packs_epi64(v[14], v[15]); 1477 u[ 8] = k_packs_epi64(v[16], v[17]); 1478 u[ 9] = k_packs_epi64(v[18], v[19]); 1479 u[10] = k_packs_epi64(v[20], v[21]); 1480 u[11] = k_packs_epi64(v[22], v[23]); 1481 u[12] = k_packs_epi64(v[24], v[25]); 1482 u[13] = k_packs_epi64(v[26], v[27]); 1483 u[14] = k_packs_epi64(v[28], v[29]); 1484 u[15] = k_packs_epi64(v[30], v[31]); 1485 1486 v[ 0] = _mm_add_epi32(u[ 0], k__DCT_CONST_ROUNDING); 1487 v[ 1] = _mm_add_epi32(u[ 1], k__DCT_CONST_ROUNDING); 1488 v[ 2] = _mm_add_epi32(u[ 2], k__DCT_CONST_ROUNDING); 1489 v[ 3] = _mm_add_epi32(u[ 3], k__DCT_CONST_ROUNDING); 1490 v[ 4] = _mm_add_epi32(u[ 4], k__DCT_CONST_ROUNDING); 1491 v[ 5] = _mm_add_epi32(u[ 5], k__DCT_CONST_ROUNDING); 1492 v[ 6] = _mm_add_epi32(u[ 6], k__DCT_CONST_ROUNDING); 1493 v[ 7] = _mm_add_epi32(u[ 7], k__DCT_CONST_ROUNDING); 1494 v[ 8] = _mm_add_epi32(u[ 8], k__DCT_CONST_ROUNDING); 1495 v[ 9] = _mm_add_epi32(u[ 9], k__DCT_CONST_ROUNDING); 1496 v[10] = _mm_add_epi32(u[10], k__DCT_CONST_ROUNDING); 1497 v[11] = _mm_add_epi32(u[11], k__DCT_CONST_ROUNDING); 1498 v[12] = _mm_add_epi32(u[12], k__DCT_CONST_ROUNDING); 1499 v[13] = _mm_add_epi32(u[13], k__DCT_CONST_ROUNDING); 1500 v[14] = _mm_add_epi32(u[14], k__DCT_CONST_ROUNDING); 1501 v[15] = _mm_add_epi32(u[15], k__DCT_CONST_ROUNDING); 1502 1503 lstep1[36] = _mm_srai_epi32(v[ 0], DCT_CONST_BITS); 1504 lstep1[37] = _mm_srai_epi32(v[ 1], DCT_CONST_BITS); 1505 lstep1[38] = _mm_srai_epi32(v[ 2], DCT_CONST_BITS); 1506 lstep1[39] = _mm_srai_epi32(v[ 3], DCT_CONST_BITS); 1507 lstep1[40] = _mm_srai_epi32(v[ 4], DCT_CONST_BITS); 1508 lstep1[41] = _mm_srai_epi32(v[ 5], DCT_CONST_BITS); 1509 lstep1[42] = _mm_srai_epi32(v[ 6], DCT_CONST_BITS); 1510 lstep1[43] = _mm_srai_epi32(v[ 7], DCT_CONST_BITS); 1511 lstep1[52] = _mm_srai_epi32(v[ 8], DCT_CONST_BITS); 1512 lstep1[53] = _mm_srai_epi32(v[ 9], DCT_CONST_BITS); 1513 lstep1[54] = _mm_srai_epi32(v[10], DCT_CONST_BITS); 1514 lstep1[55] = _mm_srai_epi32(v[11], DCT_CONST_BITS); 1515 lstep1[56] = _mm_srai_epi32(v[12], DCT_CONST_BITS); 1516 lstep1[57] = _mm_srai_epi32(v[13], DCT_CONST_BITS); 1517 lstep1[58] = _mm_srai_epi32(v[14], DCT_CONST_BITS); 1518 lstep1[59] = _mm_srai_epi32(v[15], DCT_CONST_BITS); 1519 } 1520 // stage 5 1521 { 1522 lstep2[ 8] = _mm_add_epi32(lstep1[10], lstep3[ 8]); 1523 lstep2[ 9] = _mm_add_epi32(lstep1[11], lstep3[ 9]); 1524 lstep2[10] = _mm_sub_epi32(lstep3[ 8], lstep1[10]); 1525 lstep2[11] = _mm_sub_epi32(lstep3[ 9], lstep1[11]); 1526 lstep2[12] = _mm_sub_epi32(lstep3[14], lstep1[12]); 1527 lstep2[13] = _mm_sub_epi32(lstep3[15], lstep1[13]); 1528 lstep2[14] = _mm_add_epi32(lstep1[12], lstep3[14]); 1529 lstep2[15] = _mm_add_epi32(lstep1[13], lstep3[15]); 1530 } 1531 { 1532 const __m128i k32_p16_p16 = pair_set_epi32(cospi_16_64, cospi_16_64); 1533 const __m128i k32_p16_m16 = pair_set_epi32(cospi_16_64, -cospi_16_64); 1534 const __m128i k32_p24_p08 = pair_set_epi32(cospi_24_64, cospi_8_64); 1535 const __m128i k32_m08_p24 = pair_set_epi32(-cospi_8_64, cospi_24_64); 1536 1537 u[0] = _mm_unpacklo_epi32(lstep1[0], lstep1[2]); 1538 u[1] = _mm_unpackhi_epi32(lstep1[0], lstep1[2]); 1539 u[2] = _mm_unpacklo_epi32(lstep1[1], lstep1[3]); 1540 u[3] = _mm_unpackhi_epi32(lstep1[1], lstep1[3]); 1541 u[4] = _mm_unpacklo_epi32(lstep1[4], lstep1[6]); 1542 u[5] = _mm_unpackhi_epi32(lstep1[4], lstep1[6]); 1543 u[6] = _mm_unpacklo_epi32(lstep1[5], lstep1[7]); 1544 u[7] = _mm_unpackhi_epi32(lstep1[5], lstep1[7]); 1545 1546 // TODO(jingning): manually inline k_madd_epi32_ to further hide 1547 // instruction latency. 1548 v[ 0] = k_madd_epi32(u[0], k32_p16_p16); 1549 v[ 1] = k_madd_epi32(u[1], k32_p16_p16); 1550 v[ 2] = k_madd_epi32(u[2], k32_p16_p16); 1551 v[ 3] = k_madd_epi32(u[3], k32_p16_p16); 1552 v[ 4] = k_madd_epi32(u[0], k32_p16_m16); 1553 v[ 5] = k_madd_epi32(u[1], k32_p16_m16); 1554 v[ 6] = k_madd_epi32(u[2], k32_p16_m16); 1555 v[ 7] = k_madd_epi32(u[3], k32_p16_m16); 1556 v[ 8] = k_madd_epi32(u[4], k32_p24_p08); 1557 v[ 9] = k_madd_epi32(u[5], k32_p24_p08); 1558 v[10] = k_madd_epi32(u[6], k32_p24_p08); 1559 v[11] = k_madd_epi32(u[7], k32_p24_p08); 1560 v[12] = k_madd_epi32(u[4], k32_m08_p24); 1561 v[13] = k_madd_epi32(u[5], k32_m08_p24); 1562 v[14] = k_madd_epi32(u[6], k32_m08_p24); 1563 v[15] = k_madd_epi32(u[7], k32_m08_p24); 1564 1565 u[0] = k_packs_epi64(v[0], v[1]); 1566 u[1] = k_packs_epi64(v[2], v[3]); 1567 u[2] = k_packs_epi64(v[4], v[5]); 1568 u[3] = k_packs_epi64(v[6], v[7]); 1569 u[4] = k_packs_epi64(v[8], v[9]); 1570 u[5] = k_packs_epi64(v[10], v[11]); 1571 u[6] = k_packs_epi64(v[12], v[13]); 1572 u[7] = k_packs_epi64(v[14], v[15]); 1573 1574 v[0] = _mm_add_epi32(u[0], k__DCT_CONST_ROUNDING); 1575 v[1] = _mm_add_epi32(u[1], k__DCT_CONST_ROUNDING); 1576 v[2] = _mm_add_epi32(u[2], k__DCT_CONST_ROUNDING); 1577 v[3] = _mm_add_epi32(u[3], k__DCT_CONST_ROUNDING); 1578 v[4] = _mm_add_epi32(u[4], k__DCT_CONST_ROUNDING); 1579 v[5] = _mm_add_epi32(u[5], k__DCT_CONST_ROUNDING); 1580 v[6] = _mm_add_epi32(u[6], k__DCT_CONST_ROUNDING); 1581 v[7] = _mm_add_epi32(u[7], k__DCT_CONST_ROUNDING); 1582 1583 u[0] = _mm_srai_epi32(v[0], DCT_CONST_BITS); 1584 u[1] = _mm_srai_epi32(v[1], DCT_CONST_BITS); 1585 u[2] = _mm_srai_epi32(v[2], DCT_CONST_BITS); 1586 u[3] = _mm_srai_epi32(v[3], DCT_CONST_BITS); 1587 u[4] = _mm_srai_epi32(v[4], DCT_CONST_BITS); 1588 u[5] = _mm_srai_epi32(v[5], DCT_CONST_BITS); 1589 u[6] = _mm_srai_epi32(v[6], DCT_CONST_BITS); 1590 u[7] = _mm_srai_epi32(v[7], DCT_CONST_BITS); 1591 1592 sign[0] = _mm_cmplt_epi32(u[0], kZero); 1593 sign[1] = _mm_cmplt_epi32(u[1], kZero); 1594 sign[2] = _mm_cmplt_epi32(u[2], kZero); 1595 sign[3] = _mm_cmplt_epi32(u[3], kZero); 1596 sign[4] = _mm_cmplt_epi32(u[4], kZero); 1597 sign[5] = _mm_cmplt_epi32(u[5], kZero); 1598 sign[6] = _mm_cmplt_epi32(u[6], kZero); 1599 sign[7] = _mm_cmplt_epi32(u[7], kZero); 1600 1601 u[0] = _mm_sub_epi32(u[0], sign[0]); 1602 u[1] = _mm_sub_epi32(u[1], sign[1]); 1603 u[2] = _mm_sub_epi32(u[2], sign[2]); 1604 u[3] = _mm_sub_epi32(u[3], sign[3]); 1605 u[4] = _mm_sub_epi32(u[4], sign[4]); 1606 u[5] = _mm_sub_epi32(u[5], sign[5]); 1607 u[6] = _mm_sub_epi32(u[6], sign[6]); 1608 u[7] = _mm_sub_epi32(u[7], sign[7]); 1609 1610 u[0] = _mm_add_epi32(u[0], K32One); 1611 u[1] = _mm_add_epi32(u[1], K32One); 1612 u[2] = _mm_add_epi32(u[2], K32One); 1613 u[3] = _mm_add_epi32(u[3], K32One); 1614 u[4] = _mm_add_epi32(u[4], K32One); 1615 u[5] = _mm_add_epi32(u[5], K32One); 1616 u[6] = _mm_add_epi32(u[6], K32One); 1617 u[7] = _mm_add_epi32(u[7], K32One); 1618 1619 u[0] = _mm_srai_epi32(u[0], 2); 1620 u[1] = _mm_srai_epi32(u[1], 2); 1621 u[2] = _mm_srai_epi32(u[2], 2); 1622 u[3] = _mm_srai_epi32(u[3], 2); 1623 u[4] = _mm_srai_epi32(u[4], 2); 1624 u[5] = _mm_srai_epi32(u[5], 2); 1625 u[6] = _mm_srai_epi32(u[6], 2); 1626 u[7] = _mm_srai_epi32(u[7], 2); 1627 1628 // Combine 1629 out[ 0] = _mm_packs_epi32(u[0], u[1]); 1630 out[16] = _mm_packs_epi32(u[2], u[3]); 1631 out[ 8] = _mm_packs_epi32(u[4], u[5]); 1632 out[24] = _mm_packs_epi32(u[6], u[7]); 1633 } 1634 { 1635 const __m128i k32_m08_p24 = pair_set_epi32(-cospi_8_64, cospi_24_64); 1636 const __m128i k32_m24_m08 = pair_set_epi32(-cospi_24_64, -cospi_8_64); 1637 const __m128i k32_p24_p08 = pair_set_epi32(cospi_24_64, cospi_8_64); 1638 1639 u[0] = _mm_unpacklo_epi32(lstep1[18], lstep1[28]); 1640 u[1] = _mm_unpackhi_epi32(lstep1[18], lstep1[28]); 1641 u[2] = _mm_unpacklo_epi32(lstep1[19], lstep1[29]); 1642 u[3] = _mm_unpackhi_epi32(lstep1[19], lstep1[29]); 1643 u[4] = _mm_unpacklo_epi32(lstep1[20], lstep1[26]); 1644 u[5] = _mm_unpackhi_epi32(lstep1[20], lstep1[26]); 1645 u[6] = _mm_unpacklo_epi32(lstep1[21], lstep1[27]); 1646 u[7] = _mm_unpackhi_epi32(lstep1[21], lstep1[27]); 1647 1648 v[0] = k_madd_epi32(u[0], k32_m08_p24); 1649 v[1] = k_madd_epi32(u[1], k32_m08_p24); 1650 v[2] = k_madd_epi32(u[2], k32_m08_p24); 1651 v[3] = k_madd_epi32(u[3], k32_m08_p24); 1652 v[4] = k_madd_epi32(u[4], k32_m24_m08); 1653 v[5] = k_madd_epi32(u[5], k32_m24_m08); 1654 v[6] = k_madd_epi32(u[6], k32_m24_m08); 1655 v[7] = k_madd_epi32(u[7], k32_m24_m08); 1656 v[ 8] = k_madd_epi32(u[4], k32_m08_p24); 1657 v[ 9] = k_madd_epi32(u[5], k32_m08_p24); 1658 v[10] = k_madd_epi32(u[6], k32_m08_p24); 1659 v[11] = k_madd_epi32(u[7], k32_m08_p24); 1660 v[12] = k_madd_epi32(u[0], k32_p24_p08); 1661 v[13] = k_madd_epi32(u[1], k32_p24_p08); 1662 v[14] = k_madd_epi32(u[2], k32_p24_p08); 1663 v[15] = k_madd_epi32(u[3], k32_p24_p08); 1664 1665 u[0] = k_packs_epi64(v[0], v[1]); 1666 u[1] = k_packs_epi64(v[2], v[3]); 1667 u[2] = k_packs_epi64(v[4], v[5]); 1668 u[3] = k_packs_epi64(v[6], v[7]); 1669 u[4] = k_packs_epi64(v[8], v[9]); 1670 u[5] = k_packs_epi64(v[10], v[11]); 1671 u[6] = k_packs_epi64(v[12], v[13]); 1672 u[7] = k_packs_epi64(v[14], v[15]); 1673 1674 u[0] = _mm_add_epi32(u[0], k__DCT_CONST_ROUNDING); 1675 u[1] = _mm_add_epi32(u[1], k__DCT_CONST_ROUNDING); 1676 u[2] = _mm_add_epi32(u[2], k__DCT_CONST_ROUNDING); 1677 u[3] = _mm_add_epi32(u[3], k__DCT_CONST_ROUNDING); 1678 u[4] = _mm_add_epi32(u[4], k__DCT_CONST_ROUNDING); 1679 u[5] = _mm_add_epi32(u[5], k__DCT_CONST_ROUNDING); 1680 u[6] = _mm_add_epi32(u[6], k__DCT_CONST_ROUNDING); 1681 u[7] = _mm_add_epi32(u[7], k__DCT_CONST_ROUNDING); 1682 1683 lstep2[18] = _mm_srai_epi32(u[0], DCT_CONST_BITS); 1684 lstep2[19] = _mm_srai_epi32(u[1], DCT_CONST_BITS); 1685 lstep2[20] = _mm_srai_epi32(u[2], DCT_CONST_BITS); 1686 lstep2[21] = _mm_srai_epi32(u[3], DCT_CONST_BITS); 1687 lstep2[26] = _mm_srai_epi32(u[4], DCT_CONST_BITS); 1688 lstep2[27] = _mm_srai_epi32(u[5], DCT_CONST_BITS); 1689 lstep2[28] = _mm_srai_epi32(u[6], DCT_CONST_BITS); 1690 lstep2[29] = _mm_srai_epi32(u[7], DCT_CONST_BITS); 1691 } 1692 { 1693 lstep2[32] = _mm_add_epi32(lstep1[38], lstep3[32]); 1694 lstep2[33] = _mm_add_epi32(lstep1[39], lstep3[33]); 1695 lstep2[34] = _mm_add_epi32(lstep1[36], lstep3[34]); 1696 lstep2[35] = _mm_add_epi32(lstep1[37], lstep3[35]); 1697 lstep2[36] = _mm_sub_epi32(lstep3[34], lstep1[36]); 1698 lstep2[37] = _mm_sub_epi32(lstep3[35], lstep1[37]); 1699 lstep2[38] = _mm_sub_epi32(lstep3[32], lstep1[38]); 1700 lstep2[39] = _mm_sub_epi32(lstep3[33], lstep1[39]); 1701 lstep2[40] = _mm_sub_epi32(lstep3[46], lstep1[40]); 1702 lstep2[41] = _mm_sub_epi32(lstep3[47], lstep1[41]); 1703 lstep2[42] = _mm_sub_epi32(lstep3[44], lstep1[42]); 1704 lstep2[43] = _mm_sub_epi32(lstep3[45], lstep1[43]); 1705 lstep2[44] = _mm_add_epi32(lstep1[42], lstep3[44]); 1706 lstep2[45] = _mm_add_epi32(lstep1[43], lstep3[45]); 1707 lstep2[46] = _mm_add_epi32(lstep1[40], lstep3[46]); 1708 lstep2[47] = _mm_add_epi32(lstep1[41], lstep3[47]); 1709 lstep2[48] = _mm_add_epi32(lstep1[54], lstep3[48]); 1710 lstep2[49] = _mm_add_epi32(lstep1[55], lstep3[49]); 1711 lstep2[50] = _mm_add_epi32(lstep1[52], lstep3[50]); 1712 lstep2[51] = _mm_add_epi32(lstep1[53], lstep3[51]); 1713 lstep2[52] = _mm_sub_epi32(lstep3[50], lstep1[52]); 1714 lstep2[53] = _mm_sub_epi32(lstep3[51], lstep1[53]); 1715 lstep2[54] = _mm_sub_epi32(lstep3[48], lstep1[54]); 1716 lstep2[55] = _mm_sub_epi32(lstep3[49], lstep1[55]); 1717 lstep2[56] = _mm_sub_epi32(lstep3[62], lstep1[56]); 1718 lstep2[57] = _mm_sub_epi32(lstep3[63], lstep1[57]); 1719 lstep2[58] = _mm_sub_epi32(lstep3[60], lstep1[58]); 1720 lstep2[59] = _mm_sub_epi32(lstep3[61], lstep1[59]); 1721 lstep2[60] = _mm_add_epi32(lstep1[58], lstep3[60]); 1722 lstep2[61] = _mm_add_epi32(lstep1[59], lstep3[61]); 1723 lstep2[62] = _mm_add_epi32(lstep1[56], lstep3[62]); 1724 lstep2[63] = _mm_add_epi32(lstep1[57], lstep3[63]); 1725 } 1726 // stage 6 1727 { 1728 const __m128i k32_p28_p04 = pair_set_epi32(cospi_28_64, cospi_4_64); 1729 const __m128i k32_p12_p20 = pair_set_epi32(cospi_12_64, cospi_20_64); 1730 const __m128i k32_m20_p12 = pair_set_epi32(-cospi_20_64, cospi_12_64); 1731 const __m128i k32_m04_p28 = pair_set_epi32(-cospi_4_64, cospi_28_64); 1732 1733 u[0] = _mm_unpacklo_epi32(lstep2[ 8], lstep2[14]); 1734 u[1] = _mm_unpackhi_epi32(lstep2[ 8], lstep2[14]); 1735 u[2] = _mm_unpacklo_epi32(lstep2[ 9], lstep2[15]); 1736 u[3] = _mm_unpackhi_epi32(lstep2[ 9], lstep2[15]); 1737 u[4] = _mm_unpacklo_epi32(lstep2[10], lstep2[12]); 1738 u[5] = _mm_unpackhi_epi32(lstep2[10], lstep2[12]); 1739 u[6] = _mm_unpacklo_epi32(lstep2[11], lstep2[13]); 1740 u[7] = _mm_unpackhi_epi32(lstep2[11], lstep2[13]); 1741 u[8] = _mm_unpacklo_epi32(lstep2[10], lstep2[12]); 1742 u[9] = _mm_unpackhi_epi32(lstep2[10], lstep2[12]); 1743 u[10] = _mm_unpacklo_epi32(lstep2[11], lstep2[13]); 1744 u[11] = _mm_unpackhi_epi32(lstep2[11], lstep2[13]); 1745 u[12] = _mm_unpacklo_epi32(lstep2[ 8], lstep2[14]); 1746 u[13] = _mm_unpackhi_epi32(lstep2[ 8], lstep2[14]); 1747 u[14] = _mm_unpacklo_epi32(lstep2[ 9], lstep2[15]); 1748 u[15] = _mm_unpackhi_epi32(lstep2[ 9], lstep2[15]); 1749 1750 v[0] = k_madd_epi32(u[0], k32_p28_p04); 1751 v[1] = k_madd_epi32(u[1], k32_p28_p04); 1752 v[2] = k_madd_epi32(u[2], k32_p28_p04); 1753 v[3] = k_madd_epi32(u[3], k32_p28_p04); 1754 v[4] = k_madd_epi32(u[4], k32_p12_p20); 1755 v[5] = k_madd_epi32(u[5], k32_p12_p20); 1756 v[6] = k_madd_epi32(u[6], k32_p12_p20); 1757 v[7] = k_madd_epi32(u[7], k32_p12_p20); 1758 v[ 8] = k_madd_epi32(u[ 8], k32_m20_p12); 1759 v[ 9] = k_madd_epi32(u[ 9], k32_m20_p12); 1760 v[10] = k_madd_epi32(u[10], k32_m20_p12); 1761 v[11] = k_madd_epi32(u[11], k32_m20_p12); 1762 v[12] = k_madd_epi32(u[12], k32_m04_p28); 1763 v[13] = k_madd_epi32(u[13], k32_m04_p28); 1764 v[14] = k_madd_epi32(u[14], k32_m04_p28); 1765 v[15] = k_madd_epi32(u[15], k32_m04_p28); 1766 1767 u[0] = k_packs_epi64(v[0], v[1]); 1768 u[1] = k_packs_epi64(v[2], v[3]); 1769 u[2] = k_packs_epi64(v[4], v[5]); 1770 u[3] = k_packs_epi64(v[6], v[7]); 1771 u[4] = k_packs_epi64(v[8], v[9]); 1772 u[5] = k_packs_epi64(v[10], v[11]); 1773 u[6] = k_packs_epi64(v[12], v[13]); 1774 u[7] = k_packs_epi64(v[14], v[15]); 1775 1776 v[0] = _mm_add_epi32(u[0], k__DCT_CONST_ROUNDING); 1777 v[1] = _mm_add_epi32(u[1], k__DCT_CONST_ROUNDING); 1778 v[2] = _mm_add_epi32(u[2], k__DCT_CONST_ROUNDING); 1779 v[3] = _mm_add_epi32(u[3], k__DCT_CONST_ROUNDING); 1780 v[4] = _mm_add_epi32(u[4], k__DCT_CONST_ROUNDING); 1781 v[5] = _mm_add_epi32(u[5], k__DCT_CONST_ROUNDING); 1782 v[6] = _mm_add_epi32(u[6], k__DCT_CONST_ROUNDING); 1783 v[7] = _mm_add_epi32(u[7], k__DCT_CONST_ROUNDING); 1784 1785 u[0] = _mm_srai_epi32(v[0], DCT_CONST_BITS); 1786 u[1] = _mm_srai_epi32(v[1], DCT_CONST_BITS); 1787 u[2] = _mm_srai_epi32(v[2], DCT_CONST_BITS); 1788 u[3] = _mm_srai_epi32(v[3], DCT_CONST_BITS); 1789 u[4] = _mm_srai_epi32(v[4], DCT_CONST_BITS); 1790 u[5] = _mm_srai_epi32(v[5], DCT_CONST_BITS); 1791 u[6] = _mm_srai_epi32(v[6], DCT_CONST_BITS); 1792 u[7] = _mm_srai_epi32(v[7], DCT_CONST_BITS); 1793 1794 sign[0] = _mm_cmplt_epi32(u[0], kZero); 1795 sign[1] = _mm_cmplt_epi32(u[1], kZero); 1796 sign[2] = _mm_cmplt_epi32(u[2], kZero); 1797 sign[3] = _mm_cmplt_epi32(u[3], kZero); 1798 sign[4] = _mm_cmplt_epi32(u[4], kZero); 1799 sign[5] = _mm_cmplt_epi32(u[5], kZero); 1800 sign[6] = _mm_cmplt_epi32(u[6], kZero); 1801 sign[7] = _mm_cmplt_epi32(u[7], kZero); 1802 1803 u[0] = _mm_sub_epi32(u[0], sign[0]); 1804 u[1] = _mm_sub_epi32(u[1], sign[1]); 1805 u[2] = _mm_sub_epi32(u[2], sign[2]); 1806 u[3] = _mm_sub_epi32(u[3], sign[3]); 1807 u[4] = _mm_sub_epi32(u[4], sign[4]); 1808 u[5] = _mm_sub_epi32(u[5], sign[5]); 1809 u[6] = _mm_sub_epi32(u[6], sign[6]); 1810 u[7] = _mm_sub_epi32(u[7], sign[7]); 1811 1812 u[0] = _mm_add_epi32(u[0], K32One); 1813 u[1] = _mm_add_epi32(u[1], K32One); 1814 u[2] = _mm_add_epi32(u[2], K32One); 1815 u[3] = _mm_add_epi32(u[3], K32One); 1816 u[4] = _mm_add_epi32(u[4], K32One); 1817 u[5] = _mm_add_epi32(u[5], K32One); 1818 u[6] = _mm_add_epi32(u[6], K32One); 1819 u[7] = _mm_add_epi32(u[7], K32One); 1820 1821 u[0] = _mm_srai_epi32(u[0], 2); 1822 u[1] = _mm_srai_epi32(u[1], 2); 1823 u[2] = _mm_srai_epi32(u[2], 2); 1824 u[3] = _mm_srai_epi32(u[3], 2); 1825 u[4] = _mm_srai_epi32(u[4], 2); 1826 u[5] = _mm_srai_epi32(u[5], 2); 1827 u[6] = _mm_srai_epi32(u[6], 2); 1828 u[7] = _mm_srai_epi32(u[7], 2); 1829 1830 out[ 4] = _mm_packs_epi32(u[0], u[1]); 1831 out[20] = _mm_packs_epi32(u[2], u[3]); 1832 out[12] = _mm_packs_epi32(u[4], u[5]); 1833 out[28] = _mm_packs_epi32(u[6], u[7]); 1834 } 1835 { 1836 lstep3[16] = _mm_add_epi32(lstep2[18], lstep1[16]); 1837 lstep3[17] = _mm_add_epi32(lstep2[19], lstep1[17]); 1838 lstep3[18] = _mm_sub_epi32(lstep1[16], lstep2[18]); 1839 lstep3[19] = _mm_sub_epi32(lstep1[17], lstep2[19]); 1840 lstep3[20] = _mm_sub_epi32(lstep1[22], lstep2[20]); 1841 lstep3[21] = _mm_sub_epi32(lstep1[23], lstep2[21]); 1842 lstep3[22] = _mm_add_epi32(lstep2[20], lstep1[22]); 1843 lstep3[23] = _mm_add_epi32(lstep2[21], lstep1[23]); 1844 lstep3[24] = _mm_add_epi32(lstep2[26], lstep1[24]); 1845 lstep3[25] = _mm_add_epi32(lstep2[27], lstep1[25]); 1846 lstep3[26] = _mm_sub_epi32(lstep1[24], lstep2[26]); 1847 lstep3[27] = _mm_sub_epi32(lstep1[25], lstep2[27]); 1848 lstep3[28] = _mm_sub_epi32(lstep1[30], lstep2[28]); 1849 lstep3[29] = _mm_sub_epi32(lstep1[31], lstep2[29]); 1850 lstep3[30] = _mm_add_epi32(lstep2[28], lstep1[30]); 1851 lstep3[31] = _mm_add_epi32(lstep2[29], lstep1[31]); 1852 } 1853 { 1854 const __m128i k32_m04_p28 = pair_set_epi32(-cospi_4_64, cospi_28_64); 1855 const __m128i k32_m28_m04 = pair_set_epi32(-cospi_28_64, -cospi_4_64); 1856 const __m128i k32_m20_p12 = pair_set_epi32(-cospi_20_64, cospi_12_64); 1857 const __m128i k32_m12_m20 = pair_set_epi32(-cospi_12_64, 1858 -cospi_20_64); 1859 const __m128i k32_p12_p20 = pair_set_epi32(cospi_12_64, cospi_20_64); 1860 const __m128i k32_p28_p04 = pair_set_epi32(cospi_28_64, cospi_4_64); 1861 1862 u[ 0] = _mm_unpacklo_epi32(lstep2[34], lstep2[60]); 1863 u[ 1] = _mm_unpackhi_epi32(lstep2[34], lstep2[60]); 1864 u[ 2] = _mm_unpacklo_epi32(lstep2[35], lstep2[61]); 1865 u[ 3] = _mm_unpackhi_epi32(lstep2[35], lstep2[61]); 1866 u[ 4] = _mm_unpacklo_epi32(lstep2[36], lstep2[58]); 1867 u[ 5] = _mm_unpackhi_epi32(lstep2[36], lstep2[58]); 1868 u[ 6] = _mm_unpacklo_epi32(lstep2[37], lstep2[59]); 1869 u[ 7] = _mm_unpackhi_epi32(lstep2[37], lstep2[59]); 1870 u[ 8] = _mm_unpacklo_epi32(lstep2[42], lstep2[52]); 1871 u[ 9] = _mm_unpackhi_epi32(lstep2[42], lstep2[52]); 1872 u[10] = _mm_unpacklo_epi32(lstep2[43], lstep2[53]); 1873 u[11] = _mm_unpackhi_epi32(lstep2[43], lstep2[53]); 1874 u[12] = _mm_unpacklo_epi32(lstep2[44], lstep2[50]); 1875 u[13] = _mm_unpackhi_epi32(lstep2[44], lstep2[50]); 1876 u[14] = _mm_unpacklo_epi32(lstep2[45], lstep2[51]); 1877 u[15] = _mm_unpackhi_epi32(lstep2[45], lstep2[51]); 1878 1879 v[ 0] = k_madd_epi32(u[ 0], k32_m04_p28); 1880 v[ 1] = k_madd_epi32(u[ 1], k32_m04_p28); 1881 v[ 2] = k_madd_epi32(u[ 2], k32_m04_p28); 1882 v[ 3] = k_madd_epi32(u[ 3], k32_m04_p28); 1883 v[ 4] = k_madd_epi32(u[ 4], k32_m28_m04); 1884 v[ 5] = k_madd_epi32(u[ 5], k32_m28_m04); 1885 v[ 6] = k_madd_epi32(u[ 6], k32_m28_m04); 1886 v[ 7] = k_madd_epi32(u[ 7], k32_m28_m04); 1887 v[ 8] = k_madd_epi32(u[ 8], k32_m20_p12); 1888 v[ 9] = k_madd_epi32(u[ 9], k32_m20_p12); 1889 v[10] = k_madd_epi32(u[10], k32_m20_p12); 1890 v[11] = k_madd_epi32(u[11], k32_m20_p12); 1891 v[12] = k_madd_epi32(u[12], k32_m12_m20); 1892 v[13] = k_madd_epi32(u[13], k32_m12_m20); 1893 v[14] = k_madd_epi32(u[14], k32_m12_m20); 1894 v[15] = k_madd_epi32(u[15], k32_m12_m20); 1895 v[16] = k_madd_epi32(u[12], k32_m20_p12); 1896 v[17] = k_madd_epi32(u[13], k32_m20_p12); 1897 v[18] = k_madd_epi32(u[14], k32_m20_p12); 1898 v[19] = k_madd_epi32(u[15], k32_m20_p12); 1899 v[20] = k_madd_epi32(u[ 8], k32_p12_p20); 1900 v[21] = k_madd_epi32(u[ 9], k32_p12_p20); 1901 v[22] = k_madd_epi32(u[10], k32_p12_p20); 1902 v[23] = k_madd_epi32(u[11], k32_p12_p20); 1903 v[24] = k_madd_epi32(u[ 4], k32_m04_p28); 1904 v[25] = k_madd_epi32(u[ 5], k32_m04_p28); 1905 v[26] = k_madd_epi32(u[ 6], k32_m04_p28); 1906 v[27] = k_madd_epi32(u[ 7], k32_m04_p28); 1907 v[28] = k_madd_epi32(u[ 0], k32_p28_p04); 1908 v[29] = k_madd_epi32(u[ 1], k32_p28_p04); 1909 v[30] = k_madd_epi32(u[ 2], k32_p28_p04); 1910 v[31] = k_madd_epi32(u[ 3], k32_p28_p04); 1911 1912 u[ 0] = k_packs_epi64(v[ 0], v[ 1]); 1913 u[ 1] = k_packs_epi64(v[ 2], v[ 3]); 1914 u[ 2] = k_packs_epi64(v[ 4], v[ 5]); 1915 u[ 3] = k_packs_epi64(v[ 6], v[ 7]); 1916 u[ 4] = k_packs_epi64(v[ 8], v[ 9]); 1917 u[ 5] = k_packs_epi64(v[10], v[11]); 1918 u[ 6] = k_packs_epi64(v[12], v[13]); 1919 u[ 7] = k_packs_epi64(v[14], v[15]); 1920 u[ 8] = k_packs_epi64(v[16], v[17]); 1921 u[ 9] = k_packs_epi64(v[18], v[19]); 1922 u[10] = k_packs_epi64(v[20], v[21]); 1923 u[11] = k_packs_epi64(v[22], v[23]); 1924 u[12] = k_packs_epi64(v[24], v[25]); 1925 u[13] = k_packs_epi64(v[26], v[27]); 1926 u[14] = k_packs_epi64(v[28], v[29]); 1927 u[15] = k_packs_epi64(v[30], v[31]); 1928 1929 v[ 0] = _mm_add_epi32(u[ 0], k__DCT_CONST_ROUNDING); 1930 v[ 1] = _mm_add_epi32(u[ 1], k__DCT_CONST_ROUNDING); 1931 v[ 2] = _mm_add_epi32(u[ 2], k__DCT_CONST_ROUNDING); 1932 v[ 3] = _mm_add_epi32(u[ 3], k__DCT_CONST_ROUNDING); 1933 v[ 4] = _mm_add_epi32(u[ 4], k__DCT_CONST_ROUNDING); 1934 v[ 5] = _mm_add_epi32(u[ 5], k__DCT_CONST_ROUNDING); 1935 v[ 6] = _mm_add_epi32(u[ 6], k__DCT_CONST_ROUNDING); 1936 v[ 7] = _mm_add_epi32(u[ 7], k__DCT_CONST_ROUNDING); 1937 v[ 8] = _mm_add_epi32(u[ 8], k__DCT_CONST_ROUNDING); 1938 v[ 9] = _mm_add_epi32(u[ 9], k__DCT_CONST_ROUNDING); 1939 v[10] = _mm_add_epi32(u[10], k__DCT_CONST_ROUNDING); 1940 v[11] = _mm_add_epi32(u[11], k__DCT_CONST_ROUNDING); 1941 v[12] = _mm_add_epi32(u[12], k__DCT_CONST_ROUNDING); 1942 v[13] = _mm_add_epi32(u[13], k__DCT_CONST_ROUNDING); 1943 v[14] = _mm_add_epi32(u[14], k__DCT_CONST_ROUNDING); 1944 v[15] = _mm_add_epi32(u[15], k__DCT_CONST_ROUNDING); 1945 1946 lstep3[34] = _mm_srai_epi32(v[ 0], DCT_CONST_BITS); 1947 lstep3[35] = _mm_srai_epi32(v[ 1], DCT_CONST_BITS); 1948 lstep3[36] = _mm_srai_epi32(v[ 2], DCT_CONST_BITS); 1949 lstep3[37] = _mm_srai_epi32(v[ 3], DCT_CONST_BITS); 1950 lstep3[42] = _mm_srai_epi32(v[ 4], DCT_CONST_BITS); 1951 lstep3[43] = _mm_srai_epi32(v[ 5], DCT_CONST_BITS); 1952 lstep3[44] = _mm_srai_epi32(v[ 6], DCT_CONST_BITS); 1953 lstep3[45] = _mm_srai_epi32(v[ 7], DCT_CONST_BITS); 1954 lstep3[50] = _mm_srai_epi32(v[ 8], DCT_CONST_BITS); 1955 lstep3[51] = _mm_srai_epi32(v[ 9], DCT_CONST_BITS); 1956 lstep3[52] = _mm_srai_epi32(v[10], DCT_CONST_BITS); 1957 lstep3[53] = _mm_srai_epi32(v[11], DCT_CONST_BITS); 1958 lstep3[58] = _mm_srai_epi32(v[12], DCT_CONST_BITS); 1959 lstep3[59] = _mm_srai_epi32(v[13], DCT_CONST_BITS); 1960 lstep3[60] = _mm_srai_epi32(v[14], DCT_CONST_BITS); 1961 lstep3[61] = _mm_srai_epi32(v[15], DCT_CONST_BITS); 1962 } 1963 // stage 7 1964 { 1965 const __m128i k32_p30_p02 = pair_set_epi32(cospi_30_64, cospi_2_64); 1966 const __m128i k32_p14_p18 = pair_set_epi32(cospi_14_64, cospi_18_64); 1967 const __m128i k32_p22_p10 = pair_set_epi32(cospi_22_64, cospi_10_64); 1968 const __m128i k32_p06_p26 = pair_set_epi32(cospi_6_64, cospi_26_64); 1969 const __m128i k32_m26_p06 = pair_set_epi32(-cospi_26_64, cospi_6_64); 1970 const __m128i k32_m10_p22 = pair_set_epi32(-cospi_10_64, cospi_22_64); 1971 const __m128i k32_m18_p14 = pair_set_epi32(-cospi_18_64, cospi_14_64); 1972 const __m128i k32_m02_p30 = pair_set_epi32(-cospi_2_64, cospi_30_64); 1973 1974 u[ 0] = _mm_unpacklo_epi32(lstep3[16], lstep3[30]); 1975 u[ 1] = _mm_unpackhi_epi32(lstep3[16], lstep3[30]); 1976 u[ 2] = _mm_unpacklo_epi32(lstep3[17], lstep3[31]); 1977 u[ 3] = _mm_unpackhi_epi32(lstep3[17], lstep3[31]); 1978 u[ 4] = _mm_unpacklo_epi32(lstep3[18], lstep3[28]); 1979 u[ 5] = _mm_unpackhi_epi32(lstep3[18], lstep3[28]); 1980 u[ 6] = _mm_unpacklo_epi32(lstep3[19], lstep3[29]); 1981 u[ 7] = _mm_unpackhi_epi32(lstep3[19], lstep3[29]); 1982 u[ 8] = _mm_unpacklo_epi32(lstep3[20], lstep3[26]); 1983 u[ 9] = _mm_unpackhi_epi32(lstep3[20], lstep3[26]); 1984 u[10] = _mm_unpacklo_epi32(lstep3[21], lstep3[27]); 1985 u[11] = _mm_unpackhi_epi32(lstep3[21], lstep3[27]); 1986 u[12] = _mm_unpacklo_epi32(lstep3[22], lstep3[24]); 1987 u[13] = _mm_unpackhi_epi32(lstep3[22], lstep3[24]); 1988 u[14] = _mm_unpacklo_epi32(lstep3[23], lstep3[25]); 1989 u[15] = _mm_unpackhi_epi32(lstep3[23], lstep3[25]); 1990 1991 v[ 0] = k_madd_epi32(u[ 0], k32_p30_p02); 1992 v[ 1] = k_madd_epi32(u[ 1], k32_p30_p02); 1993 v[ 2] = k_madd_epi32(u[ 2], k32_p30_p02); 1994 v[ 3] = k_madd_epi32(u[ 3], k32_p30_p02); 1995 v[ 4] = k_madd_epi32(u[ 4], k32_p14_p18); 1996 v[ 5] = k_madd_epi32(u[ 5], k32_p14_p18); 1997 v[ 6] = k_madd_epi32(u[ 6], k32_p14_p18); 1998 v[ 7] = k_madd_epi32(u[ 7], k32_p14_p18); 1999 v[ 8] = k_madd_epi32(u[ 8], k32_p22_p10); 2000 v[ 9] = k_madd_epi32(u[ 9], k32_p22_p10); 2001 v[10] = k_madd_epi32(u[10], k32_p22_p10); 2002 v[11] = k_madd_epi32(u[11], k32_p22_p10); 2003 v[12] = k_madd_epi32(u[12], k32_p06_p26); 2004 v[13] = k_madd_epi32(u[13], k32_p06_p26); 2005 v[14] = k_madd_epi32(u[14], k32_p06_p26); 2006 v[15] = k_madd_epi32(u[15], k32_p06_p26); 2007 v[16] = k_madd_epi32(u[12], k32_m26_p06); 2008 v[17] = k_madd_epi32(u[13], k32_m26_p06); 2009 v[18] = k_madd_epi32(u[14], k32_m26_p06); 2010 v[19] = k_madd_epi32(u[15], k32_m26_p06); 2011 v[20] = k_madd_epi32(u[ 8], k32_m10_p22); 2012 v[21] = k_madd_epi32(u[ 9], k32_m10_p22); 2013 v[22] = k_madd_epi32(u[10], k32_m10_p22); 2014 v[23] = k_madd_epi32(u[11], k32_m10_p22); 2015 v[24] = k_madd_epi32(u[ 4], k32_m18_p14); 2016 v[25] = k_madd_epi32(u[ 5], k32_m18_p14); 2017 v[26] = k_madd_epi32(u[ 6], k32_m18_p14); 2018 v[27] = k_madd_epi32(u[ 7], k32_m18_p14); 2019 v[28] = k_madd_epi32(u[ 0], k32_m02_p30); 2020 v[29] = k_madd_epi32(u[ 1], k32_m02_p30); 2021 v[30] = k_madd_epi32(u[ 2], k32_m02_p30); 2022 v[31] = k_madd_epi32(u[ 3], k32_m02_p30); 2023 2024 u[ 0] = k_packs_epi64(v[ 0], v[ 1]); 2025 u[ 1] = k_packs_epi64(v[ 2], v[ 3]); 2026 u[ 2] = k_packs_epi64(v[ 4], v[ 5]); 2027 u[ 3] = k_packs_epi64(v[ 6], v[ 7]); 2028 u[ 4] = k_packs_epi64(v[ 8], v[ 9]); 2029 u[ 5] = k_packs_epi64(v[10], v[11]); 2030 u[ 6] = k_packs_epi64(v[12], v[13]); 2031 u[ 7] = k_packs_epi64(v[14], v[15]); 2032 u[ 8] = k_packs_epi64(v[16], v[17]); 2033 u[ 9] = k_packs_epi64(v[18], v[19]); 2034 u[10] = k_packs_epi64(v[20], v[21]); 2035 u[11] = k_packs_epi64(v[22], v[23]); 2036 u[12] = k_packs_epi64(v[24], v[25]); 2037 u[13] = k_packs_epi64(v[26], v[27]); 2038 u[14] = k_packs_epi64(v[28], v[29]); 2039 u[15] = k_packs_epi64(v[30], v[31]); 2040 2041 v[ 0] = _mm_add_epi32(u[ 0], k__DCT_CONST_ROUNDING); 2042 v[ 1] = _mm_add_epi32(u[ 1], k__DCT_CONST_ROUNDING); 2043 v[ 2] = _mm_add_epi32(u[ 2], k__DCT_CONST_ROUNDING); 2044 v[ 3] = _mm_add_epi32(u[ 3], k__DCT_CONST_ROUNDING); 2045 v[ 4] = _mm_add_epi32(u[ 4], k__DCT_CONST_ROUNDING); 2046 v[ 5] = _mm_add_epi32(u[ 5], k__DCT_CONST_ROUNDING); 2047 v[ 6] = _mm_add_epi32(u[ 6], k__DCT_CONST_ROUNDING); 2048 v[ 7] = _mm_add_epi32(u[ 7], k__DCT_CONST_ROUNDING); 2049 v[ 8] = _mm_add_epi32(u[ 8], k__DCT_CONST_ROUNDING); 2050 v[ 9] = _mm_add_epi32(u[ 9], k__DCT_CONST_ROUNDING); 2051 v[10] = _mm_add_epi32(u[10], k__DCT_CONST_ROUNDING); 2052 v[11] = _mm_add_epi32(u[11], k__DCT_CONST_ROUNDING); 2053 v[12] = _mm_add_epi32(u[12], k__DCT_CONST_ROUNDING); 2054 v[13] = _mm_add_epi32(u[13], k__DCT_CONST_ROUNDING); 2055 v[14] = _mm_add_epi32(u[14], k__DCT_CONST_ROUNDING); 2056 v[15] = _mm_add_epi32(u[15], k__DCT_CONST_ROUNDING); 2057 2058 u[ 0] = _mm_srai_epi32(v[ 0], DCT_CONST_BITS); 2059 u[ 1] = _mm_srai_epi32(v[ 1], DCT_CONST_BITS); 2060 u[ 2] = _mm_srai_epi32(v[ 2], DCT_CONST_BITS); 2061 u[ 3] = _mm_srai_epi32(v[ 3], DCT_CONST_BITS); 2062 u[ 4] = _mm_srai_epi32(v[ 4], DCT_CONST_BITS); 2063 u[ 5] = _mm_srai_epi32(v[ 5], DCT_CONST_BITS); 2064 u[ 6] = _mm_srai_epi32(v[ 6], DCT_CONST_BITS); 2065 u[ 7] = _mm_srai_epi32(v[ 7], DCT_CONST_BITS); 2066 u[ 8] = _mm_srai_epi32(v[ 8], DCT_CONST_BITS); 2067 u[ 9] = _mm_srai_epi32(v[ 9], DCT_CONST_BITS); 2068 u[10] = _mm_srai_epi32(v[10], DCT_CONST_BITS); 2069 u[11] = _mm_srai_epi32(v[11], DCT_CONST_BITS); 2070 u[12] = _mm_srai_epi32(v[12], DCT_CONST_BITS); 2071 u[13] = _mm_srai_epi32(v[13], DCT_CONST_BITS); 2072 u[14] = _mm_srai_epi32(v[14], DCT_CONST_BITS); 2073 u[15] = _mm_srai_epi32(v[15], DCT_CONST_BITS); 2074 2075 v[ 0] = _mm_cmplt_epi32(u[ 0], kZero); 2076 v[ 1] = _mm_cmplt_epi32(u[ 1], kZero); 2077 v[ 2] = _mm_cmplt_epi32(u[ 2], kZero); 2078 v[ 3] = _mm_cmplt_epi32(u[ 3], kZero); 2079 v[ 4] = _mm_cmplt_epi32(u[ 4], kZero); 2080 v[ 5] = _mm_cmplt_epi32(u[ 5], kZero); 2081 v[ 6] = _mm_cmplt_epi32(u[ 6], kZero); 2082 v[ 7] = _mm_cmplt_epi32(u[ 7], kZero); 2083 v[ 8] = _mm_cmplt_epi32(u[ 8], kZero); 2084 v[ 9] = _mm_cmplt_epi32(u[ 9], kZero); 2085 v[10] = _mm_cmplt_epi32(u[10], kZero); 2086 v[11] = _mm_cmplt_epi32(u[11], kZero); 2087 v[12] = _mm_cmplt_epi32(u[12], kZero); 2088 v[13] = _mm_cmplt_epi32(u[13], kZero); 2089 v[14] = _mm_cmplt_epi32(u[14], kZero); 2090 v[15] = _mm_cmplt_epi32(u[15], kZero); 2091 2092 u[ 0] = _mm_sub_epi32(u[ 0], v[ 0]); 2093 u[ 1] = _mm_sub_epi32(u[ 1], v[ 1]); 2094 u[ 2] = _mm_sub_epi32(u[ 2], v[ 2]); 2095 u[ 3] = _mm_sub_epi32(u[ 3], v[ 3]); 2096 u[ 4] = _mm_sub_epi32(u[ 4], v[ 4]); 2097 u[ 5] = _mm_sub_epi32(u[ 5], v[ 5]); 2098 u[ 6] = _mm_sub_epi32(u[ 6], v[ 6]); 2099 u[ 7] = _mm_sub_epi32(u[ 7], v[ 7]); 2100 u[ 8] = _mm_sub_epi32(u[ 8], v[ 8]); 2101 u[ 9] = _mm_sub_epi32(u[ 9], v[ 9]); 2102 u[10] = _mm_sub_epi32(u[10], v[10]); 2103 u[11] = _mm_sub_epi32(u[11], v[11]); 2104 u[12] = _mm_sub_epi32(u[12], v[12]); 2105 u[13] = _mm_sub_epi32(u[13], v[13]); 2106 u[14] = _mm_sub_epi32(u[14], v[14]); 2107 u[15] = _mm_sub_epi32(u[15], v[15]); 2108 2109 v[ 0] = _mm_add_epi32(u[ 0], K32One); 2110 v[ 1] = _mm_add_epi32(u[ 1], K32One); 2111 v[ 2] = _mm_add_epi32(u[ 2], K32One); 2112 v[ 3] = _mm_add_epi32(u[ 3], K32One); 2113 v[ 4] = _mm_add_epi32(u[ 4], K32One); 2114 v[ 5] = _mm_add_epi32(u[ 5], K32One); 2115 v[ 6] = _mm_add_epi32(u[ 6], K32One); 2116 v[ 7] = _mm_add_epi32(u[ 7], K32One); 2117 v[ 8] = _mm_add_epi32(u[ 8], K32One); 2118 v[ 9] = _mm_add_epi32(u[ 9], K32One); 2119 v[10] = _mm_add_epi32(u[10], K32One); 2120 v[11] = _mm_add_epi32(u[11], K32One); 2121 v[12] = _mm_add_epi32(u[12], K32One); 2122 v[13] = _mm_add_epi32(u[13], K32One); 2123 v[14] = _mm_add_epi32(u[14], K32One); 2124 v[15] = _mm_add_epi32(u[15], K32One); 2125 2126 u[ 0] = _mm_srai_epi32(v[ 0], 2); 2127 u[ 1] = _mm_srai_epi32(v[ 1], 2); 2128 u[ 2] = _mm_srai_epi32(v[ 2], 2); 2129 u[ 3] = _mm_srai_epi32(v[ 3], 2); 2130 u[ 4] = _mm_srai_epi32(v[ 4], 2); 2131 u[ 5] = _mm_srai_epi32(v[ 5], 2); 2132 u[ 6] = _mm_srai_epi32(v[ 6], 2); 2133 u[ 7] = _mm_srai_epi32(v[ 7], 2); 2134 u[ 8] = _mm_srai_epi32(v[ 8], 2); 2135 u[ 9] = _mm_srai_epi32(v[ 9], 2); 2136 u[10] = _mm_srai_epi32(v[10], 2); 2137 u[11] = _mm_srai_epi32(v[11], 2); 2138 u[12] = _mm_srai_epi32(v[12], 2); 2139 u[13] = _mm_srai_epi32(v[13], 2); 2140 u[14] = _mm_srai_epi32(v[14], 2); 2141 u[15] = _mm_srai_epi32(v[15], 2); 2142 2143 out[ 2] = _mm_packs_epi32(u[0], u[1]); 2144 out[18] = _mm_packs_epi32(u[2], u[3]); 2145 out[10] = _mm_packs_epi32(u[4], u[5]); 2146 out[26] = _mm_packs_epi32(u[6], u[7]); 2147 out[ 6] = _mm_packs_epi32(u[8], u[9]); 2148 out[22] = _mm_packs_epi32(u[10], u[11]); 2149 out[14] = _mm_packs_epi32(u[12], u[13]); 2150 out[30] = _mm_packs_epi32(u[14], u[15]); 2151 } 2152 { 2153 lstep1[32] = _mm_add_epi32(lstep3[34], lstep2[32]); 2154 lstep1[33] = _mm_add_epi32(lstep3[35], lstep2[33]); 2155 lstep1[34] = _mm_sub_epi32(lstep2[32], lstep3[34]); 2156 lstep1[35] = _mm_sub_epi32(lstep2[33], lstep3[35]); 2157 lstep1[36] = _mm_sub_epi32(lstep2[38], lstep3[36]); 2158 lstep1[37] = _mm_sub_epi32(lstep2[39], lstep3[37]); 2159 lstep1[38] = _mm_add_epi32(lstep3[36], lstep2[38]); 2160 lstep1[39] = _mm_add_epi32(lstep3[37], lstep2[39]); 2161 lstep1[40] = _mm_add_epi32(lstep3[42], lstep2[40]); 2162 lstep1[41] = _mm_add_epi32(lstep3[43], lstep2[41]); 2163 lstep1[42] = _mm_sub_epi32(lstep2[40], lstep3[42]); 2164 lstep1[43] = _mm_sub_epi32(lstep2[41], lstep3[43]); 2165 lstep1[44] = _mm_sub_epi32(lstep2[46], lstep3[44]); 2166 lstep1[45] = _mm_sub_epi32(lstep2[47], lstep3[45]); 2167 lstep1[46] = _mm_add_epi32(lstep3[44], lstep2[46]); 2168 lstep1[47] = _mm_add_epi32(lstep3[45], lstep2[47]); 2169 lstep1[48] = _mm_add_epi32(lstep3[50], lstep2[48]); 2170 lstep1[49] = _mm_add_epi32(lstep3[51], lstep2[49]); 2171 lstep1[50] = _mm_sub_epi32(lstep2[48], lstep3[50]); 2172 lstep1[51] = _mm_sub_epi32(lstep2[49], lstep3[51]); 2173 lstep1[52] = _mm_sub_epi32(lstep2[54], lstep3[52]); 2174 lstep1[53] = _mm_sub_epi32(lstep2[55], lstep3[53]); 2175 lstep1[54] = _mm_add_epi32(lstep3[52], lstep2[54]); 2176 lstep1[55] = _mm_add_epi32(lstep3[53], lstep2[55]); 2177 lstep1[56] = _mm_add_epi32(lstep3[58], lstep2[56]); 2178 lstep1[57] = _mm_add_epi32(lstep3[59], lstep2[57]); 2179 lstep1[58] = _mm_sub_epi32(lstep2[56], lstep3[58]); 2180 lstep1[59] = _mm_sub_epi32(lstep2[57], lstep3[59]); 2181 lstep1[60] = _mm_sub_epi32(lstep2[62], lstep3[60]); 2182 lstep1[61] = _mm_sub_epi32(lstep2[63], lstep3[61]); 2183 lstep1[62] = _mm_add_epi32(lstep3[60], lstep2[62]); 2184 lstep1[63] = _mm_add_epi32(lstep3[61], lstep2[63]); 2185 } 2186 // stage 8 2187 { 2188 const __m128i k32_p31_p01 = pair_set_epi32(cospi_31_64, cospi_1_64); 2189 const __m128i k32_p15_p17 = pair_set_epi32(cospi_15_64, cospi_17_64); 2190 const __m128i k32_p23_p09 = pair_set_epi32(cospi_23_64, cospi_9_64); 2191 const __m128i k32_p07_p25 = pair_set_epi32(cospi_7_64, cospi_25_64); 2192 const __m128i k32_m25_p07 = pair_set_epi32(-cospi_25_64, cospi_7_64); 2193 const __m128i k32_m09_p23 = pair_set_epi32(-cospi_9_64, cospi_23_64); 2194 const __m128i k32_m17_p15 = pair_set_epi32(-cospi_17_64, cospi_15_64); 2195 const __m128i k32_m01_p31 = pair_set_epi32(-cospi_1_64, cospi_31_64); 2196 2197 u[ 0] = _mm_unpacklo_epi32(lstep1[32], lstep1[62]); 2198 u[ 1] = _mm_unpackhi_epi32(lstep1[32], lstep1[62]); 2199 u[ 2] = _mm_unpacklo_epi32(lstep1[33], lstep1[63]); 2200 u[ 3] = _mm_unpackhi_epi32(lstep1[33], lstep1[63]); 2201 u[ 4] = _mm_unpacklo_epi32(lstep1[34], lstep1[60]); 2202 u[ 5] = _mm_unpackhi_epi32(lstep1[34], lstep1[60]); 2203 u[ 6] = _mm_unpacklo_epi32(lstep1[35], lstep1[61]); 2204 u[ 7] = _mm_unpackhi_epi32(lstep1[35], lstep1[61]); 2205 u[ 8] = _mm_unpacklo_epi32(lstep1[36], lstep1[58]); 2206 u[ 9] = _mm_unpackhi_epi32(lstep1[36], lstep1[58]); 2207 u[10] = _mm_unpacklo_epi32(lstep1[37], lstep1[59]); 2208 u[11] = _mm_unpackhi_epi32(lstep1[37], lstep1[59]); 2209 u[12] = _mm_unpacklo_epi32(lstep1[38], lstep1[56]); 2210 u[13] = _mm_unpackhi_epi32(lstep1[38], lstep1[56]); 2211 u[14] = _mm_unpacklo_epi32(lstep1[39], lstep1[57]); 2212 u[15] = _mm_unpackhi_epi32(lstep1[39], lstep1[57]); 2213 2214 v[ 0] = k_madd_epi32(u[ 0], k32_p31_p01); 2215 v[ 1] = k_madd_epi32(u[ 1], k32_p31_p01); 2216 v[ 2] = k_madd_epi32(u[ 2], k32_p31_p01); 2217 v[ 3] = k_madd_epi32(u[ 3], k32_p31_p01); 2218 v[ 4] = k_madd_epi32(u[ 4], k32_p15_p17); 2219 v[ 5] = k_madd_epi32(u[ 5], k32_p15_p17); 2220 v[ 6] = k_madd_epi32(u[ 6], k32_p15_p17); 2221 v[ 7] = k_madd_epi32(u[ 7], k32_p15_p17); 2222 v[ 8] = k_madd_epi32(u[ 8], k32_p23_p09); 2223 v[ 9] = k_madd_epi32(u[ 9], k32_p23_p09); 2224 v[10] = k_madd_epi32(u[10], k32_p23_p09); 2225 v[11] = k_madd_epi32(u[11], k32_p23_p09); 2226 v[12] = k_madd_epi32(u[12], k32_p07_p25); 2227 v[13] = k_madd_epi32(u[13], k32_p07_p25); 2228 v[14] = k_madd_epi32(u[14], k32_p07_p25); 2229 v[15] = k_madd_epi32(u[15], k32_p07_p25); 2230 v[16] = k_madd_epi32(u[12], k32_m25_p07); 2231 v[17] = k_madd_epi32(u[13], k32_m25_p07); 2232 v[18] = k_madd_epi32(u[14], k32_m25_p07); 2233 v[19] = k_madd_epi32(u[15], k32_m25_p07); 2234 v[20] = k_madd_epi32(u[ 8], k32_m09_p23); 2235 v[21] = k_madd_epi32(u[ 9], k32_m09_p23); 2236 v[22] = k_madd_epi32(u[10], k32_m09_p23); 2237 v[23] = k_madd_epi32(u[11], k32_m09_p23); 2238 v[24] = k_madd_epi32(u[ 4], k32_m17_p15); 2239 v[25] = k_madd_epi32(u[ 5], k32_m17_p15); 2240 v[26] = k_madd_epi32(u[ 6], k32_m17_p15); 2241 v[27] = k_madd_epi32(u[ 7], k32_m17_p15); 2242 v[28] = k_madd_epi32(u[ 0], k32_m01_p31); 2243 v[29] = k_madd_epi32(u[ 1], k32_m01_p31); 2244 v[30] = k_madd_epi32(u[ 2], k32_m01_p31); 2245 v[31] = k_madd_epi32(u[ 3], k32_m01_p31); 2246 2247 u[ 0] = k_packs_epi64(v[ 0], v[ 1]); 2248 u[ 1] = k_packs_epi64(v[ 2], v[ 3]); 2249 u[ 2] = k_packs_epi64(v[ 4], v[ 5]); 2250 u[ 3] = k_packs_epi64(v[ 6], v[ 7]); 2251 u[ 4] = k_packs_epi64(v[ 8], v[ 9]); 2252 u[ 5] = k_packs_epi64(v[10], v[11]); 2253 u[ 6] = k_packs_epi64(v[12], v[13]); 2254 u[ 7] = k_packs_epi64(v[14], v[15]); 2255 u[ 8] = k_packs_epi64(v[16], v[17]); 2256 u[ 9] = k_packs_epi64(v[18], v[19]); 2257 u[10] = k_packs_epi64(v[20], v[21]); 2258 u[11] = k_packs_epi64(v[22], v[23]); 2259 u[12] = k_packs_epi64(v[24], v[25]); 2260 u[13] = k_packs_epi64(v[26], v[27]); 2261 u[14] = k_packs_epi64(v[28], v[29]); 2262 u[15] = k_packs_epi64(v[30], v[31]); 2263 2264 v[ 0] = _mm_add_epi32(u[ 0], k__DCT_CONST_ROUNDING); 2265 v[ 1] = _mm_add_epi32(u[ 1], k__DCT_CONST_ROUNDING); 2266 v[ 2] = _mm_add_epi32(u[ 2], k__DCT_CONST_ROUNDING); 2267 v[ 3] = _mm_add_epi32(u[ 3], k__DCT_CONST_ROUNDING); 2268 v[ 4] = _mm_add_epi32(u[ 4], k__DCT_CONST_ROUNDING); 2269 v[ 5] = _mm_add_epi32(u[ 5], k__DCT_CONST_ROUNDING); 2270 v[ 6] = _mm_add_epi32(u[ 6], k__DCT_CONST_ROUNDING); 2271 v[ 7] = _mm_add_epi32(u[ 7], k__DCT_CONST_ROUNDING); 2272 v[ 8] = _mm_add_epi32(u[ 8], k__DCT_CONST_ROUNDING); 2273 v[ 9] = _mm_add_epi32(u[ 9], k__DCT_CONST_ROUNDING); 2274 v[10] = _mm_add_epi32(u[10], k__DCT_CONST_ROUNDING); 2275 v[11] = _mm_add_epi32(u[11], k__DCT_CONST_ROUNDING); 2276 v[12] = _mm_add_epi32(u[12], k__DCT_CONST_ROUNDING); 2277 v[13] = _mm_add_epi32(u[13], k__DCT_CONST_ROUNDING); 2278 v[14] = _mm_add_epi32(u[14], k__DCT_CONST_ROUNDING); 2279 v[15] = _mm_add_epi32(u[15], k__DCT_CONST_ROUNDING); 2280 2281 u[ 0] = _mm_srai_epi32(v[ 0], DCT_CONST_BITS); 2282 u[ 1] = _mm_srai_epi32(v[ 1], DCT_CONST_BITS); 2283 u[ 2] = _mm_srai_epi32(v[ 2], DCT_CONST_BITS); 2284 u[ 3] = _mm_srai_epi32(v[ 3], DCT_CONST_BITS); 2285 u[ 4] = _mm_srai_epi32(v[ 4], DCT_CONST_BITS); 2286 u[ 5] = _mm_srai_epi32(v[ 5], DCT_CONST_BITS); 2287 u[ 6] = _mm_srai_epi32(v[ 6], DCT_CONST_BITS); 2288 u[ 7] = _mm_srai_epi32(v[ 7], DCT_CONST_BITS); 2289 u[ 8] = _mm_srai_epi32(v[ 8], DCT_CONST_BITS); 2290 u[ 9] = _mm_srai_epi32(v[ 9], DCT_CONST_BITS); 2291 u[10] = _mm_srai_epi32(v[10], DCT_CONST_BITS); 2292 u[11] = _mm_srai_epi32(v[11], DCT_CONST_BITS); 2293 u[12] = _mm_srai_epi32(v[12], DCT_CONST_BITS); 2294 u[13] = _mm_srai_epi32(v[13], DCT_CONST_BITS); 2295 u[14] = _mm_srai_epi32(v[14], DCT_CONST_BITS); 2296 u[15] = _mm_srai_epi32(v[15], DCT_CONST_BITS); 2297 2298 v[ 0] = _mm_cmplt_epi32(u[ 0], kZero); 2299 v[ 1] = _mm_cmplt_epi32(u[ 1], kZero); 2300 v[ 2] = _mm_cmplt_epi32(u[ 2], kZero); 2301 v[ 3] = _mm_cmplt_epi32(u[ 3], kZero); 2302 v[ 4] = _mm_cmplt_epi32(u[ 4], kZero); 2303 v[ 5] = _mm_cmplt_epi32(u[ 5], kZero); 2304 v[ 6] = _mm_cmplt_epi32(u[ 6], kZero); 2305 v[ 7] = _mm_cmplt_epi32(u[ 7], kZero); 2306 v[ 8] = _mm_cmplt_epi32(u[ 8], kZero); 2307 v[ 9] = _mm_cmplt_epi32(u[ 9], kZero); 2308 v[10] = _mm_cmplt_epi32(u[10], kZero); 2309 v[11] = _mm_cmplt_epi32(u[11], kZero); 2310 v[12] = _mm_cmplt_epi32(u[12], kZero); 2311 v[13] = _mm_cmplt_epi32(u[13], kZero); 2312 v[14] = _mm_cmplt_epi32(u[14], kZero); 2313 v[15] = _mm_cmplt_epi32(u[15], kZero); 2314 2315 u[ 0] = _mm_sub_epi32(u[ 0], v[ 0]); 2316 u[ 1] = _mm_sub_epi32(u[ 1], v[ 1]); 2317 u[ 2] = _mm_sub_epi32(u[ 2], v[ 2]); 2318 u[ 3] = _mm_sub_epi32(u[ 3], v[ 3]); 2319 u[ 4] = _mm_sub_epi32(u[ 4], v[ 4]); 2320 u[ 5] = _mm_sub_epi32(u[ 5], v[ 5]); 2321 u[ 6] = _mm_sub_epi32(u[ 6], v[ 6]); 2322 u[ 7] = _mm_sub_epi32(u[ 7], v[ 7]); 2323 u[ 8] = _mm_sub_epi32(u[ 8], v[ 8]); 2324 u[ 9] = _mm_sub_epi32(u[ 9], v[ 9]); 2325 u[10] = _mm_sub_epi32(u[10], v[10]); 2326 u[11] = _mm_sub_epi32(u[11], v[11]); 2327 u[12] = _mm_sub_epi32(u[12], v[12]); 2328 u[13] = _mm_sub_epi32(u[13], v[13]); 2329 u[14] = _mm_sub_epi32(u[14], v[14]); 2330 u[15] = _mm_sub_epi32(u[15], v[15]); 2331 2332 v[0] = _mm_add_epi32(u[0], K32One); 2333 v[1] = _mm_add_epi32(u[1], K32One); 2334 v[2] = _mm_add_epi32(u[2], K32One); 2335 v[3] = _mm_add_epi32(u[3], K32One); 2336 v[4] = _mm_add_epi32(u[4], K32One); 2337 v[5] = _mm_add_epi32(u[5], K32One); 2338 v[6] = _mm_add_epi32(u[6], K32One); 2339 v[7] = _mm_add_epi32(u[7], K32One); 2340 v[8] = _mm_add_epi32(u[8], K32One); 2341 v[9] = _mm_add_epi32(u[9], K32One); 2342 v[10] = _mm_add_epi32(u[10], K32One); 2343 v[11] = _mm_add_epi32(u[11], K32One); 2344 v[12] = _mm_add_epi32(u[12], K32One); 2345 v[13] = _mm_add_epi32(u[13], K32One); 2346 v[14] = _mm_add_epi32(u[14], K32One); 2347 v[15] = _mm_add_epi32(u[15], K32One); 2348 2349 u[0] = _mm_srai_epi32(v[0], 2); 2350 u[1] = _mm_srai_epi32(v[1], 2); 2351 u[2] = _mm_srai_epi32(v[2], 2); 2352 u[3] = _mm_srai_epi32(v[3], 2); 2353 u[4] = _mm_srai_epi32(v[4], 2); 2354 u[5] = _mm_srai_epi32(v[5], 2); 2355 u[6] = _mm_srai_epi32(v[6], 2); 2356 u[7] = _mm_srai_epi32(v[7], 2); 2357 u[8] = _mm_srai_epi32(v[8], 2); 2358 u[9] = _mm_srai_epi32(v[9], 2); 2359 u[10] = _mm_srai_epi32(v[10], 2); 2360 u[11] = _mm_srai_epi32(v[11], 2); 2361 u[12] = _mm_srai_epi32(v[12], 2); 2362 u[13] = _mm_srai_epi32(v[13], 2); 2363 u[14] = _mm_srai_epi32(v[14], 2); 2364 u[15] = _mm_srai_epi32(v[15], 2); 2365 2366 out[ 1] = _mm_packs_epi32(u[0], u[1]); 2367 out[17] = _mm_packs_epi32(u[2], u[3]); 2368 out[ 9] = _mm_packs_epi32(u[4], u[5]); 2369 out[25] = _mm_packs_epi32(u[6], u[7]); 2370 out[ 7] = _mm_packs_epi32(u[8], u[9]); 2371 out[23] = _mm_packs_epi32(u[10], u[11]); 2372 out[15] = _mm_packs_epi32(u[12], u[13]); 2373 out[31] = _mm_packs_epi32(u[14], u[15]); 2374 } 2375 { 2376 const __m128i k32_p27_p05 = pair_set_epi32(cospi_27_64, cospi_5_64); 2377 const __m128i k32_p11_p21 = pair_set_epi32(cospi_11_64, cospi_21_64); 2378 const __m128i k32_p19_p13 = pair_set_epi32(cospi_19_64, cospi_13_64); 2379 const __m128i k32_p03_p29 = pair_set_epi32(cospi_3_64, cospi_29_64); 2380 const __m128i k32_m29_p03 = pair_set_epi32(-cospi_29_64, cospi_3_64); 2381 const __m128i k32_m13_p19 = pair_set_epi32(-cospi_13_64, cospi_19_64); 2382 const __m128i k32_m21_p11 = pair_set_epi32(-cospi_21_64, cospi_11_64); 2383 const __m128i k32_m05_p27 = pair_set_epi32(-cospi_5_64, cospi_27_64); 2384 2385 u[ 0] = _mm_unpacklo_epi32(lstep1[40], lstep1[54]); 2386 u[ 1] = _mm_unpackhi_epi32(lstep1[40], lstep1[54]); 2387 u[ 2] = _mm_unpacklo_epi32(lstep1[41], lstep1[55]); 2388 u[ 3] = _mm_unpackhi_epi32(lstep1[41], lstep1[55]); 2389 u[ 4] = _mm_unpacklo_epi32(lstep1[42], lstep1[52]); 2390 u[ 5] = _mm_unpackhi_epi32(lstep1[42], lstep1[52]); 2391 u[ 6] = _mm_unpacklo_epi32(lstep1[43], lstep1[53]); 2392 u[ 7] = _mm_unpackhi_epi32(lstep1[43], lstep1[53]); 2393 u[ 8] = _mm_unpacklo_epi32(lstep1[44], lstep1[50]); 2394 u[ 9] = _mm_unpackhi_epi32(lstep1[44], lstep1[50]); 2395 u[10] = _mm_unpacklo_epi32(lstep1[45], lstep1[51]); 2396 u[11] = _mm_unpackhi_epi32(lstep1[45], lstep1[51]); 2397 u[12] = _mm_unpacklo_epi32(lstep1[46], lstep1[48]); 2398 u[13] = _mm_unpackhi_epi32(lstep1[46], lstep1[48]); 2399 u[14] = _mm_unpacklo_epi32(lstep1[47], lstep1[49]); 2400 u[15] = _mm_unpackhi_epi32(lstep1[47], lstep1[49]); 2401 2402 v[ 0] = k_madd_epi32(u[ 0], k32_p27_p05); 2403 v[ 1] = k_madd_epi32(u[ 1], k32_p27_p05); 2404 v[ 2] = k_madd_epi32(u[ 2], k32_p27_p05); 2405 v[ 3] = k_madd_epi32(u[ 3], k32_p27_p05); 2406 v[ 4] = k_madd_epi32(u[ 4], k32_p11_p21); 2407 v[ 5] = k_madd_epi32(u[ 5], k32_p11_p21); 2408 v[ 6] = k_madd_epi32(u[ 6], k32_p11_p21); 2409 v[ 7] = k_madd_epi32(u[ 7], k32_p11_p21); 2410 v[ 8] = k_madd_epi32(u[ 8], k32_p19_p13); 2411 v[ 9] = k_madd_epi32(u[ 9], k32_p19_p13); 2412 v[10] = k_madd_epi32(u[10], k32_p19_p13); 2413 v[11] = k_madd_epi32(u[11], k32_p19_p13); 2414 v[12] = k_madd_epi32(u[12], k32_p03_p29); 2415 v[13] = k_madd_epi32(u[13], k32_p03_p29); 2416 v[14] = k_madd_epi32(u[14], k32_p03_p29); 2417 v[15] = k_madd_epi32(u[15], k32_p03_p29); 2418 v[16] = k_madd_epi32(u[12], k32_m29_p03); 2419 v[17] = k_madd_epi32(u[13], k32_m29_p03); 2420 v[18] = k_madd_epi32(u[14], k32_m29_p03); 2421 v[19] = k_madd_epi32(u[15], k32_m29_p03); 2422 v[20] = k_madd_epi32(u[ 8], k32_m13_p19); 2423 v[21] = k_madd_epi32(u[ 9], k32_m13_p19); 2424 v[22] = k_madd_epi32(u[10], k32_m13_p19); 2425 v[23] = k_madd_epi32(u[11], k32_m13_p19); 2426 v[24] = k_madd_epi32(u[ 4], k32_m21_p11); 2427 v[25] = k_madd_epi32(u[ 5], k32_m21_p11); 2428 v[26] = k_madd_epi32(u[ 6], k32_m21_p11); 2429 v[27] = k_madd_epi32(u[ 7], k32_m21_p11); 2430 v[28] = k_madd_epi32(u[ 0], k32_m05_p27); 2431 v[29] = k_madd_epi32(u[ 1], k32_m05_p27); 2432 v[30] = k_madd_epi32(u[ 2], k32_m05_p27); 2433 v[31] = k_madd_epi32(u[ 3], k32_m05_p27); 2434 2435 u[ 0] = k_packs_epi64(v[ 0], v[ 1]); 2436 u[ 1] = k_packs_epi64(v[ 2], v[ 3]); 2437 u[ 2] = k_packs_epi64(v[ 4], v[ 5]); 2438 u[ 3] = k_packs_epi64(v[ 6], v[ 7]); 2439 u[ 4] = k_packs_epi64(v[ 8], v[ 9]); 2440 u[ 5] = k_packs_epi64(v[10], v[11]); 2441 u[ 6] = k_packs_epi64(v[12], v[13]); 2442 u[ 7] = k_packs_epi64(v[14], v[15]); 2443 u[ 8] = k_packs_epi64(v[16], v[17]); 2444 u[ 9] = k_packs_epi64(v[18], v[19]); 2445 u[10] = k_packs_epi64(v[20], v[21]); 2446 u[11] = k_packs_epi64(v[22], v[23]); 2447 u[12] = k_packs_epi64(v[24], v[25]); 2448 u[13] = k_packs_epi64(v[26], v[27]); 2449 u[14] = k_packs_epi64(v[28], v[29]); 2450 u[15] = k_packs_epi64(v[30], v[31]); 2451 2452 v[ 0] = _mm_add_epi32(u[ 0], k__DCT_CONST_ROUNDING); 2453 v[ 1] = _mm_add_epi32(u[ 1], k__DCT_CONST_ROUNDING); 2454 v[ 2] = _mm_add_epi32(u[ 2], k__DCT_CONST_ROUNDING); 2455 v[ 3] = _mm_add_epi32(u[ 3], k__DCT_CONST_ROUNDING); 2456 v[ 4] = _mm_add_epi32(u[ 4], k__DCT_CONST_ROUNDING); 2457 v[ 5] = _mm_add_epi32(u[ 5], k__DCT_CONST_ROUNDING); 2458 v[ 6] = _mm_add_epi32(u[ 6], k__DCT_CONST_ROUNDING); 2459 v[ 7] = _mm_add_epi32(u[ 7], k__DCT_CONST_ROUNDING); 2460 v[ 8] = _mm_add_epi32(u[ 8], k__DCT_CONST_ROUNDING); 2461 v[ 9] = _mm_add_epi32(u[ 9], k__DCT_CONST_ROUNDING); 2462 v[10] = _mm_add_epi32(u[10], k__DCT_CONST_ROUNDING); 2463 v[11] = _mm_add_epi32(u[11], k__DCT_CONST_ROUNDING); 2464 v[12] = _mm_add_epi32(u[12], k__DCT_CONST_ROUNDING); 2465 v[13] = _mm_add_epi32(u[13], k__DCT_CONST_ROUNDING); 2466 v[14] = _mm_add_epi32(u[14], k__DCT_CONST_ROUNDING); 2467 v[15] = _mm_add_epi32(u[15], k__DCT_CONST_ROUNDING); 2468 2469 u[ 0] = _mm_srai_epi32(v[ 0], DCT_CONST_BITS); 2470 u[ 1] = _mm_srai_epi32(v[ 1], DCT_CONST_BITS); 2471 u[ 2] = _mm_srai_epi32(v[ 2], DCT_CONST_BITS); 2472 u[ 3] = _mm_srai_epi32(v[ 3], DCT_CONST_BITS); 2473 u[ 4] = _mm_srai_epi32(v[ 4], DCT_CONST_BITS); 2474 u[ 5] = _mm_srai_epi32(v[ 5], DCT_CONST_BITS); 2475 u[ 6] = _mm_srai_epi32(v[ 6], DCT_CONST_BITS); 2476 u[ 7] = _mm_srai_epi32(v[ 7], DCT_CONST_BITS); 2477 u[ 8] = _mm_srai_epi32(v[ 8], DCT_CONST_BITS); 2478 u[ 9] = _mm_srai_epi32(v[ 9], DCT_CONST_BITS); 2479 u[10] = _mm_srai_epi32(v[10], DCT_CONST_BITS); 2480 u[11] = _mm_srai_epi32(v[11], DCT_CONST_BITS); 2481 u[12] = _mm_srai_epi32(v[12], DCT_CONST_BITS); 2482 u[13] = _mm_srai_epi32(v[13], DCT_CONST_BITS); 2483 u[14] = _mm_srai_epi32(v[14], DCT_CONST_BITS); 2484 u[15] = _mm_srai_epi32(v[15], DCT_CONST_BITS); 2485 2486 v[ 0] = _mm_cmplt_epi32(u[ 0], kZero); 2487 v[ 1] = _mm_cmplt_epi32(u[ 1], kZero); 2488 v[ 2] = _mm_cmplt_epi32(u[ 2], kZero); 2489 v[ 3] = _mm_cmplt_epi32(u[ 3], kZero); 2490 v[ 4] = _mm_cmplt_epi32(u[ 4], kZero); 2491 v[ 5] = _mm_cmplt_epi32(u[ 5], kZero); 2492 v[ 6] = _mm_cmplt_epi32(u[ 6], kZero); 2493 v[ 7] = _mm_cmplt_epi32(u[ 7], kZero); 2494 v[ 8] = _mm_cmplt_epi32(u[ 8], kZero); 2495 v[ 9] = _mm_cmplt_epi32(u[ 9], kZero); 2496 v[10] = _mm_cmplt_epi32(u[10], kZero); 2497 v[11] = _mm_cmplt_epi32(u[11], kZero); 2498 v[12] = _mm_cmplt_epi32(u[12], kZero); 2499 v[13] = _mm_cmplt_epi32(u[13], kZero); 2500 v[14] = _mm_cmplt_epi32(u[14], kZero); 2501 v[15] = _mm_cmplt_epi32(u[15], kZero); 2502 2503 u[ 0] = _mm_sub_epi32(u[ 0], v[ 0]); 2504 u[ 1] = _mm_sub_epi32(u[ 1], v[ 1]); 2505 u[ 2] = _mm_sub_epi32(u[ 2], v[ 2]); 2506 u[ 3] = _mm_sub_epi32(u[ 3], v[ 3]); 2507 u[ 4] = _mm_sub_epi32(u[ 4], v[ 4]); 2508 u[ 5] = _mm_sub_epi32(u[ 5], v[ 5]); 2509 u[ 6] = _mm_sub_epi32(u[ 6], v[ 6]); 2510 u[ 7] = _mm_sub_epi32(u[ 7], v[ 7]); 2511 u[ 8] = _mm_sub_epi32(u[ 8], v[ 8]); 2512 u[ 9] = _mm_sub_epi32(u[ 9], v[ 9]); 2513 u[10] = _mm_sub_epi32(u[10], v[10]); 2514 u[11] = _mm_sub_epi32(u[11], v[11]); 2515 u[12] = _mm_sub_epi32(u[12], v[12]); 2516 u[13] = _mm_sub_epi32(u[13], v[13]); 2517 u[14] = _mm_sub_epi32(u[14], v[14]); 2518 u[15] = _mm_sub_epi32(u[15], v[15]); 2519 2520 v[0] = _mm_add_epi32(u[0], K32One); 2521 v[1] = _mm_add_epi32(u[1], K32One); 2522 v[2] = _mm_add_epi32(u[2], K32One); 2523 v[3] = _mm_add_epi32(u[3], K32One); 2524 v[4] = _mm_add_epi32(u[4], K32One); 2525 v[5] = _mm_add_epi32(u[5], K32One); 2526 v[6] = _mm_add_epi32(u[6], K32One); 2527 v[7] = _mm_add_epi32(u[7], K32One); 2528 v[8] = _mm_add_epi32(u[8], K32One); 2529 v[9] = _mm_add_epi32(u[9], K32One); 2530 v[10] = _mm_add_epi32(u[10], K32One); 2531 v[11] = _mm_add_epi32(u[11], K32One); 2532 v[12] = _mm_add_epi32(u[12], K32One); 2533 v[13] = _mm_add_epi32(u[13], K32One); 2534 v[14] = _mm_add_epi32(u[14], K32One); 2535 v[15] = _mm_add_epi32(u[15], K32One); 2536 2537 u[0] = _mm_srai_epi32(v[0], 2); 2538 u[1] = _mm_srai_epi32(v[1], 2); 2539 u[2] = _mm_srai_epi32(v[2], 2); 2540 u[3] = _mm_srai_epi32(v[3], 2); 2541 u[4] = _mm_srai_epi32(v[4], 2); 2542 u[5] = _mm_srai_epi32(v[5], 2); 2543 u[6] = _mm_srai_epi32(v[6], 2); 2544 u[7] = _mm_srai_epi32(v[7], 2); 2545 u[8] = _mm_srai_epi32(v[8], 2); 2546 u[9] = _mm_srai_epi32(v[9], 2); 2547 u[10] = _mm_srai_epi32(v[10], 2); 2548 u[11] = _mm_srai_epi32(v[11], 2); 2549 u[12] = _mm_srai_epi32(v[12], 2); 2550 u[13] = _mm_srai_epi32(v[13], 2); 2551 u[14] = _mm_srai_epi32(v[14], 2); 2552 u[15] = _mm_srai_epi32(v[15], 2); 2553 2554 out[ 5] = _mm_packs_epi32(u[0], u[1]); 2555 out[21] = _mm_packs_epi32(u[2], u[3]); 2556 out[13] = _mm_packs_epi32(u[4], u[5]); 2557 out[29] = _mm_packs_epi32(u[6], u[7]); 2558 out[ 3] = _mm_packs_epi32(u[8], u[9]); 2559 out[19] = _mm_packs_epi32(u[10], u[11]); 2560 out[11] = _mm_packs_epi32(u[12], u[13]); 2561 out[27] = _mm_packs_epi32(u[14], u[15]); 2562 } 2563 } 2564 #endif 2565 // Transpose the results, do it as four 8x8 transposes. 2566 { 2567 int transpose_block; 2568 int16_t *output; 2569 if (0 == pass) { 2570 output = &intermediate[column_start * 32]; 2571 } else { 2572 output = &output_org[column_start * 32]; 2573 } 2574 for (transpose_block = 0; transpose_block < 4; ++transpose_block) { 2575 __m128i *this_out = &out[8 * transpose_block]; 2576 // 00 01 02 03 04 05 06 07 2577 // 10 11 12 13 14 15 16 17 2578 // 20 21 22 23 24 25 26 27 2579 // 30 31 32 33 34 35 36 37 2580 // 40 41 42 43 44 45 46 47 2581 // 50 51 52 53 54 55 56 57 2582 // 60 61 62 63 64 65 66 67 2583 // 70 71 72 73 74 75 76 77 2584 const __m128i tr0_0 = _mm_unpacklo_epi16(this_out[0], this_out[1]); 2585 const __m128i tr0_1 = _mm_unpacklo_epi16(this_out[2], this_out[3]); 2586 const __m128i tr0_2 = _mm_unpackhi_epi16(this_out[0], this_out[1]); 2587 const __m128i tr0_3 = _mm_unpackhi_epi16(this_out[2], this_out[3]); 2588 const __m128i tr0_4 = _mm_unpacklo_epi16(this_out[4], this_out[5]); 2589 const __m128i tr0_5 = _mm_unpacklo_epi16(this_out[6], this_out[7]); 2590 const __m128i tr0_6 = _mm_unpackhi_epi16(this_out[4], this_out[5]); 2591 const __m128i tr0_7 = _mm_unpackhi_epi16(this_out[6], this_out[7]); 2592 // 00 10 01 11 02 12 03 13 2593 // 20 30 21 31 22 32 23 33 2594 // 04 14 05 15 06 16 07 17 2595 // 24 34 25 35 26 36 27 37 2596 // 40 50 41 51 42 52 43 53 2597 // 60 70 61 71 62 72 63 73 2598 // 54 54 55 55 56 56 57 57 2599 // 64 74 65 75 66 76 67 77 2600 const __m128i tr1_0 = _mm_unpacklo_epi32(tr0_0, tr0_1); 2601 const __m128i tr1_1 = _mm_unpacklo_epi32(tr0_2, tr0_3); 2602 const __m128i tr1_2 = _mm_unpackhi_epi32(tr0_0, tr0_1); 2603 const __m128i tr1_3 = _mm_unpackhi_epi32(tr0_2, tr0_3); 2604 const __m128i tr1_4 = _mm_unpacklo_epi32(tr0_4, tr0_5); 2605 const __m128i tr1_5 = _mm_unpacklo_epi32(tr0_6, tr0_7); 2606 const __m128i tr1_6 = _mm_unpackhi_epi32(tr0_4, tr0_5); 2607 const __m128i tr1_7 = _mm_unpackhi_epi32(tr0_6, tr0_7); 2608 // 00 10 20 30 01 11 21 31 2609 // 40 50 60 70 41 51 61 71 2610 // 02 12 22 32 03 13 23 33 2611 // 42 52 62 72 43 53 63 73 2612 // 04 14 24 34 05 15 21 36 2613 // 44 54 64 74 45 55 61 76 2614 // 06 16 26 36 07 17 27 37 2615 // 46 56 66 76 47 57 67 77 2616 __m128i tr2_0 = _mm_unpacklo_epi64(tr1_0, tr1_4); 2617 __m128i tr2_1 = _mm_unpackhi_epi64(tr1_0, tr1_4); 2618 __m128i tr2_2 = _mm_unpacklo_epi64(tr1_2, tr1_6); 2619 __m128i tr2_3 = _mm_unpackhi_epi64(tr1_2, tr1_6); 2620 __m128i tr2_4 = _mm_unpacklo_epi64(tr1_1, tr1_5); 2621 __m128i tr2_5 = _mm_unpackhi_epi64(tr1_1, tr1_5); 2622 __m128i tr2_6 = _mm_unpacklo_epi64(tr1_3, tr1_7); 2623 __m128i tr2_7 = _mm_unpackhi_epi64(tr1_3, tr1_7); 2624 // 00 10 20 30 40 50 60 70 2625 // 01 11 21 31 41 51 61 71 2626 // 02 12 22 32 42 52 62 72 2627 // 03 13 23 33 43 53 63 73 2628 // 04 14 24 34 44 54 64 74 2629 // 05 15 25 35 45 55 65 75 2630 // 06 16 26 36 46 56 66 76 2631 // 07 17 27 37 47 57 67 77 2632 if (0 == pass) { 2633 // output[j] = (output[j] + 1 + (output[j] > 0)) >> 2; 2634 // TODO(cd): see quality impact of only doing 2635 // output[j] = (output[j] + 1) >> 2; 2636 // which would remove the code between here ... 2637 __m128i tr2_0_0 = _mm_cmpgt_epi16(tr2_0, kZero); 2638 __m128i tr2_1_0 = _mm_cmpgt_epi16(tr2_1, kZero); 2639 __m128i tr2_2_0 = _mm_cmpgt_epi16(tr2_2, kZero); 2640 __m128i tr2_3_0 = _mm_cmpgt_epi16(tr2_3, kZero); 2641 __m128i tr2_4_0 = _mm_cmpgt_epi16(tr2_4, kZero); 2642 __m128i tr2_5_0 = _mm_cmpgt_epi16(tr2_5, kZero); 2643 __m128i tr2_6_0 = _mm_cmpgt_epi16(tr2_6, kZero); 2644 __m128i tr2_7_0 = _mm_cmpgt_epi16(tr2_7, kZero); 2645 tr2_0 = _mm_sub_epi16(tr2_0, tr2_0_0); 2646 tr2_1 = _mm_sub_epi16(tr2_1, tr2_1_0); 2647 tr2_2 = _mm_sub_epi16(tr2_2, tr2_2_0); 2648 tr2_3 = _mm_sub_epi16(tr2_3, tr2_3_0); 2649 tr2_4 = _mm_sub_epi16(tr2_4, tr2_4_0); 2650 tr2_5 = _mm_sub_epi16(tr2_5, tr2_5_0); 2651 tr2_6 = _mm_sub_epi16(tr2_6, tr2_6_0); 2652 tr2_7 = _mm_sub_epi16(tr2_7, tr2_7_0); 2653 // ... and here. 2654 // PS: also change code in vp9/encoder/vp9_dct.c 2655 tr2_0 = _mm_add_epi16(tr2_0, kOne); 2656 tr2_1 = _mm_add_epi16(tr2_1, kOne); 2657 tr2_2 = _mm_add_epi16(tr2_2, kOne); 2658 tr2_3 = _mm_add_epi16(tr2_3, kOne); 2659 tr2_4 = _mm_add_epi16(tr2_4, kOne); 2660 tr2_5 = _mm_add_epi16(tr2_5, kOne); 2661 tr2_6 = _mm_add_epi16(tr2_6, kOne); 2662 tr2_7 = _mm_add_epi16(tr2_7, kOne); 2663 tr2_0 = _mm_srai_epi16(tr2_0, 2); 2664 tr2_1 = _mm_srai_epi16(tr2_1, 2); 2665 tr2_2 = _mm_srai_epi16(tr2_2, 2); 2666 tr2_3 = _mm_srai_epi16(tr2_3, 2); 2667 tr2_4 = _mm_srai_epi16(tr2_4, 2); 2668 tr2_5 = _mm_srai_epi16(tr2_5, 2); 2669 tr2_6 = _mm_srai_epi16(tr2_6, 2); 2670 tr2_7 = _mm_srai_epi16(tr2_7, 2); 2671 } 2672 // Note: even though all these stores are aligned, using the aligned 2673 // intrinsic make the code slightly slower. 2674 _mm_storeu_si128((__m128i *)(output + 0 * 32), tr2_0); 2675 _mm_storeu_si128((__m128i *)(output + 1 * 32), tr2_1); 2676 _mm_storeu_si128((__m128i *)(output + 2 * 32), tr2_2); 2677 _mm_storeu_si128((__m128i *)(output + 3 * 32), tr2_3); 2678 _mm_storeu_si128((__m128i *)(output + 4 * 32), tr2_4); 2679 _mm_storeu_si128((__m128i *)(output + 5 * 32), tr2_5); 2680 _mm_storeu_si128((__m128i *)(output + 6 * 32), tr2_6); 2681 _mm_storeu_si128((__m128i *)(output + 7 * 32), tr2_7); 2682 // Process next 8x8 2683 output += 8; 2684 } 2685 } 2686 } 2687 } 2688 } // NOLINT 2689