Commit 88ce3c0c authored by fbarchard@google.com's avatar fbarchard@google.com

Change unittests to pass when size is 1 tall.

BUG=202
TEST=set LIBYUV_HEIGHT=1 & out\release\libyuv_unittest
R=ryanpetrie@google.com

Review URL: https://webrtc-codereview.appspot.com/2391004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@811 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 7f67961e
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 810 Version: 811
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 810 #define LIBYUV_VERSION 811
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -1664,12 +1664,13 @@ void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride, ...@@ -1664,12 +1664,13 @@ void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride,
assert(src_height > 0); assert(src_height > 0);
for (int x = 0; x < src_width; ++x) { for (int x = 0; x < src_width; ++x) {
const uint8* s = src_ptr + x; const uint8* s = src_ptr + x;
int sum = 0; unsigned int sum = 0u;
for (int y = 0; y < src_height; ++y) { for (int y = 0; y < src_height; ++y) {
sum += s[0]; sum += s[0];
s += src_stride; s += src_stride;
} }
dst_ptr[x] = sum; // TODO(fbarchard): Consider limitting height to 256 to avoid overflow.
dst_ptr[x] = sum < 65535u ? sum : 65535u;
} }
} }
......
...@@ -286,7 +286,7 @@ TEST_F(libyuvTest, Psnr) { ...@@ -286,7 +286,7 @@ TEST_F(libyuvTest, Psnr) {
src_b + kSrcStride * b + b, kSrcStride, src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight); kSrcWidth, kSrcHeight);
EXPECT_GT(err, 4.0); EXPECT_GT(err, 2.0);
if (kSrcWidth * kSrcHeight >= 256) { if (kSrcWidth * kSrcHeight >= 256) {
EXPECT_LT(err, 5.0); EXPECT_LT(err, 5.0);
} }
......
...@@ -389,12 +389,14 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ ...@@ -389,12 +389,14 @@ TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
TESTBIPLANARTOP(NV12, 2, 2, I420, 2, 2) TESTBIPLANARTOP(NV12, 2, 2, I420, 2, 2)
TESTBIPLANARTOP(NV21, 2, 2, I420, 2, 2) TESTBIPLANARTOP(NV21, 2, 2, I420, 2, 2)
#define ALIGNINT(V, ALIGN) (((V) + (ALIGN) - 1) / (ALIGN) * (ALIGN))
#define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ #define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \
TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
const int kHeight = benchmark_height_; \ const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
const int kStrideB = ((kWidth * BPP_B + ALIGN - 1) / ALIGN) * ALIGN; \ const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \
const int kSizeUV = \ const int kSizeUV = \
SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \
align_buffer_64(src_y, kWidth * kHeight + OFF); \ align_buffer_64(src_y, kWidth * kHeight + OFF); \
...@@ -457,40 +459,41 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ ...@@ -457,40 +459,41 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
} }
#define TESTPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ #define TESTPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
DIFF, FMT_C, BPP_C) \ YALIGN, DIFF, FMT_C, BPP_C) \
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \ YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \ YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \ YALIGN, benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
benchmark_width_, DIFF, _Opt, +, 0, FMT_C, BPP_C) YALIGN, benchmark_width_, DIFF, _Opt, +, 0, FMT_C, BPP_C)
TESTPLANARTOB(I420, 2, 2, ARGB, 4, 4, 2, ARGB, 4) // TODO(fbarchard): Make vertical alignment unnecessary on bayer.
TESTPLANARTOB(I420, 2, 2, BGRA, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, ARGB, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, ABGR, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, BGRA, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, RGBA, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, ABGR, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, RAW, 3, 3, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, RGBA, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, RGB24, 3, 3, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, RAW, 3, 3, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, RGB565, 2, 2, 9, ARGB, 4) TESTPLANARTOB(I420, 2, 2, RGB24, 3, 3, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, ARGB1555, 2, 2, 9, ARGB, 4) TESTPLANARTOB(I420, 2, 2, RGB565, 2, 2, 1, 9, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, ARGB4444, 2, 2, 17, ARGB, 4) TESTPLANARTOB(I420, 2, 2, ARGB1555, 2, 2, 1, 9, ARGB, 4)
TESTPLANARTOB(I422, 2, 1, ARGB, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, ARGB4444, 2, 2, 1, 17, ARGB, 4)
TESTPLANARTOB(I422, 2, 1, BGRA, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I422, 2, 1, ARGB, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I422, 2, 1, ABGR, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I422, 2, 1, BGRA, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I422, 2, 1, RGBA, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I422, 2, 1, ABGR, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I411, 4, 1, ARGB, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I422, 2, 1, RGBA, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I444, 1, 1, ARGB, 4, 4, 2, ARGB, 4) TESTPLANARTOB(I411, 4, 1, ARGB, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, YUY2, 2, 4, 1, ARGB, 4) TESTPLANARTOB(I444, 1, 1, ARGB, 4, 4, 1, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, UYVY, 2, 4, 1, ARGB, 4) TESTPLANARTOB(I420, 2, 2, YUY2, 2, 4, 1, 1, ARGB, 4)
TESTPLANARTOB(I422, 2, 1, YUY2, 2, 4, 0, ARGB, 4) TESTPLANARTOB(I420, 2, 2, UYVY, 2, 4, 1, 1, ARGB, 4)
TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4, 0, ARGB, 4) TESTPLANARTOB(I422, 2, 1, YUY2, 2, 4, 1, 0, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 0, ARGB, 4) TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4, 1, 0, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, BayerBGGR, 1, 1, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 1, 0, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, BayerRGGB, 1, 1, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, BayerBGGR, 1, 2, 2, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, BayerGBRG, 1, 1, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, BayerRGGB, 1, 2, 2, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, BayerGRBG, 1, 1, 2, ARGB, 4) TESTPLANARTOB(I420, 2, 2, BayerGBRG, 1, 2, 2, 2, ARGB, 4)
TESTPLANARTOB(I420, 2, 2, BayerGRBG, 1, 2, 2, 2, ARGB, 4)
#define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \
W1280, DIFF, N, NEG, OFF) \ W1280, DIFF, N, NEG, OFF) \
...@@ -571,11 +574,11 @@ TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4, 2) ...@@ -571,11 +574,11 @@ TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4, 2)
TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2, 9) TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2, 9)
TESTBIPLANARTOB(NV21, 2, 2, RGB565, 2, 9) TESTBIPLANARTOB(NV21, 2, 2, RGB565, 2, 9)
#define TESTATOPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ #define TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
W1280, DIFF, N, NEG, OFF) \ W1280, DIFF, N, NEG, OFF) \
TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
const int kHeight = benchmark_height_; \ const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \
const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \ const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \
align_buffer_64(src_argb, kStride * kHeight + OFF); \ align_buffer_64(src_argb, kStride * kHeight + OFF); \
align_buffer_64(dst_y_c, kWidth * kHeight); \ align_buffer_64(dst_y_c, kWidth * kHeight); \
...@@ -667,43 +670,44 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \ ...@@ -667,43 +670,44 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \
free_aligned_buffer_64(src_argb) \ free_aligned_buffer_64(src_argb) \
} }
#define TESTATOPLANAR(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, DIFF) \ #define TESTATOPLANAR(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
TESTATOPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ DIFF) \
TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
benchmark_width_ - 4, DIFF, _Any, +, 0) \ benchmark_width_ - 4, DIFF, _Any, +, 0) \
TESTATOPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
benchmark_width_, DIFF, _Unaligned, +, 1) \ benchmark_width_, DIFF, _Unaligned, +, 1) \
TESTATOPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
benchmark_width_, DIFF, _Invert, -, 0) \ benchmark_width_, DIFF, _Invert, -, 0) \
TESTATOPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
benchmark_width_, DIFF, _Opt, +, 0) benchmark_width_, DIFF, _Opt, +, 0)
TESTATOPLANAR(ARGB, 4, I420, 2, 2, 4) TESTATOPLANAR(ARGB, 4, 1, I420, 2, 2, 4)
#ifdef __arm__ #ifdef __arm__
TESTATOPLANAR(ARGB, 4, J420, 2, 2, 4) TESTATOPLANAR(ARGB, 4, 1, J420, 2, 2, 4)
#else #else
TESTATOPLANAR(ARGB, 4, J420, 2, 2, 0) TESTATOPLANAR(ARGB, 4, 1, J420, 2, 2, 0)
#endif #endif
TESTATOPLANAR(BGRA, 4, I420, 2, 2, 4) TESTATOPLANAR(BGRA, 4, 1, I420, 2, 2, 4)
TESTATOPLANAR(ABGR, 4, I420, 2, 2, 4) TESTATOPLANAR(ABGR, 4, 1, I420, 2, 2, 4)
TESTATOPLANAR(RGBA, 4, I420, 2, 2, 4) TESTATOPLANAR(RGBA, 4, 1, I420, 2, 2, 4)
TESTATOPLANAR(RAW, 3, I420, 2, 2, 4) TESTATOPLANAR(RAW, 3, 1, I420, 2, 2, 4)
TESTATOPLANAR(RGB24, 3, I420, 2, 2, 4) TESTATOPLANAR(RGB24, 3, 1, I420, 2, 2, 4)
TESTATOPLANAR(RGB565, 2, I420, 2, 2, 5) TESTATOPLANAR(RGB565, 2, 1, I420, 2, 2, 5)
// TODO(fbarchard): Make 1555 neon work same as C code, reduce to diff 9. // TODO(fbarchard): Make 1555 neon work same as C code, reduce to diff 9.
TESTATOPLANAR(ARGB1555, 2, I420, 2, 2, 15) TESTATOPLANAR(ARGB1555, 2, 1, I420, 2, 2, 15)
TESTATOPLANAR(ARGB4444, 2, I420, 2, 2, 17) TESTATOPLANAR(ARGB4444, 2, 1, I420, 2, 2, 17)
TESTATOPLANAR(ARGB, 4, I411, 4, 1, 4) TESTATOPLANAR(ARGB, 4, 1, I411, 4, 1, 4)
TESTATOPLANAR(ARGB, 4, I422, 2, 1, 2) TESTATOPLANAR(ARGB, 4, 1, I422, 2, 1, 2)
TESTATOPLANAR(ARGB, 4, I444, 1, 1, 2) TESTATOPLANAR(ARGB, 4, 1, I444, 1, 1, 2)
TESTATOPLANAR(YUY2, 2, I420, 2, 2, 2) TESTATOPLANAR(YUY2, 2, 1, I420, 2, 2, 2)
TESTATOPLANAR(UYVY, 2, I420, 2, 2, 2) TESTATOPLANAR(UYVY, 2, 1, I420, 2, 2, 2)
TESTATOPLANAR(YUY2, 2, I422, 2, 1, 2) TESTATOPLANAR(YUY2, 2, 1, I422, 2, 1, 2)
TESTATOPLANAR(UYVY, 2, I422, 2, 1, 2) TESTATOPLANAR(UYVY, 2, 1, I422, 2, 1, 2)
TESTATOPLANAR(I400, 1, I420, 2, 2, 2) TESTATOPLANAR(I400, 1, 1, I420, 2, 2, 2)
TESTATOPLANAR(BayerBGGR, 1, I420, 2, 2, 4) TESTATOPLANAR(BayerBGGR, 1, 2, I420, 2, 2, 4)
TESTATOPLANAR(BayerRGGB, 1, I420, 2, 2, 4) TESTATOPLANAR(BayerRGGB, 1, 2, I420, 2, 2, 4)
TESTATOPLANAR(BayerGBRG, 1, I420, 2, 2, 4) TESTATOPLANAR(BayerGBRG, 1, 2, I420, 2, 2, 4)
TESTATOPLANAR(BayerGRBG, 1, I420, 2, 2, 4) TESTATOPLANAR(BayerGRBG, 1, 2, I420, 2, 2, 4)
#define TESTATOBIPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ #define TESTATOBIPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
W1280, N, NEG, OFF) \ W1280, N, NEG, OFF) \
......
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