From fcc1b9559202505a630e93d279d939c039a80f55 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Wed, 29 May 2013 17:05:42 +0000 Subject: [PATCH] Scale up point use step / 2 as initial coordinate, which is more symetric and matches ffmpeg exactly. BUG=232 TEST=convert.exe -f 0 faces_352x288_P420.yuv faces_640x480_P420.yuv R=ryanpetrie@google.com Review URL: https://webrtc-codereview.appspot.com/1580005 git-svn-id: http://libyuv.googlecode.com/svn/trunk@706 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/scale.cc | 10 ++-------- source/scale_argb.cc | 8 ++------ 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/README.chromium b/README.chromium index 62ace2ee8..48b2e296f 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 705 +Version: 706 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 3f344fe8e..2626f123a 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 705 +#define LIBYUV_VERSION 706 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/scale.cc b/source/scale.cc index 7c11e5d07..9fd27a157 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -3232,20 +3232,14 @@ static void ScalePlaneSimple(int src_width, int src_height, const uint8* src_ptr, uint8* dst_ptr) { int dx = (Abs(src_width) << 16) / dst_width; int dy = (src_height << 16) / dst_height; - int x = 0; - int y = 0; - if (dst_width <= Abs(src_width)) { - x = (dx >> 1) - 32768; - } + int x = (dx >= 65536) ? ((dx >> 1) - 32768) : (dx >> 1); + int y = (dy >= 65536) ? ((dy >> 1) - 32768) : (dy >> 1); // Negative src_width means horizontally mirror. if (src_width < 0) { x += (dst_width - 1) * dx; dx = -dx; src_width = -src_width; } - if (dst_height <= src_height) { - y = (dy >> 1) - 32768; - } for (int j = 0; j < dst_height; ++j) { int xs = x; diff --git a/source/scale_argb.cc b/source/scale_argb.cc index 885395f49..1aaf057c7 100644 --- a/source/scale_argb.cc +++ b/source/scale_argb.cc @@ -1081,12 +1081,8 @@ static void ScaleARGB(const uint8* src, int src_stride, // Scale step for point sampling duplicates all pixels equally. dx = (Abs(src_width) << 16) / dst_width; dy = (src_height << 16) / dst_height; - if (dst_width <= Abs(src_width)) { - x = (dx >> 1) - 32768; - } - if (dst_height <= src_height) { - y = (dy >> 1) - 32768; - } + x = (dx >= 65536) ? ((dx >> 1) - 32768) : (dx >> 1); + y = (dy >= 65536) ? ((dy >> 1) - 32768) : (dy >> 1); } // Negative src_width means horizontally mirror. if (src_width < 0) {