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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 uint8* dst_y, int dst_stride_y, | 426 uint8* dst_y, int dst_stride_y, |
427 uint8* dst_u, int dst_stride_u, | 427 uint8* dst_u, int dst_stride_u, |
428 uint8* dst_v, int dst_stride_v, | 428 uint8* dst_v, int dst_stride_v, |
429 int width, int height) { | 429 int width, int height) { |
430 int y; | 430 int y; |
431 void (*YUY2ToUV422Row)(const uint8* src_yuy2, | 431 void (*YUY2ToUV422Row)(const uint8* src_yuy2, |
432 uint8* dst_u, uint8* dst_v, int width) = | 432 uint8* dst_u, uint8* dst_v, int width) = |
433 YUY2ToUV422Row_C; | 433 YUY2ToUV422Row_C; |
434 void (*YUY2ToYRow)(const uint8* src_yuy2, uint8* dst_y, int width) = | 434 void (*YUY2ToYRow)(const uint8* src_yuy2, uint8* dst_y, int width) = |
435 YUY2ToYRow_C; | 435 YUY2ToYRow_C; |
| 436 if (!src_yuy2 || !dst_y || !dst_u || !dst_v || |
| 437 width <= 0 || height == 0) { |
| 438 return -1; |
| 439 } |
436 // Negative height means invert the image. | 440 // Negative height means invert the image. |
437 if (height < 0) { | 441 if (height < 0) { |
438 height = -height; | 442 height = -height; |
439 src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; | 443 src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; |
440 src_stride_yuy2 = -src_stride_yuy2; | 444 src_stride_yuy2 = -src_stride_yuy2; |
441 } | 445 } |
442 // Coalesce rows. | 446 // Coalesce rows. |
443 if (src_stride_yuy2 == width * 2 && | 447 if (src_stride_yuy2 == width * 2 && |
444 dst_stride_y == width && | 448 dst_stride_y == width && |
445 dst_stride_u * 2 == width && | 449 dst_stride_u * 2 == width && |
(...skipping 18 matching lines...) Expand all Loading... |
464 YUY2ToYRow = YUY2ToYRow_Any_AVX2; | 468 YUY2ToYRow = YUY2ToYRow_Any_AVX2; |
465 if (IS_ALIGNED(width, 32)) { | 469 if (IS_ALIGNED(width, 32)) { |
466 YUY2ToUV422Row = YUY2ToUV422Row_AVX2; | 470 YUY2ToUV422Row = YUY2ToUV422Row_AVX2; |
467 YUY2ToYRow = YUY2ToYRow_AVX2; | 471 YUY2ToYRow = YUY2ToYRow_AVX2; |
468 } | 472 } |
469 } | 473 } |
470 #endif | 474 #endif |
471 #if defined(HAS_YUY2TOYROW_NEON) | 475 #if defined(HAS_YUY2TOYROW_NEON) |
472 if (TestCpuFlag(kCpuHasNEON)) { | 476 if (TestCpuFlag(kCpuHasNEON)) { |
473 YUY2ToYRow = YUY2ToYRow_Any_NEON; | 477 YUY2ToYRow = YUY2ToYRow_Any_NEON; |
474 if (width >= 16) { | 478 YUY2ToUV422Row = YUY2ToUV422Row_Any_NEON; |
475 YUY2ToUV422Row = YUY2ToUV422Row_Any_NEON; | |
476 } | |
477 if (IS_ALIGNED(width, 16)) { | 479 if (IS_ALIGNED(width, 16)) { |
478 YUY2ToYRow = YUY2ToYRow_NEON; | 480 YUY2ToYRow = YUY2ToYRow_NEON; |
479 YUY2ToUV422Row = YUY2ToUV422Row_NEON; | 481 YUY2ToUV422Row = YUY2ToUV422Row_NEON; |
480 } | 482 } |
481 } | 483 } |
482 #endif | 484 #endif |
483 | 485 |
484 for (y = 0; y < height; ++y) { | 486 for (y = 0; y < height; ++y) { |
485 YUY2ToUV422Row(src_yuy2, dst_u, dst_v, width); | 487 YUY2ToUV422Row(src_yuy2, dst_u, dst_v, width); |
486 YUY2ToYRow(src_yuy2, dst_y, width); | 488 YUY2ToYRow(src_yuy2, dst_y, width); |
(...skipping 11 matching lines...) Expand all Loading... |
498 uint8* dst_y, int dst_stride_y, | 500 uint8* dst_y, int dst_stride_y, |
499 uint8* dst_u, int dst_stride_u, | 501 uint8* dst_u, int dst_stride_u, |
500 uint8* dst_v, int dst_stride_v, | 502 uint8* dst_v, int dst_stride_v, |
501 int width, int height) { | 503 int width, int height) { |
502 int y; | 504 int y; |
503 void (*UYVYToUV422Row)(const uint8* src_uyvy, | 505 void (*UYVYToUV422Row)(const uint8* src_uyvy, |
504 uint8* dst_u, uint8* dst_v, int width) = | 506 uint8* dst_u, uint8* dst_v, int width) = |
505 UYVYToUV422Row_C; | 507 UYVYToUV422Row_C; |
506 void (*UYVYToYRow)(const uint8* src_uyvy, | 508 void (*UYVYToYRow)(const uint8* src_uyvy, |
507 uint8* dst_y, int width) = UYVYToYRow_C; | 509 uint8* dst_y, int width) = UYVYToYRow_C; |
| 510 if (!src_uyvy || !dst_y || !dst_u || !dst_v || |
| 511 width <= 0 || height == 0) { |
| 512 return -1; |
| 513 } |
508 // Negative height means invert the image. | 514 // Negative height means invert the image. |
509 if (height < 0) { | 515 if (height < 0) { |
510 height = -height; | 516 height = -height; |
511 src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; | 517 src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; |
512 src_stride_uyvy = -src_stride_uyvy; | 518 src_stride_uyvy = -src_stride_uyvy; |
513 } | 519 } |
514 // Coalesce rows. | 520 // Coalesce rows. |
515 if (src_stride_uyvy == width * 2 && | 521 if (src_stride_uyvy == width * 2 && |
516 dst_stride_y == width && | 522 dst_stride_y == width && |
517 dst_stride_u * 2 == width && | 523 dst_stride_u * 2 == width && |
(...skipping 18 matching lines...) Expand all Loading... |
536 UYVYToYRow = UYVYToYRow_Any_AVX2; | 542 UYVYToYRow = UYVYToYRow_Any_AVX2; |
537 if (IS_ALIGNED(width, 32)) { | 543 if (IS_ALIGNED(width, 32)) { |
538 UYVYToUV422Row = UYVYToUV422Row_AVX2; | 544 UYVYToUV422Row = UYVYToUV422Row_AVX2; |
539 UYVYToYRow = UYVYToYRow_AVX2; | 545 UYVYToYRow = UYVYToYRow_AVX2; |
540 } | 546 } |
541 } | 547 } |
542 #endif | 548 #endif |
543 #if defined(HAS_UYVYTOYROW_NEON) | 549 #if defined(HAS_UYVYTOYROW_NEON) |
544 if (TestCpuFlag(kCpuHasNEON)) { | 550 if (TestCpuFlag(kCpuHasNEON)) { |
545 UYVYToYRow = UYVYToYRow_Any_NEON; | 551 UYVYToYRow = UYVYToYRow_Any_NEON; |
546 if (width >= 16) { | 552 UYVYToUV422Row = UYVYToUV422Row_Any_NEON; |
547 UYVYToUV422Row = UYVYToUV422Row_Any_NEON; | |
548 } | |
549 if (IS_ALIGNED(width, 16)) { | 553 if (IS_ALIGNED(width, 16)) { |
550 UYVYToYRow = UYVYToYRow_NEON; | 554 UYVYToYRow = UYVYToYRow_NEON; |
551 UYVYToUV422Row = UYVYToUV422Row_NEON; | 555 UYVYToUV422Row = UYVYToUV422Row_NEON; |
552 } | 556 } |
553 } | 557 } |
554 #endif | 558 #endif |
555 | 559 |
556 for (y = 0; y < height; ++y) { | 560 for (y = 0; y < height; ++y) { |
557 UYVYToUV422Row(src_uyvy, dst_u, dst_v, width); | 561 UYVYToUV422Row(src_uyvy, dst_u, dst_v, width); |
558 UYVYToYRow(src_uyvy, dst_y, width); | 562 UYVYToYRow(src_uyvy, dst_y, width); |
(...skipping 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2871 } | 2875 } |
2872 free_aligned_buffer_64(rows); | 2876 free_aligned_buffer_64(rows); |
2873 } | 2877 } |
2874 return 0; | 2878 return 0; |
2875 } | 2879 } |
2876 | 2880 |
2877 #ifdef __cplusplus | 2881 #ifdef __cplusplus |
2878 } // extern "C" | 2882 } // extern "C" |
2879 } // namespace libyuv | 2883 } // namespace libyuv |
2880 #endif | 2884 #endif |
OLD | NEW |