- Timestamp:
- Jul 28, 2017 2:51:44 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/third_party/yuv/source/planar_functions.cc
r5358 r5633 27 27 // Copy a plane of data 28 28 LIBYUV_API 29 void CopyPlane(const uint8* src_y, int src_stride_y, 30 uint8* dst_y, int dst_stride_y, 31 int width, int height) { 29 void CopyPlane(const uint8* src_y, 30 int src_stride_y, 31 uint8* dst_y, 32 int dst_stride_y, 33 int width, 34 int height) { 32 35 int y; 33 36 void (*CopyRow)(const uint8* src, uint8* dst, int width) = CopyRow_C; 37 // Negative height means invert the image. 38 if (height < 0) { 39 height = -height; 40 dst_y = dst_y + (height - 1) * dst_stride_y; 41 dst_stride_y = -dst_stride_y; 42 } 34 43 // Coalesce rows. 35 if (src_stride_y == width && 36 dst_stride_y == width) { 44 if (src_stride_y == width && dst_stride_y == width) { 37 45 width *= height; 38 46 height = 1; … … 77 85 } 78 86 79 LIBYUV_API 80 void CopyPlane_16(const uint16* src_y, int src_stride_y, 81 uint16* dst_y, int dst_stride_y, 82 int width, int height) { 87 // TODO(fbarchard): Consider support for negative height. 88 // TODO(fbarchard): Consider stride measured in bytes. 89 LIBYUV_API 90 void CopyPlane_16(const uint16* src_y, 91 int src_stride_y, 92 uint16* dst_y, 93 int dst_stride_y, 94 int width, 95 int height) { 83 96 int y; 84 97 void (*CopyRow)(const uint16* src, uint16* dst, int width) = CopyRow_16_C; 85 98 // Coalesce rows. 86 if (src_stride_y == width && 87 dst_stride_y == width) { 99 if (src_stride_y == width && dst_stride_y == width) { 88 100 width *= height; 89 101 height = 1; … … 121 133 // Copy I422. 122 134 LIBYUV_API 123 int I422Copy(const uint8* src_y, int src_stride_y, 124 const uint8* src_u, int src_stride_u, 125 const uint8* src_v, int src_stride_v, 126 uint8* dst_y, int dst_stride_y, 127 uint8* dst_u, int dst_stride_u, 128 uint8* dst_v, int dst_stride_v, 129 int width, int height) { 135 int I422Copy(const uint8* src_y, 136 int src_stride_y, 137 const uint8* src_u, 138 int src_stride_u, 139 const uint8* src_v, 140 int src_stride_v, 141 uint8* dst_y, 142 int dst_stride_y, 143 uint8* dst_u, 144 int dst_stride_u, 145 uint8* dst_v, 146 int dst_stride_v, 147 int width, 148 int height) { 130 149 int halfwidth = (width + 1) >> 1; 131 if (!src_y || !src_u || !src_v || 132 !dst_y || !dst_u || !dst_v || 133 width <= 0 || height == 0) { 150 if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { 134 151 return -1; 135 152 } … … 144 161 src_stride_v = -src_stride_v; 145 162 } 146 CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 163 164 if (dst_y) { 165 CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 166 } 147 167 CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height); 148 168 CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height); … … 152 172 // Copy I444. 153 173 LIBYUV_API 154 int I444Copy(const uint8* src_y, int src_stride_y, 155 const uint8* src_u, int src_stride_u, 156 const uint8* src_v, int src_stride_v, 157 uint8* dst_y, int dst_stride_y, 158 uint8* dst_u, int dst_stride_u, 159 uint8* dst_v, int dst_stride_v, 160 int width, int height) { 161 if (!src_y || !src_u || !src_v || 162 !dst_y || !dst_u || !dst_v || 163 width <= 0 || height == 0) { 174 int I444Copy(const uint8* src_y, 175 int src_stride_y, 176 const uint8* src_u, 177 int src_stride_u, 178 const uint8* src_v, 179 int src_stride_v, 180 uint8* dst_y, 181 int dst_stride_y, 182 uint8* dst_u, 183 int dst_stride_u, 184 uint8* dst_v, 185 int dst_stride_v, 186 int width, 187 int height) { 188 if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { 164 189 return -1; 165 190 } … … 175 200 } 176 201 177 CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 202 if (dst_y) { 203 CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 204 } 178 205 CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height); 179 206 CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height); … … 183 210 // Copy I400. 184 211 LIBYUV_API 185 int I400ToI400(const uint8* src_y, int src_stride_y, 186 uint8* dst_y, int dst_stride_y, 187 int width, int height) { 212 int I400ToI400(const uint8* src_y, 213 int src_stride_y, 214 uint8* dst_y, 215 int dst_stride_y, 216 int width, 217 int height) { 188 218 if (!src_y || !dst_y || width <= 0 || height == 0) { 189 219 return -1; … … 201 231 // Convert I420 to I400. 202 232 LIBYUV_API 203 int I420ToI400(const uint8* src_y, int src_stride_y, 204 const uint8* src_u, int src_stride_u, 205 const uint8* src_v, int src_stride_v, 206 uint8* dst_y, int dst_stride_y, 207 int width, int height) { 233 int I420ToI400(const uint8* src_y, 234 int src_stride_y, 235 const uint8* src_u, 236 int src_stride_u, 237 const uint8* src_v, 238 int src_stride_v, 239 uint8* dst_y, 240 int dst_stride_y, 241 int width, 242 int height) { 243 (void)src_u; 244 (void)src_stride_u; 245 (void)src_v; 246 (void)src_stride_v; 208 247 if (!src_y || !dst_y || width <= 0 || height == 0) { 209 248 return -1; … … 215 254 src_stride_y = -src_stride_y; 216 255 } 256 217 257 CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 218 258 return 0; 219 259 } 220 260 261 // Support function for NV12 etc UV channels. 262 // Width and height are plane sizes (typically half pixel width). 263 LIBYUV_API 264 void SplitUVPlane(const uint8* src_uv, 265 int src_stride_uv, 266 uint8* dst_u, 267 int dst_stride_u, 268 uint8* dst_v, 269 int dst_stride_v, 270 int width, 271 int height) { 272 int y; 273 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, 274 int width) = SplitUVRow_C; 275 // Negative height means invert the image. 276 if (height < 0) { 277 height = -height; 278 dst_u = dst_u + (height - 1) * dst_stride_u; 279 dst_v = dst_v + (height - 1) * dst_stride_v; 280 dst_stride_u = -dst_stride_u; 281 dst_stride_v = -dst_stride_v; 282 } 283 // Coalesce rows. 284 if (src_stride_uv == width * 2 && dst_stride_u == width && 285 dst_stride_v == width) { 286 width *= height; 287 height = 1; 288 src_stride_uv = dst_stride_u = dst_stride_v = 0; 289 } 290 #if defined(HAS_SPLITUVROW_SSE2) 291 if (TestCpuFlag(kCpuHasSSE2)) { 292 SplitUVRow = SplitUVRow_Any_SSE2; 293 if (IS_ALIGNED(width, 16)) { 294 SplitUVRow = SplitUVRow_SSE2; 295 } 296 } 297 #endif 298 #if defined(HAS_SPLITUVROW_AVX2) 299 if (TestCpuFlag(kCpuHasAVX2)) { 300 SplitUVRow = SplitUVRow_Any_AVX2; 301 if (IS_ALIGNED(width, 32)) { 302 SplitUVRow = SplitUVRow_AVX2; 303 } 304 } 305 #endif 306 #if defined(HAS_SPLITUVROW_NEON) 307 if (TestCpuFlag(kCpuHasNEON)) { 308 SplitUVRow = SplitUVRow_Any_NEON; 309 if (IS_ALIGNED(width, 16)) { 310 SplitUVRow = SplitUVRow_NEON; 311 } 312 } 313 #endif 314 #if defined(HAS_SPLITUVROW_DSPR2) 315 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(dst_u, 4) && 316 IS_ALIGNED(dst_stride_u, 4) && IS_ALIGNED(dst_v, 4) && 317 IS_ALIGNED(dst_stride_v, 4)) { 318 SplitUVRow = SplitUVRow_Any_DSPR2; 319 if (IS_ALIGNED(width, 16)) { 320 SplitUVRow = SplitUVRow_DSPR2; 321 } 322 } 323 #endif 324 325 for (y = 0; y < height; ++y) { 326 // Copy a row of UV. 327 SplitUVRow(src_uv, dst_u, dst_v, width); 328 dst_u += dst_stride_u; 329 dst_v += dst_stride_v; 330 src_uv += src_stride_uv; 331 } 332 } 333 334 LIBYUV_API 335 void MergeUVPlane(const uint8* src_u, 336 int src_stride_u, 337 const uint8* src_v, 338 int src_stride_v, 339 uint8* dst_uv, 340 int dst_stride_uv, 341 int width, 342 int height) { 343 int y; 344 void (*MergeUVRow)(const uint8* src_u, const uint8* src_v, uint8* dst_uv, 345 int width) = MergeUVRow_C; 346 // Coalesce rows. 347 // Negative height means invert the image. 348 if (height < 0) { 349 height = -height; 350 dst_uv = dst_uv + (height - 1) * dst_stride_uv; 351 dst_stride_uv = -dst_stride_uv; 352 } 353 // Coalesce rows. 354 if (src_stride_u == width && src_stride_v == width && 355 dst_stride_uv == width * 2) { 356 width *= height; 357 height = 1; 358 src_stride_u = src_stride_v = dst_stride_uv = 0; 359 } 360 #if defined(HAS_MERGEUVROW_SSE2) 361 if (TestCpuFlag(kCpuHasSSE2)) { 362 MergeUVRow = MergeUVRow_Any_SSE2; 363 if (IS_ALIGNED(width, 16)) { 364 MergeUVRow = MergeUVRow_SSE2; 365 } 366 } 367 #endif 368 #if defined(HAS_MERGEUVROW_AVX2) 369 if (TestCpuFlag(kCpuHasAVX2)) { 370 MergeUVRow = MergeUVRow_Any_AVX2; 371 if (IS_ALIGNED(width, 32)) { 372 MergeUVRow = MergeUVRow_AVX2; 373 } 374 } 375 #endif 376 #if defined(HAS_MERGEUVROW_NEON) 377 if (TestCpuFlag(kCpuHasNEON)) { 378 MergeUVRow = MergeUVRow_Any_NEON; 379 if (IS_ALIGNED(width, 16)) { 380 MergeUVRow = MergeUVRow_NEON; 381 } 382 } 383 #endif 384 #if defined(HAS_MERGEUVROW_MSA) 385 if (TestCpuFlag(kCpuHasMSA)) { 386 MergeUVRow = MergeUVRow_Any_MSA; 387 if (IS_ALIGNED(width, 16)) { 388 MergeUVRow = MergeUVRow_MSA; 389 } 390 } 391 #endif 392 393 for (y = 0; y < height; ++y) { 394 // Merge a row of U and V into a row of UV. 395 MergeUVRow(src_u, src_v, dst_uv, width); 396 src_u += src_stride_u; 397 src_v += src_stride_v; 398 dst_uv += dst_stride_uv; 399 } 400 } 401 221 402 // Mirror a plane of data. 222 void MirrorPlane(const uint8* src_y, int src_stride_y, 223 uint8* dst_y, int dst_stride_y, 224 int width, int height) { 403 void MirrorPlane(const uint8* src_y, 404 int src_stride_y, 405 uint8* dst_y, 406 int dst_stride_y, 407 int width, 408 int height) { 225 409 int y; 226 410 void (*MirrorRow)(const uint8* src, uint8* dst, int width) = MirrorRow_C; … … 257 441 // TODO(fbarchard): Mirror on mips handle unaligned memory. 258 442 #if defined(HAS_MIRRORROW_DSPR2) 259 if (TestCpuFlag(kCpuHasDSPR2) && 260 IS_ALIGNED(src_ y, 4) && IS_ALIGNED(src_stride_y, 4) &&261 IS_ALIGNED(dst_ y, 4) && IS_ALIGNED(dst_stride_y, 4)) {443 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src_y, 4) && 444 IS_ALIGNED(src_stride_y, 4) && IS_ALIGNED(dst_y, 4) && 445 IS_ALIGNED(dst_stride_y, 4)) { 262 446 MirrorRow = MirrorRow_DSPR2; 447 } 448 #endif 449 #if defined(HAS_MIRRORROW_MSA) 450 if (TestCpuFlag(kCpuHasMSA)) { 451 MirrorRow = MirrorRow_Any_MSA; 452 if (IS_ALIGNED(width, 64)) { 453 MirrorRow = MirrorRow_MSA; 454 } 263 455 } 264 456 #endif … … 274 466 // Convert YUY2 to I422. 275 467 LIBYUV_API 276 int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2, 277 uint8* dst_y, int dst_stride_y, 278 uint8* dst_u, int dst_stride_u, 279 uint8* dst_v, int dst_stride_v, 280 int width, int height) { 281 int y; 282 void (*YUY2ToUV422Row)(const uint8* src_yuy2, 283 uint8* dst_u, uint8* dst_v, int width) = 284 YUY2ToUV422Row_C; 468 int YUY2ToI422(const uint8* src_yuy2, 469 int src_stride_yuy2, 470 uint8* dst_y, 471 int dst_stride_y, 472 uint8* dst_u, 473 int dst_stride_u, 474 uint8* dst_v, 475 int dst_stride_v, 476 int width, 477 int height) { 478 int y; 479 void (*YUY2ToUV422Row)(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, 480 int width) = YUY2ToUV422Row_C; 285 481 void (*YUY2ToYRow)(const uint8* src_yuy2, uint8* dst_y, int width) = 286 482 YUY2ToYRow_C; 483 if (!src_yuy2 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { 484 return -1; 485 } 287 486 // Negative height means invert the image. 288 487 if (height < 0) { … … 292 491 } 293 492 // Coalesce rows. 294 if (src_stride_yuy2 == width * 2 && 295 dst_stride_y == width && 296 dst_stride_u * 2 == width && 297 dst_stride_v * 2 == width) { 493 if (src_stride_yuy2 == width * 2 && dst_stride_y == width && 494 dst_stride_u * 2 == width && dst_stride_v * 2 == width && 495 width * height <= 32768) { 298 496 width *= height; 299 497 height = 1; … … 323 521 if (TestCpuFlag(kCpuHasNEON)) { 324 522 YUY2ToYRow = YUY2ToYRow_Any_NEON; 325 if (width >= 16) { 326 YUY2ToUV422Row = YUY2ToUV422Row_Any_NEON; 327 } 523 YUY2ToUV422Row = YUY2ToUV422Row_Any_NEON; 328 524 if (IS_ALIGNED(width, 16)) { 329 525 YUY2ToYRow = YUY2ToYRow_NEON; 330 526 YUY2ToUV422Row = YUY2ToUV422Row_NEON; 527 } 528 } 529 #endif 530 #if defined(HAS_YUY2TOYROW_MSA) 531 if (TestCpuFlag(kCpuHasMSA)) { 532 YUY2ToYRow = YUY2ToYRow_Any_MSA; 533 YUY2ToUV422Row = YUY2ToUV422Row_Any_MSA; 534 if (IS_ALIGNED(width, 32)) { 535 YUY2ToYRow = YUY2ToYRow_MSA; 536 YUY2ToUV422Row = YUY2ToUV422Row_MSA; 331 537 } 332 538 } … … 346 552 // Convert UYVY to I422. 347 553 LIBYUV_API 348 int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy, 349 uint8* dst_y, int dst_stride_y, 350 uint8* dst_u, int dst_stride_u, 351 uint8* dst_v, int dst_stride_v, 352 int width, int height) { 353 int y; 354 void (*UYVYToUV422Row)(const uint8* src_uyvy, 355 uint8* dst_u, uint8* dst_v, int width) = 356 UYVYToUV422Row_C; 357 void (*UYVYToYRow)(const uint8* src_uyvy, 358 uint8* dst_y, int width) = UYVYToYRow_C; 554 int UYVYToI422(const uint8* src_uyvy, 555 int src_stride_uyvy, 556 uint8* dst_y, 557 int dst_stride_y, 558 uint8* dst_u, 559 int dst_stride_u, 560 uint8* dst_v, 561 int dst_stride_v, 562 int width, 563 int height) { 564 int y; 565 void (*UYVYToUV422Row)(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, 566 int width) = UYVYToUV422Row_C; 567 void (*UYVYToYRow)(const uint8* src_uyvy, uint8* dst_y, int width) = 568 UYVYToYRow_C; 569 if (!src_uyvy || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { 570 return -1; 571 } 359 572 // Negative height means invert the image. 360 573 if (height < 0) { … … 364 577 } 365 578 // Coalesce rows. 366 if (src_stride_uyvy == width * 2 && 367 dst_stride_y == width && 368 dst_stride_u * 2 == width && 369 dst_stride_v * 2 == width) { 579 if (src_stride_uyvy == width * 2 && dst_stride_y == width && 580 dst_stride_u * 2 == width && dst_stride_v * 2 == width && 581 width * height <= 32768) { 370 582 width *= height; 371 583 height = 1; … … 395 607 if (TestCpuFlag(kCpuHasNEON)) { 396 608 UYVYToYRow = UYVYToYRow_Any_NEON; 397 if (width >= 16) { 398 UYVYToUV422Row = UYVYToUV422Row_Any_NEON; 399 } 609 UYVYToUV422Row = UYVYToUV422Row_Any_NEON; 400 610 if (IS_ALIGNED(width, 16)) { 401 611 UYVYToYRow = UYVYToYRow_NEON; 402 612 UYVYToUV422Row = UYVYToUV422Row_NEON; 613 } 614 } 615 #endif 616 #if defined(HAS_UYVYTOYROW_MSA) 617 if (TestCpuFlag(kCpuHasMSA)) { 618 UYVYToYRow = UYVYToYRow_Any_MSA; 619 UYVYToUV422Row = UYVYToUV422Row_Any_MSA; 620 if (IS_ALIGNED(width, 32)) { 621 UYVYToYRow = UYVYToYRow_MSA; 622 UYVYToUV422Row = UYVYToUV422Row_MSA; 403 623 } 404 624 } … … 416 636 } 417 637 638 // Convert YUY2 to Y. 639 LIBYUV_API 640 int YUY2ToY(const uint8* src_yuy2, 641 int src_stride_yuy2, 642 uint8* dst_y, 643 int dst_stride_y, 644 int width, 645 int height) { 646 int y; 647 void (*YUY2ToYRow)(const uint8* src_yuy2, uint8* dst_y, int width) = 648 YUY2ToYRow_C; 649 if (!src_yuy2 || !dst_y || width <= 0 || height == 0) { 650 return -1; 651 } 652 // Negative height means invert the image. 653 if (height < 0) { 654 height = -height; 655 src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; 656 src_stride_yuy2 = -src_stride_yuy2; 657 } 658 // Coalesce rows. 659 if (src_stride_yuy2 == width * 2 && dst_stride_y == width) { 660 width *= height; 661 height = 1; 662 src_stride_yuy2 = dst_stride_y = 0; 663 } 664 #if defined(HAS_YUY2TOYROW_SSE2) 665 if (TestCpuFlag(kCpuHasSSE2)) { 666 YUY2ToYRow = YUY2ToYRow_Any_SSE2; 667 if (IS_ALIGNED(width, 16)) { 668 YUY2ToYRow = YUY2ToYRow_SSE2; 669 } 670 } 671 #endif 672 #if defined(HAS_YUY2TOYROW_AVX2) 673 if (TestCpuFlag(kCpuHasAVX2)) { 674 YUY2ToYRow = YUY2ToYRow_Any_AVX2; 675 if (IS_ALIGNED(width, 32)) { 676 YUY2ToYRow = YUY2ToYRow_AVX2; 677 } 678 } 679 #endif 680 #if defined(HAS_YUY2TOYROW_NEON) 681 if (TestCpuFlag(kCpuHasNEON)) { 682 YUY2ToYRow = YUY2ToYRow_Any_NEON; 683 if (IS_ALIGNED(width, 16)) { 684 YUY2ToYRow = YUY2ToYRow_NEON; 685 } 686 } 687 #endif 688 #if defined(HAS_YUY2TOYROW_MSA) 689 if (TestCpuFlag(kCpuHasMSA)) { 690 YUY2ToYRow = YUY2ToYRow_Any_MSA; 691 if (IS_ALIGNED(width, 32)) { 692 YUY2ToYRow = YUY2ToYRow_MSA; 693 } 694 } 695 #endif 696 697 for (y = 0; y < height; ++y) { 698 YUY2ToYRow(src_yuy2, dst_y, width); 699 src_yuy2 += src_stride_yuy2; 700 dst_y += dst_stride_y; 701 } 702 return 0; 703 } 704 418 705 // Mirror I400 with optional flipping 419 706 LIBYUV_API 420 int I400Mirror(const uint8* src_y, int src_stride_y, 421 uint8* dst_y, int dst_stride_y, 422 int width, int height) { 423 if (!src_y || !dst_y || 424 width <= 0 || height == 0) { 707 int I400Mirror(const uint8* src_y, 708 int src_stride_y, 709 uint8* dst_y, 710 int dst_stride_y, 711 int width, 712 int height) { 713 if (!src_y || !dst_y || width <= 0 || height == 0) { 425 714 return -1; 426 715 } … … 438 727 // Mirror I420 with optional flipping 439 728 LIBYUV_API 440 int I420Mirror(const uint8* src_y, int src_stride_y, 441 const uint8* src_u, int src_stride_u, 442 const uint8* src_v, int src_stride_v, 443 uint8* dst_y, int dst_stride_y, 444 uint8* dst_u, int dst_stride_u, 445 uint8* dst_v, int dst_stride_v, 446 int width, int height) { 729 int I420Mirror(const uint8* src_y, 730 int src_stride_y, 731 const uint8* src_u, 732 int src_stride_u, 733 const uint8* src_v, 734 int src_stride_v, 735 uint8* dst_y, 736 int dst_stride_y, 737 uint8* dst_u, 738 int dst_stride_u, 739 uint8* dst_v, 740 int dst_stride_v, 741 int width, 742 int height) { 447 743 int halfwidth = (width + 1) >> 1; 448 744 int halfheight = (height + 1) >> 1; 449 if (!src_y || !src_u || !src_v || !dst_y || !dst_u || !dst_v || 450 width <= 0 ||height == 0) {745 if (!src_y || !src_u || !src_v || !dst_y || !dst_u || !dst_v || width <= 0 || 746 height == 0) { 451 747 return -1; 452 748 } … … 473 769 // ARGB mirror. 474 770 LIBYUV_API 475 int ARGBMirror(const uint8* src_argb, int src_stride_argb, 476 uint8* dst_argb, int dst_stride_argb, 477 int width, int height) { 771 int ARGBMirror(const uint8* src_argb, 772 int src_stride_argb, 773 uint8* dst_argb, 774 int dst_stride_argb, 775 int width, 776 int height) { 478 777 int y; 479 778 void (*ARGBMirrorRow)(const uint8* src, uint8* dst, int width) = … … 509 808 if (IS_ALIGNED(width, 8)) { 510 809 ARGBMirrorRow = ARGBMirrorRow_AVX2; 810 } 811 } 812 #endif 813 #if defined(HAS_ARGBMIRRORROW_MSA) 814 if (TestCpuFlag(kCpuHasMSA)) { 815 ARGBMirrorRow = ARGBMirrorRow_Any_MSA; 816 if (IS_ALIGNED(width, 16)) { 817 ARGBMirrorRow = ARGBMirrorRow_MSA; 511 818 } 512 819 } … … 545 852 // Alpha Blend 2 ARGB images and store to destination. 546 853 LIBYUV_API 547 int ARGBBlend(const uint8* src_argb0, int src_stride_argb0, 548 const uint8* src_argb1, int src_stride_argb1, 549 uint8* dst_argb, int dst_stride_argb, 550 int width, int height) { 854 int ARGBBlend(const uint8* src_argb0, 855 int src_stride_argb0, 856 const uint8* src_argb1, 857 int src_stride_argb1, 858 uint8* dst_argb, 859 int dst_stride_argb, 860 int width, 861 int height) { 551 862 int y; 552 863 void (*ARGBBlendRow)(const uint8* src_argb, const uint8* src_argb1, … … 562 873 } 563 874 // Coalesce rows. 564 if (src_stride_argb0 == width * 4 && 565 src_stride_argb1 == width * 4 && 875 if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && 566 876 dst_stride_argb == width * 4) { 567 877 width *= height; … … 581 891 // Alpha Blend plane and store to destination. 582 892 LIBYUV_API 583 int BlendPlane(const uint8* src_y0, int src_stride_y0, 584 const uint8* src_y1, int src_stride_y1, 585 const uint8* alpha, int alpha_stride, 586 uint8* dst_y, int dst_stride_y, 587 int width, int height) { 893 int BlendPlane(const uint8* src_y0, 894 int src_stride_y0, 895 const uint8* src_y1, 896 int src_stride_y1, 897 const uint8* alpha, 898 int alpha_stride, 899 uint8* dst_y, 900 int dst_stride_y, 901 int width, 902 int height) { 588 903 int y; 589 904 void (*BlendPlaneRow)(const uint8* src0, const uint8* src1, 590 const uint8* alpha, uint8* dst, int width) = BlendPlaneRow_C; 905 const uint8* alpha, uint8* dst, int width) = 906 BlendPlaneRow_C; 591 907 if (!src_y0 || !src_y1 || !alpha || !dst_y || width <= 0 || height == 0) { 592 908 return -1; … … 600 916 601 917 // Coalesce rows for Y plane. 602 if (src_stride_y0 == width && 603 src_stride_y1 == width && 604 alpha_stride == width && 605 dst_stride_y == width) { 918 if (src_stride_y0 == width && src_stride_y1 == width && 919 alpha_stride == width && dst_stride_y == width) { 606 920 width *= height; 607 921 height = 1; … … 611 925 #if defined(HAS_BLENDPLANEROW_SSSE3) 612 926 if (TestCpuFlag(kCpuHasSSSE3)) { 613 BlendPlaneRow = BlendPlaneRow_Any_SSSE3;927 BlendPlaneRow = BlendPlaneRow_Any_SSSE3; 614 928 if (IS_ALIGNED(width, 8)) { 615 929 BlendPlaneRow = BlendPlaneRow_SSSE3; … … 619 933 #if defined(HAS_BLENDPLANEROW_AVX2) 620 934 if (TestCpuFlag(kCpuHasAVX2)) { 621 BlendPlaneRow = BlendPlaneRow_Any_AVX2;935 BlendPlaneRow = BlendPlaneRow_Any_AVX2; 622 936 if (IS_ALIGNED(width, 32)) { 623 937 BlendPlaneRow = BlendPlaneRow_AVX2; … … 639 953 // Alpha Blend YUV images and store to destination. 640 954 LIBYUV_API 641 int I420Blend(const uint8* src_y0, int src_stride_y0, 642 const uint8* src_u0, int src_stride_u0, 643 const uint8* src_v0, int src_stride_v0, 644 const uint8* src_y1, int src_stride_y1, 645 const uint8* src_u1, int src_stride_u1, 646 const uint8* src_v1, int src_stride_v1, 647 const uint8* alpha, int alpha_stride, 648 uint8* dst_y, int dst_stride_y, 649 uint8* dst_u, int dst_stride_u, 650 uint8* dst_v, int dst_stride_v, 651 int width, int height) { 955 int I420Blend(const uint8* src_y0, 956 int src_stride_y0, 957 const uint8* src_u0, 958 int src_stride_u0, 959 const uint8* src_v0, 960 int src_stride_v0, 961 const uint8* src_y1, 962 int src_stride_y1, 963 const uint8* src_u1, 964 int src_stride_u1, 965 const uint8* src_v1, 966 int src_stride_v1, 967 const uint8* alpha, 968 int alpha_stride, 969 uint8* dst_y, 970 int dst_stride_y, 971 uint8* dst_u, 972 int dst_stride_u, 973 uint8* dst_v, 974 int dst_stride_v, 975 int width, 976 int height) { 652 977 int y; 653 978 // Half width/height for UV. 654 979 int halfwidth = (width + 1) >> 1; 655 980 void (*BlendPlaneRow)(const uint8* src0, const uint8* src1, 656 const uint8* alpha, uint8* dst, int width) = BlendPlaneRow_C; 981 const uint8* alpha, uint8* dst, int width) = 982 BlendPlaneRow_C; 657 983 void (*ScaleRowDown2)(const uint8* src_ptr, ptrdiff_t src_stride, 658 984 uint8* dst_ptr, int dst_width) = ScaleRowDown2Box_C; … … 670 996 671 997 // Blend Y plane. 672 BlendPlane(src_y0, src_stride_y0, 673 src_y1, src_stride_y1, 674 alpha, alpha_stride, 675 dst_y, dst_stride_y, 676 width, height); 998 BlendPlane(src_y0, src_stride_y0, src_y1, src_stride_y1, alpha, alpha_stride, 999 dst_y, dst_stride_y, width, height); 677 1000 678 1001 #if defined(HAS_BLENDPLANEROW_SSSE3) … … 754 1077 // Multiply 2 ARGB images and store to destination. 755 1078 LIBYUV_API 756 int ARGBMultiply(const uint8* src_argb0, int src_stride_argb0, 757 const uint8* src_argb1, int src_stride_argb1, 758 uint8* dst_argb, int dst_stride_argb, 759 int width, int height) { 1079 int ARGBMultiply(const uint8* src_argb0, 1080 int src_stride_argb0, 1081 const uint8* src_argb1, 1082 int src_stride_argb1, 1083 uint8* dst_argb, 1084 int dst_stride_argb, 1085 int width, 1086 int height) { 760 1087 int y; 761 1088 void (*ARGBMultiplyRow)(const uint8* src0, const uint8* src1, uint8* dst, … … 771 1098 } 772 1099 // Coalesce rows. 773 if (src_stride_argb0 == width * 4 && 774 src_stride_argb1 == width * 4 && 1100 if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && 775 1101 dst_stride_argb == width * 4) { 776 1102 width *= height; … … 802 1128 } 803 1129 #endif 1130 #if defined(HAS_ARGBMULTIPLYROW_MSA) 1131 if (TestCpuFlag(kCpuHasMSA)) { 1132 ARGBMultiplyRow = ARGBMultiplyRow_Any_MSA; 1133 if (IS_ALIGNED(width, 4)) { 1134 ARGBMultiplyRow = ARGBMultiplyRow_MSA; 1135 } 1136 } 1137 #endif 804 1138 805 1139 // Multiply plane … … 815 1149 // Add 2 ARGB images and store to destination. 816 1150 LIBYUV_API 817 int ARGBAdd(const uint8* src_argb0, int src_stride_argb0, 818 const uint8* src_argb1, int src_stride_argb1, 819 uint8* dst_argb, int dst_stride_argb, 820 int width, int height) { 1151 int ARGBAdd(const uint8* src_argb0, 1152 int src_stride_argb0, 1153 const uint8* src_argb1, 1154 int src_stride_argb1, 1155 uint8* dst_argb, 1156 int dst_stride_argb, 1157 int width, 1158 int height) { 821 1159 int y; 822 1160 void (*ARGBAddRow)(const uint8* src0, const uint8* src1, uint8* dst, … … 832 1170 } 833 1171 // Coalesce rows. 834 if (src_stride_argb0 == width * 4 && 835 src_stride_argb1 == width * 4 && 1172 if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && 836 1173 dst_stride_argb == width * 4) { 837 1174 width *= height; … … 868 1205 } 869 1206 #endif 1207 #if defined(HAS_ARGBADDROW_MSA) 1208 if (TestCpuFlag(kCpuHasMSA)) { 1209 ARGBAddRow = ARGBAddRow_Any_MSA; 1210 if (IS_ALIGNED(width, 8)) { 1211 ARGBAddRow = ARGBAddRow_MSA; 1212 } 1213 } 1214 #endif 870 1215 871 1216 // Add plane … … 881 1226 // Subtract 2 ARGB images and store to destination. 882 1227 LIBYUV_API 883 int ARGBSubtract(const uint8* src_argb0, int src_stride_argb0, 884 const uint8* src_argb1, int src_stride_argb1, 885 uint8* dst_argb, int dst_stride_argb, 886 int width, int height) { 1228 int ARGBSubtract(const uint8* src_argb0, 1229 int src_stride_argb0, 1230 const uint8* src_argb1, 1231 int src_stride_argb1, 1232 uint8* dst_argb, 1233 int dst_stride_argb, 1234 int width, 1235 int height) { 887 1236 int y; 888 1237 void (*ARGBSubtractRow)(const uint8* src0, const uint8* src1, uint8* dst, … … 898 1247 } 899 1248 // Coalesce rows. 900 if (src_stride_argb0 == width * 4 && 901 src_stride_argb1 == width * 4 && 1249 if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && 902 1250 dst_stride_argb == width * 4) { 903 1251 width *= height; … … 929 1277 } 930 1278 #endif 1279 #if defined(HAS_ARGBSUBTRACTROW_MSA) 1280 if (TestCpuFlag(kCpuHasMSA)) { 1281 ARGBSubtractRow = ARGBSubtractRow_Any_MSA; 1282 if (IS_ALIGNED(width, 8)) { 1283 ARGBSubtractRow = ARGBSubtractRow_MSA; 1284 } 1285 } 1286 #endif 931 1287 932 1288 // Subtract plane … … 940 1296 } 941 1297 // Convert I422 to RGBA with matrix 942 static int I422ToRGBAMatrix(const uint8* src_y, int src_stride_y, 943 const uint8* src_u, int src_stride_u, 944 const uint8* src_v, int src_stride_v, 945 uint8* dst_rgba, int dst_stride_rgba, 1298 static int I422ToRGBAMatrix(const uint8* src_y, 1299 int src_stride_y, 1300 const uint8* src_u, 1301 int src_stride_u, 1302 const uint8* src_v, 1303 int src_stride_v, 1304 uint8* dst_rgba, 1305 int dst_stride_rgba, 946 1306 const struct YuvConstants* yuvconstants, 947 int width, int height) { 948 int y; 949 void (*I422ToRGBARow)(const uint8* y_buf, 950 const uint8* u_buf, 951 const uint8* v_buf, 952 uint8* rgb_buf, 953 const struct YuvConstants* yuvconstants, 954 int width) = I422ToRGBARow_C; 955 if (!src_y || !src_u || !src_v || !dst_rgba || 956 width <= 0 || height == 0) { 1307 int width, 1308 int height) { 1309 int y; 1310 void (*I422ToRGBARow)(const uint8* y_buf, const uint8* u_buf, 1311 const uint8* v_buf, uint8* rgb_buf, 1312 const struct YuvConstants* yuvconstants, int width) = 1313 I422ToRGBARow_C; 1314 if (!src_y || !src_u || !src_v || !dst_rgba || width <= 0 || height == 0) { 957 1315 return -1; 958 1316 } … … 996 1354 } 997 1355 #endif 1356 #if defined(HAS_I422TORGBAROW_MSA) 1357 if (TestCpuFlag(kCpuHasMSA)) { 1358 I422ToRGBARow = I422ToRGBARow_Any_MSA; 1359 if (IS_ALIGNED(width, 8)) { 1360 I422ToRGBARow = I422ToRGBARow_MSA; 1361 } 1362 } 1363 #endif 998 1364 999 1365 for (y = 0; y < height; ++y) { … … 1009 1375 // Convert I422 to RGBA. 1010 1376 LIBYUV_API 1011 int I422ToRGBA(const uint8* src_y, int src_stride_y, 1012 const uint8* src_u, int src_stride_u, 1013 const uint8* src_v, int src_stride_v, 1014 uint8* dst_rgba, int dst_stride_rgba, 1015 int width, int height) { 1016 return I422ToRGBAMatrix(src_y, src_stride_y, 1017 src_u, src_stride_u, 1018 src_v, src_stride_v, 1019 dst_rgba, dst_stride_rgba, 1020 &kYuvI601Constants, 1021 width, height); 1377 int I422ToRGBA(const uint8* src_y, 1378 int src_stride_y, 1379 const uint8* src_u, 1380 int src_stride_u, 1381 const uint8* src_v, 1382 int src_stride_v, 1383 uint8* dst_rgba, 1384 int dst_stride_rgba, 1385 int width, 1386 int height) { 1387 return I422ToRGBAMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, 1388 src_stride_v, dst_rgba, dst_stride_rgba, 1389 &kYuvI601Constants, width, height); 1022 1390 } 1023 1391 1024 1392 // Convert I422 to BGRA. 1025 1393 LIBYUV_API 1026 int I422ToBGRA(const uint8* src_y, int src_stride_y, 1027 const uint8* src_u, int src_stride_u, 1028 const uint8* src_v, int src_stride_v, 1029 uint8* dst_bgra, int dst_stride_bgra, 1030 int width, int height) { 1031 return I422ToRGBAMatrix(src_y, src_stride_y, 1032 src_v, src_stride_v, // Swap U and V 1033 src_u, src_stride_u, 1034 dst_bgra, dst_stride_bgra, 1394 int I422ToBGRA(const uint8* src_y, 1395 int src_stride_y, 1396 const uint8* src_u, 1397 int src_stride_u, 1398 const uint8* src_v, 1399 int src_stride_v, 1400 uint8* dst_bgra, 1401 int dst_stride_bgra, 1402 int width, 1403 int height) { 1404 return I422ToRGBAMatrix(src_y, src_stride_y, src_v, 1405 src_stride_v, // Swap U and V 1406 src_u, src_stride_u, dst_bgra, dst_stride_bgra, 1035 1407 &kYvuI601Constants, // Use Yvu matrix 1036 1408 width, height); … … 1039 1411 // Convert NV12 to RGB565. 1040 1412 LIBYUV_API 1041 int NV12ToRGB565(const uint8* src_y, int src_stride_y, 1042 const uint8* src_uv, int src_stride_uv, 1043 uint8* dst_rgb565, int dst_stride_rgb565, 1044 int width, int height) { 1045 int y; 1046 void (*NV12ToRGB565Row)(const uint8* y_buf, 1047 const uint8* uv_buf, 1048 uint8* rgb_buf, 1049 const struct YuvConstants* yuvconstants, 1050 int width) = NV12ToRGB565Row_C; 1051 if (!src_y || !src_uv || !dst_rgb565 || 1052 width <= 0 || height == 0) { 1413 int NV12ToRGB565(const uint8* src_y, 1414 int src_stride_y, 1415 const uint8* src_uv, 1416 int src_stride_uv, 1417 uint8* dst_rgb565, 1418 int dst_stride_rgb565, 1419 int width, 1420 int height) { 1421 int y; 1422 void (*NV12ToRGB565Row)( 1423 const uint8* y_buf, const uint8* uv_buf, uint8* rgb_buf, 1424 const struct YuvConstants* yuvconstants, int width) = NV12ToRGB565Row_C; 1425 if (!src_y || !src_uv || !dst_rgb565 || width <= 0 || height == 0) { 1053 1426 return -1; 1054 1427 } … … 1083 1456 } 1084 1457 #endif 1458 #if defined(HAS_NV12TORGB565ROW_MSA) 1459 if (TestCpuFlag(kCpuHasMSA)) { 1460 NV12ToRGB565Row = NV12ToRGB565Row_Any_MSA; 1461 if (IS_ALIGNED(width, 8)) { 1462 NV12ToRGB565Row = NV12ToRGB565Row_MSA; 1463 } 1464 } 1465 #endif 1085 1466 1086 1467 for (y = 0; y < height; ++y) { … … 1097 1478 // Convert RAW to RGB24. 1098 1479 LIBYUV_API 1099 int RAWToRGB24(const uint8* src_raw, int src_stride_raw, 1100 uint8* dst_rgb24, int dst_stride_rgb24, 1101 int width, int height) { 1480 int RAWToRGB24(const uint8* src_raw, 1481 int src_stride_raw, 1482 uint8* dst_rgb24, 1483 int dst_stride_rgb24, 1484 int width, 1485 int height) { 1102 1486 int y; 1103 1487 void (*RAWToRGB24Row)(const uint8* src_rgb, uint8* dst_rgb24, int width) = 1104 1488 RAWToRGB24Row_C; 1105 if (!src_raw || !dst_rgb24 || 1106 width <= 0 || height == 0) { 1489 if (!src_raw || !dst_rgb24 || width <= 0 || height == 0) { 1107 1490 return -1; 1108 1491 } … … 1114 1497 } 1115 1498 // Coalesce rows. 1116 if (src_stride_raw == width * 3 && 1117 dst_stride_rgb24 == width * 3) { 1499 if (src_stride_raw == width * 3 && dst_stride_rgb24 == width * 3) { 1118 1500 width *= height; 1119 1501 height = 1; … … 1136 1518 } 1137 1519 #endif 1520 #if defined(HAS_RAWTORGB24ROW_MSA) 1521 if (TestCpuFlag(kCpuHasMSA)) { 1522 RAWToRGB24Row = RAWToRGB24Row_Any_MSA; 1523 if (IS_ALIGNED(width, 16)) { 1524 RAWToRGB24Row = RAWToRGB24Row_MSA; 1525 } 1526 } 1527 #endif 1138 1528 1139 1529 for (y = 0; y < height; ++y) { … … 1146 1536 1147 1537 LIBYUV_API 1148 void SetPlane(uint8* dst_y, int dst_stride_y, 1149 int width, int height, 1538 void SetPlane(uint8* dst_y, 1539 int dst_stride_y, 1540 int width, 1541 int height, 1150 1542 uint32 value) { 1151 1543 int y; 1152 void (*SetRow)(uint8 * dst, uint8 value, int width) = SetRow_C;1544 void (*SetRow)(uint8 * dst, uint8 value, int width) = SetRow_C; 1153 1545 if (height < 0) { 1154 1546 height = -height; … … 1193 1585 // Draw a rectangle into I420 1194 1586 LIBYUV_API 1195 int I420Rect(uint8* dst_y, int dst_stride_y, 1196 uint8* dst_u, int dst_stride_u, 1197 uint8* dst_v, int dst_stride_v, 1198 int x, int y, 1199 int width, int height, 1200 int value_y, int value_u, int value_v) { 1587 int I420Rect(uint8* dst_y, 1588 int dst_stride_y, 1589 uint8* dst_u, 1590 int dst_stride_u, 1591 uint8* dst_v, 1592 int dst_stride_v, 1593 int x, 1594 int y, 1595 int width, 1596 int height, 1597 int value_y, 1598 int value_u, 1599 int value_v) { 1201 1600 int halfwidth = (width + 1) >> 1; 1202 1601 int halfheight = (height + 1) >> 1; … … 1204 1603 uint8* start_u = dst_u + (y / 2) * dst_stride_u + (x / 2); 1205 1604 uint8* start_v = dst_v + (y / 2) * dst_stride_v + (x / 2); 1206 if (!dst_y || !dst_u || !dst_v || 1207 width <= 0 || height == 0 || 1208 x < 0 || y < 0 || 1209 value_y < 0 || value_y > 255 || 1210 value_u < 0 || value_u > 255 || 1605 if (!dst_y || !dst_u || !dst_v || width <= 0 || height == 0 || x < 0 || 1606 y < 0 || value_y < 0 || value_y > 255 || value_u < 0 || value_u > 255 || 1211 1607 value_v < 0 || value_v > 255) { 1212 1608 return -1; … … 1221 1617 // Draw a rectangle into ARGB 1222 1618 LIBYUV_API 1223 int ARGBRect(uint8* dst_argb, int dst_stride_argb, 1224 int dst_x, int dst_y, 1225 int width, int height, 1619 int ARGBRect(uint8* dst_argb, 1620 int dst_stride_argb, 1621 int dst_x, 1622 int dst_y, 1623 int width, 1624 int height, 1226 1625 uint32 value) { 1227 1626 int y; 1228 void (*ARGBSetRow)(uint8* dst_argb, uint32 value, int width) = ARGBSetRow_C; 1229 if (!dst_argb || 1230 width <= 0 || height == 0 || 1231 dst_x < 0 || dst_y < 0) { 1627 void (*ARGBSetRow)(uint8 * dst_argb, uint32 value, int width) = ARGBSetRow_C; 1628 if (!dst_argb || width <= 0 || height == 0 || dst_x < 0 || dst_y < 0) { 1232 1629 return -1; 1233 1630 } … … 1256 1653 if (TestCpuFlag(kCpuHasX86)) { 1257 1654 ARGBSetRow = ARGBSetRow_X86; 1655 } 1656 #endif 1657 #if defined(HAS_ARGBSETROW_MSA) 1658 if (TestCpuFlag(kCpuHasMSA)) { 1659 ARGBSetRow = ARGBSetRow_Any_MSA; 1660 if (IS_ALIGNED(width, 4)) { 1661 ARGBSetRow = ARGBSetRow_MSA; 1662 } 1258 1663 } 1259 1664 #endif … … 1281 1686 1282 1687 LIBYUV_API 1283 int ARGBAttenuate(const uint8* src_argb, int src_stride_argb, 1284 uint8* dst_argb, int dst_stride_argb, 1285 int width, int height) { 1286 int y; 1287 void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb, 1288 int width) = ARGBAttenuateRow_C; 1688 int ARGBAttenuate(const uint8* src_argb, 1689 int src_stride_argb, 1690 uint8* dst_argb, 1691 int dst_stride_argb, 1692 int width, 1693 int height) { 1694 int y; 1695 void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb, int width) = 1696 ARGBAttenuateRow_C; 1289 1697 if (!src_argb || !dst_argb || width <= 0 || height == 0) { 1290 1698 return -1; … … 1296 1704 } 1297 1705 // Coalesce rows. 1298 if (src_stride_argb == width * 4 && 1299 dst_stride_argb == width * 4) { 1706 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 1300 1707 width *= height; 1301 1708 height = 1; … … 1326 1733 } 1327 1734 #endif 1735 #if defined(HAS_ARGBATTENUATEROW_MSA) 1736 if (TestCpuFlag(kCpuHasMSA)) { 1737 ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; 1738 if (IS_ALIGNED(width, 8)) { 1739 ARGBAttenuateRow = ARGBAttenuateRow_MSA; 1740 } 1741 } 1742 #endif 1328 1743 1329 1744 for (y = 0; y < height; ++y) { … … 1337 1752 // Convert preattentuated ARGB to unattenuated ARGB. 1338 1753 LIBYUV_API 1339 int ARGBUnattenuate(const uint8* src_argb, int src_stride_argb, 1340 uint8* dst_argb, int dst_stride_argb, 1341 int width, int height) { 1754 int ARGBUnattenuate(const uint8* src_argb, 1755 int src_stride_argb, 1756 uint8* dst_argb, 1757 int dst_stride_argb, 1758 int width, 1759 int height) { 1342 1760 int y; 1343 1761 void (*ARGBUnattenuateRow)(const uint8* src_argb, uint8* dst_argb, … … 1352 1770 } 1353 1771 // Coalesce rows. 1354 if (src_stride_argb == width * 4 && 1355 dst_stride_argb == width * 4) { 1772 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 1356 1773 width *= height; 1357 1774 height = 1; … … 1374 1791 } 1375 1792 #endif 1376 // TODO(fbarchard): Neon version.1793 // TODO(fbarchard): Neon version. 1377 1794 1378 1795 for (y = 0; y < height; ++y) { … … 1386 1803 // Convert ARGB to Grayed ARGB. 1387 1804 LIBYUV_API 1388 int ARGBGrayTo(const uint8* src_argb, int src_stride_argb, 1389 uint8* dst_argb, int dst_stride_argb, 1390 int width, int height) { 1391 int y; 1392 void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb, 1393 int width) = ARGBGrayRow_C; 1805 int ARGBGrayTo(const uint8* src_argb, 1806 int src_stride_argb, 1807 uint8* dst_argb, 1808 int dst_stride_argb, 1809 int width, 1810 int height) { 1811 int y; 1812 void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb, int width) = 1813 ARGBGrayRow_C; 1394 1814 if (!src_argb || !dst_argb || width <= 0 || height == 0) { 1395 1815 return -1; … … 1401 1821 } 1402 1822 // Coalesce rows. 1403 if (src_stride_argb == width * 4 && 1404 dst_stride_argb == width * 4) { 1823 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 1405 1824 width *= height; 1406 1825 height = 1; … … 1417 1836 } 1418 1837 #endif 1838 #if defined(HAS_ARGBGRAYROW_MSA) 1839 if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { 1840 ARGBGrayRow = ARGBGrayRow_MSA; 1841 } 1842 #endif 1419 1843 1420 1844 for (y = 0; y < height; ++y) { … … 1428 1852 // Make a rectangle of ARGB gray scale. 1429 1853 LIBYUV_API 1430 int ARGBGray(uint8* dst_argb, int dst_stride_argb, 1431 int dst_x, int dst_y, 1432 int width, int height) { 1433 int y; 1434 void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb, 1435 int width) = ARGBGrayRow_C; 1854 int ARGBGray(uint8* dst_argb, 1855 int dst_stride_argb, 1856 int dst_x, 1857 int dst_y, 1858 int width, 1859 int height) { 1860 int y; 1861 void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb, int width) = 1862 ARGBGrayRow_C; 1436 1863 uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; 1437 1864 if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) { … … 1454 1881 } 1455 1882 #endif 1883 #if defined(HAS_ARGBGRAYROW_MSA) 1884 if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { 1885 ARGBGrayRow = ARGBGrayRow_MSA; 1886 } 1887 #endif 1888 1456 1889 for (y = 0; y < height; ++y) { 1457 1890 ARGBGrayRow(dst, dst, width); … … 1463 1896 // Make a rectangle of ARGB Sepia tone. 1464 1897 LIBYUV_API 1465 int ARGBSepia(uint8* dst_argb, int dst_stride_argb, 1466 int dst_x, int dst_y, int width, int height) { 1467 int y; 1468 void (*ARGBSepiaRow)(uint8* dst_argb, int width) = ARGBSepiaRow_C; 1898 int ARGBSepia(uint8* dst_argb, 1899 int dst_stride_argb, 1900 int dst_x, 1901 int dst_y, 1902 int width, 1903 int height) { 1904 int y; 1905 void (*ARGBSepiaRow)(uint8 * dst_argb, int width) = ARGBSepiaRow_C; 1469 1906 uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; 1470 1907 if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) { … … 1487 1924 } 1488 1925 #endif 1926 #if defined(HAS_ARGBSEPIAROW_MSA) 1927 if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { 1928 ARGBSepiaRow = ARGBSepiaRow_MSA; 1929 } 1930 #endif 1931 1489 1932 for (y = 0; y < height; ++y) { 1490 1933 ARGBSepiaRow(dst, width); … … 1497 1940 // Note: Normally for shading, but can be used to swizzle or invert. 1498 1941 LIBYUV_API 1499 int ARGBColorMatrix(const uint8* src_argb, int src_stride_argb, 1500 uint8* dst_argb, int dst_stride_argb, 1942 int ARGBColorMatrix(const uint8* src_argb, 1943 int src_stride_argb, 1944 uint8* dst_argb, 1945 int dst_stride_argb, 1501 1946 const int8* matrix_argb, 1502 int width, int height) { 1947 int width, 1948 int height) { 1503 1949 int y; 1504 1950 void (*ARGBColorMatrixRow)(const uint8* src_argb, uint8* dst_argb, 1505 const int8* matrix_argb, int width) = ARGBColorMatrixRow_C; 1951 const int8* matrix_argb, int width) = 1952 ARGBColorMatrixRow_C; 1506 1953 if (!src_argb || !dst_argb || !matrix_argb || width <= 0 || height == 0) { 1507 1954 return -1; … … 1513 1960 } 1514 1961 // Coalesce rows. 1515 if (src_stride_argb == width * 4 && 1516 dst_stride_argb == width * 4) { 1962 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 1517 1963 width *= height; 1518 1964 height = 1; … … 1540 1986 // Deprecated. 1541 1987 LIBYUV_API 1542 int RGBColorMatrix(uint8* dst_argb, int dst_stride_argb, 1988 int RGBColorMatrix(uint8* dst_argb, 1989 int dst_stride_argb, 1543 1990 const int8* matrix_rgb, 1544 int dst_x, int dst_y, int width, int height) { 1991 int dst_x, 1992 int dst_y, 1993 int width, 1994 int height) { 1545 1995 SIMD_ALIGNED(int8 matrix_argb[16]); 1546 1996 uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; 1547 if (!dst_argb || !matrix_rgb || width <= 0 || height <= 0 || 1548 dst_ x < 0 || dst_y < 0) {1997 if (!dst_argb || !matrix_rgb || width <= 0 || height <= 0 || dst_x < 0 || 1998 dst_y < 0) { 1549 1999 return -1; 1550 2000 } … … 1566 2016 matrix_argb[15] = 64; // 1.0 1567 2017 1568 return ARGBColorMatrix((const uint8*)(dst), dst_stride_argb, 1569 dst, dst_stride_argb, 1570 &matrix_argb[0], width, height); 2018 return ARGBColorMatrix((const uint8*)(dst), dst_stride_argb, dst, 2019 dst_stride_argb, &matrix_argb[0], width, height); 1571 2020 } 1572 2021 … … 1574 2023 // Table contains 256 ARGB values. 1575 2024 LIBYUV_API 1576 int ARGBColorTable(uint8* dst_argb, int dst_stride_argb, 2025 int ARGBColorTable(uint8* dst_argb, 2026 int dst_stride_argb, 1577 2027 const uint8* table_argb, 1578 int dst_x, int dst_y, int width, int height) { 1579 int y; 1580 void (*ARGBColorTableRow)(uint8* dst_argb, const uint8* table_argb, 2028 int dst_x, 2029 int dst_y, 2030 int width, 2031 int height) { 2032 int y; 2033 void (*ARGBColorTableRow)(uint8 * dst_argb, const uint8* table_argb, 1581 2034 int width) = ARGBColorTableRow_C; 1582 2035 uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; 1583 if (!dst_argb || !table_argb || width <= 0 || height <= 0 || 1584 dst_ x < 0 || dst_y < 0) {2036 if (!dst_argb || !table_argb || width <= 0 || height <= 0 || dst_x < 0 || 2037 dst_y < 0) { 1585 2038 return -1; 1586 2039 } … … 1606 2059 // Table contains 256 ARGB values. 1607 2060 LIBYUV_API 1608 int RGBColorTable(uint8* dst_argb, int dst_stride_argb, 2061 int RGBColorTable(uint8* dst_argb, 2062 int dst_stride_argb, 1609 2063 const uint8* table_argb, 1610 int dst_x, int dst_y, int width, int height) { 1611 int y; 1612 void (*RGBColorTableRow)(uint8* dst_argb, const uint8* table_argb, 2064 int dst_x, 2065 int dst_y, 2066 int width, 2067 int height) { 2068 int y; 2069 void (*RGBColorTableRow)(uint8 * dst_argb, const uint8* table_argb, 1613 2070 int width) = RGBColorTableRow_C; 1614 2071 uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; 1615 if (!dst_argb || !table_argb || width <= 0 || height <= 0 || 1616 dst_ x < 0 || dst_y < 0) {2072 if (!dst_argb || !table_argb || width <= 0 || height <= 0 || dst_x < 0 || 2073 dst_y < 0) { 1617 2074 return -1; 1618 2075 } … … 1645 2102 // with care if doing anything but quantization. 1646 2103 LIBYUV_API 1647 int ARGBQuantize(uint8* dst_argb, int dst_stride_argb, 1648 int scale, int interval_size, int interval_offset, 1649 int dst_x, int dst_y, int width, int height) { 1650 int y; 1651 void (*ARGBQuantizeRow)(uint8* dst_argb, int scale, int interval_size, 2104 int ARGBQuantize(uint8* dst_argb, 2105 int dst_stride_argb, 2106 int scale, 2107 int interval_size, 2108 int interval_offset, 2109 int dst_x, 2110 int dst_y, 2111 int width, 2112 int height) { 2113 int y; 2114 void (*ARGBQuantizeRow)(uint8 * dst_argb, int scale, int interval_size, 1652 2115 int interval_offset, int width) = ARGBQuantizeRow_C; 1653 2116 uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; … … 1682 2145 // of all values above and to the left of the entry. Used by ARGBBlur. 1683 2146 LIBYUV_API 1684 int ARGBComputeCumulativeSum(const uint8* src_argb, int src_stride_argb, 1685 int32* dst_cumsum, int dst_stride32_cumsum, 1686 int width, int height) { 2147 int ARGBComputeCumulativeSum(const uint8* src_argb, 2148 int src_stride_argb, 2149 int32* dst_cumsum, 2150 int dst_stride32_cumsum, 2151 int width, 2152 int height) { 1687 2153 int y; 1688 2154 void (*ComputeCumulativeSumRow)(const uint8* row, int32* cumsum, 1689 const int32* previous_cumsum, int width) = ComputeCumulativeSumRow_C; 2155 const int32* previous_cumsum, int width) = 2156 ComputeCumulativeSumRow_C; 1690 2157 int32* previous_cumsum = dst_cumsum; 1691 2158 if (!dst_cumsum || !src_argb || width <= 0 || height <= 0) { … … 1712 2179 // as the buffer is treated as circular. 1713 2180 LIBYUV_API 1714 int ARGBBlur(const uint8* src_argb, int src_stride_argb, 1715 uint8* dst_argb, int dst_stride_argb, 1716 int32* dst_cumsum, int dst_stride32_cumsum, 1717 int width, int height, int radius) { 1718 int y; 1719 void (*ComputeCumulativeSumRow)(const uint8 *row, int32 *cumsum, 1720 const int32* previous_cumsum, int width) = ComputeCumulativeSumRow_C; 2181 int ARGBBlur(const uint8* src_argb, 2182 int src_stride_argb, 2183 uint8* dst_argb, 2184 int dst_stride_argb, 2185 int32* dst_cumsum, 2186 int dst_stride32_cumsum, 2187 int width, 2188 int height, 2189 int radius) { 2190 int y; 2191 void (*ComputeCumulativeSumRow)(const uint8* row, int32* cumsum, 2192 const int32* previous_cumsum, int width) = 2193 ComputeCumulativeSumRow_C; 1721 2194 void (*CumulativeSumToAverageRow)(const int32* topleft, const int32* botleft, 1722 int width, int area, uint8* dst, int count) = CumulativeSumToAverageRow_C; 2195 int width, int area, uint8* dst, 2196 int count) = CumulativeSumToAverageRow_C; 1723 2197 int32* cumsum_bot_row; 1724 2198 int32* max_cumsum_bot_row; … … 1750 2224 // Compute enough CumulativeSum for first row to be blurred. After this 1751 2225 // one row of CumulativeSum is updated at a time. 1752 ARGBComputeCumulativeSum(src_argb, src_stride_argb, 1753 dst_cumsum, dst_stride32_cumsum, 1754 width, radius); 2226 ARGBComputeCumulativeSum(src_argb, src_stride_argb, dst_cumsum, 2227 dst_stride32_cumsum, width, radius); 1755 2228 1756 2229 src_argb = src_argb + radius * src_stride_argb; … … 1790 2263 // Left clipped. 1791 2264 for (x = 0; x < radius + 1; ++x) { 1792 CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, 1793 boxwidth, area,&dst_argb[x * 4], 1);2265 CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, boxwidth, area, 2266 &dst_argb[x * 4], 1); 1794 2267 area += (bot_y - top_y); 1795 2268 boxwidth += 4; … … 1798 2271 // Middle unclipped. 1799 2272 n = (width - 1) - radius - x + 1; 1800 CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, 1801 boxwidth, area,&dst_argb[x * 4], n);2273 CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, boxwidth, area, 2274 &dst_argb[x * 4], n); 1802 2275 1803 2276 // Right clipped. … … 1806 2279 boxwidth -= 4; 1807 2280 CumulativeSumToAverageRow(cumsum_top_row + (x - radius - 1) * 4, 1808 cumsum_bot_row + (x - radius - 1) * 4, 1809 boxwidth,area, &dst_argb[x * 4], 1);2281 cumsum_bot_row + (x - radius - 1) * 4, boxwidth, 2282 area, &dst_argb[x * 4], 1); 1810 2283 } 1811 2284 dst_argb += dst_stride_argb; … … 1816 2289 // Multiply ARGB image by a specified ARGB value. 1817 2290 LIBYUV_API 1818 int ARGBShade(const uint8* src_argb, int src_stride_argb, 1819 uint8* dst_argb, int dst_stride_argb, 1820 int width, int height, uint32 value) { 1821 int y; 1822 void (*ARGBShadeRow)(const uint8* src_argb, uint8* dst_argb, 1823 int width, uint32 value) = ARGBShadeRow_C; 2291 int ARGBShade(const uint8* src_argb, 2292 int src_stride_argb, 2293 uint8* dst_argb, 2294 int dst_stride_argb, 2295 int width, 2296 int height, 2297 uint32 value) { 2298 int y; 2299 void (*ARGBShadeRow)(const uint8* src_argb, uint8* dst_argb, int width, 2300 uint32 value) = ARGBShadeRow_C; 1824 2301 if (!src_argb || !dst_argb || width <= 0 || height == 0 || value == 0u) { 1825 2302 return -1; … … 1831 2308 } 1832 2309 // Coalesce rows. 1833 if (src_stride_argb == width * 4 && 1834 dst_stride_argb == width * 4) { 2310 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 1835 2311 width *= height; 1836 2312 height = 1; … … 1847 2323 } 1848 2324 #endif 2325 #if defined(HAS_ARGBSHADEROW_MSA) 2326 if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 4)) { 2327 ARGBShadeRow = ARGBShadeRow_MSA; 2328 } 2329 #endif 1849 2330 1850 2331 for (y = 0; y < height; ++y) { … … 1858 2339 // Interpolate 2 planes by specified amount (0 to 255). 1859 2340 LIBYUV_API 1860 int InterpolatePlane(const uint8* src0, int src_stride0, 1861 const uint8* src1, int src_stride1, 1862 uint8* dst, int dst_stride, 1863 int width, int height, int interpolation) { 1864 int y; 1865 void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, 2341 int InterpolatePlane(const uint8* src0, 2342 int src_stride0, 2343 const uint8* src1, 2344 int src_stride1, 2345 uint8* dst, 2346 int dst_stride, 2347 int width, 2348 int height, 2349 int interpolation) { 2350 int y; 2351 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr, 1866 2352 ptrdiff_t src_stride, int dst_width, 1867 2353 int source_y_fraction) = InterpolateRow_C; … … 1876 2362 } 1877 2363 // Coalesce rows. 1878 if (src_stride0 == width && 1879 src_stride1 == width && 1880 dst_stride == width) { 2364 if (src_stride0 == width && src_stride1 == width && dst_stride == width) { 1881 2365 width *= height; 1882 2366 height = 1; … … 1908 2392 #endif 1909 2393 #if defined(HAS_INTERPOLATEROW_DSPR2) 1910 if (TestCpuFlag(kCpuHasDSPR2) && 1911 IS_ALIGNED(src0, 4) && IS_ALIGNED(src_stride0, 4) && 1912 IS_ALIGNED(src1, 4) && IS_ALIGNED(src_stride1, 4) && 1913 IS_ALIGNED(dst, 4) && IS_ALIGNED(dst_stride, 4) && 1914 IS_ALIGNED(width, 4)) { 2394 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src0, 4) && 2395 IS_ALIGNED(src_stride0, 4) && IS_ALIGNED(src1, 4) && 2396 IS_ALIGNED(src_stride1, 4) && IS_ALIGNED(dst, 4) && 2397 IS_ALIGNED(dst_stride, 4) && IS_ALIGNED(width, 4)) { 1915 2398 InterpolateRow = InterpolateRow_DSPR2; 2399 } 2400 #endif 2401 #if defined(HAS_INTERPOLATEROW_MSA) 2402 if (TestCpuFlag(kCpuHasMSA)) { 2403 InterpolateRow = InterpolateRow_Any_MSA; 2404 if (IS_ALIGNED(width, 32)) { 2405 InterpolateRow = InterpolateRow_MSA; 2406 } 1916 2407 } 1917 2408 #endif … … 1928 2419 // Interpolate 2 ARGB images by specified amount (0 to 255). 1929 2420 LIBYUV_API 1930 int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0, 1931 const uint8* src_argb1, int src_stride_argb1, 1932 uint8* dst_argb, int dst_stride_argb, 1933 int width, int height, int interpolation) { 1934 return InterpolatePlane(src_argb0, src_stride_argb0, 1935 src_argb1, src_stride_argb1, 1936 dst_argb, dst_stride_argb, 2421 int ARGBInterpolate(const uint8* src_argb0, 2422 int src_stride_argb0, 2423 const uint8* src_argb1, 2424 int src_stride_argb1, 2425 uint8* dst_argb, 2426 int dst_stride_argb, 2427 int width, 2428 int height, 2429 int interpolation) { 2430 return InterpolatePlane(src_argb0, src_stride_argb0, src_argb1, 2431 src_stride_argb1, dst_argb, dst_stride_argb, 1937 2432 width * 4, height, interpolation); 1938 2433 } … … 1940 2435 // Interpolate 2 YUV images by specified amount (0 to 255). 1941 2436 LIBYUV_API 1942 int I420Interpolate(const uint8* src0_y, int src0_stride_y, 1943 const uint8* src0_u, int src0_stride_u, 1944 const uint8* src0_v, int src0_stride_v, 1945 const uint8* src1_y, int src1_stride_y, 1946 const uint8* src1_u, int src1_stride_u, 1947 const uint8* src1_v, int src1_stride_v, 1948 uint8* dst_y, int dst_stride_y, 1949 uint8* dst_u, int dst_stride_u, 1950 uint8* dst_v, int dst_stride_v, 1951 int width, int height, int interpolation) { 2437 int I420Interpolate(const uint8* src0_y, 2438 int src0_stride_y, 2439 const uint8* src0_u, 2440 int src0_stride_u, 2441 const uint8* src0_v, 2442 int src0_stride_v, 2443 const uint8* src1_y, 2444 int src1_stride_y, 2445 const uint8* src1_u, 2446 int src1_stride_u, 2447 const uint8* src1_v, 2448 int src1_stride_v, 2449 uint8* dst_y, 2450 int dst_stride_y, 2451 uint8* dst_u, 2452 int dst_stride_u, 2453 uint8* dst_v, 2454 int dst_stride_v, 2455 int width, 2456 int height, 2457 int interpolation) { 1952 2458 int halfwidth = (width + 1) >> 1; 1953 2459 int halfheight = (height + 1) >> 1; 1954 if (!src0_y || !src0_u || !src0_v || 1955 !src1_y || !src1_u || !src1_v || 1956 !dst_y || !dst_u || !dst_v || 1957 width <= 0 || height == 0) { 1958 return -1; 1959 } 1960 InterpolatePlane(src0_y, src0_stride_y, 1961 src1_y, src1_stride_y, 1962 dst_y, dst_stride_y, 1963 width, height, interpolation); 1964 InterpolatePlane(src0_u, src0_stride_u, 1965 src1_u, src1_stride_u, 1966 dst_u, dst_stride_u, 1967 halfwidth, halfheight, interpolation); 1968 InterpolatePlane(src0_v, src0_stride_v, 1969 src1_v, src1_stride_v, 1970 dst_v, dst_stride_v, 1971 halfwidth, halfheight, interpolation); 2460 if (!src0_y || !src0_u || !src0_v || !src1_y || !src1_u || !src1_v || 2461 !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { 2462 return -1; 2463 } 2464 InterpolatePlane(src0_y, src0_stride_y, src1_y, src1_stride_y, dst_y, 2465 dst_stride_y, width, height, interpolation); 2466 InterpolatePlane(src0_u, src0_stride_u, src1_u, src1_stride_u, dst_u, 2467 dst_stride_u, halfwidth, halfheight, interpolation); 2468 InterpolatePlane(src0_v, src0_stride_v, src1_v, src1_stride_v, dst_v, 2469 dst_stride_v, halfwidth, halfheight, interpolation); 1972 2470 return 0; 1973 2471 } … … 1975 2473 // Shuffle ARGB channel order. e.g. BGRA to ARGB. 1976 2474 LIBYUV_API 1977 int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra, 1978 uint8* dst_argb, int dst_stride_argb, 1979 const uint8* shuffler, int width, int height) { 2475 int ARGBShuffle(const uint8* src_bgra, 2476 int src_stride_bgra, 2477 uint8* dst_argb, 2478 int dst_stride_argb, 2479 const uint8* shuffler, 2480 int width, 2481 int height) { 1980 2482 int y; 1981 2483 void (*ARGBShuffleRow)(const uint8* src_bgra, uint8* dst_argb, 1982 2484 const uint8* shuffler, int width) = ARGBShuffleRow_C; 1983 if (!src_bgra || !dst_argb || 1984 width <= 0 || height == 0) { 2485 if (!src_bgra || !dst_argb || width <= 0 || height == 0) { 1985 2486 return -1; 1986 2487 } … … 1992 2493 } 1993 2494 // Coalesce rows. 1994 if (src_stride_bgra == width * 4 && 1995 dst_stride_argb == width * 4) { 2495 if (src_stride_bgra == width * 4 && dst_stride_argb == width * 4) { 1996 2496 width *= height; 1997 2497 height = 1; … … 2030 2530 } 2031 2531 #endif 2532 #if defined(HAS_ARGBSHUFFLEROW_MSA) 2533 if (TestCpuFlag(kCpuHasMSA)) { 2534 ARGBShuffleRow = ARGBShuffleRow_Any_MSA; 2535 if (IS_ALIGNED(width, 8)) { 2536 ARGBShuffleRow = ARGBShuffleRow_MSA; 2537 } 2538 } 2539 #endif 2032 2540 2033 2541 for (y = 0; y < height; ++y) { … … 2040 2548 2041 2549 // Sobel ARGB effect. 2042 static int ARGBSobelize(const uint8* src_argb, int src_stride_argb, 2043 uint8* dst_argb, int dst_stride_argb, 2044 int width, int height, 2550 static int ARGBSobelize(const uint8* src_argb, 2551 int src_stride_argb, 2552 uint8* dst_argb, 2553 int dst_stride_argb, 2554 int width, 2555 int height, 2045 2556 void (*SobelRow)(const uint8* src_sobelx, 2046 2557 const uint8* src_sobely, 2047 uint8* dst, int width)) { 2558 uint8* dst, 2559 int width)) { 2048 2560 int y; 2049 2561 void (*ARGBToYJRow)(const uint8* src_argb, uint8* dst_g, int width) = 2050 2562 ARGBToYJRow_C; 2051 void (*SobelYRow)(const uint8* src_y0, const uint8* src_y1, 2052 uint8* dst_sobely,int width) = SobelYRow_C;2563 void (*SobelYRow)(const uint8* src_y0, const uint8* src_y1, uint8* dst_sobely, 2564 int width) = SobelYRow_C; 2053 2565 void (*SobelXRow)(const uint8* src_y0, const uint8* src_y1, 2054 2566 const uint8* src_y2, uint8* dst_sobely, int width) = 2055 2567 SobelXRow_C; 2056 2568 const int kEdge = 16; // Extra pixels at start of row for extrude/align. 2057 if (!src_argb 2569 if (!src_argb || !dst_argb || width <= 0 || height == 0) { 2058 2570 return -1; 2059 2571 } … … 2061 2573 if (height < 0) { 2062 2574 height = -height; 2063 src_argb = src_argb+ (height - 1) * src_stride_argb;2575 src_argb = src_argb + (height - 1) * src_stride_argb; 2064 2576 src_stride_argb = -src_stride_argb; 2065 2577 } … … 2086 2598 if (IS_ALIGNED(width, 8)) { 2087 2599 ARGBToYJRow = ARGBToYJRow_NEON; 2600 } 2601 } 2602 #endif 2603 #if defined(HAS_ARGBTOYJROW_MSA) 2604 if (TestCpuFlag(kCpuHasMSA)) { 2605 ARGBToYJRow = ARGBToYJRow_Any_MSA; 2606 if (IS_ALIGNED(width, 16)) { 2607 ARGBToYJRow = ARGBToYJRow_MSA; 2088 2608 } 2089 2609 } … … 2160 2680 // Sobel ARGB effect. 2161 2681 LIBYUV_API 2162 int ARGBSobel(const uint8* src_argb, int src_stride_argb, 2163 uint8* dst_argb, int dst_stride_argb, 2164 int width, int height) { 2682 int ARGBSobel(const uint8* src_argb, 2683 int src_stride_argb, 2684 uint8* dst_argb, 2685 int dst_stride_argb, 2686 int width, 2687 int height) { 2165 2688 void (*SobelRow)(const uint8* src_sobelx, const uint8* src_sobely, 2166 2689 uint8* dst_argb, int width) = SobelRow_C; … … 2181 2704 } 2182 2705 #endif 2706 #if defined(HAS_SOBELROW_MSA) 2707 if (TestCpuFlag(kCpuHasMSA)) { 2708 SobelRow = SobelRow_Any_MSA; 2709 if (IS_ALIGNED(width, 16)) { 2710 SobelRow = SobelRow_MSA; 2711 } 2712 } 2713 #endif 2183 2714 return ARGBSobelize(src_argb, src_stride_argb, dst_argb, dst_stride_argb, 2184 2715 width, height, SobelRow); … … 2187 2718 // Sobel ARGB effect with planar output. 2188 2719 LIBYUV_API 2189 int ARGBSobelToPlane(const uint8* src_argb, int src_stride_argb, 2190 uint8* dst_y, int dst_stride_y, 2191 int width, int height) { 2720 int ARGBSobelToPlane(const uint8* src_argb, 2721 int src_stride_argb, 2722 uint8* dst_y, 2723 int dst_stride_y, 2724 int width, 2725 int height) { 2192 2726 void (*SobelToPlaneRow)(const uint8* src_sobelx, const uint8* src_sobely, 2193 2727 uint8* dst_, int width) = SobelToPlaneRow_C; … … 2208 2742 } 2209 2743 #endif 2210 return ARGBSobelize(src_argb, src_stride_argb, dst_y, dst_stride_y, 2211 width, height, SobelToPlaneRow); 2744 #if defined(HAS_SOBELTOPLANEROW_MSA) 2745 if (TestCpuFlag(kCpuHasMSA)) { 2746 SobelToPlaneRow = SobelToPlaneRow_Any_MSA; 2747 if (IS_ALIGNED(width, 32)) { 2748 SobelToPlaneRow = SobelToPlaneRow_MSA; 2749 } 2750 } 2751 #endif 2752 return ARGBSobelize(src_argb, src_stride_argb, dst_y, dst_stride_y, width, 2753 height, SobelToPlaneRow); 2212 2754 } 2213 2755 … … 2215 2757 // Similar to Sobel, but also stores Sobel X in R and Sobel Y in B. G = Sobel. 2216 2758 LIBYUV_API 2217 int ARGBSobelXY(const uint8* src_argb, int src_stride_argb, 2218 uint8* dst_argb, int dst_stride_argb, 2219 int width, int height) { 2759 int ARGBSobelXY(const uint8* src_argb, 2760 int src_stride_argb, 2761 uint8* dst_argb, 2762 int dst_stride_argb, 2763 int width, 2764 int height) { 2220 2765 void (*SobelXYRow)(const uint8* src_sobelx, const uint8* src_sobely, 2221 2766 uint8* dst_argb, int width) = SobelXYRow_C; … … 2236 2781 } 2237 2782 #endif 2783 #if defined(HAS_SOBELXYROW_MSA) 2784 if (TestCpuFlag(kCpuHasMSA)) { 2785 SobelXYRow = SobelXYRow_Any_MSA; 2786 if (IS_ALIGNED(width, 16)) { 2787 SobelXYRow = SobelXYRow_MSA; 2788 } 2789 } 2790 #endif 2238 2791 return ARGBSobelize(src_argb, src_stride_argb, dst_argb, dst_stride_argb, 2239 2792 width, height, SobelXYRow); … … 2242 2795 // Apply a 4x4 polynomial to each ARGB pixel. 2243 2796 LIBYUV_API 2244 int ARGBPolynomial(const uint8* src_argb, int src_stride_argb, 2245 uint8* dst_argb, int dst_stride_argb, 2797 int ARGBPolynomial(const uint8* src_argb, 2798 int src_stride_argb, 2799 uint8* dst_argb, 2800 int dst_stride_argb, 2246 2801 const float* poly, 2247 int width, int height) {2248 int y;2249 void (*ARGBPolynomialRow)(const uint8* src_argb,2250 uint8* dst_argb, const float* poly,2251 int width) = ARGBPolynomialRow_C;2802 int width, 2803 int height) { 2804 int y; 2805 void (*ARGBPolynomialRow)(const uint8* src_argb, uint8* dst_argb, 2806 const float* poly, int width) = ARGBPolynomialRow_C; 2252 2807 if (!src_argb || !dst_argb || !poly || width <= 0 || height == 0) { 2253 2808 return -1; … … 2256 2811 if (height < 0) { 2257 2812 height = -height; 2258 src_argb = src_argb+ (height - 1) * src_stride_argb;2813 src_argb = src_argb + (height - 1) * src_stride_argb; 2259 2814 src_stride_argb = -src_stride_argb; 2260 2815 } 2261 2816 // Coalesce rows. 2262 if (src_stride_argb == width * 4 && 2263 dst_stride_argb == width * 4) { 2817 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 2264 2818 width *= height; 2265 2819 height = 1; … … 2286 2840 } 2287 2841 2842 // Convert plane of 16 bit shorts to half floats. 2843 // Source values are multiplied by scale before storing as half float. 2844 LIBYUV_API 2845 int HalfFloatPlane(const uint16* src_y, 2846 int src_stride_y, 2847 uint16* dst_y, 2848 int dst_stride_y, 2849 float scale, 2850 int width, 2851 int height) { 2852 int y; 2853 void (*HalfFloatRow)(const uint16* src, uint16* dst, float scale, int width) = 2854 HalfFloatRow_C; 2855 if (!src_y || !dst_y || width <= 0 || height == 0) { 2856 return -1; 2857 } 2858 src_stride_y >>= 1; 2859 dst_stride_y >>= 1; 2860 // Negative height means invert the image. 2861 if (height < 0) { 2862 height = -height; 2863 src_y = src_y + (height - 1) * src_stride_y; 2864 src_stride_y = -src_stride_y; 2865 } 2866 // Coalesce rows. 2867 if (src_stride_y == width && dst_stride_y == width) { 2868 width *= height; 2869 height = 1; 2870 src_stride_y = dst_stride_y = 0; 2871 } 2872 #if defined(HAS_HALFFLOATROW_SSE2) 2873 if (TestCpuFlag(kCpuHasSSE2)) { 2874 HalfFloatRow = HalfFloatRow_Any_SSE2; 2875 if (IS_ALIGNED(width, 8)) { 2876 HalfFloatRow = HalfFloatRow_SSE2; 2877 } 2878 } 2879 #endif 2880 #if defined(HAS_HALFFLOATROW_AVX2) 2881 if (TestCpuFlag(kCpuHasAVX2)) { 2882 HalfFloatRow = HalfFloatRow_Any_AVX2; 2883 if (IS_ALIGNED(width, 16)) { 2884 HalfFloatRow = HalfFloatRow_AVX2; 2885 } 2886 } 2887 #endif 2888 #if defined(HAS_HALFFLOATROW_F16C) 2889 if (TestCpuFlag(kCpuHasAVX2) && TestCpuFlag(kCpuHasF16C)) { 2890 HalfFloatRow = 2891 (scale == 1.0f) ? HalfFloat1Row_Any_F16C : HalfFloatRow_Any_F16C; 2892 if (IS_ALIGNED(width, 16)) { 2893 HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_F16C : HalfFloatRow_F16C; 2894 } 2895 } 2896 #endif 2897 #if defined(HAS_HALFFLOATROW_NEON) 2898 if (TestCpuFlag(kCpuHasNEON)) { 2899 HalfFloatRow = 2900 (scale == 1.0f) ? HalfFloat1Row_Any_NEON : HalfFloatRow_Any_NEON; 2901 if (IS_ALIGNED(width, 8)) { 2902 HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_NEON : HalfFloatRow_NEON; 2903 } 2904 } 2905 #endif 2906 2907 for (y = 0; y < height; ++y) { 2908 HalfFloatRow(src_y, dst_y, scale, width); 2909 src_y += src_stride_y; 2910 dst_y += dst_stride_y; 2911 } 2912 return 0; 2913 } 2914 2288 2915 // Apply a lumacolortable to each ARGB pixel. 2289 2916 LIBYUV_API 2290 int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb, 2291 uint8* dst_argb, int dst_stride_argb, 2917 int ARGBLumaColorTable(const uint8* src_argb, 2918 int src_stride_argb, 2919 uint8* dst_argb, 2920 int dst_stride_argb, 2292 2921 const uint8* luma, 2293 int width, int height) { 2294 int y; 2295 void (*ARGBLumaColorTableRow)(const uint8* src_argb, uint8* dst_argb, 2296 int width, const uint8* luma, const uint32 lumacoeff) = 2297 ARGBLumaColorTableRow_C; 2922 int width, 2923 int height) { 2924 int y; 2925 void (*ARGBLumaColorTableRow)( 2926 const uint8* src_argb, uint8* dst_argb, int width, const uint8* luma, 2927 const uint32 lumacoeff) = ARGBLumaColorTableRow_C; 2298 2928 if (!src_argb || !dst_argb || !luma || width <= 0 || height == 0) { 2299 2929 return -1; … … 2302 2932 if (height < 0) { 2303 2933 height = -height; 2304 src_argb = src_argb+ (height - 1) * src_stride_argb;2934 src_argb = src_argb + (height - 1) * src_stride_argb; 2305 2935 src_stride_argb = -src_stride_argb; 2306 2936 } 2307 2937 // Coalesce rows. 2308 if (src_stride_argb == width * 4 && 2309 dst_stride_argb == width * 4) { 2938 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 2310 2939 width *= height; 2311 2940 height = 1; … … 2328 2957 // Copy Alpha from one ARGB image to another. 2329 2958 LIBYUV_API 2330 int ARGBCopyAlpha(const uint8* src_argb, int src_stride_argb, 2331 uint8* dst_argb, int dst_stride_argb, 2332 int width, int height) { 2959 int ARGBCopyAlpha(const uint8* src_argb, 2960 int src_stride_argb, 2961 uint8* dst_argb, 2962 int dst_stride_argb, 2963 int width, 2964 int height) { 2333 2965 int y; 2334 2966 void (*ARGBCopyAlphaRow)(const uint8* src_argb, uint8* dst_argb, int width) = … … 2344 2976 } 2345 2977 // Coalesce rows. 2346 if (src_stride_argb == width * 4 && 2347 dst_stride_argb == width * 4) { 2978 if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { 2348 2979 width *= height; 2349 2980 height = 1; … … 2377 3008 // Extract just the alpha channel from ARGB. 2378 3009 LIBYUV_API 2379 int ARGBExtractAlpha(const uint8* src_argb, int src_stride, 2380 uint8* dst_a, int dst_stride, 2381 int width, int height) { 3010 int ARGBExtractAlpha(const uint8* src_argb, 3011 int src_stride, 3012 uint8* dst_a, 3013 int dst_stride, 3014 int width, 3015 int height) { 2382 3016 if (!src_argb || !dst_a || width <= 0 || height == 0) { 2383 3017 return -1; … … 2395 3029 src_stride = dst_stride = 0; 2396 3030 } 2397 void (*ARGBExtractAlphaRow)(const uint8 *src_argb, uint8 *dst_a, int width) =3031 void (*ARGBExtractAlphaRow)(const uint8* src_argb, uint8* dst_a, int width) = 2398 3032 ARGBExtractAlphaRow_C; 2399 3033 #if defined(HAS_ARGBEXTRACTALPHAROW_SSE2) … … 2403 3037 } 2404 3038 #endif 3039 #if defined(HAS_ARGBEXTRACTALPHAROW_AVX2) 3040 if (TestCpuFlag(kCpuHasAVX2)) { 3041 ARGBExtractAlphaRow = IS_ALIGNED(width, 32) ? ARGBExtractAlphaRow_AVX2 3042 : ARGBExtractAlphaRow_Any_AVX2; 3043 } 3044 #endif 2405 3045 #if defined(HAS_ARGBEXTRACTALPHAROW_NEON) 2406 3046 if (TestCpuFlag(kCpuHasNEON)) { … … 2420 3060 // Copy a planar Y channel to the alpha channel of a destination ARGB image. 2421 3061 LIBYUV_API 2422 int ARGBCopyYToAlpha(const uint8* src_y, int src_stride_y, 2423 uint8* dst_argb, int dst_stride_argb, 2424 int width, int height) { 3062 int ARGBCopyYToAlpha(const uint8* src_y, 3063 int src_stride_y, 3064 uint8* dst_argb, 3065 int dst_stride_argb, 3066 int width, 3067 int height) { 2425 3068 int y; 2426 3069 void (*ARGBCopyYToAlphaRow)(const uint8* src_y, uint8* dst_argb, int width) = … … 2436 3079 } 2437 3080 // Coalesce rows. 2438 if (src_stride_y == width && 2439 dst_stride_argb == width * 4) { 3081 if (src_stride_y == width && dst_stride_argb == width * 4) { 2440 3082 width *= height; 2441 3083 height = 1; … … 2471 3113 2472 3114 LIBYUV_API 2473 int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2, 2474 uint8* dst_y, int dst_stride_y, 2475 uint8* dst_uv, int dst_stride_uv, 2476 int width, int height) { 3115 int YUY2ToNV12(const uint8* src_yuy2, 3116 int src_stride_yuy2, 3117 uint8* dst_y, 3118 int dst_stride_y, 3119 uint8* dst_uv, 3120 int dst_stride_uv, 3121 int width, 3122 int height) { 2477 3123 int y; 2478 3124 int halfwidth = (width + 1) >> 1; 2479 3125 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, 2480 3126 int width) = SplitUVRow_C; 2481 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr,3127 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr, 2482 3128 ptrdiff_t src_stride, int dst_width, 2483 3129 int source_y_fraction) = InterpolateRow_C; 2484 if (!src_yuy2 || 2485 !dst_y || !dst_uv || 2486 width <= 0 || height == 0) { 3130 if (!src_yuy2 || !dst_y || !dst_uv || width <= 0 || height == 0) { 2487 3131 return -1; 2488 3132 } … … 2538 3182 if (IS_ALIGNED(width, 16)) { 2539 3183 InterpolateRow = InterpolateRow_NEON; 3184 } 3185 } 3186 #endif 3187 #if defined(HAS_INTERPOLATEROW_MSA) 3188 if (TestCpuFlag(kCpuHasMSA)) { 3189 InterpolateRow = InterpolateRow_Any_MSA; 3190 if (IS_ALIGNED(width, 32)) { 3191 InterpolateRow = InterpolateRow_MSA; 2540 3192 } 2541 3193 } … … 2569 3221 2570 3222 LIBYUV_API 2571 int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy, 2572 uint8* dst_y, int dst_stride_y, 2573 uint8* dst_uv, int dst_stride_uv, 2574 int width, int height) { 3223 int UYVYToNV12(const uint8* src_uyvy, 3224 int src_stride_uyvy, 3225 uint8* dst_y, 3226 int dst_stride_y, 3227 uint8* dst_uv, 3228 int dst_stride_uv, 3229 int width, 3230 int height) { 2575 3231 int y; 2576 3232 int halfwidth = (width + 1) >> 1; 2577 3233 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, 2578 3234 int width) = SplitUVRow_C; 2579 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr,3235 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr, 2580 3236 ptrdiff_t src_stride, int dst_width, 2581 3237 int source_y_fraction) = InterpolateRow_C; 2582 if (!src_uyvy || 2583 !dst_y || !dst_uv || 2584 width <= 0 || height == 0) { 3238 if (!src_uyvy || !dst_y || !dst_uv || width <= 0 || height == 0) { 2585 3239 return -1; 2586 3240 } … … 2636 3290 if (IS_ALIGNED(width, 16)) { 2637 3291 InterpolateRow = InterpolateRow_NEON; 3292 } 3293 } 3294 #endif 3295 #if defined(HAS_INTERPOLATEROW_MSA) 3296 if (TestCpuFlag(kCpuHasMSA)) { 3297 InterpolateRow = InterpolateRow_Any_MSA; 3298 if (IS_ALIGNED(width, 32)) { 3299 InterpolateRow = InterpolateRow_MSA; 2638 3300 } 2639 3301 }
Note: See TracChangeset
for help on using the changeset viewer.