Commit 12084cd0 authored by Frank Barchard's avatar Frank Barchard Committed by Frank Barchard

SSSE3 scaling test detect SSSE3 before running

Bug: libyuv:755
Test: ~/intelsde/sde -p4p -- out/Release/libyuv_unittest --gtest_filter=LibYUVScaleTest*
Change-Id: Ibb0c908c38efc49dc56e86fa54ae7bd48ced02b5
Reviewed-on: https://chromium-review.googlesource.com/756363Reviewed-by: 's avatarCheng Wang <wangcheng@google.com>
parent 522fd699
...@@ -366,7 +366,7 @@ TEST_SCALETO(Scale, 1280, 720) ...@@ -366,7 +366,7 @@ TEST_SCALETO(Scale, 1280, 720)
#undef TEST_SCALETO #undef TEST_SCALETO
#ifdef HAS_SCALEROWDOWN2_SSSE3 #ifdef HAS_SCALEROWDOWN2_SSSE3
TEST_F(LibYUVScaleTest, TestScaleOdd) { TEST_F(LibYUVScaleTest, TestScaleRowDown2Box_Odd_SSSE3) {
SIMD_ALIGNED(uint8 orig_pixels[128 * 2]); SIMD_ALIGNED(uint8 orig_pixels[128 * 2]);
SIMD_ALIGNED(uint8 dst_pixels_opt[64]); SIMD_ALIGNED(uint8 dst_pixels_opt[64]);
SIMD_ALIGNED(uint8 dst_pixels_c[64]); SIMD_ALIGNED(uint8 dst_pixels_c[64]);
...@@ -374,78 +374,83 @@ TEST_F(LibYUVScaleTest, TestScaleOdd) { ...@@ -374,78 +374,83 @@ TEST_F(LibYUVScaleTest, TestScaleOdd) {
memset(dst_pixels_opt, 0, sizeof(dst_pixels_opt)); memset(dst_pixels_opt, 0, sizeof(dst_pixels_opt));
memset(dst_pixels_c, 0, sizeof(dst_pixels_c)); memset(dst_pixels_c, 0, sizeof(dst_pixels_c));
// TL int has_ssse3 = TestCpuFlag(kCpuHasSSSE3);
orig_pixels[0] = 255u; if (!has_ssse3) {
orig_pixels[1] = 0u; printf("Warning SSSE3 not detected; Skipping test.\n");
orig_pixels[128 + 0] = 0u; } else {
orig_pixels[128 + 1] = 0u; // TL
// TR orig_pixels[0] = 255u;
orig_pixels[2] = 0u; orig_pixels[1] = 0u;
orig_pixels[3] = 100u; orig_pixels[128 + 0] = 0u;
orig_pixels[128 + 2] = 0u; orig_pixels[128 + 1] = 0u;
orig_pixels[128 + 3] = 0u; // TR
// BL orig_pixels[2] = 0u;
orig_pixels[4] = 0u; orig_pixels[3] = 100u;
orig_pixels[5] = 0u; orig_pixels[128 + 2] = 0u;
orig_pixels[128 + 4] = 50u; orig_pixels[128 + 3] = 0u;
orig_pixels[128 + 5] = 0u; // BL
// BR orig_pixels[4] = 0u;
orig_pixels[6] = 0u; orig_pixels[5] = 0u;
orig_pixels[7] = 0u; orig_pixels[128 + 4] = 50u;
orig_pixels[128 + 6] = 0u; orig_pixels[128 + 5] = 0u;
orig_pixels[128 + 7] = 20u; // BR
// Odd orig_pixels[6] = 0u;
orig_pixels[126] = 4u; orig_pixels[7] = 0u;
orig_pixels[127] = 255u; orig_pixels[128 + 6] = 0u;
orig_pixels[128 + 126] = 16u; orig_pixels[128 + 7] = 20u;
orig_pixels[128 + 127] = 255u; // Odd
orig_pixels[126] = 4u;
// Test regular half size. orig_pixels[127] = 255u;
ScaleRowDown2Box_C(orig_pixels, 128, dst_pixels_c, 64); orig_pixels[128 + 126] = 16u;
orig_pixels[128 + 127] = 255u;
EXPECT_EQ(64u, dst_pixels_c[0]);
EXPECT_EQ(25u, dst_pixels_c[1]); // Test regular half size.
EXPECT_EQ(13u, dst_pixels_c[2]); ScaleRowDown2Box_C(orig_pixels, 128, dst_pixels_c, 64);
EXPECT_EQ(5u, dst_pixels_c[3]);
EXPECT_EQ(0u, dst_pixels_c[4]); EXPECT_EQ(64u, dst_pixels_c[0]);
EXPECT_EQ(133u, dst_pixels_c[63]); EXPECT_EQ(25u, dst_pixels_c[1]);
EXPECT_EQ(13u, dst_pixels_c[2]);
// Test Odd width version - Last pixel is just 1 horizontal pixel. EXPECT_EQ(5u, dst_pixels_c[3]);
ScaleRowDown2Box_Odd_C(orig_pixels, 128, dst_pixels_c, 64); EXPECT_EQ(0u, dst_pixels_c[4]);
EXPECT_EQ(133u, dst_pixels_c[63]);
EXPECT_EQ(64u, dst_pixels_c[0]);
EXPECT_EQ(25u, dst_pixels_c[1]); // Test Odd width version - Last pixel is just 1 horizontal pixel.
EXPECT_EQ(13u, dst_pixels_c[2]); ScaleRowDown2Box_Odd_C(orig_pixels, 128, dst_pixels_c, 64);
EXPECT_EQ(5u, dst_pixels_c[3]);
EXPECT_EQ(0u, dst_pixels_c[4]); EXPECT_EQ(64u, dst_pixels_c[0]);
EXPECT_EQ(10u, dst_pixels_c[63]); EXPECT_EQ(25u, dst_pixels_c[1]);
EXPECT_EQ(13u, dst_pixels_c[2]);
// Test one pixel less, should skip the last pixel. EXPECT_EQ(5u, dst_pixels_c[3]);
memset(dst_pixels_c, 0, sizeof(dst_pixels_c)); EXPECT_EQ(0u, dst_pixels_c[4]);
ScaleRowDown2Box_Odd_C(orig_pixels, 128, dst_pixels_c, 63); EXPECT_EQ(10u, dst_pixels_c[63]);
EXPECT_EQ(64u, dst_pixels_c[0]); // Test one pixel less, should skip the last pixel.
EXPECT_EQ(25u, dst_pixels_c[1]); memset(dst_pixels_c, 0, sizeof(dst_pixels_c));
EXPECT_EQ(13u, dst_pixels_c[2]); ScaleRowDown2Box_Odd_C(orig_pixels, 128, dst_pixels_c, 63);
EXPECT_EQ(5u, dst_pixels_c[3]);
EXPECT_EQ(0u, dst_pixels_c[4]); EXPECT_EQ(64u, dst_pixels_c[0]);
EXPECT_EQ(0u, dst_pixels_c[63]); EXPECT_EQ(25u, dst_pixels_c[1]);
EXPECT_EQ(13u, dst_pixels_c[2]);
// Test regular half size SSSE3. EXPECT_EQ(5u, dst_pixels_c[3]);
ScaleRowDown2Box_SSSE3(orig_pixels, 128, dst_pixels_opt, 64); EXPECT_EQ(0u, dst_pixels_c[4]);
EXPECT_EQ(0u, dst_pixels_c[63]);
EXPECT_EQ(64u, dst_pixels_opt[0]);
EXPECT_EQ(25u, dst_pixels_opt[1]); // Test regular half size SSSE3.
EXPECT_EQ(13u, dst_pixels_opt[2]); ScaleRowDown2Box_SSSE3(orig_pixels, 128, dst_pixels_opt, 64);
EXPECT_EQ(5u, dst_pixels_opt[3]);
EXPECT_EQ(0u, dst_pixels_opt[4]); EXPECT_EQ(64u, dst_pixels_opt[0]);
EXPECT_EQ(133u, dst_pixels_opt[63]); EXPECT_EQ(25u, dst_pixels_opt[1]);
EXPECT_EQ(13u, dst_pixels_opt[2]);
// Compare C and SSSE3 match. EXPECT_EQ(5u, dst_pixels_opt[3]);
ScaleRowDown2Box_Odd_C(orig_pixels, 128, dst_pixels_c, 64); EXPECT_EQ(0u, dst_pixels_opt[4]);
ScaleRowDown2Box_Odd_SSSE3(orig_pixels, 128, dst_pixels_opt, 64); EXPECT_EQ(133u, dst_pixels_opt[63]);
for (int i = 0; i < 64; ++i) {
EXPECT_EQ(dst_pixels_c[i], dst_pixels_opt[i]); // Compare C and SSSE3 match.
ScaleRowDown2Box_Odd_C(orig_pixels, 128, dst_pixels_c, 64);
ScaleRowDown2Box_Odd_SSSE3(orig_pixels, 128, dst_pixels_opt, 64);
for (int i = 0; i < 64; ++i) {
EXPECT_EQ(dst_pixels_c[i], dst_pixels_opt[i]);
}
} }
} }
#endif // HAS_SCALEROWDOWN2_SSSE3 #endif // HAS_SCALEROWDOWN2_SSSE3
......
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