History

Merge pull request #2448 from saamas/encoder-getnonzerocount-sse42

[Encoder] Add an SSE4.2 implementation of WelsGetNonZeroCount

HaiboZhu committed 10 years ago

Commit c30cc412 parents e9dc978 4645bd24 files · +50 −15Browse files

Showing the changes to test/encoder/EncUT_EncoderMbAux.cpp (1 of 4 files). Show all

Unified · Split

test/encoder/EncUT_EncoderMbAux.cpp+32−15
@@ -269,26 +269,43 @@ GENERATE_UT_FOR_COPY (16, 8, WelsCopy16x8NotAligned_sse2); · 268 unmodified lines
269GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16NotAligned_sse2);269GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16NotAligned_sse2);
270GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16_sse2);270GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16_sse2);
271#endif271#endif
272TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_c) {272
273namespace {
274
275void TestGetNoneZeroCount (PGetNoneZeroCountFunc func) {
273 ENFORCE_STACK_ALIGN_1D (int16_t, pLevel, 16, 16);276 ENFORCE_STACK_ALIGN_1D (int16_t, pLevel, 16, 16);
274 int32_t result = 0;277 const int num_test_runs = 1000;
275 for (int i = 0; i < 16; i++) {278 for (int run = 0; run < num_test_runs; run++) {
276 pLevel[i] = (rand() & 0x07) - 4;279 const bool all_zero = run == 0;
277 if (pLevel[i]) result ++;280 const bool all_nonzero = run == 1;
281 int result = 0;
282 for (int i = 0; i < 16; i++) {
283 const int r = rand();
284 if (all_zero)
285 pLevel[i] = 0;
286 else if (all_nonzero)
287 pLevel[i] = r % 0xFFFF - 0x8000 ? r % 0xFFFF - 0x8000 : 0x7FFF;
288 else
289 pLevel[i] = (r >> 16 & 1) * ((r & 0xFFFF) - 0x8000);
290 result += pLevel[i] != 0;
291 }
292 const int32_t nnz = func (pLevel);
293 EXPECT_EQ (nnz, result);
278 }294 }
279 int32_t nnz = WelsGetNoneZeroCount_c (pLevel);295}
280 EXPECT_EQ (nnz, result);296
297} // anon ns.
298
299TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_c) {
300 TestGetNoneZeroCount (WelsGetNoneZeroCount_c);
281}301}
282#ifdef X86_ASM302#ifdef X86_ASM
283TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) {303TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) {
284 ENFORCE_STACK_ALIGN_1D (int16_t, pLevel, 16, 16);304 TestGetNoneZeroCount (WelsGetNoneZeroCount_sse2);
285 int32_t result = 0;305}
286 for (int i = 0; i < 16; i++) {306TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_sse42) {
287 pLevel[i] = (rand() & 0x07) - 4;307 if (WelsCPUFeatureDetect (0) & WELS_CPU_SSE42)
288 if (pLevel[i]) result ++;308 TestGetNoneZeroCount (WelsGetNoneZeroCount_sse42);
289 }
290 int32_t nnz = WelsGetNoneZeroCount_sse2 (pLevel);
291 EXPECT_EQ (nnz, result);
292}309}
293#endif310#endif
294#define WELS_ABS_LC(a) ((sign ^ (int32_t)(a)) - sign)311#define WELS_ABS_LC(a) ((sign ^ (int32_t)(a)) - sign)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t