History

add mv range limitation and related ut

ruil2 committed 12 years ago

Commit 441dc451 parent 153a0315 files · +8588 −8460Browse files

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

Unified · Split

test/encoder/EncUT_MotionEstimate.cpp+118−0
@@ -125,6 +125,124 @@ TEST_F (MotionEstimateTest, TestDiamondSearch) { · 124 unmodified lines
125125 }
126126 }
127127
128+class MotionEstimateRangeTest : public ::testing::Test {
129+ public:
130+ virtual void SetUp() {
131+
132+ m_iWidth = 320;
133+ m_iHeight = 240;
134+ m_iWidthExt = m_iWidth + 2 * PADDING_LENGTH;
135+ m_iHeightExt = m_iHeight + 2 * PADDING_LENGTH;
136+ m_iMbWidth = m_iWidth >> 4;
137+ m_iMbHeight = m_iHeight >> 4;
138+
139+ m_iUsageType = 0;
140+ m_iNumDependencyLayers = 1;
141+ m_iMvRange = m_iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE;
142+ m_iMvdRange = (m_iUsageType ? EXPANDED_MVD_RANGE : ((m_iNumDependencyLayers == 1) ? CAMERA_MVD_RANGE :
143+ CAMERA_HIGHLAYER_MVD_RANGE));
144+ m_uiMvdInterTableSize = (m_iMvdRange << 2); //intepel*4=qpel
145+ m_uiMvdInterTableStride = 1 + (m_uiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-);
146+ m_uiMvdCacheAlignedSize = m_uiMvdInterTableStride * sizeof (uint16_t);
147+
148+ m_pMa = new CMemoryAlign (16);
149+ ASSERT_TRUE (NULL != m_pMa);
150+ m_pMvdCostTable = (uint16_t*)m_pMa->WelsMallocz (52 * m_uiMvdCacheAlignedSize, "pMvdCostTable");
151+ ASSERT_TRUE (NULL != m_pMvdCostTable);
152+ m_pRefStart = (uint8_t*)m_pMa->WelsMallocz (m_iWidthExt * m_iHeightExt, "reference frame ");
153+ ASSERT_TRUE (NULL != m_pRefStart);
154+ m_pSrc = (uint8_t*)m_pMa->WelsMallocz (m_iWidth * m_iHeight, "source frame");
155+ ASSERT_TRUE (NULL != m_pSrc);
156+
157+ }
158+ virtual void TearDown() {
159+ if (!m_pMa)
160+ return;
161+ if (m_pRefStart) {
162+ m_pMa->WelsFree (m_pRefStart, "reference frame ");
163+ m_pRefStart = NULL;
164+ }
165+ if (m_pSrc) {
166+ m_pMa->WelsFree (m_pSrc, "source frame ");
167+ m_pSrc = NULL;
168+ }
169+ if (m_pMvdCostTable) {
170+ m_pMa->WelsFree (m_pMvdCostTable, "pMvdCostTable");
171+ m_pMvdCostTable = NULL;
172+ }
173+ if (m_pMa) {
174+ delete m_pMa;
175+ m_pMa = NULL;
176+ }
177+
178+ }
179+ public:
180+ uint8_t* m_pRefStart;
181+ uint8_t* m_pSrc;
182+ uint16_t* m_pMvdCostTable;
183+
184+ int32_t m_iWidth;
185+ int32_t m_iHeight;
186+ int32_t m_iWidthExt;
187+ int32_t m_iHeightExt;
188+ int32_t m_iMbWidth;
189+ int32_t m_iMbHeight;
190+ CMemoryAlign* m_pMa;
191+
192+ int32_t m_iMvRange;
193+ int32_t m_iMvdRange;
194+ uint32_t m_uiMvdInterTableSize;
195+ uint32_t m_uiMvdInterTableStride;
196+ uint32_t m_uiMvdCacheAlignedSize;
197+ int32_t m_iUsageType;
198+ int32_t m_iNumDependencyLayers;
199+};
200+
201+TEST_F (MotionEstimateRangeTest, TestDiamondSearch) {
202+
203+ const int32_t kiMaxBlock16Sad = 72000;//a rough number
204+ uint8_t* pRef = m_pRefStart + PADDING_LENGTH * m_iWidthExt + PADDING_LENGTH;
205+ SWelsFuncPtrList sFuncList;
206+ SWelsME sMe;
207+ SSlice sSlice;
208+ const uint8_t kuiQp = rand() % 52;
209+ InitMe (kuiQp, m_uiMvdInterTableStride, m_uiMvdInterTableStride, m_pMvdCostTable, &sMe);
210+
211+ WelsInitSampleSadFunc (&sFuncList, 0); //test c functions
212+
213+ memset (m_pSrc, 128, m_iWidth * m_iHeight);
214+ memset (m_pRefStart, 0, m_iWidthExt * m_iHeightExt);
215+
216+ sMe.uiBlockSize = BLOCK_16x16; //
217+
218+ sMe.sMvp.iMvX = rand() % m_iMvRange;
219+ sMe.sMvp.iMvY = rand() % m_iMvRange;
220+
221+ for (int h = 0; h < m_iHeight; h++)
222+ memset (pRef + h * m_iWidthExt, h, m_iWidthExt);
223+
224+ sMe.pEncMb = m_pSrc;
225+
226+ sMe.sMv.iMvX = sMe.sMvp.iMvX;
227+ sMe.sMv.iMvY = sMe.sMvp.iMvY;
228+
229+ sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
230+ SetMvWithinIntegerMvRange (m_iMbWidth, m_iMbHeight, 0, 0, m_iMvRange,
231+ & (sSlice.sMvStartMin), & (sSlice.sMvStartMax));
232+
233+
234+ sMe.pRefMb = pRef + sMe.sMvp.iMvY * m_iWidthExt;
235+ WelsDiamondSearch (&sFuncList, &sMe, &sSlice, m_iWidth, m_iWidthExt);
236+
237+ if ((WELS_ABS (sMe.sMv.iMvX) > m_iMvRange))
238+ printf ("mvx = %d\n", sMe.sMv.iMvX);
239+ ASSERT_TRUE (! (WELS_ABS (sMe.sMv.iMvX) > m_iMvRange));
240+ if ((WELS_ABS (sMe.sMv.iMvY) > m_iMvRange))
241+ printf ("mvy = %d\n", sMe.sMv.iMvY);
242+ ASSERT_TRUE (! (WELS_ABS (sMe.sMv.iMvY) > m_iMvRange));
243+
244+
245+}
128246
129247 void MotionEstimateTest::DoLineTest (PLineFullSearchFunc func, bool vertical) {
130248 const int32_t kiMaxBlock16Sad = 72000;//a rough number

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