From 1b06484b4aeb06ce45759ea9928fe84981680ac9 Mon Sep 17 00:00:00 2001 From: "mikhal@webrtc.org" Date: Thu, 10 Nov 2011 23:58:32 +0000 Subject: [PATCH] libyuv: clean up: 1. Removing libyuv:: when not needed 2. Test clean-up Review URL: http://webrtc-codereview.appspot.com/279002 git-svn-id: http://libyuv.googlecode.com/svn/trunk@74 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- source/format_conversion.cc | 6 +++--- source/rotate.cc | 18 +++++++++--------- source/scale.cc | 26 +++++++++++++------------- unit_test/compare_test.cc | 4 +++- unit_test/rotate_test.cc | 4 +++- unit_test/scale_test.cc | 8 +++++--- unit_test/unit_test.cc | 20 +------------------- unit_test/unit_test.h | 13 +++++-------- 8 files changed, 42 insertions(+), 57 deletions(-) diff --git a/source/format_conversion.cc b/source/format_conversion.cc index 8ead34191..96b95a5e3 100644 --- a/source/format_conversion.cc +++ b/source/format_conversion.cc @@ -111,7 +111,7 @@ int ARGBToBayerRGB(const uint8* src_rgb, int src_stride_rgb, void (*ARGBToBayerRow)(const uint8* src_argb, uint8* dst_bayer, uint32 selector, int pix); #if defined(HAS_ARGBTOBAYERROW_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (width % 4 == 0) && IS_ALIGNED(src_rgb, 16) && (src_stride_rgb % 16 == 0) && IS_ALIGNED(dst_bayer, 4) && (dst_stride_bayer % 4 == 0)) { @@ -365,7 +365,7 @@ int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer, SIMD_ALIGNED(uint8 row[kMaxStride * 2]); #if defined(HAS_ARGBTOYROW_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (width % 16 == 0) && IS_ALIGNED(row, 16) && (kMaxStride % 16 == 0) && IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { @@ -376,7 +376,7 @@ int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer, ARGBToYRow = ARGBToYRow_C; } #if defined(HAS_ARGBTOUVROW_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (width % 16 == 0) && IS_ALIGNED(row, 16) && (kMaxStride % 16 == 0) && IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && diff --git a/source/rotate.cc b/source/rotate.cc index 3581dff1d..dc5371f3c 100644 --- a/source/rotate.cc +++ b/source/rotate.cc @@ -782,13 +782,13 @@ void TransposePlane(const uint8* src, int src_stride, rotate_wxh_func TransposeWxH; #if defined(HAS_TRANSPOSE_WX8_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON)) { + if (TestCpuFlag(kCpuHasNEON)) { TransposeWx8 = TransposeWx8_NEON; TransposeWxH = TransposeWxH_C; } else #endif #if defined(HAS_TRANSPOSE_WX8_FAST_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (width % 16 == 0) && IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && IS_ALIGNED(dst, 8) && (dst_stride % 8 == 0)) { @@ -797,7 +797,7 @@ void TransposePlane(const uint8* src, int src_stride, } else #endif #if defined(HAS_TRANSPOSE_WX8_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (width % 8 == 0) && IS_ALIGNED(src, 8) && (src_stride % 8 == 0) && IS_ALIGNED(dst, 8) && (dst_stride % 8 == 0)) { @@ -912,12 +912,12 @@ void RotatePlane180(const uint8* src, int src_stride, reverse_func ReverseLine; #if defined(HAS_REVERSE_LINE_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON)) { + if (TestCpuFlag(kCpuHasNEON)) { ReverseLine = ReverseLine_NEON; } else #endif #if defined(HAS_REVERSE_LINE_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (width % 16 == 0) && IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && IS_ALIGNED(dst, 16) && (dst_stride % 16 == 0)) { @@ -986,13 +986,13 @@ void TransposeUV(const uint8* src, int src_stride, rotate_uv_wxh_func TransposeWxH; #if defined(HAS_TRANSPOSE_UVWX8_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON)) { + if (TestCpuFlag(kCpuHasNEON)) { TransposeWx8 = TransposeUVWx8_NEON; TransposeWxH = TransposeUVWxH_C; } else #endif #if defined(HAS_TRANSPOSE_UVWX8_SSE2) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && (width % 8 == 0) && IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && IS_ALIGNED(dst_a, 8) && (dst_stride_a % 8 == 0) && @@ -1137,12 +1137,12 @@ void RotateUV180(const uint8* src, int src_stride, reverse_uv_func ReverseLine; #if defined(HAS_REVERSE_LINE_UV_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON)) { + if (TestCpuFlag(kCpuHasNEON)) { ReverseLine = ReverseLineUV_NEON; } else #endif #if defined(HAS_REVERSE_LINE_UV_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (width % 16 == 0) && IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && IS_ALIGNED(dst_a, 8) && (dst_stride_a % 8 == 0) && diff --git a/source/scale.cc b/source/scale.cc index 25b8de47e..cad1c538c 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -3060,13 +3060,13 @@ static void ScalePlaneDown2(int src_width, int src_height, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN2_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON) && + if (TestCpuFlag(kCpuHasNEON) && (dst_width % 16 == 0)) { ScaleRowDown2 = filtering ? ScaleRowDown2Int_NEON : ScaleRowDown2_NEON; } else #endif #if defined(HAS_SCALEROWDOWN2_SSE2) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && (dst_width % 16 == 0) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 16)) { ScaleRowDown2 = filtering ? ScaleRowDown2Int_SSE2 : ScaleRowDown2_SSE2; @@ -3100,13 +3100,13 @@ static void ScalePlaneDown4(int src_width, int src_height, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN4_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON) && + if (TestCpuFlag(kCpuHasNEON) && (dst_width % 4 == 0)) { ScaleRowDown4 = filtering ? ScaleRowDown4Int_NEON : ScaleRowDown4_NEON; } else #endif #if defined(HAS_SCALEROWDOWN4_SSE2) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && (dst_width % 8 == 0) && (src_stride % 16 == 0) && (dst_stride % 8 == 0) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8)) { @@ -3141,7 +3141,7 @@ static void ScalePlaneDown8(int src_width, int src_height, void (*ScaleRowDown8)(const uint8* src_ptr, int src_stride, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN8_SSE2) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && (dst_width % 16 == 0) && dst_width <= kMaxOutputWidth && (src_stride % 16 == 0) && (dst_stride % 16 == 0) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 16)) { @@ -3176,7 +3176,7 @@ static void ScalePlaneDown34(int src_width, int src_height, void (*ScaleRowDown34_1)(const uint8* src_ptr, int src_stride, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN34_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON) && + if (TestCpuFlag(kCpuHasNEON) && (dst_width % 24 == 0)) { if (!filtering) { ScaleRowDown34_0 = ScaleRowDown34_NEON; @@ -3188,7 +3188,7 @@ static void ScalePlaneDown34(int src_width, int src_height, } else #endif #if defined(HAS_SCALEROWDOWN34_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (dst_width % 24 == 0) && (src_stride % 16 == 0) && (dst_stride % 8 == 0) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8)) { @@ -3202,7 +3202,7 @@ static void ScalePlaneDown34(int src_width, int src_height, } else #endif #if defined(HAS_SCALEROWDOWN34_SSE2) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && (dst_width % 24 == 0) && (src_stride % 16 == 0) && (dst_stride % 8 == 0) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8) && @@ -3265,7 +3265,7 @@ static void ScalePlaneDown38(int src_width, int src_height, void (*ScaleRowDown38_2)(const uint8* src_ptr, int src_stride, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN38_NEON) - if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON) && + if (TestCpuFlag(kCpuHasNEON) && (dst_width % 12 == 0)) { if (!filtering) { ScaleRowDown38_3 = ScaleRowDown38_NEON; @@ -3277,7 +3277,7 @@ static void ScalePlaneDown38(int src_width, int src_height, } else #endif #if defined(HAS_SCALEROWDOWN38_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (dst_width % 24 == 0) && (src_stride % 16 == 0) && (dst_stride % 8 == 0) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8)) { @@ -3426,7 +3426,7 @@ static void ScalePlaneBox(int src_width, int src_height, void (*ScaleAddCols)(int dst_width, int boxheight, int dx, const uint16* src_ptr, uint8* dst_ptr); #if defined(HAS_SCALEADDROWS_SSE2) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && (src_stride % 16 == 0) && IS_ALIGNED(src_ptr, 16) && (src_width % 16) == 0) { ScaleAddRows = ScaleAddRows_SSE2; @@ -3521,14 +3521,14 @@ static void ScalePlaneBilinear(int src_width, int src_height, void (*ScaleFilterCols)(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int dx); #if defined(HAS_SCALEFILTERROWS_SSSE3) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && + if (TestCpuFlag(kCpuHasSSSE3) && (src_stride % 16 == 0) && IS_ALIGNED(src_ptr, 16) && (src_width % 16) == 0) { ScaleFilterRows = ScaleFilterRows_SSSE3; } else #endif #if defined(HAS_SCALEFILTERROWS_SSE2) - if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && (src_stride % 16 == 0) && IS_ALIGNED(src_ptr, 16) && (src_width % 16) == 0) { ScaleFilterRows = ScaleFilterRows_SSE2; diff --git a/unit_test/compare_test.cc b/unit_test/compare_test.cc index c48556390..3c48c4508 100644 --- a/unit_test/compare_test.cc +++ b/unit_test/compare_test.cc @@ -16,7 +16,7 @@ #include #include -using namespace libyuv; +namespace libyuv { TEST_F(libyuvTest, BenchmarkSumSquareError_C) { const int max_width = 4096*3; @@ -328,3 +328,5 @@ TEST_F(libyuvTest, Ssim) { free_aligned_buffer_16(src_a) free_aligned_buffer_16(src_b) } + +} diff --git a/unit_test/rotate_test.cc b/unit_test/rotate_test.cc index 784b7d249..c92f176b3 100644 --- a/unit_test/rotate_test.cc +++ b/unit_test/rotate_test.cc @@ -14,7 +14,7 @@ #include #include -using namespace libyuv; +namespace libyuv { void print_array(uint8 *array, int w, int h) { int i, j; @@ -1445,3 +1445,5 @@ TEST_F(libyuvTest, NV12ToI420RotateNegHeight180) { EXPECT_EQ(0, y_err + uv_err); } + +} // namespace diff --git a/unit_test/scale_test.cc b/unit_test/scale_test.cc index dc9c8bfee..7dbd6c18a 100644 --- a/unit_test/scale_test.cc +++ b/unit_test/scale_test.cc @@ -14,7 +14,7 @@ #include #include -using namespace libyuv; +namespace libyuv { static int TestFilter(int src_width, int src_height, int dst_width, int dst_height, @@ -68,7 +68,7 @@ static int TestFilter(int src_width, int src_height, align_buffer_16(dst_u_opt, dst_uv_plane_size) align_buffer_16(dst_v_opt, dst_uv_plane_size) - libyuv::MaskCpuFlags(kCpuInitialized); + MaskCpuFlags(kCpuInitialized); double c_time = get_time(); for (i = 0; i < runs; ++i) @@ -83,7 +83,7 @@ static int TestFilter(int src_width, int src_height, c_time = (get_time() - c_time) / runs; - libyuv::MaskCpuFlags(-1); + MaskCpuFlags(-1); double opt_time = get_time(); for (i = 0; i < runs; ++i) @@ -210,3 +210,5 @@ TEST_F(libyuvTest, ScaleDownBy38) { EXPECT_EQ(0, err); } + +} // namespace diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc index 5c8abbf3e..35a447351 100644 --- a/unit_test/unit_test.cc +++ b/unit_test/unit_test.cc @@ -11,15 +11,6 @@ #include #include "unit_test.h" -class libyuvEnvironment : public ::testing::Environment { - public: - virtual void SetUp() { - } - - virtual void TearDown() { - } -}; - libyuvTest::libyuvTest() : _rotate_max_w(128), _rotate_max_h(128), @@ -28,16 +19,7 @@ libyuvTest::libyuvTest() : _benchmark_height(720) { } -void libyuvTest::SetUp() { -} - -void libyuvTest::TearDown() { -} - int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - libyuvEnvironment* env = new libyuvEnvironment; - ::testing::AddGlobalTestEnvironment(env); - return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/unit_test/unit_test.h b/unit_test/unit_test.h index f57be2d64..102d2e465 100644 --- a/unit_test/unit_test.h +++ b/unit_test/unit_test.h @@ -40,12 +40,11 @@ static double get_time() #include #include -static double get_time() -{ - struct timeval t; - struct timezone tzp; - gettimeofday(&t, &tzp); - return t.tv_sec + t.tv_usec*1e-6; +static double get_time() { + struct timeval t; + struct timezone tzp; + gettimeofday(&t, &tzp); + return t.tv_sec + t.tv_usec*1e-6; } #endif @@ -53,8 +52,6 @@ static double get_time() class libyuvTest : public ::testing::Test { protected: libyuvTest(); - virtual void SetUp(); - virtual void TearDown(); const int _rotate_max_w; const int _rotate_max_h;