Enable intraSad ASM code Refine format Add X86_ASM pretect for intraSad ASM code UT remove duplicated code.
Showing the changes to test/encoder/EncUT_Sample.cpp (1 of 6 files). Show all
Unified · Split
| @@ -9,7 +9,136 @@ · 8 unmodified lines | |||
| 9 | #include "sad_common.h" | 9 | #include "sad_common.h" |
| 10 | 10 | ||
| 11 | using namespace WelsSVCEnc; | 11 | using namespace WelsSVCEnc; |
| 12 | #ifdef X86_ASM | ||
| 13 | TEST(IntraSadSatdFuncTest, WelsIntra16x16Combined3Sad_ssse3){ | ||
| 14 | const int32_t iLineSizeDec = 32; | ||
| 15 | const int32_t iLineSizeEnc = 32; | ||
| 16 | int32_t tmpa, tmpb; | ||
| 17 | int32_t iBestMode_c, iBestMode_a, iLambda = 50; | ||
| 18 | CMemoryAlign cMemoryAlign(0); | ||
| 19 | int32_t iCpuCores = 0; | ||
| 20 | uint32_t m_uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores); | ||
| 21 | if (0 == (m_uiCpuFeatureFlag & WELS_CPU_SSSE3)) | ||
| 22 | return; | ||
| 23 | uint8_t* pDec = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeDec<<5,"pDec"); | ||
| 24 | uint8_t* pEnc = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeEnc<<5,"pEnc"); | ||
| 25 | uint8_t* pDst = (uint8_t *)cMemoryAlign.WelsMalloc(512,"pDst"); | ||
| 26 | srand((uint32_t)time(NULL)); | ||
| 27 | for(int i=0;i<(iLineSizeDec<<5);i++) | ||
| 28 | pDec[i]=rand()%256; | ||
| 29 | for(int i=0;i<(iLineSizeEnc<<5);i++) | ||
| 30 | pEnc[i]=rand()%256; | ||
| 31 | |||
| 32 | for(int i=0;i<512;i++) | ||
| 33 | pDst[i]=rand()%256; | ||
| 34 | tmpa = WelsSampleSadIntra16x16Combined3_c(pDec+128, iLineSizeDec, pEnc,iLineSizeEnc,&iBestMode_c, iLambda, pDst); | ||
| 35 | tmpb = WelsIntra16x16Combined3Sad_ssse3(pDec+128, iLineSizeDec, pEnc,iLineSizeEnc,&iBestMode_a, iLambda, pDst); | ||
| 36 | |||
| 37 | ASSERT_EQ(tmpa, tmpb); | ||
| 38 | ASSERT_EQ(iBestMode_c, iBestMode_a); | ||
| 39 | |||
| 40 | cMemoryAlign.WelsFree(pDec,"pDec"); | ||
| 41 | cMemoryAlign.WelsFree(pEnc,"pEnc"); | ||
| 42 | cMemoryAlign.WelsFree(pDst,"pDst"); | ||
| 43 | } | ||
| 12 | 44 | ||
| 45 | TEST(IntraSadSatdFuncTest, WelsIntra16x16Combined3Satd_sse41){ | ||
| 46 | const int32_t iLineSizeDec = 32; | ||
| 47 | const int32_t iLineSizeEnc = 32; | ||
| 48 | int32_t tmpa, tmpb; | ||
| 49 | int32_t iBestMode_c, iBestMode_a, iLambda = 50; | ||
| 50 | CMemoryAlign cMemoryAlign(0); | ||
| 51 | int32_t iCpuCores = 0; | ||
| 52 | uint32_t m_uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores); | ||
| 53 | if (0 == (m_uiCpuFeatureFlag & WELS_CPU_SSE41)) | ||
| 54 | return; | ||
| 55 | uint8_t* pDec = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeDec<<5,"pDec"); | ||
| 56 | uint8_t* pEnc = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeEnc<<5,"pEnc"); | ||
| 57 | uint8_t* pDst = (uint8_t *)cMemoryAlign.WelsMalloc(512,"pDst"); | ||
| 58 | srand((uint32_t)time(NULL)); | ||
| 59 | for(int i=0;i<(iLineSizeDec<<5);i++) | ||
| 60 | pDec[i]=rand()%256; | ||
| 61 | for(int i=0;i<(iLineSizeEnc<<5);i++) | ||
| 62 | pEnc[i]=rand()%256; | ||
| 63 | for(int i=0;i<512;i++) | ||
| 64 | pDst[i]=rand()%256; | ||
| 65 | tmpa = WelsSampleSatdIntra16x16Combined3_c(pDec+128, iLineSizeDec, pEnc,iLineSizeEnc,&iBestMode_c, iLambda, pDst); | ||
| 66 | tmpb = WelsIntra16x16Combined3Satd_sse41(pDec+128, iLineSizeDec, pEnc,iLineSizeEnc,&iBestMode_a, iLambda, pDst); | ||
| 67 | ASSERT_EQ(tmpa, tmpb); | ||
| 68 | ASSERT_EQ(iBestMode_c, iBestMode_a); | ||
| 69 | cMemoryAlign.WelsFree(pDec,"pDec"); | ||
| 70 | cMemoryAlign.WelsFree(pEnc,"pEnc"); | ||
| 71 | cMemoryAlign.WelsFree(pDst,"pDst"); | ||
| 72 | } | ||
| 73 | |||
| 74 | TEST(IntraSadSatdFuncTest, WelsSampleSatdThree4x4_sse2){ | ||
| 75 | const int32_t iLineSizeDec = 32; | ||
| 76 | const int32_t iLineSizeEnc = 32; | ||
| 77 | int32_t tmpa, tmpb; | ||
| 78 | int32_t iBestMode_c, iBestMode_a, iLambda = 50; | ||
| 79 | int32_t lambda[2] = {iLambda << 2, iLambda}; | ||
| 80 | int32_t iPredMode = rand()%3; | ||
| 81 | CMemoryAlign cMemoryAlign(0); | ||
| 82 | int32_t iCpuCores = 0; | ||
| 83 | uint32_t m_uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores); | ||
| 84 | if (0 == (m_uiCpuFeatureFlag & WELS_CPU_SSE2)) | ||
| 85 | return; | ||
| 86 | uint8_t* pDec = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeDec<<5,"pDec"); | ||
| 87 | uint8_t* pEnc = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeEnc<<5,"pEnc"); | ||
| 88 | uint8_t* pDst = (uint8_t *)cMemoryAlign.WelsMalloc(512,"pDst"); | ||
| 89 | srand((uint32_t)time(NULL)); | ||
| 90 | for(int i=0;i<(iLineSizeDec<<5);i++) | ||
| 91 | pDec[i]=rand()%256; | ||
| 92 | for(int i=0;i<(iLineSizeEnc<<5);i++) | ||
| 93 | pEnc[i]=rand()%256; | ||
| 94 | for(int i=0;i<512;i++) | ||
| 95 | pDst[i]=rand()%256; | ||
| 96 | tmpa = WelsSampleSatdIntra4x4Combined3_c(pDec+128, iLineSizeDec, pEnc,iLineSizeEnc, pDst, &iBestMode_c, lambda[iPredMode == 2], lambda[iPredMode == 1], lambda[iPredMode == 0]); | ||
| 97 | tmpb = WelsSampleSatdThree4x4_sse2(pDec+128, iLineSizeDec, pEnc,iLineSizeEnc, pDst, &iBestMode_a, lambda[iPredMode == 2], lambda[iPredMode == 1], lambda[iPredMode == 0]); | ||
| 98 | ASSERT_EQ(tmpa, tmpb); | ||
| 99 | ASSERT_EQ(iBestMode_c, iBestMode_a); | ||
| 100 | cMemoryAlign.WelsFree(pDec,"pDec"); | ||
| 101 | cMemoryAlign.WelsFree(pEnc,"pEnc"); | ||
| 102 | cMemoryAlign.WelsFree(pDst,"pDst"); | ||
| 103 | } | ||
| 104 | |||
| 105 | TEST(IntraSadSatdFuncTest, WelsIntraChroma8x8Combined3Satd_sse41){ | ||
| 106 | const int32_t iLineSizeDec = 32; | ||
| 107 | const int32_t iLineSizeEnc = 32; | ||
| 108 | int32_t tmpa, tmpb; | ||
| 109 | int32_t iBestMode_c, iBestMode_a, iLambda = 50; | ||
| 110 | CMemoryAlign cMemoryAlign(0); | ||
| 111 | int32_t iCpuCores = 0; | ||
| 112 | uint32_t m_uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores); | ||
| 113 | if (0 == (m_uiCpuFeatureFlag & WELS_CPU_SSE41)) | ||
| 114 | return; | ||
| 115 | uint8_t* pDecCb = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeDec<<5,"pDecCb"); | ||
| 116 | uint8_t* pEncCb = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeEnc<<5,"pEncCb"); | ||
| 117 | uint8_t* pDecCr = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeDec<<5,"pDecCr"); | ||
| 118 | uint8_t* pEncCr = (uint8_t *)cMemoryAlign.WelsMalloc(iLineSizeEnc<<5,"pEncCr"); | ||
| 119 | uint8_t* pDstChma = (uint8_t *)cMemoryAlign.WelsMalloc(512,"pDstChma"); | ||
| 120 | srand((uint32_t)time(NULL)); | ||
| 121 | for(int i=0;i<(iLineSizeDec<<5);i++){ | ||
| 122 | pDecCb[i]=rand()%256; | ||
| 123 | pDecCr[i]=rand()%256; | ||
| 124 | } | ||
| 125 | for(int i=0;i<(iLineSizeEnc<<5);i++){ | ||
| 126 | pEncCb[i]=rand()%256; | ||
| 127 | pEncCr[i]=rand()%256; | ||
| 128 | } | ||
| 129 | for(int i=0;i<512;i++) | ||
| 130 | pDstChma[i]=rand()%256; | ||
| 131 | tmpa = WelsSampleSatdIntra8x8Combined3_c(pDecCb+128, iLineSizeDec, pEncCb,iLineSizeEnc,&iBestMode_c, iLambda, pDstChma, pDecCr+128, pEncCr); | ||
| 132 | tmpb = WelsIntraChroma8x8Combined3Satd_sse41(pDecCb+128, iLineSizeDec, pEncCb,iLineSizeEnc,&iBestMode_a, iLambda, pDstChma, pDecCr+128, pEncCr); | ||
| 133 | ASSERT_EQ(tmpa, tmpb); | ||
| 134 | ASSERT_EQ(iBestMode_c, iBestMode_a); | ||
| 135 | cMemoryAlign.WelsFree(pDecCb,"pDecCb"); | ||
| 136 | cMemoryAlign.WelsFree(pEncCb,"pEncCb"); | ||
| 137 | cMemoryAlign.WelsFree(pDecCr,"pDecCr"); | ||
| 138 | cMemoryAlign.WelsFree(pEncCr,"pEncCr"); | ||
| 139 | cMemoryAlign.WelsFree(pDstChma,"pDstChma"); | ||
| 140 | } | ||
| 141 | #endif | ||
| 13 | #define ASSERT_MEMORY_FAIL2X(A, B) \ | 142 | #define ASSERT_MEMORY_FAIL2X(A, B) \ |
| 14 | if (NULL == B) { \ | 143 | if (NULL == B) { \ |
| 15 | pMemAlign->WelsFree(A, "Sad_SrcA");\ | 144 | pMemAlign->WelsFree(A, "Sad_SrcA");\ |