idct4x4_msa.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2015 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 "./vpx_dsp_rtcd.h"
  11. #include "vpx_dsp/mips/inv_txfm_msa.h"
  12. void vpx_iwht4x4_16_add_msa(const int16_t *input, uint8_t *dst,
  13. int32_t dst_stride) {
  14. v8i16 in0, in1, in2, in3;
  15. v4i32 in0_r, in1_r, in2_r, in3_r, in4_r;
  16. /* load vector elements of 4x4 block */
  17. LD4x4_SH(input, in0, in2, in3, in1);
  18. TRANSPOSE4x4_SH_SH(in0, in2, in3, in1, in0, in2, in3, in1);
  19. UNPCK_R_SH_SW(in0, in0_r);
  20. UNPCK_R_SH_SW(in2, in2_r);
  21. UNPCK_R_SH_SW(in3, in3_r);
  22. UNPCK_R_SH_SW(in1, in1_r);
  23. SRA_4V(in0_r, in1_r, in2_r, in3_r, UNIT_QUANT_SHIFT);
  24. in0_r += in2_r;
  25. in3_r -= in1_r;
  26. in4_r = (in0_r - in3_r) >> 1;
  27. in1_r = in4_r - in1_r;
  28. in2_r = in4_r - in2_r;
  29. in0_r -= in1_r;
  30. in3_r += in2_r;
  31. TRANSPOSE4x4_SW_SW(in0_r, in1_r, in2_r, in3_r, in0_r, in1_r, in2_r, in3_r);
  32. in0_r += in1_r;
  33. in2_r -= in3_r;
  34. in4_r = (in0_r - in2_r) >> 1;
  35. in3_r = in4_r - in3_r;
  36. in1_r = in4_r - in1_r;
  37. in0_r -= in3_r;
  38. in2_r += in1_r;
  39. PCKEV_H4_SH(in0_r, in0_r, in1_r, in1_r, in2_r, in2_r, in3_r, in3_r, in0, in1,
  40. in2, in3);
  41. ADDBLK_ST4x4_UB(in0, in3, in1, in2, dst, dst_stride);
  42. }
  43. void vpx_iwht4x4_1_add_msa(const int16_t *input, uint8_t *dst,
  44. int32_t dst_stride) {
  45. int16_t a1, e1;
  46. v8i16 in1, in0 = { 0 };
  47. a1 = input[0] >> UNIT_QUANT_SHIFT;
  48. e1 = a1 >> 1;
  49. a1 -= e1;
  50. in0 = __msa_insert_h(in0, 0, a1);
  51. in0 = __msa_insert_h(in0, 1, e1);
  52. in0 = __msa_insert_h(in0, 2, e1);
  53. in0 = __msa_insert_h(in0, 3, e1);
  54. in1 = in0 >> 1;
  55. in0 -= in1;
  56. ADDBLK_ST4x4_UB(in0, in1, in1, in1, dst, dst_stride);
  57. }
  58. void vpx_idct4x4_16_add_msa(const int16_t *input, uint8_t *dst,
  59. int32_t dst_stride) {
  60. v8i16 in0, in1, in2, in3;
  61. /* load vector elements of 4x4 block */
  62. LD4x4_SH(input, in0, in1, in2, in3);
  63. /* rows */
  64. TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
  65. VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3);
  66. /* columns */
  67. TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
  68. VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3);
  69. /* rounding (add 2^3, divide by 2^4) */
  70. SRARI_H4_SH(in0, in1, in2, in3, 4);
  71. ADDBLK_ST4x4_UB(in0, in1, in2, in3, dst, dst_stride);
  72. }
  73. void vpx_idct4x4_1_add_msa(const int16_t *input, uint8_t *dst,
  74. int32_t dst_stride) {
  75. int16_t out;
  76. v8i16 vec;
  77. out = ROUND_POWER_OF_TWO((input[0] * cospi_16_64), DCT_CONST_BITS);
  78. out = ROUND_POWER_OF_TWO((out * cospi_16_64), DCT_CONST_BITS);
  79. out = ROUND_POWER_OF_TWO(out, 4);
  80. vec = __msa_fill_h(out);
  81. ADDBLK_ST4x4_UB(vec, vec, vec, vec, dst, dst_stride);
  82. }