ref: eb889c95e0f1389af99ba4534f8cc19a4de0198b
parent: a6ebecd70712b4bc4ddc0dbf6f7971dbd2091592
parent: cf9e21febdb858847befa4a14d70270811c25019
author: ruil2 <ruil2@cisco.com>
date: Tue Jun 10 07:12:49 EDT 2014
Merge pull request #938 from dongzha/AddArm64UnitTestEP add ARM32/64 Unit Test for Expand Picture
--- a/test/decoder/DecUT_ExpandPicture.cpp
+++ b/test/decoder/DecUT_ExpandPicture.cpp
@@ -3,6 +3,7 @@
#include "expand_pic.h"
#include "mem_align.h"
#include "decoder_context.h"
+#include "cpu.h"
using namespace WelsDec;
#define EXPAND_PIC_TEST_NUM 10
namespace WelsDec {
@@ -99,34 +100,43 @@
TEST (ExpandPicture, ExpandPictureLuma) {
SExpandPicFunc sExpandPicFunc;
- InitExpandPictureFunc (&sExpandPicFunc, 0);
- srand ((unsigned int)time (0));
- for (int32_t iTestIdx = 0; iTestIdx < EXPAND_PIC_TEST_NUM; iTestIdx++) {
- int32_t iPicWidth = 16 + (rand() % 200) * 16;
- int32_t iPicHeight = 16 + (rand() % 100) * 16;
+ int32_t iCpuCores = 1;
+ uint32_t uiCpuFlag = 0;
+ for(int32_t k =0; k<2; k++) {
+ if(k==0) {
+ uiCpuFlag = 0;
+ }else {
+ uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
+ }
+ InitExpandPictureFunc (&sExpandPicFunc, uiCpuFlag);
+ srand ((unsigned int)time (0));
+ for (int32_t iTestIdx = 0; iTestIdx < EXPAND_PIC_TEST_NUM; iTestIdx++) {
+ int32_t iPicWidth = 16 + (rand() % 200) * 16;
+ int32_t iPicHeight = 16 + (rand() % 100) * 16;
- int32_t iStride = iPicWidth + H264_PADDING_LENGTH_LUMA * 2;
- int32_t iBuffHeight = iPicHeight + H264_PADDING_LENGTH_LUMA * 2;
- int32_t iBuffSize = iBuffHeight * iStride * sizeof (uint8_t);
- uint8_t* pAnchorDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pAnchorDstBuff"));
- uint8_t* pAnchorDst = pAnchorDstBuff + H264_PADDING_LENGTH_LUMA * iStride + H264_PADDING_LENGTH_LUMA;
+ int32_t iStride = iPicWidth + H264_PADDING_LENGTH_LUMA * 2;
+ int32_t iBuffHeight = iPicHeight + H264_PADDING_LENGTH_LUMA * 2;
+ int32_t iBuffSize = iBuffHeight * iStride * sizeof (uint8_t);
+ uint8_t* pAnchorDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pAnchorDstBuff"));
+ uint8_t* pAnchorDst = pAnchorDstBuff + H264_PADDING_LENGTH_LUMA * iStride + H264_PADDING_LENGTH_LUMA;
- uint8_t* pTestDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pTestDstBuff"));
- uint8_t* pTestDst = pTestDstBuff + H264_PADDING_LENGTH_LUMA * iStride + H264_PADDING_LENGTH_LUMA;
+ uint8_t* pTestDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pTestDstBuff"));
+ uint8_t* pTestDst = pTestDstBuff + H264_PADDING_LENGTH_LUMA * iStride + H264_PADDING_LENGTH_LUMA;
- // Generate Src
- for (int32_t j = 0; j < iPicHeight; j++) {
- for (int32_t i = 0; i < iPicWidth; i++) {
- pAnchorDst[i + j * iStride] = pTestDst[i + j * iStride] = rand() % 256;
+ // Generate Src
+ for (int32_t j = 0; j < iPicHeight; j++) {
+ for (int32_t i = 0; i < iPicWidth; i++) {
+ pAnchorDst[i + j * iStride] = pTestDst[i + j * iStride] = rand() % 256;
+ }
}
- }
- H264ExpandPictureLumaAnchor_c (pAnchorDst, iStride, iPicWidth, iPicHeight);
- sExpandPicFunc.pfExpandLumaPicture (pTestDst, iStride, iPicWidth, iPicHeight);
- EXPECT_EQ (CompareBuff (pAnchorDstBuff, pTestDstBuff, iStride, iPicWidth + H264_PADDING_LENGTH_LUMA * 2,
- iPicHeight + H264_PADDING_LENGTH_LUMA * 2), true);
+ H264ExpandPictureLumaAnchor_c (pAnchorDst, iStride, iPicWidth, iPicHeight);
+ sExpandPicFunc.pfExpandLumaPicture (pTestDst, iStride, iPicWidth, iPicHeight);
+ EXPECT_EQ (CompareBuff (pAnchorDstBuff, pTestDstBuff, iStride, iPicWidth + H264_PADDING_LENGTH_LUMA * 2,
+ iPicHeight + H264_PADDING_LENGTH_LUMA * 2), true);
- WELS_SAFE_FREE (pAnchorDstBuff, "pAnchorDstBuff");
- WELS_SAFE_FREE (pTestDstBuff, "pTestDstBuff");
+ WELS_SAFE_FREE (pAnchorDstBuff, "pAnchorDstBuff");
+ WELS_SAFE_FREE (pTestDstBuff, "pTestDstBuff");
+ }
}
}
@@ -133,35 +143,44 @@
TEST (ExpandPicture, ExpandPictureChroma) {
SExpandPicFunc sExpandPicFunc;
- InitExpandPictureFunc (&sExpandPicFunc, 0);
- srand ((unsigned int)time (0));
+ int32_t iCpuCores = 1;
+ uint32_t uiCpuFlag = 0;
+ for(int32_t k =0; k<2; k++) {
+ if(k==0) {
+ uiCpuFlag = 0;
+ }else {
+ uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
+ }
+ InitExpandPictureFunc (&sExpandPicFunc, uiCpuFlag);
+ srand ((unsigned int)time (0));
- for (int32_t iTestIdx = 0; iTestIdx < EXPAND_PIC_TEST_NUM; iTestIdx++) {
- int32_t iPicWidth = (8 + (rand() % 200) * 8);
- int32_t iPicHeight = (8 + (rand() % 100) * 8);
+ for (int32_t iTestIdx = 0; iTestIdx < EXPAND_PIC_TEST_NUM; iTestIdx++) {
+ int32_t iPicWidth = (8 + (rand() % 200) * 8);
+ int32_t iPicHeight = (8 + (rand() % 100) * 8);
- int32_t iStride = (iPicWidth + H264_PADDING_LENGTH_CHROMA * 2 + 8) >> 4 << 4;
- int32_t iBuffHeight = iPicHeight + H264_PADDING_LENGTH_CHROMA * 2;
- int32_t iBuffSize = iBuffHeight * iStride * sizeof (uint8_t);
- uint8_t* pAnchorDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pAnchorDstBuff"));
- uint8_t* pAnchorDst = pAnchorDstBuff + H264_PADDING_LENGTH_CHROMA * iStride + H264_PADDING_LENGTH_CHROMA;
+ int32_t iStride = (iPicWidth + H264_PADDING_LENGTH_CHROMA * 2 + 8) >> 4 << 4;
+ int32_t iBuffHeight = iPicHeight + H264_PADDING_LENGTH_CHROMA * 2;
+ int32_t iBuffSize = iBuffHeight * iStride * sizeof (uint8_t);
+ uint8_t* pAnchorDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pAnchorDstBuff"));
+ uint8_t* pAnchorDst = pAnchorDstBuff + H264_PADDING_LENGTH_CHROMA * iStride + H264_PADDING_LENGTH_CHROMA;
- uint8_t* pTestDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pTestDstBuff"));
- uint8_t* pTestDst = pTestDstBuff + H264_PADDING_LENGTH_CHROMA * iStride + H264_PADDING_LENGTH_CHROMA;
+ uint8_t* pTestDstBuff = static_cast<uint8_t*> (WelsMalloc (iBuffSize, "pTestDstBuff"));
+ uint8_t* pTestDst = pTestDstBuff + H264_PADDING_LENGTH_CHROMA * iStride + H264_PADDING_LENGTH_CHROMA;
- // Generate Src
- for (int32_t j = 0; j < iPicHeight; j++) {
- for (int32_t i = 0; i < iPicWidth; i++) {
- pAnchorDst[i + j * iStride] = pTestDst[i + j * iStride] = rand() % 256;
+ // Generate Src
+ for (int32_t j = 0; j < iPicHeight; j++) {
+ for (int32_t i = 0; i < iPicWidth; i++) {
+ pAnchorDst[i + j * iStride] = pTestDst[i + j * iStride] = rand() % 256;
+ }
}
- }
- H264ExpandPictureChromaAnchor_c (pAnchorDst, iStride, iPicWidth, iPicHeight);
- sExpandPicFunc.pfExpandChromaPicture[0] (pTestDst, iStride, iPicWidth, iPicHeight);
- EXPECT_EQ (CompareBuff (pAnchorDstBuff, pTestDstBuff, iStride, iPicWidth + H264_PADDING_LENGTH_CHROMA * 2,
- iPicHeight + H264_PADDING_LENGTH_CHROMA * 2), true);
+ H264ExpandPictureChromaAnchor_c (pAnchorDst, iStride, iPicWidth, iPicHeight);
+ sExpandPicFunc.pfExpandChromaPicture[0] (pTestDst, iStride, iPicWidth, iPicHeight);
+ EXPECT_EQ (CompareBuff (pAnchorDstBuff, pTestDstBuff, iStride, iPicWidth + H264_PADDING_LENGTH_CHROMA * 2,
+ iPicHeight + H264_PADDING_LENGTH_CHROMA * 2), true);
- WELS_SAFE_FREE (pAnchorDstBuff, "pAnchorDstBuff");
- WELS_SAFE_FREE (pTestDstBuff, "pTestDstBuff");
+ WELS_SAFE_FREE (pAnchorDstBuff, "pAnchorDstBuff");
+ WELS_SAFE_FREE (pTestDstBuff, "pTestDstBuff");
+ }
}
}
@@ -168,50 +187,59 @@
TEST (ExpandPicture, ExpandPicForMotion) {
SExpandPicFunc sExpandPicFunc;
- InitExpandPictureFunc (&sExpandPicFunc, 0);
- srand ((unsigned int)time (0));
- SWelsDecoderContext sCtx;
- PPicture pPicAnchor = NULL;
- PPicture pPicTest = NULL;
- for (int32_t iTestIdx = 0; iTestIdx < EXPAND_PIC_TEST_NUM; iTestIdx++) {
- int32_t iPicWidth = (16 + (rand() % 200) * 16);
- int32_t iPicHeight = (16 + (rand() % 100) * 16);
+ int32_t iCpuCores = 1;
+ uint32_t uiCpuFlag = 0;
+ for(int32_t k =0; k<2; k++) {
+ if(k==0) {
+ uiCpuFlag = 0;
+ }else {
+ uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
+ }
+ InitExpandPictureFunc (&sExpandPicFunc, uiCpuFlag);
+ srand ((unsigned int)time (0));
+ SWelsDecoderContext sCtx;
+ PPicture pPicAnchor = NULL;
+ PPicture pPicTest = NULL;
+ for (int32_t iTestIdx = 0; iTestIdx < EXPAND_PIC_TEST_NUM; iTestIdx++) {
+ int32_t iPicWidth = (16 + (rand() % 200) * 16);
+ int32_t iPicHeight = (16 + (rand() % 100) * 16);
- pPicAnchor = AllocPicture (&sCtx, iPicWidth, iPicHeight);
- pPicTest = AllocPicture (&sCtx, iPicWidth, iPicHeight);
- sCtx.pDec = pPicTest;
+ pPicAnchor = AllocPicture (&sCtx, iPicWidth, iPicHeight);
+ pPicTest = AllocPicture (&sCtx, iPicWidth, iPicHeight);
+ sCtx.pDec = pPicTest;
- int32_t iStride = pPicAnchor->iLinesize[0];
- int32_t iStrideC;
- iStrideC = pPicAnchor->iLinesize[1];
- // Generate Src
- for (int32_t j = 0; j < iPicHeight; j++) {
- for (int32_t i = 0; i < iPicWidth; i++) {
- pPicAnchor->pData[0][i + j * iStride] = pPicTest->pData[0][i + j * iStride] = rand() % 256;
+ int32_t iStride = pPicAnchor->iLinesize[0];
+ int32_t iStrideC;
+ iStrideC = pPicAnchor->iLinesize[1];
+ // Generate Src
+ for (int32_t j = 0; j < iPicHeight; j++) {
+ for (int32_t i = 0; i < iPicWidth; i++) {
+ pPicAnchor->pData[0][i + j * iStride] = pPicTest->pData[0][i + j * iStride] = rand() % 256;
+ }
}
- }
- for (int32_t j = 0; j < iPicHeight / 2; j++) {
- for (int32_t i = 0; i < iPicWidth / 2; i++) {
- pPicAnchor->pData[1][i + j * iStrideC] = pPicTest->pData[1][i + j * iStrideC] = rand() % 256;
- pPicAnchor->pData[2][i + j * iStrideC] = pPicTest->pData[2][i + j * iStrideC] = rand() % 256;
+ for (int32_t j = 0; j < iPicHeight / 2; j++) {
+ for (int32_t i = 0; i < iPicWidth / 2; i++) {
+ pPicAnchor->pData[1][i + j * iStrideC] = pPicTest->pData[1][i + j * iStrideC] = rand() % 256;
+ pPicAnchor->pData[2][i + j * iStrideC] = pPicTest->pData[2][i + j * iStrideC] = rand() % 256;
+ }
}
- }
- H264ExpandPictureLumaAnchor_c (pPicAnchor->pData[0], iStride, iPicWidth, iPicHeight);
- H264ExpandPictureChromaAnchor_c (pPicAnchor->pData[1], iStrideC, iPicWidth / 2, iPicHeight / 2);
- H264ExpandPictureChromaAnchor_c (pPicAnchor->pData[2], iStrideC, iPicWidth / 2, iPicHeight / 2);
- ExpandReferencingPicture (sCtx.pDec->pData, sCtx.pDec->iWidthInPixel, sCtx.pDec->iHeightInPixel, sCtx.pDec->iLinesize,
- sExpandPicFunc.pfExpandLumaPicture, sExpandPicFunc.pfExpandChromaPicture);
+ H264ExpandPictureLumaAnchor_c (pPicAnchor->pData[0], iStride, iPicWidth, iPicHeight);
+ H264ExpandPictureChromaAnchor_c (pPicAnchor->pData[1], iStrideC, iPicWidth / 2, iPicHeight / 2);
+ H264ExpandPictureChromaAnchor_c (pPicAnchor->pData[2], iStrideC, iPicWidth / 2, iPicHeight / 2);
+ ExpandReferencingPicture (sCtx.pDec->pData, sCtx.pDec->iWidthInPixel, sCtx.pDec->iHeightInPixel, sCtx.pDec->iLinesize,
+ sExpandPicFunc.pfExpandLumaPicture, sExpandPicFunc.pfExpandChromaPicture);
- EXPECT_EQ (CompareBuff (pPicAnchor->pBuffer[0], pPicTest->pBuffer[0], iStride, iPicWidth + PADDING_LENGTH * 2,
- iPicHeight + PADDING_LENGTH * 2), true);
- EXPECT_EQ (CompareBuff (pPicAnchor->pBuffer[1], pPicTest->pBuffer[1], iStrideC, iPicWidth / 2 + PADDING_LENGTH,
- iPicHeight / 2 + PADDING_LENGTH), true);
- EXPECT_EQ (CompareBuff (pPicAnchor->pBuffer[2], pPicTest->pBuffer[2], iStrideC, iPicWidth / 2 + PADDING_LENGTH,
- iPicHeight / 2 + PADDING_LENGTH), true);
+ EXPECT_EQ (CompareBuff (pPicAnchor->pBuffer[0], pPicTest->pBuffer[0], iStride, iPicWidth + PADDING_LENGTH * 2,
+ iPicHeight + PADDING_LENGTH * 2), true);
+ EXPECT_EQ (CompareBuff (pPicAnchor->pBuffer[1], pPicTest->pBuffer[1], iStrideC, iPicWidth / 2 + PADDING_LENGTH,
+ iPicHeight / 2 + PADDING_LENGTH), true);
+ EXPECT_EQ (CompareBuff (pPicAnchor->pBuffer[2], pPicTest->pBuffer[2], iStrideC, iPicWidth / 2 + PADDING_LENGTH,
+ iPicHeight / 2 + PADDING_LENGTH), true);
- FreePicture (pPicAnchor);
- FreePicture (pPicTest);
+ FreePicture (pPicAnchor);
+ FreePicture (pPicTest);
+ }
}
}