transpose_vsx.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #ifndef VPX_VPX_DSP_PPC_TRANSPOSE_VSX_H_
  11. #define VPX_VPX_DSP_PPC_TRANSPOSE_VSX_H_
  12. #include "./vpx_config.h"
  13. #include "vpx_dsp/ppc/types_vsx.h"
  14. static INLINE void vpx_transpose_s16_8x8(int16x8_t v[8]) {
  15. // d = vec_mergeh(a,b):
  16. // The even elements of the result are obtained left-to-right,
  17. // from the high elements of a.
  18. // The odd elements of the result are obtained left-to-right,
  19. // from the high elements of b.
  20. //
  21. // d = vec_mergel(a,b):
  22. // The even elements of the result are obtained left-to-right,
  23. // from the low elements of a.
  24. // The odd elements of the result are obtained left-to-right,
  25. // from the low elements of b.
  26. // Example, starting with:
  27. // v[0]: 00 01 02 03 04 05 06 07
  28. // v[1]: 10 11 12 13 14 15 16 17
  29. // v[2]: 20 21 22 23 24 25 26 27
  30. // v[3]: 30 31 32 33 34 35 36 37
  31. // v[4]: 40 41 42 43 44 45 46 47
  32. // v[5]: 50 51 52 53 54 55 56 57
  33. // v[6]: 60 61 62 63 64 65 66 67
  34. // v[7]: 70 71 72 73 74 75 76 77
  35. int16x8_t b0, b1, b2, b3, b4, b5, b6, b7;
  36. int16x8_t c0, c1, c2, c3, c4, c5, c6, c7;
  37. b0 = vec_mergeh(v[0], v[4]);
  38. b1 = vec_mergel(v[0], v[4]);
  39. b2 = vec_mergeh(v[1], v[5]);
  40. b3 = vec_mergel(v[1], v[5]);
  41. b4 = vec_mergeh(v[2], v[6]);
  42. b5 = vec_mergel(v[2], v[6]);
  43. b6 = vec_mergeh(v[3], v[7]);
  44. b7 = vec_mergel(v[3], v[7]);
  45. // After first merge operation
  46. // b0: 00 40 01 41 02 42 03 43
  47. // b1: 04 44 05 45 06 46 07 47
  48. // b2: 10 50 11 51 12 52 13 53
  49. // b3: 14 54 15 55 16 56 17 57
  50. // b4: 20 60 21 61 22 62 23 63
  51. // b5: 24 64 25 65 26 66 27 67
  52. // b6: 30 70 31 71 32 62 33 73
  53. // b7: 34 74 35 75 36 76 37 77
  54. c0 = vec_mergeh(b0, b4);
  55. c1 = vec_mergel(b0, b4);
  56. c2 = vec_mergeh(b1, b5);
  57. c3 = vec_mergel(b1, b5);
  58. c4 = vec_mergeh(b2, b6);
  59. c5 = vec_mergel(b2, b6);
  60. c6 = vec_mergeh(b3, b7);
  61. c7 = vec_mergel(b3, b7);
  62. // After second merge operation
  63. // c0: 00 20 40 60 01 21 41 61
  64. // c1: 02 22 42 62 03 23 43 63
  65. // c2: 04 24 44 64 05 25 45 65
  66. // c3: 06 26 46 66 07 27 47 67
  67. // c4: 10 30 50 70 11 31 51 71
  68. // c5: 12 32 52 72 13 33 53 73
  69. // c6: 14 34 54 74 15 35 55 75
  70. // c7: 16 36 56 76 17 37 57 77
  71. v[0] = vec_mergeh(c0, c4);
  72. v[1] = vec_mergel(c0, c4);
  73. v[2] = vec_mergeh(c1, c5);
  74. v[3] = vec_mergel(c1, c5);
  75. v[4] = vec_mergeh(c2, c6);
  76. v[5] = vec_mergel(c2, c6);
  77. v[6] = vec_mergeh(c3, c7);
  78. v[7] = vec_mergel(c3, c7);
  79. // After last merge operation
  80. // v[0]: 00 10 20 30 40 50 60 70
  81. // v[1]: 01 11 21 31 41 51 61 71
  82. // v[2]: 02 12 22 32 42 52 62 72
  83. // v[3]: 03 13 23 33 43 53 63 73
  84. // v[4]: 04 14 24 34 44 54 64 74
  85. // v[5]: 05 15 25 35 45 55 65 75
  86. // v[6]: 06 16 26 36 46 56 66 76
  87. // v[7]: 07 17 27 37 47 57 67 77
  88. }
  89. static INLINE void transpose_8x8(const int16x8_t *a, int16x8_t *b) {
  90. // Stage 1
  91. const int16x8_t s1_0 = vec_mergeh(a[0], a[4]);
  92. const int16x8_t s1_1 = vec_mergel(a[0], a[4]);
  93. const int16x8_t s1_2 = vec_mergeh(a[1], a[5]);
  94. const int16x8_t s1_3 = vec_mergel(a[1], a[5]);
  95. const int16x8_t s1_4 = vec_mergeh(a[2], a[6]);
  96. const int16x8_t s1_5 = vec_mergel(a[2], a[6]);
  97. const int16x8_t s1_6 = vec_mergeh(a[3], a[7]);
  98. const int16x8_t s1_7 = vec_mergel(a[3], a[7]);
  99. // Stage 2
  100. const int16x8_t s2_0 = vec_mergeh(s1_0, s1_4);
  101. const int16x8_t s2_1 = vec_mergel(s1_0, s1_4);
  102. const int16x8_t s2_2 = vec_mergeh(s1_1, s1_5);
  103. const int16x8_t s2_3 = vec_mergel(s1_1, s1_5);
  104. const int16x8_t s2_4 = vec_mergeh(s1_2, s1_6);
  105. const int16x8_t s2_5 = vec_mergel(s1_2, s1_6);
  106. const int16x8_t s2_6 = vec_mergeh(s1_3, s1_7);
  107. const int16x8_t s2_7 = vec_mergel(s1_3, s1_7);
  108. // Stage 2
  109. b[0] = vec_mergeh(s2_0, s2_4);
  110. b[1] = vec_mergel(s2_0, s2_4);
  111. b[2] = vec_mergeh(s2_1, s2_5);
  112. b[3] = vec_mergel(s2_1, s2_5);
  113. b[4] = vec_mergeh(s2_2, s2_6);
  114. b[5] = vec_mergel(s2_2, s2_6);
  115. b[6] = vec_mergeh(s2_3, s2_7);
  116. b[7] = vec_mergel(s2_3, s2_7);
  117. }
  118. #endif // VPX_VPX_DSP_PPC_TRANSPOSE_VSX_H_