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

Side by Side Diff: source/row_common.cc

Issue 2371293002: Add low level support for 12 bit 420, 422 and 444 YUV video frame conversion. (Closed)
Patch Set: cast to uint16 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
« no previous file with comments | « source/row_any.cc ('k') | source/row_gcc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 2326
2327 dst_argb[0] = Clamp((int32)(db)); 2327 dst_argb[0] = Clamp((int32)(db));
2328 dst_argb[1] = Clamp((int32)(dg)); 2328 dst_argb[1] = Clamp((int32)(dg));
2329 dst_argb[2] = Clamp((int32)(dr)); 2329 dst_argb[2] = Clamp((int32)(dr));
2330 dst_argb[3] = Clamp((int32)(da)); 2330 dst_argb[3] = Clamp((int32)(da));
2331 src_argb += 4; 2331 src_argb += 4;
2332 dst_argb += 4; 2332 dst_argb += 4;
2333 } 2333 }
2334 } 2334 }
2335 2335
2336 // Samples assumed to be unsigned in low 9, 10 or 12 bits. Scale factor
2337 // adjust the source integer range to the half float range desired.
2338
2339 // This magic constant is 2^-112. Multiplying by this
2340 // is the same as subtracting 112 from the exponent, which
2341 // is the difference in exponent bias between 32-bit and
2342 // 16-bit floats. Once we've done this subtraction, we can
2343 // simply extract the low bits of the exponent and the high
2344 // bits of the mantissa from our float and we're done.
2345
2346 void HalfFloatRow_C(const uint16* src, uint16* dst, float scale, int width) {
2347 int i;
2348 float mult = 1.9259299444e-34f * scale;
2349 for (i = 0; i < width; ++i) {
2350 float value = src[i] * mult;
2351 dst[i] = (uint16)((*(uint32_t*)&value) >> 13);
2352 }
2353 }
2354
2336 void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width, 2355 void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width,
2337 const uint8* luma, uint32 lumacoeff) { 2356 const uint8* luma, uint32 lumacoeff) {
2338 uint32 bc = lumacoeff & 0xff; 2357 uint32 bc = lumacoeff & 0xff;
2339 uint32 gc = (lumacoeff >> 8) & 0xff; 2358 uint32 gc = (lumacoeff >> 8) & 0xff;
2340 uint32 rc = (lumacoeff >> 16) & 0xff; 2359 uint32 rc = (lumacoeff >> 16) & 0xff;
2341 2360
2342 int i; 2361 int i;
2343 for (i = 0; i < width - 1; i += 2) { 2362 for (i = 0; i < width - 1; i += 2) {
2344 // Luminance in rows, color values in columns. 2363 // Luminance in rows, color values in columns.
2345 const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + 2364 const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc +
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 dst_rgb565 += twidth * 2; 2638 dst_rgb565 += twidth * 2;
2620 width -= twidth; 2639 width -= twidth;
2621 } 2640 }
2622 } 2641 }
2623 #endif 2642 #endif
2624 2643
2625 #ifdef __cplusplus 2644 #ifdef __cplusplus
2626 } // extern "C" 2645 } // extern "C"
2627 } // namespace libyuv 2646 } // namespace libyuv
2628 #endif 2647 #endif
OLDNEW
« no previous file with comments | « source/row_any.cc ('k') | source/row_gcc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698