highbd_inv_txfm_sse4.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2017 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VPX_VPX_DSP_X86_HIGHBD_INV_TXFM_SSE4_H_
  11. #define VPX_VPX_DSP_X86_HIGHBD_INV_TXFM_SSE4_H_
  12. #include <smmintrin.h> // SSE4.1
  13. #include "./vpx_config.h"
  14. #include "vpx_dsp/x86/highbd_inv_txfm_sse2.h"
  15. static INLINE __m128i multiplication_round_shift_sse4_1(
  16. const __m128i *const in /*in[2]*/, const int c) {
  17. const __m128i pair_c = pair_set_epi32(c * 4, 0);
  18. __m128i t0, t1;
  19. t0 = _mm_mul_epi32(in[0], pair_c);
  20. t1 = _mm_mul_epi32(in[1], pair_c);
  21. t0 = dct_const_round_shift_64bit(t0);
  22. t1 = dct_const_round_shift_64bit(t1);
  23. return pack_4(t0, t1);
  24. }
  25. static INLINE void highbd_butterfly_sse4_1(const __m128i in0, const __m128i in1,
  26. const int c0, const int c1,
  27. __m128i *const out0,
  28. __m128i *const out1) {
  29. const __m128i pair_c0 = pair_set_epi32(4 * c0, 0);
  30. const __m128i pair_c1 = pair_set_epi32(4 * c1, 0);
  31. __m128i temp1[4], temp2[4];
  32. extend_64bit(in0, temp1);
  33. extend_64bit(in1, temp2);
  34. temp1[2] = _mm_mul_epi32(temp1[0], pair_c1);
  35. temp1[3] = _mm_mul_epi32(temp1[1], pair_c1);
  36. temp1[0] = _mm_mul_epi32(temp1[0], pair_c0);
  37. temp1[1] = _mm_mul_epi32(temp1[1], pair_c0);
  38. temp2[2] = _mm_mul_epi32(temp2[0], pair_c0);
  39. temp2[3] = _mm_mul_epi32(temp2[1], pair_c0);
  40. temp2[0] = _mm_mul_epi32(temp2[0], pair_c1);
  41. temp2[1] = _mm_mul_epi32(temp2[1], pair_c1);
  42. temp1[0] = _mm_sub_epi64(temp1[0], temp2[0]);
  43. temp1[1] = _mm_sub_epi64(temp1[1], temp2[1]);
  44. temp2[0] = _mm_add_epi64(temp1[2], temp2[2]);
  45. temp2[1] = _mm_add_epi64(temp1[3], temp2[3]);
  46. temp1[0] = dct_const_round_shift_64bit(temp1[0]);
  47. temp1[1] = dct_const_round_shift_64bit(temp1[1]);
  48. temp2[0] = dct_const_round_shift_64bit(temp2[0]);
  49. temp2[1] = dct_const_round_shift_64bit(temp2[1]);
  50. *out0 = pack_4(temp1[0], temp1[1]);
  51. *out1 = pack_4(temp2[0], temp2[1]);
  52. }
  53. static INLINE void highbd_butterfly_cospi16_sse4_1(const __m128i in0,
  54. const __m128i in1,
  55. __m128i *const out0,
  56. __m128i *const out1) {
  57. __m128i temp1[2], temp2;
  58. temp2 = _mm_add_epi32(in0, in1);
  59. extend_64bit(temp2, temp1);
  60. *out0 = multiplication_round_shift_sse4_1(temp1, cospi_16_64);
  61. temp2 = _mm_sub_epi32(in0, in1);
  62. extend_64bit(temp2, temp1);
  63. *out1 = multiplication_round_shift_sse4_1(temp1, cospi_16_64);
  64. }
  65. static INLINE void highbd_partial_butterfly_sse4_1(const __m128i in,
  66. const int c0, const int c1,
  67. __m128i *const out0,
  68. __m128i *const out1) {
  69. __m128i temp[2];
  70. extend_64bit(in, temp);
  71. *out0 = multiplication_round_shift_sse4_1(temp, c0);
  72. *out1 = multiplication_round_shift_sse4_1(temp, c1);
  73. }
  74. static INLINE void highbd_idct4_sse4_1(__m128i *const io) {
  75. __m128i temp[2], step[4];
  76. transpose_32bit_4x4(io, io);
  77. // stage 1
  78. temp[0] = _mm_add_epi32(io[0], io[2]); // input[0] + input[2]
  79. extend_64bit(temp[0], temp);
  80. step[0] = multiplication_round_shift_sse4_1(temp, cospi_16_64);
  81. temp[0] = _mm_sub_epi32(io[0], io[2]); // input[0] - input[2]
  82. extend_64bit(temp[0], temp);
  83. step[1] = multiplication_round_shift_sse4_1(temp, cospi_16_64);
  84. highbd_butterfly_sse4_1(io[1], io[3], cospi_24_64, cospi_8_64, &step[2],
  85. &step[3]);
  86. // stage 2
  87. io[0] = _mm_add_epi32(step[0], step[3]); // step[0] + step[3]
  88. io[1] = _mm_add_epi32(step[1], step[2]); // step[1] + step[2]
  89. io[2] = _mm_sub_epi32(step[1], step[2]); // step[1] - step[2]
  90. io[3] = _mm_sub_epi32(step[0], step[3]); // step[0] - step[3]
  91. }
  92. void vpx_highbd_idct8x8_half1d_sse4_1(__m128i *const io);
  93. void vpx_highbd_idct16_4col_sse4_1(__m128i *const io /*io[16]*/);
  94. #endif // VPX_VPX_DSP_X86_HIGHBD_INV_TXFM_SSE4_H_