| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 uint8* dst_vu, int dst_stride_vu, | 443 uint8* dst_vu, int dst_stride_vu, |
| 444 int width, int height) { | 444 int width, int height) { |
| 445 return I420ToNV12(src_y, src_stride_y, | 445 return I420ToNV12(src_y, src_stride_y, |
| 446 src_v, src_stride_v, | 446 src_v, src_stride_v, |
| 447 src_u, src_stride_u, | 447 src_u, src_stride_u, |
| 448 dst_y, src_stride_y, | 448 dst_y, src_stride_y, |
| 449 dst_vu, dst_stride_vu, | 449 dst_vu, dst_stride_vu, |
| 450 width, height); | 450 width, height); |
| 451 } | 451 } |
| 452 | 452 |
| 453 // Convert I420 to ARGB. | |
| 454 LIBYUV_API | |
| 455 int I420ToARGB(const uint8* src_y, int src_stride_y, | |
| 456 const uint8* src_u, int src_stride_u, | |
| 457 const uint8* src_v, int src_stride_v, | |
| 458 uint8* dst_argb, int dst_stride_argb, | |
| 459 int width, int height) { | |
| 460 int y; | |
| 461 void (*I422ToARGBRow)(const uint8* y_buf, | |
| 462 const uint8* u_buf, | |
| 463 const uint8* v_buf, | |
| 464 uint8* rgb_buf, | |
| 465 const struct YuvConstants* yuvconstants, | |
| 466 int width) = I422ToARGBRow_C; | |
| 467 if (!src_y || !src_u || !src_v || !dst_argb || | |
| 468 width <= 0 || height == 0) { | |
| 469 return -1; | |
| 470 } | |
| 471 // Negative height means invert the image. | |
| 472 if (height < 0) { | |
| 473 height = -height; | |
| 474 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | |
| 475 dst_stride_argb = -dst_stride_argb; | |
| 476 } | |
| 477 #if defined(HAS_I422TOARGBROW_SSSE3) | |
| 478 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 479 I422ToARGBRow = I422ToARGBRow_Any_SSSE3; | |
| 480 if (IS_ALIGNED(width, 8)) { | |
| 481 I422ToARGBRow = I422ToARGBRow_SSSE3; | |
| 482 } | |
| 483 } | |
| 484 #endif | |
| 485 #if defined(HAS_I422TOARGBROW_AVX2) | |
| 486 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 487 I422ToARGBRow = I422ToARGBRow_Any_AVX2; | |
| 488 if (IS_ALIGNED(width, 16)) { | |
| 489 I422ToARGBRow = I422ToARGBRow_AVX2; | |
| 490 } | |
| 491 } | |
| 492 #endif | |
| 493 #if defined(HAS_I422TOARGBROW_NEON) | |
| 494 if (TestCpuFlag(kCpuHasNEON)) { | |
| 495 I422ToARGBRow = I422ToARGBRow_Any_NEON; | |
| 496 if (IS_ALIGNED(width, 8)) { | |
| 497 I422ToARGBRow = I422ToARGBRow_NEON; | |
| 498 } | |
| 499 } | |
| 500 #endif | |
| 501 #if defined(HAS_I422TOARGBROW_MIPS_DSPR2) | |
| 502 if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) && | |
| 503 IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) && | |
| 504 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && | |
| 505 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && | |
| 506 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { | |
| 507 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; | |
| 508 } | |
| 509 #endif | |
| 510 | |
| 511 for (y = 0; y < height; ++y) { | |
| 512 I422ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvIConstants, width); | |
| 513 dst_argb += dst_stride_argb; | |
| 514 src_y += src_stride_y; | |
| 515 if (y & 1) { | |
| 516 src_u += src_stride_u; | |
| 517 src_v += src_stride_v; | |
| 518 } | |
| 519 } | |
| 520 return 0; | |
| 521 } | |
| 522 | |
| 523 // Convert I420 to BGRA. | 453 // Convert I420 to BGRA. |
| 524 LIBYUV_API | 454 LIBYUV_API |
| 525 int I420ToBGRA(const uint8* src_y, int src_stride_y, | 455 int I420ToBGRA(const uint8* src_y, int src_stride_y, |
| 526 const uint8* src_u, int src_stride_u, | 456 const uint8* src_u, int src_stride_u, |
| 527 const uint8* src_v, int src_stride_v, | 457 const uint8* src_v, int src_stride_v, |
| 528 uint8* dst_bgra, int dst_stride_bgra, | 458 uint8* dst_bgra, int dst_stride_bgra, |
| 529 int width, int height) { | 459 int width, int height) { |
| 530 int y; | 460 int y; |
| 531 void (*I422ToBGRARow)(const uint8* y_buf, | 461 void (*I422ToBGRARow)(const uint8* y_buf, |
| 532 const uint8* u_buf, | 462 const uint8* u_buf, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 dst_bgra += dst_stride_bgra; | 513 dst_bgra += dst_stride_bgra; |
| 584 src_y += src_stride_y; | 514 src_y += src_stride_y; |
| 585 if (y & 1) { | 515 if (y & 1) { |
| 586 src_u += src_stride_u; | 516 src_u += src_stride_u; |
| 587 src_v += src_stride_v; | 517 src_v += src_stride_v; |
| 588 } | 518 } |
| 589 } | 519 } |
| 590 return 0; | 520 return 0; |
| 591 } | 521 } |
| 592 | 522 |
| 593 // Convert I420 to ABGR. | |
| 594 LIBYUV_API | |
| 595 int I420ToABGR(const uint8* src_y, int src_stride_y, | |
| 596 const uint8* src_u, int src_stride_u, | |
| 597 const uint8* src_v, int src_stride_v, | |
| 598 uint8* dst_abgr, int dst_stride_abgr, | |
| 599 int width, int height) { | |
| 600 int y; | |
| 601 void (*I422ToABGRRow)(const uint8* y_buf, | |
| 602 const uint8* u_buf, | |
| 603 const uint8* v_buf, | |
| 604 uint8* rgb_buf, | |
| 605 const struct YuvConstants* yuvconstants, | |
| 606 int width) = I422ToABGRRow_C; | |
| 607 if (!src_y || !src_u || !src_v || !dst_abgr || | |
| 608 width <= 0 || height == 0) { | |
| 609 return -1; | |
| 610 } | |
| 611 // Negative height means invert the image. | |
| 612 if (height < 0) { | |
| 613 height = -height; | |
| 614 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | |
| 615 dst_stride_abgr = -dst_stride_abgr; | |
| 616 } | |
| 617 #if defined(HAS_I422TOABGRROW_SSSE3) | |
| 618 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 619 I422ToABGRRow = I422ToABGRRow_Any_SSSE3; | |
| 620 if (IS_ALIGNED(width, 8)) { | |
| 621 I422ToABGRRow = I422ToABGRRow_SSSE3; | |
| 622 } | |
| 623 } | |
| 624 #endif | |
| 625 #if defined(HAS_I422TOABGRROW_AVX2) | |
| 626 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 627 I422ToABGRRow = I422ToABGRRow_Any_AVX2; | |
| 628 if (IS_ALIGNED(width, 16)) { | |
| 629 I422ToABGRRow = I422ToABGRRow_AVX2; | |
| 630 } | |
| 631 } | |
| 632 #endif | |
| 633 #if defined(HAS_I422TOABGRROW_NEON) | |
| 634 if (TestCpuFlag(kCpuHasNEON)) { | |
| 635 I422ToABGRRow = I422ToABGRRow_Any_NEON; | |
| 636 if (IS_ALIGNED(width, 8)) { | |
| 637 I422ToABGRRow = I422ToABGRRow_NEON; | |
| 638 } | |
| 639 } | |
| 640 #endif | |
| 641 | |
| 642 for (y = 0; y < height; ++y) { | |
| 643 I422ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvIConstants, width); | |
| 644 dst_abgr += dst_stride_abgr; | |
| 645 src_y += src_stride_y; | |
| 646 if (y & 1) { | |
| 647 src_u += src_stride_u; | |
| 648 src_v += src_stride_v; | |
| 649 } | |
| 650 } | |
| 651 return 0; | |
| 652 } | |
| 653 | |
| 654 // Convert I420 to RGBA. | 523 // Convert I420 to RGBA. |
| 655 LIBYUV_API | 524 LIBYUV_API |
| 656 int I420ToRGBA(const uint8* src_y, int src_stride_y, | 525 int I420ToRGBA(const uint8* src_y, int src_stride_y, |
| 657 const uint8* src_u, int src_stride_u, | 526 const uint8* src_u, int src_stride_u, |
| 658 const uint8* src_v, int src_stride_v, | 527 const uint8* src_v, int src_stride_v, |
| 659 uint8* dst_rgba, int dst_stride_rgba, | 528 uint8* dst_rgba, int dst_stride_rgba, |
| 660 int width, int height) { | 529 int width, int height) { |
| 661 int y; | 530 int y; |
| 662 void (*I422ToRGBARow)(const uint8* y_buf, | 531 void (*I422ToRGBARow)(const uint8* y_buf, |
| 663 const uint8* u_buf, | 532 const uint8* u_buf, |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 default: | 1220 default: |
| 1352 return -1; // unknown fourcc - return failure code. | 1221 return -1; // unknown fourcc - return failure code. |
| 1353 } | 1222 } |
| 1354 return r; | 1223 return r; |
| 1355 } | 1224 } |
| 1356 | 1225 |
| 1357 #ifdef __cplusplus | 1226 #ifdef __cplusplus |
| 1358 } // extern "C" | 1227 } // extern "C" |
| 1359 } // namespace libyuv | 1228 } // namespace libyuv |
| 1360 #endif | 1229 #endif |
| OLD | NEW |