From 6e815e708d23483467aec6be06f9d9a5f25b62a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 29 Jun 2014 00:51:58 +0300 Subject: [PATCH] Use ENFORCE_STACK_ALIGN_1D instead of manually doing stack buffer alignment --- test/decoder/DecUT_IntraPrediction.cpp | 14 ++++---------- test/encoder/EncUT_EncoderMbAux.cpp | 13 +++++-------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/test/decoder/DecUT_IntraPrediction.cpp b/test/decoder/DecUT_IntraPrediction.cpp index 6af45dce..75c56340 100644 --- a/test/decoder/DecUT_IntraPrediction.cpp +++ b/test/decoder/DecUT_IntraPrediction.cpp @@ -382,9 +382,8 @@ GENERATE_4x4_UT (WelsI4x4LumaPredHD_c, WelsI4x4LumaPredHD_ref, 0, 0) 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 @@ if (ASM) { \ 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 @@ GENERATE_8x8_UT (WelsIChromaPredV_c, LumaI8x8PredV, 0, 0) 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 @@ if (ASM) { \ 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 ++) {\ diff --git a/test/encoder/EncUT_EncoderMbAux.cpp b/test/encoder/EncUT_EncoderMbAux.cpp index 3ae3e409..3a30558f 100644 --- a/test/encoder/EncUT_EncoderMbAux.cpp +++ b/test/encoder/EncUT_EncoderMbAux.cpp @@ -239,10 +239,9 @@ void copy (uint8_t* pDst, int32_t iDStride, uint8_t* pSrc, int32_t iSStride, int 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, WelsCopy16x16NotAligned_sse2); 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 @@ TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_c) { } #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++) {