Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(799)

Side by Side Diff: source/planar_functions.cc

Issue 2371293002: Add low level support for 12 bit 420, 422 and 444 YUV video frame conversion. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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, int16* dst, float scale, int width) =
2454 HalfFloatRow_C;
2455 if (!src_y || !dst_y || width <= 0 || height == 0) {
2456 return -1;
2457 }
2458 // Negative height means invert the image.
2459 if (height < 0) {
2460 height = -height;
2461 src_y = src_y + (height - 1) * src_stride_y;
2462 src_stride_y = -src_stride_y;
2463 }
2464 // Coalesce rows.
2465 if (src_stride_y == width &&
2466 dst_stride_y == width) {
2467 width *= height;
2468 height = 1;
2469 src_stride_y = dst_stride_y = 0;
2470 }
2471 #if defined(HAS_HALFFLOATROW_AVX2)
2472 if (TestCpuFlag(kCpuHasAVX2) && IS_ALIGNED(width, 8)) {
2473 HalfFloatRow = HalfFloatRow_AVX2;
2474 }
2475 #endif
2476
2477 for (y = 0; y < height; ++y) {
2478 HalfFloatRow(src_y, dst_y, scale, width);
2479 src_y += src_stride_y;
2480 dst_y += dst_stride_y;
2481 }
2482 return 0;
2483 }
2484
2485
2486
2444 // Apply a lumacolortable to each ARGB pixel. 2487 // Apply a lumacolortable to each ARGB pixel.
2445 LIBYUV_API 2488 LIBYUV_API
2446 int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb, 2489 int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb,
2447 uint8* dst_argb, int dst_stride_argb, 2490 uint8* dst_argb, int dst_stride_argb,
2448 const uint8* luma, 2491 const uint8* luma,
2449 int width, int height) { 2492 int width, int height) {
2450 int y; 2493 int y;
2451 void (*ARGBLumaColorTableRow)(const uint8* src_argb, uint8* dst_argb, 2494 void (*ARGBLumaColorTableRow)(const uint8* src_argb, uint8* dst_argb,
2452 int width, const uint8* luma, const uint32 lumacoeff) = 2495 int width, const uint8* luma, const uint32 lumacoeff) =
2453 ARGBLumaColorTableRow_C; 2496 ARGBLumaColorTableRow_C;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2818 } 2861 }
2819 free_aligned_buffer_64(rows); 2862 free_aligned_buffer_64(rows);
2820 } 2863 }
2821 return 0; 2864 return 0;
2822 } 2865 }
2823 2866
2824 #ifdef __cplusplus 2867 #ifdef __cplusplus
2825 } // extern "C" 2868 } // extern "C"
2826 } // namespace libyuv 2869 } // namespace libyuv
2827 #endif 2870 #endif
OLDNEW
« no previous file with comments | « include/libyuv/row.h ('k') | source/row_common.cc » ('j') | source/row_common.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698