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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // Copy plane | 77 // Copy plane |
78 for (y = 0; y < height; ++y) { | 78 for (y = 0; y < height; ++y) { |
79 CopyRow(src_y, dst_y, width); | 79 CopyRow(src_y, dst_y, width); |
80 src_y += src_stride_y; | 80 src_y += src_stride_y; |
81 dst_y += dst_stride_y; | 81 dst_y += dst_stride_y; |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 // TODO(fbarchard): Consider support for negative height. | 85 // TODO(fbarchard): Consider support for negative height. |
| 86 // TODO(fbarchard): Consider stride measured in bytes. |
86 LIBYUV_API | 87 LIBYUV_API |
87 void CopyPlane_16(const uint16* src_y, int src_stride_y, | 88 void CopyPlane_16(const uint16* src_y, int src_stride_y, |
88 uint16* dst_y, int dst_stride_y, | 89 uint16* dst_y, int dst_stride_y, |
89 int width, int height) { | 90 int width, int height) { |
90 int y; | 91 int y; |
91 void (*CopyRow)(const uint16* src, uint16* dst, int width) = CopyRow_16_C; | 92 void (*CopyRow)(const uint16* src, uint16* dst, int width) = CopyRow_16_C; |
92 // Coalesce rows. | 93 // Coalesce rows. |
93 if (src_stride_y == width && | 94 if (src_stride_y == width && |
94 dst_stride_y == width) { | 95 dst_stride_y == width) { |
95 width *= height; | 96 width *= height; |
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2434 #endif | 2435 #endif |
2435 | 2436 |
2436 for (y = 0; y < height; ++y) { | 2437 for (y = 0; y < height; ++y) { |
2437 ARGBPolynomialRow(src_argb, dst_argb, poly, width); | 2438 ARGBPolynomialRow(src_argb, dst_argb, poly, width); |
2438 src_argb += src_stride_argb; | 2439 src_argb += src_stride_argb; |
2439 dst_argb += dst_stride_argb; | 2440 dst_argb += dst_stride_argb; |
2440 } | 2441 } |
2441 return 0; | 2442 return 0; |
2442 } | 2443 } |
2443 | 2444 |
| 2445 // Convert plane of 16 bit shorts to half floats. |
| 2446 // Source values are multiplied by scale before storing as half float. |
| 2447 LIBYUV_API |
| 2448 int HalfFloatPlane(const uint16* src_y, int src_stride_y, |
| 2449 uint16* dst_y, int dst_stride_y, |
| 2450 float scale, |
| 2451 int width, int height) { |
| 2452 int y; |
| 2453 void (*HalfFloatRow)(const uint16* src, uint16* dst, float scale, int width) = |
| 2454 HalfFloatRow_C; |
| 2455 if (!src_y || !dst_y || width <= 0 || height == 0) { |
| 2456 return -1; |
| 2457 } |
| 2458 src_stride_y >>= 1; |
| 2459 dst_stride_y >>= 1; |
| 2460 // Negative height means invert the image. |
| 2461 if (height < 0) { |
| 2462 height = -height; |
| 2463 src_y = src_y + (height - 1) * src_stride_y; |
| 2464 src_stride_y = -src_stride_y; |
| 2465 } |
| 2466 // Coalesce rows. |
| 2467 if (src_stride_y == width && |
| 2468 dst_stride_y == width) { |
| 2469 width *= height; |
| 2470 height = 1; |
| 2471 src_stride_y = dst_stride_y = 0; |
| 2472 } |
| 2473 #if defined(HAS_HALFFLOATROW_AVX2) |
| 2474 if (TestCpuFlag(kCpuHasAVX2)) { |
| 2475 HalfFloatRow = HalfFloatRow_Any_AVX2; |
| 2476 if (IS_ALIGNED(width, 16)) { |
| 2477 HalfFloatRow = HalfFloatRow_AVX2; |
| 2478 } |
| 2479 } |
| 2480 #endif |
| 2481 |
| 2482 for (y = 0; y < height; ++y) { |
| 2483 HalfFloatRow(src_y, dst_y, scale, width); |
| 2484 src_y += src_stride_y; |
| 2485 dst_y += dst_stride_y; |
| 2486 } |
| 2487 return 0; |
| 2488 } |
| 2489 |
2444 // Apply a lumacolortable to each ARGB pixel. | 2490 // Apply a lumacolortable to each ARGB pixel. |
2445 LIBYUV_API | 2491 LIBYUV_API |
2446 int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb, | 2492 int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb, |
2447 uint8* dst_argb, int dst_stride_argb, | 2493 uint8* dst_argb, int dst_stride_argb, |
2448 const uint8* luma, | 2494 const uint8* luma, |
2449 int width, int height) { | 2495 int width, int height) { |
2450 int y; | 2496 int y; |
2451 void (*ARGBLumaColorTableRow)(const uint8* src_argb, uint8* dst_argb, | 2497 void (*ARGBLumaColorTableRow)(const uint8* src_argb, uint8* dst_argb, |
2452 int width, const uint8* luma, const uint32 lumacoeff) = | 2498 int width, const uint8* luma, const uint32 lumacoeff) = |
2453 ARGBLumaColorTableRow_C; | 2499 ARGBLumaColorTableRow_C; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2818 } | 2864 } |
2819 free_aligned_buffer_64(rows); | 2865 free_aligned_buffer_64(rows); |
2820 } | 2866 } |
2821 return 0; | 2867 return 0; |
2822 } | 2868 } |
2823 | 2869 |
2824 #ifdef __cplusplus | 2870 #ifdef __cplusplus |
2825 } // extern "C" | 2871 } // extern "C" |
2826 } // namespace libyuv | 2872 } // namespace libyuv |
2827 #endif | 2873 #endif |
OLD | NEW |