Commit 3db4588b authored by fbarchard@google.com's avatar fbarchard@google.com

Scale horizontally by 2 but vertically anything.

BUG=none
TEST=set LIBYUV_WIDTH=320 set LIBYUV_HEIGHT=90 libyuvTest.ARGBScaleFrom640x360_Bilinear
Review URL: https://webrtc-codereview.appspot.com/1477006

git-svn-id: http://libyuv.googlecode.com/svn/trunk@695 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 927eb2c1
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 694 Version: 695
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 694 #define LIBYUV_VERSION 695
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -743,7 +743,7 @@ static void ScaleARGBDown2(int /* src_width */, int /* src_height */, ...@@ -743,7 +743,7 @@ static void ScaleARGBDown2(int /* src_width */, int /* src_height */,
int x, int dx, int y, int dy, int x, int dx, int y, int dy,
FilterMode filtering) { FilterMode filtering) {
assert(dx == 65536 * 2); // Test scale factor of 2. assert(dx == 65536 * 2); // Test scale factor of 2.
assert(dy == 65536 * 2); assert((dy & 0x1ffff) == 0); // Test vertical scale is multiple of 2.
void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride,
uint8* dst_argb, int dst_width) = uint8* dst_argb, int dst_width) =
filtering ? ScaleARGBRowDown2Int_C : ScaleARGBRowDown2_C; filtering ? ScaleARGBRowDown2Int_C : ScaleARGBRowDown2_C;
...@@ -762,11 +762,12 @@ static void ScaleARGBDown2(int /* src_width */, int /* src_height */, ...@@ -762,11 +762,12 @@ static void ScaleARGBDown2(int /* src_width */, int /* src_height */,
} }
#endif #endif
src_argb += (y >> 16) * src_stride + (x >> 16) * 4; src_argb += (y >> 16) * src_stride + (x >> 16) * 4;
int row_stride = src_stride * (dy >> 16);
// TODO(fbarchard): Loop through source height to allow odd height. // TODO(fbarchard): Loop through source height to allow odd height.
for (int y = 0; y < dst_height; ++y) { for (int y = 0; y < dst_height; ++y) {
ScaleARGBRowDown2(src_argb, src_stride, dst_argb, dst_width); ScaleARGBRowDown2(src_argb, src_stride, dst_argb, dst_width);
src_argb += (src_stride << 1); src_argb += row_stride;
dst_argb += dst_stride; dst_argb += dst_stride;
} }
} }
...@@ -1115,35 +1116,32 @@ static void ScaleARGB(const uint8* src, int src_stride, ...@@ -1115,35 +1116,32 @@ static void ScaleARGB(const uint8* src, int src_stride,
filtering = (FilterMode)atoi(filter_override); // NOLINT filtering = (FilterMode)atoi(filter_override); // NOLINT
} }
#endif #endif
if (dst_width == src_width && dst_height == src_height) { // Special case for integer step values.
// Straight copy. if (((dx | dy) & 0xffff) == 0) {
ARGBCopy(src + (y >> 16) * src_stride + (x >> 16) * 4, src_stride, // Optimized even scale down. ie 2, 4, 6, 8, 10x.
dst, dst_stride, clip_width, clip_height); if (!(dx & 0x10000) && !(dy & 0x10000)) {
return; if ((dx >> 16) == 2) {
} // Optimized 1/2 horizontal.
// TODO(fbarchard): Allow different vertical scales. ScaleARGBDown2(src_width, src_height, clip_width, clip_height,
if (2 * dst_width == src_width && 2 * dst_height == src_height) { src_stride, dst_stride, src, dst,
// Optimized 1/2. x, dx, y, dy, filtering);
ScaleARGBDown2(src_width, src_height, return;
clip_width, clip_height, }
src_stride, dst_stride, src, dst,
x, dx, y, dy, filtering);
return;
}
// TODO(fbarchard): Remove this divide, reusing dx and dy.
int scale_down_x = src_width / dst_width;
int scale_down_y = src_height / dst_height;
if (dst_width * scale_down_x == src_width &&
dst_height * scale_down_y == src_height) {
if (!(scale_down_x & 1) && !(scale_down_y & 1)) {
// Optimized even scale down. ie 4, 6, 8, 10x.
ScaleARGBDownEven(src_width, src_height, clip_width, clip_height, ScaleARGBDownEven(src_width, src_height, clip_width, clip_height,
src_stride, dst_stride, src, dst, src_stride, dst_stride, src, dst,
x, dx, y, dy, filtering); x, dx, y, dy, filtering);
return; return;
} }
if ((scale_down_x & 1) && (scale_down_y & 1)) { // Optimized odd scale down. ie 3, 5, 7, 9x.
if ((dx & 0x10000) && (dy & 0x10000)) {
filtering = kFilterNone; filtering = kFilterNone;
if (dst_width == src_width && dst_height == src_height) {
// Straight copy.
ARGBCopy(src + (y >> 16) * src_stride + (x >> 16) * 4, src_stride,
dst, dst_stride, clip_width, clip_height);
return;
}
} }
} }
// Arbitrary scale up and/or down. // Arbitrary scale up and/or down.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment