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

Side by Side Diff: source/scale_argb.cc

Issue 1533643005: Add rounding to InterpolateRow for improved quality and consistency. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: lint fix in unittest 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 | « source/scale.cc ('k') | source/scale_common.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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 int clip_src_width; 203 int clip_src_width;
204 xl = (xl >> 16) & ~3; // Left edge aligned. 204 xl = (xl >> 16) & ~3; // Left edge aligned.
205 xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels. 205 xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels.
206 xr = (xr + 1 + 3) & ~3; // 1 beyond 4 pixel aligned right most pixel. 206 xr = (xr + 1 + 3) & ~3; // 1 beyond 4 pixel aligned right most pixel.
207 if (xr > src_width) { 207 if (xr > src_width) {
208 xr = src_width; 208 xr = src_width;
209 } 209 }
210 clip_src_width = (int)(xr - xl) * 4; // Width aligned to 4. 210 clip_src_width = (int)(xr - xl) * 4; // Width aligned to 4.
211 src_argb += xl * 4; 211 src_argb += xl * 4;
212 x -= (int)(xl << 16); 212 x -= (int)(xl << 16);
213 #if defined(HAS_INTERPOLATEROW_SSE2)
214 if (TestCpuFlag(kCpuHasSSE2)) {
215 InterpolateRow = InterpolateRow_Any_SSE2;
216 if (IS_ALIGNED(clip_src_width, 16)) {
217 InterpolateRow = InterpolateRow_SSE2;
218 }
219 }
220 #endif
221 #if defined(HAS_INTERPOLATEROW_SSSE3) 213 #if defined(HAS_INTERPOLATEROW_SSSE3)
222 if (TestCpuFlag(kCpuHasSSSE3)) { 214 if (TestCpuFlag(kCpuHasSSSE3)) {
223 InterpolateRow = InterpolateRow_Any_SSSE3; 215 InterpolateRow = InterpolateRow_Any_SSSE3;
224 if (IS_ALIGNED(clip_src_width, 16)) { 216 if (IS_ALIGNED(clip_src_width, 16)) {
225 InterpolateRow = InterpolateRow_SSSE3; 217 InterpolateRow = InterpolateRow_SSSE3;
226 } 218 }
227 } 219 }
228 #endif 220 #endif
229 #if defined(HAS_INTERPOLATEROW_AVX2) 221 #if defined(HAS_INTERPOLATEROW_AVX2)
230 if (TestCpuFlag(kCpuHasAVX2)) { 222 if (TestCpuFlag(kCpuHasAVX2)) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 int x, int dx, int y, int dy, 293 int x, int dx, int y, int dy,
302 enum FilterMode filtering) { 294 enum FilterMode filtering) {
303 int j; 295 int j;
304 void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, 296 void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
305 ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 297 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
306 InterpolateRow_C; 298 InterpolateRow_C;
307 void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb, 299 void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb,
308 int dst_width, int x, int dx) = 300 int dst_width, int x, int dx) =
309 filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; 301 filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C;
310 const int max_y = (src_height - 1) << 16; 302 const int max_y = (src_height - 1) << 16;
311 #if defined(HAS_INTERPOLATEROW_SSE2)
312 if (TestCpuFlag(kCpuHasSSE2)) {
313 InterpolateRow = InterpolateRow_Any_SSE2;
314 if (IS_ALIGNED(dst_width, 4)) {
315 InterpolateRow = InterpolateRow_SSE2;
316 }
317 }
318 #endif
319 #if defined(HAS_INTERPOLATEROW_SSSE3) 303 #if defined(HAS_INTERPOLATEROW_SSSE3)
320 if (TestCpuFlag(kCpuHasSSSE3)) { 304 if (TestCpuFlag(kCpuHasSSSE3)) {
321 InterpolateRow = InterpolateRow_Any_SSSE3; 305 InterpolateRow = InterpolateRow_Any_SSSE3;
322 if (IS_ALIGNED(dst_width, 4)) { 306 if (IS_ALIGNED(dst_width, 4)) {
323 InterpolateRow = InterpolateRow_SSSE3; 307 InterpolateRow = InterpolateRow_SSSE3;
324 } 308 }
325 } 309 }
326 #endif 310 #endif
327 #if defined(HAS_INTERPOLATEROW_AVX2) 311 #if defined(HAS_INTERPOLATEROW_AVX2)
328 if (TestCpuFlag(kCpuHasAVX2)) { 312 if (TestCpuFlag(kCpuHasAVX2)) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) && 471 IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
488 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) && 472 IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
489 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 473 IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {
490 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2; 474 I422ToARGBRow = I422ToARGBRow_MIPS_DSPR2;
491 } 475 }
492 #endif 476 #endif
493 477
494 void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, 478 void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
495 ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 479 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
496 InterpolateRow_C; 480 InterpolateRow_C;
497 #if defined(HAS_INTERPOLATEROW_SSE2)
498 if (TestCpuFlag(kCpuHasSSE2)) {
499 InterpolateRow = InterpolateRow_Any_SSE2;
500 if (IS_ALIGNED(dst_width, 4)) {
501 InterpolateRow = InterpolateRow_SSE2;
502 }
503 }
504 #endif
505 #if defined(HAS_INTERPOLATEROW_SSSE3) 481 #if defined(HAS_INTERPOLATEROW_SSSE3)
506 if (TestCpuFlag(kCpuHasSSSE3)) { 482 if (TestCpuFlag(kCpuHasSSSE3)) {
507 InterpolateRow = InterpolateRow_Any_SSSE3; 483 InterpolateRow = InterpolateRow_Any_SSSE3;
508 if (IS_ALIGNED(dst_width, 4)) { 484 if (IS_ALIGNED(dst_width, 4)) {
509 InterpolateRow = InterpolateRow_SSSE3; 485 InterpolateRow = InterpolateRow_SSSE3;
510 } 486 }
511 } 487 }
512 #endif 488 #endif
513 #if defined(HAS_INTERPOLATEROW_AVX2) 489 #if defined(HAS_INTERPOLATEROW_AVX2)
514 if (TestCpuFlag(kCpuHasAVX2)) { 490 if (TestCpuFlag(kCpuHasAVX2)) {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 clip_x, clip_y, clip_width, clip_height, 851 clip_x, clip_y, clip_width, clip_height,
876 filtering); 852 filtering);
877 free(argb_buffer); 853 free(argb_buffer);
878 return r; 854 return r;
879 } 855 }
880 856
881 #ifdef __cplusplus 857 #ifdef __cplusplus
882 } // extern "C" 858 } // extern "C"
883 } // namespace libyuv 859 } // namespace libyuv
884 #endif 860 #endif
OLDNEW
« no previous file with comments | « source/scale.cc ('k') | source/scale_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698