highbd_idct16x16_add_neon.c 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  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. #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. static INLINE int32x4_t dct_const_round_shift_high_4(const int64x2x2_t in) {
  16. int32x2x2_t t32;
  17. t32.val[0] = vrshrn_n_s64(in.val[0], DCT_CONST_BITS);
  18. t32.val[1] = vrshrn_n_s64(in.val[1], DCT_CONST_BITS);
  19. return vcombine_s32(t32.val[0], t32.val[1]);
  20. }
  21. static INLINE void dct_const_round_shift_high_4_dual(
  22. const int64x2x2_t *const in, int32x4_t *const d0, int32x4_t *const d1) {
  23. *d0 = dct_const_round_shift_high_4(in[0]);
  24. *d1 = dct_const_round_shift_high_4(in[1]);
  25. }
  26. static INLINE int32x4x2_t
  27. dct_const_round_shift_high_4x2_int64x2x2(const int64x2x2_t *const in) {
  28. int32x4x2_t out;
  29. out.val[0] = dct_const_round_shift_high_4(in[0]);
  30. out.val[1] = dct_const_round_shift_high_4(in[1]);
  31. return out;
  32. }
  33. static INLINE void dct_const_round_shift_high_4x2x2(const int64x2x2_t *const in,
  34. int32x4x2_t *const d0,
  35. int32x4x2_t *const d1) {
  36. *d0 = dct_const_round_shift_high_4x2_int64x2x2(in + 0);
  37. *d1 = dct_const_round_shift_high_4x2_int64x2x2(in + 2);
  38. }
  39. static INLINE void highbd_idct_cospi_2_30(const int32x4x2_t s0,
  40. const int32x4x2_t s1,
  41. const int32x4_t cospi_2_30_10_22,
  42. int32x4x2_t *const d0,
  43. int32x4x2_t *const d1) {
  44. int64x2x2_t t[4];
  45. t[0].val[0] = vmull_lane_s32(vget_low_s32(s0.val[0]),
  46. vget_low_s32(cospi_2_30_10_22), 1);
  47. t[0].val[1] = vmull_lane_s32(vget_high_s32(s0.val[0]),
  48. vget_low_s32(cospi_2_30_10_22), 1);
  49. t[1].val[0] = vmull_lane_s32(vget_low_s32(s0.val[1]),
  50. vget_low_s32(cospi_2_30_10_22), 1);
  51. t[1].val[1] = vmull_lane_s32(vget_high_s32(s0.val[1]),
  52. vget_low_s32(cospi_2_30_10_22), 1);
  53. t[2].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  54. vget_low_s32(cospi_2_30_10_22), 1);
  55. t[2].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  56. vget_low_s32(cospi_2_30_10_22), 1);
  57. t[3].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  58. vget_low_s32(cospi_2_30_10_22), 1);
  59. t[3].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  60. vget_low_s32(cospi_2_30_10_22), 1);
  61. t[0].val[0] = vmlsl_lane_s32(t[0].val[0], vget_low_s32(s1.val[0]),
  62. vget_low_s32(cospi_2_30_10_22), 0);
  63. t[0].val[1] = vmlsl_lane_s32(t[0].val[1], vget_high_s32(s1.val[0]),
  64. vget_low_s32(cospi_2_30_10_22), 0);
  65. t[1].val[0] = vmlsl_lane_s32(t[1].val[0], vget_low_s32(s1.val[1]),
  66. vget_low_s32(cospi_2_30_10_22), 0);
  67. t[1].val[1] = vmlsl_lane_s32(t[1].val[1], vget_high_s32(s1.val[1]),
  68. vget_low_s32(cospi_2_30_10_22), 0);
  69. t[2].val[0] = vmlal_lane_s32(t[2].val[0], vget_low_s32(s0.val[0]),
  70. vget_low_s32(cospi_2_30_10_22), 0);
  71. t[2].val[1] = vmlal_lane_s32(t[2].val[1], vget_high_s32(s0.val[0]),
  72. vget_low_s32(cospi_2_30_10_22), 0);
  73. t[3].val[0] = vmlal_lane_s32(t[3].val[0], vget_low_s32(s0.val[1]),
  74. vget_low_s32(cospi_2_30_10_22), 0);
  75. t[3].val[1] = vmlal_lane_s32(t[3].val[1], vget_high_s32(s0.val[1]),
  76. vget_low_s32(cospi_2_30_10_22), 0);
  77. dct_const_round_shift_high_4x2x2(t, d0, d1);
  78. }
  79. static INLINE void highbd_idct_cospi_4_28(const int32x4x2_t s0,
  80. const int32x4x2_t s1,
  81. const int32x4_t cospi_4_12_20N_28,
  82. int32x4x2_t *const d0,
  83. int32x4x2_t *const d1) {
  84. int64x2x2_t t[4];
  85. t[0].val[0] = vmull_lane_s32(vget_low_s32(s0.val[0]),
  86. vget_high_s32(cospi_4_12_20N_28), 1);
  87. t[0].val[1] = vmull_lane_s32(vget_high_s32(s0.val[0]),
  88. vget_high_s32(cospi_4_12_20N_28), 1);
  89. t[1].val[0] = vmull_lane_s32(vget_low_s32(s0.val[1]),
  90. vget_high_s32(cospi_4_12_20N_28), 1);
  91. t[1].val[1] = vmull_lane_s32(vget_high_s32(s0.val[1]),
  92. vget_high_s32(cospi_4_12_20N_28), 1);
  93. t[2].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  94. vget_high_s32(cospi_4_12_20N_28), 1);
  95. t[2].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  96. vget_high_s32(cospi_4_12_20N_28), 1);
  97. t[3].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  98. vget_high_s32(cospi_4_12_20N_28), 1);
  99. t[3].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  100. vget_high_s32(cospi_4_12_20N_28), 1);
  101. t[0].val[0] = vmlsl_lane_s32(t[0].val[0], vget_low_s32(s1.val[0]),
  102. vget_low_s32(cospi_4_12_20N_28), 0);
  103. t[0].val[1] = vmlsl_lane_s32(t[0].val[1], vget_high_s32(s1.val[0]),
  104. vget_low_s32(cospi_4_12_20N_28), 0);
  105. t[1].val[0] = vmlsl_lane_s32(t[1].val[0], vget_low_s32(s1.val[1]),
  106. vget_low_s32(cospi_4_12_20N_28), 0);
  107. t[1].val[1] = vmlsl_lane_s32(t[1].val[1], vget_high_s32(s1.val[1]),
  108. vget_low_s32(cospi_4_12_20N_28), 0);
  109. t[2].val[0] = vmlal_lane_s32(t[2].val[0], vget_low_s32(s0.val[0]),
  110. vget_low_s32(cospi_4_12_20N_28), 0);
  111. t[2].val[1] = vmlal_lane_s32(t[2].val[1], vget_high_s32(s0.val[0]),
  112. vget_low_s32(cospi_4_12_20N_28), 0);
  113. t[3].val[0] = vmlal_lane_s32(t[3].val[0], vget_low_s32(s0.val[1]),
  114. vget_low_s32(cospi_4_12_20N_28), 0);
  115. t[3].val[1] = vmlal_lane_s32(t[3].val[1], vget_high_s32(s0.val[1]),
  116. vget_low_s32(cospi_4_12_20N_28), 0);
  117. dct_const_round_shift_high_4x2x2(t, d0, d1);
  118. }
  119. static INLINE void highbd_idct_cospi_6_26(const int32x4x2_t s0,
  120. const int32x4x2_t s1,
  121. const int32x4_t cospi_6_26N_14_18N,
  122. int32x4x2_t *const d0,
  123. int32x4x2_t *const d1) {
  124. int64x2x2_t t[4];
  125. t[0].val[0] = vmull_lane_s32(vget_low_s32(s0.val[0]),
  126. vget_low_s32(cospi_6_26N_14_18N), 0);
  127. t[0].val[1] = vmull_lane_s32(vget_high_s32(s0.val[0]),
  128. vget_low_s32(cospi_6_26N_14_18N), 0);
  129. t[1].val[0] = vmull_lane_s32(vget_low_s32(s0.val[1]),
  130. vget_low_s32(cospi_6_26N_14_18N), 0);
  131. t[1].val[1] = vmull_lane_s32(vget_high_s32(s0.val[1]),
  132. vget_low_s32(cospi_6_26N_14_18N), 0);
  133. t[2].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  134. vget_low_s32(cospi_6_26N_14_18N), 0);
  135. t[2].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  136. vget_low_s32(cospi_6_26N_14_18N), 0);
  137. t[3].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  138. vget_low_s32(cospi_6_26N_14_18N), 0);
  139. t[3].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  140. vget_low_s32(cospi_6_26N_14_18N), 0);
  141. t[0].val[0] = vmlal_lane_s32(t[0].val[0], vget_low_s32(s1.val[0]),
  142. vget_low_s32(cospi_6_26N_14_18N), 1);
  143. t[0].val[1] = vmlal_lane_s32(t[0].val[1], vget_high_s32(s1.val[0]),
  144. vget_low_s32(cospi_6_26N_14_18N), 1);
  145. t[1].val[0] = vmlal_lane_s32(t[1].val[0], vget_low_s32(s1.val[1]),
  146. vget_low_s32(cospi_6_26N_14_18N), 1);
  147. t[1].val[1] = vmlal_lane_s32(t[1].val[1], vget_high_s32(s1.val[1]),
  148. vget_low_s32(cospi_6_26N_14_18N), 1);
  149. t[2].val[0] = vmlsl_lane_s32(t[2].val[0], vget_low_s32(s0.val[0]),
  150. vget_low_s32(cospi_6_26N_14_18N), 1);
  151. t[2].val[1] = vmlsl_lane_s32(t[2].val[1], vget_high_s32(s0.val[0]),
  152. vget_low_s32(cospi_6_26N_14_18N), 1);
  153. t[3].val[0] = vmlsl_lane_s32(t[3].val[0], vget_low_s32(s0.val[1]),
  154. vget_low_s32(cospi_6_26N_14_18N), 1);
  155. t[3].val[1] = vmlsl_lane_s32(t[3].val[1], vget_high_s32(s0.val[1]),
  156. vget_low_s32(cospi_6_26N_14_18N), 1);
  157. dct_const_round_shift_high_4x2x2(t, d0, d1);
  158. }
  159. static INLINE void highbd_idct_cospi_10_22(const int32x4x2_t s0,
  160. const int32x4x2_t s1,
  161. const int32x4_t cospi_2_30_10_22,
  162. int32x4x2_t *const d0,
  163. int32x4x2_t *const d1) {
  164. int64x2x2_t t[4];
  165. t[0].val[0] = vmull_lane_s32(vget_low_s32(s0.val[0]),
  166. vget_high_s32(cospi_2_30_10_22), 1);
  167. t[0].val[1] = vmull_lane_s32(vget_high_s32(s0.val[0]),
  168. vget_high_s32(cospi_2_30_10_22), 1);
  169. t[1].val[0] = vmull_lane_s32(vget_low_s32(s0.val[1]),
  170. vget_high_s32(cospi_2_30_10_22), 1);
  171. t[1].val[1] = vmull_lane_s32(vget_high_s32(s0.val[1]),
  172. vget_high_s32(cospi_2_30_10_22), 1);
  173. t[2].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  174. vget_high_s32(cospi_2_30_10_22), 1);
  175. t[2].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  176. vget_high_s32(cospi_2_30_10_22), 1);
  177. t[3].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  178. vget_high_s32(cospi_2_30_10_22), 1);
  179. t[3].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  180. vget_high_s32(cospi_2_30_10_22), 1);
  181. t[0].val[0] = vmlsl_lane_s32(t[0].val[0], vget_low_s32(s1.val[0]),
  182. vget_high_s32(cospi_2_30_10_22), 0);
  183. t[0].val[1] = vmlsl_lane_s32(t[0].val[1], vget_high_s32(s1.val[0]),
  184. vget_high_s32(cospi_2_30_10_22), 0);
  185. t[1].val[0] = vmlsl_lane_s32(t[1].val[0], vget_low_s32(s1.val[1]),
  186. vget_high_s32(cospi_2_30_10_22), 0);
  187. t[1].val[1] = vmlsl_lane_s32(t[1].val[1], vget_high_s32(s1.val[1]),
  188. vget_high_s32(cospi_2_30_10_22), 0);
  189. t[2].val[0] = vmlal_lane_s32(t[2].val[0], vget_low_s32(s0.val[0]),
  190. vget_high_s32(cospi_2_30_10_22), 0);
  191. t[2].val[1] = vmlal_lane_s32(t[2].val[1], vget_high_s32(s0.val[0]),
  192. vget_high_s32(cospi_2_30_10_22), 0);
  193. t[3].val[0] = vmlal_lane_s32(t[3].val[0], vget_low_s32(s0.val[1]),
  194. vget_high_s32(cospi_2_30_10_22), 0);
  195. t[3].val[1] = vmlal_lane_s32(t[3].val[1], vget_high_s32(s0.val[1]),
  196. vget_high_s32(cospi_2_30_10_22), 0);
  197. dct_const_round_shift_high_4x2x2(t, d0, d1);
  198. }
  199. static INLINE void highbd_idct_cospi_12_20(const int32x4x2_t s0,
  200. const int32x4x2_t s1,
  201. const int32x4_t cospi_4_12_20N_28,
  202. int32x4x2_t *const d0,
  203. int32x4x2_t *const d1) {
  204. int64x2x2_t t[4];
  205. t[0].val[0] = vmull_lane_s32(vget_low_s32(s0.val[0]),
  206. vget_low_s32(cospi_4_12_20N_28), 1);
  207. t[0].val[1] = vmull_lane_s32(vget_high_s32(s0.val[0]),
  208. vget_low_s32(cospi_4_12_20N_28), 1);
  209. t[1].val[0] = vmull_lane_s32(vget_low_s32(s0.val[1]),
  210. vget_low_s32(cospi_4_12_20N_28), 1);
  211. t[1].val[1] = vmull_lane_s32(vget_high_s32(s0.val[1]),
  212. vget_low_s32(cospi_4_12_20N_28), 1);
  213. t[2].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  214. vget_low_s32(cospi_4_12_20N_28), 1);
  215. t[2].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  216. vget_low_s32(cospi_4_12_20N_28), 1);
  217. t[3].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  218. vget_low_s32(cospi_4_12_20N_28), 1);
  219. t[3].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  220. vget_low_s32(cospi_4_12_20N_28), 1);
  221. t[0].val[0] = vmlal_lane_s32(t[0].val[0], vget_low_s32(s1.val[0]),
  222. vget_high_s32(cospi_4_12_20N_28), 0);
  223. t[0].val[1] = vmlal_lane_s32(t[0].val[1], vget_high_s32(s1.val[0]),
  224. vget_high_s32(cospi_4_12_20N_28), 0);
  225. t[1].val[0] = vmlal_lane_s32(t[1].val[0], vget_low_s32(s1.val[1]),
  226. vget_high_s32(cospi_4_12_20N_28), 0);
  227. t[1].val[1] = vmlal_lane_s32(t[1].val[1], vget_high_s32(s1.val[1]),
  228. vget_high_s32(cospi_4_12_20N_28), 0);
  229. t[2].val[0] = vmlsl_lane_s32(t[2].val[0], vget_low_s32(s0.val[0]),
  230. vget_high_s32(cospi_4_12_20N_28), 0);
  231. t[2].val[1] = vmlsl_lane_s32(t[2].val[1], vget_high_s32(s0.val[0]),
  232. vget_high_s32(cospi_4_12_20N_28), 0);
  233. t[3].val[0] = vmlsl_lane_s32(t[3].val[0], vget_low_s32(s0.val[1]),
  234. vget_high_s32(cospi_4_12_20N_28), 0);
  235. t[3].val[1] = vmlsl_lane_s32(t[3].val[1], vget_high_s32(s0.val[1]),
  236. vget_high_s32(cospi_4_12_20N_28), 0);
  237. dct_const_round_shift_high_4x2x2(t, d0, d1);
  238. }
  239. static INLINE void highbd_idct_cospi_14_18(const int32x4x2_t s0,
  240. const int32x4x2_t s1,
  241. const int32x4_t cospi_6_26N_14_18N,
  242. int32x4x2_t *const d0,
  243. int32x4x2_t *const d1) {
  244. int64x2x2_t t[4];
  245. t[0].val[0] = vmull_lane_s32(vget_low_s32(s0.val[0]),
  246. vget_high_s32(cospi_6_26N_14_18N), 0);
  247. t[0].val[1] = vmull_lane_s32(vget_high_s32(s0.val[0]),
  248. vget_high_s32(cospi_6_26N_14_18N), 0);
  249. t[1].val[0] = vmull_lane_s32(vget_low_s32(s0.val[1]),
  250. vget_high_s32(cospi_6_26N_14_18N), 0);
  251. t[1].val[1] = vmull_lane_s32(vget_high_s32(s0.val[1]),
  252. vget_high_s32(cospi_6_26N_14_18N), 0);
  253. t[2].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  254. vget_high_s32(cospi_6_26N_14_18N), 0);
  255. t[2].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  256. vget_high_s32(cospi_6_26N_14_18N), 0);
  257. t[3].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  258. vget_high_s32(cospi_6_26N_14_18N), 0);
  259. t[3].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  260. vget_high_s32(cospi_6_26N_14_18N), 0);
  261. t[0].val[0] = vmlal_lane_s32(t[0].val[0], vget_low_s32(s1.val[0]),
  262. vget_high_s32(cospi_6_26N_14_18N), 1);
  263. t[0].val[1] = vmlal_lane_s32(t[0].val[1], vget_high_s32(s1.val[0]),
  264. vget_high_s32(cospi_6_26N_14_18N), 1);
  265. t[1].val[0] = vmlal_lane_s32(t[1].val[0], vget_low_s32(s1.val[1]),
  266. vget_high_s32(cospi_6_26N_14_18N), 1);
  267. t[1].val[1] = vmlal_lane_s32(t[1].val[1], vget_high_s32(s1.val[1]),
  268. vget_high_s32(cospi_6_26N_14_18N), 1);
  269. t[2].val[0] = vmlsl_lane_s32(t[2].val[0], vget_low_s32(s0.val[0]),
  270. vget_high_s32(cospi_6_26N_14_18N), 1);
  271. t[2].val[1] = vmlsl_lane_s32(t[2].val[1], vget_high_s32(s0.val[0]),
  272. vget_high_s32(cospi_6_26N_14_18N), 1);
  273. t[3].val[0] = vmlsl_lane_s32(t[3].val[0], vget_low_s32(s0.val[1]),
  274. vget_high_s32(cospi_6_26N_14_18N), 1);
  275. t[3].val[1] = vmlsl_lane_s32(t[3].val[1], vget_high_s32(s0.val[1]),
  276. vget_high_s32(cospi_6_26N_14_18N), 1);
  277. dct_const_round_shift_high_4x2x2(t, d0, d1);
  278. }
  279. static INLINE void highbd_idct_cospi_8_24_q_kernel(
  280. const int32x4x2_t s0, const int32x4x2_t s1, const int32x4_t cospi_0_8_16_24,
  281. int64x2x2_t *const t) {
  282. t[0].val[0] = vmull_lane_s32(vget_low_s32(s0.val[0]),
  283. vget_high_s32(cospi_0_8_16_24), 1);
  284. t[0].val[1] = vmull_lane_s32(vget_high_s32(s0.val[0]),
  285. vget_high_s32(cospi_0_8_16_24), 1);
  286. t[1].val[0] = vmull_lane_s32(vget_low_s32(s0.val[1]),
  287. vget_high_s32(cospi_0_8_16_24), 1);
  288. t[1].val[1] = vmull_lane_s32(vget_high_s32(s0.val[1]),
  289. vget_high_s32(cospi_0_8_16_24), 1);
  290. t[2].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  291. vget_high_s32(cospi_0_8_16_24), 1);
  292. t[2].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  293. vget_high_s32(cospi_0_8_16_24), 1);
  294. t[3].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  295. vget_high_s32(cospi_0_8_16_24), 1);
  296. t[3].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  297. vget_high_s32(cospi_0_8_16_24), 1);
  298. t[0].val[0] = vmlsl_lane_s32(t[0].val[0], vget_low_s32(s1.val[0]),
  299. vget_low_s32(cospi_0_8_16_24), 1);
  300. t[0].val[1] = vmlsl_lane_s32(t[0].val[1], vget_high_s32(s1.val[0]),
  301. vget_low_s32(cospi_0_8_16_24), 1);
  302. t[1].val[0] = vmlsl_lane_s32(t[1].val[0], vget_low_s32(s1.val[1]),
  303. vget_low_s32(cospi_0_8_16_24), 1);
  304. t[1].val[1] = vmlsl_lane_s32(t[1].val[1], vget_high_s32(s1.val[1]),
  305. vget_low_s32(cospi_0_8_16_24), 1);
  306. t[2].val[0] = vmlal_lane_s32(t[2].val[0], vget_low_s32(s0.val[0]),
  307. vget_low_s32(cospi_0_8_16_24), 1);
  308. t[2].val[1] = vmlal_lane_s32(t[2].val[1], vget_high_s32(s0.val[0]),
  309. vget_low_s32(cospi_0_8_16_24), 1);
  310. t[3].val[0] = vmlal_lane_s32(t[3].val[0], vget_low_s32(s0.val[1]),
  311. vget_low_s32(cospi_0_8_16_24), 1);
  312. t[3].val[1] = vmlal_lane_s32(t[3].val[1], vget_high_s32(s0.val[1]),
  313. vget_low_s32(cospi_0_8_16_24), 1);
  314. }
  315. static INLINE void highbd_idct_cospi_8_24_d_kernel(
  316. const int32x4_t s0, const int32x4_t s1, const int32x4_t cospi_0_8_16_24,
  317. int64x2x2_t *const t) {
  318. t[0].val[0] =
  319. vmull_lane_s32(vget_low_s32(s0), vget_high_s32(cospi_0_8_16_24), 1);
  320. t[0].val[1] =
  321. vmull_lane_s32(vget_high_s32(s0), vget_high_s32(cospi_0_8_16_24), 1);
  322. t[1].val[0] =
  323. vmull_lane_s32(vget_low_s32(s1), vget_high_s32(cospi_0_8_16_24), 1);
  324. t[1].val[1] =
  325. vmull_lane_s32(vget_high_s32(s1), vget_high_s32(cospi_0_8_16_24), 1);
  326. t[0].val[0] = vmlsl_lane_s32(t[0].val[0], vget_low_s32(s1),
  327. vget_low_s32(cospi_0_8_16_24), 1);
  328. t[0].val[1] = vmlsl_lane_s32(t[0].val[1], vget_high_s32(s1),
  329. vget_low_s32(cospi_0_8_16_24), 1);
  330. t[1].val[0] = vmlal_lane_s32(t[1].val[0], vget_low_s32(s0),
  331. vget_low_s32(cospi_0_8_16_24), 1);
  332. t[1].val[1] = vmlal_lane_s32(t[1].val[1], vget_high_s32(s0),
  333. vget_low_s32(cospi_0_8_16_24), 1);
  334. }
  335. static INLINE void highbd_idct_cospi_8_24_q(const int32x4x2_t s0,
  336. const int32x4x2_t s1,
  337. const int32x4_t cospi_0_8_16_24,
  338. int32x4x2_t *const d0,
  339. int32x4x2_t *const d1) {
  340. int64x2x2_t t[4];
  341. highbd_idct_cospi_8_24_q_kernel(s0, s1, cospi_0_8_16_24, t);
  342. dct_const_round_shift_high_4x2x2(t, d0, d1);
  343. }
  344. static INLINE void highbd_idct_cospi_8_24_d(const int32x4_t s0,
  345. const int32x4_t s1,
  346. const int32x4_t cospi_0_8_16_24,
  347. int32x4_t *const d0,
  348. int32x4_t *const d1) {
  349. int64x2x2_t t[2];
  350. highbd_idct_cospi_8_24_d_kernel(s0, s1, cospi_0_8_16_24, t);
  351. dct_const_round_shift_high_4_dual(t, d0, d1);
  352. }
  353. static INLINE void highbd_idct_cospi_8_24_neg_q(const int32x4x2_t s0,
  354. const int32x4x2_t s1,
  355. const int32x4_t cospi_0_8_16_24,
  356. int32x4x2_t *const d0,
  357. int32x4x2_t *const d1) {
  358. int64x2x2_t t[4];
  359. highbd_idct_cospi_8_24_q_kernel(s0, s1, cospi_0_8_16_24, t);
  360. t[2].val[0] = vsubq_s64(vdupq_n_s64(0), t[2].val[0]);
  361. t[2].val[1] = vsubq_s64(vdupq_n_s64(0), t[2].val[1]);
  362. t[3].val[0] = vsubq_s64(vdupq_n_s64(0), t[3].val[0]);
  363. t[3].val[1] = vsubq_s64(vdupq_n_s64(0), t[3].val[1]);
  364. dct_const_round_shift_high_4x2x2(t, d0, d1);
  365. }
  366. static INLINE void highbd_idct_cospi_8_24_neg_d(const int32x4_t s0,
  367. const int32x4_t s1,
  368. const int32x4_t cospi_0_8_16_24,
  369. int32x4_t *const d0,
  370. int32x4_t *const d1) {
  371. int64x2x2_t t[2];
  372. highbd_idct_cospi_8_24_d_kernel(s0, s1, cospi_0_8_16_24, t);
  373. t[1].val[0] = vsubq_s64(vdupq_n_s64(0), t[1].val[0]);
  374. t[1].val[1] = vsubq_s64(vdupq_n_s64(0), t[1].val[1]);
  375. dct_const_round_shift_high_4_dual(t, d0, d1);
  376. }
  377. static INLINE void highbd_idct_cospi_16_16_q(const int32x4x2_t s0,
  378. const int32x4x2_t s1,
  379. const int32x4_t cospi_0_8_16_24,
  380. int32x4x2_t *const d0,
  381. int32x4x2_t *const d1) {
  382. int64x2x2_t t[6];
  383. t[4].val[0] = vmull_lane_s32(vget_low_s32(s1.val[0]),
  384. vget_high_s32(cospi_0_8_16_24), 0);
  385. t[4].val[1] = vmull_lane_s32(vget_high_s32(s1.val[0]),
  386. vget_high_s32(cospi_0_8_16_24), 0);
  387. t[5].val[0] = vmull_lane_s32(vget_low_s32(s1.val[1]),
  388. vget_high_s32(cospi_0_8_16_24), 0);
  389. t[5].val[1] = vmull_lane_s32(vget_high_s32(s1.val[1]),
  390. vget_high_s32(cospi_0_8_16_24), 0);
  391. t[0].val[0] = vmlsl_lane_s32(t[4].val[0], vget_low_s32(s0.val[0]),
  392. vget_high_s32(cospi_0_8_16_24), 0);
  393. t[0].val[1] = vmlsl_lane_s32(t[4].val[1], vget_high_s32(s0.val[0]),
  394. vget_high_s32(cospi_0_8_16_24), 0);
  395. t[1].val[0] = vmlsl_lane_s32(t[5].val[0], vget_low_s32(s0.val[1]),
  396. vget_high_s32(cospi_0_8_16_24), 0);
  397. t[1].val[1] = vmlsl_lane_s32(t[5].val[1], vget_high_s32(s0.val[1]),
  398. vget_high_s32(cospi_0_8_16_24), 0);
  399. t[2].val[0] = vmlal_lane_s32(t[4].val[0], vget_low_s32(s0.val[0]),
  400. vget_high_s32(cospi_0_8_16_24), 0);
  401. t[2].val[1] = vmlal_lane_s32(t[4].val[1], vget_high_s32(s0.val[0]),
  402. vget_high_s32(cospi_0_8_16_24), 0);
  403. t[3].val[0] = vmlal_lane_s32(t[5].val[0], vget_low_s32(s0.val[1]),
  404. vget_high_s32(cospi_0_8_16_24), 0);
  405. t[3].val[1] = vmlal_lane_s32(t[5].val[1], vget_high_s32(s0.val[1]),
  406. vget_high_s32(cospi_0_8_16_24), 0);
  407. dct_const_round_shift_high_4x2x2(t, d0, d1);
  408. }
  409. static INLINE void highbd_idct_cospi_16_16_d(const int32x4_t s0,
  410. const int32x4_t s1,
  411. const int32x4_t cospi_0_8_16_24,
  412. int32x4_t *const d0,
  413. int32x4_t *const d1) {
  414. int64x2x2_t t[3];
  415. t[2].val[0] =
  416. vmull_lane_s32(vget_low_s32(s1), vget_high_s32(cospi_0_8_16_24), 0);
  417. t[2].val[1] =
  418. vmull_lane_s32(vget_high_s32(s1), vget_high_s32(cospi_0_8_16_24), 0);
  419. t[0].val[0] = vmlsl_lane_s32(t[2].val[0], vget_low_s32(s0),
  420. vget_high_s32(cospi_0_8_16_24), 0);
  421. t[0].val[1] = vmlsl_lane_s32(t[2].val[1], vget_high_s32(s0),
  422. vget_high_s32(cospi_0_8_16_24), 0);
  423. t[1].val[0] = vmlal_lane_s32(t[2].val[0], vget_low_s32(s0),
  424. vget_high_s32(cospi_0_8_16_24), 0);
  425. t[1].val[1] = vmlal_lane_s32(t[2].val[1], vget_high_s32(s0),
  426. vget_high_s32(cospi_0_8_16_24), 0);
  427. dct_const_round_shift_high_4_dual(t, d0, d1);
  428. }
  429. static INLINE void highbd_idct16x16_add_stage7_dual(
  430. const int32x4x2_t *const step2, int32x4x2_t *const out) {
  431. out[0].val[0] = vaddq_s32(step2[0].val[0], step2[15].val[0]);
  432. out[0].val[1] = vaddq_s32(step2[0].val[1], step2[15].val[1]);
  433. out[1].val[0] = vaddq_s32(step2[1].val[0], step2[14].val[0]);
  434. out[1].val[1] = vaddq_s32(step2[1].val[1], step2[14].val[1]);
  435. out[2].val[0] = vaddq_s32(step2[2].val[0], step2[13].val[0]);
  436. out[2].val[1] = vaddq_s32(step2[2].val[1], step2[13].val[1]);
  437. out[3].val[0] = vaddq_s32(step2[3].val[0], step2[12].val[0]);
  438. out[3].val[1] = vaddq_s32(step2[3].val[1], step2[12].val[1]);
  439. out[4].val[0] = vaddq_s32(step2[4].val[0], step2[11].val[0]);
  440. out[4].val[1] = vaddq_s32(step2[4].val[1], step2[11].val[1]);
  441. out[5].val[0] = vaddq_s32(step2[5].val[0], step2[10].val[0]);
  442. out[5].val[1] = vaddq_s32(step2[5].val[1], step2[10].val[1]);
  443. out[6].val[0] = vaddq_s32(step2[6].val[0], step2[9].val[0]);
  444. out[6].val[1] = vaddq_s32(step2[6].val[1], step2[9].val[1]);
  445. out[7].val[0] = vaddq_s32(step2[7].val[0], step2[8].val[0]);
  446. out[7].val[1] = vaddq_s32(step2[7].val[1], step2[8].val[1]);
  447. out[8].val[0] = vsubq_s32(step2[7].val[0], step2[8].val[0]);
  448. out[8].val[1] = vsubq_s32(step2[7].val[1], step2[8].val[1]);
  449. out[9].val[0] = vsubq_s32(step2[6].val[0], step2[9].val[0]);
  450. out[9].val[1] = vsubq_s32(step2[6].val[1], step2[9].val[1]);
  451. out[10].val[0] = vsubq_s32(step2[5].val[0], step2[10].val[0]);
  452. out[10].val[1] = vsubq_s32(step2[5].val[1], step2[10].val[1]);
  453. out[11].val[0] = vsubq_s32(step2[4].val[0], step2[11].val[0]);
  454. out[11].val[1] = vsubq_s32(step2[4].val[1], step2[11].val[1]);
  455. out[12].val[0] = vsubq_s32(step2[3].val[0], step2[12].val[0]);
  456. out[12].val[1] = vsubq_s32(step2[3].val[1], step2[12].val[1]);
  457. out[13].val[0] = vsubq_s32(step2[2].val[0], step2[13].val[0]);
  458. out[13].val[1] = vsubq_s32(step2[2].val[1], step2[13].val[1]);
  459. out[14].val[0] = vsubq_s32(step2[1].val[0], step2[14].val[0]);
  460. out[14].val[1] = vsubq_s32(step2[1].val[1], step2[14].val[1]);
  461. out[15].val[0] = vsubq_s32(step2[0].val[0], step2[15].val[0]);
  462. out[15].val[1] = vsubq_s32(step2[0].val[1], step2[15].val[1]);
  463. }
  464. static INLINE void highbd_idct16x16_add_stage7(const int32x4_t *const step2,
  465. int32x4_t *const out) {
  466. out[0] = vaddq_s32(step2[0], step2[15]);
  467. out[1] = vaddq_s32(step2[1], step2[14]);
  468. out[2] = vaddq_s32(step2[2], step2[13]);
  469. out[3] = vaddq_s32(step2[3], step2[12]);
  470. out[4] = vaddq_s32(step2[4], step2[11]);
  471. out[5] = vaddq_s32(step2[5], step2[10]);
  472. out[6] = vaddq_s32(step2[6], step2[9]);
  473. out[7] = vaddq_s32(step2[7], step2[8]);
  474. out[8] = vsubq_s32(step2[7], step2[8]);
  475. out[9] = vsubq_s32(step2[6], step2[9]);
  476. out[10] = vsubq_s32(step2[5], step2[10]);
  477. out[11] = vsubq_s32(step2[4], step2[11]);
  478. out[12] = vsubq_s32(step2[3], step2[12]);
  479. out[13] = vsubq_s32(step2[2], step2[13]);
  480. out[14] = vsubq_s32(step2[1], step2[14]);
  481. out[15] = vsubq_s32(step2[0], step2[15]);
  482. }
  483. void vpx_highbd_idct16x16_256_add_half1d(const int32_t *input, int32_t *output,
  484. uint16_t *dest, const int stride,
  485. const int bd) {
  486. const int32x4_t cospi_0_8_16_24 = vld1q_s32(kCospi32 + 0);
  487. const int32x4_t cospi_4_12_20N_28 = vld1q_s32(kCospi32 + 4);
  488. const int32x4_t cospi_2_30_10_22 = vld1q_s32(kCospi32 + 8);
  489. const int32x4_t cospi_6_26N_14_18N = vld1q_s32(kCospi32 + 12);
  490. int32x4x2_t in[16], step1[16], step2[16], out[16];
  491. // Load input (16x8)
  492. in[0].val[0] = vld1q_s32(input);
  493. in[0].val[1] = vld1q_s32(input + 4);
  494. input += 8;
  495. in[8].val[0] = vld1q_s32(input);
  496. in[8].val[1] = vld1q_s32(input + 4);
  497. input += 8;
  498. in[1].val[0] = vld1q_s32(input);
  499. in[1].val[1] = vld1q_s32(input + 4);
  500. input += 8;
  501. in[9].val[0] = vld1q_s32(input);
  502. in[9].val[1] = vld1q_s32(input + 4);
  503. input += 8;
  504. in[2].val[0] = vld1q_s32(input);
  505. in[2].val[1] = vld1q_s32(input + 4);
  506. input += 8;
  507. in[10].val[0] = vld1q_s32(input);
  508. in[10].val[1] = vld1q_s32(input + 4);
  509. input += 8;
  510. in[3].val[0] = vld1q_s32(input);
  511. in[3].val[1] = vld1q_s32(input + 4);
  512. input += 8;
  513. in[11].val[0] = vld1q_s32(input);
  514. in[11].val[1] = vld1q_s32(input + 4);
  515. input += 8;
  516. in[4].val[0] = vld1q_s32(input);
  517. in[4].val[1] = vld1q_s32(input + 4);
  518. input += 8;
  519. in[12].val[0] = vld1q_s32(input);
  520. in[12].val[1] = vld1q_s32(input + 4);
  521. input += 8;
  522. in[5].val[0] = vld1q_s32(input);
  523. in[5].val[1] = vld1q_s32(input + 4);
  524. input += 8;
  525. in[13].val[0] = vld1q_s32(input);
  526. in[13].val[1] = vld1q_s32(input + 4);
  527. input += 8;
  528. in[6].val[0] = vld1q_s32(input);
  529. in[6].val[1] = vld1q_s32(input + 4);
  530. input += 8;
  531. in[14].val[0] = vld1q_s32(input);
  532. in[14].val[1] = vld1q_s32(input + 4);
  533. input += 8;
  534. in[7].val[0] = vld1q_s32(input);
  535. in[7].val[1] = vld1q_s32(input + 4);
  536. input += 8;
  537. in[15].val[0] = vld1q_s32(input);
  538. in[15].val[1] = vld1q_s32(input + 4);
  539. // Transpose
  540. transpose_s32_8x8(&in[0], &in[1], &in[2], &in[3], &in[4], &in[5], &in[6],
  541. &in[7]);
  542. transpose_s32_8x8(&in[8], &in[9], &in[10], &in[11], &in[12], &in[13], &in[14],
  543. &in[15]);
  544. // stage 1
  545. step1[0] = in[0 / 2];
  546. step1[1] = in[16 / 2];
  547. step1[2] = in[8 / 2];
  548. step1[3] = in[24 / 2];
  549. step1[4] = in[4 / 2];
  550. step1[5] = in[20 / 2];
  551. step1[6] = in[12 / 2];
  552. step1[7] = in[28 / 2];
  553. step1[8] = in[2 / 2];
  554. step1[9] = in[18 / 2];
  555. step1[10] = in[10 / 2];
  556. step1[11] = in[26 / 2];
  557. step1[12] = in[6 / 2];
  558. step1[13] = in[22 / 2];
  559. step1[14] = in[14 / 2];
  560. step1[15] = in[30 / 2];
  561. // stage 2
  562. step2[0] = step1[0];
  563. step2[1] = step1[1];
  564. step2[2] = step1[2];
  565. step2[3] = step1[3];
  566. step2[4] = step1[4];
  567. step2[5] = step1[5];
  568. step2[6] = step1[6];
  569. step2[7] = step1[7];
  570. highbd_idct_cospi_2_30(step1[8], step1[15], cospi_2_30_10_22, &step2[8],
  571. &step2[15]);
  572. highbd_idct_cospi_14_18(step1[9], step1[14], cospi_6_26N_14_18N, &step2[9],
  573. &step2[14]);
  574. highbd_idct_cospi_10_22(step1[10], step1[13], cospi_2_30_10_22, &step2[10],
  575. &step2[13]);
  576. highbd_idct_cospi_6_26(step1[11], step1[12], cospi_6_26N_14_18N, &step2[11],
  577. &step2[12]);
  578. // stage 3
  579. step1[0] = step2[0];
  580. step1[1] = step2[1];
  581. step1[2] = step2[2];
  582. step1[3] = step2[3];
  583. highbd_idct_cospi_4_28(step2[4], step2[7], cospi_4_12_20N_28, &step1[4],
  584. &step1[7]);
  585. highbd_idct_cospi_12_20(step2[5], step2[6], cospi_4_12_20N_28, &step1[5],
  586. &step1[6]);
  587. step1[8].val[0] = vaddq_s32(step2[8].val[0], step2[9].val[0]);
  588. step1[8].val[1] = vaddq_s32(step2[8].val[1], step2[9].val[1]);
  589. step1[9].val[0] = vsubq_s32(step2[8].val[0], step2[9].val[0]);
  590. step1[9].val[1] = vsubq_s32(step2[8].val[1], step2[9].val[1]);
  591. step1[10].val[0] = vsubq_s32(step2[11].val[0], step2[10].val[0]);
  592. step1[10].val[1] = vsubq_s32(step2[11].val[1], step2[10].val[1]);
  593. step1[11].val[0] = vaddq_s32(step2[11].val[0], step2[10].val[0]);
  594. step1[11].val[1] = vaddq_s32(step2[11].val[1], step2[10].val[1]);
  595. step1[12].val[0] = vaddq_s32(step2[12].val[0], step2[13].val[0]);
  596. step1[12].val[1] = vaddq_s32(step2[12].val[1], step2[13].val[1]);
  597. step1[13].val[0] = vsubq_s32(step2[12].val[0], step2[13].val[0]);
  598. step1[13].val[1] = vsubq_s32(step2[12].val[1], step2[13].val[1]);
  599. step1[14].val[0] = vsubq_s32(step2[15].val[0], step2[14].val[0]);
  600. step1[14].val[1] = vsubq_s32(step2[15].val[1], step2[14].val[1]);
  601. step1[15].val[0] = vaddq_s32(step2[15].val[0], step2[14].val[0]);
  602. step1[15].val[1] = vaddq_s32(step2[15].val[1], step2[14].val[1]);
  603. // stage 4
  604. highbd_idct_cospi_16_16_q(step1[1], step1[0], cospi_0_8_16_24, &step2[1],
  605. &step2[0]);
  606. highbd_idct_cospi_8_24_q(step1[2], step1[3], cospi_0_8_16_24, &step2[2],
  607. &step2[3]);
  608. step2[4].val[0] = vaddq_s32(step1[4].val[0], step1[5].val[0]);
  609. step2[4].val[1] = vaddq_s32(step1[4].val[1], step1[5].val[1]);
  610. step2[5].val[0] = vsubq_s32(step1[4].val[0], step1[5].val[0]);
  611. step2[5].val[1] = vsubq_s32(step1[4].val[1], step1[5].val[1]);
  612. step2[6].val[0] = vsubq_s32(step1[7].val[0], step1[6].val[0]);
  613. step2[6].val[1] = vsubq_s32(step1[7].val[1], step1[6].val[1]);
  614. step2[7].val[0] = vaddq_s32(step1[7].val[0], step1[6].val[0]);
  615. step2[7].val[1] = vaddq_s32(step1[7].val[1], step1[6].val[1]);
  616. step2[8] = step1[8];
  617. highbd_idct_cospi_8_24_q(step1[14], step1[9], cospi_0_8_16_24, &step2[9],
  618. &step2[14]);
  619. highbd_idct_cospi_8_24_neg_q(step1[13], step1[10], cospi_0_8_16_24,
  620. &step2[13], &step2[10]);
  621. step2[11] = step1[11];
  622. step2[12] = step1[12];
  623. step2[15] = step1[15];
  624. // stage 5
  625. step1[0].val[0] = vaddq_s32(step2[0].val[0], step2[3].val[0]);
  626. step1[0].val[1] = vaddq_s32(step2[0].val[1], step2[3].val[1]);
  627. step1[1].val[0] = vaddq_s32(step2[1].val[0], step2[2].val[0]);
  628. step1[1].val[1] = vaddq_s32(step2[1].val[1], step2[2].val[1]);
  629. step1[2].val[0] = vsubq_s32(step2[1].val[0], step2[2].val[0]);
  630. step1[2].val[1] = vsubq_s32(step2[1].val[1], step2[2].val[1]);
  631. step1[3].val[0] = vsubq_s32(step2[0].val[0], step2[3].val[0]);
  632. step1[3].val[1] = vsubq_s32(step2[0].val[1], step2[3].val[1]);
  633. step1[4] = step2[4];
  634. highbd_idct_cospi_16_16_q(step2[5], step2[6], cospi_0_8_16_24, &step1[5],
  635. &step1[6]);
  636. step1[7] = step2[7];
  637. step1[8].val[0] = vaddq_s32(step2[8].val[0], step2[11].val[0]);
  638. step1[8].val[1] = vaddq_s32(step2[8].val[1], step2[11].val[1]);
  639. step1[9].val[0] = vaddq_s32(step2[9].val[0], step2[10].val[0]);
  640. step1[9].val[1] = vaddq_s32(step2[9].val[1], step2[10].val[1]);
  641. step1[10].val[0] = vsubq_s32(step2[9].val[0], step2[10].val[0]);
  642. step1[10].val[1] = vsubq_s32(step2[9].val[1], step2[10].val[1]);
  643. step1[11].val[0] = vsubq_s32(step2[8].val[0], step2[11].val[0]);
  644. step1[11].val[1] = vsubq_s32(step2[8].val[1], step2[11].val[1]);
  645. step1[12].val[0] = vsubq_s32(step2[15].val[0], step2[12].val[0]);
  646. step1[12].val[1] = vsubq_s32(step2[15].val[1], step2[12].val[1]);
  647. step1[13].val[0] = vsubq_s32(step2[14].val[0], step2[13].val[0]);
  648. step1[13].val[1] = vsubq_s32(step2[14].val[1], step2[13].val[1]);
  649. step1[14].val[0] = vaddq_s32(step2[14].val[0], step2[13].val[0]);
  650. step1[14].val[1] = vaddq_s32(step2[14].val[1], step2[13].val[1]);
  651. step1[15].val[0] = vaddq_s32(step2[15].val[0], step2[12].val[0]);
  652. step1[15].val[1] = vaddq_s32(step2[15].val[1], step2[12].val[1]);
  653. // stage 6
  654. step2[0].val[0] = vaddq_s32(step1[0].val[0], step1[7].val[0]);
  655. step2[0].val[1] = vaddq_s32(step1[0].val[1], step1[7].val[1]);
  656. step2[1].val[0] = vaddq_s32(step1[1].val[0], step1[6].val[0]);
  657. step2[1].val[1] = vaddq_s32(step1[1].val[1], step1[6].val[1]);
  658. step2[2].val[0] = vaddq_s32(step1[2].val[0], step1[5].val[0]);
  659. step2[2].val[1] = vaddq_s32(step1[2].val[1], step1[5].val[1]);
  660. step2[3].val[0] = vaddq_s32(step1[3].val[0], step1[4].val[0]);
  661. step2[3].val[1] = vaddq_s32(step1[3].val[1], step1[4].val[1]);
  662. step2[4].val[0] = vsubq_s32(step1[3].val[0], step1[4].val[0]);
  663. step2[4].val[1] = vsubq_s32(step1[3].val[1], step1[4].val[1]);
  664. step2[5].val[0] = vsubq_s32(step1[2].val[0], step1[5].val[0]);
  665. step2[5].val[1] = vsubq_s32(step1[2].val[1], step1[5].val[1]);
  666. step2[6].val[0] = vsubq_s32(step1[1].val[0], step1[6].val[0]);
  667. step2[6].val[1] = vsubq_s32(step1[1].val[1], step1[6].val[1]);
  668. step2[7].val[0] = vsubq_s32(step1[0].val[0], step1[7].val[0]);
  669. step2[7].val[1] = vsubq_s32(step1[0].val[1], step1[7].val[1]);
  670. highbd_idct_cospi_16_16_q(step1[10], step1[13], cospi_0_8_16_24, &step2[10],
  671. &step2[13]);
  672. highbd_idct_cospi_16_16_q(step1[11], step1[12], cospi_0_8_16_24, &step2[11],
  673. &step2[12]);
  674. step2[8] = step1[8];
  675. step2[9] = step1[9];
  676. step2[14] = step1[14];
  677. step2[15] = step1[15];
  678. // stage 7
  679. highbd_idct16x16_add_stage7_dual(step2, out);
  680. if (output) {
  681. highbd_idct16x16_store_pass1(out, output);
  682. } else {
  683. highbd_idct16x16_add_store(out, dest, stride, bd);
  684. }
  685. }
  686. static INLINE int32x4x2_t highbd_idct_cospi_lane0_dual(const int32x4x2_t s,
  687. const int32x2_t coef) {
  688. int64x2x2_t t[2];
  689. t[0].val[0] = vmull_lane_s32(vget_low_s32(s.val[0]), coef, 0);
  690. t[0].val[1] = vmull_lane_s32(vget_high_s32(s.val[0]), coef, 0);
  691. t[1].val[0] = vmull_lane_s32(vget_low_s32(s.val[1]), coef, 0);
  692. t[1].val[1] = vmull_lane_s32(vget_high_s32(s.val[1]), coef, 0);
  693. return dct_const_round_shift_high_4x2_int64x2x2(t);
  694. }
  695. static INLINE int32x4_t highbd_idct_cospi_lane0(const int32x4_t s,
  696. const int32x2_t coef) {
  697. int64x2x2_t t;
  698. t.val[0] = vmull_lane_s32(vget_low_s32(s), coef, 0);
  699. t.val[1] = vmull_lane_s32(vget_high_s32(s), coef, 0);
  700. return dct_const_round_shift_high_4(t);
  701. }
  702. static INLINE int32x4x2_t highbd_idct_cospi_lane1_dual(const int32x4x2_t s,
  703. const int32x2_t coef) {
  704. int64x2x2_t t[2];
  705. t[0].val[0] = vmull_lane_s32(vget_low_s32(s.val[0]), coef, 1);
  706. t[0].val[1] = vmull_lane_s32(vget_high_s32(s.val[0]), coef, 1);
  707. t[1].val[0] = vmull_lane_s32(vget_low_s32(s.val[1]), coef, 1);
  708. t[1].val[1] = vmull_lane_s32(vget_high_s32(s.val[1]), coef, 1);
  709. return dct_const_round_shift_high_4x2_int64x2x2(t);
  710. }
  711. static INLINE int32x4_t highbd_idct_cospi_lane1(const int32x4_t s,
  712. const int32x2_t coef) {
  713. int64x2x2_t t;
  714. t.val[0] = vmull_lane_s32(vget_low_s32(s), coef, 1);
  715. t.val[1] = vmull_lane_s32(vget_high_s32(s), coef, 1);
  716. return dct_const_round_shift_high_4(t);
  717. }
  718. static void vpx_highbd_idct16x16_38_add_half1d(const int32_t *input,
  719. int32_t *output, uint16_t *dest,
  720. const int stride, const int bd) {
  721. const int32x4_t cospi_0_8_16_24 = vld1q_s32(kCospi32 + 0);
  722. const int32x4_t cospi_4_12_20N_28 = vld1q_s32(kCospi32 + 4);
  723. const int32x4_t cospi_2_30_10_22 = vld1q_s32(kCospi32 + 8);
  724. const int32x4_t cospi_6_26N_14_18N = vld1q_s32(kCospi32 + 12);
  725. int32x4x2_t in[8], step1[16], step2[16], out[16];
  726. // Load input (8x8)
  727. in[0].val[0] = vld1q_s32(input);
  728. in[0].val[1] = vld1q_s32(input + 4);
  729. input += 16;
  730. in[1].val[0] = vld1q_s32(input);
  731. in[1].val[1] = vld1q_s32(input + 4);
  732. input += 16;
  733. in[2].val[0] = vld1q_s32(input);
  734. in[2].val[1] = vld1q_s32(input + 4);
  735. input += 16;
  736. in[3].val[0] = vld1q_s32(input);
  737. in[3].val[1] = vld1q_s32(input + 4);
  738. input += 16;
  739. in[4].val[0] = vld1q_s32(input);
  740. in[4].val[1] = vld1q_s32(input + 4);
  741. input += 16;
  742. in[5].val[0] = vld1q_s32(input);
  743. in[5].val[1] = vld1q_s32(input + 4);
  744. input += 16;
  745. in[6].val[0] = vld1q_s32(input);
  746. in[6].val[1] = vld1q_s32(input + 4);
  747. input += 16;
  748. in[7].val[0] = vld1q_s32(input);
  749. in[7].val[1] = vld1q_s32(input + 4);
  750. // Transpose
  751. transpose_s32_8x8(&in[0], &in[1], &in[2], &in[3], &in[4], &in[5], &in[6],
  752. &in[7]);
  753. // stage 1
  754. step1[0] = in[0 / 2];
  755. step1[2] = in[8 / 2];
  756. step1[4] = in[4 / 2];
  757. step1[6] = in[12 / 2];
  758. step1[8] = in[2 / 2];
  759. step1[10] = in[10 / 2];
  760. step1[12] = in[6 / 2];
  761. step1[14] = in[14 / 2]; // 0 in pass 1
  762. // stage 2
  763. step2[0] = step1[0];
  764. step2[2] = step1[2];
  765. step2[4] = step1[4];
  766. step2[6] = step1[6];
  767. step2[8] =
  768. highbd_idct_cospi_lane1_dual(step1[8], vget_low_s32(cospi_2_30_10_22));
  769. step2[9] = highbd_idct_cospi_lane1_dual(step1[14],
  770. vget_high_s32(cospi_6_26N_14_18N));
  771. step2[10] =
  772. highbd_idct_cospi_lane1_dual(step1[10], vget_high_s32(cospi_2_30_10_22));
  773. step2[11] =
  774. highbd_idct_cospi_lane1_dual(step1[12], vget_low_s32(cospi_6_26N_14_18N));
  775. step2[12] =
  776. highbd_idct_cospi_lane0_dual(step1[12], vget_low_s32(cospi_6_26N_14_18N));
  777. step2[13] =
  778. highbd_idct_cospi_lane0_dual(step1[10], vget_high_s32(cospi_2_30_10_22));
  779. step2[14] = highbd_idct_cospi_lane0_dual(step1[14],
  780. vget_high_s32(cospi_6_26N_14_18N));
  781. step2[15] =
  782. highbd_idct_cospi_lane0_dual(step1[8], vget_low_s32(cospi_2_30_10_22));
  783. // stage 3
  784. step1[0] = step2[0];
  785. step1[2] = step2[2];
  786. step1[4] =
  787. highbd_idct_cospi_lane1_dual(step2[4], vget_high_s32(cospi_4_12_20N_28));
  788. step1[5] =
  789. highbd_idct_cospi_lane0_dual(step2[6], vget_high_s32(cospi_4_12_20N_28));
  790. step1[6] =
  791. highbd_idct_cospi_lane1_dual(step2[6], vget_low_s32(cospi_4_12_20N_28));
  792. step1[7] =
  793. highbd_idct_cospi_lane0_dual(step2[4], vget_low_s32(cospi_4_12_20N_28));
  794. step1[8] = highbd_idct_add_dual(step2[8], step2[9]);
  795. step1[9] = highbd_idct_sub_dual(step2[8], step2[9]);
  796. step1[10] = highbd_idct_sub_dual(step2[11], step2[10]);
  797. step1[11] = highbd_idct_add_dual(step2[11], step2[10]);
  798. step1[12] = highbd_idct_add_dual(step2[12], step2[13]);
  799. step1[13] = highbd_idct_sub_dual(step2[12], step2[13]);
  800. step1[14] = highbd_idct_sub_dual(step2[15], step2[14]);
  801. step1[15] = highbd_idct_add_dual(step2[15], step2[14]);
  802. // stage 4
  803. step2[0] = step2[1] =
  804. highbd_idct_cospi_lane0_dual(step1[0], vget_high_s32(cospi_0_8_16_24));
  805. step2[2] =
  806. highbd_idct_cospi_lane1_dual(step1[2], vget_high_s32(cospi_0_8_16_24));
  807. step2[3] =
  808. highbd_idct_cospi_lane1_dual(step1[2], vget_low_s32(cospi_0_8_16_24));
  809. step2[4] = highbd_idct_add_dual(step1[4], step1[5]);
  810. step2[5] = highbd_idct_sub_dual(step1[4], step1[5]);
  811. step2[6] = highbd_idct_sub_dual(step1[7], step1[6]);
  812. step2[7] = highbd_idct_add_dual(step1[7], step1[6]);
  813. step2[8] = step1[8];
  814. highbd_idct_cospi_8_24_q(step1[14], step1[9], cospi_0_8_16_24, &step2[9],
  815. &step2[14]);
  816. highbd_idct_cospi_8_24_neg_q(step1[13], step1[10], cospi_0_8_16_24,
  817. &step2[13], &step2[10]);
  818. step2[11] = step1[11];
  819. step2[12] = step1[12];
  820. step2[15] = step1[15];
  821. // stage 5
  822. step1[0] = highbd_idct_add_dual(step2[0], step2[3]);
  823. step1[1] = highbd_idct_add_dual(step2[1], step2[2]);
  824. step1[2] = highbd_idct_sub_dual(step2[1], step2[2]);
  825. step1[3] = highbd_idct_sub_dual(step2[0], step2[3]);
  826. step1[4] = step2[4];
  827. highbd_idct_cospi_16_16_q(step2[5], step2[6], cospi_0_8_16_24, &step1[5],
  828. &step1[6]);
  829. step1[7] = step2[7];
  830. step1[8] = highbd_idct_add_dual(step2[8], step2[11]);
  831. step1[9] = highbd_idct_add_dual(step2[9], step2[10]);
  832. step1[10] = highbd_idct_sub_dual(step2[9], step2[10]);
  833. step1[11] = highbd_idct_sub_dual(step2[8], step2[11]);
  834. step1[12] = highbd_idct_sub_dual(step2[15], step2[12]);
  835. step1[13] = highbd_idct_sub_dual(step2[14], step2[13]);
  836. step1[14] = highbd_idct_add_dual(step2[14], step2[13]);
  837. step1[15] = highbd_idct_add_dual(step2[15], step2[12]);
  838. // stage 6
  839. step2[0] = highbd_idct_add_dual(step1[0], step1[7]);
  840. step2[1] = highbd_idct_add_dual(step1[1], step1[6]);
  841. step2[2] = highbd_idct_add_dual(step1[2], step1[5]);
  842. step2[3] = highbd_idct_add_dual(step1[3], step1[4]);
  843. step2[4] = highbd_idct_sub_dual(step1[3], step1[4]);
  844. step2[5] = highbd_idct_sub_dual(step1[2], step1[5]);
  845. step2[6] = highbd_idct_sub_dual(step1[1], step1[6]);
  846. step2[7] = highbd_idct_sub_dual(step1[0], step1[7]);
  847. highbd_idct_cospi_16_16_q(step1[10], step1[13], cospi_0_8_16_24, &step2[10],
  848. &step2[13]);
  849. highbd_idct_cospi_16_16_q(step1[11], step1[12], cospi_0_8_16_24, &step2[11],
  850. &step2[12]);
  851. step2[8] = step1[8];
  852. step2[9] = step1[9];
  853. step2[14] = step1[14];
  854. step2[15] = step1[15];
  855. // stage 7
  856. highbd_idct16x16_add_stage7_dual(step2, out);
  857. if (output) {
  858. highbd_idct16x16_store_pass1(out, output);
  859. } else {
  860. highbd_idct16x16_add_store(out, dest, stride, bd);
  861. }
  862. }
  863. static void highbd_idct16x16_10_add_half1d_pass1(const tran_low_t *input,
  864. int32_t *output) {
  865. const int32x4_t cospi_0_8_16_24 = vld1q_s32(kCospi32 + 0);
  866. const int32x4_t cospi_4_12_20N_28 = vld1q_s32(kCospi32 + 4);
  867. const int32x4_t cospi_2_30_10_22 = vld1q_s32(kCospi32 + 8);
  868. const int32x4_t cospi_6_26N_14_18N = vld1q_s32(kCospi32 + 12);
  869. int32x4_t in[4], step1[16], step2[16], out[16];
  870. // Load input (4x4)
  871. in[0] = vld1q_s32(input);
  872. input += 16;
  873. in[1] = vld1q_s32(input);
  874. input += 16;
  875. in[2] = vld1q_s32(input);
  876. input += 16;
  877. in[3] = vld1q_s32(input);
  878. // Transpose
  879. transpose_s32_4x4(&in[0], &in[1], &in[2], &in[3]);
  880. // stage 1
  881. step1[0] = in[0 / 2];
  882. step1[4] = in[4 / 2];
  883. step1[8] = in[2 / 2];
  884. step1[12] = in[6 / 2];
  885. // stage 2
  886. step2[0] = step1[0];
  887. step2[4] = step1[4];
  888. step2[8] = highbd_idct_cospi_lane1(step1[8], vget_low_s32(cospi_2_30_10_22));
  889. step2[11] =
  890. highbd_idct_cospi_lane1(step1[12], vget_low_s32(cospi_6_26N_14_18N));
  891. step2[12] =
  892. highbd_idct_cospi_lane0(step1[12], vget_low_s32(cospi_6_26N_14_18N));
  893. step2[15] = highbd_idct_cospi_lane0(step1[8], vget_low_s32(cospi_2_30_10_22));
  894. // stage 3
  895. step1[0] = step2[0];
  896. step1[4] =
  897. highbd_idct_cospi_lane1(step2[4], vget_high_s32(cospi_4_12_20N_28));
  898. step1[7] = highbd_idct_cospi_lane0(step2[4], vget_low_s32(cospi_4_12_20N_28));
  899. step1[8] = step2[8];
  900. step1[9] = step2[8];
  901. step1[10] = step2[11];
  902. step1[11] = step2[11];
  903. step1[12] = step2[12];
  904. step1[13] = step2[12];
  905. step1[14] = step2[15];
  906. step1[15] = step2[15];
  907. // stage 4
  908. step2[0] = step2[1] =
  909. highbd_idct_cospi_lane0(step1[0], vget_high_s32(cospi_0_8_16_24));
  910. step2[4] = step1[4];
  911. step2[5] = step1[4];
  912. step2[6] = step1[7];
  913. step2[7] = step1[7];
  914. step2[8] = step1[8];
  915. highbd_idct_cospi_8_24_d(step1[14], step1[9], cospi_0_8_16_24, &step2[9],
  916. &step2[14]);
  917. highbd_idct_cospi_8_24_neg_d(step1[13], step1[10], cospi_0_8_16_24,
  918. &step2[13], &step2[10]);
  919. step2[11] = step1[11];
  920. step2[12] = step1[12];
  921. step2[15] = step1[15];
  922. // stage 5
  923. step1[0] = step2[0];
  924. step1[1] = step2[1];
  925. step1[2] = step2[1];
  926. step1[3] = step2[0];
  927. step1[4] = step2[4];
  928. highbd_idct_cospi_16_16_d(step2[5], step2[6], cospi_0_8_16_24, &step1[5],
  929. &step1[6]);
  930. step1[7] = step2[7];
  931. step1[8] = vaddq_s32(step2[8], step2[11]);
  932. step1[9] = vaddq_s32(step2[9], step2[10]);
  933. step1[10] = vsubq_s32(step2[9], step2[10]);
  934. step1[11] = vsubq_s32(step2[8], step2[11]);
  935. step1[12] = vsubq_s32(step2[15], step2[12]);
  936. step1[13] = vsubq_s32(step2[14], step2[13]);
  937. step1[14] = vaddq_s32(step2[14], step2[13]);
  938. step1[15] = vaddq_s32(step2[15], step2[12]);
  939. // stage 6
  940. step2[0] = vaddq_s32(step1[0], step1[7]);
  941. step2[1] = vaddq_s32(step1[1], step1[6]);
  942. step2[2] = vaddq_s32(step1[2], step1[5]);
  943. step2[3] = vaddq_s32(step1[3], step1[4]);
  944. step2[4] = vsubq_s32(step1[3], step1[4]);
  945. step2[5] = vsubq_s32(step1[2], step1[5]);
  946. step2[6] = vsubq_s32(step1[1], step1[6]);
  947. step2[7] = vsubq_s32(step1[0], step1[7]);
  948. highbd_idct_cospi_16_16_d(step1[10], step1[13], cospi_0_8_16_24, &step2[10],
  949. &step2[13]);
  950. highbd_idct_cospi_16_16_d(step1[11], step1[12], cospi_0_8_16_24, &step2[11],
  951. &step2[12]);
  952. step2[8] = step1[8];
  953. step2[9] = step1[9];
  954. step2[14] = step1[14];
  955. step2[15] = step1[15];
  956. // stage 7
  957. highbd_idct16x16_add_stage7(step2, out);
  958. // pass 1: save the result into output
  959. vst1q_s32(output, out[0]);
  960. output += 4;
  961. vst1q_s32(output, out[1]);
  962. output += 4;
  963. vst1q_s32(output, out[2]);
  964. output += 4;
  965. vst1q_s32(output, out[3]);
  966. output += 4;
  967. vst1q_s32(output, out[4]);
  968. output += 4;
  969. vst1q_s32(output, out[5]);
  970. output += 4;
  971. vst1q_s32(output, out[6]);
  972. output += 4;
  973. vst1q_s32(output, out[7]);
  974. output += 4;
  975. vst1q_s32(output, out[8]);
  976. output += 4;
  977. vst1q_s32(output, out[9]);
  978. output += 4;
  979. vst1q_s32(output, out[10]);
  980. output += 4;
  981. vst1q_s32(output, out[11]);
  982. output += 4;
  983. vst1q_s32(output, out[12]);
  984. output += 4;
  985. vst1q_s32(output, out[13]);
  986. output += 4;
  987. vst1q_s32(output, out[14]);
  988. output += 4;
  989. vst1q_s32(output, out[15]);
  990. }
  991. static void highbd_idct16x16_10_add_half1d_pass2(const int32_t *input,
  992. int32_t *const output,
  993. uint16_t *const dest,
  994. const int stride,
  995. const int bd) {
  996. const int32x4_t cospi_0_8_16_24 = vld1q_s32(kCospi32 + 0);
  997. const int32x4_t cospi_4_12_20N_28 = vld1q_s32(kCospi32 + 4);
  998. const int32x4_t cospi_2_30_10_22 = vld1q_s32(kCospi32 + 8);
  999. const int32x4_t cospi_6_26N_14_18N = vld1q_s32(kCospi32 + 12);
  1000. int32x4x2_t in[4], step1[16], step2[16], out[16];
  1001. // Load input (4x8)
  1002. in[0].val[0] = vld1q_s32(input);
  1003. input += 4;
  1004. in[0].val[1] = vld1q_s32(input);
  1005. input += 4;
  1006. in[1].val[0] = vld1q_s32(input);
  1007. input += 4;
  1008. in[1].val[1] = vld1q_s32(input);
  1009. input += 4;
  1010. in[2].val[0] = vld1q_s32(input);
  1011. input += 4;
  1012. in[2].val[1] = vld1q_s32(input);
  1013. input += 4;
  1014. in[3].val[0] = vld1q_s32(input);
  1015. input += 4;
  1016. in[3].val[1] = vld1q_s32(input);
  1017. // Transpose
  1018. transpose_s32_4x8(&in[0].val[0], &in[0].val[1], &in[1].val[0], &in[1].val[1],
  1019. &in[2].val[0], &in[2].val[1], &in[3].val[0], &in[3].val[1]);
  1020. // stage 1
  1021. step1[0] = in[0 / 2];
  1022. step1[4] = in[4 / 2];
  1023. step1[8] = in[2 / 2];
  1024. step1[12] = in[6 / 2];
  1025. // stage 2
  1026. step2[0] = step1[0];
  1027. step2[4] = step1[4];
  1028. step2[8] =
  1029. highbd_idct_cospi_lane1_dual(step1[8], vget_low_s32(cospi_2_30_10_22));
  1030. step2[11] =
  1031. highbd_idct_cospi_lane1_dual(step1[12], vget_low_s32(cospi_6_26N_14_18N));
  1032. step2[12] =
  1033. highbd_idct_cospi_lane0_dual(step1[12], vget_low_s32(cospi_6_26N_14_18N));
  1034. step2[15] =
  1035. highbd_idct_cospi_lane0_dual(step1[8], vget_low_s32(cospi_2_30_10_22));
  1036. // stage 3
  1037. step1[0] = step2[0];
  1038. step1[4] =
  1039. highbd_idct_cospi_lane1_dual(step2[4], vget_high_s32(cospi_4_12_20N_28));
  1040. step1[7] =
  1041. highbd_idct_cospi_lane0_dual(step2[4], vget_low_s32(cospi_4_12_20N_28));
  1042. step1[8] = step2[8];
  1043. step1[9] = step2[8];
  1044. step1[10] = step2[11];
  1045. step1[11] = step2[11];
  1046. step1[12] = step2[12];
  1047. step1[13] = step2[12];
  1048. step1[14] = step2[15];
  1049. step1[15] = step2[15];
  1050. // stage 4
  1051. step2[0] = step2[1] =
  1052. highbd_idct_cospi_lane0_dual(step1[0], vget_high_s32(cospi_0_8_16_24));
  1053. step2[4] = step1[4];
  1054. step2[5] = step1[4];
  1055. step2[6] = step1[7];
  1056. step2[7] = step1[7];
  1057. step2[8] = step1[8];
  1058. highbd_idct_cospi_8_24_q(step1[14], step1[9], cospi_0_8_16_24, &step2[9],
  1059. &step2[14]);
  1060. highbd_idct_cospi_8_24_neg_q(step1[13], step1[10], cospi_0_8_16_24,
  1061. &step2[13], &step2[10]);
  1062. step2[11] = step1[11];
  1063. step2[12] = step1[12];
  1064. step2[15] = step1[15];
  1065. // stage 5
  1066. step1[0] = step2[0];
  1067. step1[1] = step2[1];
  1068. step1[2] = step2[1];
  1069. step1[3] = step2[0];
  1070. step1[4] = step2[4];
  1071. highbd_idct_cospi_16_16_q(step2[5], step2[6], cospi_0_8_16_24, &step1[5],
  1072. &step1[6]);
  1073. step1[7] = step2[7];
  1074. step1[8] = highbd_idct_add_dual(step2[8], step2[11]);
  1075. step1[9] = highbd_idct_add_dual(step2[9], step2[10]);
  1076. step1[10] = highbd_idct_sub_dual(step2[9], step2[10]);
  1077. step1[11] = highbd_idct_sub_dual(step2[8], step2[11]);
  1078. step1[12] = highbd_idct_sub_dual(step2[15], step2[12]);
  1079. step1[13] = highbd_idct_sub_dual(step2[14], step2[13]);
  1080. step1[14] = highbd_idct_add_dual(step2[14], step2[13]);
  1081. step1[15] = highbd_idct_add_dual(step2[15], step2[12]);
  1082. // stage 6
  1083. step2[0] = highbd_idct_add_dual(step1[0], step1[7]);
  1084. step2[1] = highbd_idct_add_dual(step1[1], step1[6]);
  1085. step2[2] = highbd_idct_add_dual(step1[2], step1[5]);
  1086. step2[3] = highbd_idct_add_dual(step1[3], step1[4]);
  1087. step2[4] = highbd_idct_sub_dual(step1[3], step1[4]);
  1088. step2[5] = highbd_idct_sub_dual(step1[2], step1[5]);
  1089. step2[6] = highbd_idct_sub_dual(step1[1], step1[6]);
  1090. step2[7] = highbd_idct_sub_dual(step1[0], step1[7]);
  1091. highbd_idct_cospi_16_16_q(step1[10], step1[13], cospi_0_8_16_24, &step2[10],
  1092. &step2[13]);
  1093. highbd_idct_cospi_16_16_q(step1[11], step1[12], cospi_0_8_16_24, &step2[11],
  1094. &step2[12]);
  1095. step2[8] = step1[8];
  1096. step2[9] = step1[9];
  1097. step2[14] = step1[14];
  1098. step2[15] = step1[15];
  1099. // stage 7
  1100. highbd_idct16x16_add_stage7_dual(step2, out);
  1101. if (output) {
  1102. highbd_idct16x16_store_pass1(out, output);
  1103. } else {
  1104. highbd_idct16x16_add_store(out, dest, stride, bd);
  1105. }
  1106. }
  1107. void vpx_highbd_idct16x16_256_add_neon(const tran_low_t *input, uint16_t *dest,
  1108. int stride, int bd) {
  1109. if (bd == 8) {
  1110. int16_t row_idct_output[16 * 16];
  1111. // pass 1
  1112. // Parallel idct on the upper 8 rows
  1113. vpx_idct16x16_256_add_half1d(input, row_idct_output, dest, stride, 1);
  1114. // Parallel idct on the lower 8 rows
  1115. vpx_idct16x16_256_add_half1d(input + 8 * 16, row_idct_output + 8, dest,
  1116. stride, 1);
  1117. // pass 2
  1118. // Parallel idct to get the left 8 columns
  1119. vpx_idct16x16_256_add_half1d(row_idct_output, NULL, dest, stride, 1);
  1120. // Parallel idct to get the right 8 columns
  1121. vpx_idct16x16_256_add_half1d(row_idct_output + 8 * 16, NULL, dest + 8,
  1122. stride, 1);
  1123. } else {
  1124. int32_t row_idct_output[16 * 16];
  1125. // pass 1
  1126. // Parallel idct on the upper 8 rows
  1127. vpx_highbd_idct16x16_256_add_half1d(input, row_idct_output, dest, stride,
  1128. bd);
  1129. // Parallel idct on the lower 8 rows
  1130. vpx_highbd_idct16x16_256_add_half1d(input + 8 * 16, row_idct_output + 8,
  1131. dest, stride, bd);
  1132. // pass 2
  1133. // Parallel idct to get the left 8 columns
  1134. vpx_highbd_idct16x16_256_add_half1d(row_idct_output, NULL, dest, stride,
  1135. bd);
  1136. // Parallel idct to get the right 8 columns
  1137. vpx_highbd_idct16x16_256_add_half1d(row_idct_output + 8 * 16, NULL,
  1138. dest + 8, stride, bd);
  1139. }
  1140. }
  1141. void vpx_highbd_idct16x16_38_add_neon(const tran_low_t *input, uint16_t *dest,
  1142. int stride, int bd) {
  1143. if (bd == 8) {
  1144. int16_t row_idct_output[16 * 16];
  1145. // pass 1
  1146. // Parallel idct on the upper 8 rows
  1147. vpx_idct16x16_38_add_half1d(input, row_idct_output, dest, stride, 1);
  1148. // pass 2
  1149. // Parallel idct to get the left 8 columns
  1150. vpx_idct16x16_38_add_half1d(row_idct_output, NULL, dest, stride, 1);
  1151. // Parallel idct to get the right 8 columns
  1152. vpx_idct16x16_38_add_half1d(row_idct_output + 16 * 8, NULL, dest + 8,
  1153. stride, 1);
  1154. } else {
  1155. int32_t row_idct_output[16 * 16];
  1156. // pass 1
  1157. // Parallel idct on the upper 8 rows
  1158. vpx_highbd_idct16x16_38_add_half1d(input, row_idct_output, dest, stride,
  1159. bd);
  1160. // pass 2
  1161. // Parallel idct to get the left 8 columns
  1162. vpx_highbd_idct16x16_38_add_half1d(row_idct_output, NULL, dest, stride, bd);
  1163. // Parallel idct to get the right 8 columns
  1164. vpx_highbd_idct16x16_38_add_half1d(row_idct_output + 16 * 8, NULL, dest + 8,
  1165. stride, bd);
  1166. }
  1167. }
  1168. void vpx_highbd_idct16x16_10_add_neon(const tran_low_t *input, uint16_t *dest,
  1169. int stride, int bd) {
  1170. if (bd == 8) {
  1171. int16_t row_idct_output[4 * 16];
  1172. // pass 1
  1173. // Parallel idct on the upper 8 rows
  1174. vpx_idct16x16_10_add_half1d_pass1(input, row_idct_output);
  1175. // pass 2
  1176. // Parallel idct to get the left 8 columns
  1177. vpx_idct16x16_10_add_half1d_pass2(row_idct_output, NULL, dest, stride, 1);
  1178. // Parallel idct to get the right 8 columns
  1179. vpx_idct16x16_10_add_half1d_pass2(row_idct_output + 4 * 8, NULL, dest + 8,
  1180. stride, 1);
  1181. } else {
  1182. int32_t row_idct_output[4 * 16];
  1183. // pass 1
  1184. // Parallel idct on the upper 8 rows
  1185. highbd_idct16x16_10_add_half1d_pass1(input, row_idct_output);
  1186. // pass 2
  1187. // Parallel idct to get the left 8 columns
  1188. highbd_idct16x16_10_add_half1d_pass2(row_idct_output, NULL, dest, stride,
  1189. bd);
  1190. // Parallel idct to get the right 8 columns
  1191. highbd_idct16x16_10_add_half1d_pass2(row_idct_output + 4 * 8, NULL,
  1192. dest + 8, stride, bd);
  1193. }
  1194. }
  1195. static INLINE void highbd_idct16x16_1_add_pos_kernel(uint16_t **dest,
  1196. const int stride,
  1197. const int16x8_t res,
  1198. const int16x8_t max) {
  1199. const uint16x8_t a0 = vld1q_u16(*dest + 0);
  1200. const uint16x8_t a1 = vld1q_u16(*dest + 8);
  1201. const int16x8_t b0 = vaddq_s16(res, vreinterpretq_s16_u16(a0));
  1202. const int16x8_t b1 = vaddq_s16(res, vreinterpretq_s16_u16(a1));
  1203. const int16x8_t c0 = vminq_s16(b0, max);
  1204. const int16x8_t c1 = vminq_s16(b1, max);
  1205. vst1q_u16(*dest + 0, vreinterpretq_u16_s16(c0));
  1206. vst1q_u16(*dest + 8, vreinterpretq_u16_s16(c1));
  1207. *dest += stride;
  1208. }
  1209. static INLINE void highbd_idct16x16_1_add_neg_kernel(uint16_t **dest,
  1210. const int stride,
  1211. const int16x8_t res) {
  1212. const uint16x8_t a0 = vld1q_u16(*dest + 0);
  1213. const uint16x8_t a1 = vld1q_u16(*dest + 8);
  1214. const int16x8_t b0 = vaddq_s16(res, vreinterpretq_s16_u16(a0));
  1215. const int16x8_t b1 = vaddq_s16(res, vreinterpretq_s16_u16(a1));
  1216. const uint16x8_t c0 = vqshluq_n_s16(b0, 0);
  1217. const uint16x8_t c1 = vqshluq_n_s16(b1, 0);
  1218. vst1q_u16(*dest + 0, c0);
  1219. vst1q_u16(*dest + 8, c1);
  1220. *dest += stride;
  1221. }
  1222. void vpx_highbd_idct16x16_1_add_neon(const tran_low_t *input, uint16_t *dest,
  1223. int stride, int bd) {
  1224. const tran_low_t out0 = HIGHBD_WRAPLOW(
  1225. dct_const_round_shift(input[0] * (tran_high_t)cospi_16_64), bd);
  1226. const tran_low_t out1 = HIGHBD_WRAPLOW(
  1227. dct_const_round_shift(out0 * (tran_high_t)cospi_16_64), bd);
  1228. const int16_t a1 = ROUND_POWER_OF_TWO(out1, 6);
  1229. const int16x8_t dc = vdupq_n_s16(a1);
  1230. int i;
  1231. if (a1 >= 0) {
  1232. const int16x8_t max = vdupq_n_s16((1 << bd) - 1);
  1233. for (i = 0; i < 4; ++i) {
  1234. highbd_idct16x16_1_add_pos_kernel(&dest, stride, dc, max);
  1235. highbd_idct16x16_1_add_pos_kernel(&dest, stride, dc, max);
  1236. highbd_idct16x16_1_add_pos_kernel(&dest, stride, dc, max);
  1237. highbd_idct16x16_1_add_pos_kernel(&dest, stride, dc, max);
  1238. }
  1239. } else {
  1240. for (i = 0; i < 4; ++i) {
  1241. highbd_idct16x16_1_add_neg_kernel(&dest, stride, dc);
  1242. highbd_idct16x16_1_add_neg_kernel(&dest, stride, dc);
  1243. highbd_idct16x16_1_add_neg_kernel(&dest, stride, dc);
  1244. highbd_idct16x16_1_add_neg_kernel(&dest, stride, dc);
  1245. }
  1246. }
  1247. }