History

add arm 32/64 code and UT for SVC SCC motion estimation

HFVideoMac committed 12 years ago

Commit cff49f51 parent 3aec3a28 files · +532 −1Browse files

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

Unified · Split

test/encoder/EncUT_SVC_me.cpp+157−0
@@ -0,0 +1,157 @@
1+#include <gtest/gtest.h>
2+#include <math.h>
3+#include <stdlib.h>
4+#include <time.h>
5+
6+#include "cpu_core.h"
7+#include "cpu.h"
8+#include "macros.h"
9+#include "svc_motion_estimate.h"
10+
11+using namespace WelsSVCEnc;
12+#define SVC_ME_TEST_NUM 10
13+static void FillWithRandomData (uint8_t* p, int32_t Len) {
14+ for (int32_t i = 0; i < Len; i++) {
15+ p[i] = rand() % 256;
16+ }
17+}
18+
19+//preprocess related
20+int32_t SumOf8x8SingleBlock_ref (uint8_t* pRef, const int32_t kiRefStride) {
21+ int32_t iSum = 0, i;
22+ for (i = 0; i < 8; i++) {
23+ iSum += pRef[0] + pRef[1] + pRef[2] + pRef[3];
24+ iSum += pRef[4] + pRef[5] + pRef[6] + pRef[7];
25+ pRef += kiRefStride;
26+ }
27+ return iSum;
28+}
29+int32_t SumOf16x16SingleBlock_ref (uint8_t* pRef, const int32_t kiRefStride) {
30+ int32_t iSum = 0, i;
31+ for (i = 0; i < 16; i++) {
32+ iSum += pRef[0] + pRef[1] + pRef[2] + pRef[3];
33+ iSum += pRef[4] + pRef[5] + pRef[6] + pRef[7];
34+ iSum += pRef[8] + pRef[9] + pRef[10] + pRef[11];
35+ iSum += pRef[12] + pRef[13] + pRef[14] + pRef[15];
36+ pRef += kiRefStride;
37+ }
38+ return iSum;
39+}
40+
41+void SumOf8x8BlockOfFrame_ref (uint8_t* pRefPicture, const int32_t kiWidth, const int32_t kiHeight,
42+ const int32_t kiRefStride,
43+ uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]) {
44+ int32_t x, y;
45+ uint8_t* pRef;
46+ uint16_t* pBuffer;
47+ int32_t iSum;
48+ for (y = 0; y < kiHeight; y++) {
49+ pRef = pRefPicture + kiRefStride * y;
50+ pBuffer = pFeatureOfBlock + kiWidth * y;
51+ for (x = 0; x < kiWidth; x++) {
52+ iSum = SumOf8x8SingleBlock_c (pRef + x, kiRefStride);
53+
54+ pBuffer[x] = iSum;
55+ pTimesOfFeatureValue[iSum]++;
56+ }
57+ }
58+}
59+
60+void SumOf16x16BlockOfFrame_ref (uint8_t* pRefPicture, const int32_t kiWidth, const int32_t kiHeight,
61+ const int32_t kiRefStride,
62+ uint16_t* pFeatureOfBlock, uint32_t pTimesOfFeatureValue[]) {
63+ //TODO: this is similar to SumOf8x8BlockOfFrame_c expect the calling of single block func, refactor-able?
64+ int32_t x, y;
65+ uint8_t* pRef;
66+ uint16_t* pBuffer;
67+ int32_t iSum;
68+ for (y = 0; y < kiHeight; y++) {
69+ pRef = pRefPicture + kiRefStride * y;
70+ pBuffer = pFeatureOfBlock + kiWidth * y;
71+ for (x = 0; x < kiWidth; x++) {
72+ iSum = SumOf16x16SingleBlock_c (pRef + x, kiRefStride);
73+
74+ pBuffer[x] = iSum;
75+ pTimesOfFeatureValue[iSum]++;
76+ }
77+ }
78+}
79+
80+#define GENERATE_SumOfSingleBlock(anchor, method) \
81+TEST (SVC_ME_FunTest, method) {\
82+ ENFORCE_STACK_ALIGN_1D (uint8_t, uiRefBuf, 16*320, 16);\
83+ int32_t iRes[2];\
84+ for (int32_t k = 0; k < SVC_ME_TEST_NUM; k++) {\
85+ FillWithRandomData (uiRefBuf,16*320);\
86+ iRes[0] = anchor (uiRefBuf,320);\
87+ iRes[1] = method (uiRefBuf,320);\
88+ ASSERT_EQ (iRes[0], iRes[1]);\
89+ }\
90+}
91+
92+GENERATE_SumOfSingleBlock (SumOf8x8SingleBlock_ref, SumOf8x8SingleBlock_c)
93+GENERATE_SumOfSingleBlock (SumOf16x16SingleBlock_ref, SumOf16x16SingleBlock_c)
94+
95+#ifdef HAVE_NEON
96+GENERATE_SumOfSingleBlock (SumOf8x8SingleBlock_ref, SumOf8x8SingleBlock_neon)
97+GENERATE_SumOfSingleBlock (SumOf16x16SingleBlock_ref, SumOf16x16SingleBlock_neon)
98+#endif
99+
100+#ifdef HAVE_NEON_AARCH64
101+GENERATE_SumOfSingleBlock (SumOf8x8SingleBlock_ref, SumOf8x8SingleBlock_AArch64_neon)
102+GENERATE_SumOfSingleBlock (SumOf16x16SingleBlock_ref, SumOf16x16SingleBlock_AArch64_neon)
103+#endif
104+
105+
106+#define ENFORCE_NEW_ALIGN_1D(_tp, _nm, _nbuff, _sz, _al) \
107+_tp *_nbuff = new _tp[(_sz)+(_al)-1]; \
108+_tp *_nm = _nbuff + ((_al)-1) - (((uintptr_t)(_nbuff + ((_al)-1)) & ((_al)-1))/sizeof(_tp));
109+
110+#define GENERATE_SumOfFrame(anchor, method, kiWidth, kiHeight) \
111+TEST (SVC_ME_FunTest, method##_##kiWidth##x##kiHeight) {\
112+ENFORCE_NEW_ALIGN_1D (uint8_t, pRefPicture, pRefPictureBuff, ((kiHeight+16)*((((kiWidth+15)>>4)<<4)+16)), 16) \
113+ENFORCE_NEW_ALIGN_1D (uint16_t, pFeatureOfBlock1, pFeatureOfBlockBuff1, (kiWidth*kiHeight), 16) \
114+ENFORCE_NEW_ALIGN_1D (uint16_t, pFeatureOfBlock2, pFeatureOfBlockBuff2, (kiWidth*kiHeight), 16) \
115+uint32_t pTimesOfFeatureValue[2][65536]; \
116+for (int32_t k = 0; k < SVC_ME_TEST_NUM; k++) {\
117+ FillWithRandomData (pRefPicture,(kiHeight+16)*((((kiWidth+15)>>4)<<4)+16));\
118+ memset(pTimesOfFeatureValue[0], 0, 65536*sizeof(uint32_t)); \
119+ memset(pTimesOfFeatureValue[1], 0, 65536*sizeof(uint32_t)); \
120+ anchor (pRefPicture,kiWidth,kiHeight,((((kiWidth+15)>>4)<<4)+16),pFeatureOfBlock1,pTimesOfFeatureValue[0]); \
121+ method (pRefPicture,kiWidth,kiHeight,((((kiWidth+15)>>4)<<4)+16),pFeatureOfBlock2,pTimesOfFeatureValue[1]); \
122+ for(int32_t j=0;j<kiWidth*kiHeight;j++){\
123+ ASSERT_EQ (pFeatureOfBlock1[j], pFeatureOfBlock2[j]);\
124+ }\
125+ for(int32_t j=0;j<65536;j++){\
126+ ASSERT_EQ (pTimesOfFeatureValue[0][j], pTimesOfFeatureValue[1][j]);\
127+ }\
128+}\
129+delete[] pRefPictureBuff; \
130+delete[] pFeatureOfBlockBuff1; \
131+delete[] pFeatureOfBlockBuff2; \
132+}
133+
134+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_c, 1, 1)
135+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_c, 1, 1)
136+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_c, 1, 320)
137+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_c, 1, 320)
138+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_c, 640, 320)
139+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_c, 640, 320)
140+
141+#ifdef HAVE_NEON
142+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_neon, 1, 1)
143+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_neon, 1, 1)
144+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_neon, 1, 320)
145+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_neon, 1, 320)
146+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_neon, 640, 320)
147+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_neon, 640, 320)
148+#endif
149+
150+#ifdef HAVE_NEON_AARCH64
151+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_AArch64_neon, 1, 1)
152+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_AArch64_neon, 1, 1)
153+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_AArch64_neon, 1, 320)
154+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_AArch64_neon, 1, 320)
155+GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_AArch64_neon, 640, 320)
156+GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_AArch64_neon, 640, 320)
157+#endif

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