| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 uint8* dst_argb, int dst_stride_argb, | 480 uint8* dst_argb, int dst_stride_argb, |
| 481 int width, int height) { | 481 int width, int height) { |
| 482 return I444ToARGBMatrix(src_y, src_stride_y, | 482 return I444ToARGBMatrix(src_y, src_stride_y, |
| 483 src_u, src_stride_u, | 483 src_u, src_stride_u, |
| 484 src_v, src_stride_v, | 484 src_v, src_stride_v, |
| 485 dst_argb, dst_stride_argb, | 485 dst_argb, dst_stride_argb, |
| 486 &kYuvJPEGConstants, | 486 &kYuvJPEGConstants, |
| 487 width, height); | 487 width, height); |
| 488 } | 488 } |
| 489 | 489 |
| 490 // Convert I411 to ARGB. | |
| 491 LIBYUV_API | |
| 492 int I411ToARGB(const uint8* src_y, int src_stride_y, | |
| 493 const uint8* src_u, int src_stride_u, | |
| 494 const uint8* src_v, int src_stride_v, | |
| 495 uint8* dst_argb, int dst_stride_argb, | |
| 496 int width, int height) { | |
| 497 int y; | |
| 498 void (*I411ToARGBRow)(const uint8* y_buf, | |
| 499 const uint8* u_buf, | |
| 500 const uint8* v_buf, | |
| 501 uint8* rgb_buf, | |
| 502 const struct YuvConstants* yuvconstants, | |
| 503 int width) = I411ToARGBRow_C; | |
| 504 if (!src_y || !src_u || !src_v || | |
| 505 !dst_argb || | |
| 506 width <= 0 || height == 0) { | |
| 507 return -1; | |
| 508 } | |
| 509 // Negative height means invert the image. | |
| 510 if (height < 0) { | |
| 511 height = -height; | |
| 512 dst_argb = dst_argb + (height - 1) * dst_stride_argb; | |
| 513 dst_stride_argb = -dst_stride_argb; | |
| 514 } | |
| 515 // Coalesce rows. | |
| 516 if (src_stride_y == width && | |
| 517 src_stride_u * 4 == width && | |
| 518 src_stride_v * 4 == width && | |
| 519 dst_stride_argb == width * 4) { | |
| 520 width *= height; | |
| 521 height = 1; | |
| 522 src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; | |
| 523 } | |
| 524 #if defined(HAS_I411TOARGBROW_SSSE3) | |
| 525 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 526 I411ToARGBRow = I411ToARGBRow_Any_SSSE3; | |
| 527 if (IS_ALIGNED(width, 8)) { | |
| 528 I411ToARGBRow = I411ToARGBRow_SSSE3; | |
| 529 } | |
| 530 } | |
| 531 #endif | |
| 532 #if defined(HAS_I411TOARGBROW_AVX2) | |
| 533 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 534 I411ToARGBRow = I411ToARGBRow_Any_AVX2; | |
| 535 if (IS_ALIGNED(width, 16)) { | |
| 536 I411ToARGBRow = I411ToARGBRow_AVX2; | |
| 537 } | |
| 538 } | |
| 539 #endif | |
| 540 #if defined(HAS_I411TOARGBROW_NEON) | |
| 541 if (TestCpuFlag(kCpuHasNEON)) { | |
| 542 I411ToARGBRow = I411ToARGBRow_Any_NEON; | |
| 543 if (IS_ALIGNED(width, 8)) { | |
| 544 I411ToARGBRow = I411ToARGBRow_NEON; | |
| 545 } | |
| 546 } | |
| 547 #endif | |
| 548 | |
| 549 for (y = 0; y < height; ++y) { | |
| 550 I411ToARGBRow(src_y, src_u, src_v, dst_argb, &kYuvI601Constants, width); | |
| 551 dst_argb += dst_stride_argb; | |
| 552 src_y += src_stride_y; | |
| 553 src_u += src_stride_u; | |
| 554 src_v += src_stride_v; | |
| 555 } | |
| 556 return 0; | |
| 557 } | |
| 558 | |
| 559 // Convert I420 with Alpha to preattenuated ARGB. | 490 // Convert I420 with Alpha to preattenuated ARGB. |
| 560 static int I420AlphaToARGBMatrix(const uint8* src_y, int src_stride_y, | 491 static int I420AlphaToARGBMatrix(const uint8* src_y, int src_stride_y, |
| 561 const uint8* src_u, int src_stride_u, | 492 const uint8* src_u, int src_stride_u, |
| 562 const uint8* src_v, int src_stride_v, | 493 const uint8* src_v, int src_stride_v, |
| 563 const uint8* src_a, int src_stride_a, | 494 const uint8* src_a, int src_stride_a, |
| 564 uint8* dst_argb, int dst_stride_argb, | 495 uint8* dst_argb, int dst_stride_argb, |
| 565 const struct YuvConstants* yuvconstants, | 496 const struct YuvConstants* yuvconstants, |
| 566 int width, int height, int attenuate) { | 497 int width, int height, int attenuate) { |
| 567 int y; | 498 int y; |
| 568 void (*I422AlphaToARGBRow)(const uint8* y_buf, | 499 void (*I422AlphaToARGBRow)(const uint8* y_buf, |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 src_uyvy += src_stride_uyvy; | 1378 src_uyvy += src_stride_uyvy; |
| 1448 dst_argb += dst_stride_argb; | 1379 dst_argb += dst_stride_argb; |
| 1449 } | 1380 } |
| 1450 return 0; | 1381 return 0; |
| 1451 } | 1382 } |
| 1452 | 1383 |
| 1453 #ifdef __cplusplus | 1384 #ifdef __cplusplus |
| 1454 } // extern "C" | 1385 } // extern "C" |
| 1455 } // namespace libyuv | 1386 } // namespace libyuv |
| 1456 #endif | 1387 #endif |
| OLD | NEW |