highbd_idct32x32_add_neon.c 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #include <arm_neon.h>
  11. #include "./vpx_dsp_rtcd.h"
  12. #include "vpx_dsp/arm/idct_neon.h"
  13. #include "vpx_dsp/inv_txfm.h"
  14. static INLINE void highbd_idct32x32_1_add_pos_kernel(uint16_t **dest,
  15. const int stride,
  16. const int16x8_t res,
  17. const int16x8_t max) {
  18. const uint16x8_t a0 = vld1q_u16(*dest);
  19. const uint16x8_t a1 = vld1q_u16(*dest + 8);
  20. const uint16x8_t a2 = vld1q_u16(*dest + 16);
  21. const uint16x8_t a3 = vld1q_u16(*dest + 24);
  22. const int16x8_t b0 = vaddq_s16(res, vreinterpretq_s16_u16(a0));
  23. const int16x8_t b1 = vaddq_s16(res, vreinterpretq_s16_u16(a1));
  24. const int16x8_t b2 = vaddq_s16(res, vreinterpretq_s16_u16(a2));
  25. const int16x8_t b3 = vaddq_s16(res, vreinterpretq_s16_u16(a3));
  26. const int16x8_t c0 = vminq_s16(b0, max);
  27. const int16x8_t c1 = vminq_s16(b1, max);
  28. const int16x8_t c2 = vminq_s16(b2, max);
  29. const int16x8_t c3 = vminq_s16(b3, max);
  30. vst1q_u16(*dest, vreinterpretq_u16_s16(c0));
  31. vst1q_u16(*dest + 8, vreinterpretq_u16_s16(c1));
  32. vst1q_u16(*dest + 16, vreinterpretq_u16_s16(c2));
  33. vst1q_u16(*dest + 24, vreinterpretq_u16_s16(c3));
  34. *dest += stride;
  35. }
  36. static INLINE void highbd_idct32x32_1_add_neg_kernel(uint16_t **dest,
  37. const int stride,
  38. const int16x8_t res) {
  39. const uint16x8_t a0 = vld1q_u16(*dest);
  40. const uint16x8_t a1 = vld1q_u16(*dest + 8);
  41. const uint16x8_t a2 = vld1q_u16(*dest + 16);
  42. const uint16x8_t a3 = vld1q_u16(*dest + 24);
  43. const int16x8_t b0 = vaddq_s16(res, vreinterpretq_s16_u16(a0));
  44. const int16x8_t b1 = vaddq_s16(res, vreinterpretq_s16_u16(a1));
  45. const int16x8_t b2 = vaddq_s16(res, vreinterpretq_s16_u16(a2));
  46. const int16x8_t b3 = vaddq_s16(res, vreinterpretq_s16_u16(a3));
  47. const uint16x8_t c0 = vqshluq_n_s16(b0, 0);
  48. const uint16x8_t c1 = vqshluq_n_s16(b1, 0);
  49. const uint16x8_t c2 = vqshluq_n_s16(b2, 0);
  50. const uint16x8_t c3 = vqshluq_n_s16(b3, 0);
  51. vst1q_u16(*dest, c0);
  52. vst1q_u16(*dest + 8, c1);
  53. vst1q_u16(*dest + 16, c2);
  54. vst1q_u16(*dest + 24, c3);
  55. *dest += stride;
  56. }
  57. void vpx_highbd_idct32x32_1_add_neon(const tran_low_t *input, uint16_t *dest,
  58. int stride, int bd) {
  59. const tran_low_t out0 = HIGHBD_WRAPLOW(
  60. dct_const_round_shift(input[0] * (tran_high_t)cospi_16_64), bd);
  61. const tran_low_t out1 = HIGHBD_WRAPLOW(
  62. dct_const_round_shift(out0 * (tran_high_t)cospi_16_64), bd);
  63. const int16_t a1 = ROUND_POWER_OF_TWO(out1, 6);
  64. const int16x8_t dc = vdupq_n_s16(a1);
  65. int i;
  66. if (a1 >= 0) {
  67. const int16x8_t max = vdupq_n_s16((1 << bd) - 1);
  68. for (i = 0; i < 8; ++i) {
  69. highbd_idct32x32_1_add_pos_kernel(&dest, stride, dc, max);
  70. highbd_idct32x32_1_add_pos_kernel(&dest, stride, dc, max);
  71. highbd_idct32x32_1_add_pos_kernel(&dest, stride, dc, max);
  72. highbd_idct32x32_1_add_pos_kernel(&dest, stride, dc, max);
  73. }
  74. } else {
  75. for (i = 0; i < 8; ++i) {
  76. highbd_idct32x32_1_add_neg_kernel(&dest, stride, dc);
  77. highbd_idct32x32_1_add_neg_kernel(&dest, stride, dc);
  78. highbd_idct32x32_1_add_neg_kernel(&dest, stride, dc);
  79. highbd_idct32x32_1_add_neg_kernel(&dest, stride, dc);
  80. }
  81. }
  82. }