1 /*
2 * Copyright (c) 2017 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <smmintrin.h> // SSE4.1
12
13 #include "./vpx_dsp_rtcd.h"
14 #include "vpx_dsp/x86/highbd_inv_txfm_sse2.h"
15 #include "vpx_dsp/x86/highbd_inv_txfm_sse4.h"
16 #include "vpx_dsp/x86/inv_txfm_sse2.h"
17 #include "vpx_dsp/x86/transpose_sse2.h"
18
highbd_idct4(__m128i * const io)19 static INLINE void highbd_idct4(__m128i *const io) {
20 __m128i temp[2], step[4];
21
22 transpose_32bit_4x4(io, io);
23
24 // stage 1
25 temp[0] = _mm_add_epi32(io[0], io[2]); // input[0] + input[2]
26 extend_64bit(temp[0], temp);
27 step[0] = multiplication_round_shift_sse4_1(temp, cospi_16_64);
28 temp[0] = _mm_sub_epi32(io[0], io[2]); // input[0] - input[2]
29 extend_64bit(temp[0], temp);
30 step[1] = multiplication_round_shift_sse4_1(temp, cospi_16_64);
31 highbd_butterfly_sse4_1(io[1], io[3], cospi_24_64, cospi_8_64, &step[2],
32 &step[3]);
33
34 // stage 2
35 io[0] = _mm_add_epi32(step[0], step[3]); // step[0] + step[3]
36 io[1] = _mm_add_epi32(step[1], step[2]); // step[1] + step[2]
37 io[2] = _mm_sub_epi32(step[1], step[2]); // step[1] - step[2]
38 io[3] = _mm_sub_epi32(step[0], step[3]); // step[0] - step[3]
39 }
40
vpx_highbd_idct4x4_16_add_sse4_1(const tran_low_t * input,uint16_t * dest,int stride,int bd)41 void vpx_highbd_idct4x4_16_add_sse4_1(const tran_low_t *input, uint16_t *dest,
42 int stride, int bd) {
43 __m128i io[4];
44
45 io[0] = _mm_load_si128((const __m128i *)(input + 0));
46 io[1] = _mm_load_si128((const __m128i *)(input + 4));
47 io[2] = _mm_load_si128((const __m128i *)(input + 8));
48 io[3] = _mm_load_si128((const __m128i *)(input + 12));
49
50 if (bd == 8) {
51 __m128i io_short[2];
52
53 io_short[0] = _mm_packs_epi32(io[0], io[1]);
54 io_short[1] = _mm_packs_epi32(io[2], io[3]);
55 idct4_sse2(io_short);
56 idct4_sse2(io_short);
57 io_short[0] = _mm_add_epi16(io_short[0], _mm_set1_epi16(8));
58 io_short[1] = _mm_add_epi16(io_short[1], _mm_set1_epi16(8));
59 io[0] = _mm_srai_epi16(io_short[0], 4);
60 io[1] = _mm_srai_epi16(io_short[1], 4);
61 } else {
62 highbd_idct4(io);
63 highbd_idct4(io);
64 io[0] = wraplow_16bit_shift4(io[0], io[1], _mm_set1_epi32(8));
65 io[1] = wraplow_16bit_shift4(io[2], io[3], _mm_set1_epi32(8));
66 }
67
68 recon_and_store_4x4(io, dest, stride, bd);
69 }
70