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

Side by Side Diff: source/row_common.cc

Issue 1872953002: Fix stride bug for msan on I420Interpolate. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: Created 4 years, 8 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/planar_functions.cc ('k') | 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 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 *(uint32*)(dst_argb) = 2140 *(uint32*)(dst_argb) =
2141 *(const uint32*)(src_argb + y * src_argb_stride + 2141 *(const uint32*)(src_argb + y * src_argb_stride +
2142 x * 4); 2142 x * 4);
2143 dst_argb += 4; 2143 dst_argb += 4;
2144 uv[0] += uv_dudv[2]; 2144 uv[0] += uv_dudv[2];
2145 uv[1] += uv_dudv[3]; 2145 uv[1] += uv_dudv[3];
2146 } 2146 }
2147 } 2147 }
2148 2148
2149 // Blend 2 rows into 1. 2149 // Blend 2 rows into 1.
2150 static void HalfRow_C(const uint8* src_uv, int src_uv_stride, 2150 static void HalfRow_C(const uint8* src_uv, ptrdiff_t src_uv_stride,
2151 uint8* dst_uv, int width) { 2151 uint8* dst_uv, int width) {
2152 int x; 2152 int x;
2153 for (x = 0; x < width; ++x) { 2153 for (x = 0; x < width; ++x) {
2154 dst_uv[x] = (src_uv[x] + src_uv[src_uv_stride + x] + 1) >> 1; 2154 dst_uv[x] = (src_uv[x] + src_uv[src_uv_stride + x] + 1) >> 1;
2155 } 2155 }
2156 } 2156 }
2157 2157
2158 static void HalfRow_16_C(const uint16* src_uv, int src_uv_stride, 2158 static void HalfRow_16_C(const uint16* src_uv, ptrdiff_t src_uv_stride,
2159 uint16* dst_uv, int width) { 2159 uint16* dst_uv, int width) {
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, (int)(src_stride), dst_ptr, width); 2179 HalfRow_C(src_ptr, src_stride, dst_ptr, width);
2180 return; 2180 return;
2181 } 2181 }
2182 for (x = 0; x < width - 1; x += 2) { 2182 for (x = 0; x < width - 1; x += 2) {
2183 dst_ptr[0] = 2183 dst_ptr[0] =
2184 (src_ptr[0] * y0_fraction + src_ptr1[0] * y1_fraction + 128) >> 8; 2184 (src_ptr[0] * y0_fraction + src_ptr1[0] * y1_fraction + 128) >> 8;
2185 dst_ptr[1] = 2185 dst_ptr[1] =
2186 (src_ptr[1] * y0_fraction + src_ptr1[1] * y1_fraction + 128) >> 8; 2186 (src_ptr[1] * y0_fraction + src_ptr1[1] * y1_fraction + 128) >> 8;
2187 src_ptr += 2; 2187 src_ptr += 2;
2188 src_ptr1 += 2; 2188 src_ptr1 += 2;
2189 dst_ptr += 2; 2189 dst_ptr += 2;
2190 } 2190 }
2191 if (width & 1) { 2191 if (width & 1) {
2192 dst_ptr[0] = 2192 dst_ptr[0] =
2193 (src_ptr[0] * y0_fraction + src_ptr1[0] * y1_fraction + 128) >> 8; 2193 (src_ptr[0] * y0_fraction + src_ptr1[0] * y1_fraction + 128) >> 8;
2194 } 2194 }
2195 } 2195 }
2196 2196
2197 void InterpolateRow_16_C(uint16* dst_ptr, const uint16* src_ptr, 2197 void InterpolateRow_16_C(uint16* dst_ptr, const uint16* src_ptr,
2198 ptrdiff_t src_stride, 2198 ptrdiff_t src_stride,
2199 int width, int source_y_fraction) { 2199 int width, int source_y_fraction) {
2200 int y1_fraction = source_y_fraction; 2200 int y1_fraction = source_y_fraction;
2201 int y0_fraction = 256 - y1_fraction; 2201 int y0_fraction = 256 - y1_fraction;
2202 const uint16* src_ptr1 = src_ptr + src_stride; 2202 const uint16* src_ptr1 = src_ptr + src_stride;
2203 int x; 2203 int x;
2204 if (source_y_fraction == 0) { 2204 if (source_y_fraction == 0) {
2205 memcpy(dst_ptr, src_ptr, width * 2); 2205 memcpy(dst_ptr, src_ptr, width * 2);
2206 return; 2206 return;
2207 } 2207 }
2208 if (source_y_fraction == 128) { 2208 if (source_y_fraction == 128) {
2209 HalfRow_16_C(src_ptr, (int)(src_stride), dst_ptr, width); 2209 HalfRow_16_C(src_ptr, src_stride, dst_ptr, width);
2210 return; 2210 return;
2211 } 2211 }
2212 for (x = 0; x < width - 1; x += 2) { 2212 for (x = 0; x < width - 1; x += 2) {
2213 dst_ptr[0] = (src_ptr[0] * y0_fraction + src_ptr1[0] * y1_fraction) >> 8; 2213 dst_ptr[0] = (src_ptr[0] * y0_fraction + src_ptr1[0] * y1_fraction) >> 8;
2214 dst_ptr[1] = (src_ptr[1] * y0_fraction + src_ptr1[1] * y1_fraction) >> 8; 2214 dst_ptr[1] = (src_ptr[1] * y0_fraction + src_ptr1[1] * y1_fraction) >> 8;
2215 src_ptr += 2; 2215 src_ptr += 2;
2216 src_ptr1 += 2; 2216 src_ptr1 += 2;
2217 dst_ptr += 2; 2217 dst_ptr += 2;
2218 } 2218 }
2219 if (width & 1) { 2219 if (width & 1) {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 dst_rgb565 += twidth * 2; 2605 dst_rgb565 += twidth * 2;
2606 width -= twidth; 2606 width -= twidth;
2607 } 2607 }
2608 } 2608 }
2609 #endif 2609 #endif
2610 2610
2611 #ifdef __cplusplus 2611 #ifdef __cplusplus
2612 } // extern "C" 2612 } // extern "C"
2613 } // namespace libyuv 2613 } // namespace libyuv
2614 #endif 2614 #endif
OLDNEW
« no previous file with comments | « source/planar_functions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698