vp9_fdct4x4_msa.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <assert.h>
  11. #include "vp9/common/vp9_enums.h"
  12. #include "vp9/encoder/mips/msa/vp9_fdct_msa.h"
  13. void vp9_fwht4x4_msa(const int16_t *input, int16_t *output,
  14. int32_t src_stride) {
  15. v8i16 in0, in1, in2, in3, in4;
  16. LD_SH4(input, src_stride, in0, in1, in2, in3);
  17. in0 += in1;
  18. in3 -= in2;
  19. in4 = (in0 - in3) >> 1;
  20. SUB2(in4, in1, in4, in2, in1, in2);
  21. in0 -= in2;
  22. in3 += in1;
  23. TRANSPOSE4x4_SH_SH(in0, in2, in3, in1, in0, in2, in3, in1);
  24. in0 += in2;
  25. in1 -= in3;
  26. in4 = (in0 - in1) >> 1;
  27. SUB2(in4, in2, in4, in3, in2, in3);
  28. in0 -= in3;
  29. in1 += in2;
  30. SLLI_4V(in0, in1, in2, in3, 2);
  31. TRANSPOSE4x4_SH_SH(in0, in3, in1, in2, in0, in3, in1, in2);
  32. ST4x2_UB(in0, output, 4);
  33. ST4x2_UB(in3, output + 4, 4);
  34. ST4x2_UB(in1, output + 8, 4);
  35. ST4x2_UB(in2, output + 12, 4);
  36. }
  37. void vp9_fht4x4_msa(const int16_t *input, int16_t *output, int32_t stride,
  38. int32_t tx_type) {
  39. v8i16 in0, in1, in2, in3;
  40. LD_SH4(input, stride, in0, in1, in2, in3);
  41. /* fdct4 pre-process */
  42. {
  43. v8i16 temp, mask;
  44. v16i8 zero = { 0 };
  45. v16i8 one = __msa_ldi_b(1);
  46. mask = (v8i16)__msa_sldi_b(zero, one, 15);
  47. SLLI_4V(in0, in1, in2, in3, 4);
  48. temp = __msa_ceqi_h(in0, 0);
  49. temp = (v8i16)__msa_xori_b((v16u8)temp, 255);
  50. temp = mask & temp;
  51. in0 += temp;
  52. }
  53. switch (tx_type) {
  54. case DCT_DCT:
  55. VP9_FDCT4(in0, in1, in2, in3, in0, in1, in2, in3);
  56. TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
  57. VP9_FDCT4(in0, in1, in2, in3, in0, in1, in2, in3);
  58. break;
  59. case ADST_DCT:
  60. VP9_FADST4(in0, in1, in2, in3, in0, in1, in2, in3);
  61. TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
  62. VP9_FDCT4(in0, in1, in2, in3, in0, in1, in2, in3);
  63. break;
  64. case DCT_ADST:
  65. VP9_FDCT4(in0, in1, in2, in3, in0, in1, in2, in3);
  66. TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
  67. VP9_FADST4(in0, in1, in2, in3, in0, in1, in2, in3);
  68. break;
  69. case ADST_ADST:
  70. VP9_FADST4(in0, in1, in2, in3, in0, in1, in2, in3);
  71. TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
  72. VP9_FADST4(in0, in1, in2, in3, in0, in1, in2, in3);
  73. break;
  74. default: assert(0); break;
  75. }
  76. TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
  77. ADD4(in0, 1, in1, 1, in2, 1, in3, 1, in0, in1, in2, in3);
  78. SRA_4V(in0, in1, in2, in3, 2);
  79. PCKEV_D2_SH(in1, in0, in3, in2, in0, in2);
  80. ST_SH2(in0, in2, output, 8);
  81. }