| 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 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2417 #endif | 2417 #endif |
| 2418 | 2418 |
| 2419 for (y = 0; y < height; ++y) { | 2419 for (y = 0; y < height; ++y) { |
| 2420 ARGBCopyYToAlphaRow(src_y, dst_argb, width); | 2420 ARGBCopyYToAlphaRow(src_y, dst_argb, width); |
| 2421 src_y += src_stride_y; | 2421 src_y += src_stride_y; |
| 2422 dst_argb += dst_stride_argb; | 2422 dst_argb += dst_stride_argb; |
| 2423 } | 2423 } |
| 2424 return 0; | 2424 return 0; |
| 2425 } | 2425 } |
| 2426 | 2426 |
| 2427 // TODO(fbarchard): Consider if width is even Y channel can be split |
| 2428 // directly. A SplitUVRow_Odd function could copy the remaining chroma. |
| 2429 |
| 2427 LIBYUV_API | 2430 LIBYUV_API |
| 2428 int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2, | 2431 int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2, |
| 2429 uint8* dst_y, int dst_stride_y, | 2432 uint8* dst_y, int dst_stride_y, |
| 2430 uint8* dst_uv, int dst_stride_uv, | 2433 uint8* dst_uv, int dst_stride_uv, |
| 2431 int width, int height) { | 2434 int width, int height) { |
| 2432 int y; | 2435 int y; |
| 2433 int halfwidth = (width + 1) >> 1; | 2436 int halfwidth = (width + 1) >> 1; |
| 2434 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, | 2437 void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, |
| 2435 int width) = SplitUVRow_C; | 2438 int width) = SplitUVRow_C; |
| 2436 void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, | 2439 void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 if (TestCpuFlag(kCpuHasNEON)) { | 2494 if (TestCpuFlag(kCpuHasNEON)) { |
| 2492 InterpolateRow = InterpolateRow_Any_NEON; | 2495 InterpolateRow = InterpolateRow_Any_NEON; |
| 2493 if (IS_ALIGNED(width, 16)) { | 2496 if (IS_ALIGNED(width, 16)) { |
| 2494 InterpolateRow = InterpolateRow_NEON; | 2497 InterpolateRow = InterpolateRow_NEON; |
| 2495 } | 2498 } |
| 2496 } | 2499 } |
| 2497 #endif | 2500 #endif |
| 2498 | 2501 |
| 2499 { | 2502 { |
| 2500 int awidth = halfwidth * 2; | 2503 int awidth = halfwidth * 2; |
| 2501 // 2 rows of uv | 2504 // row of y and 2 rows of uv |
| 2502 align_buffer_64(rows, awidth * 2); | 2505 align_buffer_64(rows, awidth * 3); |
| 2503 | 2506 |
| 2504 for (y = 0; y < height - 1; y += 2) { | 2507 for (y = 0; y < height - 1; y += 2) { |
| 2505 // Split Y from UV. | 2508 // Split Y from UV. |
| 2506 SplitUVRow(src_yuy2, dst_y, rows, awidth); | 2509 SplitUVRow(src_yuy2, rows, rows + awidth, awidth); |
| 2507 SplitUVRow(src_yuy2 + src_stride_yuy2, dst_y + dst_stride_y, | 2510 memcpy(dst_y, rows, width); |
| 2508 rows + awidth, awidth); | 2511 SplitUVRow(src_yuy2 + src_stride_yuy2, rows, rows + awidth * 2, awidth); |
| 2509 InterpolateRow(dst_uv, rows, awidth, awidth, 128); | 2512 memcpy(dst_y + dst_stride_y, rows, width); |
| 2513 InterpolateRow(dst_uv, rows + awidth, awidth, awidth, 128); |
| 2510 src_yuy2 += src_stride_yuy2 * 2; | 2514 src_yuy2 += src_stride_yuy2 * 2; |
| 2511 dst_y += dst_stride_y * 2; | 2515 dst_y += dst_stride_y * 2; |
| 2512 dst_uv += dst_stride_uv; | 2516 dst_uv += dst_stride_uv; |
| 2513 } | 2517 } |
| 2514 if (height & 1) { | 2518 if (height & 1) { |
| 2515 // Split Y from UV. | 2519 // Split Y from UV. |
| 2516 SplitUVRow(src_yuy2, dst_y, dst_uv, awidth); | 2520 SplitUVRow(src_yuy2, rows, dst_uv, awidth); |
| 2521 memcpy(dst_y, rows, width); |
| 2517 } | 2522 } |
| 2518 free_aligned_buffer_64(rows); | 2523 free_aligned_buffer_64(rows); |
| 2519 } | 2524 } |
| 2520 return 0; | 2525 return 0; |
| 2521 } | 2526 } |
| 2522 | 2527 |
| 2523 LIBYUV_API | 2528 LIBYUV_API |
| 2524 int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy, | 2529 int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy, |
| 2525 uint8* dst_y, int dst_stride_y, | 2530 uint8* dst_y, int dst_stride_y, |
| 2526 uint8* dst_uv, int dst_stride_uv, | 2531 uint8* dst_uv, int dst_stride_uv, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2587 if (TestCpuFlag(kCpuHasNEON)) { | 2592 if (TestCpuFlag(kCpuHasNEON)) { |
| 2588 InterpolateRow = InterpolateRow_Any_NEON; | 2593 InterpolateRow = InterpolateRow_Any_NEON; |
| 2589 if (IS_ALIGNED(width, 16)) { | 2594 if (IS_ALIGNED(width, 16)) { |
| 2590 InterpolateRow = InterpolateRow_NEON; | 2595 InterpolateRow = InterpolateRow_NEON; |
| 2591 } | 2596 } |
| 2592 } | 2597 } |
| 2593 #endif | 2598 #endif |
| 2594 | 2599 |
| 2595 { | 2600 { |
| 2596 int awidth = halfwidth * 2; | 2601 int awidth = halfwidth * 2; |
| 2597 // 2 rows of uv | 2602 // row of y and 2 rows of uv |
| 2598 align_buffer_64(rows, awidth * 2); | 2603 align_buffer_64(rows, awidth * 3); |
| 2599 | 2604 |
| 2600 for (y = 0; y < height - 1; y += 2) { | 2605 for (y = 0; y < height - 1; y += 2) { |
| 2601 // Split Y from UV. | 2606 // Split Y from UV. |
| 2602 SplitUVRow(src_uyvy, rows, dst_y, awidth); | 2607 SplitUVRow(src_uyvy, rows + awidth, rows, awidth); |
| 2603 SplitUVRow(src_uyvy + src_stride_uyvy, rows + awidth, | 2608 memcpy(dst_y, rows, width); |
| 2604 dst_y + dst_stride_y, awidth); | 2609 SplitUVRow(src_uyvy + src_stride_uyvy, rows + awidth * 2, rows, awidth); |
| 2605 InterpolateRow(dst_uv, rows, awidth, awidth, 128); | 2610 memcpy(dst_y + dst_stride_y, rows, width); |
| 2611 InterpolateRow(dst_uv, rows + awidth, awidth, awidth, 128); |
| 2606 src_uyvy += src_stride_uyvy * 2; | 2612 src_uyvy += src_stride_uyvy * 2; |
| 2607 dst_y += dst_stride_y * 2; | 2613 dst_y += dst_stride_y * 2; |
| 2608 dst_uv += dst_stride_uv; | 2614 dst_uv += dst_stride_uv; |
| 2609 } | 2615 } |
| 2610 if (height & 1) { | 2616 if (height & 1) { |
| 2611 // Split Y from UV. | 2617 // Split Y from UV. |
| 2612 SplitUVRow(src_uyvy, dst_uv, dst_y, awidth); | 2618 SplitUVRow(src_uyvy, dst_uv, rows, awidth); |
| 2619 memcpy(dst_y, rows, width); |
| 2613 } | 2620 } |
| 2614 free_aligned_buffer_64(rows); | 2621 free_aligned_buffer_64(rows); |
| 2615 } | 2622 } |
| 2616 return 0; | 2623 return 0; |
| 2617 } | 2624 } |
| 2618 | 2625 |
| 2619 #ifdef __cplusplus | 2626 #ifdef __cplusplus |
| 2620 } // extern "C" | 2627 } // extern "C" |
| 2621 } // namespace libyuv | 2628 } // namespace libyuv |
| 2622 #endif | 2629 #endif |
| OLD | NEW |