ref: 492627977e800388a54e6f84be3a0da1becdebf4
parent: c38126b094c51222a26e1725ba6421527d3c18bd
parent: 1e43075b258dd1b372447b60552c59ee2af0bde8
author: dongzha <[email protected]>
date: Thu Jun 12 06:46:06 EDT 2014
Merge pull request #961 from ruil2/expand_update update expand picture UT
--- a/Makefile
+++ b/Makefile
@@ -97,6 +97,7 @@
ENCODER_UNITTEST_INCLUDES = $(CODEC_UNITTEST_INCLUDES) $(ENCODER_INCLUDES) -Itest -Itest/encoder
PROCESSING_UNITTEST_INCLUDES = $(CODEC_UNITTEST_INCLUDES) $(PROCESSING_INCLUDES) -Itest -Itest/processing
API_TEST_INCLUDES = $(CODEC_UNITTEST_INCLUDES) -Itest -Itest/api
+COMMON_UNITTEST_INCLUDES = $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES) -Itest -Itest/common
.PHONY: test gtest-bootstrap clean
all: libraries binaries
@@ -177,15 +178,16 @@
include test/decoder/targets.mk
include test/encoder/targets.mk
include test/processing/targets.mk
+include test/common/targets.mk
LIBRARIES += $(LIBPREFIX)ut.$(LIBSUFFIX)
-$(LIBPREFIX)ut.$(LIBSUFFIX): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS)
+$(LIBPREFIX)ut.$(LIBSUFFIX): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(COMMON_UNITTEST_OBJS) $(API_TEST_OBJS)
$(QUIET)rm -f $@
$(QUIET_AR)$(AR) $(AR_OPTS) $+
LIBRARIES +=$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
-$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(CODEC_UNITTEST_DEPS)
+$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(COMMON_UNITTEST_OBJS) $(CODEC_UNITTEST_DEPS)
$(QUIET)rm -f $@
$(QUIET_CXX)$(CXX) $(SHARED) $(LDFLAGS) $(CXX_LINK_O) $+ $(CODEC_UNITTEST_LDFLAGS)
@@ -205,7 +207,7 @@
cd ./test/build/android && $(NDKROOT)/ndk-build APP_ABI=$(APP_ABI) clean && ant clean
else
-codec_unittest$(EXEEXT): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(CODEC_UNITTEST_DEPS)
+codec_unittest$(EXEEXT): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(COMMON_UNITTEST_OBJS) $(CODEC_UNITTEST_DEPS)
$(QUIET)rm -f $@
$(QUIET_CXX)$(CXX) $(CXX_LINK_O) $+ $(CODEC_UNITTEST_LDFLAGS) $(LDFLAGS)
--- /dev/null
+++ b/test/common/ExpandPicture.cpp
@@ -1,0 +1,267 @@
+#include<gtest/gtest.h>
+#include "codec_def.h"
+#include "expand_pic.h"
+#include "mem_align.h"
+#include "decoder_context.h"
+#include "cpu.h"
+#include "cpu_core.h"
+#define EXPAND_PIC_TEST_NUM 10
+#define H264_PADDING_LENGTH_LUMA (PADDING_LENGTH)
+#define H264_PADDING_LENGTH_CHROMA (PADDING_LENGTH>>1)
+
+using namespace WelsDec;
+
+void H264ExpandPictureLumaAnchor_c (uint8_t* pDst, int32_t iStride, int32_t iPicWidth, int32_t iPicHeight) {
+ uint8_t* pTmp = pDst;
+ uint8_t* pDstLastLine = pTmp + (iPicHeight - 1) * iStride;
+ uint8_t pTL = pTmp[0];
+ uint8_t pTR = pTmp[iPicWidth - 1];
+ uint8_t pBL = pDstLastLine[0];
+ uint8_t pBR = pDstLastLine[iPicWidth - 1];
+ int32_t i = 0;
+
+ do {
+ const int32_t kStrides = (1 + i) * iStride;
+ uint8_t* pTop = pTmp - kStrides;
+ uint8_t* pBottom = pDstLastLine + kStrides;
+
+ // pad pTop and pBottom
+ memcpy (pTop, pTmp, iPicWidth);
+ memcpy (pBottom, pDstLastLine, iPicWidth);
+
+ // pad corners
+ memset (pTop - H264_PADDING_LENGTH_LUMA, pTL, H264_PADDING_LENGTH_LUMA); //pTop left
+ memset (pTop + iPicWidth, pTR, H264_PADDING_LENGTH_LUMA); //pTop right
+ memset (pBottom - H264_PADDING_LENGTH_LUMA, pBL, H264_PADDING_LENGTH_LUMA); //pBottom left
+ memset (pBottom + iPicWidth, pBR, H264_PADDING_LENGTH_LUMA); //pBottom right
+ ++ i;
+ } while (i < H264_PADDING_LENGTH_LUMA);
+
+ // pad left and right
+ i = 0;
+ do {
+ memset (pTmp - H264_PADDING_LENGTH_LUMA, pTmp[0], H264_PADDING_LENGTH_LUMA);
+ memset (pTmp + iPicWidth, pTmp[iPicWidth - 1], H264_PADDING_LENGTH_LUMA);
+ pTmp += iStride;
+ ++ i;
+ } while (i < iPicHeight);
+}
+
+void H264ExpandPictureChromaAnchor_c (uint8_t* pDst, int32_t iStride, int32_t iPicWidth, int32_t iPicHeight) {
+ uint8_t* pTmp = pDst;
+ uint8_t* pDstLastLine = pTmp + (iPicHeight - 1) * iStride;
+ uint8_t pTL = pTmp[0];
+ uint8_t pTR = pTmp[iPicWidth - 1];
+ uint8_t pBL = pDstLastLine[0];
+ uint8_t pBR = pDstLastLine[iPicWidth - 1];
+ int32_t i = 0;
+
+ do {
+ const int32_t kStrides = (1 + i) * iStride;
+ uint8_t* pTop = pTmp - kStrides;
+ uint8_t* pBottom = pDstLastLine + kStrides;
+
+ // pad pTop and pBottom
+ memcpy (pTop, pTmp, iPicWidth);
+ memcpy (pBottom, pDstLastLine, iPicWidth);
+
+ // pad corners
+ memset (pTop - H264_PADDING_LENGTH_CHROMA, pTL, H264_PADDING_LENGTH_CHROMA); //pTop left
+ memset (pTop + iPicWidth, pTR, H264_PADDING_LENGTH_CHROMA); //pTop right
+ memset (pBottom - H264_PADDING_LENGTH_CHROMA, pBL, H264_PADDING_LENGTH_CHROMA); //pBottom left
+ memset (pBottom + iPicWidth, pBR, H264_PADDING_LENGTH_CHROMA); //pBottom right
+
+ ++ i;
+ } while (i < H264_PADDING_LENGTH_CHROMA);
+
+ // pad left and right
+ i = 0;
+ do {
+ memset (pTmp - H264_PADDING_LENGTH_CHROMA, pTmp[0], H264_PADDING_LENGTH_CHROMA);
+ memset (pTmp + iPicWidth, pTmp[iPicWidth - 1], H264_PADDING_LENGTH_CHROMA);
+
+ pTmp += iStride;
+ ++ i;
+ } while (i < iPicHeight);
+}
+
+bool CompareBuff (uint8_t* pSrc0, uint8_t* pSrc1, int32_t iStride, int32_t iWidth, int32_t iHeight) {
+ for (int32_t j = 0; j < iHeight; j++) {
+ for (int32_t i = 0; i < iWidth; i++) {
+ if (pSrc0[i + j * iStride] != pSrc1[i + j * iStride]) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+bool CompareImage (uint8_t* pSrc0, uint8_t* pSrc1, int32_t iSize) {
+ for (int32_t n = 0; n < iSize; n++) {
+ if (pSrc0[n] != pSrc1[n]) {
+ return false;
+ }
+
+ }
+ return true;
+}
+
+TEST (ExpandPicture, ExpandPictureLuma) {
+ SExpandPicFunc sExpandPicFunc;
+ 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;
+
+ 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;
+ }
+ }
+ 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");
+ }
+ }
+
+}
+
+TEST (ExpandPicture, ExpandPictureChroma) {
+ SExpandPicFunc sExpandPicFunc;
+ 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);
+ if (uiCpuFlag & WELS_CPU_SSE2) {
+ iPicWidth = WELS_MAX (iPicWidth, 16);
+ }
+ 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;
+
+ 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;
+ }
+ }
+ 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");
+ }
+ }
+
+}
+
+TEST (ExpandPicture, ExpandPicForMotion) {
+ SExpandPicFunc sExpandPicFunc;
+ 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));
+ uint8_t* pPicAnchorBuffer = NULL;
+ uint8_t* pPicTestBuffer = NULL;
+ uint8_t* pPicAnchor[3] = {NULL, NULL, NULL};
+ uint8_t* pPicTest[3] = {NULL, NULL, NULL};
+ int32_t iStride[3];
+ 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);
+ if (uiCpuFlag & WELS_CPU_SSE2) {
+ iPicWidth = WELS_ALIGN (iPicWidth, 32);
+ }
+ iStride[0] = WELS_ALIGN (iPicWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon
+ int32_t iPicHeightExt = WELS_ALIGN (iPicHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical
+ iStride[1] = iStride[0] >> 1;
+ int32_t iPicChromaHeightExt = iPicHeightExt >> 1;
+ iStride[2] = iStride[1];
+ int32_t iLumaSize = iStride[0] * iPicHeightExt;
+ int32_t iChromaSize = iStride[1] * iPicChromaHeightExt;
+
+ pPicAnchorBuffer = static_cast<uint8_t*> (WelsMalloc (iLumaSize + (iChromaSize << 1), "pPicAnchor"));
+ pPicAnchor[0] = pPicAnchorBuffer + (1 + iStride[0]) * PADDING_LENGTH;
+ pPicAnchor[1] = pPicAnchorBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1);
+ pPicAnchor[2] = pPicAnchorBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1);
+
+ pPicTestBuffer = static_cast<uint8_t*> (WelsMalloc (iLumaSize + (iChromaSize << 1), "pPicTest"));
+ pPicTest[0] = pPicTestBuffer + (1 + iStride[0]) * PADDING_LENGTH;
+ pPicTest[1] = pPicTestBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1);
+ pPicTest[2] = pPicTestBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1);
+
+
+ // Generate Src
+ for (int32_t j = 0; j < iPicHeight; j++) {
+ for (int32_t i = 0; i < iPicWidth; i++) {
+ pPicAnchor[0][i + j * iStride[0]] = pPicTest[0][i + j * iStride[0]] = rand() % 256;
+ }
+ }
+ for (int32_t j = 0; j < iPicHeight / 2; j++) {
+ for (int32_t i = 0; i < iPicWidth / 2; i++) {
+ pPicAnchor[1][i + j * iStride[1]] = pPicTest[1][i + j * iStride[1]] = rand() % 256;
+ pPicAnchor[2][i + j * iStride[2]] = pPicTest[2][i + j * iStride[2]] = rand() % 256;
+ }
+ }
+ H264ExpandPictureLumaAnchor_c (pPicAnchor[0], iStride[0], iPicWidth, iPicHeight);
+ H264ExpandPictureChromaAnchor_c (pPicAnchor[1], iStride[1], iPicWidth / 2, iPicHeight / 2);
+ H264ExpandPictureChromaAnchor_c (pPicAnchor[2], iStride[2], iPicWidth / 2, iPicHeight / 2);
+ ExpandReferencingPicture (pPicTest, iPicWidth, iPicHeight, iStride,
+ sExpandPicFunc.pfExpandLumaPicture, sExpandPicFunc.pfExpandChromaPicture);
+ EXPECT_EQ (CompareImage (pPicAnchorBuffer, pPicTestBuffer, (iLumaSize + (iChromaSize << 1))), true);
+
+
+ WELS_SAFE_FREE (pPicAnchorBuffer, "pPicAnchor");
+ WELS_SAFE_FREE (pPicTestBuffer, "pPicTest");
+
+ }
+ }
+}
+
--- /dev/null
+++ b/test/common/targets.mk
@@ -1,0 +1,10 @@
+COMMON_UNITTEST_SRCDIR=test/common
+COMMON_UNITTEST_CPP_SRCS=\
+ $(COMMON_UNITTEST_SRCDIR)/ExpandPicture.cpp\
+
+COMMON_UNITTEST_OBJS += $(COMMON_UNITTEST_CPP_SRCS:.cpp=.$(OBJ))
+
+OBJS += $(COMMON_UNITTEST_OBJS)
+$(COMMON_UNITTEST_SRCDIR)/%.$(OBJ): $(COMMON_UNITTEST_SRCDIR)/%.cpp
+ $(QUIET_CXX)$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(COMMON_UNITTEST_CFLAGS) $(COMMON_UNITTEST_INCLUDES) -c $(CXX_O) $<
+
--- a/test/decoder/DecUT_ExpandPicture.cpp
+++ /dev/null
@@ -1,249 +1,0 @@
-#include<gtest/gtest.h>
-#include "codec_def.h"
-#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 {
-extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kPicWidth, const int32_t kPicHeight);
-extern void FreePicture (PPicture pPic);
-}
-#define H264_PADDING_LENGTH_LUMA (PADDING_LENGTH)
-#define H264_PADDING_LENGTH_CHROMA (PADDING_LENGTH>>1)
-
-void H264ExpandPictureLumaAnchor_c (uint8_t* pDst, int32_t iStride, int32_t iPicWidth, int32_t iPicHeight) {
- uint8_t* pTmp = pDst;
- uint8_t* pDstLastLine = pTmp + (iPicHeight - 1) * iStride;
- uint8_t pTL = pTmp[0];
- uint8_t pTR = pTmp[iPicWidth - 1];
- uint8_t pBL = pDstLastLine[0];
- uint8_t pBR = pDstLastLine[iPicWidth - 1];
- int32_t i = 0;
-
- do {
- const int32_t kStrides = (1 + i) * iStride;
- uint8_t* pTop = pTmp - kStrides;
- uint8_t* pBottom = pDstLastLine + kStrides;
-
- // pad pTop and pBottom
- memcpy (pTop, pTmp, iPicWidth);
- memcpy (pBottom, pDstLastLine, iPicWidth);
-
- // pad corners
- memset (pTop - H264_PADDING_LENGTH_LUMA, pTL, H264_PADDING_LENGTH_LUMA); //pTop left
- memset (pTop + iPicWidth, pTR, H264_PADDING_LENGTH_LUMA); //pTop right
- memset (pBottom - H264_PADDING_LENGTH_LUMA, pBL, H264_PADDING_LENGTH_LUMA); //pBottom left
- memset (pBottom + iPicWidth, pBR, H264_PADDING_LENGTH_LUMA); //pBottom right
- ++ i;
- } while (i < H264_PADDING_LENGTH_LUMA);
-
- // pad left and right
- i = 0;
- do {
- memset (pTmp - H264_PADDING_LENGTH_LUMA, pTmp[0], H264_PADDING_LENGTH_LUMA);
- memset (pTmp + iPicWidth, pTmp[iPicWidth - 1], H264_PADDING_LENGTH_LUMA);
- pTmp += iStride;
- ++ i;
- } while (i < iPicHeight);
-}
-
-void H264ExpandPictureChromaAnchor_c (uint8_t* pDst, int32_t iStride, int32_t iPicWidth, int32_t iPicHeight) {
- uint8_t* pTmp = pDst;
- uint8_t* pDstLastLine = pTmp + (iPicHeight - 1) * iStride;
- uint8_t pTL = pTmp[0];
- uint8_t pTR = pTmp[iPicWidth - 1];
- uint8_t pBL = pDstLastLine[0];
- uint8_t pBR = pDstLastLine[iPicWidth - 1];
- int32_t i = 0;
-
- do {
- const int32_t kStrides = (1 + i) * iStride;
- uint8_t* pTop = pTmp - kStrides;
- uint8_t* pBottom = pDstLastLine + kStrides;
-
- // pad pTop and pBottom
- memcpy (pTop, pTmp, iPicWidth);
- memcpy (pBottom, pDstLastLine, iPicWidth);
-
- // pad corners
- memset (pTop - H264_PADDING_LENGTH_CHROMA, pTL, H264_PADDING_LENGTH_CHROMA); //pTop left
- memset (pTop + iPicWidth, pTR, H264_PADDING_LENGTH_CHROMA); //pTop right
- memset (pBottom - H264_PADDING_LENGTH_CHROMA, pBL, H264_PADDING_LENGTH_CHROMA); //pBottom left
- memset (pBottom + iPicWidth, pBR, H264_PADDING_LENGTH_CHROMA); //pBottom right
-
- ++ i;
- } while (i < H264_PADDING_LENGTH_CHROMA);
-
- // pad left and right
- i = 0;
- do {
- memset (pTmp - H264_PADDING_LENGTH_CHROMA, pTmp[0], H264_PADDING_LENGTH_CHROMA);
- memset (pTmp + iPicWidth, pTmp[iPicWidth - 1], H264_PADDING_LENGTH_CHROMA);
-
- pTmp += iStride;
- ++ i;
- } while (i < iPicHeight);
-}
-
-bool CompareBuff (uint8_t* pSrc0, uint8_t* pSrc1, int32_t iStride, int32_t iWidth, int32_t iHeight) {
- for (int32_t j = 0; j < iHeight; j++) {
- for (int32_t i = 0; i < iWidth; i++) {
- if (pSrc0[i + j * iStride] != pSrc1[i + j * iStride]) {
- return false;
- }
- }
- }
- return true;
-}
-
-TEST (ExpandPicture, ExpandPictureLuma) {
- SExpandPicFunc sExpandPicFunc;
- 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;
-
- 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;
- }
- }
- 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");
- }
- }
-
-}
-
-TEST (ExpandPicture, ExpandPictureChroma) {
- SExpandPicFunc sExpandPicFunc;
- 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);
- if(uiCpuFlag & WELS_CPU_SSE2)
- {
- iPicWidth = WELS_MAX(iPicWidth, 16);
- }
- 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;
-
- 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;
- }
- }
- 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");
- }
- }
-
-}
-
-TEST (ExpandPicture, ExpandPicForMotion) {
- SExpandPicFunc sExpandPicFunc;
- 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;
-
- 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;
- }
- }
-
- 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);
-
- FreePicture (pPicAnchor);
- FreePicture (pPicTest);
- }
- }
-}
-
--- a/test/decoder/targets.mk
+++ b/test/decoder/targets.mk
@@ -2,7 +2,6 @@
DECODER_UNITTEST_CPP_SRCS=\
$(DECODER_UNITTEST_SRCDIR)/DecUT_Deblock.cpp\
$(DECODER_UNITTEST_SRCDIR)/DecUT_ErrorConcealment.cpp\
- $(DECODER_UNITTEST_SRCDIR)/DecUT_ExpandPicture.cpp\
$(DECODER_UNITTEST_SRCDIR)/DecUT_IdctResAddPred.cpp\
$(DECODER_UNITTEST_SRCDIR)/DecUT_IntraPrediction.cpp\
$(DECODER_UNITTEST_SRCDIR)/DecUT_MotionCompensation.cpp\
--- a/test/encoder/EncUT_ExpandPic.cpp
+++ /dev/null
@@ -1,150 +1,0 @@
-#include<gtest/gtest.h>
-#include<stdlib.h>
-
-#include "wels_func_ptr_def.h"
-#include "expand_pic.h"
-
-using namespace WelsSVCEnc;
-
-TEST (ExpandPicTest, TestExpandPictureLuma_c) {
- SWelsFuncPtrList sFuncList;
- InitExpandPictureFunc (& (sFuncList.sExpandPicFunc), 0);
-
- int32_t iPicW = rand() % 256 + 1;
- int32_t iPicH = rand() % 256 + 1;
- int32_t iStride = iPicW + rand() % 16 + 1 + PADDING_LENGTH * 2;
-
- const int32_t kiPaddingLen = PADDING_LENGTH;
- const int32_t kiMemSize = (iStride + kiPaddingLen * 2) * (iPicH + kiPaddingLen * 2);
-
- uint8_t* pRef = new uint8_t[kiMemSize];
-
- for (int i = 0; i < kiMemSize; i++)
- pRef[i] = rand() % 256 + 1;
-
- uint8_t* pDst = pRef + kiPaddingLen * iStride + kiPaddingLen;
-
- sFuncList.sExpandPicFunc.pfExpandLumaPicture (pDst, iStride, iPicW, iPicH);
-
- int k = 0;
- //top and top corner
- for (int i = 0; i < kiPaddingLen; i++) {
- for (int j = 0; j < iPicW + 2 * kiPaddingLen; j++) {
- if (j < kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[0]);
- } else if (j >= iPicW + kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[iPicW - 1]);
- } else
- EXPECT_EQ (pRef[k + j], pDst[j - kiPaddingLen]);
- }
- k += iStride;
- }
-
- k = (iPicH + kiPaddingLen - 1) * iStride;
- //bottom and bottom corner
- for (int i = iPicH + kiPaddingLen; i < iPicH + 2 * kiPaddingLen; i++) {
- for (int j = 0; j < iPicW + 2 * kiPaddingLen; j++) {
- if (j < kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride]);
- } else if (j >= iPicW + kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + iPicW - 1]);
- } else
- EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + j - kiPaddingLen]);
- }
- k += iStride;
- }
-
- k = kiPaddingLen * iStride;
- int l = 0;
- for (int i = 0; i < iPicH - 1; i++) { //left
- for (int j = 0; j < kiPaddingLen; j++) {
- EXPECT_EQ (pRef[k + j], pDst[l]);
- }
- k += iStride;
- l += iStride;
- }
-
- k = kiPaddingLen * iStride;
- l = 0;
- for (int i = 0; i < iPicH - 1; i++) { //right
- for (int j = iPicW + kiPaddingLen; j < iPicW + 2 * kiPaddingLen; j++) {
- EXPECT_EQ (pRef[k + j], pDst[l + iPicW - 1]);
- }
- k += iStride;
- l += iStride;
- }
-
- delete []pRef;
-}
-
-TEST (ExpandPicTest, TestExpandPictureChroma_c) {
- SWelsFuncPtrList sFuncList;
- InitExpandPictureFunc (& (sFuncList.sExpandPicFunc), 0);
-
- int32_t iPicW = rand() % 256 + 1;
- int32_t iPicH = rand() % 256 + 1;
-
- const int32_t kiPaddingLen = (PADDING_LENGTH >> 1);
- int32_t iStride = iPicW + rand() % 16 + 1 + kiPaddingLen * 2;
-
- const int32_t kiMemSize = (iStride + kiPaddingLen * 2) * (iPicH + kiPaddingLen * 2);
-
- uint8_t* pRef = new uint8_t[kiMemSize];
-
- for (int i = 0; i < kiMemSize; i++)
- pRef[i] = rand() % 256 + 1;
-
- uint8_t* pDst = pRef + kiPaddingLen * iStride + kiPaddingLen;
-
- sFuncList.sExpandPicFunc.pfExpandChromaPicture[0] (pDst, iStride, iPicW, iPicH);
-
- int k = 0;
- //top and top corner
- for (int i = 0; i < kiPaddingLen; i++) {
- for (int j = 0; j < iPicW + 2 * kiPaddingLen; j++) {
- if (j < kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[0]);
- } else if (j >= iPicW + kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[iPicW - 1]);
- } else
- EXPECT_EQ (pRef[k + j], pDst[j - kiPaddingLen]);
- }
- k += iStride;
- }
-
- k = (iPicH + kiPaddingLen - 1) * iStride;
- //bottom and bottom corner
- for (int i = iPicH + kiPaddingLen; i < iPicH + 2 * kiPaddingLen; i++) {
- for (int j = 0; j < iPicW + 2 * kiPaddingLen; j++) {
- if (j < kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride]);
- } else if (j >= iPicW + kiPaddingLen) {
- EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + iPicW - 1]);
- } else
- EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + j - kiPaddingLen]);
- }
- k += iStride;
- }
-
- k = kiPaddingLen * iStride;
- int l = 0;
- for (int i = 0; i < iPicH - 1; i++) { //left
- for (int j = 0; j < kiPaddingLen; j++) {
- EXPECT_EQ (pRef[k + j], pDst[l]);
- }
- k += iStride;
- l += iStride;
- }
-
- k = kiPaddingLen * iStride;
- l = 0;
- for (int i = 0; i < iPicH - 1; i++) { //right
- for (int j = iPicW + kiPaddingLen; j < iPicW + 2 * kiPaddingLen; j++) {
- EXPECT_EQ (pRef[k + j], pDst[l + iPicW - 1]);
- }
- k += iStride;
- l += iStride;
- }
-
- delete []pRef;
-}
--- a/test/encoder/targets.mk
+++ b/test/encoder/targets.mk
@@ -3,7 +3,6 @@
$(ENCODER_UNITTEST_SRCDIR)/EncUT_DecodeMbAux.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMb.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMbAux.cpp\
- $(ENCODER_UNITTEST_SRCDIR)/EncUT_ExpandPic.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_ExpGolomb.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_GetIntraPredictor.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryAlloc.cpp\