ref: 62139f09819f7e09a713fae90aa09c7c22db582f
parent: 9e8d6fc36dde22177981a890353446c62ee9e5fa
parent: 2d335320c102385a4b721b847fda70b1e9bdfc02
author: Licai Guo <[email protected]>
date: Fri Mar 28 07:14:10 EDT 2014
Merge pull request #593 from ganyangbbl/encUT_ExpandPic3 add ExpandPic encoder unit test file
--- /dev/null
+++ b/test/encoder/EncUT_ExpandPic.cpp
@@ -1,0 +1,152 @@
+#include<gtest/gtest.h>
+#include<stdlib.h>
+
+#include "wels_func_ptr_def.h"
+#include "expand_pic.h"
+
+using namespace WelsSVCEnc;
+
+TEST(ExpandPicTest, TestExpand_picture_luma_c)
+{
+ SWelsFuncPtrList sFuncList;
+ InitExpandPictureFunc( &sFuncList, 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.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, TestExpand_picture_chroma_c)
+{
+ SWelsFuncPtrList sFuncList;
+ InitExpandPictureFunc( &sFuncList, 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.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
@@ -1,5 +1,6 @@
ENCODER_UNITTEST_SRCDIR=test/encoder
ENCODER_UNITTEST_CPP_SRCS=\
+ $(ENCODER_UNITTEST_SRCDIR)/EncUT_ExpandPic.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryAlloc.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MotionEstimate.cpp\