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