From b4a1182ffd8e1918bd1acda0ba27d895ac86c383 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Thu, 31 May 2012 18:15:51 +0000 Subject: [PATCH] Add LIBYUV_SVNREVISION macro and planar unittest fix/improvement BUG=30 TESTED=libyuvTest.TestVersion Review URL: https://webrtc-codereview.appspot.com/619007 git-svn-id: http://libyuv.googlecode.com/svn/trunk@274 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/planar_functions.h | 9 ++-- include/libyuv/version.h | 2 +- libyuv_test.gyp | 6 ++- unit_test/cpu_test.cc | 4 -- unit_test/planar_test.cc | 77 +++++++++++++++++++++++++------ unit_test/version_test.cc | 34 ++++++++++++++ 7 files changed, 110 insertions(+), 24 deletions(-) create mode 100644 unit_test/version_test.cc diff --git a/README.chromium b/README.chromium index 798f0d105..8f5266f1f 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 273 +Version: 274 License: BSD License File: LICENSE diff --git a/include/libyuv/planar_functions.h b/include/libyuv/planar_functions.h index 1ffa5bd02..c1a1cdd74 100644 --- a/include/libyuv/planar_functions.h +++ b/include/libyuv/planar_functions.h @@ -86,19 +86,22 @@ int RAWToARGB(const uint8* src_raw, int src_stride_raw, uint8* dst_argb, int dst_stride_argb, int width, int height); +// Deprecated function name. +#define BG24ToARGB RGB24ToARGB + // Convert RGB24 to ARGB. int RGB24ToARGB(const uint8* src_bg24, int src_stride_bg24, uint8* dst_argb, int dst_stride_argb, int width, int height); -// Deprecated function name. -#define BG24ToARGB RGB24ToARGB - // Convert ABGR to ARGB. Also used for ARGB to ABGR. int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr, uint8* dst_argb, int dst_stride_argb, int width, int height); +// Palindromes. +#define ARGBToBGRA BGRAToARGB + // Convert BGRA to ARGB. Also used for ARGB to BGRA. int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra, uint8* dst_argb, int dst_stride_argb, diff --git a/include/libyuv/version.h b/include/libyuv/version.h index eaab28dcd..8f99aaa80 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,7 +11,7 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 273 +#define LIBYUV_VERSION 274 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/libyuv_test.gyp b/libyuv_test.gyp index 64fa95d09..5b1764c68 100644 --- a/libyuv_test.gyp +++ b/libyuv_test.gyp @@ -9,7 +9,7 @@ { 'targets': [ { - 'target_name': 'libyuv_unittest', + 'target_name': 'libyuv_unittest', 'type': 'executable', 'dependencies': [ 'libyuv.gyp:libyuv', @@ -17,6 +17,9 @@ 'testing/gtest.gyp:gtest', 'testing/gtest.gyp:gtest_main', ], + 'defines': [ + 'LIBYUV_SVNREVISION="> 2); \ align_buffer_16(src_v, (src_width * src_height) >> 2); \ - align_buffer_16(dst_rgb_c, (src_width << 2) * src_height); \ - align_buffer_16(dst_rgb_opt, (src_width << 2) * src_height); \ + align_buffer_16(dst_rgb_c, (src_width * BPP) * src_height); \ + align_buffer_16(dst_rgb_opt, (src_width * BPP) * src_height); \ srandom(time(NULL)); \ for (int i = 0; i < src_height; ++i) \ for (int j = 0; j < src_width; ++j) \ - src_y[(i * src_height) + j] = (random() & 0xff); \ + src_y[(i * src_width) + j] = (random() & 0xff); \ for (int i = 0; i < src_height >> 1; ++i) \ for (int j = 0; j < src_width >> 1; ++j) { \ - src_u[(i * src_height >> 1) + j] = (random() & 0xff); \ - src_v[(i * src_height >> 1) + j] = (random() & 0xff); \ + src_u[(i * src_width >> 1) + j] = (random() & 0xff); \ + src_v[(i * src_width >> 1) + j] = (random() & 0xff); \ } \ MaskCpuFlags(kCpuInitialized); \ I420To##FMT(src_y, src_width, \ src_u, src_width >> 1, \ src_v, src_width >> 1, \ - dst_rgb_c, src_width << 2, \ + dst_rgb_c, src_width * BPP, \ src_width, src_height); \ MaskCpuFlags(-1); \ I420To##FMT(src_y, src_width, \ src_u, src_width >> 1, \ src_v, src_width >> 1, \ - dst_rgb_opt, src_width << 2, \ + dst_rgb_opt, src_width * BPP, \ src_width, src_height); \ int err = 0; \ for (int i = 0; i < src_height; ++i) { \ - for (int j = 0; j < src_width << 2; ++j) { \ - int diff = static_cast(dst_rgb_c[i * src_height + j]) - \ - static_cast(dst_rgb_opt[i * src_height + j]); \ + for (int j = 0; j < src_width * BPP; ++j) { \ + int diff = static_cast(dst_rgb_c[i * src_width * BPP + j]) - \ + static_cast(dst_rgb_opt[i * src_width * BPP + j]); \ if (abs(diff) > 2) \ err++; \ } \ @@ -116,9 +116,58 @@ TEST_F(libyuvTest, I420To##FMT##_CvsOPT) { \ free_aligned_buffer_16(dst_rgb_opt) \ } -TESTI420TO(ARGB) -TESTI420TO(BGRA) -TESTI420TO(ABGR) +TESTI420TO(ARGB, 4) +TESTI420TO(BGRA, 4) +TESTI420TO(ABGR, 4) +TESTI420TO(RAW, 3) +TESTI420TO(RGB24, 3) +TESTI420TO(RGB565, 2) +// TODO(fbarchard): Add 555/4444 unittests once passing. +//TESTI420TO(ARGB1555, 2) +//TESTI420TO(ARGB4444, 2) + +#define TESTARGBTO(FMT, BPP) \ +TEST_F(libyuvTest, ARGBTo##FMT##_CvsOPT) { \ + const int src_width = 1280; \ + const int src_height = 720; \ + align_buffer_16(src_argb, src_width * src_height * 4); \ + align_buffer_16(dst_rgb_c, (src_width * BPP) * src_height); \ + align_buffer_16(dst_rgb_opt, (src_width * BPP) * src_height); \ + srandom(time(NULL)); \ + for (int i = 0; i < src_height; ++i) \ + for (int j = 0; j < src_width * 4; ++j) \ + src_argb[(i * src_width * 4) + j] = (random() & 0xff); \ + MaskCpuFlags(kCpuInitialized); \ + ARGBTo##FMT(src_argb, src_width * 4, \ + dst_rgb_c, src_width * BPP, \ + src_width, src_height); \ + MaskCpuFlags(-1); \ + ARGBTo##FMT(src_argb, src_width * 4, \ + dst_rgb_opt, src_width * BPP, \ + src_width, src_height); \ + int err = 0; \ + for (int i = 0; i < src_height; ++i) { \ + for (int j = 0; j < src_width * BPP; ++j) { \ + int diff = static_cast(dst_rgb_c[i * src_width * BPP + j]) - \ + static_cast(dst_rgb_opt[i * src_width * BPP + j]); \ + if (abs(diff) > 2) \ + err++; \ + } \ + } \ + EXPECT_EQ(err, 0); \ + free_aligned_buffer_16(src_argb) \ + free_aligned_buffer_16(dst_rgb_c) \ + free_aligned_buffer_16(dst_rgb_opt) \ +} + +// TODO(fbarchard): Expose all ARGBToRGB functions and test. +//TESTARGBTO(BGRA, 4) +//TESTARGBTO(ABGR, 4) +TESTARGBTO(RAW, 3) +TESTARGBTO(RGB24, 3) +//TESTARGBTO(RGB565, 2) +//TESTARGBTO(ARGB1555, 2) +//TESTARGBTO(ARGB4444, 2) TEST_F(libyuvTest, TestAttenuate) { SIMD_ALIGNED(uint8 orig_pixels[256][4]); diff --git a/unit_test/version_test.cc b/unit_test/version_test.cc new file mode 100644 index 000000000..17069181c --- /dev/null +++ b/unit_test/version_test.cc @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012 The LibYuv project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include +#include + +#include "libyuv/basic_types.h" +#include "libyuv/version.h" +#include "unit_test/unit_test.h" + +namespace libyuv { + +TEST_F(libyuvTest, TestVersion) { + EXPECT_GE(LIBYUV_VERSION, 169); // 169 is first version to support version. + printf("LIBYUV_VERSION %d\n", LIBYUV_VERSION); +#ifdef LIBYUV_SVNREVISION + const char *ver = strchr(LIBYUV_SVNREVISION, ':'); + if (!ver) { + ver = LIBYUV_SVNREVISION; + } + int svn_revision = atoi(ver); + printf("LIBYUV_SVNREVISION %d\n", svn_revision); + EXPECT_GE(LIBYUV_VERSION, svn_revision); +#endif +} + +} // namespace libyuv