row_any.cc 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561
  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. #ifdef HAS_I422ALPHATOARGBROW_MMI
  60. ANY41C(I422AlphaToARGBRow_Any_MMI, I422AlphaToARGBRow_MMI, 1, 0, 4, 7)
  61. #endif
  62. #undef ANY41C
  63. // Any 3 planes to 1.
  64. #define ANY31(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \
  65. void NAMEANY(const uint8_t* y_buf, const uint8_t* u_buf, \
  66. const uint8_t* v_buf, uint8_t* dst_ptr, int width) { \
  67. SIMD_ALIGNED(uint8_t temp[64 * 4]); \
  68. memset(temp, 0, 64 * 3); /* for YUY2 and msan */ \
  69. int r = width & MASK; \
  70. int n = width & ~MASK; \
  71. if (n > 0) { \
  72. ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, n); \
  73. } \
  74. memcpy(temp, y_buf + n, r); \
  75. memcpy(temp + 64, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  76. memcpy(temp + 128, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  77. ANY_SIMD(temp, temp + 64, temp + 128, temp + 192, MASK + 1); \
  78. memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 192, \
  79. SS(r, DUVSHIFT) * BPP); \
  80. }
  81. // Merge functions.
  82. #ifdef HAS_MERGERGBROW_SSSE3
  83. ANY31(MergeRGBRow_Any_SSSE3, MergeRGBRow_SSSE3, 0, 0, 3, 15)
  84. #endif
  85. #ifdef HAS_MERGERGBROW_NEON
  86. ANY31(MergeRGBRow_Any_NEON, MergeRGBRow_NEON, 0, 0, 3, 15)
  87. #endif
  88. #ifdef HAS_MERGERGBROW_MMI
  89. ANY31(MergeRGBRow_Any_MMI, MergeRGBRow_MMI, 0, 0, 3, 7)
  90. #endif
  91. #ifdef HAS_I422TOYUY2ROW_SSE2
  92. ANY31(I422ToYUY2Row_Any_SSE2, I422ToYUY2Row_SSE2, 1, 1, 4, 15)
  93. ANY31(I422ToUYVYRow_Any_SSE2, I422ToUYVYRow_SSE2, 1, 1, 4, 15)
  94. #endif
  95. #ifdef HAS_I422TOYUY2ROW_AVX2
  96. ANY31(I422ToYUY2Row_Any_AVX2, I422ToYUY2Row_AVX2, 1, 1, 4, 31)
  97. ANY31(I422ToUYVYRow_Any_AVX2, I422ToUYVYRow_AVX2, 1, 1, 4, 31)
  98. #endif
  99. #ifdef HAS_I422TOYUY2ROW_NEON
  100. ANY31(I422ToYUY2Row_Any_NEON, I422ToYUY2Row_NEON, 1, 1, 4, 15)
  101. #endif
  102. #ifdef HAS_I422TOYUY2ROW_MSA
  103. ANY31(I422ToYUY2Row_Any_MSA, I422ToYUY2Row_MSA, 1, 1, 4, 31)
  104. #endif
  105. #ifdef HAS_I422TOYUY2ROW_MMI
  106. ANY31(I422ToYUY2Row_Any_MMI, I422ToYUY2Row_MMI, 1, 1, 4, 7)
  107. #endif
  108. #ifdef HAS_I422TOUYVYROW_NEON
  109. ANY31(I422ToUYVYRow_Any_NEON, I422ToUYVYRow_NEON, 1, 1, 4, 15)
  110. #endif
  111. #ifdef HAS_I422TOUYVYROW_MSA
  112. ANY31(I422ToUYVYRow_Any_MSA, I422ToUYVYRow_MSA, 1, 1, 4, 31)
  113. #endif
  114. #ifdef HAS_I422TOUYVYROW_MMI
  115. ANY31(I422ToUYVYRow_Any_MMI, I422ToUYVYRow_MMI, 1, 1, 4, 7)
  116. #endif
  117. #ifdef HAS_BLENDPLANEROW_AVX2
  118. ANY31(BlendPlaneRow_Any_AVX2, BlendPlaneRow_AVX2, 0, 0, 1, 31)
  119. #endif
  120. #ifdef HAS_BLENDPLANEROW_SSSE3
  121. ANY31(BlendPlaneRow_Any_SSSE3, BlendPlaneRow_SSSE3, 0, 0, 1, 7)
  122. #endif
  123. #ifdef HAS_BLENDPLANEROW_MMI
  124. ANY31(BlendPlaneRow_Any_MMI, BlendPlaneRow_MMI, 0, 0, 1, 7)
  125. #endif
  126. #undef ANY31
  127. // Note that odd width replication includes 444 due to implementation
  128. // on arm that subsamples 444 to 422 internally.
  129. // Any 3 planes to 1 with yuvconstants
  130. #define ANY31C(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, BPP, MASK) \
  131. void NAMEANY(const uint8_t* y_buf, const uint8_t* u_buf, \
  132. const uint8_t* v_buf, uint8_t* dst_ptr, \
  133. const struct YuvConstants* yuvconstants, int width) { \
  134. SIMD_ALIGNED(uint8_t temp[128 * 4]); \
  135. memset(temp, 0, 128 * 3); /* for YUY2 and msan */ \
  136. int r = width & MASK; \
  137. int n = width & ~MASK; \
  138. if (n > 0) { \
  139. ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, yuvconstants, n); \
  140. } \
  141. memcpy(temp, y_buf + n, r); \
  142. memcpy(temp + 128, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  143. memcpy(temp + 256, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT)); \
  144. if (width & 1) { \
  145. temp[128 + SS(r, UVSHIFT)] = temp[128 + SS(r, UVSHIFT) - 1]; \
  146. temp[256 + SS(r, UVSHIFT)] = temp[256 + SS(r, UVSHIFT) - 1]; \
  147. } \
  148. ANY_SIMD(temp, temp + 128, temp + 256, temp + 384, yuvconstants, \
  149. MASK + 1); \
  150. memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, temp + 384, \
  151. SS(r, DUVSHIFT) * BPP); \
  152. }
  153. #ifdef HAS_I422TOARGBROW_SSSE3
  154. ANY31C(I422ToARGBRow_Any_SSSE3, I422ToARGBRow_SSSE3, 1, 0, 4, 7)
  155. #endif
  156. #ifdef HAS_I422TOAR30ROW_SSSE3
  157. ANY31C(I422ToAR30Row_Any_SSSE3, I422ToAR30Row_SSSE3, 1, 0, 4, 7)
  158. #endif
  159. #ifdef HAS_I422TOAR30ROW_AVX2
  160. ANY31C(I422ToAR30Row_Any_AVX2, I422ToAR30Row_AVX2, 1, 0, 4, 15)
  161. #endif
  162. #ifdef HAS_I444TOARGBROW_SSSE3
  163. ANY31C(I444ToARGBRow_Any_SSSE3, I444ToARGBRow_SSSE3, 0, 0, 4, 7)
  164. ANY31C(I422ToRGBARow_Any_SSSE3, I422ToRGBARow_SSSE3, 1, 0, 4, 7)
  165. ANY31C(I422ToARGB4444Row_Any_SSSE3, I422ToARGB4444Row_SSSE3, 1, 0, 2, 7)
  166. ANY31C(I422ToARGB1555Row_Any_SSSE3, I422ToARGB1555Row_SSSE3, 1, 0, 2, 7)
  167. ANY31C(I422ToRGB565Row_Any_SSSE3, I422ToRGB565Row_SSSE3, 1, 0, 2, 7)
  168. ANY31C(I422ToRGB24Row_Any_SSSE3, I422ToRGB24Row_SSSE3, 1, 0, 3, 15)
  169. #endif // HAS_I444TOARGBROW_SSSE3
  170. #ifdef HAS_I422TORGB24ROW_AVX2
  171. ANY31C(I422ToRGB24Row_Any_AVX2, I422ToRGB24Row_AVX2, 1, 0, 3, 31)
  172. #endif
  173. #ifdef HAS_I422TOARGBROW_AVX2
  174. ANY31C(I422ToARGBRow_Any_AVX2, I422ToARGBRow_AVX2, 1, 0, 4, 15)
  175. #endif
  176. #ifdef HAS_I422TORGBAROW_AVX2
  177. ANY31C(I422ToRGBARow_Any_AVX2, I422ToRGBARow_AVX2, 1, 0, 4, 15)
  178. #endif
  179. #ifdef HAS_I444TOARGBROW_AVX2
  180. ANY31C(I444ToARGBRow_Any_AVX2, I444ToARGBRow_AVX2, 0, 0, 4, 15)
  181. #endif
  182. #ifdef HAS_I422TOARGB4444ROW_AVX2
  183. ANY31C(I422ToARGB4444Row_Any_AVX2, I422ToARGB4444Row_AVX2, 1, 0, 2, 15)
  184. #endif
  185. #ifdef HAS_I422TOARGB1555ROW_AVX2
  186. ANY31C(I422ToARGB1555Row_Any_AVX2, I422ToARGB1555Row_AVX2, 1, 0, 2, 15)
  187. #endif
  188. #ifdef HAS_I422TORGB565ROW_AVX2
  189. ANY31C(I422ToRGB565Row_Any_AVX2, I422ToRGB565Row_AVX2, 1, 0, 2, 15)
  190. #endif
  191. #ifdef HAS_I422TOARGBROW_NEON
  192. ANY31C(I444ToARGBRow_Any_NEON, I444ToARGBRow_NEON, 0, 0, 4, 7)
  193. ANY31C(I422ToARGBRow_Any_NEON, I422ToARGBRow_NEON, 1, 0, 4, 7)
  194. ANY31C(I422ToRGBARow_Any_NEON, I422ToRGBARow_NEON, 1, 0, 4, 7)
  195. ANY31C(I422ToRGB24Row_Any_NEON, I422ToRGB24Row_NEON, 1, 0, 3, 7)
  196. ANY31C(I422ToARGB4444Row_Any_NEON, I422ToARGB4444Row_NEON, 1, 0, 2, 7)
  197. ANY31C(I422ToARGB1555Row_Any_NEON, I422ToARGB1555Row_NEON, 1, 0, 2, 7)
  198. ANY31C(I422ToRGB565Row_Any_NEON, I422ToRGB565Row_NEON, 1, 0, 2, 7)
  199. #endif
  200. #ifdef HAS_I422TOARGBROW_MSA
  201. ANY31C(I444ToARGBRow_Any_MSA, I444ToARGBRow_MSA, 0, 0, 4, 7)
  202. ANY31C(I422ToARGBRow_Any_MSA, I422ToARGBRow_MSA, 1, 0, 4, 7)
  203. ANY31C(I422ToRGBARow_Any_MSA, I422ToRGBARow_MSA, 1, 0, 4, 7)
  204. ANY31C(I422ToRGB24Row_Any_MSA, I422ToRGB24Row_MSA, 1, 0, 3, 15)
  205. ANY31C(I422ToARGB4444Row_Any_MSA, I422ToARGB4444Row_MSA, 1, 0, 2, 7)
  206. ANY31C(I422ToARGB1555Row_Any_MSA, I422ToARGB1555Row_MSA, 1, 0, 2, 7)
  207. ANY31C(I422ToRGB565Row_Any_MSA, I422ToRGB565Row_MSA, 1, 0, 2, 7)
  208. #endif
  209. #ifdef HAS_I422TOARGBROW_MMI
  210. ANY31C(I444ToARGBRow_Any_MMI, I444ToARGBRow_MMI, 0, 0, 4, 7)
  211. ANY31C(I422ToARGBRow_Any_MMI, I422ToARGBRow_MMI, 1, 0, 4, 7)
  212. ANY31C(I422ToRGB24Row_Any_MMI, I422ToRGB24Row_MMI, 1, 0, 3, 15)
  213. ANY31C(I422ToARGB4444Row_Any_MMI, I422ToARGB4444Row_MMI, 1, 0, 2, 7)
  214. ANY31C(I422ToARGB1555Row_Any_MMI, I422ToARGB1555Row_MMI, 1, 0, 2, 7)
  215. ANY31C(I422ToRGB565Row_Any_MMI, I422ToRGB565Row_MMI, 1, 0, 2, 7)
  216. ANY31C(I422ToRGBARow_Any_MMI, I422ToRGBARow_MMI, 1, 0, 4, 7)
  217. #endif
  218. #undef ANY31C
  219. // Any 3 planes of 16 bit to 1 with yuvconstants
  220. // TODO(fbarchard): consider sharing this code with ANY31C
  221. #define ANY31CT(NAMEANY, ANY_SIMD, UVSHIFT, DUVSHIFT, T, SBPP, BPP, MASK) \
  222. void NAMEANY(const T* y_buf, const T* u_buf, const T* v_buf, \
  223. uint8_t* dst_ptr, const struct YuvConstants* yuvconstants, \
  224. int width) { \
  225. SIMD_ALIGNED(T temp[16 * 3]); \
  226. SIMD_ALIGNED(uint8_t out[64]); \
  227. memset(temp, 0, 16 * 3 * SBPP); /* for YUY2 and msan */ \
  228. int r = width & MASK; \
  229. int n = width & ~MASK; \
  230. if (n > 0) { \
  231. ANY_SIMD(y_buf, u_buf, v_buf, dst_ptr, yuvconstants, n); \
  232. } \
  233. memcpy(temp, y_buf + n, r * SBPP); \
  234. memcpy(temp + 16, u_buf + (n >> UVSHIFT), SS(r, UVSHIFT) * SBPP); \
  235. memcpy(temp + 32, v_buf + (n >> UVSHIFT), SS(r, UVSHIFT) * SBPP); \
  236. ANY_SIMD(temp, temp + 16, temp + 32, out, yuvconstants, MASK + 1); \
  237. memcpy(dst_ptr + (n >> DUVSHIFT) * BPP, out, SS(r, DUVSHIFT) * BPP); \
  238. }
  239. #ifdef HAS_I210TOAR30ROW_SSSE3
  240. ANY31CT(I210ToAR30Row_Any_SSSE3, I210ToAR30Row_SSSE3, 1, 0, uint16_t, 2, 4, 7)
  241. #endif
  242. #ifdef HAS_I210TOARGBROW_SSSE3
  243. ANY31CT(I210ToARGBRow_Any_SSSE3, I210ToARGBRow_SSSE3, 1, 0, uint16_t, 2, 4, 7)
  244. #endif
  245. #ifdef HAS_I210TOARGBROW_AVX2
  246. ANY31CT(I210ToARGBRow_Any_AVX2, I210ToARGBRow_AVX2, 1, 0, uint16_t, 2, 4, 15)
  247. #endif
  248. #ifdef HAS_I210TOAR30ROW_AVX2
  249. ANY31CT(I210ToAR30Row_Any_AVX2, I210ToAR30Row_AVX2, 1, 0, uint16_t, 2, 4, 15)
  250. #endif
  251. #ifdef HAS_I210TOARGBROW_MMI
  252. ANY31CT(I210ToARGBRow_Any_MMI, I210ToARGBRow_MMI, 1, 0, uint16_t, 2, 4, 7)
  253. #endif
  254. #undef ANY31CT
  255. // Any 2 planes to 1.
  256. #define ANY21(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, SBPP2, BPP, MASK) \
  257. void NAMEANY(const uint8_t* y_buf, const uint8_t* uv_buf, uint8_t* dst_ptr, \
  258. int width) { \
  259. SIMD_ALIGNED(uint8_t temp[64 * 3]); \
  260. memset(temp, 0, 64 * 2); /* for msan */ \
  261. int r = width & MASK; \
  262. int n = width & ~MASK; \
  263. if (n > 0) { \
  264. ANY_SIMD(y_buf, uv_buf, dst_ptr, n); \
  265. } \
  266. memcpy(temp, y_buf + n * SBPP, r * SBPP); \
  267. memcpy(temp + 64, uv_buf + (n >> UVSHIFT) * SBPP2, \
  268. SS(r, UVSHIFT) * SBPP2); \
  269. ANY_SIMD(temp, temp + 64, temp + 128, MASK + 1); \
  270. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  271. }
  272. // Merge functions.
  273. #ifdef HAS_MERGEUVROW_SSE2
  274. ANY21(MergeUVRow_Any_SSE2, MergeUVRow_SSE2, 0, 1, 1, 2, 15)
  275. #endif
  276. #ifdef HAS_MERGEUVROW_AVX2
  277. ANY21(MergeUVRow_Any_AVX2, MergeUVRow_AVX2, 0, 1, 1, 2, 31)
  278. #endif
  279. #ifdef HAS_MERGEUVROW_NEON
  280. ANY21(MergeUVRow_Any_NEON, MergeUVRow_NEON, 0, 1, 1, 2, 15)
  281. #endif
  282. #ifdef HAS_MERGEUVROW_MSA
  283. ANY21(MergeUVRow_Any_MSA, MergeUVRow_MSA, 0, 1, 1, 2, 15)
  284. #endif
  285. #ifdef HAS_MERGEUVROW_MMI
  286. ANY21(MergeUVRow_Any_MMI, MergeUVRow_MMI, 0, 1, 1, 2, 7)
  287. #endif
  288. #ifdef HAS_NV21TOYUV24ROW_NEON
  289. ANY21(NV21ToYUV24Row_Any_NEON, NV21ToYUV24Row_NEON, 1, 1, 2, 3, 15)
  290. #endif
  291. #ifdef HAS_NV21TOYUV24ROW_AVX2
  292. ANY21(NV21ToYUV24Row_Any_AVX2, NV21ToYUV24Row_AVX2, 1, 1, 2, 3, 31)
  293. #endif
  294. // Math functions.
  295. #ifdef HAS_ARGBMULTIPLYROW_SSE2
  296. ANY21(ARGBMultiplyRow_Any_SSE2, ARGBMultiplyRow_SSE2, 0, 4, 4, 4, 3)
  297. #endif
  298. #ifdef HAS_ARGBADDROW_SSE2
  299. ANY21(ARGBAddRow_Any_SSE2, ARGBAddRow_SSE2, 0, 4, 4, 4, 3)
  300. #endif
  301. #ifdef HAS_ARGBSUBTRACTROW_SSE2
  302. ANY21(ARGBSubtractRow_Any_SSE2, ARGBSubtractRow_SSE2, 0, 4, 4, 4, 3)
  303. #endif
  304. #ifdef HAS_ARGBMULTIPLYROW_AVX2
  305. ANY21(ARGBMultiplyRow_Any_AVX2, ARGBMultiplyRow_AVX2, 0, 4, 4, 4, 7)
  306. #endif
  307. #ifdef HAS_ARGBADDROW_AVX2
  308. ANY21(ARGBAddRow_Any_AVX2, ARGBAddRow_AVX2, 0, 4, 4, 4, 7)
  309. #endif
  310. #ifdef HAS_ARGBSUBTRACTROW_AVX2
  311. ANY21(ARGBSubtractRow_Any_AVX2, ARGBSubtractRow_AVX2, 0, 4, 4, 4, 7)
  312. #endif
  313. #ifdef HAS_ARGBMULTIPLYROW_NEON
  314. ANY21(ARGBMultiplyRow_Any_NEON, ARGBMultiplyRow_NEON, 0, 4, 4, 4, 7)
  315. #endif
  316. #ifdef HAS_ARGBADDROW_NEON
  317. ANY21(ARGBAddRow_Any_NEON, ARGBAddRow_NEON, 0, 4, 4, 4, 7)
  318. #endif
  319. #ifdef HAS_ARGBSUBTRACTROW_NEON
  320. ANY21(ARGBSubtractRow_Any_NEON, ARGBSubtractRow_NEON, 0, 4, 4, 4, 7)
  321. #endif
  322. #ifdef HAS_ARGBMULTIPLYROW_MSA
  323. ANY21(ARGBMultiplyRow_Any_MSA, ARGBMultiplyRow_MSA, 0, 4, 4, 4, 3)
  324. #endif
  325. #ifdef HAS_ARGBMULTIPLYROW_MMI
  326. ANY21(ARGBMultiplyRow_Any_MMI, ARGBMultiplyRow_MMI, 0, 4, 4, 4, 1)
  327. #endif
  328. #ifdef HAS_ARGBADDROW_MSA
  329. ANY21(ARGBAddRow_Any_MSA, ARGBAddRow_MSA, 0, 4, 4, 4, 7)
  330. #endif
  331. #ifdef HAS_ARGBADDROW_MMI
  332. ANY21(ARGBAddRow_Any_MMI, ARGBAddRow_MMI, 0, 4, 4, 4, 1)
  333. #endif
  334. #ifdef HAS_ARGBSUBTRACTROW_MSA
  335. ANY21(ARGBSubtractRow_Any_MSA, ARGBSubtractRow_MSA, 0, 4, 4, 4, 7)
  336. #endif
  337. #ifdef HAS_ARGBSUBTRACTROW_MMI
  338. ANY21(ARGBSubtractRow_Any_MMI, ARGBSubtractRow_MMI, 0, 4, 4, 4, 1)
  339. #endif
  340. #ifdef HAS_SOBELROW_SSE2
  341. ANY21(SobelRow_Any_SSE2, SobelRow_SSE2, 0, 1, 1, 4, 15)
  342. #endif
  343. #ifdef HAS_SOBELROW_NEON
  344. ANY21(SobelRow_Any_NEON, SobelRow_NEON, 0, 1, 1, 4, 7)
  345. #endif
  346. #ifdef HAS_SOBELROW_MSA
  347. ANY21(SobelRow_Any_MSA, SobelRow_MSA, 0, 1, 1, 4, 15)
  348. #endif
  349. #ifdef HAS_SOBELROW_MMI
  350. ANY21(SobelRow_Any_MMI, SobelRow_MMI, 0, 1, 1, 4, 7)
  351. #endif
  352. #ifdef HAS_SOBELTOPLANEROW_SSE2
  353. ANY21(SobelToPlaneRow_Any_SSE2, SobelToPlaneRow_SSE2, 0, 1, 1, 1, 15)
  354. #endif
  355. #ifdef HAS_SOBELTOPLANEROW_NEON
  356. ANY21(SobelToPlaneRow_Any_NEON, SobelToPlaneRow_NEON, 0, 1, 1, 1, 15)
  357. #endif
  358. #ifdef HAS_SOBELTOPLANEROW_MSA
  359. ANY21(SobelToPlaneRow_Any_MSA, SobelToPlaneRow_MSA, 0, 1, 1, 1, 31)
  360. #endif
  361. #ifdef HAS_SOBELTOPLANEROW_MMI
  362. ANY21(SobelToPlaneRow_Any_MMI, SobelToPlaneRow_MMI, 0, 1, 1, 1, 7)
  363. #endif
  364. #ifdef HAS_SOBELXYROW_SSE2
  365. ANY21(SobelXYRow_Any_SSE2, SobelXYRow_SSE2, 0, 1, 1, 4, 15)
  366. #endif
  367. #ifdef HAS_SOBELXYROW_NEON
  368. ANY21(SobelXYRow_Any_NEON, SobelXYRow_NEON, 0, 1, 1, 4, 7)
  369. #endif
  370. #ifdef HAS_SOBELXYROW_MSA
  371. ANY21(SobelXYRow_Any_MSA, SobelXYRow_MSA, 0, 1, 1, 4, 15)
  372. #endif
  373. #ifdef HAS_SOBELXYROW_MMI
  374. ANY21(SobelXYRow_Any_MMI, SobelXYRow_MMI, 0, 1, 1, 4, 7)
  375. #endif
  376. #undef ANY21
  377. // Any 2 planes to 1 with yuvconstants
  378. #define ANY21C(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, SBPP2, BPP, MASK) \
  379. void NAMEANY(const uint8_t* y_buf, const uint8_t* uv_buf, uint8_t* dst_ptr, \
  380. const struct YuvConstants* yuvconstants, int width) { \
  381. SIMD_ALIGNED(uint8_t temp[128 * 3]); \
  382. memset(temp, 0, 128 * 2); /* for msan */ \
  383. int r = width & MASK; \
  384. int n = width & ~MASK; \
  385. if (n > 0) { \
  386. ANY_SIMD(y_buf, uv_buf, dst_ptr, yuvconstants, n); \
  387. } \
  388. memcpy(temp, y_buf + n * SBPP, r * SBPP); \
  389. memcpy(temp + 128, uv_buf + (n >> UVSHIFT) * SBPP2, \
  390. SS(r, UVSHIFT) * SBPP2); \
  391. ANY_SIMD(temp, temp + 128, temp + 256, yuvconstants, MASK + 1); \
  392. memcpy(dst_ptr + n * BPP, temp + 256, r * BPP); \
  393. }
  394. // Biplanar to RGB.
  395. #ifdef HAS_NV12TOARGBROW_SSSE3
  396. ANY21C(NV12ToARGBRow_Any_SSSE3, NV12ToARGBRow_SSSE3, 1, 1, 2, 4, 7)
  397. #endif
  398. #ifdef HAS_NV12TOARGBROW_AVX2
  399. ANY21C(NV12ToARGBRow_Any_AVX2, NV12ToARGBRow_AVX2, 1, 1, 2, 4, 15)
  400. #endif
  401. #ifdef HAS_NV12TOARGBROW_NEON
  402. ANY21C(NV12ToARGBRow_Any_NEON, NV12ToARGBRow_NEON, 1, 1, 2, 4, 7)
  403. #endif
  404. #ifdef HAS_NV12TOARGBROW_MSA
  405. ANY21C(NV12ToARGBRow_Any_MSA, NV12ToARGBRow_MSA, 1, 1, 2, 4, 7)
  406. #endif
  407. #ifdef HAS_NV12TOARGBROW_MMI
  408. ANY21C(NV12ToARGBRow_Any_MMI, NV12ToARGBRow_MMI, 1, 1, 2, 4, 7)
  409. #endif
  410. #ifdef HAS_NV21TOARGBROW_SSSE3
  411. ANY21C(NV21ToARGBRow_Any_SSSE3, NV21ToARGBRow_SSSE3, 1, 1, 2, 4, 7)
  412. #endif
  413. #ifdef HAS_NV21TOARGBROW_AVX2
  414. ANY21C(NV21ToARGBRow_Any_AVX2, NV21ToARGBRow_AVX2, 1, 1, 2, 4, 15)
  415. #endif
  416. #ifdef HAS_NV21TOARGBROW_NEON
  417. ANY21C(NV21ToARGBRow_Any_NEON, NV21ToARGBRow_NEON, 1, 1, 2, 4, 7)
  418. #endif
  419. #ifdef HAS_NV21TOARGBROW_MSA
  420. ANY21C(NV21ToARGBRow_Any_MSA, NV21ToARGBRow_MSA, 1, 1, 2, 4, 7)
  421. #endif
  422. #ifdef HAS_NV21TOARGBROW_MMI
  423. ANY21C(NV21ToARGBRow_Any_MMI, NV21ToARGBRow_MMI, 1, 1, 2, 4, 7)
  424. #endif
  425. #ifdef HAS_NV12TORGB24ROW_NEON
  426. ANY21C(NV12ToRGB24Row_Any_NEON, NV12ToRGB24Row_NEON, 1, 1, 2, 3, 7)
  427. #endif
  428. #ifdef HAS_NV21TORGB24ROW_NEON
  429. ANY21C(NV21ToRGB24Row_Any_NEON, NV21ToRGB24Row_NEON, 1, 1, 2, 3, 7)
  430. #endif
  431. #ifdef HAS_NV12TORGB24ROW_SSSE3
  432. ANY21C(NV12ToRGB24Row_Any_SSSE3, NV12ToRGB24Row_SSSE3, 1, 1, 2, 3, 15)
  433. #endif
  434. #ifdef HAS_NV12TORGB24ROW_MMI
  435. ANY21C(NV12ToRGB24Row_Any_MMI, NV12ToRGB24Row_MMI, 1, 1, 2, 3, 7)
  436. #endif
  437. #ifdef HAS_NV21TORGB24ROW_SSSE3
  438. ANY21C(NV21ToRGB24Row_Any_SSSE3, NV21ToRGB24Row_SSSE3, 1, 1, 2, 3, 15)
  439. #endif
  440. #ifdef HAS_NV12TORGB24ROW_AVX2
  441. ANY21C(NV12ToRGB24Row_Any_AVX2, NV12ToRGB24Row_AVX2, 1, 1, 2, 3, 31)
  442. #endif
  443. #ifdef HAS_NV21TORGB24ROW_AVX2
  444. ANY21C(NV21ToRGB24Row_Any_AVX2, NV21ToRGB24Row_AVX2, 1, 1, 2, 3, 31)
  445. #endif
  446. #ifdef HAS_NV21TORGB24ROW_MMI
  447. ANY21C(NV21ToRGB24Row_Any_MMI, NV21ToRGB24Row_MMI, 1, 1, 2, 3, 7)
  448. #endif
  449. #ifdef HAS_NV12TORGB565ROW_SSSE3
  450. ANY21C(NV12ToRGB565Row_Any_SSSE3, NV12ToRGB565Row_SSSE3, 1, 1, 2, 2, 7)
  451. #endif
  452. #ifdef HAS_NV12TORGB565ROW_AVX2
  453. ANY21C(NV12ToRGB565Row_Any_AVX2, NV12ToRGB565Row_AVX2, 1, 1, 2, 2, 15)
  454. #endif
  455. #ifdef HAS_NV12TORGB565ROW_NEON
  456. ANY21C(NV12ToRGB565Row_Any_NEON, NV12ToRGB565Row_NEON, 1, 1, 2, 2, 7)
  457. #endif
  458. #ifdef HAS_NV12TORGB565ROW_MSA
  459. ANY21C(NV12ToRGB565Row_Any_MSA, NV12ToRGB565Row_MSA, 1, 1, 2, 2, 7)
  460. #endif
  461. #ifdef HAS_NV12TORGB565ROW_MMI
  462. ANY21C(NV12ToRGB565Row_Any_MMI, NV12ToRGB565Row_MMI, 1, 1, 2, 2, 7)
  463. #endif
  464. #undef ANY21C
  465. // Any 1 to 1.
  466. #define ANY11(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
  467. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, int width) { \
  468. SIMD_ALIGNED(uint8_t temp[128 * 2]); \
  469. memset(temp, 0, 128); /* for YUY2 and msan */ \
  470. int r = width & MASK; \
  471. int n = width & ~MASK; \
  472. if (n > 0) { \
  473. ANY_SIMD(src_ptr, dst_ptr, n); \
  474. } \
  475. memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
  476. ANY_SIMD(temp, temp + 128, MASK + 1); \
  477. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  478. }
  479. #ifdef HAS_COPYROW_AVX
  480. ANY11(CopyRow_Any_AVX, CopyRow_AVX, 0, 1, 1, 63)
  481. #endif
  482. #ifdef HAS_COPYROW_SSE2
  483. ANY11(CopyRow_Any_SSE2, CopyRow_SSE2, 0, 1, 1, 31)
  484. #endif
  485. #ifdef HAS_COPYROW_NEON
  486. ANY11(CopyRow_Any_NEON, CopyRow_NEON, 0, 1, 1, 31)
  487. #endif
  488. #if defined(HAS_ARGBTORGB24ROW_SSSE3)
  489. ANY11(ARGBToRGB24Row_Any_SSSE3, ARGBToRGB24Row_SSSE3, 0, 4, 3, 15)
  490. ANY11(ARGBToRAWRow_Any_SSSE3, ARGBToRAWRow_SSSE3, 0, 4, 3, 15)
  491. ANY11(ARGBToRGB565Row_Any_SSE2, ARGBToRGB565Row_SSE2, 0, 4, 2, 3)
  492. ANY11(ARGBToARGB1555Row_Any_SSE2, ARGBToARGB1555Row_SSE2, 0, 4, 2, 3)
  493. ANY11(ARGBToARGB4444Row_Any_SSE2, ARGBToARGB4444Row_SSE2, 0, 4, 2, 3)
  494. #endif
  495. #if defined(HAS_ARGBTORGB24ROW_AVX2)
  496. ANY11(ARGBToRGB24Row_Any_AVX2, ARGBToRGB24Row_AVX2, 0, 4, 3, 31)
  497. #endif
  498. #if defined(HAS_ARGBTORGB24ROW_AVX512VBMI)
  499. ANY11(ARGBToRGB24Row_Any_AVX512VBMI, ARGBToRGB24Row_AVX512VBMI, 0, 4, 3, 31)
  500. #endif
  501. #if defined(HAS_ARGBTORAWROW_AVX2)
  502. ANY11(ARGBToRAWRow_Any_AVX2, ARGBToRAWRow_AVX2, 0, 4, 3, 31)
  503. #endif
  504. #if defined(HAS_ARGBTORGB565ROW_AVX2)
  505. ANY11(ARGBToRGB565Row_Any_AVX2, ARGBToRGB565Row_AVX2, 0, 4, 2, 7)
  506. #endif
  507. #if defined(HAS_ARGBTOARGB4444ROW_AVX2)
  508. ANY11(ARGBToARGB1555Row_Any_AVX2, ARGBToARGB1555Row_AVX2, 0, 4, 2, 7)
  509. ANY11(ARGBToARGB4444Row_Any_AVX2, ARGBToARGB4444Row_AVX2, 0, 4, 2, 7)
  510. #endif
  511. #if defined(HAS_ABGRTOAR30ROW_SSSE3)
  512. ANY11(ABGRToAR30Row_Any_SSSE3, ABGRToAR30Row_SSSE3, 0, 4, 4, 3)
  513. #endif
  514. #if defined(HAS_ARGBTOAR30ROW_SSSE3)
  515. ANY11(ARGBToAR30Row_Any_SSSE3, ARGBToAR30Row_SSSE3, 0, 4, 4, 3)
  516. #endif
  517. #if defined(HAS_ABGRTOAR30ROW_AVX2)
  518. ANY11(ABGRToAR30Row_Any_AVX2, ABGRToAR30Row_AVX2, 0, 4, 4, 7)
  519. #endif
  520. #if defined(HAS_ARGBTOAR30ROW_AVX2)
  521. ANY11(ARGBToAR30Row_Any_AVX2, ARGBToAR30Row_AVX2, 0, 4, 4, 7)
  522. #endif
  523. #if defined(HAS_J400TOARGBROW_SSE2)
  524. ANY11(J400ToARGBRow_Any_SSE2, J400ToARGBRow_SSE2, 0, 1, 4, 7)
  525. #endif
  526. #if defined(HAS_J400TOARGBROW_AVX2)
  527. ANY11(J400ToARGBRow_Any_AVX2, J400ToARGBRow_AVX2, 0, 1, 4, 15)
  528. #endif
  529. #if defined(HAS_RGB24TOARGBROW_SSSE3)
  530. ANY11(RGB24ToARGBRow_Any_SSSE3, RGB24ToARGBRow_SSSE3, 0, 3, 4, 15)
  531. ANY11(RAWToARGBRow_Any_SSSE3, RAWToARGBRow_SSSE3, 0, 3, 4, 15)
  532. ANY11(RGB565ToARGBRow_Any_SSE2, RGB565ToARGBRow_SSE2, 0, 2, 4, 7)
  533. ANY11(ARGB1555ToARGBRow_Any_SSE2, ARGB1555ToARGBRow_SSE2, 0, 2, 4, 7)
  534. ANY11(ARGB4444ToARGBRow_Any_SSE2, ARGB4444ToARGBRow_SSE2, 0, 2, 4, 7)
  535. #endif
  536. #if defined(HAS_RAWTORGBAROW_SSSE3)
  537. ANY11(RAWToRGBARow_Any_SSSE3, RAWToRGBARow_SSSE3, 0, 3, 4, 15)
  538. #endif
  539. #if defined(HAS_RAWTORGB24ROW_SSSE3)
  540. ANY11(RAWToRGB24Row_Any_SSSE3, RAWToRGB24Row_SSSE3, 0, 3, 3, 7)
  541. #endif
  542. #if defined(HAS_RGB565TOARGBROW_AVX2)
  543. ANY11(RGB565ToARGBRow_Any_AVX2, RGB565ToARGBRow_AVX2, 0, 2, 4, 15)
  544. #endif
  545. #if defined(HAS_ARGB1555TOARGBROW_AVX2)
  546. ANY11(ARGB1555ToARGBRow_Any_AVX2, ARGB1555ToARGBRow_AVX2, 0, 2, 4, 15)
  547. #endif
  548. #if defined(HAS_ARGB4444TOARGBROW_AVX2)
  549. ANY11(ARGB4444ToARGBRow_Any_AVX2, ARGB4444ToARGBRow_AVX2, 0, 2, 4, 15)
  550. #endif
  551. #if defined(HAS_ARGBTORGB24ROW_NEON)
  552. ANY11(ARGBToRGB24Row_Any_NEON, ARGBToRGB24Row_NEON, 0, 4, 3, 7)
  553. ANY11(ARGBToRAWRow_Any_NEON, ARGBToRAWRow_NEON, 0, 4, 3, 7)
  554. ANY11(ARGBToRGB565Row_Any_NEON, ARGBToRGB565Row_NEON, 0, 4, 2, 7)
  555. ANY11(ARGBToARGB1555Row_Any_NEON, ARGBToARGB1555Row_NEON, 0, 4, 2, 7)
  556. ANY11(ARGBToARGB4444Row_Any_NEON, ARGBToARGB4444Row_NEON, 0, 4, 2, 7)
  557. ANY11(J400ToARGBRow_Any_NEON, J400ToARGBRow_NEON, 0, 1, 4, 7)
  558. #endif
  559. #if defined(HAS_ARGBTORGB24ROW_MSA)
  560. ANY11(ARGBToRGB24Row_Any_MSA, ARGBToRGB24Row_MSA, 0, 4, 3, 15)
  561. ANY11(ARGBToRAWRow_Any_MSA, ARGBToRAWRow_MSA, 0, 4, 3, 15)
  562. ANY11(ARGBToRGB565Row_Any_MSA, ARGBToRGB565Row_MSA, 0, 4, 2, 7)
  563. ANY11(ARGBToARGB1555Row_Any_MSA, ARGBToARGB1555Row_MSA, 0, 4, 2, 7)
  564. ANY11(ARGBToARGB4444Row_Any_MSA, ARGBToARGB4444Row_MSA, 0, 4, 2, 7)
  565. ANY11(J400ToARGBRow_Any_MSA, J400ToARGBRow_MSA, 0, 1, 4, 15)
  566. #endif
  567. #if defined(HAS_ARGBTORGB24ROW_MMI)
  568. ANY11(ARGBToRGB24Row_Any_MMI, ARGBToRGB24Row_MMI, 0, 4, 3, 3)
  569. ANY11(ARGBToRAWRow_Any_MMI, ARGBToRAWRow_MMI, 0, 4, 3, 3)
  570. ANY11(ARGBToRGB565Row_Any_MMI, ARGBToRGB565Row_MMI, 0, 4, 2, 3)
  571. ANY11(ARGBToARGB1555Row_Any_MMI, ARGBToARGB1555Row_MMI, 0, 4, 2, 3)
  572. ANY11(ARGBToARGB4444Row_Any_MMI, ARGBToARGB4444Row_MMI, 0, 4, 2, 3)
  573. ANY11(J400ToARGBRow_Any_MMI, J400ToARGBRow_MMI, 0, 1, 4, 3)
  574. #endif
  575. #if defined(HAS_RAWTORGB24ROW_NEON)
  576. ANY11(RAWToRGB24Row_Any_NEON, RAWToRGB24Row_NEON, 0, 3, 3, 7)
  577. #endif
  578. #if defined(HAS_RAWTORGB24ROW_MSA)
  579. ANY11(RAWToRGB24Row_Any_MSA, RAWToRGB24Row_MSA, 0, 3, 3, 15)
  580. #endif
  581. #if defined(HAS_RAWTORGB24ROW_MMI)
  582. ANY11(RAWToRGB24Row_Any_MMI, RAWToRGB24Row_MMI, 0, 3, 3, 3)
  583. #endif
  584. #ifdef HAS_ARGBTOYROW_AVX2
  585. ANY11(ARGBToYRow_Any_AVX2, ARGBToYRow_AVX2, 0, 4, 1, 31)
  586. #endif
  587. #ifdef HAS_ABGRTOYROW_AVX2
  588. ANY11(ABGRToYRow_Any_AVX2, ABGRToYRow_AVX2, 0, 4, 1, 31)
  589. #endif
  590. #ifdef HAS_ARGBTOYJROW_AVX2
  591. ANY11(ARGBToYJRow_Any_AVX2, ARGBToYJRow_AVX2, 0, 4, 1, 31)
  592. #endif
  593. #ifdef HAS_RGBATOYJROW_AVX2
  594. ANY11(RGBAToYJRow_Any_AVX2, RGBAToYJRow_AVX2, 0, 4, 1, 31)
  595. #endif
  596. #ifdef HAS_UYVYTOYROW_AVX2
  597. ANY11(UYVYToYRow_Any_AVX2, UYVYToYRow_AVX2, 0, 2, 1, 31)
  598. #endif
  599. #ifdef HAS_YUY2TOYROW_AVX2
  600. ANY11(YUY2ToYRow_Any_AVX2, YUY2ToYRow_AVX2, 1, 4, 1, 31)
  601. #endif
  602. #ifdef HAS_ARGBTOYROW_SSSE3
  603. ANY11(ARGBToYRow_Any_SSSE3, ARGBToYRow_SSSE3, 0, 4, 1, 15)
  604. #endif
  605. #ifdef HAS_BGRATOYROW_SSSE3
  606. ANY11(BGRAToYRow_Any_SSSE3, BGRAToYRow_SSSE3, 0, 4, 1, 15)
  607. ANY11(ABGRToYRow_Any_SSSE3, ABGRToYRow_SSSE3, 0, 4, 1, 15)
  608. ANY11(RGBAToYRow_Any_SSSE3, RGBAToYRow_SSSE3, 0, 4, 1, 15)
  609. ANY11(YUY2ToYRow_Any_SSE2, YUY2ToYRow_SSE2, 1, 4, 1, 15)
  610. ANY11(UYVYToYRow_Any_SSE2, UYVYToYRow_SSE2, 1, 4, 1, 15)
  611. #endif
  612. #ifdef HAS_ARGBTOYJROW_SSSE3
  613. ANY11(ARGBToYJRow_Any_SSSE3, ARGBToYJRow_SSSE3, 0, 4, 1, 15)
  614. #endif
  615. #ifdef HAS_RGBATOYJROW_SSSE3
  616. ANY11(RGBAToYJRow_Any_SSSE3, RGBAToYJRow_SSSE3, 0, 4, 1, 15)
  617. #endif
  618. #ifdef HAS_ARGBTOYROW_NEON
  619. ANY11(ARGBToYRow_Any_NEON, ARGBToYRow_NEON, 0, 4, 1, 7)
  620. #endif
  621. #ifdef HAS_ARGBTOYROW_MSA
  622. ANY11(ARGBToYRow_Any_MSA, ARGBToYRow_MSA, 0, 4, 1, 15)
  623. #endif
  624. #ifdef HAS_ARGBTOYROW_MMI
  625. ANY11(ARGBToYRow_Any_MMI, ARGBToYRow_MMI, 0, 4, 1, 7)
  626. #endif
  627. #ifdef HAS_ARGBTOYJROW_NEON
  628. ANY11(ARGBToYJRow_Any_NEON, ARGBToYJRow_NEON, 0, 4, 1, 7)
  629. #endif
  630. #ifdef HAS_RGBATOYJROW_NEON
  631. ANY11(RGBAToYJRow_Any_NEON, RGBAToYJRow_NEON, 0, 4, 1, 7)
  632. #endif
  633. #ifdef HAS_ARGBTOYJROW_MSA
  634. ANY11(ARGBToYJRow_Any_MSA, ARGBToYJRow_MSA, 0, 4, 1, 15)
  635. #endif
  636. #ifdef HAS_ARGBTOYJROW_MMI
  637. ANY11(ARGBToYJRow_Any_MMI, ARGBToYJRow_MMI, 0, 4, 1, 7)
  638. #endif
  639. #ifdef HAS_BGRATOYROW_NEON
  640. ANY11(BGRAToYRow_Any_NEON, BGRAToYRow_NEON, 0, 4, 1, 7)
  641. #endif
  642. #ifdef HAS_BGRATOYROW_MSA
  643. ANY11(BGRAToYRow_Any_MSA, BGRAToYRow_MSA, 0, 4, 1, 15)
  644. #endif
  645. #ifdef HAS_BGRATOYROW_MMI
  646. ANY11(BGRAToYRow_Any_MMI, BGRAToYRow_MMI, 0, 4, 1, 7)
  647. #endif
  648. #ifdef HAS_ABGRTOYROW_NEON
  649. ANY11(ABGRToYRow_Any_NEON, ABGRToYRow_NEON, 0, 4, 1, 7)
  650. #endif
  651. #ifdef HAS_ABGRTOYROW_MSA
  652. ANY11(ABGRToYRow_Any_MSA, ABGRToYRow_MSA, 0, 4, 1, 7)
  653. #endif
  654. #ifdef HAS_ABGRTOYROW_MMI
  655. ANY11(ABGRToYRow_Any_MMI, ABGRToYRow_MMI, 0, 4, 1, 7)
  656. #endif
  657. #ifdef HAS_RGBATOYROW_NEON
  658. ANY11(RGBAToYRow_Any_NEON, RGBAToYRow_NEON, 0, 4, 1, 7)
  659. #endif
  660. #ifdef HAS_RGBATOYROW_MSA
  661. ANY11(RGBAToYRow_Any_MSA, RGBAToYRow_MSA, 0, 4, 1, 15)
  662. #endif
  663. #ifdef HAS_RGBATOYROW_MMI
  664. ANY11(RGBAToYRow_Any_MMI, RGBAToYRow_MMI, 0, 4, 1, 7)
  665. #endif
  666. #ifdef HAS_RGB24TOYROW_NEON
  667. ANY11(RGB24ToYRow_Any_NEON, RGB24ToYRow_NEON, 0, 3, 1, 7)
  668. #endif
  669. #ifdef HAS_RGB24TOYJROW_AVX2
  670. ANY11(RGB24ToYJRow_Any_AVX2, RGB24ToYJRow_AVX2, 0, 3, 1, 31)
  671. #endif
  672. #ifdef HAS_RGB24TOYJROW_SSSE3
  673. ANY11(RGB24ToYJRow_Any_SSSE3, RGB24ToYJRow_SSSE3, 0, 3, 1, 15)
  674. #endif
  675. #ifdef HAS_RGB24TOYJROW_NEON
  676. ANY11(RGB24ToYJRow_Any_NEON, RGB24ToYJRow_NEON, 0, 3, 1, 7)
  677. #endif
  678. #ifdef HAS_RGB24TOYROW_MSA
  679. ANY11(RGB24ToYRow_Any_MSA, RGB24ToYRow_MSA, 0, 3, 1, 15)
  680. #endif
  681. #ifdef HAS_RGB24TOYROW_MMI
  682. ANY11(RGB24ToYRow_Any_MMI, RGB24ToYRow_MMI, 0, 3, 1, 7)
  683. #endif
  684. #ifdef HAS_RAWTOYROW_NEON
  685. ANY11(RAWToYRow_Any_NEON, RAWToYRow_NEON, 0, 3, 1, 7)
  686. #endif
  687. #ifdef HAS_RAWTOYJROW_AVX2
  688. ANY11(RAWToYJRow_Any_AVX2, RAWToYJRow_AVX2, 0, 3, 1, 31)
  689. #endif
  690. #ifdef HAS_RAWTOYJROW_SSSE3
  691. ANY11(RAWToYJRow_Any_SSSE3, RAWToYJRow_SSSE3, 0, 3, 1, 15)
  692. #endif
  693. #ifdef HAS_RAWTOYJROW_NEON
  694. ANY11(RAWToYJRow_Any_NEON, RAWToYJRow_NEON, 0, 3, 1, 7)
  695. #endif
  696. #ifdef HAS_RAWTOYROW_MSA
  697. ANY11(RAWToYRow_Any_MSA, RAWToYRow_MSA, 0, 3, 1, 15)
  698. #endif
  699. #ifdef HAS_RAWTOYROW_MMI
  700. ANY11(RAWToYRow_Any_MMI, RAWToYRow_MMI, 0, 3, 1, 7)
  701. #endif
  702. #ifdef HAS_RGB565TOYROW_NEON
  703. ANY11(RGB565ToYRow_Any_NEON, RGB565ToYRow_NEON, 0, 2, 1, 7)
  704. #endif
  705. #ifdef HAS_RGB565TOYROW_MSA
  706. ANY11(RGB565ToYRow_Any_MSA, RGB565ToYRow_MSA, 0, 2, 1, 15)
  707. #endif
  708. #ifdef HAS_RGB565TOYROW_MMI
  709. ANY11(RGB565ToYRow_Any_MMI, RGB565ToYRow_MMI, 0, 2, 1, 7)
  710. #endif
  711. #ifdef HAS_ARGB1555TOYROW_NEON
  712. ANY11(ARGB1555ToYRow_Any_NEON, ARGB1555ToYRow_NEON, 0, 2, 1, 7)
  713. #endif
  714. #ifdef HAS_ARGB1555TOYROW_MSA
  715. ANY11(ARGB1555ToYRow_Any_MSA, ARGB1555ToYRow_MSA, 0, 2, 1, 15)
  716. #endif
  717. #ifdef HAS_ARGB1555TOYROW_MMI
  718. ANY11(ARGB1555ToYRow_Any_MMI, ARGB1555ToYRow_MMI, 0, 2, 1, 7)
  719. #endif
  720. #ifdef HAS_ARGB4444TOYROW_NEON
  721. ANY11(ARGB4444ToYRow_Any_NEON, ARGB4444ToYRow_NEON, 0, 2, 1, 7)
  722. #endif
  723. #ifdef HAS_ARGB4444TOYROW_MMI
  724. ANY11(ARGB4444ToYRow_Any_MMI, ARGB4444ToYRow_MMI, 0, 2, 1, 7)
  725. #endif
  726. #ifdef HAS_YUY2TOYROW_NEON
  727. ANY11(YUY2ToYRow_Any_NEON, YUY2ToYRow_NEON, 1, 4, 1, 15)
  728. #endif
  729. #ifdef HAS_UYVYTOYROW_NEON
  730. ANY11(UYVYToYRow_Any_NEON, UYVYToYRow_NEON, 1, 4, 1, 15)
  731. #endif
  732. #ifdef HAS_YUY2TOYROW_MSA
  733. ANY11(YUY2ToYRow_Any_MSA, YUY2ToYRow_MSA, 1, 4, 1, 31)
  734. #endif
  735. #ifdef HAS_YUY2TOYROW_MMI
  736. ANY11(YUY2ToYRow_Any_MMI, YUY2ToYRow_MMI, 1, 4, 1, 7)
  737. #endif
  738. #ifdef HAS_UYVYTOYROW_MSA
  739. ANY11(UYVYToYRow_Any_MSA, UYVYToYRow_MSA, 1, 4, 1, 31)
  740. #endif
  741. #ifdef HAS_UYVYTOYROW_MMI
  742. ANY11(UYVYToYRow_Any_MMI, UYVYToYRow_MMI, 1, 4, 1, 15)
  743. #endif
  744. #ifdef HAS_AYUVTOYROW_NEON
  745. ANY11(AYUVToYRow_Any_NEON, AYUVToYRow_NEON, 0, 4, 1, 15)
  746. #endif
  747. #ifdef HAS_SWAPUVROW_SSSE3
  748. ANY11(SwapUVRow_Any_SSSE3, SwapUVRow_SSSE3, 0, 2, 2, 15)
  749. #endif
  750. #ifdef HAS_SWAPUVROW_AVX2
  751. ANY11(SwapUVRow_Any_AVX2, SwapUVRow_AVX2, 0, 2, 2, 31)
  752. #endif
  753. #ifdef HAS_SWAPUVROW_NEON
  754. ANY11(SwapUVRow_Any_NEON, SwapUVRow_NEON, 0, 2, 2, 15)
  755. #endif
  756. #ifdef HAS_RGB24TOARGBROW_NEON
  757. ANY11(RGB24ToARGBRow_Any_NEON, RGB24ToARGBRow_NEON, 0, 3, 4, 7)
  758. #endif
  759. #ifdef HAS_RGB24TOARGBROW_MSA
  760. ANY11(RGB24ToARGBRow_Any_MSA, RGB24ToARGBRow_MSA, 0, 3, 4, 15)
  761. #endif
  762. #ifdef HAS_RGB24TOARGBROW_MMI
  763. ANY11(RGB24ToARGBRow_Any_MMI, RGB24ToARGBRow_MMI, 0, 3, 4, 3)
  764. #endif
  765. #ifdef HAS_RAWTOARGBROW_NEON
  766. ANY11(RAWToARGBRow_Any_NEON, RAWToARGBRow_NEON, 0, 3, 4, 7)
  767. #endif
  768. #ifdef HAS_RAWTORGBAROW_NEON
  769. ANY11(RAWToRGBARow_Any_NEON, RAWToRGBARow_NEON, 0, 3, 4, 7)
  770. #endif
  771. #ifdef HAS_RAWTOARGBROW_MSA
  772. ANY11(RAWToARGBRow_Any_MSA, RAWToARGBRow_MSA, 0, 3, 4, 15)
  773. #endif
  774. #ifdef HAS_RAWTOARGBROW_MMI
  775. ANY11(RAWToARGBRow_Any_MMI, RAWToARGBRow_MMI, 0, 3, 4, 3)
  776. #endif
  777. #ifdef HAS_RGB565TOARGBROW_NEON
  778. ANY11(RGB565ToARGBRow_Any_NEON, RGB565ToARGBRow_NEON, 0, 2, 4, 7)
  779. #endif
  780. #ifdef HAS_RGB565TOARGBROW_MSA
  781. ANY11(RGB565ToARGBRow_Any_MSA, RGB565ToARGBRow_MSA, 0, 2, 4, 15)
  782. #endif
  783. #ifdef HAS_RGB565TOARGBROW_MMI
  784. ANY11(RGB565ToARGBRow_Any_MMI, RGB565ToARGBRow_MMI, 0, 2, 4, 3)
  785. #endif
  786. #ifdef HAS_ARGB1555TOARGBROW_NEON
  787. ANY11(ARGB1555ToARGBRow_Any_NEON, ARGB1555ToARGBRow_NEON, 0, 2, 4, 7)
  788. #endif
  789. #ifdef HAS_ARGB1555TOARGBROW_MSA
  790. ANY11(ARGB1555ToARGBRow_Any_MSA, ARGB1555ToARGBRow_MSA, 0, 2, 4, 15)
  791. #endif
  792. #ifdef HAS_ARGB1555TOARGBROW_MMI
  793. ANY11(ARGB1555ToARGBRow_Any_MMI, ARGB1555ToARGBRow_MMI, 0, 2, 4, 3)
  794. #endif
  795. #ifdef HAS_ARGB4444TOARGBROW_NEON
  796. ANY11(ARGB4444ToARGBRow_Any_NEON, ARGB4444ToARGBRow_NEON, 0, 2, 4, 7)
  797. #endif
  798. #ifdef HAS_ARGB4444TOARGBROW_MSA
  799. ANY11(ARGB4444ToARGBRow_Any_MSA, ARGB4444ToARGBRow_MSA, 0, 2, 4, 15)
  800. #endif
  801. #ifdef HAS_ARGB4444TOARGBROW_MMI
  802. ANY11(ARGB4444ToARGBRow_Any_MMI, ARGB4444ToARGBRow_MMI, 0, 2, 4, 3)
  803. #endif
  804. #ifdef HAS_ARGBATTENUATEROW_SSSE3
  805. ANY11(ARGBAttenuateRow_Any_SSSE3, ARGBAttenuateRow_SSSE3, 0, 4, 4, 3)
  806. #endif
  807. #ifdef HAS_ARGBUNATTENUATEROW_SSE2
  808. ANY11(ARGBUnattenuateRow_Any_SSE2, ARGBUnattenuateRow_SSE2, 0, 4, 4, 3)
  809. #endif
  810. #ifdef HAS_ARGBATTENUATEROW_AVX2
  811. ANY11(ARGBAttenuateRow_Any_AVX2, ARGBAttenuateRow_AVX2, 0, 4, 4, 7)
  812. #endif
  813. #ifdef HAS_ARGBUNATTENUATEROW_AVX2
  814. ANY11(ARGBUnattenuateRow_Any_AVX2, ARGBUnattenuateRow_AVX2, 0, 4, 4, 7)
  815. #endif
  816. #ifdef HAS_ARGBATTENUATEROW_NEON
  817. ANY11(ARGBAttenuateRow_Any_NEON, ARGBAttenuateRow_NEON, 0, 4, 4, 7)
  818. #endif
  819. #ifdef HAS_ARGBATTENUATEROW_MSA
  820. ANY11(ARGBAttenuateRow_Any_MSA, ARGBAttenuateRow_MSA, 0, 4, 4, 7)
  821. #endif
  822. #ifdef HAS_ARGBATTENUATEROW_MMI
  823. ANY11(ARGBAttenuateRow_Any_MMI, ARGBAttenuateRow_MMI, 0, 4, 4, 1)
  824. #endif
  825. #ifdef HAS_ARGBEXTRACTALPHAROW_SSE2
  826. ANY11(ARGBExtractAlphaRow_Any_SSE2, ARGBExtractAlphaRow_SSE2, 0, 4, 1, 7)
  827. #endif
  828. #ifdef HAS_ARGBEXTRACTALPHAROW_AVX2
  829. ANY11(ARGBExtractAlphaRow_Any_AVX2, ARGBExtractAlphaRow_AVX2, 0, 4, 1, 31)
  830. #endif
  831. #ifdef HAS_ARGBEXTRACTALPHAROW_NEON
  832. ANY11(ARGBExtractAlphaRow_Any_NEON, ARGBExtractAlphaRow_NEON, 0, 4, 1, 15)
  833. #endif
  834. #ifdef HAS_ARGBEXTRACTALPHAROW_MSA
  835. ANY11(ARGBExtractAlphaRow_Any_MSA, ARGBExtractAlphaRow_MSA, 0, 4, 1, 15)
  836. #endif
  837. #ifdef HAS_ARGBEXTRACTALPHAROW_MMI
  838. ANY11(ARGBExtractAlphaRow_Any_MMI, ARGBExtractAlphaRow_MMI, 0, 4, 1, 7)
  839. #endif
  840. #undef ANY11
  841. // Any 1 to 1 blended. Destination is read, modify, write.
  842. #define ANY11B(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
  843. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, int width) { \
  844. SIMD_ALIGNED(uint8_t temp[64 * 2]); \
  845. memset(temp, 0, 64 * 2); /* for msan */ \
  846. int r = width & MASK; \
  847. int n = width & ~MASK; \
  848. if (n > 0) { \
  849. ANY_SIMD(src_ptr, dst_ptr, n); \
  850. } \
  851. memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
  852. memcpy(temp + 64, dst_ptr + n * BPP, r * BPP); \
  853. ANY_SIMD(temp, temp + 64, MASK + 1); \
  854. memcpy(dst_ptr + n * BPP, temp + 64, r * BPP); \
  855. }
  856. #ifdef HAS_ARGBCOPYALPHAROW_AVX2
  857. ANY11B(ARGBCopyAlphaRow_Any_AVX2, ARGBCopyAlphaRow_AVX2, 0, 4, 4, 15)
  858. #endif
  859. #ifdef HAS_ARGBCOPYALPHAROW_SSE2
  860. ANY11B(ARGBCopyAlphaRow_Any_SSE2, ARGBCopyAlphaRow_SSE2, 0, 4, 4, 7)
  861. #endif
  862. #ifdef HAS_ARGBCOPYALPHAROW_MMI
  863. ANY11B(ARGBCopyAlphaRow_Any_MMI, ARGBCopyAlphaRow_MMI, 0, 4, 4, 1)
  864. #endif
  865. #ifdef HAS_ARGBCOPYYTOALPHAROW_AVX2
  866. ANY11B(ARGBCopyYToAlphaRow_Any_AVX2, ARGBCopyYToAlphaRow_AVX2, 0, 1, 4, 15)
  867. #endif
  868. #ifdef HAS_ARGBCOPYYTOALPHAROW_SSE2
  869. ANY11B(ARGBCopyYToAlphaRow_Any_SSE2, ARGBCopyYToAlphaRow_SSE2, 0, 1, 4, 7)
  870. #endif
  871. #ifdef HAS_ARGBCOPYYTOALPHAROW_MMI
  872. ANY11B(ARGBCopyYToAlphaRow_Any_MMI, ARGBCopyYToAlphaRow_MMI, 0, 1, 4, 7)
  873. #endif
  874. #undef ANY11B
  875. // Any 1 to 1 with parameter.
  876. #define ANY11P(NAMEANY, ANY_SIMD, T, SBPP, BPP, MASK) \
  877. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, T param, int width) { \
  878. SIMD_ALIGNED(uint8_t temp[64 * 2]); \
  879. memset(temp, 0, 64); /* for msan */ \
  880. int r = width & MASK; \
  881. int n = width & ~MASK; \
  882. if (n > 0) { \
  883. ANY_SIMD(src_ptr, dst_ptr, param, n); \
  884. } \
  885. memcpy(temp, src_ptr + n * SBPP, r * SBPP); \
  886. ANY_SIMD(temp, temp + 64, param, MASK + 1); \
  887. memcpy(dst_ptr + n * BPP, temp + 64, r * BPP); \
  888. }
  889. #if defined(HAS_I400TOARGBROW_SSE2)
  890. ANY11P(I400ToARGBRow_Any_SSE2,
  891. I400ToARGBRow_SSE2,
  892. const struct YuvConstants*,
  893. 1,
  894. 4,
  895. 7)
  896. #endif
  897. #if defined(HAS_I400TOARGBROW_AVX2)
  898. ANY11P(I400ToARGBRow_Any_AVX2,
  899. I400ToARGBRow_AVX2,
  900. const struct YuvConstants*,
  901. 1,
  902. 4,
  903. 15)
  904. #endif
  905. #if defined(HAS_I400TOARGBROW_NEON)
  906. ANY11P(I400ToARGBRow_Any_NEON,
  907. I400ToARGBRow_NEON,
  908. const struct YuvConstants*,
  909. 1,
  910. 4,
  911. 7)
  912. #endif
  913. #if defined(HAS_I400TOARGBROW_MSA)
  914. ANY11P(I400ToARGBRow_Any_MSA,
  915. I400ToARGBRow_MSA,
  916. const struct YuvConstants*,
  917. 1,
  918. 4,
  919. 15)
  920. #endif
  921. #if defined(HAS_I400TOARGBROW_MMI)
  922. ANY11P(I400ToARGBRow_Any_MMI,
  923. I400ToARGBRow_MMI,
  924. const struct YuvConstants*,
  925. 1,
  926. 4,
  927. 7)
  928. #endif
  929. #if defined(HAS_ARGBTORGB565DITHERROW_SSE2)
  930. ANY11P(ARGBToRGB565DitherRow_Any_SSE2,
  931. ARGBToRGB565DitherRow_SSE2,
  932. const uint32_t,
  933. 4,
  934. 2,
  935. 3)
  936. #endif
  937. #if defined(HAS_ARGBTORGB565DITHERROW_AVX2)
  938. ANY11P(ARGBToRGB565DitherRow_Any_AVX2,
  939. ARGBToRGB565DitherRow_AVX2,
  940. const uint32_t,
  941. 4,
  942. 2,
  943. 7)
  944. #endif
  945. #if defined(HAS_ARGBTORGB565DITHERROW_NEON)
  946. ANY11P(ARGBToRGB565DitherRow_Any_NEON,
  947. ARGBToRGB565DitherRow_NEON,
  948. const uint32_t,
  949. 4,
  950. 2,
  951. 7)
  952. #endif
  953. #if defined(HAS_ARGBTORGB565DITHERROW_MSA)
  954. ANY11P(ARGBToRGB565DitherRow_Any_MSA,
  955. ARGBToRGB565DitherRow_MSA,
  956. const uint32_t,
  957. 4,
  958. 2,
  959. 7)
  960. #endif
  961. #if defined(HAS_ARGBTORGB565DITHERROW_MMI)
  962. ANY11P(ARGBToRGB565DitherRow_Any_MMI,
  963. ARGBToRGB565DitherRow_MMI,
  964. const uint32_t,
  965. 4,
  966. 2,
  967. 3)
  968. #endif
  969. #ifdef HAS_ARGBSHUFFLEROW_SSSE3
  970. ANY11P(ARGBShuffleRow_Any_SSSE3, ARGBShuffleRow_SSSE3, const uint8_t*, 4, 4, 7)
  971. #endif
  972. #ifdef HAS_ARGBSHUFFLEROW_AVX2
  973. ANY11P(ARGBShuffleRow_Any_AVX2, ARGBShuffleRow_AVX2, const uint8_t*, 4, 4, 15)
  974. #endif
  975. #ifdef HAS_ARGBSHUFFLEROW_NEON
  976. ANY11P(ARGBShuffleRow_Any_NEON, ARGBShuffleRow_NEON, const uint8_t*, 4, 4, 3)
  977. #endif
  978. #ifdef HAS_ARGBSHUFFLEROW_MSA
  979. ANY11P(ARGBShuffleRow_Any_MSA, ARGBShuffleRow_MSA, const uint8_t*, 4, 4, 7)
  980. #endif
  981. #ifdef HAS_ARGBSHUFFLEROW_MMI
  982. ANY11P(ARGBShuffleRow_Any_MMI, ARGBShuffleRow_MMI, const uint8_t*, 4, 4, 1)
  983. #endif
  984. #undef ANY11P
  985. #undef ANY11P
  986. // Any 1 to 1 with parameter and shorts. BPP measures in shorts.
  987. #define ANY11C(NAMEANY, ANY_SIMD, SBPP, BPP, STYPE, DTYPE, MASK) \
  988. void NAMEANY(const STYPE* src_ptr, DTYPE* dst_ptr, int scale, int width) { \
  989. SIMD_ALIGNED(STYPE temp[32]); \
  990. SIMD_ALIGNED(DTYPE out[32]); \
  991. memset(temp, 0, 32 * SBPP); /* for msan */ \
  992. int r = width & MASK; \
  993. int n = width & ~MASK; \
  994. if (n > 0) { \
  995. ANY_SIMD(src_ptr, dst_ptr, scale, n); \
  996. } \
  997. memcpy(temp, src_ptr + n, r * SBPP); \
  998. ANY_SIMD(temp, out, scale, MASK + 1); \
  999. memcpy(dst_ptr + n, out, r * BPP); \
  1000. }
  1001. #ifdef HAS_CONVERT16TO8ROW_SSSE3
  1002. ANY11C(Convert16To8Row_Any_SSSE3,
  1003. Convert16To8Row_SSSE3,
  1004. 2,
  1005. 1,
  1006. uint16_t,
  1007. uint8_t,
  1008. 15)
  1009. #endif
  1010. #ifdef HAS_CONVERT16TO8ROW_AVX2
  1011. ANY11C(Convert16To8Row_Any_AVX2,
  1012. Convert16To8Row_AVX2,
  1013. 2,
  1014. 1,
  1015. uint16_t,
  1016. uint8_t,
  1017. 31)
  1018. #endif
  1019. #ifdef HAS_CONVERT8TO16ROW_SSE2
  1020. ANY11C(Convert8To16Row_Any_SSE2,
  1021. Convert8To16Row_SSE2,
  1022. 1,
  1023. 2,
  1024. uint8_t,
  1025. uint16_t,
  1026. 15)
  1027. #endif
  1028. #ifdef HAS_CONVERT8TO16ROW_AVX2
  1029. ANY11C(Convert8To16Row_Any_AVX2,
  1030. Convert8To16Row_AVX2,
  1031. 1,
  1032. 2,
  1033. uint8_t,
  1034. uint16_t,
  1035. 31)
  1036. #endif
  1037. #undef ANY11C
  1038. // Any 1 to 1 with parameter and shorts to byte. BPP measures in shorts.
  1039. #define ANY11P16(NAMEANY, ANY_SIMD, ST, T, SBPP, BPP, MASK) \
  1040. void NAMEANY(const ST* src_ptr, T* dst_ptr, float param, int width) { \
  1041. SIMD_ALIGNED(ST temp[32]); \
  1042. SIMD_ALIGNED(T out[32]); \
  1043. memset(temp, 0, SBPP * 32); /* for msan */ \
  1044. int r = width & MASK; \
  1045. int n = width & ~MASK; \
  1046. if (n > 0) { \
  1047. ANY_SIMD(src_ptr, dst_ptr, param, n); \
  1048. } \
  1049. memcpy(temp, src_ptr + n, r * SBPP); \
  1050. ANY_SIMD(temp, out, param, MASK + 1); \
  1051. memcpy(dst_ptr + n, out, r * BPP); \
  1052. }
  1053. #ifdef HAS_HALFFLOATROW_SSE2
  1054. ANY11P16(HalfFloatRow_Any_SSE2, HalfFloatRow_SSE2, uint16_t, uint16_t, 2, 2, 7)
  1055. #endif
  1056. #ifdef HAS_HALFFLOATROW_AVX2
  1057. ANY11P16(HalfFloatRow_Any_AVX2, HalfFloatRow_AVX2, uint16_t, uint16_t, 2, 2, 15)
  1058. #endif
  1059. #ifdef HAS_HALFFLOATROW_F16C
  1060. ANY11P16(HalfFloatRow_Any_F16C, HalfFloatRow_F16C, uint16_t, uint16_t, 2, 2, 15)
  1061. ANY11P16(HalfFloat1Row_Any_F16C,
  1062. HalfFloat1Row_F16C,
  1063. uint16_t,
  1064. uint16_t,
  1065. 2,
  1066. 2,
  1067. 15)
  1068. #endif
  1069. #ifdef HAS_HALFFLOATROW_NEON
  1070. ANY11P16(HalfFloatRow_Any_NEON, HalfFloatRow_NEON, uint16_t, uint16_t, 2, 2, 7)
  1071. ANY11P16(HalfFloat1Row_Any_NEON,
  1072. HalfFloat1Row_NEON,
  1073. uint16_t,
  1074. uint16_t,
  1075. 2,
  1076. 2,
  1077. 7)
  1078. #endif
  1079. #ifdef HAS_HALFFLOATROW_MSA
  1080. ANY11P16(HalfFloatRow_Any_MSA, HalfFloatRow_MSA, uint16_t, uint16_t, 2, 2, 31)
  1081. #endif
  1082. #ifdef HAS_BYTETOFLOATROW_NEON
  1083. ANY11P16(ByteToFloatRow_Any_NEON, ByteToFloatRow_NEON, uint8_t, float, 1, 3, 7)
  1084. #endif
  1085. #undef ANY11P16
  1086. // Any 1 to 1 with yuvconstants
  1087. #define ANY11C(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
  1088. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, \
  1089. const struct YuvConstants* yuvconstants, int width) { \
  1090. SIMD_ALIGNED(uint8_t temp[128 * 2]); \
  1091. memset(temp, 0, 128); /* for YUY2 and msan */ \
  1092. int r = width & MASK; \
  1093. int n = width & ~MASK; \
  1094. if (n > 0) { \
  1095. ANY_SIMD(src_ptr, dst_ptr, yuvconstants, n); \
  1096. } \
  1097. memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
  1098. ANY_SIMD(temp, temp + 128, yuvconstants, MASK + 1); \
  1099. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  1100. }
  1101. #if defined(HAS_YUY2TOARGBROW_SSSE3)
  1102. ANY11C(YUY2ToARGBRow_Any_SSSE3, YUY2ToARGBRow_SSSE3, 1, 4, 4, 15)
  1103. ANY11C(UYVYToARGBRow_Any_SSSE3, UYVYToARGBRow_SSSE3, 1, 4, 4, 15)
  1104. #endif
  1105. #if defined(HAS_YUY2TOARGBROW_AVX2)
  1106. ANY11C(YUY2ToARGBRow_Any_AVX2, YUY2ToARGBRow_AVX2, 1, 4, 4, 31)
  1107. ANY11C(UYVYToARGBRow_Any_AVX2, UYVYToARGBRow_AVX2, 1, 4, 4, 31)
  1108. #endif
  1109. #if defined(HAS_YUY2TOARGBROW_NEON)
  1110. ANY11C(YUY2ToARGBRow_Any_NEON, YUY2ToARGBRow_NEON, 1, 4, 4, 7)
  1111. ANY11C(UYVYToARGBRow_Any_NEON, UYVYToARGBRow_NEON, 1, 4, 4, 7)
  1112. #endif
  1113. #if defined(HAS_YUY2TOARGBROW_MSA)
  1114. ANY11C(YUY2ToARGBRow_Any_MSA, YUY2ToARGBRow_MSA, 1, 4, 4, 7)
  1115. ANY11C(UYVYToARGBRow_Any_MSA, UYVYToARGBRow_MSA, 1, 4, 4, 7)
  1116. #endif
  1117. #if defined(HAS_YUY2TOARGBROW_MMI)
  1118. ANY11C(YUY2ToARGBRow_Any_MMI, YUY2ToARGBRow_MMI, 1, 4, 4, 7)
  1119. ANY11C(UYVYToARGBRow_Any_MMI, UYVYToARGBRow_MMI, 1, 4, 4, 7)
  1120. #endif
  1121. #undef ANY11C
  1122. // Any 1 to 1 interpolate. Takes 2 rows of source via stride.
  1123. #define ANY11T(NAMEANY, ANY_SIMD, SBPP, BPP, MASK) \
  1124. void NAMEANY(uint8_t* dst_ptr, const uint8_t* src_ptr, \
  1125. ptrdiff_t src_stride_ptr, int width, int source_y_fraction) { \
  1126. SIMD_ALIGNED(uint8_t temp[64 * 3]); \
  1127. memset(temp, 0, 64 * 2); /* for msan */ \
  1128. int r = width & MASK; \
  1129. int n = width & ~MASK; \
  1130. if (n > 0) { \
  1131. ANY_SIMD(dst_ptr, src_ptr, src_stride_ptr, n, source_y_fraction); \
  1132. } \
  1133. memcpy(temp, src_ptr + n * SBPP, r * SBPP); \
  1134. memcpy(temp + 64, src_ptr + src_stride_ptr + n * SBPP, r * SBPP); \
  1135. ANY_SIMD(temp + 128, temp, 64, MASK + 1, source_y_fraction); \
  1136. memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
  1137. }
  1138. #ifdef HAS_INTERPOLATEROW_AVX2
  1139. ANY11T(InterpolateRow_Any_AVX2, InterpolateRow_AVX2, 1, 1, 31)
  1140. #endif
  1141. #ifdef HAS_INTERPOLATEROW_SSSE3
  1142. ANY11T(InterpolateRow_Any_SSSE3, InterpolateRow_SSSE3, 1, 1, 15)
  1143. #endif
  1144. #ifdef HAS_INTERPOLATEROW_NEON
  1145. ANY11T(InterpolateRow_Any_NEON, InterpolateRow_NEON, 1, 1, 15)
  1146. #endif
  1147. #ifdef HAS_INTERPOLATEROW_MSA
  1148. ANY11T(InterpolateRow_Any_MSA, InterpolateRow_MSA, 1, 1, 31)
  1149. #endif
  1150. #ifdef HAS_INTERPOLATEROW_MMI
  1151. ANY11T(InterpolateRow_Any_MMI, InterpolateRow_MMI, 1, 1, 7)
  1152. #endif
  1153. #undef ANY11T
  1154. // Any 1 to 1 mirror.
  1155. #define ANY11M(NAMEANY, ANY_SIMD, BPP, MASK) \
  1156. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_ptr, int width) { \
  1157. SIMD_ALIGNED(uint8_t temp[64 * 2]); \
  1158. memset(temp, 0, 64); /* for msan */ \
  1159. int r = width & MASK; \
  1160. int n = width & ~MASK; \
  1161. if (n > 0) { \
  1162. ANY_SIMD(src_ptr + r * BPP, dst_ptr, n); \
  1163. } \
  1164. memcpy(temp, src_ptr, r* BPP); \
  1165. ANY_SIMD(temp, temp + 64, MASK + 1); \
  1166. memcpy(dst_ptr + n * BPP, temp + 64 + (MASK + 1 - r) * BPP, r * BPP); \
  1167. }
  1168. #ifdef HAS_MIRRORROW_AVX2
  1169. ANY11M(MirrorRow_Any_AVX2, MirrorRow_AVX2, 1, 31)
  1170. #endif
  1171. #ifdef HAS_MIRRORROW_SSSE3
  1172. ANY11M(MirrorRow_Any_SSSE3, MirrorRow_SSSE3, 1, 15)
  1173. #endif
  1174. #ifdef HAS_MIRRORROW_NEON
  1175. ANY11M(MirrorRow_Any_NEON, MirrorRow_NEON, 1, 31)
  1176. #endif
  1177. #ifdef HAS_MIRRORROW_MSA
  1178. ANY11M(MirrorRow_Any_MSA, MirrorRow_MSA, 1, 63)
  1179. #endif
  1180. #ifdef HAS_MIRRORROW_MMI
  1181. ANY11M(MirrorRow_Any_MMI, MirrorRow_MMI, 1, 7)
  1182. #endif
  1183. #ifdef HAS_MIRRORUVROW_AVX2
  1184. ANY11M(MirrorUVRow_Any_AVX2, MirrorUVRow_AVX2, 2, 15)
  1185. #endif
  1186. #ifdef HAS_MIRRORUVROW_SSSE3
  1187. ANY11M(MirrorUVRow_Any_SSSE3, MirrorUVRow_SSSE3, 2, 7)
  1188. #endif
  1189. #ifdef HAS_MIRRORUVROW_NEON
  1190. ANY11M(MirrorUVRow_Any_NEON, MirrorUVRow_NEON, 2, 31)
  1191. #endif
  1192. #ifdef HAS_MIRRORUVROW_MSA
  1193. ANY11M(MirrorUVRow_Any_MSA, MirrorUVRow_MSA, 2, 7)
  1194. #endif
  1195. #ifdef HAS_ARGBMIRRORROW_AVX2
  1196. ANY11M(ARGBMirrorRow_Any_AVX2, ARGBMirrorRow_AVX2, 4, 7)
  1197. #endif
  1198. #ifdef HAS_ARGBMIRRORROW_SSE2
  1199. ANY11M(ARGBMirrorRow_Any_SSE2, ARGBMirrorRow_SSE2, 4, 3)
  1200. #endif
  1201. #ifdef HAS_ARGBMIRRORROW_NEON
  1202. ANY11M(ARGBMirrorRow_Any_NEON, ARGBMirrorRow_NEON, 4, 7)
  1203. #endif
  1204. #ifdef HAS_ARGBMIRRORROW_MSA
  1205. ANY11M(ARGBMirrorRow_Any_MSA, ARGBMirrorRow_MSA, 4, 15)
  1206. #endif
  1207. #ifdef HAS_ARGBMIRRORROW_MMI
  1208. ANY11M(ARGBMirrorRow_Any_MMI, ARGBMirrorRow_MMI, 4, 1)
  1209. #endif
  1210. #ifdef HAS_RGB24MIRRORROW_SSSE3
  1211. ANY11M(RGB24MirrorRow_Any_SSSE3, RGB24MirrorRow_SSSE3, 3, 15)
  1212. #endif
  1213. #ifdef HAS_RGB24MIRRORROW_NEON
  1214. ANY11M(RGB24MirrorRow_Any_NEON, RGB24MirrorRow_NEON, 3, 15)
  1215. #endif
  1216. #undef ANY11M
  1217. // Any 1 plane. (memset)
  1218. #define ANY1(NAMEANY, ANY_SIMD, T, BPP, MASK) \
  1219. void NAMEANY(uint8_t* dst_ptr, T v32, int width) { \
  1220. SIMD_ALIGNED(uint8_t temp[64]); \
  1221. int r = width & MASK; \
  1222. int n = width & ~MASK; \
  1223. if (n > 0) { \
  1224. ANY_SIMD(dst_ptr, v32, n); \
  1225. } \
  1226. ANY_SIMD(temp, v32, MASK + 1); \
  1227. memcpy(dst_ptr + n * BPP, temp, r * BPP); \
  1228. }
  1229. #ifdef HAS_SETROW_X86
  1230. ANY1(SetRow_Any_X86, SetRow_X86, uint8_t, 1, 3)
  1231. #endif
  1232. #ifdef HAS_SETROW_NEON
  1233. ANY1(SetRow_Any_NEON, SetRow_NEON, uint8_t, 1, 15)
  1234. #endif
  1235. #ifdef HAS_ARGBSETROW_NEON
  1236. ANY1(ARGBSetRow_Any_NEON, ARGBSetRow_NEON, uint32_t, 4, 3)
  1237. #endif
  1238. #ifdef HAS_ARGBSETROW_MSA
  1239. ANY1(ARGBSetRow_Any_MSA, ARGBSetRow_MSA, uint32_t, 4, 3)
  1240. #endif
  1241. #ifdef HAS_ARGBSETROW_MMI
  1242. ANY1(ARGBSetRow_Any_MMI, ARGBSetRow_MMI, uint32_t, 4, 3)
  1243. #endif
  1244. #undef ANY1
  1245. // Any 1 to 2. Outputs UV planes.
  1246. #define ANY12(NAMEANY, ANY_SIMD, UVSHIFT, BPP, DUVSHIFT, MASK) \
  1247. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_u, uint8_t* dst_v, \
  1248. int width) { \
  1249. SIMD_ALIGNED(uint8_t temp[128 * 3]); \
  1250. memset(temp, 0, 128); /* for msan */ \
  1251. int r = width & MASK; \
  1252. int n = width & ~MASK; \
  1253. if (n > 0) { \
  1254. ANY_SIMD(src_ptr, dst_u, dst_v, n); \
  1255. } \
  1256. memcpy(temp, src_ptr + (n >> UVSHIFT) * BPP, SS(r, UVSHIFT) * BPP); \
  1257. ANY_SIMD(temp, temp + 128, temp + 256, MASK + 1); \
  1258. memcpy(dst_u + (n >> DUVSHIFT), temp + 128, SS(r, DUVSHIFT)); \
  1259. memcpy(dst_v + (n >> DUVSHIFT), temp + 256, SS(r, DUVSHIFT)); \
  1260. }
  1261. #ifdef HAS_SPLITUVROW_SSE2
  1262. ANY12(SplitUVRow_Any_SSE2, SplitUVRow_SSE2, 0, 2, 0, 15)
  1263. #endif
  1264. #ifdef HAS_SPLITUVROW_AVX2
  1265. ANY12(SplitUVRow_Any_AVX2, SplitUVRow_AVX2, 0, 2, 0, 31)
  1266. #endif
  1267. #ifdef HAS_SPLITUVROW_NEON
  1268. ANY12(SplitUVRow_Any_NEON, SplitUVRow_NEON, 0, 2, 0, 15)
  1269. #endif
  1270. #ifdef HAS_SPLITUVROW_MSA
  1271. ANY12(SplitUVRow_Any_MSA, SplitUVRow_MSA, 0, 2, 0, 31)
  1272. #endif
  1273. #ifdef HAS_SPLITUVROW_MMI
  1274. ANY12(SplitUVRow_Any_MMI, SplitUVRow_MMI, 0, 2, 0, 7)
  1275. #endif
  1276. #ifdef HAS_ARGBTOUV444ROW_SSSE3
  1277. ANY12(ARGBToUV444Row_Any_SSSE3, ARGBToUV444Row_SSSE3, 0, 4, 0, 15)
  1278. #endif
  1279. #ifdef HAS_YUY2TOUV422ROW_AVX2
  1280. ANY12(YUY2ToUV422Row_Any_AVX2, YUY2ToUV422Row_AVX2, 1, 4, 1, 31)
  1281. ANY12(UYVYToUV422Row_Any_AVX2, UYVYToUV422Row_AVX2, 1, 4, 1, 31)
  1282. #endif
  1283. #ifdef HAS_YUY2TOUV422ROW_SSE2
  1284. ANY12(YUY2ToUV422Row_Any_SSE2, YUY2ToUV422Row_SSE2, 1, 4, 1, 15)
  1285. ANY12(UYVYToUV422Row_Any_SSE2, UYVYToUV422Row_SSE2, 1, 4, 1, 15)
  1286. #endif
  1287. #ifdef HAS_YUY2TOUV422ROW_NEON
  1288. ANY12(ARGBToUV444Row_Any_NEON, ARGBToUV444Row_NEON, 0, 4, 0, 7)
  1289. ANY12(YUY2ToUV422Row_Any_NEON, YUY2ToUV422Row_NEON, 1, 4, 1, 15)
  1290. ANY12(UYVYToUV422Row_Any_NEON, UYVYToUV422Row_NEON, 1, 4, 1, 15)
  1291. #endif
  1292. #ifdef HAS_YUY2TOUV422ROW_MSA
  1293. ANY12(ARGBToUV444Row_Any_MSA, ARGBToUV444Row_MSA, 0, 4, 0, 15)
  1294. ANY12(YUY2ToUV422Row_Any_MSA, YUY2ToUV422Row_MSA, 1, 4, 1, 31)
  1295. ANY12(UYVYToUV422Row_Any_MSA, UYVYToUV422Row_MSA, 1, 4, 1, 31)
  1296. #endif
  1297. #ifdef HAS_YUY2TOUV422ROW_MMI
  1298. ANY12(ARGBToUV444Row_Any_MMI, ARGBToUV444Row_MMI, 0, 4, 0, 7)
  1299. ANY12(UYVYToUV422Row_Any_MMI, UYVYToUV422Row_MMI, 1, 4, 1, 15)
  1300. ANY12(YUY2ToUV422Row_Any_MMI, YUY2ToUV422Row_MMI, 1, 4, 1, 15)
  1301. #endif
  1302. #undef ANY12
  1303. // Any 1 to 3. Outputs RGB planes.
  1304. #define ANY13(NAMEANY, ANY_SIMD, BPP, MASK) \
  1305. void NAMEANY(const uint8_t* src_ptr, uint8_t* dst_r, uint8_t* dst_g, \
  1306. uint8_t* dst_b, int width) { \
  1307. SIMD_ALIGNED(uint8_t temp[16 * 6]); \
  1308. memset(temp, 0, 16 * 3); /* for msan */ \
  1309. int r = width & MASK; \
  1310. int n = width & ~MASK; \
  1311. if (n > 0) { \
  1312. ANY_SIMD(src_ptr, dst_r, dst_g, dst_b, n); \
  1313. } \
  1314. memcpy(temp, src_ptr + n * BPP, r * BPP); \
  1315. ANY_SIMD(temp, temp + 16 * 3, temp + 16 * 4, temp + 16 * 5, MASK + 1); \
  1316. memcpy(dst_r + n, temp + 16 * 3, r); \
  1317. memcpy(dst_g + n, temp + 16 * 4, r); \
  1318. memcpy(dst_b + n, temp + 16 * 5, r); \
  1319. }
  1320. #ifdef HAS_SPLITRGBROW_SSSE3
  1321. ANY13(SplitRGBRow_Any_SSSE3, SplitRGBRow_SSSE3, 3, 15)
  1322. #endif
  1323. #ifdef HAS_SPLITRGBROW_NEON
  1324. ANY13(SplitRGBRow_Any_NEON, SplitRGBRow_NEON, 3, 15)
  1325. #endif
  1326. #ifdef HAS_SPLITRGBROW_MMI
  1327. ANY13(SplitRGBRow_Any_MMI, SplitRGBRow_MMI, 3, 3)
  1328. #endif
  1329. // Any 1 to 2 with source stride (2 rows of source). Outputs UV planes.
  1330. // 128 byte row allows for 32 avx ARGB pixels.
  1331. #define ANY12S(NAMEANY, ANY_SIMD, UVSHIFT, BPP, MASK) \
  1332. void NAMEANY(const uint8_t* src_ptr, int src_stride_ptr, uint8_t* dst_u, \
  1333. uint8_t* dst_v, int width) { \
  1334. SIMD_ALIGNED(uint8_t temp[128 * 4]); \
  1335. memset(temp, 0, 128 * 2); /* for msan */ \
  1336. int r = width & MASK; \
  1337. int n = width & ~MASK; \
  1338. if (n > 0) { \
  1339. ANY_SIMD(src_ptr, src_stride_ptr, dst_u, dst_v, n); \
  1340. } \
  1341. memcpy(temp, src_ptr + (n >> UVSHIFT) * BPP, SS(r, UVSHIFT) * BPP); \
  1342. memcpy(temp + 128, src_ptr + src_stride_ptr + (n >> UVSHIFT) * BPP, \
  1343. SS(r, UVSHIFT) * BPP); \
  1344. if ((width & 1) && UVSHIFT == 0) { /* repeat last pixel for subsample */ \
  1345. memcpy(temp + SS(r, UVSHIFT) * BPP, temp + SS(r, UVSHIFT) * BPP - BPP, \
  1346. BPP); \
  1347. memcpy(temp + 128 + SS(r, UVSHIFT) * BPP, \
  1348. temp + 128 + SS(r, UVSHIFT) * BPP - BPP, BPP); \
  1349. } \
  1350. ANY_SIMD(temp, 128, temp + 256, temp + 384, MASK + 1); \
  1351. memcpy(dst_u + (n >> 1), temp + 256, SS(r, 1)); \
  1352. memcpy(dst_v + (n >> 1), temp + 384, SS(r, 1)); \
  1353. }
  1354. #ifdef HAS_ARGBTOUVROW_AVX2
  1355. ANY12S(ARGBToUVRow_Any_AVX2, ARGBToUVRow_AVX2, 0, 4, 31)
  1356. #endif
  1357. #ifdef HAS_ABGRTOUVROW_AVX2
  1358. ANY12S(ABGRToUVRow_Any_AVX2, ABGRToUVRow_AVX2, 0, 4, 31)
  1359. #endif
  1360. #ifdef HAS_ARGBTOUVJROW_AVX2
  1361. ANY12S(ARGBToUVJRow_Any_AVX2, ARGBToUVJRow_AVX2, 0, 4, 31)
  1362. #endif
  1363. #ifdef HAS_ARGBTOUVROW_SSSE3
  1364. ANY12S(ARGBToUVRow_Any_SSSE3, ARGBToUVRow_SSSE3, 0, 4, 15)
  1365. ANY12S(ARGBToUVJRow_Any_SSSE3, ARGBToUVJRow_SSSE3, 0, 4, 15)
  1366. ANY12S(BGRAToUVRow_Any_SSSE3, BGRAToUVRow_SSSE3, 0, 4, 15)
  1367. ANY12S(ABGRToUVRow_Any_SSSE3, ABGRToUVRow_SSSE3, 0, 4, 15)
  1368. ANY12S(RGBAToUVRow_Any_SSSE3, RGBAToUVRow_SSSE3, 0, 4, 15)
  1369. #endif
  1370. #ifdef HAS_YUY2TOUVROW_AVX2
  1371. ANY12S(YUY2ToUVRow_Any_AVX2, YUY2ToUVRow_AVX2, 1, 4, 31)
  1372. ANY12S(UYVYToUVRow_Any_AVX2, UYVYToUVRow_AVX2, 1, 4, 31)
  1373. #endif
  1374. #ifdef HAS_YUY2TOUVROW_SSE2
  1375. ANY12S(YUY2ToUVRow_Any_SSE2, YUY2ToUVRow_SSE2, 1, 4, 15)
  1376. ANY12S(UYVYToUVRow_Any_SSE2, UYVYToUVRow_SSE2, 1, 4, 15)
  1377. #endif
  1378. #ifdef HAS_ARGBTOUVROW_NEON
  1379. ANY12S(ARGBToUVRow_Any_NEON, ARGBToUVRow_NEON, 0, 4, 15)
  1380. #endif
  1381. #ifdef HAS_ARGBTOUVROW_MSA
  1382. ANY12S(ARGBToUVRow_Any_MSA, ARGBToUVRow_MSA, 0, 4, 31)
  1383. #endif
  1384. #ifdef HAS_ARGBTOUVROW_MMI
  1385. ANY12S(ARGBToUVRow_Any_MMI, ARGBToUVRow_MMI, 0, 4, 15)
  1386. #endif
  1387. #ifdef HAS_ARGBTOUVJROW_NEON
  1388. ANY12S(ARGBToUVJRow_Any_NEON, ARGBToUVJRow_NEON, 0, 4, 15)
  1389. #endif
  1390. #ifdef HAS_ARGBTOUVJROW_MSA
  1391. ANY12S(ARGBToUVJRow_Any_MSA, ARGBToUVJRow_MSA, 0, 4, 31)
  1392. #endif
  1393. #ifdef HAS_ARGBTOUVJROW_MMI
  1394. ANY12S(ARGBToUVJRow_Any_MMI, ARGBToUVJRow_MMI, 0, 4, 15)
  1395. #endif
  1396. #ifdef HAS_BGRATOUVROW_NEON
  1397. ANY12S(BGRAToUVRow_Any_NEON, BGRAToUVRow_NEON, 0, 4, 15)
  1398. #endif
  1399. #ifdef HAS_BGRATOUVROW_MSA
  1400. ANY12S(BGRAToUVRow_Any_MSA, BGRAToUVRow_MSA, 0, 4, 15)
  1401. #endif
  1402. #ifdef HAS_BGRATOUVROW_MMI
  1403. ANY12S(BGRAToUVRow_Any_MMI, BGRAToUVRow_MMI, 0, 4, 15)
  1404. #endif
  1405. #ifdef HAS_ABGRTOUVROW_NEON
  1406. ANY12S(ABGRToUVRow_Any_NEON, ABGRToUVRow_NEON, 0, 4, 15)
  1407. #endif
  1408. #ifdef HAS_ABGRTOUVROW_MSA
  1409. ANY12S(ABGRToUVRow_Any_MSA, ABGRToUVRow_MSA, 0, 4, 15)
  1410. #endif
  1411. #ifdef HAS_ABGRTOUVROW_MMI
  1412. ANY12S(ABGRToUVRow_Any_MMI, ABGRToUVRow_MMI, 0, 4, 15)
  1413. #endif
  1414. #ifdef HAS_RGBATOUVROW_NEON
  1415. ANY12S(RGBAToUVRow_Any_NEON, RGBAToUVRow_NEON, 0, 4, 15)
  1416. #endif
  1417. #ifdef HAS_RGBATOUVROW_MSA
  1418. ANY12S(RGBAToUVRow_Any_MSA, RGBAToUVRow_MSA, 0, 4, 15)
  1419. #endif
  1420. #ifdef HAS_RGBATOUVROW_MMI
  1421. ANY12S(RGBAToUVRow_Any_MMI, RGBAToUVRow_MMI, 0, 4, 15)
  1422. #endif
  1423. #ifdef HAS_RGB24TOUVROW_NEON
  1424. ANY12S(RGB24ToUVRow_Any_NEON, RGB24ToUVRow_NEON, 0, 3, 15)
  1425. #endif
  1426. #ifdef HAS_RGB24TOUVROW_MSA
  1427. ANY12S(RGB24ToUVRow_Any_MSA, RGB24ToUVRow_MSA, 0, 3, 15)
  1428. #endif
  1429. #ifdef HAS_RGB24TOUVROW_MMI
  1430. ANY12S(RGB24ToUVRow_Any_MMI, RGB24ToUVRow_MMI, 0, 3, 15)
  1431. #endif
  1432. #ifdef HAS_RAWTOUVROW_NEON
  1433. ANY12S(RAWToUVRow_Any_NEON, RAWToUVRow_NEON, 0, 3, 15)
  1434. #endif
  1435. #ifdef HAS_RAWTOUVROW_MSA
  1436. ANY12S(RAWToUVRow_Any_MSA, RAWToUVRow_MSA, 0, 3, 15)
  1437. #endif
  1438. #ifdef HAS_RAWTOUVROW_MMI
  1439. ANY12S(RAWToUVRow_Any_MMI, RAWToUVRow_MMI, 0, 3, 15)
  1440. #endif
  1441. #ifdef HAS_RGB565TOUVROW_NEON
  1442. ANY12S(RGB565ToUVRow_Any_NEON, RGB565ToUVRow_NEON, 0, 2, 15)
  1443. #endif
  1444. #ifdef HAS_RGB565TOUVROW_MSA
  1445. ANY12S(RGB565ToUVRow_Any_MSA, RGB565ToUVRow_MSA, 0, 2, 15)
  1446. #endif
  1447. #ifdef HAS_RGB565TOUVROW_MMI
  1448. ANY12S(RGB565ToUVRow_Any_MMI, RGB565ToUVRow_MMI, 0, 2, 15)
  1449. #endif
  1450. #ifdef HAS_ARGB1555TOUVROW_NEON
  1451. ANY12S(ARGB1555ToUVRow_Any_NEON, ARGB1555ToUVRow_NEON, 0, 2, 15)
  1452. #endif
  1453. #ifdef HAS_ARGB1555TOUVROW_MSA
  1454. ANY12S(ARGB1555ToUVRow_Any_MSA, ARGB1555ToUVRow_MSA, 0, 2, 15)
  1455. #endif
  1456. #ifdef HAS_ARGB1555TOUVROW_MMI
  1457. ANY12S(ARGB1555ToUVRow_Any_MMI, ARGB1555ToUVRow_MMI, 0, 2, 15)
  1458. #endif
  1459. #ifdef HAS_ARGB4444TOUVROW_NEON
  1460. ANY12S(ARGB4444ToUVRow_Any_NEON, ARGB4444ToUVRow_NEON, 0, 2, 15)
  1461. #endif
  1462. #ifdef HAS_ARGB4444TOUVROW_MMI
  1463. ANY12S(ARGB4444ToUVRow_Any_MMI, ARGB4444ToUVRow_MMI, 0, 2, 15)
  1464. #endif
  1465. #ifdef HAS_YUY2TOUVROW_NEON
  1466. ANY12S(YUY2ToUVRow_Any_NEON, YUY2ToUVRow_NEON, 1, 4, 15)
  1467. #endif
  1468. #ifdef HAS_UYVYTOUVROW_NEON
  1469. ANY12S(UYVYToUVRow_Any_NEON, UYVYToUVRow_NEON, 1, 4, 15)
  1470. #endif
  1471. #ifdef HAS_YUY2TOUVROW_MSA
  1472. ANY12S(YUY2ToUVRow_Any_MSA, YUY2ToUVRow_MSA, 1, 4, 31)
  1473. #endif
  1474. #ifdef HAS_YUY2TOUVROW_MMI
  1475. ANY12S(YUY2ToUVRow_Any_MMI, YUY2ToUVRow_MMI, 1, 4, 15)
  1476. #endif
  1477. #ifdef HAS_UYVYTOUVROW_MSA
  1478. ANY12S(UYVYToUVRow_Any_MSA, UYVYToUVRow_MSA, 1, 4, 31)
  1479. #endif
  1480. #ifdef HAS_UYVYTOUVROW_MMI
  1481. ANY12S(UYVYToUVRow_Any_MMI, UYVYToUVRow_MMI, 1, 4, 15)
  1482. #endif
  1483. #undef ANY12S
  1484. // Any 1 to 1 with source stride (2 rows of source). Outputs UV plane.
  1485. // 128 byte row allows for 32 avx ARGB pixels.
  1486. #define ANY11S(NAMEANY, ANY_SIMD, UVSHIFT, BPP, MASK) \
  1487. void NAMEANY(const uint8_t* src_ptr, int src_stride_ptr, uint8_t* dst_vu, \
  1488. int width) { \
  1489. SIMD_ALIGNED(uint8_t temp[128 * 3]); \
  1490. memset(temp, 0, 128 * 2); /* for msan */ \
  1491. int r = width & MASK; \
  1492. int n = width & ~MASK; \
  1493. if (n > 0) { \
  1494. ANY_SIMD(src_ptr, src_stride_ptr, dst_vu, n); \
  1495. } \
  1496. memcpy(temp, src_ptr + (n >> UVSHIFT) * BPP, SS(r, UVSHIFT) * BPP); \
  1497. memcpy(temp + 128, src_ptr + src_stride_ptr + (n >> UVSHIFT) * BPP, \
  1498. SS(r, UVSHIFT) * BPP); \
  1499. if ((width & 1) && UVSHIFT == 0) { /* repeat last pixel for subsample */ \
  1500. memcpy(temp + SS(r, UVSHIFT) * BPP, temp + SS(r, UVSHIFT) * BPP - BPP, \
  1501. BPP); \
  1502. memcpy(temp + 128 + SS(r, UVSHIFT) * BPP, \
  1503. temp + 128 + SS(r, UVSHIFT) * BPP - BPP, BPP); \
  1504. } \
  1505. ANY_SIMD(temp, 128, temp + 256, MASK + 1); \
  1506. memcpy(dst_vu + (n >> 1) * 2, temp + 256, SS(r, 1) * 2); \
  1507. }
  1508. #ifdef HAS_AYUVTOVUROW_NEON
  1509. ANY11S(AYUVToUVRow_Any_NEON, AYUVToUVRow_NEON, 0, 4, 15)
  1510. ANY11S(AYUVToVURow_Any_NEON, AYUVToVURow_NEON, 0, 4, 15)
  1511. #endif
  1512. #undef ANY11S
  1513. #ifdef __cplusplus
  1514. } // extern "C"
  1515. } // namespace libyuv
  1516. #endif