highbd_idct4x4_add_neon.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2016 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/highbd_idct_neon.h"
  13. #include "vpx_dsp/arm/idct_neon.h"
  14. #include "vpx_dsp/inv_txfm.h"
  15. // res is in reverse row order
  16. static INLINE void highbd_idct4x4_1_add_kernel2(uint16_t **dest,
  17. const int stride,
  18. const int16x8_t res,
  19. const int16x8_t max) {
  20. const uint16x4_t a0 = vld1_u16(*dest);
  21. const uint16x4_t a1 = vld1_u16(*dest + stride);
  22. const int16x8_t a = vreinterpretq_s16_u16(vcombine_u16(a1, a0));
  23. // Note: In some profile tests, res is quite close to +/-32767.
  24. // We use saturating addition.
  25. const int16x8_t b = vqaddq_s16(res, a);
  26. const int16x8_t c = vminq_s16(b, max);
  27. const uint16x8_t d = vqshluq_n_s16(c, 0);
  28. vst1_u16(*dest, vget_high_u16(d));
  29. *dest += stride;
  30. vst1_u16(*dest, vget_low_u16(d));
  31. *dest += stride;
  32. }
  33. void vpx_highbd_idct4x4_1_add_neon(const tran_low_t *input, uint16_t *dest,
  34. int stride, int bd) {
  35. const int16x8_t max = vdupq_n_s16((1 << bd) - 1);
  36. const tran_low_t out0 = HIGHBD_WRAPLOW(
  37. dct_const_round_shift(input[0] * (tran_high_t)cospi_16_64), bd);
  38. const tran_low_t out1 = HIGHBD_WRAPLOW(
  39. dct_const_round_shift(out0 * (tran_high_t)cospi_16_64), bd);
  40. const int16_t a1 = ROUND_POWER_OF_TWO(out1, 4);
  41. const int16x8_t dc = vdupq_n_s16(a1);
  42. highbd_idct4x4_1_add_kernel1(&dest, stride, dc, max);
  43. highbd_idct4x4_1_add_kernel1(&dest, stride, dc, max);
  44. }
  45. void vpx_highbd_idct4x4_16_add_neon(const tran_low_t *input, uint16_t *dest,
  46. int stride, int bd) {
  47. const int16x8_t max = vdupq_n_s16((1 << bd) - 1);
  48. int16x8_t a[2];
  49. int32x4_t c[4];
  50. c[0] = vld1q_s32(input);
  51. c[1] = vld1q_s32(input + 4);
  52. c[2] = vld1q_s32(input + 8);
  53. c[3] = vld1q_s32(input + 12);
  54. if (bd == 8) {
  55. // Rows
  56. a[0] = vcombine_s16(vmovn_s32(c[0]), vmovn_s32(c[1]));
  57. a[1] = vcombine_s16(vmovn_s32(c[2]), vmovn_s32(c[3]));
  58. transpose_idct4x4_16_bd8(a);
  59. // Columns
  60. a[1] = vcombine_s16(vget_high_s16(a[1]), vget_low_s16(a[1]));
  61. transpose_idct4x4_16_bd8(a);
  62. a[0] = vrshrq_n_s16(a[0], 4);
  63. a[1] = vrshrq_n_s16(a[1], 4);
  64. } else {
  65. const int32x4_t cospis = vld1q_s32(kCospi32);
  66. if (bd == 10) {
  67. idct4x4_16_kernel_bd10(cospis, c);
  68. idct4x4_16_kernel_bd10(cospis, c);
  69. } else {
  70. idct4x4_16_kernel_bd12(cospis, c);
  71. idct4x4_16_kernel_bd12(cospis, c);
  72. }
  73. a[0] = vcombine_s16(vqrshrn_n_s32(c[0], 4), vqrshrn_n_s32(c[1], 4));
  74. a[1] = vcombine_s16(vqrshrn_n_s32(c[3], 4), vqrshrn_n_s32(c[2], 4));
  75. }
  76. highbd_idct4x4_1_add_kernel1(&dest, stride, a[0], max);
  77. highbd_idct4x4_1_add_kernel2(&dest, stride, a[1], max);
  78. }