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

Side by Side Diff: source/row_common.cc

Issue 2114843002: API for deinterlacing YUV420 output on Android (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: lint fixes for spacing Created 4 years, 5 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/convert.cc ('k') | unit_test/convert_test.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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 #define UB -128 /* max(-128, round(-2.018 * 64)) */ 981 #define UB -128 /* max(-128, round(-2.018 * 64)) */
982 #define UG 25 /* round(0.391 * 64) */ 982 #define UG 25 /* round(0.391 * 64) */
983 #define VG 52 /* round(0.813 * 64) */ 983 #define VG 52 /* round(0.813 * 64) */
984 #define VR -102 /* round(-1.596 * 64) */ 984 #define VR -102 /* round(-1.596 * 64) */
985 985
986 // Bias values to subtract 16 from Y and 128 from U and V. 986 // Bias values to subtract 16 from Y and 128 from U and V.
987 #define BB (UB * 128 + YGB) 987 #define BB (UB * 128 + YGB)
988 #define BG (UG * 128 + VG * 128 + YGB) 988 #define BG (UG * 128 + VG * 128 + YGB)
989 #define BR (VR * 128 + YGB) 989 #define BR (VR * 128 + YGB)
990 990
991 #if defined(__aarch64__) 991 #if defined(__aarch64__) // 64 bit arm
992 const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 992 const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
993 { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 993 { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
994 { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 994 { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
995 { UG, VG, UG, VG, UG, VG, UG, VG }, 995 { UG, VG, UG, VG, UG, VG, UG, VG },
996 { UG, VG, UG, VG, UG, VG, UG, VG }, 996 { UG, VG, UG, VG, UG, VG, UG, VG },
997 { BB, BG, BR, 0, 0, 0, 0, 0 }, 997 { BB, BG, BR, 0, 0, 0, 0, 0 },
998 { 0x0101 * YG, 0, 0, 0 } 998 { 0x0101 * YG, 0, 0, 0 }
999 }; 999 };
1000 const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 1000 const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
1001 { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 1001 { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
1002 { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 1002 { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
1003 { VG, UG, VG, UG, VG, UG, VG, UG }, 1003 { VG, UG, VG, UG, VG, UG, VG, UG },
1004 { VG, UG, VG, UG, VG, UG, VG, UG }, 1004 { VG, UG, VG, UG, VG, UG, VG, UG },
1005 { BR, BG, BB, 0, 0, 0, 0, 0 }, 1005 { BR, BG, BB, 0, 0, 0, 0, 0 },
1006 { 0x0101 * YG, 0, 0, 0 } 1006 { 0x0101 * YG, 0, 0, 0 }
1007 }; 1007 };
1008 #elif defined(__arm__) 1008 #elif defined(__arm__) // 32 bit arm
1009 const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 1009 const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
1010 { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, 1010 { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 },
1011 { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, 1011 { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 },
1012 { BB, BG, BR, 0, 0, 0, 0, 0 }, 1012 { BB, BG, BR, 0, 0, 0, 0, 0 },
1013 { 0x0101 * YG, 0, 0, 0 } 1013 { 0x0101 * YG, 0, 0, 0 }
1014 }; 1014 };
1015 const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 1015 const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
1016 { -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 }, 1016 { -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 },
1017 { VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 }, 1017 { VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 },
1018 { BR, BG, BB, 0, 0, 0, 0, 0 }, 1018 { BR, BG, BB, 0, 0, 0, 0, 0 },
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 int ug = yuvconstants->kUVToG[0]; 1257 int ug = yuvconstants->kUVToG[0];
1258 int vg = yuvconstants->kUVToG[1]; 1258 int vg = yuvconstants->kUVToG[1];
1259 int vr = yuvconstants->kUVToR[1]; 1259 int vr = yuvconstants->kUVToR[1];
1260 int bb = yuvconstants->kUVBiasB[0]; 1260 int bb = yuvconstants->kUVBiasB[0];
1261 int bg = yuvconstants->kUVBiasG[0]; 1261 int bg = yuvconstants->kUVBiasG[0];
1262 int br = yuvconstants->kUVBiasR[0]; 1262 int br = yuvconstants->kUVBiasR[0];
1263 int yg = yuvconstants->kYToRgb[0]; 1263 int yg = yuvconstants->kYToRgb[0];
1264 #endif 1264 #endif
1265 1265
1266 uint32 y1 = (uint32)(y * 0x0101 * yg) >> 16; 1266 uint32 y1 = (uint32)(y * 0x0101 * yg) >> 16;
1267 *b = Clamp((int32)(-(u * ub ) + y1 + bb) >> 6); 1267 *b = Clamp((int32)(-(u * ub) + y1 + bb) >> 6);
1268 *g = Clamp((int32)(-(u * ug + v * vg) + y1 + bg) >> 6); 1268 *g = Clamp((int32)(-(u * ug + v * vg) + y1 + bg) >> 6);
1269 *r = Clamp((int32)(-( v * vr) + y1 + br) >> 6); 1269 *r = Clamp((int32) (-(v * vr) + y1 + br) >> 6);
1270 } 1270 }
1271 1271
1272 // Y contribution to R,G,B. Scale and bias. 1272 // Y contribution to R,G,B. Scale and bias.
1273 #define YG 18997 /* round(1.164 * 64 * 256 * 256 / 257) */ 1273 #define YG 18997 /* round(1.164 * 64 * 256 * 256 / 257) */
1274 #define YGB -1160 /* 1.164 * 64 * -16 + 64 / 2 */ 1274 #define YGB -1160 /* 1.164 * 64 * -16 + 64 / 2 */
1275 1275
1276 // C reference code that mimics the YUV assembly. 1276 // C reference code that mimics the YUV assembly.
1277 static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) { 1277 static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) {
1278 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; 1278 uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16;
1279 *b = Clamp((int32)(y1 + YGB) >> 6); 1279 *b = Clamp((int32)(y1 + YGB) >> 6);
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 int x; 2160 int x;
2161 for (x = 0; x < width; ++x) { 2161 for (x = 0; x < width; ++x) {
2162 dst_uv[x] = (src_uv[x] + src_uv[src_uv_stride + x] + 1) >> 1; 2162 dst_uv[x] = (src_uv[x] + src_uv[src_uv_stride + x] + 1) >> 1;
2163 } 2163 }
2164 } 2164 }
2165 2165
2166 // C version 2x2 -> 2x1. 2166 // C version 2x2 -> 2x1.
2167 void InterpolateRow_C(uint8* dst_ptr, const uint8* src_ptr, 2167 void InterpolateRow_C(uint8* dst_ptr, const uint8* src_ptr,
2168 ptrdiff_t src_stride, 2168 ptrdiff_t src_stride,
2169 int width, int source_y_fraction) { 2169 int width, int source_y_fraction) {
2170 int y1_fraction = source_y_fraction ; 2170 int y1_fraction = source_y_fraction;
2171 int y0_fraction = 256 - y1_fraction; 2171 int y0_fraction = 256 - y1_fraction;
2172 const uint8* src_ptr1 = src_ptr + src_stride; 2172 const uint8* src_ptr1 = src_ptr + src_stride;
2173 int x; 2173 int x;
2174 if (y1_fraction == 0) { 2174 if (y1_fraction == 0) {
2175 memcpy(dst_ptr, src_ptr, width); 2175 memcpy(dst_ptr, src_ptr, width);
2176 return; 2176 return;
2177 } 2177 }
2178 if (y1_fraction == 128) { 2178 if (y1_fraction == 128) {
2179 HalfRow_C(src_ptr, src_stride, dst_ptr, width); 2179 HalfRow_C(src_ptr, src_stride, dst_ptr, width);
2180 return; 2180 return;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 dst_rgb565 += twidth * 2; 2618 dst_rgb565 += twidth * 2;
2619 width -= twidth; 2619 width -= twidth;
2620 } 2620 }
2621 } 2621 }
2622 #endif 2622 #endif
2623 2623
2624 #ifdef __cplusplus 2624 #ifdef __cplusplus
2625 } // extern "C" 2625 } // extern "C"
2626 } // namespace libyuv 2626 } // namespace libyuv
2627 #endif 2627 #endif
OLDNEW
« no previous file with comments | « source/convert.cc ('k') | unit_test/convert_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698