idct8x8_1_add_neon.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2014 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/inv_txfm.h"
  13. static INLINE uint8x8_t create_dcd(const int16_t dc) {
  14. int16x8_t t = vdupq_n_s16(dc);
  15. return vqmovun_s16(t);
  16. }
  17. static INLINE void idct8x8_1_add_pos_kernel(uint8_t **dest, const int stride,
  18. const uint8x8_t res) {
  19. const uint8x8_t a = vld1_u8(*dest);
  20. const uint8x8_t b = vqadd_u8(a, res);
  21. vst1_u8(*dest, b);
  22. *dest += stride;
  23. }
  24. static INLINE void idct8x8_1_add_neg_kernel(uint8_t **dest, const int stride,
  25. const uint8x8_t res) {
  26. const uint8x8_t a = vld1_u8(*dest);
  27. const uint8x8_t b = vqsub_u8(a, res);
  28. vst1_u8(*dest, b);
  29. *dest += stride;
  30. }
  31. void vpx_idct8x8_1_add_neon(const tran_low_t *input, uint8_t *dest,
  32. int stride) {
  33. const int16_t out0 =
  34. WRAPLOW(dct_const_round_shift((int16_t)input[0] * cospi_16_64));
  35. const int16_t out1 = WRAPLOW(dct_const_round_shift(out0 * cospi_16_64));
  36. const int16_t a1 = ROUND_POWER_OF_TWO(out1, 5);
  37. if (a1 >= 0) {
  38. const uint8x8_t dc = create_dcd(a1);
  39. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  40. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  41. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  42. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  43. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  44. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  45. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  46. idct8x8_1_add_pos_kernel(&dest, stride, dc);
  47. } else {
  48. const uint8x8_t dc = create_dcd(-a1);
  49. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  50. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  51. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  52. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  53. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  54. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  55. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  56. idct8x8_1_add_neg_kernel(&dest, stride, dc);
  57. }
  58. }