ref: e51b6365959a59a870749ec5692199dc4c9d0eaf
parent: 0e0f7d8f06aa66b44dc9e5a7459fb12e63594b2f
author: ganyang <ganyang@cisco.com>
date: Thu Apr 3 06:38:46 EDT 2014
add GetIntraPred UT Files
--- a/test/api/DataGenerator.cpp
+++ b/test/api/DataGenerator.cpp
@@ -47,7 +47,7 @@
void RandomPixelDataGenerator( uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride, int32_t iIdx )
{
uint8_t* pLocalPointer = pPointer;
- srand((uint32_t)(time(NULL)+iIdx));
+ srand((uint32_t)(time(NULL)+iIdx));
for (int32_t j=0;j<iHeight;j++) {
for (int32_t i=0;i<iWidth;i++) {
pLocalPointer[i] = rand()%256;
--- /dev/null
+++ b/test/encoder/EncUT_EncoderMb.cpp
@@ -1,0 +1,200 @@
+#include <gtest/gtest.h>
+
+#include "memory_align.h"
+#include "utils/DataGenerator.h"
+
+using namespace WelsSVCEnc;
+#include "encode_mb_aux.h"
+
+__align16( const int16_t, g_kiQuantInterFFCompare[104][8] ) = {
+/* 0*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
+/* 1*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
+/* 2*/ { 1, 1, 1, 1, 1, 1, 1, 1 },
+/* 3*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
+/* 4*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
+/* 5*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
+/* 6*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
+/* 7*/ { 1, 2, 1, 2, 2, 2, 2, 2 },
+/* 8*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
+/* 9*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
+/*10*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
+/*11*/ { 2, 2, 2, 2, 2, 4, 2, 4 },
+/*12*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
+/*13*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
+/*14*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
+/*15*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
+/*16*/ { 3, 4, 3, 4, 4, 7, 4, 7 },
+/*17*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
+/*18*/ { 3, 6, 3, 6, 6, 9, 6, 9 },
+/*19*/ { 4, 6, 4, 6, 6, 10, 6, 10 },
+/*20*/ { 4, 7, 4, 7, 7, 11, 7, 11 },
+/*21*/ { 5, 8, 5, 8, 8, 12, 8, 12 },
+/*22*/ { 6, 9, 6, 9, 9, 13, 9, 13 },
+/*23*/ { 6, 10, 6, 10, 10, 16, 10, 16 },
+/*24*/ { 7, 11, 7, 11, 11, 17, 11, 17 },
+/*25*/ { 8, 12, 8, 12, 12, 19, 12, 19 },
+/*26*/ { 9, 14, 9, 14, 14, 21, 14, 21 },
+/*27*/ { 10, 15, 10, 15, 15, 25, 15, 25 },
+/*28*/ { 11, 17, 11, 17, 17, 27, 17, 27 },
+/*29*/ { 12, 20, 12, 20, 20, 31, 20, 31 },
+/*30*/ { 14, 22, 14, 22, 22, 34, 22, 34 },
+/*31*/ { 15, 24, 15, 24, 24, 39, 24, 39 },
+/*32*/ { 18, 27, 18, 27, 27, 43, 27, 43 },
+/*33*/ { 19, 31, 19, 31, 31, 49, 31, 49 },
+/*34*/ { 22, 34, 22, 34, 34, 54, 34, 54 },
+/*35*/ { 25, 40, 25, 40, 40, 62, 40, 62 },
+/*36*/ { 27, 45, 27, 45, 45, 69, 45, 69 },
+/*37*/ { 30, 48, 30, 48, 48, 77, 48, 77 },
+/*38*/ { 36, 55, 36, 55, 55, 86, 55, 86 },
+/*39*/ { 38, 62, 38, 62, 62, 99, 62, 99 },
+/*40*/ { 44, 69, 44, 69, 69, 107, 69, 107 },
+/*41*/ { 49, 79, 49, 79, 79, 125, 79, 125 },
+/*42*/ { 55, 89, 55, 89, 89, 137, 89, 137 },
+/*43*/ { 61, 96, 61, 96, 96, 154, 96, 154 },
+/*44*/ { 71, 110, 71, 110, 110, 171, 110, 171 },
+/*45*/ { 77, 124, 77, 124, 124, 198, 124, 198 },
+/*46*/ { 88, 137, 88, 137, 137, 217, 137, 217 },
+/*47*/ { 99, 159, 99, 159, 159, 250, 159, 250 },
+/*48*/ { 110, 179, 110, 179, 179, 275, 179, 275 },
+/*49*/ { 121, 191, 121, 191, 191, 313, 191, 313 },
+/*50*/ { 143, 221, 143, 221, 221, 341, 221, 341 },
+/*51*/ { 154, 245, 154, 245, 245, 402, 245, 402 },
+//from here below is intra
+/* 0*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
+/* 1*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
+/* 2*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
+/* 3*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
+/* 4*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
+/* 5*/ { 1, 2, 1, 2, 2, 4, 2, 4 },
+/* 6*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
+/* 7*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
+/* 8*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
+/* 9*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
+/*10*/ { 3, 4, 3, 4, 4, 6, 4, 6 },
+/*11*/ { 3, 5, 3, 5, 5, 7, 5, 7 },
+/*12*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
+/*13*/ { 4, 6, 4, 6, 6, 9, 6, 9 },
+/*14*/ { 4, 7, 4, 7, 7, 10, 7, 10 },
+/*15*/ { 5, 7, 5, 7, 7, 12, 7, 12 },
+/*16*/ { 5, 8, 5, 8, 8, 13, 8, 13 },
+/*17*/ { 6, 9, 6, 9, 9, 15, 9, 15 },
+/*18*/ { 7, 11, 7, 11, 11, 16, 11, 16 },
+/*19*/ { 7, 11, 7, 11, 11, 18, 11, 18 },
+/*20*/ { 9, 13, 9, 13, 13, 20, 13, 20 },
+/*21*/ { 9, 15, 9, 15, 15, 24, 15, 24 },
+/*22*/ { 11, 16, 11, 16, 16, 26, 16, 26 },
+/*23*/ { 12, 19, 12, 19, 19, 30, 19, 30 },
+/*24*/ { 13, 21, 13, 21, 21, 33, 21, 33 },
+/*25*/ { 14, 23, 14, 23, 23, 37, 23, 37 },
+/*26*/ { 17, 26, 17, 26, 26, 41, 26, 41 },
+/*27*/ { 18, 30, 18, 30, 30, 47, 30, 47 },
+/*28*/ { 21, 33, 21, 33, 33, 51, 33, 51 },
+/*29*/ { 24, 38, 24, 38, 38, 59, 38, 59 },
+/*30*/ { 26, 43, 26, 43, 43, 66, 43, 66 },
+/*31*/ { 29, 46, 29, 46, 46, 74, 46, 74 },
+/*32*/ { 34, 52, 34, 52, 52, 82, 52, 82 },
+/*33*/ { 37, 59, 37, 59, 59, 94, 59, 94 },
+/*34*/ { 42, 66, 42, 66, 66, 102, 66, 102 },
+/*35*/ { 47, 75, 47, 75, 75, 119, 75, 119 },
+/*36*/ { 52, 85, 52, 85, 85, 131, 85, 131 },
+/*37*/ { 58, 92, 58, 92, 92, 147, 92, 147 },
+/*38*/ { 68, 105, 68, 105, 105, 164, 105, 164 },
+/*39*/ { 73, 118, 73, 118, 118, 189, 118, 189 },
+/*40*/ { 84, 131, 84, 131, 131, 205, 131, 205 },
+/*41*/ { 94, 151, 94, 151, 151, 239, 151, 239 },
+/*42*/ { 105, 171, 105, 171, 171, 262, 171, 262 },
+/*43*/ { 116, 184, 116, 184, 184, 295, 184, 295 },
+/*44*/ { 136, 211, 136, 211, 211, 326, 211, 326 },
+/*45*/ { 147, 236, 147, 236, 236, 377, 236, 377 },
+/*46*/ { 168, 262, 168, 262, 262, 414, 262, 414 },
+/*47*/ { 189, 303, 189, 303, 303, 478, 303, 478 },
+/*48*/ { 211, 341, 211, 341, 341, 524, 341, 524 },
+/*49*/ { 231, 364, 231, 364, 364, 597, 364, 597 },
+/*50*/ { 272, 422, 272, 422, 422, 652, 422, 652 },
+/*51*/ { 295, 467, 295, 467, 467, 768, 467, 768 }
+};
+
+#define ThValue 2
+
+void TestQuant(uint32_t qp,uint8_t *pSrc,uint8_t *pPred,int16_t *pDct,
+ int16_t *pDctCompare,int16_t iWidth,int16_t iHeight) {
+ const int16_t *pMf = g_kiQuantMF[qp];
+ const int16_t *pFfCompareI = g_kiQuantInterFFCompare[52 + qp];
+ const int16_t *pFfCompareP = g_kiQuantInterFFCompare[qp];
+ const int16_t *pFfI = g_kiQuantInterFF[6 + qp];
+ const int16_t *pFfP = g_kiQuantInterFF[qp];
+ //quant4x4 Intra MB
+ RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
+ RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
+
+ for (int16_t i = 0; i<16; i++) {
+ pDct[i] = pSrc[i] - pPred[i];
+ pDctCompare[i] = pSrc[i] - pPred[i];
+ }
+
+ WelsQuant4x4_c(pDct,pFfI,pMf);
+ WelsQuant4x4_c(pDctCompare,pFfCompareI,pMf);
+
+ for (int16_t i = 0;i<16;i++) {
+ int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
+ iDeta = (iDeta < ThValue) ? 0 : iDeta;
+ EXPECT_EQ(iDeta,0);
+ }
+
+ //quant4x4 DC
+ RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
+ RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
+
+ for (int16_t i = 0;i<16;i++) {
+ pDct[i] = pSrc[i] - pPred[i];
+ pDctCompare[i] = pSrc[i] - pPred[i];
+ }
+
+ WelsQuant4x4Dc_c(pDct,pFfI[0]<<1,pMf[0]>>1);
+ WelsQuant4x4Dc_c(pDctCompare,pFfCompareI[0]<<1,pMf[0]>>1);
+
+ for (int16_t i = 0;i<16;i++) {
+ int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
+ iDeta = (iDeta < ThValue) ? 0 : iDeta;
+ EXPECT_EQ(iDeta,0);
+ }
+
+ //quant4x4 Inter MB
+ RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
+ RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
+
+ for (int16_t i = 0; i<64; i++) {
+ pDct[i] = pSrc[i] - pPred[i];
+ pDctCompare[i] = pSrc[i] - pPred[i];
+ }
+
+ WelsQuantFour4x4_c(pDct,pFfP,pMf);
+ WelsQuantFour4x4_c(pDctCompare,pFfCompareP,pMf);
+
+ for (int16_t i = 0; i<64; i++) {
+ int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
+ iDeta = (iDeta <ThValue)?0:iDeta;
+ EXPECT_EQ(iDeta,0);
+ }
+}
+
+TEST(EncoderMbTest, TestQuantTable) {
+ CMemoryAlign cMemoryAlign(0);
+
+ int16_t iWidth = 16;
+ int16_t iHeight = 16;
+
+ uint8_t *pSrc = (uint8_t *)cMemoryAlign.WelsMalloc(iWidth*iHeight,"quant_src");
+ uint8_t *pPred = (uint8_t *)cMemoryAlign.WelsMalloc(iWidth*iHeight,"quant_pred");
+ int16_t *pDct = (int16_t *)cMemoryAlign.WelsMalloc(64*sizeof(int16_t),"Dct Buffer");
+ int16_t *pDctCompare = (int16_t *)cMemoryAlign.WelsMalloc(64*sizeof(int16_t),"DctCompare Buffer");
+
+ for (int32_t iQP = 0; iQP<51; iQP++) {
+ TestQuant(iQP,pSrc,pPred,pDct,pDctCompare,iWidth,iHeight);
+ }
+
+ cMemoryAlign.WelsFree(pSrc,"quant_src");
+ cMemoryAlign.WelsFree(pPred,"quant_pred");
+ cMemoryAlign.WelsFree(pDct,"Dct Buffer");
+ cMemoryAlign.WelsFree(pDctCompare,"DctCompare Buffer");
+}
--- a/test/encoder/EncUT_EncoderMbTest.cpp
+++ /dev/null
@@ -1,200 +1,0 @@
-#include <gtest/gtest.h>
-
-#include "memory_align.h"
-#include "utils/DataGenerator.h"
-
-using namespace WelsSVCEnc;
-#include "encode_mb_aux.h"
-
-__align16( const int16_t, g_kiQuantInterFFCompare[104][8] ) = {
-/* 0*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
-/* 1*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
-/* 2*/ { 1, 1, 1, 1, 1, 1, 1, 1 },
-/* 3*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
-/* 4*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
-/* 5*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
-/* 6*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
-/* 7*/ { 1, 2, 1, 2, 2, 2, 2, 2 },
-/* 8*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
-/* 9*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
-/*10*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
-/*11*/ { 2, 2, 2, 2, 2, 4, 2, 4 },
-/*12*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
-/*13*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
-/*14*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
-/*15*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
-/*16*/ { 3, 4, 3, 4, 4, 7, 4, 7 },
-/*17*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
-/*18*/ { 3, 6, 3, 6, 6, 9, 6, 9 },
-/*19*/ { 4, 6, 4, 6, 6, 10, 6, 10 },
-/*20*/ { 4, 7, 4, 7, 7, 11, 7, 11 },
-/*21*/ { 5, 8, 5, 8, 8, 12, 8, 12 },
-/*22*/ { 6, 9, 6, 9, 9, 13, 9, 13 },
-/*23*/ { 6, 10, 6, 10, 10, 16, 10, 16 },
-/*24*/ { 7, 11, 7, 11, 11, 17, 11, 17 },
-/*25*/ { 8, 12, 8, 12, 12, 19, 12, 19 },
-/*26*/ { 9, 14, 9, 14, 14, 21, 14, 21 },
-/*27*/ { 10, 15, 10, 15, 15, 25, 15, 25 },
-/*28*/ { 11, 17, 11, 17, 17, 27, 17, 27 },
-/*29*/ { 12, 20, 12, 20, 20, 31, 20, 31 },
-/*30*/ { 14, 22, 14, 22, 22, 34, 22, 34 },
-/*31*/ { 15, 24, 15, 24, 24, 39, 24, 39 },
-/*32*/ { 18, 27, 18, 27, 27, 43, 27, 43 },
-/*33*/ { 19, 31, 19, 31, 31, 49, 31, 49 },
-/*34*/ { 22, 34, 22, 34, 34, 54, 34, 54 },
-/*35*/ { 25, 40, 25, 40, 40, 62, 40, 62 },
-/*36*/ { 27, 45, 27, 45, 45, 69, 45, 69 },
-/*37*/ { 30, 48, 30, 48, 48, 77, 48, 77 },
-/*38*/ { 36, 55, 36, 55, 55, 86, 55, 86 },
-/*39*/ { 38, 62, 38, 62, 62, 99, 62, 99 },
-/*40*/ { 44, 69, 44, 69, 69, 107, 69, 107 },
-/*41*/ { 49, 79, 49, 79, 79, 125, 79, 125 },
-/*42*/ { 55, 89, 55, 89, 89, 137, 89, 137 },
-/*43*/ { 61, 96, 61, 96, 96, 154, 96, 154 },
-/*44*/ { 71, 110, 71, 110, 110, 171, 110, 171 },
-/*45*/ { 77, 124, 77, 124, 124, 198, 124, 198 },
-/*46*/ { 88, 137, 88, 137, 137, 217, 137, 217 },
-/*47*/ { 99, 159, 99, 159, 159, 250, 159, 250 },
-/*48*/ { 110, 179, 110, 179, 179, 275, 179, 275 },
-/*49*/ { 121, 191, 121, 191, 191, 313, 191, 313 },
-/*50*/ { 143, 221, 143, 221, 221, 341, 221, 341 },
-/*51*/ { 154, 245, 154, 245, 245, 402, 245, 402 },
-//from here below is intra
-/* 0*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
-/* 1*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
-/* 2*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
-/* 3*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
-/* 4*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
-/* 5*/ { 1, 2, 1, 2, 2, 4, 2, 4 },
-/* 6*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
-/* 7*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
-/* 8*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
-/* 9*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
-/*10*/ { 3, 4, 3, 4, 4, 6, 4, 6 },
-/*11*/ { 3, 5, 3, 5, 5, 7, 5, 7 },
-/*12*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
-/*13*/ { 4, 6, 4, 6, 6, 9, 6, 9 },
-/*14*/ { 4, 7, 4, 7, 7, 10, 7, 10 },
-/*15*/ { 5, 7, 5, 7, 7, 12, 7, 12 },
-/*16*/ { 5, 8, 5, 8, 8, 13, 8, 13 },
-/*17*/ { 6, 9, 6, 9, 9, 15, 9, 15 },
-/*18*/ { 7, 11, 7, 11, 11, 16, 11, 16 },
-/*19*/ { 7, 11, 7, 11, 11, 18, 11, 18 },
-/*20*/ { 9, 13, 9, 13, 13, 20, 13, 20 },
-/*21*/ { 9, 15, 9, 15, 15, 24, 15, 24 },
-/*22*/ { 11, 16, 11, 16, 16, 26, 16, 26 },
-/*23*/ { 12, 19, 12, 19, 19, 30, 19, 30 },
-/*24*/ { 13, 21, 13, 21, 21, 33, 21, 33 },
-/*25*/ { 14, 23, 14, 23, 23, 37, 23, 37 },
-/*26*/ { 17, 26, 17, 26, 26, 41, 26, 41 },
-/*27*/ { 18, 30, 18, 30, 30, 47, 30, 47 },
-/*28*/ { 21, 33, 21, 33, 33, 51, 33, 51 },
-/*29*/ { 24, 38, 24, 38, 38, 59, 38, 59 },
-/*30*/ { 26, 43, 26, 43, 43, 66, 43, 66 },
-/*31*/ { 29, 46, 29, 46, 46, 74, 46, 74 },
-/*32*/ { 34, 52, 34, 52, 52, 82, 52, 82 },
-/*33*/ { 37, 59, 37, 59, 59, 94, 59, 94 },
-/*34*/ { 42, 66, 42, 66, 66, 102, 66, 102 },
-/*35*/ { 47, 75, 47, 75, 75, 119, 75, 119 },
-/*36*/ { 52, 85, 52, 85, 85, 131, 85, 131 },
-/*37*/ { 58, 92, 58, 92, 92, 147, 92, 147 },
-/*38*/ { 68, 105, 68, 105, 105, 164, 105, 164 },
-/*39*/ { 73, 118, 73, 118, 118, 189, 118, 189 },
-/*40*/ { 84, 131, 84, 131, 131, 205, 131, 205 },
-/*41*/ { 94, 151, 94, 151, 151, 239, 151, 239 },
-/*42*/ { 105, 171, 105, 171, 171, 262, 171, 262 },
-/*43*/ { 116, 184, 116, 184, 184, 295, 184, 295 },
-/*44*/ { 136, 211, 136, 211, 211, 326, 211, 326 },
-/*45*/ { 147, 236, 147, 236, 236, 377, 236, 377 },
-/*46*/ { 168, 262, 168, 262, 262, 414, 262, 414 },
-/*47*/ { 189, 303, 189, 303, 303, 478, 303, 478 },
-/*48*/ { 211, 341, 211, 341, 341, 524, 341, 524 },
-/*49*/ { 231, 364, 231, 364, 364, 597, 364, 597 },
-/*50*/ { 272, 422, 272, 422, 422, 652, 422, 652 },
-/*51*/ { 295, 467, 295, 467, 467, 768, 467, 768 }
-};
-
-#define ThValue 2
-
-void TestQuant(uint32_t qp,uint8_t *pSrc,uint8_t *pPred,int16_t *pDct,
- int16_t *pDctCompare,int16_t iWidth,int16_t iHeight) {
- const int16_t *pMf = g_kiQuantMF[qp];
- const int16_t *pFfCompareI = g_kiQuantInterFFCompare[52 + qp];
- const int16_t *pFfCompareP = g_kiQuantInterFFCompare[qp];
- const int16_t *pFfI = g_kiQuantInterFF[6 + qp];
- const int16_t *pFfP = g_kiQuantInterFF[qp];
- //quant4x4 Intra MB
- RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
- RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
-
- for (int16_t i = 0; i<16; i++) {
- pDct[i] = pSrc[i] - pPred[i];
- pDctCompare[i] = pSrc[i] - pPred[i];
- }
-
- WelsQuant4x4_c(pDct,pFfI,pMf);
- WelsQuant4x4_c(pDctCompare,pFfCompareI,pMf);
-
- for (int16_t i = 0;i<16;i++) {
- int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
- iDeta = (iDeta < ThValue) ? 0 : iDeta;
- EXPECT_EQ(iDeta,0);
- }
-
- //quant4x4 DC
- RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
- RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
-
- for (int16_t i = 0;i<16;i++) {
- pDct[i] = pSrc[i] - pPred[i];
- pDctCompare[i] = pSrc[i] - pPred[i];
- }
-
- WelsQuant4x4Dc_c(pDct,pFfI[0]<<1,pMf[0]>>1);
- WelsQuant4x4Dc_c(pDctCompare,pFfCompareI[0]<<1,pMf[0]>>1);
-
- for (int16_t i = 0;i<16;i++) {
- int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
- iDeta = (iDeta < ThValue) ? 0 : iDeta;
- EXPECT_EQ(iDeta,0);
- }
-
- //quant4x4 Inter MB
- RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
- RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
-
- for (int16_t i = 0; i<64; i++) {
- pDct[i] = pSrc[i] - pPred[i];
- pDctCompare[i] = pSrc[i] - pPred[i];
- }
-
- WelsQuantFour4x4_c(pDct,pFfP,pMf);
- WelsQuantFour4x4_c(pDctCompare,pFfCompareP,pMf);
-
- for (int16_t i = 0; i<64; i++) {
- int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
- iDeta = (iDeta <ThValue)?0:iDeta;
- EXPECT_EQ(iDeta,0);
- }
-}
-
-TEST(EncoderMbTest, TestQuantTable) {
- CMemoryAlign cMemoryAlign(0);
-
- int16_t iWidth = 16;
- int16_t iHeight = 16;
-
- uint8_t *pSrc = (uint8_t *)cMemoryAlign.WelsMalloc(iWidth*iHeight,"quant_src");
- uint8_t *pPred = (uint8_t *)cMemoryAlign.WelsMalloc(iWidth*iHeight,"quant_pred");
- int16_t *pDct = (int16_t *)cMemoryAlign.WelsMalloc(64*sizeof(int16_t),"Dct Buffer");
- int16_t *pDctCompare = (int16_t *)cMemoryAlign.WelsMalloc(64*sizeof(int16_t),"DctCompare Buffer");
-
- for (int32_t iQP = 0; iQP<51; iQP++) {
- TestQuant(iQP,pSrc,pPred,pDct,pDctCompare,iWidth,iHeight);
- }
-
- cMemoryAlign.WelsFree(pSrc,"quant_src");
- cMemoryAlign.WelsFree(pPred,"quant_pred");
- cMemoryAlign.WelsFree(pDct,"Dct Buffer");
- cMemoryAlign.WelsFree(pDctCompare,"DctCompare Buffer");
-}
--- a/test/encoder/EncUT_ExpandPic.cpp
+++ b/test/encoder/EncUT_ExpandPic.cpp
@@ -6,7 +6,7 @@
using namespace WelsSVCEnc;
-TEST(ExpandPicTest, TestExpand_picture_luma_c) {
+TEST(ExpandPicTest, TestExpandPictureLuma_c) {
SWelsFuncPtrList sFuncList;
InitExpandPictureFunc( &sFuncList, 0 );
@@ -77,7 +77,7 @@
delete []pRef;
}
-TEST(ExpandPicTest, TestExpand_picture_chroma_c) {
+TEST(ExpandPicTest, TestExpandPictureChroma_c) {
SWelsFuncPtrList sFuncList;
InitExpandPictureFunc( &sFuncList, 0 );
--- /dev/null
+++ b/test/encoder/EncUT_GetIntraPredictor.cpp
@@ -1,0 +1,571 @@
+#include<gtest/gtest.h>
+#include<stdlib.h>
+
+#include "get_intra_predictor.h"
+#include "ls_defines.h"
+#include "macros.h"
+
+using namespace WelsSVCEnc;
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredV) {
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[64];
+ for (int i=0; i<64; i++)
+ pRef[i] = rand() % 256;
+
+ const int32_t kkiStride = 0;
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredV_c(pPred, pRef, kkiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&pRef[-kkiStride]));
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredH)
+{
+ const int32_t kiStride = rand()%256+16;
+ const uint32_t kiStride2 = (kiStride<<1)-1;
+ const uint32_t kiStride3 = kiStride + kiStride2;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[kiStride3+1];
+
+ for (int i=0; i<(static_cast<int32_t>(kiStride3+1)); i++)
+ pRef[i] = rand() % 256;
+
+ pRef++;
+
+ const uint8_t kuiH1 = pRef[-1];
+ const uint8_t kuiH2 = pRef[kiStride-1];
+ const uint8_t kuiH3 = pRef[kiStride2];
+ const uint8_t kuiH4 = pRef[kiStride3];
+ const uint8_t kuiV1[4] = {kuiH1, kuiH1, kuiH1, kuiH1};
+ const uint8_t kuiV2[4] = {kuiH2, kuiH2, kuiH2, kuiH2};
+ const uint8_t kuiV3[4] = {kuiH3, kuiH3, kuiH3, kuiH3};
+ const uint8_t kuiV4[4] = {kuiH4, kuiH4, kuiH4, kuiH4};
+
+ const uint32_t kuiCpuFlag = 0;
+
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16)// TobeCont'd about assign opt as follows
+ ST32(&uiV[0], LD32(kuiV1));
+ ST32(&uiV[4], LD32(kuiV2));
+ ST32(&uiV[8], LD32(kuiV3));
+ ST32(&uiV[12], LD32(kuiV4));
+
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredH_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]), LD32(&uiV[4*i]));
+
+ pRef--;
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDL) {
+ const int32_t kiStride = 0;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[64];
+ for (int i=0; i<64; i++)
+ pRef[i] = rand() % 256;
+
+ const uint8_t kuiT0 = pRef[-kiStride];
+ const uint8_t kuiT1 = pRef[1-kiStride];
+ const uint8_t kuiT2 = pRef[2-kiStride];
+ const uint8_t kuiT3 = pRef[3-kiStride];
+ const uint8_t kuiT4 = pRef[4-kiStride];
+ const uint8_t kuiT5 = pRef[5-kiStride];
+ const uint8_t kuiT6 = pRef[6-kiStride];
+ const uint8_t kuiT7 = pRef[7-kiStride];
+ const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1<<1))>>2;
+ const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2<<1))>>2;
+ const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3<<1))>>2;
+ const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4<<1))>>2;
+ const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5<<1))>>2;
+ const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6<<1))>>2;
+ const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7<<1))>>2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ uiV[0] = kuiDDL0;
+ uiV[1] = uiV[4] = kuiDDL1;
+ uiV[2] = uiV[5] = uiV[8] = kuiDDL2;
+ uiV[3] = uiV[6] = uiV[9] = uiV[12] = kuiDDL3;
+ uiV[7] = uiV[10]= uiV[13]= kuiDDL4;
+ uiV[11]= uiV[14]= kuiDDL5;
+ uiV[15] = kuiDDL6;
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredDDL_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDLTop) {
+ const int32_t kiStride = 0;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[64];
+ for (int i=0; i<64; i++)
+ pRef[i] = rand() % 256;
+
+ const uint8_t kuiT0 = pRef[-kiStride];
+ const uint8_t kuiT1 = pRef[1-kiStride];
+ const uint8_t kuiT2 = pRef[2-kiStride];
+ const uint8_t kuiT3 = pRef[3-kiStride];
+ const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1<<1))>>2;
+ const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2<<1))>>2;
+ const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3<<1))>>2;
+ const uint8_t kuiDLT3 = (2 + (kuiT3<<2))>>2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ memset(&uiV[6], kuiDLT3, 10*sizeof(uint8_t));
+ uiV[0] = kuiDLT0;
+ uiV[1] = uiV[4] = kuiDLT1;
+ uiV[2] = uiV[5] = uiV[8] = kuiDLT2;
+ uiV[3] = kuiDLT3;
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredDDLTop_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDR) {
+ const int32_t kiStride = rand()%256+16;
+ const int32_t kiStride2 = kiStride<<1;
+ const int32_t kiStride3 = kiStride + kiStride2;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[kiStride3+kiStride+1];
+
+ for (int i=0; i<kiStride3+kiStride+1; i++)
+ pRef[i] = rand() % 256;
+
+ pRef += kiStride + 1;
+
+ const uint8_t kuiLT = pRef[-kiStride-1];
+ const uint8_t kuiL0 = pRef[-1];
+ const uint8_t kuiL1 = pRef[kiStride-1];
+ const uint8_t kuiL2 = pRef[kiStride2-1];
+ const uint8_t kuiL3 = pRef[kiStride3-1];
+ const uint8_t kuiT0 = pRef[-kiStride];
+ const uint8_t kuiT1 = pRef[1-kiStride];
+ const uint8_t kuiT2 = pRef[2-kiStride];
+ const uint8_t kuiT3 = pRef[3-kiStride];
+ const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
+ const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
+ const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
+ const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
+ const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
+ const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
+ const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
+ const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
+ const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2;
+ const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2;
+ const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2;
+ const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2;
+ const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2;
+ const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2;
+ const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ uiV[0] = uiV[5] = uiV[10] = uiV[15] = kuiDDR0;
+ uiV[1] = uiV[6] = uiV[11] = kuiDDR1;
+ uiV[2] = uiV[7] = kuiDDR2;
+ uiV[3] = kuiDDR3;
+ uiV[4] = uiV[9] = uiV[14] = kuiDDR4;
+ uiV[8] = uiV[13] = kuiDDR5;
+ uiV[12]= kuiDDR6;
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredDDR_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ pRef -= kiStride + 1;
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVL) {
+ const int32_t kiStride = 0;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[64];
+ for (int i=0; i<64; i++)
+ pRef[i] = rand() % 256;
+
+ const uint8_t kuiT0 = pRef[-kiStride];
+ const uint8_t kuiT1 = pRef[1-kiStride];
+ const uint8_t kuiT2 = pRef[2-kiStride];
+ const uint8_t kuiT3 = pRef[3-kiStride];
+ const uint8_t kuiT4 = pRef[4-kiStride];
+ const uint8_t kuiT5 = pRef[5-kiStride];
+ const uint8_t kuiT6 = pRef[6-kiStride];
+ const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1)>>1;
+ const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2)>>1;
+ const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3)>>1;
+ const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4)>>1;
+ const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5)>>1;
+ const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1<<1) + kuiT2)>>2;
+ const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2<<1) + kuiT3)>>2;
+ const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3<<1) + kuiT4)>>2;
+ const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4<<1) + kuiT5)>>2;
+ const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5<<1) + kuiT6)>>2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ uiV[0] = kuiVL0;
+ uiV[1] = uiV[8] = kuiVL1;
+ uiV[2] = uiV[9] = kuiVL2;
+ uiV[3] = uiV[10]= kuiVL3;
+ uiV[4] = kuiVL5;
+ uiV[5] = uiV[12] = kuiVL6;
+ uiV[6] = uiV[13] = kuiVL7;
+ uiV[7] = uiV[14] = kuiVL8;
+ uiV[11]= kuiVL4;
+ uiV[15]= kuiVL9;
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredVL_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVLTop) {
+ const int32_t kiStride = 0;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[64];
+ for (int i=0; i<64; i++)
+ pRef[i] = rand() % 256;
+
+ pRef++;
+
+ uint8_t *pTopLeft = &pRef[-kiStride-1]; // top-left
+
+ const uint8_t kuiT0 = *(pTopLeft+1);
+ const uint8_t kuiT1 = *(pTopLeft+2);
+ const uint8_t kuiT2 = *(pTopLeft+3);
+ const uint8_t kuiT3 = *(pTopLeft+4);
+ const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1)>>1;
+ const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2)>>1;
+ const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3)>>1;
+ const uint8_t kuiVLT3 = (1 + (kuiT3<<1))>>1;
+ const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1<<1) + kuiT2)>>2;
+ const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2<<1) + kuiT3)>>2;
+ const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3<<1) + kuiT3)>>2;
+ const uint8_t kuiVLT7 = (2 + (kuiT3<<2))>>2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ uiV[0] = kuiVLT0;
+ uiV[1] = uiV[8] = kuiVLT1;
+ uiV[2] = uiV[9] = kuiVLT2;
+ uiV[3] = uiV[10]= uiV[11] = kuiVLT3;
+ uiV[4] = kuiVLT4;
+ uiV[5] = uiV[12] = kuiVLT5;
+ uiV[6] = uiV[13] = kuiVLT6;
+ uiV[7] = uiV[14] = uiV[15] = kuiVLT7;
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredVLTop_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ pRef--;
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVR) {
+ const int32_t kiStride = rand()%256+16;
+ const int32_t kiStride2 = kiStride<<1;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[kiStride2+kiStride+1];
+
+ for (int i=0; i<kiStride2+kiStride+1; i++)
+ pRef[i] = rand() % 256;
+
+ pRef += kiStride + 1;
+
+ const uint8_t kuiLT = pRef[-kiStride-1]; // top-left
+ const uint8_t kuiL0 = pRef[-1];
+ const uint8_t kuiL1 = pRef[kiStride-1];
+ const uint8_t kuiL2 = pRef[kiStride2-1];
+ const uint8_t kuiT0 = pRef[-kiStride];
+ const uint8_t kuiT1 = pRef[1-kiStride];
+ const uint8_t kuiT2 = pRef[2-kiStride];
+ const uint8_t kuiT3 = pRef[3-kiStride];
+ const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1;
+ const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1;
+ const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1;
+ const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1;
+ const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2;
+ const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2;
+ const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
+ const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
+ const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2;
+ const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ uiV[0] = uiV[9] = kuiVR0;
+ uiV[1] = uiV[10] = kuiVR1;
+ uiV[2] = uiV[11] = kuiVR2;
+ uiV[3] = kuiVR3;
+ uiV[4] = uiV[13] = kuiVR4;
+ uiV[5] = uiV[14] = kuiVR5;
+ uiV[6] = uiV[15] = kuiVR6;
+ uiV[7] = kuiVR7;
+ uiV[8] = kuiVR8;
+ uiV[12]= kuiVR9;
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredVR_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ pRef -= kiStride + 1;
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHU) {
+ const int32_t kiStride = rand()%256+16;
+ const int32_t kiStride2 = kiStride<<1;
+ const int32_t kiStride3 = kiStride + kiStride2;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[kiStride3+1];
+
+ for (int i=0; i<kiStride3+1; i++)
+ pRef[i] = rand() % 256;
+
+ pRef++;
+
+ const uint8_t kuiL0 = pRef[-1];
+ const uint8_t kuiL1 = pRef[kiStride-1];
+ const uint8_t kuiL2 = pRef[kiStride2-1];
+ const uint8_t kuiL3 = pRef[kiStride3-1];
+ const uint16_t kuiL01 = (1 + kuiL0 + kuiL1);
+ const uint16_t kuiL12 = (1 + kuiL1 + kuiL2);
+ const uint16_t kuiL23 = (1 + kuiL2 + kuiL3);
+ const uint8_t kuiHU0 = kuiL01 >> 1;
+ const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2;
+ const uint8_t kuiHU2 = kuiL12 >> 1;
+ const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2;
+ const uint8_t kuiHU4 = kuiL23 >> 1;
+ const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ uiV[0] = kuiHU0;
+ uiV[1] = kuiHU1;
+ uiV[2] = uiV[4] = kuiHU2;
+ uiV[3] = uiV[5] = kuiHU3;
+ uiV[6] = uiV[8] = kuiHU4;
+ uiV[7] = uiV[9] = kuiHU5;
+ memset(&uiV[10], kuiL3, 6*sizeof(uint8_t));
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredHU_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ pRef--;
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHD) {
+ const int32_t kiStride = rand()%256+16;
+ const int32_t kiStride2 = kiStride<<1;
+ const int32_t kiStride3 = kiStride + kiStride2;
+
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[kiStride3+kiStride+1];
+
+ for (int i=0; i<kiStride3+kiStride+1; i++)
+ pRef[i] = rand() % 256;
+
+ pRef += kiStride + 1;
+
+ const uint8_t kuiLT = pRef[-kiStride-1]; // top-left
+ const uint8_t kuiL0 = pRef[-1];
+ const uint8_t kuiL1 = pRef[kiStride-1];
+ const uint8_t kuiL2 = pRef[kiStride2-1];
+ const uint8_t kuiL3 = pRef[kiStride3-1];
+ const uint8_t kuiT0 = pRef[-kiStride];
+ const uint8_t kuiT1 = pRef[1-kiStride];
+ const uint8_t kuiT2 = pRef[2-kiStride];
+ const uint8_t kuiHD0 = (1 + kuiLT + kuiL0)>>1;
+ const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT<<1) + kuiT0)>>2;
+ const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0<<1) + kuiT1)>>2;
+ const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1<<1) + kuiT2)>>2;
+ const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1)>>1;
+ const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0<<1) + kuiL1)>>2;
+ const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2)>>1;
+ const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1<<1) + kuiL2)>>2;
+ const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3)>>1;
+ const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2<<1) + kuiL3)>>2;
+ ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
+ uiV[0] = uiV[6] = kuiHD0;
+ uiV[1] = uiV[7] = kuiHD1;
+ uiV[2] = kuiHD2;
+ uiV[3] = kuiHD3;
+ uiV[4] = uiV[10] = kuiHD4;
+ uiV[5] = uiV[11] = kuiHD5;
+ uiV[8] = uiV[14] = kuiHD6;
+ uiV[9] = uiV[15] = kuiHD7;
+ uiV[12] = kuiHD8;
+ uiV[13] = kuiHD9;
+
+ const uint32_t kuiCpuFlag = 0;
+ WelsInitFillingPredFuncs(kuiCpuFlag);
+ WelsI4x4LumaPredHD_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<4; i++)
+ EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
+
+ pRef -= kiStride + 1;
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetIChormaPredV) {
+ uint8_t *pPred = new uint8_t[64];
+ uint8_t *pRef = new uint8_t[64];
+ for (int i=0; i<64; i++)
+ pRef[i] = rand() % 256 + 1;
+
+ const int32_t kiStride = 0;
+ WelsIChormaPredV_c(pPred, pRef, kiStride);
+
+ for (int i=0; i<8; i++)
+ EXPECT_EQ(LD32(&pPred[8*i]),LD32(&pRef[-kiStride]));
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI16x16LumaPredPlane) {
+ const int32_t kiStride = rand()%16+16;
+
+ uint8_t *pPred = new uint8_t[16*kiStride];
+ uint8_t *pRef = new uint8_t[16*kiStride+1];
+ for (int i=0; i<16*kiStride+1; i++)
+ pRef[i]=rand()%256+1;
+
+ pRef += kiStride + 1;
+
+ int32_t iA=0, iB=0, iC=0, iH=0, iV=0;
+ int32_t i, j;
+ uint8_t *pTop = &pRef[-kiStride];
+ uint8_t *pLeft = &pRef[-1];
+ int32_t iPredStride = 16;
+
+ for (i=0; i<8; i++) {
+ iH += (i + 1) * (pTop[8 + i] - pTop[6 - i]);
+ iV += (i + 1) * (pLeft[(8 + i)*kiStride] - pLeft[(6 - i)*kiStride]);
+ }
+
+ iA = (pLeft[15*kiStride] + pTop[15]) << 4;
+ iB = (5 * iH + 32) >> 6;
+ iC = (5 * iV + 32) >> 6;
+
+ WelsI16x16LumaPredPlane_c(pPred, pRef, kiStride);
+ for (i=0; i<16; i++) {
+ for (j=0; j<16; j++) {
+ EXPECT_EQ(pPred[j],(uint8_t)WelsClip1((iA + iB * (j - 7) + iC * (i - 7) + 16) >> 5));
+ }
+ pPred += iPredStride;
+ }
+
+ pRef -= kiStride + 1;
+ delete []pRef;
+}
+
+TEST(GetIntraPredictorTest, TestGetI16x16LumaPredDc) {
+ const int32_t kiStride = rand()%16+16;
+
+ uint8_t *pPred = new uint8_t[256];
+ uint8_t *pRef = new uint8_t[16*kiStride];
+ for (int i=0; i<16*kiStride; i++)
+ pRef[i] = rand() % 256 + 1;
+
+ pRef += kiStride;
+
+ int32_t iTmp = (kiStride << 4) - kiStride;
+ int32_t iSum = 0;
+ uint8_t i = 15;
+ uint8_t uiMean = 0;
+
+ do {
+ iSum += pRef[-1+iTmp] + pRef[-kiStride+i];
+ iTmp -= kiStride;
+ } while(i-- > 0);
+ uiMean = ( 16 + iSum ) >> 5;
+
+ WelsI16x16LumaPredDc_c(pPred, pRef, kiStride);
+ for (int i=0; i<256; i++)
+ EXPECT_EQ(pPred[i],uiMean);
+
+ pRef -= kiStride;
+
+ delete []pRef;
+ delete []pPred;
+}
+
+TEST(GetIntraPredictorTest, TestGetI16x16LumaPredDcTop) {
+ const int32_t kiStride = rand()%16+16;
+
+ uint8_t *pPred = new uint8_t[256];
+ uint8_t *pRef = new uint8_t[16*kiStride];
+ for (int i=0; i<16*kiStride; i++)
+ pRef[i] = rand() % 256 + 1;
+
+ pRef += kiStride;
+
+ int32_t iSum = 0;
+ uint8_t i = 15;
+ uint8_t uiMean = 0;
+ do {
+ iSum += pRef[-kiStride+i];
+ } while(i-- > 0);
+ uiMean = ( 8 + iSum ) >> 4;
+
+ WelsI16x16LumaPredDcTop_c(pPred, pRef, kiStride);
+ for (int i=0; i<256; i++)
+ EXPECT_EQ(pPred[i],uiMean);
+
+ pRef -= kiStride;
+
+ delete []pRef;
+ delete []pPred;
+}
--- a/test/encoder/targets.mk
+++ b/test/encoder/targets.mk
@@ -1,8 +1,9 @@
ENCODER_UNITTEST_SRCDIR=test/encoder
ENCODER_UNITTEST_CPP_SRCS=\
- $(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMbTest.cpp\
+ $(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMb.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\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MotionEstimate.cpp\