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

Side by Side Diff: source/row_common.cc

Issue 1502343003: Unroll C version of YUV blender for improved performance. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: ublend undef Created 5 years 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 | « no previous file | no next file » | 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 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 uint32 bg = src_argb1[1]; 2010 uint32 bg = src_argb1[1];
2011 uint32 br = src_argb1[2]; 2011 uint32 br = src_argb1[2];
2012 dst_argb[0] = BLEND(fb, bb, a); 2012 dst_argb[0] = BLEND(fb, bb, a);
2013 dst_argb[1] = BLEND(fg, bg, a); 2013 dst_argb[1] = BLEND(fg, bg, a);
2014 dst_argb[2] = BLEND(fr, br, a); 2014 dst_argb[2] = BLEND(fr, br, a);
2015 dst_argb[3] = 255u; 2015 dst_argb[3] = 255u;
2016 } 2016 }
2017 } 2017 }
2018 #undef BLEND 2018 #undef BLEND
2019 2019
2020 #define UBLEND(f, b, a) (((a) * f) + ((255 - a) * b) + 255) >> 8
2020 void BlendPlaneRow_C(const uint8* src0, const uint8* src1, 2021 void BlendPlaneRow_C(const uint8* src0, const uint8* src1,
2021 const uint8* alpha, uint8* dst, int width) { 2022 const uint8* alpha, uint8* dst, int width) {
2022 int x; 2023 int x;
2023 for (x = 0; x < width; ++x) { 2024 for (x = 0; x < width - 1; x += 2) {
2024 uint32 f = *src0++; 2025 dst[0] = UBLEND(src0[0], src1[0], alpha[0]);
2025 uint32 b = *src1++; 2026 dst[1] = UBLEND(src0[1], src1[1], alpha[1]);
2026 uint32 a = *alpha++; 2027 src0 += 2;
2027 *dst++ = (((a) * f) + ((255 - a) * b) + 255) >> 8; 2028 src1 += 2;
2029 alpha += 2;
2030 dst += 2;
2031 }
2032 if (width & 1) {
2033 dst[0] = UBLEND(src0[0], src1[0], alpha[0]);
2028 } 2034 }
2029 } 2035 }
2036 #undef UBLEND
2030 2037
2031 #define ATTENUATE(f, a) (a | (a << 8)) * (f | (f << 8)) >> 24 2038 #define ATTENUATE(f, a) (a | (a << 8)) * (f | (f << 8)) >> 24
2032 2039
2033 // Multiply source RGB by alpha and store to destination. 2040 // Multiply source RGB by alpha and store to destination.
2034 // This code mimics the SSSE3 version for better testability. 2041 // This code mimics the SSSE3 version for better testability.
2035 void ARGBAttenuateRow_C(const uint8* src_argb, uint8* dst_argb, int width) { 2042 void ARGBAttenuateRow_C(const uint8* src_argb, uint8* dst_argb, int width) {
2036 int i; 2043 int i;
2037 for (i = 0; i < width - 1; i += 2) { 2044 for (i = 0; i < width - 1; i += 2) {
2038 uint32 b = src_argb[0]; 2045 uint32 b = src_argb[0];
2039 uint32 g = src_argb[1]; 2046 uint32 g = src_argb[1];
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 dst_rgb565 += twidth * 2; 2630 dst_rgb565 += twidth * 2;
2624 width -= twidth; 2631 width -= twidth;
2625 } 2632 }
2626 } 2633 }
2627 #endif 2634 #endif
2628 2635
2629 #ifdef __cplusplus 2636 #ifdef __cplusplus
2630 } // extern "C" 2637 } // extern "C"
2631 } // namespace libyuv 2638 } // namespace libyuv
2632 #endif 2639 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698