ref: 704cad26f51bbf1e6e6f9f59dd7e73fd28870f5a
parent: d8e78fee09c4fcb31cf126f41fec10fa42abfe98
parent: 6e815e708d23483467aec6be06f9d9a5f25b62a6
author: zhilwang <zhilwang@cisco.com>
date: Mon Jun 30 06:00:44 EDT 2014
Merge pull request #1038 from mstorsjo/avoid-manual-alignment Use ENFORCE_STACK_ALIGN_1D instead of manually doing stack buffer alignment
--- a/test/decoder/DecUT_IntraPrediction.cpp
+++ b/test/decoder/DecUT_IntraPrediction.cpp
@@ -382,9 +382,8 @@
TEST(DecoderIntraPredictionTest, pred) {\
const int32_t kiStride = 32; \
int iRunTimes = 1000; \
-uint8_t _pRefBuffer[18 * kiStride + 64]; \
-uint8_t _pPredBuffer[18 * kiStride + 64]; \
-uint8_t *pRefBuffer, *pPredBuffer; \
+ENFORCE_STACK_ALIGN_1D (uint8_t, pRefBuffer, 18 * kiStride, 16); \
+ENFORCE_STACK_ALIGN_1D (uint8_t, pPredBuffer, 18 * kiStride, 16); \
if (ASM) { \
int32_t iTmp = 1; \
uint32_t uiCPUFlags = WelsCPUFeatureDetect(&iTmp); \
@@ -392,8 +391,6 @@
return; \
} \
} \
-pRefBuffer = (uint8_t*)((((intptr_t)(&_pRefBuffer[31])) >> 4) << 4); \
-pPredBuffer = (uint8_t*)((((intptr_t)(&_pPredBuffer[31])) >> 4) << 4); \
srand((unsigned int)time(NULL)); \
while(iRunTimes--) {\
for (int i = 0; i < 17; i ++) {\
@@ -523,9 +520,8 @@
TEST(DecoderIntraPredictionTest, pred) {\
const int32_t kiStride = 32; \
int32_t iRunTimes = 1000; \
-uint8_t _pRefBuffer[18 * kiStride + 64]; \
-uint8_t _pPredBuffer[18 * kiStride + 64]; \
-uint8_t *pRefBuffer, *pPredBuffer; \
+ENFORCE_STACK_ALIGN_1D (uint8_t, pRefBuffer, 18 * kiStride, 16); \
+ENFORCE_STACK_ALIGN_1D (uint8_t, pPredBuffer, 18 * kiStride, 16); \
if (ASM) { \
int32_t iTmp = 1; \
uint32_t uiCPUFlags = WelsCPUFeatureDetect( &iTmp); \
@@ -533,8 +529,6 @@
return ; \
} \
}\
-pRefBuffer = (uint8_t*)((((intptr_t)(&_pRefBuffer[31])) >> 4) << 4); \
-pPredBuffer = (uint8_t*)((((intptr_t)(&_pPredBuffer[31])) >> 4) << 4); \
srand((unsigned int)time(NULL)); \
while(iRunTimes--) {\
for (int i = 0; i < 17; i ++) {\
--- a/test/encoder/EncUT_EncoderMbAux.cpp
+++ b/test/encoder/EncUT_EncoderMbAux.cpp
@@ -239,10 +239,9 @@
TEST(EncodeMbAuxTest, function) { \
const int iSStride = 64; \
const int iDStride = 64; \
- uint8_t _ref_src[64*64], _ref_dst[64*64], _dst[64*64]; \
- uint8_t *ref_src = (uint8_t*)((((uintptr_t)(_ref_src + 15)) >> 4) << 4); \
- uint8_t *ref_dst = (uint8_t*)((((uintptr_t)(_ref_dst + 15)) >> 4) << 4); \
- uint8_t *dst = (uint8_t*)((((uintptr_t)(_dst + 15)) >> 4) << 4); \
+ ENFORCE_STACK_ALIGN_1D (uint8_t, ref_src, iSStride*height, 16); \
+ ENFORCE_STACK_ALIGN_1D (uint8_t, ref_dst, iDStride*height, 16); \
+ ENFORCE_STACK_ALIGN_1D (uint8_t, dst, iDStride*height, 16); \
srand((unsigned int)time(NULL)); \
for(int i = 0; i < height; i++) \
for(int j = 0; j < width; j++) \
@@ -265,8 +264,7 @@
GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16_sse2);
#endif
TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_c) {
- int16_t _iLevel[32];
- int16_t* pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4);
+ ENFORCE_STACK_ALIGN_1D (int16_t, pLevel, 16, 16);
srand ((unsigned int)time (NULL));
int32_t result = 0;
for (int i = 0; i < 16; i++) {
@@ -278,8 +276,7 @@
}
#ifdef X86_ASM
TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) {
- int16_t _iLevel[32];
- int16_t* pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4);
+ ENFORCE_STACK_ALIGN_1D (int16_t, pLevel, 16, 16);
srand ((unsigned int)time (NULL));
int32_t result = 0;
for (int i = 0; i < 16; i++) {