ref: b7b01faf29d039578d7a8c9d36d1b4ed25a0ae93
parent: 3956a32d416850ed240785a704e44ad5125a3bca
parent: 95a2a401906d5c4d21ea52681b1e327f0ad73371
author: ruil2 <[email protected]>
date: Tue Mar 18 11:04:29 EDT 2014
Merge pull request #526 from licaiguo/IdctResAddPred-pr add IdctResAddPred unit test for decoder
--- /dev/null
+++ b/test/DecUT_IdctResAddPred.cpp
@@ -1,0 +1,82 @@
+#include <gtest/gtest.h>
+#include "macros.h"
+#include "../codec/decoder/core/inc/decode_mb_aux.h"
+using namespace WelsDec;
+void IdctResAddPred_ref (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
+ int16_t iSrc[16];
+
+ uint8_t* pDst = pPred;
+ const int32_t kiStride2 = kiStride << 1;
+ const int32_t kiStride3 = kiStride + kiStride2;
+ int32_t i;
+
+ for (i = 0; i < 4; i++) {
+ const int32_t kiY = i << 2;
+ const int32_t kiT0 = pRs[kiY] + pRs[kiY + 2];
+ const int32_t kiT1 = pRs[kiY] - pRs[kiY + 2];
+ const int32_t kiT2 = (pRs[kiY + 1] >> 1) - pRs[kiY + 3];
+ const int32_t kiT3 = pRs[kiY + 1] + (pRs[kiY + 3] >> 1);
+
+ iSrc[kiY] = kiT0 + kiT3;
+ iSrc[kiY + 1] = kiT1 + kiT2;
+ iSrc[kiY + 2] = kiT1 - kiT2;
+ iSrc[kiY + 3] = kiT0 - kiT3;
+ }
+
+ for (i = 0; i < 4; i++) {
+ int32_t kT1 = iSrc[i] + iSrc[i + 8];
+ int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1);
+ int32_t kT3 = (32 + kT1 + kT2) >> 6;
+ int32_t kT4 = (32 + kT1 - kT2) >> 6;
+
+ pDst[i] = WELS_CLIP1 (kT3 + pPred[i]);
+ pDst[i + kiStride3] = WELS_CLIP1 (kT4 + pPred[i + kiStride3]);
+
+ kT1 = iSrc[i] - iSrc[i + 8];
+ kT2 = (iSrc[i + 4] >> 1) - iSrc[i + 12];
+ pDst[i + kiStride] = WELS_CLIP1 (((32 + kT1 + kT2) >> 6) + pDst[i + kiStride]);
+ pDst[i + kiStride2] = WELS_CLIP1 (((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2]);
+ }
+}
+
+#define GENERATE_IDCTRESADDPRED(pred) \
+TEST(DecoderDecodeMbAux, pred) {\
+ const int32_t kiStride = 32;\
+ const int iBits = 12;\
+ const int iMask = (1 << iBits) - 1;\
+ const int iOffset = 1 << (iBits - 1);\
+ int16_t iRS[16];\
+ uint8_t uiPred[16*kiStride];\
+ int16_t iRefRS[16];\
+ uint8_t uiRefPred[16*kiStride];\
+ int32_t iRunTimes = 1000;\
+ srand((unsigned int)time(NULL));\
+ while(iRunTimes--) {\
+ for(int i = 0; i < 4; i++)\
+ for(int j = 0; j < 4; j++)\
+ iRefRS[i*4+j] = iRS[i*4+j] = (rand() & iMask) - iOffset;\
+ for(int i = 0; i < 4; i++)\
+ for(int j = 0; j < 4; j++)\
+ uiRefPred[i * kiStride + j] = uiPred[i * kiStride + j] = rand() & 255;\
+ pred(uiPred, kiStride, iRS);\
+ IdctResAddPred_ref(uiRefPred, kiStride, iRefRS);\
+ bool ok = true;\
+ for(int i = 0; i < 4; i++)\
+ for(int j = 0; j < 4; j++)\
+ if (uiRefPred[i * kiStride + j] != uiPred[i * kiStride + j]) {\
+ ok = false;\
+ goto next;\
+ }\
+ next:\
+ EXPECT_EQ(ok, true);\
+ }\
+}
+
+GENERATE_IDCTRESADDPRED (IdctResAddPred_c)
+#if defined(X86_ASM)
+GENERATE_IDCTRESADDPRED (IdctResAddPred_mmx)
+#endif
+
+#if defined(HAVE_NEON)
+GENERATE_IDCTRESADDPRED (IdctResAddPred_neon)
+#endif
--- a/test/targets.mk
+++ b/test/targets.mk
@@ -10,6 +10,7 @@
$(CODEC_UNITTEST_SRCDIR)/EncUT_MemoryAlloc.cpp\
$(CODEC_UNITTEST_SRCDIR)/EncUT_MotionEstimate.cpp\
$(CODEC_UNITTEST_SRCDIR)/simple_test.cpp\
+ $(CODEC_UNITTEST_SRCDIR)/DecUT_IdctResAddPred.cpp\
CODEC_UNITTEST_OBJS += $(CODEC_UNITTEST_CPP_SRCS:.cpp=.o)