row_any.cc 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. /*
  2. * Copyright 2012 The LibYuv 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 "libyuv/row.h"
  11. #include <string.h> // For memset.
  12. #include "libyuv/basic_types.h"
  13. #ifdef __cplusplus
  14. namespace libyuv {
  15. extern "C" {
  16. #endif
  17. // memset for temp is meant to clear the source buffer (not dest) so that
  18. // SIMD that reads full multiple of 16 bytes will not trigger msan errors.
  19. // memset is not needed for production, as the garbage values are processed but
  20. // not used, although there may be edge cases for subsampling.
  21. // The size of the buffer is based on the largest read, which can be inferred
  22. // by the source type (e.g. ARGB) and the mask (last parameter), or by examining
  23. // the source code for how much the source pointers are advanced.
  24. // Subsampled source needs to be increase by 1 of not even.
  25. #define SS(width, shift) (((width) + (1 << (shift)) - 1) >> (shift))
  26. // Any 4 planes to 1 with yuvconstants
  27. #define ANY41C(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \
  28. void NAMEANY(const uint8_t* y_buf, const uint8_t* u_buf, \
  29. const uint8_t* v_buf, const uint8_t* a_buf, uint8_t* dst_ptr, \
  30. const struct YuvConstants* yuvconstants, int width) { \
  31. SIMD_ALIGNED(uint8_t temp[64 * 5]); \
  32. memset(temp, 0, 64 * 4); /* for msan */ \
  33. int r = width & MASK; \
  34. int n = width & ~MASK; \
  35. if (n > 0) { \
  36. ANY_SIMD(y_buf, u_buf, v_buf, a_buf, dst_ptr, yuvconstants, n); \
  37. } \
  38. memcpy(temp, y_buf + n, r); \
  39. memcpy(temp + 64, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  40. memcpy(temp + 128, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  41. memcpy(temp + 192, a_buf + n, r); \
  42. ANY_SIMD(temp, temp + 64, temp + 128, temp + 192, temp + 256, \
  43. yuvconstants, MASK + 1); \
  44. memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 256, \
  45. SS(r, DUVSHIFT) * BPP); \
  46. }
  47. #ifdef HAS_I422ALPHATOARGBROW_SSSE3
  48. ANY41C(I422AlphaToARGBRow_Any_SSSE3, I422AlphaToARGBRow_SSSE3, 1, 0, 4, 7)
  49. #endif
  50. #ifdef HAS_I422ALPHATOARGBROW_AVX2
  51. ANY41C(I422AlphaToARGBRow_Any_AVX2, I422AlphaToARGBRow_AVX2, 1, 0, 4, 15)
  52. #endif
  53. #ifdef HAS_I422ALPHATOARGBROW_NEON
  54. ANY41C(I422AlphaToARGBRow_Any_NEON, I422AlphaToARGBRow_NEON, 1, 0, 4, 7)
  55. #endif
  56. #ifdef HAS_I422ALPHATOARGBROW_MSA
  57. ANY41C(I422AlphaToARGBRow_Any_MSA, I422AlphaToARGBRow_MSA, 1, 0, 4, 7)
  58. #endif
  59. #undef ANY41C
  60. // Any 3 planes to 1.
  61. #define ANY31(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \
  62. void NAMEANY(const uint8_t* y_buf, const uint8_t* u_buf, \
  63. const uint8_t* v_buf, uint8_t* dst_ptr, int width) { \
  64. SIMD_ALIGNED(uint8_t temp[64 * 4]); \
  65. memset(temp, 0, 64 * 3); /* for YUY2 and msan */ \
  66. int r = width & MASK; \
  67. int n = width & ~MASK; \
  68. if (n > 0) { \
  69. ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, n); \
  70. } \
  71. memcpy(temp, y_buf + n, r); \
  72. memcpy(temp + 64, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  73. memcpy(temp + 128, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  74. ANY_SIMD(temp, temp + 64, temp + 128, temp + 192, MASK + 1); \
  75. memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 192, \
  76. SS(r, DUVSHIFT) * BPP); \
  77. }
  78. // Merge functions.
  79. #ifdef HAS_MERGERGBROW_SSSE3
  80. ANY31(MergeRGBRow_Any_SSSE3, MergeRGBRow_SSSE3, 0, 0, 3, 15)
  81. #endif
  82. #ifdef HAS_MERGERGBROW_NEON
  83. ANY31(MergeRGBRow_Any_NEON, MergeRGBRow_NEON, 0, 0, 3, 15)
  84. #endif
  85. #ifdef HAS_I422TOYUY2ROW_SSE2
  86. ANY31(I422ToYUY2Row_Any_SSE2, I422ToYUY2Row_SSE2, 1, 1, 4, 15)
  87. ANY31(I422ToUYVYRow_Any_SSE2, I422ToUYVYRow_SSE2, 1, 1, 4, 15)
  88. #endif
  89. #ifdef HAS_I422TOYUY2ROW_AVX2
  90. ANY31(I422ToYUY2Row_Any_AVX2, I422ToYUY2Row_AVX2, 1, 1, 4, 31)
  91. ANY31(I422ToUYVYRow_Any_AVX2, I422ToUYVYRow_AVX2, 1, 1, 4, 31)
  92. #endif
  93. #ifdef HAS_I422TOYUY2ROW_NEON
  94. ANY31(I422ToYUY2Row_Any_NEON, I422ToYUY2Row_NEON, 1, 1, 4, 15)
  95. #endif
  96. #ifdef HAS_I422TOYUY2ROW_MSA
  97. ANY31(I422ToYUY2Row_Any_MSA, I422ToYUY2Row_MSA, 1, 1, 4, 31)
  98. #endif
  99. #ifdef HAS_I422TOUYVYROW_NEON
  100. ANY31(I422ToUYVYRow_Any_NEON, I422ToUYVYRow_NEON, 1, 1, 4, 15)
  101. #endif
  102. #ifdef HAS_I422TOUYVYROW_MSA
  103. ANY31(I422ToUYVYRow_Any_MSA, I422ToUYVYRow_MSA, 1, 1, 4, 31)
  104. #endif
  105. #ifdef HAS_BLENDPLANEROW_AVX2
  106. ANY31(BlendPlaneRow_Any_AVX2, BlendPlaneRow_AVX2, 0, 0, 1, 31)
  107. #endif
  108. #ifdef HAS_BLENDPLANEROW_SSSE3
  109. ANY31(BlendPlaneRow_Any_SSSE3, BlendPlaneRow_SSSE3, 0, 0, 1, 7)
  110. #endif
  111. #undef ANY31
  112. // Note that odd width replication includes 444 due to implementation
  113. // on arm that subsamples 444 to 422 internally.
  114. // Any 3 planes to 1 with yuvconstants
  115. #define ANY31C(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \
  116. void NAMEANY(const uint8_t* y_buf, const uint8_t* u_buf, \
  117. const uint8_t* v_buf, uint8_t* dst_ptr, \
  118. const struct YuvConstants* yuvconstants, int width) { \
  119. SIMD_ALIGNED(uint8_t temp[128 * 4]); \
  120. memset(temp, 0, 128 * 3); /* for YUY2 and msan */ \
  121. int r = width & MASK; \
  122. int n = width & ~MASK; \
  123. if (n > 0) { \
  124. ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, yuvconstants, n); \
  125. } \
  126. memcpy(temp, y_buf + n, r); \
  127. memcpy(temp + 128, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  128. memcpy(temp + 256, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  129. if (width & 1) { \
  130. temp[128 + SS(r, UVSHIFT)] = temp[128 + SS(r, UVSHIFT) - 1]; \
  131. temp[256 + SS(r, UVSHIFT)] = temp[256 + SS(r, UVSHIFT) - 1]; \
  132. } \
  133. ANY_SIMD(temp, temp + 128, temp + 256, temp + 384, yuvconstants, \
  134. MASK + 1); \
  135. memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 384, \
  136. SS(r, DUVSHIFT) * BPP); \
  137. }
  138. #ifdef HAS_I422TOARGBROW_SSSE3
  139. ANY31C(I422ToARGBRow_Any_SSSE3, I422ToARGBRow_SSSE3, 1, 0, 4, 7)
  140. #endif
  141. #ifdef HAS_I422TOAR30ROW_SSSE3
  142. ANY31C(I422ToAR30Row_Any_SSSE3, I422ToAR30Row_SSSE3, 1, 0, 4, 7)
  143. #endif
  144. #ifdef HAS_I422TOAR30ROW_AVX2
  145. ANY31C(I422ToAR30Row_Any_AVX2, I422ToAR30Row_AVX2, 1, 0, 4, 15)
  146. #endif
  147. #ifdef HAS_I444TOARGBROW_SSSE3
  148. ANY31C(I444ToARGBRow_Any_SSSE3, I444ToARGBRow_SSSE3, 0, 0, 4, 7)
  149. ANY31C(I422ToRGBARow_Any_SSSE3, I422ToRGBARow_SSSE3, 1, 0, 4, 7)
  150. ANY31C(I422ToARGB4444Row_Any_SSSE3, I422ToARGB4444Row_SSSE3, 1, 0, 2, 7)
  151. ANY31C(I422ToARGB1555Row_Any_SSSE3, I422ToARGB1555Row_SSSE3, 1, 0, 2, 7)
  152. ANY31C(I422ToRGB565Row_Any_SSSE3, I422ToRGB565Row_SSSE3, 1, 0, 2, 7)
  153. ANY31C(I422ToRGB24Row_Any_SSSE3, I422ToRGB24Row_SSSE3, 1, 0, 3, 15)
  154. #endif // HAS_I444TOARGBROW_SSSE3
  155. #ifdef HAS_I422TORGB24ROW_AVX2
  156. ANY31C(I422ToRGB24Row_Any_AVX2, I422ToRGB24Row_AVX2, 1, 0, 3, 31)
  157. #endif
  158. #ifdef HAS_I422TOARGBROW_AVX2
  159. ANY31C(I422ToARGBRow_Any_AVX2, I422ToARGBRow_AVX2, 1, 0, 4, 15)
  160. #endif
  161. #ifdef HAS_I422TORGBAROW_AVX2
  162. ANY31C(I422ToRGBARow_Any_AVX2, I422ToRGBARow_AVX2, 1, 0, 4, 15)
  163. #endif
  164. #ifdef HAS_I444TOARGBROW_AVX2
  165. ANY31C(I444ToARGBRow_Any_AVX2, I444ToARGBRow_AVX2, 0, 0, 4, 15)
  166. #endif
  167. #ifdef HAS_I422TOARGB4444ROW_AVX2
  168. ANY31C(I422ToARGB4444Row_Any_AVX2, I422ToARGB4444Row_AVX2, 1, 0, 2, 15)
  169. #endif
  170. #ifdef HAS_I422TOARGB1555ROW_AVX2
  171. ANY31C(I422ToARGB1555Row_Any_AVX2, I422ToARGB1555Row_AVX2, 1, 0, 2, 15)
  172. #endif
  173. #ifdef HAS_I422TORGB565ROW_AVX2
  174. ANY31C(I422ToRGB565Row_Any_AVX2, I422ToRGB565Row_AVX2, 1, 0, 2, 15)
  175. #endif
  176. #ifdef HAS_I422TOARGBROW_NEON
  177. ANY31C(I444ToARGBRow_Any_NEON, I444ToARGBRow_NEON, 0, 0, 4, 7)
  178. ANY31C(I422ToARGBRow_Any_NEON, I422ToARGBRow_NEON, 1, 0, 4, 7)
  179. ANY31C(I422ToRGBARow_Any_NEON, I422ToRGBARow_NEON, 1, 0, 4, 7)
  180. ANY31C(I422ToRGB24Row_Any_NEON, I422ToRGB24Row_NEON, 1, 0, 3, 7)
  181. ANY31C(I422ToARGB4444Row_Any_NEON, I422ToARGB4444Row_NEON, 1, 0, 2, 7)
  182. ANY31C(I422ToARGB1555Row_Any_NEON, I422ToARGB1555Row_NEON, 1, 0, 2, 7)
  183. ANY31C(I422ToRGB565Row_Any_NEON, I422ToRGB565Row_NEON, 1, 0, 2, 7)
  184. #endif
  185. #ifdef HAS_I422TOARGBROW_MSA
  186. ANY31C(I444ToARGBRow_Any_MSA, I444ToARGBRow_MSA, 0, 0, 4, 7)
  187. ANY31C(I422ToARGBRow_Any_MSA, I422ToARGBRow_MSA, 1, 0, 4, 7)
  188. ANY31C(I422ToRGBARow_Any_MSA, I422ToRGBARow_MSA, 1, 0, 4, 7)
  189. ANY31C(I422ToRGB24Row_Any_MSA, I422ToRGB24Row_MSA, 1, 0, 3, 15)
  190. ANY31C(I422ToARGB4444Row_Any_MSA, I422ToARGB4444Row_MSA, 1, 0, 2, 7)
  191. ANY31C(I422ToARGB1555Row_Any_MSA, I422ToARGB1555Row_MSA, 1, 0, 2, 7)
  192. ANY31C(I422ToRGB565Row_Any_MSA, I422ToRGB565Row_MSA, 1, 0, 2, 7)
  193. #endif
  194. #undef ANY31C
  195. // Any 3 planes of 16 bit to 1 with yuvconstants
  196. // TODO(fbarchard): consider sharing this code with ANY31C
  197. #define ANY31CT(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, T, SBPP, BPP, MASK) \
  198. void NAMEANY(const T* y_buf, const T* u_buf, const T* v_buf, \
  199. uint8_t* dst_ptr, const struct YuvConstants* yuvconstants, \
  200. int width) { \
  201. SIMD_ALIGNED(T temp[16 * 3]); \
  202. SIMD_ALIGNED(uint8_t out[64]); \
  203. memset(temp, 0, 16 * 3 * SBPP); /* for YUY2 and msan */ \
  204. int r = width & MASK; \
  205. int n = width & ~MASK; \
  206. if (n > 0) { \
  207. ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, yuvconstants, n); \
  208. } \
  209. memcpy(temp, y_buf + n, r * SBPP); \
  210. memcpy(temp + 16, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT) * SBPP); \
  211. memcpy(temp + 32, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT) * SBPP); \
  212. ANY_SIMD(temp, temp + 16, temp + 32, out, yuvconstants, MASK + 1); \
  213. memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, out, SS(r, DUVSHIFT) * BPP); \
  214. }
  215. #ifdef HAS_I210TOAR30ROW_SSSE3
  216. ANY31CT(I210ToAR30Row_Any_SSSE3, I210ToAR30Row_SSSE3, 1, 0, uint16_t, 2, 4, 7)
  217. #endif
  218. #ifdef HAS_I210TOARGBROW_SSSE3
  219. ANY31CT(I210ToARGBRow_Any_SSSE3, I210ToARGBRow_SSSE3, 1, 0, uint16_t, 2, 4, 7)
  220. #endif
  221. #ifdef HAS_I210TOARGBROW_AVX2
  222. ANY31CT(I210ToARGBRow_Any_AVX2, I210ToARGBRow_AVX2, 1, 0, uint16_t, 2, 4, 15)
  223. #endif
  224. #ifdef HAS_I210TOAR30ROW_AVX2
  225. ANY31CT(I210ToAR30Row_Any_AVX2, I210ToAR30Row_AVX2, 1, 0, uint16_t, 2, 4, 15)
  226. #endif
  227. #undef ANY31CT
  228. // Any 2 planes to 1.
  229. #define ANY21(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, SBPP2, BPP, MASK) \
  230. void NAMEANY(const uint8_t* y_buf, const uint8_t* uv_buf, uint8_t* dst_ptr, \
  231. int width) { \
  232. SIMD_ALIGNED(uint8_t temp[64 * 3]); \
  233. memset(temp, 0, 64 * 2); /* for msan */ \
  234. int r = width & MASK; \
  235. int n = width & ~MASK; \
  236. if (n > 0) { \
  237. ANY_SIMD(y_buf, uv_buf, dst_ptr, n); \
  238. } \
  239. memcpy(temp, y_buf + n * SBPP, r * SBPP); \
  240. memcpy(temp + 64, uv_buf + (n >> UVSHIFT) * SBPP2, \
  241. SS(r, UVSHIFT) * SBPP2); \
  242. ANY_SIMD(temp, temp + 64, temp + 128, MASK + 1); \
  243. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  244. }
  245. // Merge functions.
  246. #ifdef HAS_MERGEUVROW_SSE2
  247. ANY21(MergeUVRow_Any_SSE2, MergeUVRow_SSE2, 0, 1, 1, 2, 15)
  248. #endif
  249. #ifdef HAS_MERGEUVROW_AVX2
  250. ANY21(MergeUVRow_Any_AVX2, MergeUVRow_AVX2, 0, 1, 1, 2, 31)
  251. #endif
  252. #ifdef HAS_MERGEUVROW_NEON
  253. ANY21(MergeUVRow_Any_NEON, MergeUVRow_NEON, 0, 1, 1, 2, 15)
  254. #endif
  255. #ifdef HAS_MERGEUVROW_MSA
  256. ANY21(MergeUVRow_Any_MSA, MergeUVRow_MSA, 0, 1, 1, 2, 15)
  257. #endif
  258. // Math functions.
  259. #ifdef HAS_ARGBMULTIPLYROW_SSE2
  260. ANY21(ARGBMultiplyRow_Any_SSE2, ARGBMultiplyRow_SSE2, 0, 4, 4, 4, 3)
  261. #endif
  262. #ifdef HAS_ARGBADDROW_SSE2
  263. ANY21(ARGBAddRow_Any_SSE2, ARGBAddRow_SSE2, 0, 4, 4, 4, 3)
  264. #endif
  265. #ifdef HAS_ARGBSUBTRACTROW_SSE2
  266. ANY21(ARGBSubtractRow_Any_SSE2, ARGBSubtractRow_SSE2, 0, 4, 4, 4, 3)
  267. #endif
  268. #ifdef HAS_ARGBMULTIPLYROW_AVX2
  269. ANY21(ARGBMultiplyRow_Any_AVX2, ARGBMultiplyRow_AVX2, 0, 4, 4, 4, 7)
  270. #endif
  271. #ifdef HAS_ARGBADDROW_AVX2
  272. ANY21(ARGBAddRow_Any_AVX2, ARGBAddRow_AVX2, 0, 4, 4, 4, 7)
  273. #endif
  274. #ifdef HAS_ARGBSUBTRACTROW_AVX2
  275. ANY21(ARGBSubtractRow_Any_AVX2, ARGBSubtractRow_AVX2, 0, 4, 4, 4, 7)
  276. #endif
  277. #ifdef HAS_ARGBMULTIPLYROW_NEON
  278. ANY21(ARGBMultiplyRow_Any_NEON, ARGBMultiplyRow_NEON, 0, 4, 4, 4, 7)
  279. #endif
  280. #ifdef HAS_ARGBADDROW_NEON
  281. ANY21(ARGBAddRow_Any_NEON, ARGBAddRow_NEON, 0, 4, 4, 4, 7)
  282. #endif
  283. #ifdef HAS_ARGBSUBTRACTROW_NEON
  284. ANY21(ARGBSubtractRow_Any_NEON, ARGBSubtractRow_NEON, 0, 4, 4, 4, 7)
  285. #endif
  286. #ifdef HAS_ARGBMULTIPLYROW_MSA
  287. ANY21(ARGBMultiplyRow_Any_MSA, ARGBMultiplyRow_MSA, 0, 4, 4, 4, 3)
  288. #endif
  289. #ifdef HAS_ARGBADDROW_MSA
  290. ANY21(ARGBAddRow_Any_MSA, ARGBAddRow_MSA, 0, 4, 4, 4, 7)
  291. #endif
  292. #ifdef HAS_ARGBSUBTRACTROW_MSA
  293. ANY21(ARGBSubtractRow_Any_MSA, ARGBSubtractRow_MSA, 0, 4, 4, 4, 7)
  294. #endif
  295. #ifdef HAS_SOBELROW_SSE2
  296. ANY21(SobelRow_Any_SSE2, SobelRow_SSE2, 0, 1, 1, 4, 15)
  297. #endif
  298. #ifdef HAS_SOBELROW_NEON
  299. ANY21(SobelRow_Any_NEON, SobelRow_NEON, 0, 1, 1, 4, 7)
  300. #endif
  301. #ifdef HAS_SOBELROW_MSA
  302. ANY21(SobelRow_Any_MSA, SobelRow_MSA, 0, 1, 1, 4, 15)
  303. #endif
  304. #ifdef HAS_SOBELTOPLANEROW_SSE2
  305. ANY21(SobelToPlaneRow_Any_SSE2, SobelToPlaneRow_SSE2, 0, 1, 1, 1, 15)
  306. #endif
  307. #ifdef HAS_SOBELTOPLANEROW_NEON
  308. ANY21(SobelToPlaneRow_Any_NEON, SobelToPlaneRow_NEON, 0, 1, 1, 1, 15)
  309. #endif
  310. #ifdef HAS_SOBELTOPLANEROW_MSA
  311. ANY21(SobelToPlaneRow_Any_MSA, SobelToPlaneRow_MSA, 0, 1, 1, 1, 31)
  312. #endif
  313. #ifdef HAS_SOBELXYROW_SSE2
  314. ANY21(SobelXYRow_Any_SSE2, SobelXYRow_SSE2, 0, 1, 1, 4, 15)
  315. #endif
  316. #ifdef HAS_SOBELXYROW_NEON
  317. ANY21(SobelXYRow_Any_NEON, SobelXYRow_NEON, 0, 1, 1, 4, 7)
  318. #endif
  319. #ifdef HAS_SOBELXYROW_MSA
  320. ANY21(SobelXYRow_Any_MSA, SobelXYRow_MSA, 0, 1, 1, 4, 15)
  321. #endif
  322. #undef ANY21
  323. // Any 2 planes to 1 with yuvconstants
  324. #define ANY21C(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, SBPP2, BPP, MASK) \
  325. void NAMEANY(const uint8_t* y_buf, const uint8_t* uv_buf, uint8_t* dst_ptr, \
  326. const struct YuvConstants* yuvconstants, int width) { \
  327. SIMD_ALIGNED(uint8_t temp[128 * 3]); \
  328. memset(temp, 0, 128 * 2); /* for msan */ \
  329. int r = width & MASK; \
  330. int n = width & ~MASK; \
  331. if (n > 0) { \
  332. ANY_SIMD(y_buf, uv_buf, dst_ptr, yuvconstants, n); \
  333. } \
  334. memcpy(temp, y_buf + n * SBPP, r * SBPP); \
  335. memcpy(temp + 128, uv_buf + (n >> UVSHIFT) * SBPP2, \
  336. SS(r, UVSHIFT) * SBPP2); \
  337. ANY_SIMD(temp, temp + 128, temp + 256, yuvconstants, MASK + 1); \
  338. memcpy(dst_ptr + n * BPP, temp + 256, r * BPP); \
  339. }
  340. // Biplanar to RGB.
  341. #ifdef HAS_NV12TOARGBROW_SSSE3
  342. ANY21C(NV12ToARGBRow_Any_SSSE3, NV12ToARGBRow_SSSE3, 1, 1, 2, 4, 7)
  343. #endif
  344. #ifdef HAS_NV12TOARGBROW_AVX2
  345. ANY21C(NV12ToARGBRow_Any_AVX2, NV12ToARGBRow_AVX2, 1, 1, 2, 4, 15)
  346. #endif
  347. #ifdef HAS_NV12TOARGBROW_NEON
  348. ANY21C(NV12ToARGBRow_Any_NEON, NV12ToARGBRow_NEON, 1, 1, 2, 4, 7)
  349. #endif
  350. #ifdef HAS_NV12TOARGBROW_MSA
  351. ANY21C(NV12ToARGBRow_Any_MSA, NV12ToARGBRow_MSA, 1, 1, 2, 4, 7)
  352. #endif
  353. #ifdef HAS_NV21TOARGBROW_SSSE3
  354. ANY21C(NV21ToARGBRow_Any_SSSE3, NV21ToARGBRow_SSSE3, 1, 1, 2, 4, 7)
  355. #endif
  356. #ifdef HAS_NV21TOARGBROW_AVX2
  357. ANY21C(NV21ToARGBRow_Any_AVX2, NV21ToARGBRow_AVX2, 1, 1, 2, 4, 15)
  358. #endif
  359. #ifdef HAS_NV21TOARGBROW_NEON
  360. ANY21C(NV21ToARGBRow_Any_NEON, NV21ToARGBRow_NEON, 1, 1, 2, 4, 7)
  361. #endif
  362. #ifdef HAS_NV21TOARGBROW_MSA
  363. ANY21C(NV21ToARGBRow_Any_MSA, NV21ToARGBRow_MSA, 1, 1, 2, 4, 7)
  364. #endif
  365. #ifdef HAS_NV12TORGB24ROW_NEON
  366. ANY21C(NV12ToRGB24Row_Any_NEON, NV12ToRGB24Row_NEON, 1, 1, 2, 3, 7)
  367. #endif
  368. #ifdef HAS_NV21TORGB24ROW_NEON
  369. ANY21C(NV21ToRGB24Row_Any_NEON, NV21ToRGB24Row_NEON, 1, 1, 2, 3, 7)
  370. #endif
  371. #ifdef HAS_NV12TORGB24ROW_SSSE3
  372. ANY21C(NV12ToRGB24Row_Any_SSSE3, NV12ToRGB24Row_SSSE3, 1, 1, 2, 3, 15)
  373. #endif
  374. #ifdef HAS_NV21TORGB24ROW_SSSE3
  375. ANY21C(NV21ToRGB24Row_Any_SSSE3, NV21ToRGB24Row_SSSE3, 1, 1, 2, 3, 15)
  376. #endif
  377. #ifdef HAS_NV12TORGB24ROW_AVX2
  378. ANY21C(NV12ToRGB24Row_Any_AVX2, NV12ToRGB24Row_AVX2, 1, 1, 2, 3, 31)
  379. #endif
  380. #ifdef HAS_NV21TORGB24ROW_AVX2
  381. ANY21C(NV21ToRGB24Row_Any_AVX2, NV21ToRGB24Row_AVX2, 1, 1, 2, 3, 31)
  382. #endif
  383. #ifdef HAS_NV12TORGB565ROW_SSSE3
  384. ANY21C(NV12ToRGB565Row_Any_SSSE3, NV12ToRGB565Row_SSSE3, 1, 1, 2, 2, 7)
  385. #endif
  386. #ifdef HAS_NV12TORGB565ROW_AVX2
  387. ANY21C(NV12ToRGB565Row_Any_AVX2, NV12ToRGB565Row_AVX2, 1, 1, 2, 2, 15)
  388. #endif
  389. #ifdef HAS_NV12TORGB565ROW_NEON
  390. ANY21C(NV12ToRGB565Row_Any_NEON, NV12ToRGB565Row_NEON, 1, 1, 2, 2, 7)
  391. #endif
  392. #ifdef HAS_NV12TORGB565ROW_MSA
  393. ANY21C(NV12ToRGB565Row_Any_MSA, NV12ToRGB565Row_MSA, 1, 1, 2, 2, 7)
  394. #endif
  395. #undef ANY21C
  396. // Any 1 to 1.
  397. #define ANY11(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
  398. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, int width) { \
  399. SIMD_ALIGNED(uint8_t temp[128 * 2]); \
  400. memset(temp, 0, 128); /* for YUY2 and msan */ \
  401. int r = width & MASK; \
  402. int n = width & ~MASK; \
  403. if (n > 0) { \
  404. ANY_SIMD(src_ptr, dst_ptr, n); \
  405. } \
  406. memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
  407. ANY_SIMD(temp, temp + 128, MASK + 1); \
  408. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  409. }
  410. #ifdef HAS_COPYROW_AVX
  411. ANY11(CopyRow_Any_AVX, CopyRow_AVX, 0, 1, 1, 63)
  412. #endif
  413. #ifdef HAS_COPYROW_SSE2
  414. ANY11(CopyRow_Any_SSE2, CopyRow_SSE2, 0, 1, 1, 31)
  415. #endif
  416. #ifdef HAS_COPYROW_NEON
  417. ANY11(CopyRow_Any_NEON, CopyRow_NEON, 0, 1, 1, 31)
  418. #endif
  419. #if defined(HAS_ARGBTORGB24ROW_SSSE3)
  420. ANY11(ARGBToRGB24Row_Any_SSSE3, ARGBToRGB24Row_SSSE3, 0, 4, 3, 15)
  421. ANY11(ARGBToRAWRow_Any_SSSE3, ARGBToRAWRow_SSSE3, 0, 4, 3, 15)
  422. ANY11(ARGBToRGB565Row_Any_SSE2, ARGBToRGB565Row_SSE2, 0, 4, 2, 3)
  423. ANY11(ARGBToARGB1555Row_Any_SSE2, ARGBToARGB1555Row_SSE2, 0, 4, 2, 3)
  424. ANY11(ARGBToARGB4444Row_Any_SSE2, ARGBToARGB4444Row_SSE2, 0, 4, 2, 3)
  425. #endif
  426. #if defined(HAS_ARGBTORGB24ROW_AVX2)
  427. ANY11(ARGBToRGB24Row_Any_AVX2, ARGBToRGB24Row_AVX2, 0, 4, 3, 31)
  428. #endif
  429. #if defined(HAS_ARGBTORGB24ROW_AVX512VBMI)
  430. ANY11(ARGBToRGB24Row_Any_AVX512VBMI, ARGBToRGB24Row_AVX512VBMI, 0, 4, 3, 31)
  431. #endif
  432. #if defined(HAS_ARGBTORAWROW_AVX2)
  433. ANY11(ARGBToRAWRow_Any_AVX2, ARGBToRAWRow_AVX2, 0, 4, 3, 31)
  434. #endif
  435. #if defined(HAS_ARGBTORGB565ROW_AVX2)
  436. ANY11(ARGBToRGB565Row_Any_AVX2, ARGBToRGB565Row_AVX2, 0, 4, 2, 7)
  437. #endif
  438. #if defined(HAS_ARGBTOARGB4444ROW_AVX2)
  439. ANY11(ARGBToARGB1555Row_Any_AVX2, ARGBToARGB1555Row_AVX2, 0, 4, 2, 7)
  440. ANY11(ARGBToARGB4444Row_Any_AVX2, ARGBToARGB4444Row_AVX2, 0, 4, 2, 7)
  441. #endif
  442. #if defined(HAS_ABGRTOAR30ROW_SSSE3)
  443. ANY11(ABGRToAR30Row_Any_SSSE3, ABGRToAR30Row_SSSE3, 0, 4, 4, 3)
  444. #endif
  445. #if defined(HAS_ARGBTOAR30ROW_SSSE3)
  446. ANY11(ARGBToAR30Row_Any_SSSE3, ARGBToAR30Row_SSSE3, 0, 4, 4, 3)
  447. #endif
  448. #if defined(HAS_ABGRTOAR30ROW_AVX2)
  449. ANY11(ABGRToAR30Row_Any_AVX2, ABGRToAR30Row_AVX2, 0, 4, 4, 7)
  450. #endif
  451. #if defined(HAS_ARGBTOAR30ROW_AVX2)
  452. ANY11(ARGBToAR30Row_Any_AVX2, ARGBToAR30Row_AVX2, 0, 4, 4, 7)
  453. #endif
  454. #if defined(HAS_J400TOARGBROW_SSE2)
  455. ANY11(J400ToARGBRow_Any_SSE2, J400ToARGBRow_SSE2, 0, 1, 4, 7)
  456. #endif
  457. #if defined(HAS_J400TOARGBROW_AVX2)
  458. ANY11(J400ToARGBRow_Any_AVX2, J400ToARGBRow_AVX2, 0, 1, 4, 15)
  459. #endif
  460. #if defined(HAS_I400TOARGBROW_SSE2)
  461. ANY11(I400ToARGBRow_Any_SSE2, I400ToARGBRow_SSE2, 0, 1, 4, 7)
  462. #endif
  463. #if defined(HAS_I400TOARGBROW_AVX2)
  464. ANY11(I400ToARGBRow_Any_AVX2, I400ToARGBRow_AVX2, 0, 1, 4, 15)
  465. #endif
  466. #if defined(HAS_RGB24TOARGBROW_SSSE3)
  467. ANY11(RGB24ToARGBRow_Any_SSSE3, RGB24ToARGBRow_SSSE3, 0, 3, 4, 15)
  468. ANY11(RAWToARGBRow_Any_SSSE3, RAWToARGBRow_SSSE3, 0, 3, 4, 15)
  469. ANY11(RGB565ToARGBRow_Any_SSE2, RGB565ToARGBRow_SSE2, 0, 2, 4, 7)
  470. ANY11(ARGB1555ToARGBRow_Any_SSE2, ARGB1555ToARGBRow_SSE2, 0, 2, 4, 7)
  471. ANY11(ARGB4444ToARGBRow_Any_SSE2, ARGB4444ToARGBRow_SSE2, 0, 2, 4, 7)
  472. #endif
  473. #if defined(HAS_RAWTORGB24ROW_SSSE3)
  474. ANY11(RAWToRGB24Row_Any_SSSE3, RAWToRGB24Row_SSSE3, 0, 3, 3, 7)
  475. #endif
  476. #if defined(HAS_RGB565TOARGBROW_AVX2)
  477. ANY11(RGB565ToARGBRow_Any_AVX2, RGB565ToARGBRow_AVX2, 0, 2, 4, 15)
  478. #endif
  479. #if defined(HAS_ARGB1555TOARGBROW_AVX2)
  480. ANY11(ARGB1555ToARGBRow_Any_AVX2, ARGB1555ToARGBRow_AVX2, 0, 2, 4, 15)
  481. #endif
  482. #if defined(HAS_ARGB4444TOARGBROW_AVX2)
  483. ANY11(ARGB4444ToARGBRow_Any_AVX2, ARGB4444ToARGBRow_AVX2, 0, 2, 4, 15)
  484. #endif
  485. #if defined(HAS_ARGBTORGB24ROW_NEON)
  486. ANY11(ARGBToRGB24Row_Any_NEON, ARGBToRGB24Row_NEON, 0, 4, 3, 7)
  487. ANY11(ARGBToRAWRow_Any_NEON, ARGBToRAWRow_NEON, 0, 4, 3, 7)
  488. ANY11(ARGBToRGB565Row_Any_NEON, ARGBToRGB565Row_NEON, 0, 4, 2, 7)
  489. ANY11(ARGBToARGB1555Row_Any_NEON, ARGBToARGB1555Row_NEON, 0, 4, 2, 7)
  490. ANY11(ARGBToARGB4444Row_Any_NEON, ARGBToARGB4444Row_NEON, 0, 4, 2, 7)
  491. ANY11(J400ToARGBRow_Any_NEON, J400ToARGBRow_NEON, 0, 1, 4, 7)
  492. ANY11(I400ToARGBRow_Any_NEON, I400ToARGBRow_NEON, 0, 1, 4, 7)
  493. #endif
  494. #if defined(HAS_ARGBTORGB24ROW_MSA)
  495. ANY11(ARGBToRGB24Row_Any_MSA, ARGBToRGB24Row_MSA, 0, 4, 3, 15)
  496. ANY11(ARGBToRAWRow_Any_MSA, ARGBToRAWRow_MSA, 0, 4, 3, 15)
  497. ANY11(ARGBToRGB565Row_Any_MSA, ARGBToRGB565Row_MSA, 0, 4, 2, 7)
  498. ANY11(ARGBToARGB1555Row_Any_MSA, ARGBToARGB1555Row_MSA, 0, 4, 2, 7)
  499. ANY11(ARGBToARGB4444Row_Any_MSA, ARGBToARGB4444Row_MSA, 0, 4, 2, 7)
  500. ANY11(J400ToARGBRow_Any_MSA, J400ToARGBRow_MSA, 0, 1, 4, 15)
  501. ANY11(I400ToARGBRow_Any_MSA, I400ToARGBRow_MSA, 0, 1, 4, 15)
  502. #endif
  503. #if defined(HAS_RAWTORGB24ROW_NEON)
  504. ANY11(RAWToRGB24Row_Any_NEON, RAWToRGB24Row_NEON, 0, 3, 3, 7)
  505. #endif
  506. #if defined(HAS_RAWTORGB24ROW_MSA)
  507. ANY11(RAWToRGB24Row_Any_MSA, RAWToRGB24Row_MSA, 0, 3, 3, 15)
  508. #endif
  509. #ifdef HAS_ARGBTOYROW_AVX2
  510. ANY11(ARGBToYRow_Any_AVX2, ARGBToYRow_AVX2, 0, 4, 1, 31)
  511. #endif
  512. #ifdef HAS_ARGBTOYJROW_AVX2
  513. ANY11(ARGBToYJRow_Any_AVX2, ARGBToYJRow_AVX2, 0, 4, 1, 31)
  514. #endif
  515. #ifdef HAS_UYVYTOYROW_AVX2
  516. ANY11(UYVYToYRow_Any_AVX2, UYVYToYRow_AVX2, 0, 2, 1, 31)
  517. #endif
  518. #ifdef HAS_YUY2TOYROW_AVX2
  519. ANY11(YUY2ToYRow_Any_AVX2, YUY2ToYRow_AVX2, 1, 4, 1, 31)
  520. #endif
  521. #ifdef HAS_ARGBTOYROW_SSSE3
  522. ANY11(ARGBToYRow_Any_SSSE3, ARGBToYRow_SSSE3, 0, 4, 1, 15)
  523. #endif
  524. #ifdef HAS_BGRATOYROW_SSSE3
  525. ANY11(BGRAToYRow_Any_SSSE3, BGRAToYRow_SSSE3, 0, 4, 1, 15)
  526. ANY11(ABGRToYRow_Any_SSSE3, ABGRToYRow_SSSE3, 0, 4, 1, 15)
  527. ANY11(RGBAToYRow_Any_SSSE3, RGBAToYRow_SSSE3, 0, 4, 1, 15)
  528. ANY11(YUY2ToYRow_Any_SSE2, YUY2ToYRow_SSE2, 1, 4, 1, 15)
  529. ANY11(UYVYToYRow_Any_SSE2, UYVYToYRow_SSE2, 1, 4, 1, 15)
  530. #endif
  531. #ifdef HAS_ARGBTOYJROW_SSSE3
  532. ANY11(ARGBToYJRow_Any_SSSE3, ARGBToYJRow_SSSE3, 0, 4, 1, 15)
  533. #endif
  534. #ifdef HAS_ARGBTOYROW_NEON
  535. ANY11(ARGBToYRow_Any_NEON, ARGBToYRow_NEON, 0, 4, 1, 7)
  536. #endif
  537. #ifdef HAS_ARGBTOYROW_MSA
  538. ANY11(ARGBToYRow_Any_MSA, ARGBToYRow_MSA, 0, 4, 1, 15)
  539. #endif
  540. #ifdef HAS_ARGBTOYJROW_NEON
  541. ANY11(ARGBToYJRow_Any_NEON, ARGBToYJRow_NEON, 0, 4, 1, 7)
  542. #endif
  543. #ifdef HAS_ARGBTOYJROW_MSA
  544. ANY11(ARGBToYJRow_Any_MSA, ARGBToYJRow_MSA, 0, 4, 1, 15)
  545. #endif
  546. #ifdef HAS_BGRATOYROW_NEON
  547. ANY11(BGRAToYRow_Any_NEON, BGRAToYRow_NEON, 0, 4, 1, 7)
  548. #endif
  549. #ifdef HAS_BGRATOYROW_MSA
  550. ANY11(BGRAToYRow_Any_MSA, BGRAToYRow_MSA, 0, 4, 1, 15)
  551. #endif
  552. #ifdef HAS_ABGRTOYROW_NEON
  553. ANY11(ABGRToYRow_Any_NEON, ABGRToYRow_NEON, 0, 4, 1, 7)
  554. #endif
  555. #ifdef HAS_ABGRTOYROW_MSA
  556. ANY11(ABGRToYRow_Any_MSA, ABGRToYRow_MSA, 0, 4, 1, 7)
  557. #endif
  558. #ifdef HAS_RGBATOYROW_NEON
  559. ANY11(RGBAToYRow_Any_NEON, RGBAToYRow_NEON, 0, 4, 1, 7)
  560. #endif
  561. #ifdef HAS_RGBATOYROW_MSA
  562. ANY11(RGBAToYRow_Any_MSA, RGBAToYRow_MSA, 0, 4, 1, 15)
  563. #endif
  564. #ifdef HAS_RGB24TOYROW_NEON
  565. ANY11(RGB24ToYRow_Any_NEON, RGB24ToYRow_NEON, 0, 3, 1, 7)
  566. #endif
  567. #ifdef HAS_RGB24TOYROW_MSA
  568. ANY11(RGB24ToYRow_Any_MSA, RGB24ToYRow_MSA, 0, 3, 1, 15)
  569. #endif
  570. #ifdef HAS_RAWTOYROW_NEON
  571. ANY11(RAWToYRow_Any_NEON, RAWToYRow_NEON, 0, 3, 1, 7)
  572. #endif
  573. #ifdef HAS_RAWTOYROW_MSA
  574. ANY11(RAWToYRow_Any_MSA, RAWToYRow_MSA, 0, 3, 1, 15)
  575. #endif
  576. #ifdef HAS_RGB565TOYROW_NEON
  577. ANY11(RGB565ToYRow_Any_NEON, RGB565ToYRow_NEON, 0, 2, 1, 7)
  578. #endif
  579. #ifdef HAS_RGB565TOYROW_MSA
  580. ANY11(RGB565ToYRow_Any_MSA, RGB565ToYRow_MSA, 0, 2, 1, 15)
  581. #endif
  582. #ifdef HAS_ARGB1555TOYROW_NEON
  583. ANY11(ARGB1555ToYRow_Any_NEON, ARGB1555ToYRow_NEON, 0, 2, 1, 7)
  584. #endif
  585. #ifdef HAS_ARGB1555TOYROW_MSA
  586. ANY11(ARGB1555ToYRow_Any_MSA, ARGB1555ToYRow_MSA, 0, 2, 1, 15)
  587. #endif
  588. #ifdef HAS_ARGB4444TOYROW_NEON
  589. ANY11(ARGB4444ToYRow_Any_NEON, ARGB4444ToYRow_NEON, 0, 2, 1, 7)
  590. #endif
  591. #ifdef HAS_YUY2TOYROW_NEON
  592. ANY11(YUY2ToYRow_Any_NEON, YUY2ToYRow_NEON, 1, 4, 1, 15)
  593. #endif
  594. #ifdef HAS_UYVYTOYROW_NEON
  595. ANY11(UYVYToYRow_Any_NEON, UYVYToYRow_NEON, 1, 4, 1, 15)
  596. #endif
  597. #ifdef HAS_YUY2TOYROW_MSA
  598. ANY11(YUY2ToYRow_Any_MSA, YUY2ToYRow_MSA, 1, 4, 1, 31)
  599. #endif
  600. #ifdef HAS_UYVYTOYROW_MSA
  601. ANY11(UYVYToYRow_Any_MSA, UYVYToYRow_MSA, 1, 4, 1, 31)
  602. #endif
  603. #ifdef HAS_RGB24TOARGBROW_NEON
  604. ANY11(RGB24ToARGBRow_Any_NEON, RGB24ToARGBRow_NEON, 0, 3, 4, 7)
  605. #endif
  606. #ifdef HAS_RGB24TOARGBROW_MSA
  607. ANY11(RGB24ToARGBRow_Any_MSA, RGB24ToARGBRow_MSA, 0, 3, 4, 15)
  608. #endif
  609. #ifdef HAS_RAWTOARGBROW_NEON
  610. ANY11(RAWToARGBRow_Any_NEON, RAWToARGBRow_NEON, 0, 3, 4, 7)
  611. #endif
  612. #ifdef HAS_RAWTOARGBROW_MSA
  613. ANY11(RAWToARGBRow_Any_MSA, RAWToARGBRow_MSA, 0, 3, 4, 15)
  614. #endif
  615. #ifdef HAS_RGB565TOARGBROW_NEON
  616. ANY11(RGB565ToARGBRow_Any_NEON, RGB565ToARGBRow_NEON, 0, 2, 4, 7)
  617. #endif
  618. #ifdef HAS_RGB565TOARGBROW_MSA
  619. ANY11(RGB565ToARGBRow_Any_MSA, RGB565ToARGBRow_MSA, 0, 2, 4, 15)
  620. #endif
  621. #ifdef HAS_ARGB1555TOARGBROW_NEON
  622. ANY11(ARGB1555ToARGBRow_Any_NEON, ARGB1555ToARGBRow_NEON, 0, 2, 4, 7)
  623. #endif
  624. #ifdef HAS_ARGB1555TOARGBROW_MSA
  625. ANY11(ARGB1555ToARGBRow_Any_MSA, ARGB1555ToARGBRow_MSA, 0, 2, 4, 15)
  626. #endif
  627. #ifdef HAS_ARGB4444TOARGBROW_NEON
  628. ANY11(ARGB4444ToARGBRow_Any_NEON, ARGB4444ToARGBRow_NEON, 0, 2, 4, 7)
  629. #endif
  630. #ifdef HAS_ARGB4444TOARGBROW_MSA
  631. ANY11(ARGB4444ToARGBRow_Any_MSA, ARGB4444ToARGBRow_MSA, 0, 2, 4, 15)
  632. #endif
  633. #ifdef HAS_ARGBATTENUATEROW_SSSE3
  634. ANY11(ARGBAttenuateRow_Any_SSSE3, ARGBAttenuateRow_SSSE3, 0, 4, 4, 3)
  635. #endif
  636. #ifdef HAS_ARGBUNATTENUATEROW_SSE2
  637. ANY11(ARGBUnattenuateRow_Any_SSE2, ARGBUnattenuateRow_SSE2, 0, 4, 4, 3)
  638. #endif
  639. #ifdef HAS_ARGBATTENUATEROW_AVX2
  640. ANY11(ARGBAttenuateRow_Any_AVX2, ARGBAttenuateRow_AVX2, 0, 4, 4, 7)
  641. #endif
  642. #ifdef HAS_ARGBUNATTENUATEROW_AVX2
  643. ANY11(ARGBUnattenuateRow_Any_AVX2, ARGBUnattenuateRow_AVX2, 0, 4, 4, 7)
  644. #endif
  645. #ifdef HAS_ARGBATTENUATEROW_NEON
  646. ANY11(ARGBAttenuateRow_Any_NEON, ARGBAttenuateRow_NEON, 0, 4, 4, 7)
  647. #endif
  648. #ifdef HAS_ARGBATTENUATEROW_MSA
  649. ANY11(ARGBAttenuateRow_Any_MSA, ARGBAttenuateRow_MSA, 0, 4, 4, 7)
  650. #endif
  651. #ifdef HAS_ARGBEXTRACTALPHAROW_SSE2
  652. ANY11(ARGBExtractAlphaRow_Any_SSE2, ARGBExtractAlphaRow_SSE2, 0, 4, 1, 7)
  653. #endif
  654. #ifdef HAS_ARGBEXTRACTALPHAROW_AVX2
  655. ANY11(ARGBExtractAlphaRow_Any_AVX2, ARGBExtractAlphaRow_AVX2, 0, 4, 1, 31)
  656. #endif
  657. #ifdef HAS_ARGBEXTRACTALPHAROW_NEON
  658. ANY11(ARGBExtractAlphaRow_Any_NEON, ARGBExtractAlphaRow_NEON, 0, 4, 1, 15)
  659. #endif
  660. #ifdef HAS_ARGBEXTRACTALPHAROW_MSA
  661. ANY11(ARGBExtractAlphaRow_Any_MSA, ARGBExtractAlphaRow_MSA, 0, 4, 1, 15)
  662. #endif
  663. #undef ANY11
  664. // Any 1 to 1 blended. Destination is read, modify, write.
  665. #define ANY11B(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
  666. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, int width) { \
  667. SIMD_ALIGNED(uint8_t temp[64 * 2]); \
  668. memset(temp, 0, 64 * 2); /* for msan */ \
  669. int r = width & MASK; \
  670. int n = width & ~MASK; \
  671. if (n > 0) { \
  672. ANY_SIMD(src_ptr, dst_ptr, n); \
  673. } \
  674. memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
  675. memcpy(temp + 64, dst_ptr + n * BPP, r * BPP); \
  676. ANY_SIMD(temp, temp + 64, MASK + 1); \
  677. memcpy(dst_ptr + n * BPP, temp + 64, r * BPP); \
  678. }
  679. #ifdef HAS_ARGBCOPYALPHAROW_AVX2
  680. ANY11B(ARGBCopyAlphaRow_Any_AVX2, ARGBCopyAlphaRow_AVX2, 0, 4, 4, 15)
  681. #endif
  682. #ifdef HAS_ARGBCOPYALPHAROW_SSE2
  683. ANY11B(ARGBCopyAlphaRow_Any_SSE2, ARGBCopyAlphaRow_SSE2, 0, 4, 4, 7)
  684. #endif
  685. #ifdef HAS_ARGBCOPYYTOALPHAROW_AVX2
  686. ANY11B(ARGBCopyYToAlphaRow_Any_AVX2, ARGBCopyYToAlphaRow_AVX2, 0, 1, 4, 15)
  687. #endif
  688. #ifdef HAS_ARGBCOPYYTOALPHAROW_SSE2
  689. ANY11B(ARGBCopyYToAlphaRow_Any_SSE2, ARGBCopyYToAlphaRow_SSE2, 0, 1, 4, 7)
  690. #endif
  691. #undef ANY11B
  692. // Any 1 to 1 with parameter.
  693. #define ANY11P(NAMEANY, ANY_SIMD, T, SBPP, BPP, MASK) \
  694. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, T param, int width) { \
  695. SIMD_ALIGNED(uint8_t temp[64 * 2]); \
  696. memset(temp, 0, 64); /* for msan */ \
  697. int r = width & MASK; \
  698. int n = width & ~MASK; \
  699. if (n > 0) { \
  700. ANY_SIMD(src_ptr, dst_ptr, param, n); \
  701. } \
  702. memcpy(temp, src_ptr + n * SBPP, r * SBPP); \
  703. ANY_SIMD(temp, temp + 64, param, MASK + 1); \
  704. memcpy(dst_ptr + n * BPP, temp + 64, r * BPP); \
  705. }
  706. #if defined(HAS_ARGBTORGB565DITHERROW_SSE2)
  707. ANY11P(ARGBToRGB565DitherRow_Any_SSE2,
  708. ARGBToRGB565DitherRow_SSE2,
  709. const uint32_t,
  710. 4,
  711. 2,
  712. 3)
  713. #endif
  714. #if defined(HAS_ARGBTORGB565DITHERROW_AVX2)
  715. ANY11P(ARGBToRGB565DitherRow_Any_AVX2,
  716. ARGBToRGB565DitherRow_AVX2,
  717. const uint32_t,
  718. 4,
  719. 2,
  720. 7)
  721. #endif
  722. #if defined(HAS_ARGBTORGB565DITHERROW_NEON)
  723. ANY11P(ARGBToRGB565DitherRow_Any_NEON,
  724. ARGBToRGB565DitherRow_NEON,
  725. const uint32_t,
  726. 4,
  727. 2,
  728. 7)
  729. #endif
  730. #if defined(HAS_ARGBTORGB565DITHERROW_MSA)
  731. ANY11P(ARGBToRGB565DitherRow_Any_MSA,
  732. ARGBToRGB565DitherRow_MSA,
  733. const uint32_t,
  734. 4,
  735. 2,
  736. 7)
  737. #endif
  738. #ifdef HAS_ARGBSHUFFLEROW_SSSE3
  739. ANY11P(ARGBShuffleRow_Any_SSSE3, ARGBShuffleRow_SSSE3, const uint8_t*, 4, 4, 7)
  740. #endif
  741. #ifdef HAS_ARGBSHUFFLEROW_AVX2
  742. ANY11P(ARGBShuffleRow_Any_AVX2, ARGBShuffleRow_AVX2, const uint8_t*, 4, 4, 15)
  743. #endif
  744. #ifdef HAS_ARGBSHUFFLEROW_NEON
  745. ANY11P(ARGBShuffleRow_Any_NEON, ARGBShuffleRow_NEON, const uint8_t*, 4, 4, 3)
  746. #endif
  747. #ifdef HAS_ARGBSHUFFLEROW_MSA
  748. ANY11P(ARGBShuffleRow_Any_MSA, ARGBShuffleRow_MSA, const uint8_t*, 4, 4, 7)
  749. #endif
  750. #undef ANY11P
  751. // Any 1 to 1 with parameter and shorts. BPP measures in shorts.
  752. #define ANY11C(NAMEANY, ANY_SIMD, SBPP, BPP, STYPE, DTYPE, MASK) \
  753. void NAMEANY(const STYPE* src_ptr, DTYPE* dst_ptr, int scale, int width) { \
  754. SIMD_ALIGNED(STYPE temp[32]); \
  755. SIMD_ALIGNED(DTYPE out[32]); \
  756. memset(temp, 0, 32 * SBPP); /* for msan */ \
  757. int r = width & MASK; \
  758. int n = width & ~MASK; \
  759. if (n > 0) { \
  760. ANY_SIMD(src_ptr, dst_ptr, scale, n); \
  761. } \
  762. memcpy(temp, src_ptr + n, r * SBPP); \
  763. ANY_SIMD(temp, out, scale, MASK + 1); \
  764. memcpy(dst_ptr + n, out, r * BPP); \
  765. }
  766. #ifdef HAS_CONVERT16TO8ROW_SSSE3
  767. ANY11C(Convert16To8Row_Any_SSSE3,
  768. Convert16To8Row_SSSE3,
  769. 2,
  770. 1,
  771. uint16_t,
  772. uint8_t,
  773. 15)
  774. #endif
  775. #ifdef HAS_CONVERT16TO8ROW_AVX2
  776. ANY11C(Convert16To8Row_Any_AVX2,
  777. Convert16To8Row_AVX2,
  778. 2,
  779. 1,
  780. uint16_t,
  781. uint8_t,
  782. 31)
  783. #endif
  784. #ifdef HAS_CONVERT8TO16ROW_SSE2
  785. ANY11C(Convert8To16Row_Any_SSE2,
  786. Convert8To16Row_SSE2,
  787. 1,
  788. 2,
  789. uint8_t,
  790. uint16_t,
  791. 15)
  792. #endif
  793. #ifdef HAS_CONVERT8TO16ROW_AVX2
  794. ANY11C(Convert8To16Row_Any_AVX2,
  795. Convert8To16Row_AVX2,
  796. 1,
  797. 2,
  798. uint8_t,
  799. uint16_t,
  800. 31)
  801. #endif
  802. #undef ANY11C
  803. // Any 1 to 1 with parameter and shorts to byte. BPP measures in shorts.
  804. #define ANY11P16(NAMEANY, ANY_SIMD, ST, T, SBPP, BPP, MASK) \
  805. void NAMEANY(const ST* src_ptr, T* dst_ptr, float param, int width) { \
  806. SIMD_ALIGNED(ST temp[32]); \
  807. SIMD_ALIGNED(T out[32]); \
  808. memset(temp, 0, SBPP * 32); /* for msan */ \
  809. int r = width & MASK; \
  810. int n = width & ~MASK; \
  811. if (n > 0) { \
  812. ANY_SIMD(src_ptr, dst_ptr, param, n); \
  813. } \
  814. memcpy(temp, src_ptr + n, r * SBPP); \
  815. ANY_SIMD(temp, out, param, MASK + 1); \
  816. memcpy(dst_ptr + n, out, r * BPP); \
  817. }
  818. #ifdef HAS_HALFFLOATROW_SSE2
  819. ANY11P16(HalfFloatRow_Any_SSE2, HalfFloatRow_SSE2, uint16_t, uint16_t, 2, 2, 7)
  820. #endif
  821. #ifdef HAS_HALFFLOATROW_AVX2
  822. ANY11P16(HalfFloatRow_Any_AVX2, HalfFloatRow_AVX2, uint16_t, uint16_t, 2, 2, 15)
  823. #endif
  824. #ifdef HAS_HALFFLOATROW_F16C
  825. ANY11P16(HalfFloatRow_Any_F16C, HalfFloatRow_F16C, uint16_t, uint16_t, 2, 2, 15)
  826. ANY11P16(HalfFloat1Row_Any_F16C,
  827. HalfFloat1Row_F16C,
  828. uint16_t,
  829. uint16_t,
  830. 2,
  831. 2,
  832. 15)
  833. #endif
  834. #ifdef HAS_HALFFLOATROW_NEON
  835. ANY11P16(HalfFloatRow_Any_NEON, HalfFloatRow_NEON, uint16_t, uint16_t, 2, 2, 7)
  836. ANY11P16(HalfFloat1Row_Any_NEON,
  837. HalfFloat1Row_NEON,
  838. uint16_t,
  839. uint16_t,
  840. 2,
  841. 2,
  842. 7)
  843. #endif
  844. #ifdef HAS_HALFFLOATROW_MSA
  845. ANY11P16(HalfFloatRow_Any_MSA, HalfFloatRow_MSA, uint16_t, uint16_t, 2, 2, 31)
  846. #endif
  847. #ifdef HAS_BYTETOFLOATROW_NEON
  848. ANY11P16(ByteToFloatRow_Any_NEON, ByteToFloatRow_NEON, uint8_t, float, 1, 3, 7)
  849. #endif
  850. #undef ANY11P16
  851. // Any 1 to 1 with yuvconstants
  852. #define ANY11C(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
  853. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, \
  854. const struct YuvConstants* yuvconstants, int width) { \
  855. SIMD_ALIGNED(uint8_t temp[128 * 2]); \
  856. memset(temp, 0, 128); /* for YUY2 and msan */ \
  857. int r = width & MASK; \
  858. int n = width & ~MASK; \
  859. if (n > 0) { \
  860. ANY_SIMD(src_ptr, dst_ptr, yuvconstants, n); \
  861. } \
  862. memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
  863. ANY_SIMD(temp, temp + 128, yuvconstants, MASK + 1); \
  864. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  865. }
  866. #if defined(HAS_YUY2TOARGBROW_SSSE3)
  867. ANY11C(YUY2ToARGBRow_Any_SSSE3, YUY2ToARGBRow_SSSE3, 1, 4, 4, 15)
  868. ANY11C(UYVYToARGBRow_Any_SSSE3, UYVYToARGBRow_SSSE3, 1, 4, 4, 15)
  869. #endif
  870. #if defined(HAS_YUY2TOARGBROW_AVX2)
  871. ANY11C(YUY2ToARGBRow_Any_AVX2, YUY2ToARGBRow_AVX2, 1, 4, 4, 31)
  872. ANY11C(UYVYToARGBRow_Any_AVX2, UYVYToARGBRow_AVX2, 1, 4, 4, 31)
  873. #endif
  874. #if defined(HAS_YUY2TOARGBROW_NEON)
  875. ANY11C(YUY2ToARGBRow_Any_NEON, YUY2ToARGBRow_NEON, 1, 4, 4, 7)
  876. ANY11C(UYVYToARGBRow_Any_NEON, UYVYToARGBRow_NEON, 1, 4, 4, 7)
  877. #endif
  878. #if defined(HAS_YUY2TOARGBROW_MSA)
  879. ANY11C(YUY2ToARGBRow_Any_MSA, YUY2ToARGBRow_MSA, 1, 4, 4, 7)
  880. ANY11C(UYVYToARGBRow_Any_MSA, UYVYToARGBRow_MSA, 1, 4, 4, 7)
  881. #endif
  882. #undef ANY11C
  883. // Any 1 to 1 interpolate. Takes 2 rows of source via stride.
  884. #define ANY11T(NAMEANY, ANY_SIMD, SBPP, BPP, MASK) \
  885. void NAMEANY(uint8_t* dst_ptr, const uint8_t* src_ptr, \
  886. ptrdiff_t src_stride_ptr, int width, int source_y_fraction) { \
  887. SIMD_ALIGNED(uint8_t temp[64 * 3]); \
  888. memset(temp, 0, 64 * 2); /* for msan */ \
  889. int r = width & MASK; \
  890. int n = width & ~MASK; \
  891. if (n > 0) { \
  892. ANY_SIMD(dst_ptr, src_ptr, src_stride_ptr, n, source_y_fraction); \
  893. } \
  894. memcpy(temp, src_ptr + n * SBPP, r * SBPP); \
  895. memcpy(temp + 64, src_ptr + src_stride_ptr + n * SBPP, r * SBPP); \
  896. ANY_SIMD(temp + 128, temp, 64, MASK + 1, source_y_fraction); \
  897. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  898. }
  899. #ifdef HAS_INTERPOLATEROW_AVX2
  900. ANY11T(InterpolateRow_Any_AVX2, InterpolateRow_AVX2, 1, 1, 31)
  901. #endif
  902. #ifdef HAS_INTERPOLATEROW_SSSE3
  903. ANY11T(InterpolateRow_Any_SSSE3, InterpolateRow_SSSE3, 1, 1, 15)
  904. #endif
  905. #ifdef HAS_INTERPOLATEROW_NEON
  906. ANY11T(InterpolateRow_Any_NEON, InterpolateRow_NEON, 1, 1, 15)
  907. #endif
  908. #ifdef HAS_INTERPOLATEROW_MSA
  909. ANY11T(InterpolateRow_Any_MSA, InterpolateRow_MSA, 1, 1, 31)
  910. #endif
  911. #undef ANY11T
  912. // Any 1 to 1 mirror.
  913. #define ANY11M(NAMEANY, ANY_SIMD, BPP, MASK) \
  914. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, int width) { \
  915. SIMD_ALIGNED(uint8_t temp[64 * 2]); \
  916. memset(temp, 0, 64); /* for msan */ \
  917. int r = width & MASK; \
  918. int n = width & ~MASK; \
  919. if (n > 0) { \
  920. ANY_SIMD(src_ptr + r * BPP, dst_ptr, n); \
  921. } \
  922. memcpy(temp, src_ptr, r* BPP); \
  923. ANY_SIMD(temp, temp + 64, MASK + 1); \
  924. memcpy(dst_ptr + n * BPP, temp + 64 + (MASK + 1 - r) * BPP, r * BPP); \
  925. }
  926. #ifdef HAS_MIRRORROW_AVX2
  927. ANY11M(MirrorRow_Any_AVX2, MirrorRow_AVX2, 1, 31)
  928. #endif
  929. #ifdef HAS_MIRRORROW_SSSE3
  930. ANY11M(MirrorRow_Any_SSSE3, MirrorRow_SSSE3, 1, 15)
  931. #endif
  932. #ifdef HAS_MIRRORROW_NEON
  933. ANY11M(MirrorRow_Any_NEON, MirrorRow_NEON, 1, 15)
  934. #endif
  935. #ifdef HAS_MIRRORROW_MSA
  936. ANY11M(MirrorRow_Any_MSA, MirrorRow_MSA, 1, 63)
  937. #endif
  938. #ifdef HAS_ARGBMIRRORROW_AVX2
  939. ANY11M(ARGBMirrorRow_Any_AVX2, ARGBMirrorRow_AVX2, 4, 7)
  940. #endif
  941. #ifdef HAS_ARGBMIRRORROW_SSE2
  942. ANY11M(ARGBMirrorRow_Any_SSE2, ARGBMirrorRow_SSE2, 4, 3)
  943. #endif
  944. #ifdef HAS_ARGBMIRRORROW_NEON
  945. ANY11M(ARGBMirrorRow_Any_NEON, ARGBMirrorRow_NEON, 4, 3)
  946. #endif
  947. #ifdef HAS_ARGBMIRRORROW_MSA
  948. ANY11M(ARGBMirrorRow_Any_MSA, ARGBMirrorRow_MSA, 4, 15)
  949. #endif
  950. #undef ANY11M
  951. // Any 1 plane. (memset)
  952. #define ANY1(NAMEANY, ANY_SIMD, T, BPP, MASK) \
  953. void NAMEANY(uint8_t* dst_ptr, T v32, int width) { \
  954. SIMD_ALIGNED(uint8_t temp[64]); \
  955. int r = width & MASK; \
  956. int n = width & ~MASK; \
  957. if (n > 0) { \
  958. ANY_SIMD(dst_ptr, v32, n); \
  959. } \
  960. ANY_SIMD(temp, v32, MASK + 1); \
  961. memcpy(dst_ptr + n * BPP, temp, r * BPP); \
  962. }
  963. #ifdef HAS_SETROW_X86
  964. ANY1(SetRow_Any_X86, SetRow_X86, uint8_t, 1, 3)
  965. #endif
  966. #ifdef HAS_SETROW_NEON
  967. ANY1(SetRow_Any_NEON, SetRow_NEON, uint8_t, 1, 15)
  968. #endif
  969. #ifdef HAS_ARGBSETROW_NEON
  970. ANY1(ARGBSetRow_Any_NEON, ARGBSetRow_NEON, uint32_t, 4, 3)
  971. #endif
  972. #ifdef HAS_ARGBSETROW_MSA
  973. ANY1(ARGBSetRow_Any_MSA, ARGBSetRow_MSA, uint32_t, 4, 3)
  974. #endif
  975. #undef ANY1
  976. // Any 1 to 2. Outputs UV planes.
  977. #define ANY12(NAMEANY, ANY_SIMD, UVSHIFT, BPP, DUVSHIFT, MASK) \
  978. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_u, uint8_t* dst_v, \
  979. int width) { \
  980. SIMD_ALIGNED(uint8_t temp[128 * 3]); \
  981. memset(temp, 0, 128); /* for msan */ \
  982. int r = width & MASK; \
  983. int n = width & ~MASK; \
  984. if (n > 0) { \
  985. ANY_SIMD(src_ptr, dst_u, dst_v, n); \
  986. } \
  987. memcpy(temp, src_ptr + (n >> UVSHIFT) * BPP, SS(r, UVSHIFT) * BPP); \
  988. ANY_SIMD(temp, temp + 128, temp + 256, MASK + 1); \
  989. memcpy(dst_u + (n >> DUVSHIFT), temp + 128, SS(r, DUVSHIFT)); \
  990. memcpy(dst_v + (n >> DUVSHIFT), temp + 256, SS(r, DUVSHIFT)); \
  991. }
  992. #ifdef HAS_SPLITUVROW_SSE2
  993. ANY12(SplitUVRow_Any_SSE2, SplitUVRow_SSE2, 0, 2, 0, 15)
  994. #endif
  995. #ifdef HAS_SPLITUVROW_AVX2
  996. ANY12(SplitUVRow_Any_AVX2, SplitUVRow_AVX2, 0, 2, 0, 31)
  997. #endif
  998. #ifdef HAS_SPLITUVROW_NEON
  999. ANY12(SplitUVRow_Any_NEON, SplitUVRow_NEON, 0, 2, 0, 15)
  1000. #endif
  1001. #ifdef HAS_SPLITUVROW_MSA
  1002. ANY12(SplitUVRow_Any_MSA, SplitUVRow_MSA, 0, 2, 0, 31)
  1003. #endif
  1004. #ifdef HAS_ARGBTOUV444ROW_SSSE3
  1005. ANY12(ARGBToUV444Row_Any_SSSE3, ARGBToUV444Row_SSSE3, 0, 4, 0, 15)
  1006. #endif
  1007. #ifdef HAS_YUY2TOUV422ROW_AVX2
  1008. ANY12(YUY2ToUV422Row_Any_AVX2, YUY2ToUV422Row_AVX2, 1, 4, 1, 31)
  1009. ANY12(UYVYToUV422Row_Any_AVX2, UYVYToUV422Row_AVX2, 1, 4, 1, 31)
  1010. #endif
  1011. #ifdef HAS_YUY2TOUV422ROW_SSE2
  1012. ANY12(YUY2ToUV422Row_Any_SSE2, YUY2ToUV422Row_SSE2, 1, 4, 1, 15)
  1013. ANY12(UYVYToUV422Row_Any_SSE2, UYVYToUV422Row_SSE2, 1, 4, 1, 15)
  1014. #endif
  1015. #ifdef HAS_YUY2TOUV422ROW_NEON
  1016. ANY12(ARGBToUV444Row_Any_NEON, ARGBToUV444Row_NEON, 0, 4, 0, 7)
  1017. ANY12(YUY2ToUV422Row_Any_NEON, YUY2ToUV422Row_NEON, 1, 4, 1, 15)
  1018. ANY12(UYVYToUV422Row_Any_NEON, UYVYToUV422Row_NEON, 1, 4, 1, 15)
  1019. #endif
  1020. #ifdef HAS_YUY2TOUV422ROW_MSA
  1021. ANY12(ARGBToUV444Row_Any_MSA, ARGBToUV444Row_MSA, 0, 4, 0, 15)
  1022. ANY12(YUY2ToUV422Row_Any_MSA, YUY2ToUV422Row_MSA, 1, 4, 1, 31)
  1023. ANY12(UYVYToUV422Row_Any_MSA, UYVYToUV422Row_MSA, 1, 4, 1, 31)
  1024. #endif
  1025. #undef ANY12
  1026. // Any 1 to 3. Outputs RGB planes.
  1027. #define ANY13(NAMEANY, ANY_SIMD, BPP, MASK) \
  1028. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_r, uint8_t* dst_g, \
  1029. uint8_t* dst_b, int width) { \
  1030. SIMD_ALIGNED(uint8_t temp[16 * 6]); \
  1031. memset(temp, 0, 16 * 3); /* for msan */ \
  1032. int r = width & MASK; \
  1033. int n = width & ~MASK; \
  1034. if (n > 0) { \
  1035. ANY_SIMD(src_ptr, dst_r, dst_g, dst_b, n); \
  1036. } \
  1037. memcpy(temp, src_ptr + n * BPP, r * BPP); \
  1038. ANY_SIMD(temp, temp + 16 * 3, temp + 16 * 4, temp + 16 * 5, MASK + 1); \
  1039. memcpy(dst_r + n, temp + 16 * 3, r); \
  1040. memcpy(dst_g + n, temp + 16 * 4, r); \
  1041. memcpy(dst_b + n, temp + 16 * 5, r); \
  1042. }
  1043. #ifdef HAS_SPLITRGBROW_SSSE3
  1044. ANY13(SplitRGBRow_Any_SSSE3, SplitRGBRow_SSSE3, 3, 15)
  1045. #endif
  1046. #ifdef HAS_SPLITRGBROW_NEON
  1047. ANY13(SplitRGBRow_Any_NEON, SplitRGBRow_NEON, 3, 15)
  1048. #endif
  1049. // Any 1 to 2 with source stride (2 rows of source). Outputs UV planes.
  1050. // 128 byte row allows for 32 avx ARGB pixels.
  1051. #define ANY12S(NAMEANY, ANY_SIMD, UVSHIFT, BPP, MASK) \
  1052. void NAMEANY(const uint8_t* src_ptr, int src_stride_ptr, uint8_t* dst_u, \
  1053. uint8_t* dst_v, int width) { \
  1054. SIMD_ALIGNED(uint8_t temp[128 * 4]); \
  1055. memset(temp, 0, 128 * 2); /* for msan */ \
  1056. int r = width & MASK; \
  1057. int n = width & ~MASK; \
  1058. if (n > 0) { \
  1059. ANY_SIMD(src_ptr, src_stride_ptr, dst_u, dst_v, n); \
  1060. } \
  1061. memcpy(temp, src_ptr + (n >> UVSHIFT) * BPP, SS(r, UVSHIFT) * BPP); \
  1062. memcpy(temp + 128, src_ptr + src_stride_ptr + (n >> UVSHIFT) * BPP, \
  1063. SS(r, UVSHIFT) * BPP); \
  1064. if ((width & 1) && UVSHIFT == 0) { /* repeat last pixel for subsample */ \
  1065. memcpy(temp + SS(r, UVSHIFT) * BPP, temp + SS(r, UVSHIFT) * BPP - BPP, \
  1066. BPP); \
  1067. memcpy(temp + 128 + SS(r, UVSHIFT) * BPP, \
  1068. temp + 128 + SS(r, UVSHIFT) * BPP - BPP, BPP); \
  1069. } \
  1070. ANY_SIMD(temp, 128, temp + 256, temp + 384, MASK + 1); \
  1071. memcpy(dst_u + (n >> 1), temp + 256, SS(r, 1)); \
  1072. memcpy(dst_v + (n >> 1), temp + 384, SS(r, 1)); \
  1073. }
  1074. #ifdef HAS_ARGBTOUVROW_AVX2
  1075. ANY12S(ARGBToUVRow_Any_AVX2, ARGBToUVRow_AVX2, 0, 4, 31)
  1076. #endif
  1077. #ifdef HAS_ARGBTOUVJROW_AVX2
  1078. ANY12S(ARGBToUVJRow_Any_AVX2, ARGBToUVJRow_AVX2, 0, 4, 31)
  1079. #endif
  1080. #ifdef HAS_ARGBTOUVROW_SSSE3
  1081. ANY12S(ARGBToUVRow_Any_SSSE3, ARGBToUVRow_SSSE3, 0, 4, 15)
  1082. ANY12S(ARGBToUVJRow_Any_SSSE3, ARGBToUVJRow_SSSE3, 0, 4, 15)
  1083. ANY12S(BGRAToUVRow_Any_SSSE3, BGRAToUVRow_SSSE3, 0, 4, 15)
  1084. ANY12S(ABGRToUVRow_Any_SSSE3, ABGRToUVRow_SSSE3, 0, 4, 15)
  1085. ANY12S(RGBAToUVRow_Any_SSSE3, RGBAToUVRow_SSSE3, 0, 4, 15)
  1086. #endif
  1087. #ifdef HAS_YUY2TOUVROW_AVX2
  1088. ANY12S(YUY2ToUVRow_Any_AVX2, YUY2ToUVRow_AVX2, 1, 4, 31)
  1089. ANY12S(UYVYToUVRow_Any_AVX2, UYVYToUVRow_AVX2, 1, 4, 31)
  1090. #endif
  1091. #ifdef HAS_YUY2TOUVROW_SSE2
  1092. ANY12S(YUY2ToUVRow_Any_SSE2, YUY2ToUVRow_SSE2, 1, 4, 15)
  1093. ANY12S(UYVYToUVRow_Any_SSE2, UYVYToUVRow_SSE2, 1, 4, 15)
  1094. #endif
  1095. #ifdef HAS_ARGBTOUVROW_NEON
  1096. ANY12S(ARGBToUVRow_Any_NEON, ARGBToUVRow_NEON, 0, 4, 15)
  1097. #endif
  1098. #ifdef HAS_ARGBTOUVROW_MSA
  1099. ANY12S(ARGBToUVRow_Any_MSA, ARGBToUVRow_MSA, 0, 4, 31)
  1100. #endif
  1101. #ifdef HAS_ARGBTOUVJROW_NEON
  1102. ANY12S(ARGBToUVJRow_Any_NEON, ARGBToUVJRow_NEON, 0, 4, 15)
  1103. #endif
  1104. #ifdef HAS_ARGBTOUVJROW_MSA
  1105. ANY12S(ARGBToUVJRow_Any_MSA, ARGBToUVJRow_MSA, 0, 4, 31)
  1106. #endif
  1107. #ifdef HAS_BGRATOUVROW_NEON
  1108. ANY12S(BGRAToUVRow_Any_NEON, BGRAToUVRow_NEON, 0, 4, 15)
  1109. #endif
  1110. #ifdef HAS_BGRATOUVROW_MSA
  1111. ANY12S(BGRAToUVRow_Any_MSA, BGRAToUVRow_MSA, 0, 4, 31)
  1112. #endif
  1113. #ifdef HAS_ABGRTOUVROW_NEON
  1114. ANY12S(ABGRToUVRow_Any_NEON, ABGRToUVRow_NEON, 0, 4, 15)
  1115. #endif
  1116. #ifdef HAS_ABGRTOUVROW_MSA
  1117. ANY12S(ABGRToUVRow_Any_MSA, ABGRToUVRow_MSA, 0, 4, 31)
  1118. #endif
  1119. #ifdef HAS_RGBATOUVROW_NEON
  1120. ANY12S(RGBAToUVRow_Any_NEON, RGBAToUVRow_NEON, 0, 4, 15)
  1121. #endif
  1122. #ifdef HAS_RGBATOUVROW_MSA
  1123. ANY12S(RGBAToUVRow_Any_MSA, RGBAToUVRow_MSA, 0, 4, 31)
  1124. #endif
  1125. #ifdef HAS_RGB24TOUVROW_NEON
  1126. ANY12S(RGB24ToUVRow_Any_NEON, RGB24ToUVRow_NEON, 0, 3, 15)
  1127. #endif
  1128. #ifdef HAS_RGB24TOUVROW_MSA
  1129. ANY12S(RGB24ToUVRow_Any_MSA, RGB24ToUVRow_MSA, 0, 3, 15)
  1130. #endif
  1131. #ifdef HAS_RAWTOUVROW_NEON
  1132. ANY12S(RAWToUVRow_Any_NEON, RAWToUVRow_NEON, 0, 3, 15)
  1133. #endif
  1134. #ifdef HAS_RAWTOUVROW_MSA
  1135. ANY12S(RAWToUVRow_Any_MSA, RAWToUVRow_MSA, 0, 3, 15)
  1136. #endif
  1137. #ifdef HAS_RGB565TOUVROW_NEON
  1138. ANY12S(RGB565ToUVRow_Any_NEON, RGB565ToUVRow_NEON, 0, 2, 15)
  1139. #endif
  1140. #ifdef HAS_RGB565TOUVROW_MSA
  1141. ANY12S(RGB565ToUVRow_Any_MSA, RGB565ToUVRow_MSA, 0, 2, 15)
  1142. #endif
  1143. #ifdef HAS_ARGB1555TOUVROW_NEON
  1144. ANY12S(ARGB1555ToUVRow_Any_NEON, ARGB1555ToUVRow_NEON, 0, 2, 15)
  1145. #endif
  1146. #ifdef HAS_ARGB1555TOUVROW_MSA
  1147. ANY12S(ARGB1555ToUVRow_Any_MSA, ARGB1555ToUVRow_MSA, 0, 2, 15)
  1148. #endif
  1149. #ifdef HAS_ARGB4444TOUVROW_NEON
  1150. ANY12S(ARGB4444ToUVRow_Any_NEON, ARGB4444ToUVRow_NEON, 0, 2, 15)
  1151. #endif
  1152. #ifdef HAS_YUY2TOUVROW_NEON
  1153. ANY12S(YUY2ToUVRow_Any_NEON, YUY2ToUVRow_NEON, 1, 4, 15)
  1154. #endif
  1155. #ifdef HAS_UYVYTOUVROW_NEON
  1156. ANY12S(UYVYToUVRow_Any_NEON, UYVYToUVRow_NEON, 1, 4, 15)
  1157. #endif
  1158. #ifdef HAS_YUY2TOUVROW_MSA
  1159. ANY12S(YUY2ToUVRow_Any_MSA, YUY2ToUVRow_MSA, 1, 4, 31)
  1160. #endif
  1161. #ifdef HAS_UYVYTOUVROW_MSA
  1162. ANY12S(UYVYToUVRow_Any_MSA, UYVYToUVRow_MSA, 1, 4, 31)
  1163. #endif
  1164. #undef ANY12S
  1165. #ifdef __cplusplus
  1166. } // extern "C"
  1167. } // namespace libyuv
  1168. #endif