mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 01:06:46 +08:00
YUV scaler mirror horizontal if src_width is negative
BUG= Review URL: https://webrtc-codereview.appspot.com/1449004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@692 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
9f24b14e05
commit
306e984451
@ -1,6 +1,6 @@
|
|||||||
Name: libyuv
|
Name: libyuv
|
||||||
URL: http://code.google.com/p/libyuv/
|
URL: http://code.google.com/p/libyuv/
|
||||||
Version: 691
|
Version: 692
|
||||||
License: BSD
|
License: BSD
|
||||||
License File: LICENSE
|
License File: LICENSE
|
||||||
|
|
||||||
|
|||||||
@ -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 691
|
#define LIBYUV_VERSION 692
|
||||||
|
|
||||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||||
|
|||||||
155
source/scale.cc
155
source/scale.cc
@ -23,6 +23,14 @@ namespace libyuv {
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static __inline int Abs(int v) {
|
||||||
|
return v >= 0 ? v : -v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int Half(int v) {
|
||||||
|
return v >= 0 ? ((v + 1) >> 1) : -((-v + 1) >> 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Note: Some SSE2 reference manuals
|
// Note: Some SSE2 reference manuals
|
||||||
// cpuvol1.pdf agner_instruction_tables.pdf 253666.pdf 253667.pdf
|
// cpuvol1.pdf agner_instruction_tables.pdf 253666.pdf 253667.pdf
|
||||||
|
|
||||||
@ -3009,10 +3017,16 @@ static void ScalePlaneBox(int src_width, int src_height,
|
|||||||
const uint8* src_ptr, uint8* dst_ptr) {
|
const uint8* src_ptr, uint8* dst_ptr) {
|
||||||
assert(dst_width > 0);
|
assert(dst_width > 0);
|
||||||
assert(dst_height > 0);
|
assert(dst_height > 0);
|
||||||
int dx = (src_width << 16) / dst_width;
|
int dx = (Abs(src_width) << 16) / dst_width;
|
||||||
int dy = (src_height << 16) / dst_height;
|
int dy = (src_height << 16) / dst_height;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
// Negative src_width means horizontally mirror.
|
||||||
|
if (src_width < 0) {
|
||||||
|
x += (dst_width - 1) * dx;
|
||||||
|
dx = -dx;
|
||||||
|
src_width = -src_width;
|
||||||
|
}
|
||||||
int maxy = (src_height << 16);
|
int maxy = (src_height << 16);
|
||||||
if (!IS_ALIGNED(src_width, 16) || (src_width > kMaxStride) ||
|
if (!IS_ALIGNED(src_width, 16) || (src_width > kMaxStride) ||
|
||||||
dst_height * 2 > src_height) {
|
dst_height * 2 > src_height) {
|
||||||
@ -3033,7 +3047,7 @@ static void ScalePlaneBox(int src_width, int src_height,
|
|||||||
} else {
|
} else {
|
||||||
SIMD_ALIGNED(uint16 row[kMaxStride]);
|
SIMD_ALIGNED(uint16 row[kMaxStride]);
|
||||||
void (*ScaleAddRows)(const uint8* src_ptr, ptrdiff_t src_stride,
|
void (*ScaleAddRows)(const uint8* src_ptr, ptrdiff_t src_stride,
|
||||||
uint16* dst_ptr, int src_width, int src_height)=
|
uint16* dst_ptr, int src_width, int src_height) =
|
||||||
ScaleAddRows_C;
|
ScaleAddRows_C;
|
||||||
void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx,
|
void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx,
|
||||||
const uint16* src_ptr, uint8* dst_ptr);
|
const uint16* src_ptr, uint8* dst_ptr);
|
||||||
@ -3070,22 +3084,44 @@ static void ScalePlaneBilinearSimple(int src_width, int src_height,
|
|||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
int src_stride, int dst_stride,
|
int src_stride, int dst_stride,
|
||||||
const uint8* src_ptr, uint8* dst_ptr) {
|
const uint8* src_ptr, uint8* dst_ptr) {
|
||||||
int dx = (src_width << 16) / dst_width;
|
int dx = 0;
|
||||||
int dy = (src_height << 16) / dst_height;
|
int dy = 0;
|
||||||
int y = (dy >= 65536) ? ((dy >> 1) - 32768) : (dy >> 1);
|
int x = 0;
|
||||||
int maxx = (src_width > 1) ? ((src_width - 1) << 16) - 1 : 0;
|
int y = 0;
|
||||||
|
if (dst_width <= Abs(src_width)) {
|
||||||
|
dx = (Abs(src_width) << 16) / dst_width;
|
||||||
|
x = (dx >> 1) - 32768;
|
||||||
|
} else if (dst_width > 1) {
|
||||||
|
dx = ((Abs(src_width) - 1) << 16) / (dst_width - 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) {
|
||||||
|
dy = (src_height << 16) / dst_height;
|
||||||
|
y = (dy >> 1) - 32768;
|
||||||
|
} else if (dst_height > 1) {
|
||||||
|
dy = ((src_height - 1) << 16) / (dst_height - 1);
|
||||||
|
}
|
||||||
|
int maxx = (Abs(src_width) > 1) ? ((Abs(src_width) - 1) << 16) - 1 : 0;
|
||||||
int maxy = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0;
|
int maxy = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0;
|
||||||
|
if (y > maxy) {
|
||||||
|
y = maxy;
|
||||||
|
}
|
||||||
for (int i = 0; i < dst_height; ++i) {
|
for (int i = 0; i < dst_height; ++i) {
|
||||||
int x = (dx >= 65536) ? ((dx >> 1) - 32768) : (dx >> 1);
|
int xs = x;
|
||||||
int yi = y >> 16;
|
int yi = y >> 16;
|
||||||
int yf = y & 0xffff;
|
int yf = y & 0xffff;
|
||||||
const uint8* src0 = src_ptr + yi * src_stride;
|
const uint8* src0 = src_ptr + yi * src_stride;
|
||||||
const uint8* src1 = (yi < src_height - 1) ? src0 + src_stride : src0;
|
const uint8* src1 = (yi < src_height - 1) ? src0 + src_stride : src0;
|
||||||
uint8* dst = dst_ptr;
|
uint8* dst = dst_ptr;
|
||||||
for (int j = 0; j < dst_width; ++j) {
|
for (int j = 0; j < dst_width; ++j) {
|
||||||
int xi = x >> 16;
|
int xi = xs >> 16;
|
||||||
int xf = x & 0xffff;
|
int xf = xs & 0xffff;
|
||||||
int x1 = (xi < src_width - 1) ? xi + 1 : xi;
|
int x1 = (xi < (src_width - 1)) ? xi + 1 : xi;
|
||||||
int a = src0[xi];
|
int a = src0[xi];
|
||||||
int b = src0[x1];
|
int b = src0[x1];
|
||||||
int r0 = BLENDER(a, b, xf);
|
int r0 = BLENDER(a, b, xf);
|
||||||
@ -3093,9 +3129,9 @@ static void ScalePlaneBilinearSimple(int src_width, int src_height,
|
|||||||
b = src1[x1];
|
b = src1[x1];
|
||||||
int r1 = BLENDER(a, b, xf);
|
int r1 = BLENDER(a, b, xf);
|
||||||
*dst++ = BLENDER(r0, r1, yf);
|
*dst++ = BLENDER(r0, r1, yf);
|
||||||
x += dx;
|
xs += dx;
|
||||||
if (x > maxx)
|
if (xs > maxx)
|
||||||
x = maxx;
|
xs = maxx;
|
||||||
}
|
}
|
||||||
dst_ptr += dst_stride;
|
dst_ptr += dst_stride;
|
||||||
y += dy;
|
y += dy;
|
||||||
@ -3113,7 +3149,7 @@ void ScalePlaneBilinear(int src_width, int src_height,
|
|||||||
const uint8* src_ptr, uint8* dst_ptr) {
|
const uint8* src_ptr, uint8* dst_ptr) {
|
||||||
assert(dst_width > 0);
|
assert(dst_width > 0);
|
||||||
assert(dst_height > 0);
|
assert(dst_height > 0);
|
||||||
if (src_width > kMaxStride) {
|
if (Abs(src_width) > kMaxStride) {
|
||||||
ScalePlaneBilinearSimple(src_width, src_height, dst_width, dst_height,
|
ScalePlaneBilinearSimple(src_width, src_height, dst_width, dst_height,
|
||||||
src_stride, dst_stride, src_ptr, dst_ptr);
|
src_stride, dst_stride, src_ptr, dst_ptr);
|
||||||
|
|
||||||
@ -3148,11 +3184,28 @@ void ScalePlaneBilinear(int src_width, int src_height,
|
|||||||
ScaleFilterRows = ScaleFilterRows_MIPS_DSPR2;
|
ScaleFilterRows = ScaleFilterRows_MIPS_DSPR2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
int dx = 0;
|
||||||
int dx = (src_width << 16) / dst_width;
|
int dy = 0;
|
||||||
int dy = (src_height << 16) / dst_height;
|
int x = 0;
|
||||||
int x = (dx >= 65536) ? ((dx >> 1) - 32768) : (dx >> 1);
|
int y = 0;
|
||||||
int y = (dy >= 65536) ? ((dy >> 1) - 32768) : (dy >> 1);
|
if (dst_width <= Abs(src_width)) {
|
||||||
|
dx = (Abs(src_width) << 16) / dst_width;
|
||||||
|
x = (dx >> 1) - 32768;
|
||||||
|
} else if (dst_width > 1) {
|
||||||
|
dx = ((Abs(src_width) - 1) << 16) / (dst_width - 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) {
|
||||||
|
dy = (src_height << 16) / dst_height;
|
||||||
|
y = (dy >> 1) - 32768;
|
||||||
|
} else if (dst_height > 1) {
|
||||||
|
dy = ((src_height - 1) << 16) / (dst_height - 1);
|
||||||
|
}
|
||||||
int maxy = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0;
|
int maxy = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0;
|
||||||
for (int j = 0; j < dst_height; ++j) {
|
for (int j = 0; j < dst_height; ++j) {
|
||||||
if (y > maxy) {
|
if (y > maxy) {
|
||||||
@ -3178,17 +3231,31 @@ static void ScalePlaneSimple(int src_width, int src_height,
|
|||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
int src_stride, int dst_stride,
|
int src_stride, int dst_stride,
|
||||||
const uint8* src_ptr, uint8* dst_ptr) {
|
const uint8* src_ptr, uint8* dst_ptr) {
|
||||||
int dx = (src_width << 16) / dst_width;
|
int dx = (Abs(src_width) << 16) / dst_width;
|
||||||
int dy = (src_height << 16) / dst_height;
|
int dy = (src_height << 16) / dst_height;
|
||||||
int y = (dy >= 65536) ? ((dy >> 1) - 32768) : (dy >> 1);
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
if (dst_width <= Abs(src_width)) {
|
||||||
|
x = (dx >> 1) - 32768;
|
||||||
|
}
|
||||||
|
// 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) {
|
for (int j = 0; j < dst_height; ++j) {
|
||||||
int x = (dx >= 65536) ? ((dx >> 1) - 32768) : (dx >> 1);
|
int xs = x;
|
||||||
int yi = y >> 16;
|
int yi = y >> 16;
|
||||||
const uint8* src = src_ptr + yi * src_stride;
|
const uint8* src = src_ptr + yi * src_stride;
|
||||||
uint8* dst = dst_ptr;
|
uint8* dst = dst_ptr;
|
||||||
for (int i = 0; i < dst_width; ++i) {
|
for (int i = 0; i < dst_width; ++i) {
|
||||||
*dst++ = src[x >> 16];
|
*dst++ = src[xs >> 16];
|
||||||
x += dx;
|
xs += dx;
|
||||||
}
|
}
|
||||||
dst_ptr += dst_stride;
|
dst_ptr += dst_stride;
|
||||||
y += dy;
|
y += dy;
|
||||||
@ -3258,7 +3325,7 @@ void ScalePlane(const uint8* src, int src_stride,
|
|||||||
if (dst_width == src_width && dst_height == src_height) {
|
if (dst_width == src_width && dst_height == src_height) {
|
||||||
// Straight copy.
|
// Straight copy.
|
||||||
CopyPlane(src, src_stride, dst, dst_stride, dst_width, dst_height);
|
CopyPlane(src, src_stride, dst, dst_stride, dst_width, dst_height);
|
||||||
} else if (dst_width <= src_width && dst_height <= src_height) {
|
} else if (dst_width <= Abs(src_width) && dst_height <= src_height) {
|
||||||
// Scale down.
|
// Scale down.
|
||||||
if (use_reference_impl_) {
|
if (use_reference_impl_) {
|
||||||
// For testing, allow the optimized versions to be disabled.
|
// For testing, allow the optimized versions to be disabled.
|
||||||
@ -3316,14 +3383,14 @@ int I420Scale(const uint8* src_y, int src_stride_y,
|
|||||||
uint8* dst_v, int dst_stride_v,
|
uint8* dst_v, int dst_stride_v,
|
||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
FilterMode filtering) {
|
FilterMode filtering) {
|
||||||
if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
|
if (!src_y || !src_u || !src_v || src_width == 0 || src_height == 0 ||
|
||||||
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
!dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (src_height < 0) {
|
if (src_height < 0) {
|
||||||
src_height = -src_height;
|
src_height = -src_height;
|
||||||
int halfheight = (src_height + 1) >> 1;
|
int halfheight = Half(src_height);
|
||||||
src_y = src_y + (src_height - 1) * src_stride_y;
|
src_y = src_y + (src_height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (halfheight - 1) * src_stride_v;
|
||||||
@ -3331,17 +3398,17 @@ int I420Scale(const uint8* src_y, int src_stride_y,
|
|||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
}
|
}
|
||||||
int src_halfwidth = (src_width + 1) >> 1;
|
int src_halfwidth = Half(src_width);
|
||||||
int src_halfheight = (src_height + 1) >> 1;
|
int src_halfheight = Half(src_height);
|
||||||
int dst_halfwidth = (dst_width + 1) >> 1;
|
int dst_halfwidth = Half(dst_width);
|
||||||
int dst_halfheight = (dst_height + 1) >> 1;
|
int dst_halfheight = Half(dst_height);
|
||||||
|
|
||||||
#ifdef UNDER_ALLOCATED_HACK
|
#ifdef UNDER_ALLOCATED_HACK
|
||||||
// If caller passed width / 2 for stride, adjust halfwidth to match.
|
// If caller passed width / 2 for stride, adjust halfwidth to match.
|
||||||
if ((src_width & 1) && src_stride_u && src_halfwidth > abs(src_stride_u)) {
|
if ((src_width & 1) && src_stride_u && src_halfwidth > Abs(src_stride_u)) {
|
||||||
src_halfwidth = src_width >> 1;
|
src_halfwidth = src_width >> 1;
|
||||||
}
|
}
|
||||||
if ((dst_width & 1) && dst_stride_u && dst_halfwidth > abs(dst_stride_u)) {
|
if ((dst_width & 1) && dst_stride_u && dst_halfwidth > Abs(dst_stride_u)) {
|
||||||
dst_halfwidth = dst_width >> 1;
|
dst_halfwidth = dst_width >> 1;
|
||||||
}
|
}
|
||||||
// If caller used height / 2 when computing src_v, it will point into what
|
// If caller used height / 2 when computing src_v, it will point into what
|
||||||
@ -3386,7 +3453,7 @@ int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v,
|
|||||||
// Negative height means invert the image.
|
// Negative height means invert the image.
|
||||||
if (src_height < 0) {
|
if (src_height < 0) {
|
||||||
src_height = -src_height;
|
src_height = -src_height;
|
||||||
int halfheight = (src_height + 1) >> 1;
|
int halfheight = Half(src_height);
|
||||||
src_y = src_y + (src_height - 1) * src_stride_y;
|
src_y = src_y + (src_height - 1) * src_stride_y;
|
||||||
src_u = src_u + (halfheight - 1) * src_stride_u;
|
src_u = src_u + (halfheight - 1) * src_stride_u;
|
||||||
src_v = src_v + (halfheight - 1) * src_stride_v;
|
src_v = src_v + (halfheight - 1) * src_stride_v;
|
||||||
@ -3394,18 +3461,18 @@ int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v,
|
|||||||
src_stride_u = -src_stride_u;
|
src_stride_u = -src_stride_u;
|
||||||
src_stride_v = -src_stride_v;
|
src_stride_v = -src_stride_v;
|
||||||
}
|
}
|
||||||
int src_halfwidth = (src_width + 1) >> 1;
|
int src_halfwidth = Half(src_width);
|
||||||
int src_halfheight = (src_height + 1) >> 1;
|
int src_halfheight = Half(src_height);
|
||||||
int dst_halfwidth = (dst_width + 1) >> 1;
|
int dst_halfwidth = Half(dst_width);
|
||||||
int dst_halfheight = (dst_height + 1) >> 1;
|
int dst_halfheight = Half(dst_height);
|
||||||
FilterMode filtering = interpolate ? kFilterBox : kFilterNone;
|
FilterMode filtering = interpolate ? kFilterBox : kFilterNone;
|
||||||
|
|
||||||
#ifdef UNDER_ALLOCATED_HACK
|
#ifdef UNDER_ALLOCATED_HACK
|
||||||
// If caller passed width / 2 for stride, adjust halfwidth to match.
|
// If caller passed width / 2 for stride, adjust halfwidth to match.
|
||||||
if ((src_width & 1) && src_stride_u && src_halfwidth > abs(src_stride_u)) {
|
if ((src_width & 1) && src_stride_u && src_halfwidth > Abs(src_stride_u)) {
|
||||||
src_halfwidth = src_width >> 1;
|
src_halfwidth = src_width >> 1;
|
||||||
}
|
}
|
||||||
if ((dst_width & 1) && dst_stride_u && dst_halfwidth > abs(dst_stride_u)) {
|
if ((dst_width & 1) && dst_stride_u && dst_halfwidth > Abs(dst_stride_u)) {
|
||||||
dst_halfwidth = dst_width >> 1;
|
dst_halfwidth = dst_width >> 1;
|
||||||
}
|
}
|
||||||
// If caller used height / 2 when computing src_v, it will point into what
|
// If caller used height / 2 when computing src_v, it will point into what
|
||||||
@ -3445,10 +3512,10 @@ int ScaleOffset(const uint8* src, int src_width, int src_height,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
dst_yoffset = dst_yoffset & ~1; // chroma requires offset to multiple of 2.
|
dst_yoffset = dst_yoffset & ~1; // chroma requires offset to multiple of 2.
|
||||||
int src_halfwidth = (src_width + 1) >> 1;
|
int src_halfwidth = Half(src_width);
|
||||||
int src_halfheight = (src_height + 1) >> 1;
|
int src_halfheight = Half(src_height);
|
||||||
int dst_halfwidth = (dst_width + 1) >> 1;
|
int dst_halfwidth = Half(dst_width);
|
||||||
int dst_halfheight = (dst_height + 1) >> 1;
|
int dst_halfheight = Half(dst_height);
|
||||||
int aheight = dst_height - dst_yoffset * 2; // actual output height
|
int aheight = dst_height - dst_yoffset * 2; // actual output height
|
||||||
const uint8* src_y = src;
|
const uint8* src_y = src;
|
||||||
const uint8* src_u = src + src_width * src_height;
|
const uint8* src_u = src + src_width * src_height;
|
||||||
|
|||||||
@ -17,17 +17,21 @@
|
|||||||
|
|
||||||
namespace libyuv {
|
namespace libyuv {
|
||||||
|
|
||||||
|
static __inline int Abs(int v) {
|
||||||
|
return v >= 0 ? v : -v;
|
||||||
|
}
|
||||||
|
|
||||||
static int TestFilter(int src_width, int src_height,
|
static int TestFilter(int src_width, int src_height,
|
||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
FilterMode f, int benchmark_iterations) {
|
FilterMode f, int benchmark_iterations) {
|
||||||
const int b = 128;
|
const int b = 128;
|
||||||
int src_width_uv = (src_width + 1) >> 1;
|
int src_width_uv = (Abs(src_width) + 1) >> 1;
|
||||||
int src_height_uv = (src_height + 1) >> 1;
|
int src_height_uv = (Abs(src_height) + 1) >> 1;
|
||||||
|
|
||||||
int src_y_plane_size = (src_width + b * 2) * (src_height + b * 2);
|
int src_y_plane_size = (Abs(src_width) + b * 2) * (Abs(src_height) + b * 2);
|
||||||
int src_uv_plane_size = (src_width_uv + b * 2) * (src_height_uv + b * 2);
|
int src_uv_plane_size = (src_width_uv + b * 2) * (src_height_uv + b * 2);
|
||||||
|
|
||||||
int src_stride_y = b * 2 + src_width;
|
int src_stride_y = b * 2 + Abs(src_width) ;
|
||||||
int src_stride_uv = b * 2 + src_width_uv;
|
int src_stride_uv = b * 2 + src_width_uv;
|
||||||
|
|
||||||
align_buffer_page_end(src_y, src_y_plane_size)
|
align_buffer_page_end(src_y, src_y_plane_size)
|
||||||
@ -46,8 +50,8 @@ static int TestFilter(int src_width, int src_height,
|
|||||||
srandom(time(NULL));
|
srandom(time(NULL));
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
for (i = b; i < (src_height + b); ++i) {
|
for (i = b; i < (Abs(src_height) + b); ++i) {
|
||||||
for (j = b; j < (src_width + b); ++j) {
|
for (j = b; j < (Abs(src_width) + b); ++j) {
|
||||||
src_y[(i * src_stride_y) + j] = (random() & 0xff);
|
src_y[(i * src_stride_y) + j] = (random() & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,8 +168,8 @@ static int TestFilter(int src_width, int src_height,
|
|||||||
TEST_F(libyuvTest, ScaleDownBy2_None) {
|
TEST_F(libyuvTest, ScaleDownBy2_None) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 2;
|
const int dst_width = Abs(src_width) / 2;
|
||||||
const int dst_height = src_height / 2;
|
const int dst_height = Abs(src_height) / 2;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -177,8 +181,8 @@ TEST_F(libyuvTest, ScaleDownBy2_None) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy2_Bilinear) {
|
TEST_F(libyuvTest, ScaleDownBy2_Bilinear) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 2;
|
const int dst_width = Abs(src_width) / 2;
|
||||||
const int dst_height = src_height / 2;
|
const int dst_height = Abs(src_height) / 2;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -190,8 +194,8 @@ TEST_F(libyuvTest, ScaleDownBy2_Bilinear) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy2_Box) {
|
TEST_F(libyuvTest, ScaleDownBy2_Box) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 2;
|
const int dst_width = Abs(src_width) / 2;
|
||||||
const int dst_height = src_height / 2;
|
const int dst_height = Abs(src_height) / 2;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -203,8 +207,8 @@ TEST_F(libyuvTest, ScaleDownBy2_Box) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy4_None) {
|
TEST_F(libyuvTest, ScaleDownBy4_None) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 4;
|
const int dst_width = Abs(src_width) / 4;
|
||||||
const int dst_height = src_height / 4;
|
const int dst_height = Abs(src_height) / 4;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -216,8 +220,8 @@ TEST_F(libyuvTest, ScaleDownBy4_None) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy4_Bilinear) {
|
TEST_F(libyuvTest, ScaleDownBy4_Bilinear) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 4;
|
const int dst_width = Abs(src_width) / 4;
|
||||||
const int dst_height = src_height / 4;
|
const int dst_height = Abs(src_height) / 4;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -229,8 +233,8 @@ TEST_F(libyuvTest, ScaleDownBy4_Bilinear) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy4_Box) {
|
TEST_F(libyuvTest, ScaleDownBy4_Box) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 4;
|
const int dst_width = Abs(src_width) / 4;
|
||||||
const int dst_height = src_height / 4;
|
const int dst_height = Abs(src_height) / 4;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -242,8 +246,8 @@ TEST_F(libyuvTest, ScaleDownBy4_Box) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy5_None) {
|
TEST_F(libyuvTest, ScaleDownBy5_None) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 5;
|
const int dst_width = Abs(src_width) / 5;
|
||||||
const int dst_height = src_height / 5;
|
const int dst_height = Abs(src_height) / 5;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -255,8 +259,8 @@ TEST_F(libyuvTest, ScaleDownBy5_None) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy5_Bilinear) {
|
TEST_F(libyuvTest, ScaleDownBy5_Bilinear) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 5;
|
const int dst_width = Abs(src_width) / 5;
|
||||||
const int dst_height = src_height / 5;
|
const int dst_height = Abs(src_height) / 5;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -268,8 +272,8 @@ TEST_F(libyuvTest, ScaleDownBy5_Bilinear) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy5_Box) {
|
TEST_F(libyuvTest, ScaleDownBy5_Box) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 5;
|
const int dst_width = Abs(src_width) / 5;
|
||||||
const int dst_height = src_height / 5;
|
const int dst_height = Abs(src_height) / 5;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -281,8 +285,8 @@ TEST_F(libyuvTest, ScaleDownBy5_Box) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy8_None) {
|
TEST_F(libyuvTest, ScaleDownBy8_None) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 8;
|
const int dst_width = Abs(src_width) / 8;
|
||||||
const int dst_height = src_height / 8;
|
const int dst_height = Abs(src_height) / 8;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -294,8 +298,8 @@ TEST_F(libyuvTest, ScaleDownBy8_None) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy8_Bilinear) {
|
TEST_F(libyuvTest, ScaleDownBy8_Bilinear) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 8;
|
const int dst_width = Abs(src_width) / 8;
|
||||||
const int dst_height = src_height / 8;
|
const int dst_height = Abs(src_height) / 8;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -307,8 +311,8 @@ TEST_F(libyuvTest, ScaleDownBy8_Bilinear) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy8_Box) {
|
TEST_F(libyuvTest, ScaleDownBy8_Box) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 8;
|
const int dst_width = Abs(src_width) / 8;
|
||||||
const int dst_height = src_height / 8;
|
const int dst_height = Abs(src_height) / 8;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -320,8 +324,8 @@ TEST_F(libyuvTest, ScaleDownBy8_Box) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy16_None) {
|
TEST_F(libyuvTest, ScaleDownBy16_None) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 16;
|
const int dst_width = Abs(src_width) / 16;
|
||||||
const int dst_height = src_height / 16;
|
const int dst_height = Abs(src_height) / 16;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -333,8 +337,8 @@ TEST_F(libyuvTest, ScaleDownBy16_None) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy16_Bilinear) {
|
TEST_F(libyuvTest, ScaleDownBy16_Bilinear) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 16;
|
const int dst_width = Abs(src_width) / 16;
|
||||||
const int dst_height = src_height / 16;
|
const int dst_height = Abs(src_height) / 16;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -346,8 +350,8 @@ TEST_F(libyuvTest, ScaleDownBy16_Bilinear) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy16_Box) {
|
TEST_F(libyuvTest, ScaleDownBy16_Box) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width / 16;
|
const int dst_width = Abs(src_width) / 16;
|
||||||
const int dst_height = src_height / 16;
|
const int dst_height = Abs(src_height) / 16;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -359,8 +363,8 @@ TEST_F(libyuvTest, ScaleDownBy16_Box) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy34_None) {
|
TEST_F(libyuvTest, ScaleDownBy34_None) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width * 3 / 4;
|
const int dst_width = Abs(src_width) * 3 / 4;
|
||||||
const int dst_height = src_height * 3 / 4;
|
const int dst_height = Abs(src_height) * 3 / 4;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -372,8 +376,8 @@ TEST_F(libyuvTest, ScaleDownBy34_None) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy34_Bilinear) {
|
TEST_F(libyuvTest, ScaleDownBy34_Bilinear) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width * 3 / 4;
|
const int dst_width = Abs(src_width) * 3 / 4;
|
||||||
const int dst_height = src_height * 3 / 4;
|
const int dst_height = Abs(src_height) * 3 / 4;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -385,8 +389,8 @@ TEST_F(libyuvTest, ScaleDownBy34_Bilinear) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy34_Box) {
|
TEST_F(libyuvTest, ScaleDownBy34_Box) {
|
||||||
const int src_width = benchmark_width_;
|
const int src_width = benchmark_width_;
|
||||||
const int src_height = benchmark_height_;
|
const int src_height = benchmark_height_;
|
||||||
const int dst_width = src_width * 3 / 4;
|
const int dst_width = Abs(src_width) * 3 / 4;
|
||||||
const int dst_height = src_height * 3 / 4;
|
const int dst_height = Abs(src_height) * 3 / 4;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -398,8 +402,8 @@ TEST_F(libyuvTest, ScaleDownBy34_Box) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy38_None) {
|
TEST_F(libyuvTest, ScaleDownBy38_None) {
|
||||||
int src_width = benchmark_width_;
|
int src_width = benchmark_width_;
|
||||||
int src_height = benchmark_height_;
|
int src_height = benchmark_height_;
|
||||||
int dst_width = src_width * 3 / 8;
|
int dst_width = Abs(src_width) * 3 / 8;
|
||||||
int dst_height = src_height * 3 / 8;
|
int dst_height = Abs(src_height) * 3 / 8;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -411,8 +415,8 @@ TEST_F(libyuvTest, ScaleDownBy38_None) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy38_Bilinear) {
|
TEST_F(libyuvTest, ScaleDownBy38_Bilinear) {
|
||||||
int src_width = benchmark_width_;
|
int src_width = benchmark_width_;
|
||||||
int src_height = benchmark_height_;
|
int src_height = benchmark_height_;
|
||||||
int dst_width = src_width * 3 / 8;
|
int dst_width = Abs(src_width) * 3 / 8;
|
||||||
int dst_height = src_height * 3 / 8;
|
int dst_height = Abs(src_height) * 3 / 8;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -424,8 +428,8 @@ TEST_F(libyuvTest, ScaleDownBy38_Bilinear) {
|
|||||||
TEST_F(libyuvTest, ScaleDownBy38_Box) {
|
TEST_F(libyuvTest, ScaleDownBy38_Box) {
|
||||||
int src_width = benchmark_width_;
|
int src_width = benchmark_width_;
|
||||||
int src_height = benchmark_height_;
|
int src_height = benchmark_height_;
|
||||||
int dst_width = src_width * 3 / 8;
|
int dst_width = Abs(src_width) * 3 / 8;
|
||||||
int dst_height = src_height * 3 / 8;
|
int dst_height = Abs(src_height) * 3 / 8;
|
||||||
|
|
||||||
int max_diff = TestFilter(src_width, src_height,
|
int max_diff = TestFilter(src_width, src_height,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -535,7 +539,7 @@ TEST_F(libyuvTest, ScaleTo853x480_Bilinear) {
|
|||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
kFilterBilinear,
|
kFilterBilinear,
|
||||||
benchmark_iterations_);
|
benchmark_iterations_);
|
||||||
EXPECT_LE(max_diff, 1);
|
EXPECT_LE(max_diff, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(libyuvTest, ScaleTo853x480_Box) {
|
TEST_F(libyuvTest, ScaleTo853x480_Box) {
|
||||||
@ -548,7 +552,7 @@ TEST_F(libyuvTest, ScaleTo853x480_Box) {
|
|||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
kFilterBox,
|
kFilterBox,
|
||||||
benchmark_iterations_);
|
benchmark_iterations_);
|
||||||
EXPECT_LE(max_diff, 1);
|
EXPECT_LE(max_diff, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(libyuvTest, ScaleFrom640x360_None) {
|
TEST_F(libyuvTest, ScaleFrom640x360_None) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user