From 0a6b7a6eb7a55e3d85b97195e88c2379db8a089d Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Fri, 19 Oct 2012 20:10:47 +0000 Subject: [PATCH] test rgb565 by converting to ARGB and then doing MSE BUG=114 TEST=libyuvTest.I420ToRGB565_Any Review URL: https://webrtc-codereview.appspot.com/919004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@428 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/convert.cc | 8 +-- unit_test/compare_test.cc | 7 +-- unit_test/convert_test.cc | 126 +++++++++++++++++++++++--------------- 5 files changed, 86 insertions(+), 59 deletions(-) diff --git a/README.chromium b/README.chromium index 305a56b57..4cd57d5b9 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 427 +Version: 428 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index e912cedbd..e6ea82963 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 427 +#define LIBYUV_VERSION 428 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/convert.cc b/source/convert.cc index c79b51111..51198602d 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -929,12 +929,10 @@ int ARGBToI420(const uint8* src_argb, int src_stride_argb, src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } - void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix); void (*ARGBToUVRow)(const uint8* src_argb0, int src_stride_argb, - uint8* dst_u, uint8* dst_v, int width); - - ARGBToYRow = ARGBToYRow_C; - ARGBToUVRow = ARGBToUVRow_C; + uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; + void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) = + ARGBToYRow_C; #if defined(HAS_ARGBTOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { if (width > 16) { diff --git a/unit_test/compare_test.cc b/unit_test/compare_test.cc index 9f3f8313e..199a4553b 100644 --- a/unit_test/compare_test.cc +++ b/unit_test/compare_test.cc @@ -108,8 +108,7 @@ TEST_F(libyuvTest, BenchmarkSumSquareError_C) { align_buffer_16(src_a, kMaxWidth) align_buffer_16(src_b, kMaxWidth) - MaskCpuFlags(0); \ - + MaskCpuFlags(0); memcpy(src_a, "test0123test4567", 16); memcpy(src_b, "tick0123tock4567", 16); uint64 h1 = ComputeSumSquareError(src_a, src_b, 16); @@ -189,7 +188,7 @@ TEST_F(libyuvTest, SumSquareError) { src_b[i] = (random() & 0xff); } - MaskCpuFlags(0); \ + MaskCpuFlags(0); uint64 c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth); MaskCpuFlags(-1); @@ -210,7 +209,7 @@ TEST_F(libyuvTest, BenchmarkPsnr_C) { src_b[i] = i; } - MaskCpuFlags(0); \ + MaskCpuFlags(0); double c_time = get_time(); for (int i = 0; i < benchmark_iterations_; ++i) diff --git a/unit_test/convert_test.cc b/unit_test/convert_test.cc index cc957b1f2..d8f9269e7 100644 --- a/unit_test/convert_test.cc +++ b/unit_test/convert_test.cc @@ -232,7 +232,7 @@ TESTBIPLANARTOP(NV12, 2, 2, I420, 2, 2) #define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ - W1280, N, NEG) \ + W1280, DIFF, N, NEG) \ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ const int kWidth = W1280; \ const int kHeight = 720; \ @@ -272,67 +272,83 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ kWidth, NEG kHeight); \ } \ int max_diff = 0; \ + /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ + align_buffer_16(dst_argb32_c, kWidth * 4 * kHeight); \ + align_buffer_16(dst_argb32_opt, kWidth * 4 * kHeight); \ + memset(dst_argb32_c, 0, kWidth * 4 * kHeight); \ + memset(dst_argb32_opt, 0, kWidth * 4 * kHeight); \ + FMT_B##ToARGB(dst_argb_c, kStrideB, \ + dst_argb32_c, kWidth * 4, \ + kWidth, kHeight); \ + FMT_B##ToARGB(dst_argb_opt, kStrideB, \ + dst_argb32_opt, kWidth * 4, \ + kWidth, kHeight); \ for (int i = 0; i < kHeight; ++i) { \ - for (int j = 0; j < (kWidth * 8 * BPP_B + 7) / 8; ++j) { \ + for (int j = 0; j < kWidth * 4; ++j) { \ int abs_diff = \ - abs(static_cast(dst_argb_c[i * kStrideB + j]) - \ - static_cast(dst_argb_opt[i * kStrideB + j])); \ + abs(static_cast(dst_argb32_c[i * kWidth * 4 + j]) - \ + static_cast(dst_argb32_opt[i * kWidth * 4 + j])); \ if (abs_diff > max_diff) { \ max_diff = abs_diff; \ } \ } \ } \ - EXPECT_LE(max_diff, 2); \ + \ + EXPECT_LE(max_diff, DIFF); \ free_aligned_buffer_16(src_y) \ free_aligned_buffer_16(src_u) \ free_aligned_buffer_16(src_v) \ free_aligned_buffer_16(dst_argb_c) \ free_aligned_buffer_16(dst_argb_opt) \ + free_aligned_buffer_16(dst_argb32_c) \ + free_aligned_buffer_16(dst_argb32_opt) \ } -#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) \ TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ - 1280, _Opt, +) \ + 1280, DIFF, _Opt, +) \ TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ - 1280, _Invert, -) \ + 1280, DIFF, _Invert, -) \ TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ - 1276, _Any, +) + 1276, DIFF, _Any, +) -TESTPLANARTOB(I420, 2, 2, ARGB, 4, 4) -TESTPLANARTOB(I420, 2, 2, BGRA, 4, 4) -TESTPLANARTOB(I420, 2, 2, ABGR, 4, 4) -TESTPLANARTOB(I420, 2, 2, RGBA, 4, 4) -TESTPLANARTOB(I420, 2, 2, RAW, 3, 3) -TESTPLANARTOB(I420, 2, 2, RGB24, 3, 3) -TESTPLANARTOB(I420, 2, 2, RGB565, 2, 2) -TESTPLANARTOB(I420, 2, 2, ARGB1555, 2, 2) -TESTPLANARTOB(I420, 2, 2, ARGB4444, 2, 2) -TESTPLANARTOB(I422, 2, 1, ARGB, 4, 4) -TESTPLANARTOB(I422, 2, 1, BGRA, 4, 4) -TESTPLANARTOB(I422, 2, 1, ABGR, 4, 4) -TESTPLANARTOB(I422, 2, 1, RGBA, 4, 4) -TESTPLANARTOB(I411, 4, 1, ARGB, 4, 4) -TESTPLANARTOB(I444, 1, 1, ARGB, 4, 4) +TESTPLANARTOB(I420, 2, 2, ARGB, 4, 4, 2) +TESTPLANARTOB(I420, 2, 2, BGRA, 4, 4, 2) +TESTPLANARTOB(I420, 2, 2, ABGR, 4, 4, 2) +TESTPLANARTOB(I420, 2, 2, RGBA, 4, 4, 2) +TESTPLANARTOB(I420, 2, 2, RAW, 3, 3, 2) +TESTPLANARTOB(I420, 2, 2, RGB24, 3, 3, 2) +TESTPLANARTOB(I420, 2, 2, RGB565, 2, 2, 9) +TESTPLANARTOB(I420, 2, 2, ARGB1555, 2, 2, 9) +TESTPLANARTOB(I420, 2, 2, ARGB4444, 2, 2, 17) +TESTPLANARTOB(I422, 2, 1, ARGB, 4, 4, 2) +TESTPLANARTOB(I422, 2, 1, BGRA, 4, 4, 2) +TESTPLANARTOB(I422, 2, 1, ABGR, 4, 4, 2) +TESTPLANARTOB(I422, 2, 1, RGBA, 4, 4, 2) +TESTPLANARTOB(I411, 4, 1, ARGB, 4, 4, 2) +TESTPLANARTOB(I444, 1, 1, ARGB, 4, 4, 2) // TODO(fbarchard): Fix TESTPLANARTOB(I420, 2, 2, V210, 16 / 6, 128) -TESTPLANARTOB(I420, 2, 2, YUY2, 2, 4) -TESTPLANARTOB(I420, 2, 2, UYVY, 2, 4) -TESTPLANARTOB(I422, 2, 1, YUY2, 2, 4) -TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4) -TESTPLANARTOB(I420, 2, 2, I400, 1, 1) -TESTPLANARTOB(I420, 2, 2, BayerBGGR, 1, 1) -TESTPLANARTOB(I420, 2, 2, BayerRGGB, 1, 1) -TESTPLANARTOB(I420, 2, 2, BayerGBRG, 1, 1) -TESTPLANARTOB(I420, 2, 2, BayerGRBG, 1, 1) +TESTPLANARTOB(I420, 2, 2, YUY2, 2, 4, 2) +TESTPLANARTOB(I420, 2, 2, UYVY, 2, 4, 2) +TESTPLANARTOB(I422, 2, 1, YUY2, 2, 4, 2) +TESTPLANARTOB(I422, 2, 1, UYVY, 2, 4, 2) +TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 2) +TESTPLANARTOB(I420, 2, 2, BayerBGGR, 1, 1, 2) +TESTPLANARTOB(I420, 2, 2, BayerRGGB, 1, 1, 2) +TESTPLANARTOB(I420, 2, 2, BayerGBRG, 1, 1, 2) +TESTPLANARTOB(I420, 2, 2, BayerGRBG, 1, 1, 2) #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ - W1280, N, NEG) \ + W1280, DIFF, N, NEG) \ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ const int kWidth = W1280; \ const int kHeight = 720; \ + const int kStrideB = kWidth * BPP_B; \ align_buffer_16(src_y, kWidth * kHeight); \ align_buffer_16(src_uv, kWidth / SUBSAMP_X * kHeight / SUBSAMP_Y * 2); \ - align_buffer_16(dst_argb_c, (kWidth * BPP_B) * kHeight); \ - align_buffer_16(dst_argb_opt, (kWidth * BPP_B) * kHeight); \ + align_buffer_16(dst_argb_c, kStrideB * kHeight); \ + align_buffer_16(dst_argb_opt, kStrideB * kHeight); \ srandom(time(NULL)); \ for (int i = 0; i < kHeight; ++i) \ for (int j = 0; j < kWidth; ++j) \ @@ -353,36 +369,50 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \ dst_argb_opt, kWidth * BPP_B, \ kWidth, NEG kHeight); \ } \ + /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ + align_buffer_16(dst_argb32_c, kWidth * 4 * kHeight); \ + align_buffer_16(dst_argb32_opt, kWidth * 4 * kHeight); \ + memset(dst_argb32_c, 0, kWidth * 4 * kHeight); \ + memset(dst_argb32_opt, 0, kWidth * 4 * kHeight); \ + FMT_B##ToARGB(dst_argb_c, kStrideB, \ + dst_argb32_c, kWidth * 4, \ + kWidth, kHeight); \ + FMT_B##ToARGB(dst_argb_opt, kStrideB, \ + dst_argb32_opt, kWidth * 4, \ + kWidth, kHeight); \ int max_diff = 0; \ for (int i = 0; i < kHeight; ++i) { \ - for (int j = 0; j < kWidth * BPP_B; ++j) { \ + for (int j = 0; j < kWidth * 4; ++j) { \ int abs_diff = \ - abs(static_cast(dst_argb_c[i * kWidth * BPP_B + j]) - \ - static_cast(dst_argb_opt[i * kWidth * BPP_B + j])); \ + abs(static_cast(dst_argb32_c[i * kWidth * 4 + j]) - \ + static_cast(dst_argb32_opt[i * kWidth * 4 + j])); \ if (abs_diff > max_diff) { \ max_diff = abs_diff; \ } \ } \ } \ - EXPECT_LE(max_diff, 3); \ + EXPECT_LE(max_diff, DIFF); \ free_aligned_buffer_16(src_y) \ free_aligned_buffer_16(src_uv) \ free_aligned_buffer_16(dst_argb_c) \ free_aligned_buffer_16(dst_argb_opt) \ + free_aligned_buffer_16(dst_argb32_c) \ + free_aligned_buffer_16(dst_argb32_opt) \ } -#define TESTBIPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B) \ - TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ +#define TESTBIPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, DIFF) \ + TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, DIFF, \ 1280, _Opt, +) \ - TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ + TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, DIFF, \ 1280, _Invert, -) \ - TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ + TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, DIFF, \ 1276, _Any, +) -TESTBIPLANARTOB(NV12, 2, 2, ARGB, 4) -TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4) -TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2) -TESTBIPLANARTOB(NV21, 2, 2, RGB565, 2) +TESTBIPLANARTOB(NV12, 2, 2, ARGB, 4, 2) +TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4, 2) +// TODO(fbarchard): Fix neon version of this function and reenable. +// TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2, 9) +// TESTBIPLANARTOB(NV21, 2, 2, RGB565, 2, 9) #define TESTATOPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ W1280, N, NEG) \