History

[Decoder] Use encoder x86 IDCT routines

Move asm routines to common. Delete obsolete decoder routines. Use wider routines where applicable. ~1.07x overall faster decode on a quick 720p30 4Mbps test on Haswell.

Sindre Aamås committed 10 years ago

Commit 98042f11 parent 48a520912 files · +1217 −1047Browse files

Showing the changes to test/decoder/DecUT_IdctResAddPred.cpp (1 of 12 files). Show all

Unified · Split

test/decoder/DecUT_IdctResAddPred.cpp+56−2
@@ -4,6 +4,9 @@ · 3 unmodified lines
44 #include "deblocking.h"
55 #include "cpu.h"
66 using namespace WelsDec;
7+
8+namespace {
9+
710 void IdctResAddPred_ref (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
811 int16_t iSrc[16];
912
@@ -49,14 +52,25 @@ void SetNonZeroCount_ref (int8_t* pNonZeroCount) { · 39 unmodified lines
4952 }
5053 }
5154
55+#if defined(X86_ASM)
56+void IdctFourResAddPred_ref (uint8_t* pPred, int32_t iStride, int16_t* pRs) {
57+ IdctResAddPred_ref (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16);
58+ IdctResAddPred_ref (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16);
59+ IdctResAddPred_ref (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16);
60+ IdctResAddPred_ref (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16);
61+}
62+#endif
63+
64+} // anon ns
65+
5266 #define GENERATE_IDCTRESADDPRED(pred, flag) \
5367 TEST(DecoderDecodeMbAux, pred) {\
5468 const int32_t kiStride = 32;\
5569 const int iBits = 12;\
5670 const int iMask = (1 << iBits) - 1;\
5771 const int iOffset = 1 << (iBits - 1);\
58− int16_t iRS[16];\
59− uint8_t uiPred[16*kiStride];\
72+ ENFORCE_STACK_ALIGN_1D (int16_t, iRS, 16, 16);\
73+ ENFORCE_STACK_ALIGN_1D (uint8_t, uiPred, 16 * kiStride, 16);\
6074 int16_t iRefRS[16];\
6175 uint8_t uiRefPred[16*kiStride];\
6276 int32_t iRunTimes = 1000;\
@@ -84,9 +98,49 @@ TEST(DecoderDecodeMbAux, pred) {\ · 21 unmodified lines
8498 }\
8599 }
86100
101+#define GENERATE_IDCTFOURRESADDPRED(pred, flag) \
102+TEST(DecoderDecodeMbAux, pred) {\
103+ const int32_t kiStride = 32;\
104+ const int iBits = 12;\
105+ const int iMask = (1 << iBits) - 1;\
106+ const int iOffset = 1 << (iBits - 1);\
107+ ENFORCE_STACK_ALIGN_1D (int16_t, iRS, 4 * 16, 16);\
108+ ENFORCE_STACK_ALIGN_1D (uint8_t, uiPred, 4 * 16 * kiStride, 16);\
109+ int16_t iRefRS[4 * 16];\
110+ uint8_t uiRefPred[4 * 16 * kiStride];\
111+ int8_t iNzc[6] = { 0 };\
112+ int32_t iRunTimes = 1000;\
113+ uint32_t uiCPUFlags = WelsCPUFeatureDetect(0); \
114+ if ((uiCPUFlags & flag) == 0 && flag != 0) \
115+ return; \
116+ while (iRunTimes--) {\
117+ for (int i = 0; i < 4; i++)\
118+ for (int j = 0; j < 16; j++)\
119+ iNzc[i / 2 * 4 + i % 2] += !!(iRefRS[16 * i + j] = iRS[16 * i + j] = (rand() & iMask) - iOffset);\
120+ for (int i = 0; i < 8; i++)\
121+ for (int j = 0; j < 8; j++)\
122+ uiRefPred[i * kiStride + j] = uiPred[i * kiStride + j] = rand() & 255;\
123+ pred (uiPred, kiStride, iRS, iNzc);\
124+ IdctFourResAddPred_ref (uiRefPred, kiStride, iRefRS);\
125+ bool ok = true;\
126+ for (int i = 0; i < 8; i++)\
127+ for (int j = 0; j < 8; j++)\
128+ if (uiRefPred[i * kiStride + j] != uiPred[i * kiStride + j]) {\
129+ ok = false;\
130+ goto next;\
131+ }\
132+ next:\
133+ EXPECT_EQ(ok, true);\
134+ }\
135+}
136+
87137 GENERATE_IDCTRESADDPRED (IdctResAddPred_c, 0)
88138 #if defined(X86_ASM)
89139 GENERATE_IDCTRESADDPRED (IdctResAddPred_mmx, WELS_CPU_MMXEXT)
140+GENERATE_IDCTRESADDPRED (IdctResAddPred_sse2, WELS_CPU_SSE2)
141+GENERATE_IDCTRESADDPRED (IdctResAddPred_avx2, WELS_CPU_AVX2)
142+GENERATE_IDCTFOURRESADDPRED (IdctFourResAddPred_sse2, WELS_CPU_SSE2)
143+GENERATE_IDCTFOURRESADDPRED (IdctFourResAddPred_avx2, WELS_CPU_AVX2)
90144 #endif
91145
92146 #if defined(HAVE_NEON)

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