Showing the changes to test/api/encode_decode_api_test.cpp (1 of 16 files). Show all
Unified · Split
| @@ -88,26 +88,25 @@ class EncodeDecodeTestBase : public ::testing::TestWithParam<EncodeDecodeFilePar · 87 unmodified lines | ||
| 88 | 88 | BaseDecoderTest::TearDown(); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | − virtual void prepareParam (int iLayers, int iSlices, int width, int height, float framerate) { | |
| 92 | − memset (¶m_, 0, sizeof (SEncParamExt)); | |
| 93 | − param_.iUsageType = CAMERA_VIDEO_REAL_TIME; | |
| 94 | − param_.iPicWidth = width; | |
| 95 | − param_.iPicHeight = height; | |
| 96 | − param_.fMaxFrameRate = framerate; | |
| 97 | − param_.iRCMode = RC_OFF_MODE; //rc off | |
| 98 | − param_.iMultipleThreadIdc = 1; //single thread | |
| 99 | − param_.iSpatialLayerNum = iLayers; | |
| 100 | − param_.iNumRefFrame = AUTO_REF_PIC_COUNT; | |
| 91 | + virtual void prepareParam (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) { | |
| 92 | + memset (pParam, 0, sizeof (SEncParamExt)); | |
| 93 | + pParam->iUsageType = CAMERA_VIDEO_REAL_TIME; | |
| 94 | + pParam->iPicWidth = width; | |
| 95 | + pParam->iPicHeight = height; | |
| 96 | + pParam->fMaxFrameRate = framerate; | |
| 97 | + pParam->iRCMode = RC_OFF_MODE; //rc off | |
| 98 | + pParam->iMultipleThreadIdc = 1; //single thread | |
| 99 | + pParam->iSpatialLayerNum = iLayers; | |
| 100 | + pParam->iNumRefFrame = AUTO_REF_PIC_COUNT; | |
| 101 | 101 | for (int i = 0; i < iLayers; i++) { |
| 102 | − param_.sSpatialLayers[i].iVideoWidth = width >> (iLayers - i - 1); | |
| 103 | − param_.sSpatialLayers[i].iVideoHeight = height >> (iLayers - i - 1); | |
| 104 | − param_.sSpatialLayers[i].fFrameRate = framerate; | |
| 105 | − param_.sSpatialLayers[i].sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE; | |
| 106 | − param_.sSpatialLayers[i].sSliceCfg.sSliceArgument.uiSliceNum = iSlices; | |
| 102 | + pParam->sSpatialLayers[i].iVideoWidth = width >> (iLayers - i - 1); | |
| 103 | + pParam->sSpatialLayers[i].iVideoHeight = height >> (iLayers - i - 1); | |
| 104 | + pParam->sSpatialLayers[i].fFrameRate = framerate; | |
| 105 | + pParam->sSpatialLayers[i].sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE; | |
| 106 | + pParam->sSpatialLayers[i].sSliceCfg.sSliceArgument.uiSliceNum = iSlices; | |
| 107 | 107 | } |
| 108 | − | |
| 109 | − | |
| 110 | 108 | } |
| 109 | + | |
| 111 | 110 | virtual void prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam) { |
| 112 | 111 | //for encoder |
| 113 | 112 | //I420: 1(Y) + 1/4(U) + 1/4(V) |
| @@ -147,6 +146,15 @@ class EncodeDecodeTestBase : public ::testing::TestWithParam<EncodeDecodeFilePar · 33 unmodified lines | ||
| 147 | 146 | len = layerInfo.pNalLengthInByte[iSliceNum]; |
| 148 | 147 | } |
| 149 | 148 | |
| 149 | + | |
| 150 | + virtual int GetRandWidth() { | |
| 151 | + return (WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH)); | |
| 152 | + } | |
| 153 | + | |
| 154 | + virtual int GetRandHeight() { | |
| 155 | + return (WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT)); | |
| 156 | + } | |
| 157 | + | |
| 150 | 158 | protected: |
| 151 | 159 | SEncParamExt param_; |
| 152 | 160 | BufferedData buf_; |
| @@ -171,8 +179,8 @@ class EncodeDecodeTestAPI : public EncodeDecodeTestBase { · 18 unmodified lines | ||
| 171 | 179 | EncodeDecodeTestBase::TearDown(); |
| 172 | 180 | } |
| 173 | 181 | |
| 174 | − void prepareParam (int iLayers, int iSlices, int width, int height, float framerate) { | |
| 175 | − EncodeDecodeTestBase::prepareParam (iLayers, iSlices, width, height, framerate); | |
| 182 | + void prepareParam (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) { | |
| 183 | + EncodeDecodeTestBase::prepareParam (iLayers, iSlices, width, height, framerate, pParam); | |
| 176 | 184 | } |
| 177 | 185 | |
| 178 | 186 | void InitialEncDec (int iWidth, int iHeight); |
| @@ -192,6 +200,24 @@ class EncodeDecodeTestAPI : public EncodeDecodeTestBase { · 13 unmodified lines | ||
| 192 | 200 | else if (1 == iCheckTypeIndex) |
| 193 | 201 | ASSERT_TRUE (rv == cmResultSuccess || rv == cmUnkonwReason); |
| 194 | 202 | } |
| 203 | + | |
| 204 | + void EncDecOneFrame (const int iWidth, const int iHeight, const int iFrame, FILE* pfEnc) { | |
| 205 | + int iLen = 0, rv; | |
| 206 | + InitialEncDec (iWidth, iHeight); | |
| 207 | + EncodeOneFrame (iFrame); | |
| 208 | + | |
| 209 | + //extract target layer data | |
| 210 | + encToDecData (info, iLen); | |
| 211 | + //call decoder | |
| 212 | + unsigned char* pData[3] = { NULL }; | |
| 213 | + memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); | |
| 214 | + rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, iLen, pData, &dstBufInfo_); | |
| 215 | + EXPECT_TRUE (rv == cmResultSuccess) << " rv = " << rv << " iFrameIdx = " << iFrame; | |
| 216 | + | |
| 217 | + if (NULL != pfEnc) { | |
| 218 | + fwrite (info.sLayerInfo[0].pBsBuf, iLen, 1, pfEnc); | |
| 219 | + } | |
| 220 | + } | |
| 195 | 221 | }; |
| 196 | 222 | |
| 197 | 223 | void EncodeDecodeTestAPI::InitialEncDec (int iWidth, int iHeight) { |
| @@ -234,7 +260,7 @@ void EncodeDecodeTestAPI::RandomParamExtCombination() { · 36 unmodified lines | ||
| 234 | 260 | param_.iNumRefFrame = AUTO_REF_PIC_COUNT; |
| 235 | 261 | param_.iMultipleThreadIdc = rand(); |
| 236 | 262 | |
| 237 | − param_.bEnableSpsPpsIdAddition = (rand() % 2 == 0) ? false : true; | |
| 263 | + param_.iSpsPpsIdStrategy = rand() % 3; | |
| 238 | 264 | param_.bPrefixNalAddingCtrl = (rand() % 2 == 0) ? false : true; |
| 239 | 265 | param_.bEnableSSEI = (rand() % 2 == 0) ? false : true; |
| 240 | 266 | param_.iPaddingFlag = rand() % 2; |
| @@ -462,7 +488,7 @@ static const EncodeDecodeFileParamBase kFileParamArray[] = { · 221 unmodified lines | ||
| 462 | 488 | |
| 463 | 489 | TEST_P (EncodeDecodeTestAPI, DecoderVclNal) { |
| 464 | 490 | EncodeDecodeFileParamBase p = GetParam(); |
| 465 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 491 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 466 | 492 | encoder_->Uninitialize(); |
| 467 | 493 | int rv = encoder_->InitializeExt (¶m_); |
| 468 | 494 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -498,7 +524,7 @@ TEST_P (EncodeDecodeTestAPI, DecoderVclNal) { · 29 unmodified lines | ||
| 498 | 524 | |
| 499 | 525 | TEST_P (EncodeDecodeTestAPI, GetOptionFramenum) { |
| 500 | 526 | EncodeDecodeFileParamBase p = GetParam(); |
| 501 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 527 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 502 | 528 | encoder_->Uninitialize(); |
| 503 | 529 | int rv = encoder_->InitializeExt (¶m_); |
| 504 | 530 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -535,7 +561,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionFramenum) { · 30 unmodified lines | ||
| 535 | 561 | |
| 536 | 562 | TEST_P (EncodeDecodeTestAPI, GetOptionIDR) { |
| 537 | 563 | EncodeDecodeFileParamBase p = GetParam(); |
| 538 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 564 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 539 | 565 | encoder_->Uninitialize(); |
| 540 | 566 | int rv = encoder_->InitializeExt (¶m_); |
| 541 | 567 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -554,7 +580,8 @@ TEST_P (EncodeDecodeTestAPI, GetOptionIDR) { · 12 unmodified lines | ||
| 554 | 580 | int32_t iSpsPpsIdAddition = 0; |
| 555 | 581 | int iIdx = 0; |
| 556 | 582 | while (iIdx <= p.numframes) { |
| 557 | − iSpsPpsIdAddition = rand() % 2; | |
| 583 | + iSpsPpsIdAddition = rand() % | |
| 584 | + 2; //the current strategy supports more than 2 modes, but the switch between the modes>2 is not allowed | |
| 558 | 585 | iIDRPeriod = (rand() % 150) + 1; |
| 559 | 586 | encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod); |
| 560 | 587 | encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iSpsPpsIdAddition); |
| @@ -776,7 +803,7 @@ int SimulateNALLoss (const unsigned char* pSrc, int& iSrcLen, std::vector<SLost · 215 unmodified lines | ||
| 776 | 803 | |
| 777 | 804 | TEST_P (EncodeDecodeTestAPI, GetOptionLTR_ALLIDR) { |
| 778 | 805 | EncodeDecodeFileParamBase p = GetParam(); |
| 779 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 806 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 780 | 807 | encoder_->Uninitialize(); |
| 781 | 808 | int rv = encoder_->InitializeExt (¶m_); |
| 782 | 809 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -809,7 +836,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_ALLLTR) { · 26 unmodified lines | ||
| 809 | 836 | SLTRMarkingFeedback m_LTR_Marking_Feedback; |
| 810 | 837 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 811 | 838 | EncodeDecodeFileParamBase p = GetParam(); |
| 812 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 839 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 813 | 840 | encoder_->Uninitialize(); |
| 814 | 841 | int rv = encoder_->InitializeExt (¶m_); |
| 815 | 842 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -868,7 +895,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_Engine) { · 52 unmodified lines | ||
| 868 | 895 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 869 | 896 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 870 | 897 | EncodeDecodeFileParamBase p = GetParam(); |
| 871 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 898 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 872 | 899 | encoder_->Uninitialize(); |
| 873 | 900 | int rv = encoder_->InitializeExt (¶m_); |
| 874 | 901 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -918,7 +945,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_DISABLE) { · 43 unmodified lines | ||
| 918 | 945 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 919 | 946 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 920 | 947 | EncodeDecodeFileParamBase p = GetParam(); |
| 921 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 948 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 922 | 949 | param_.bEnableLongTermReference = true; |
| 923 | 950 | param_.iLTRRefNum = 1; |
| 924 | 951 | encoder_->Uninitialize(); |
| @@ -985,7 +1012,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_SLICE_COPY) { · 60 unmodified lines | ||
| 985 | 1012 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 986 | 1013 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 987 | 1014 | EncodeDecodeFileParamBase p = GetParam(); |
| 988 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1015 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 989 | 1016 | encoder_->Uninitialize(); |
| 990 | 1017 | int rv = encoder_->InitializeExt (¶m_); |
| 991 | 1018 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -1036,7 +1063,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_SLICE_COPY) { · 44 unmodified lines | ||
| 1036 | 1063 | |
| 1037 | 1064 | TEST_P (EncodeDecodeTestAPI, InOutTimeStamp) { |
| 1038 | 1065 | EncodeDecodeFileParamBase p = GetParam(); |
| 1039 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1066 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1040 | 1067 | encoder_->Uninitialize(); |
| 1041 | 1068 | int rv = encoder_->InitializeExt (¶m_); |
| 1042 | 1069 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -1086,7 +1113,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_NOPREFIX) { · 43 unmodified lines | ||
| 1086 | 1113 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 1087 | 1114 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 1088 | 1115 | EncodeDecodeFileParamBase p = GetParam(); |
| 1089 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1116 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1090 | 1117 | param_.bPrefixNalAddingCtrl = false; |
| 1091 | 1118 | param_.iTemporalLayerNum = (rand() % 4) + 1; |
| 1092 | 1119 | encoder_->Uninitialize(); |
| @@ -1155,7 +1182,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_WITH_PREFIX_NOLOSS) { · 62 unmodified lines | ||
| 1155 | 1182 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 1156 | 1183 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 1157 | 1184 | EncodeDecodeFileParamBase p = GetParam(); |
| 1158 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1185 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1159 | 1186 | param_.bPrefixNalAddingCtrl = true; |
| 1160 | 1187 | param_.iTemporalLayerNum = (rand() % 4) + 1; |
| 1161 | 1188 | param_.iSpatialLayerNum = 1; |
| @@ -1210,7 +1237,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_SVC_L1_NOLOSS) { · 48 unmodified lines | ||
| 1210 | 1237 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 1211 | 1238 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 1212 | 1239 | EncodeDecodeFileParamBase p = GetParam(); |
| 1213 | − prepareParam (2, p.slicenum, p.width, p.height, p.frameRate); | |
| 1240 | + prepareParam (2, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1214 | 1241 | param_.iTemporalLayerNum = (rand() % 4) + 1; |
| 1215 | 1242 | param_.iSpatialLayerNum = 2; |
| 1216 | 1243 | encoder_->Uninitialize(); |
| @@ -1266,7 +1293,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace) { · 49 unmodified lines | ||
| 1266 | 1293 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 1267 | 1294 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 1268 | 1295 | EncodeDecodeFileParamBase p = GetParam(); |
| 1269 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1296 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1270 | 1297 | param_.iSpatialLayerNum = 1; |
| 1271 | 1298 | |
| 1272 | 1299 | int rv = encoder_->InitializeExt (¶m_); |
| @@ -1330,7 +1357,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace_NULL) { · 57 unmodified lines | ||
| 1330 | 1357 | SLTRRecoverRequest m_LTR_Recover_Request; |
| 1331 | 1358 | m_LTR_Recover_Request.uiIDRPicId = 0; |
| 1332 | 1359 | EncodeDecodeFileParamBase p = GetParam(); |
| 1333 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1360 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1334 | 1361 | param_.iSpatialLayerNum = 1; |
| 1335 | 1362 | int rv = encoder_->InitializeExt (¶m_); |
| 1336 | 1363 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -1393,7 +1420,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECIDC_GeneralSliceChange) { · 56 unmodified lines | ||
| 1393 | 1420 | uint32_t uiEcIdc; |
| 1394 | 1421 | uint32_t uiGet; |
| 1395 | 1422 | EncodeDecodeFileParamBase p = GetParam(); |
| 1396 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1423 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1397 | 1424 | param_.iSpatialLayerNum = 1; |
| 1398 | 1425 | encoder_->Uninitialize(); |
| 1399 | 1426 | int rv = encoder_->InitializeExt (¶m_); |
| @@ -1473,7 +1500,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 73 unmodified lines | ||
| 1473 | 1500 | uint32_t uiEcIdc; |
| 1474 | 1501 | uint32_t uiGet; |
| 1475 | 1502 | EncodeDecodeFileParamBase p = kFileParamArray[0]; |
| 1476 | − prepareParam (1, p.slicenum, p.width, p.height, p.frameRate); | |
| 1503 | + prepareParam (1, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1477 | 1504 | param_.iSpatialLayerNum = 1; |
| 1478 | 1505 | encoder_->Uninitialize(); |
| 1479 | 1506 | int rv = encoder_->InitializeExt (¶m_); |
| @@ -1612,7 +1639,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 132 unmodified lines | ||
| 1612 | 1639 | uint32_t uiEcIdc = 2; //default set as SLICE_COPY |
| 1613 | 1640 | uint32_t uiGet; |
| 1614 | 1641 | EncodeDecodeFileParamBase p = kFileParamArray[0]; |
| 1615 | − prepareParam (1, 2, p.width, p.height, p.frameRate); | |
| 1642 | + prepareParam (1, 2, p.width, p.height, p.frameRate, ¶m_); | |
| 1616 | 1643 | param_.iSpatialLayerNum = 1; |
| 1617 | 1644 | encoder_->Uninitialize(); |
| 1618 | 1645 | int rv = encoder_->InitializeExt (¶m_); |
| @@ -1745,7 +1772,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 126 unmodified lines | ||
| 1745 | 1772 | uint32_t uiEcIdc; |
| 1746 | 1773 | uint32_t uiGet; |
| 1747 | 1774 | EncodeDecodeFileParamBase p = kFileParamArray[0]; |
| 1748 | − prepareParam (1, 2, p.width, p.height, p.frameRate); | |
| 1775 | + prepareParam (1, 2, p.width, p.height, p.frameRate, ¶m_); | |
| 1749 | 1776 | param_.iSpatialLayerNum = 1; |
| 1750 | 1777 | encoder_->Uninitialize(); |
| 1751 | 1778 | int rv = encoder_->InitializeExt (¶m_); |
| @@ -1914,7 +1941,7 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_I) { · 162 unmodified lines | ||
| 1914 | 1941 | EncodeDecodeFileParamBase p = kSVCSwitch[0]; |
| 1915 | 1942 | p.width = p.width << 2; |
| 1916 | 1943 | p.height = p.height << 2; |
| 1917 | − prepareParam (4, p.slicenum, p.width, p.height, p.frameRate); | |
| 1944 | + prepareParam (4, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1918 | 1945 | param_.iTemporalLayerNum = (rand() % 4) + 1; |
| 1919 | 1946 | param_.iSpatialLayerNum = 4; |
| 1920 | 1947 | encoder_->Uninitialize(); |
| @@ -1979,7 +2006,7 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_P) { · 58 unmodified lines | ||
| 1979 | 2006 | int iLastDid = 0; |
| 1980 | 2007 | p.width = p.width << 2; |
| 1981 | 2008 | p.height = p.height << 2; |
| 1982 | − prepareParam (4, p.slicenum, p.width, p.height, p.frameRate); | |
| 2009 | + prepareParam (4, p.slicenum, p.width, p.height, p.frameRate, ¶m_); | |
| 1983 | 2010 | param_.iTemporalLayerNum = (rand() % 4) + 1; |
| 1984 | 2011 | param_.iSpatialLayerNum = 4; |
| 1985 | 2012 | encoder_->Uninitialize(); |
| @@ -2065,7 +2092,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionEncParamExt) { · 79 unmodified lines | ||
| 2065 | 2092 | int iEncFrameNum = WelsClip3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM); |
| 2066 | 2093 | int iSliceNum = 1; |
| 2067 | 2094 | encoder_->GetDefaultParams (¶m_); |
| 2068 | − prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate); | |
| 2095 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, ¶m_); | |
| 2069 | 2096 | |
| 2070 | 2097 | int rv = encoder_->InitializeExt (¶m_); |
| 2071 | 2098 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -2128,8 +2155,8 @@ class DecodeCrashTestAPI : public EncodeDecodeTestBase { · 56 unmodified lines | ||
| 2128 | 2155 | ASSERT_TRUE (ucBuf_ == NULL); |
| 2129 | 2156 | } |
| 2130 | 2157 | |
| 2131 | − void prepareParam (int iLayerNum, int iSliceNum, int width, int height, float framerate) { | |
| 2132 | − EncodeDecodeTestBase::prepareParam (iLayerNum, iSliceNum, width, height, framerate); | |
| 2158 | + void prepareParam (int iLayerNum, int iSliceNum, int width, int height, float framerate, SEncParamExt* pParam) { | |
| 2159 | + EncodeDecodeTestBase::prepareParam (iLayerNum, iSliceNum, width, height, framerate, pParam); | |
| 2133 | 2160 | } |
| 2134 | 2161 | |
| 2135 | 2162 | void prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam); |
| @@ -2203,11 +2230,11 @@ TEST_F (DecodeCrashTestAPI, DecoderCrashTest) { · 67 unmodified lines | ||
| 2203 | 2230 | int iSeed = rand() % 3; //3 indicates the length of kParamArray[] used in the following |
| 2204 | 2231 | EncodeDecodeParamBase p = kParamArray[iSeed]; |
| 2205 | 2232 | //Initialize Encoder |
| 2206 | − prepareParam (1, 1, p.width, p.height, p.frameRate); | |
| 2233 | + prepareParam (1, 1, p.width, p.height, p.frameRate, ¶m_); | |
| 2207 | 2234 | param_.iRCMode = RC_BITRATE_MODE; |
| 2208 | 2235 | param_.iTargetBitrate = p.iTarBitrate; |
| 2209 | 2236 | param_.uiIntraPeriod = 0; |
| 2210 | − param_.bEnableSpsPpsIdAddition = true; | |
| 2237 | + param_.iSpsPpsIdStrategy = INCREASING_ID; | |
| 2211 | 2238 | param_.bEnableBackgroundDetection = true; |
| 2212 | 2239 | param_.bEnableSceneChangeDetect = true; |
| 2213 | 2240 | param_.bPrefixNalAddingCtrl = true; |
| @@ -2398,7 +2425,7 @@ TEST_F (DecodeParseAPI, ParseOnly_General) { · 184 unmodified lines | ||
| 2398 | 2425 | p.height = iHeight_; |
| 2399 | 2426 | p.frameRate = kiFrameRate; |
| 2400 | 2427 | p.numframes = kiFrameNum; |
| 2401 | − prepareParam (kiTotalLayer, kiSliceNum, p.width, p.height, p.frameRate); | |
| 2428 | + prepareParam (kiTotalLayer, kiSliceNum, p.width, p.height, p.frameRate, ¶m_); | |
| 2402 | 2429 | param_.iSpatialLayerNum = kiTotalLayer; |
| 2403 | 2430 | encoder_->Uninitialize(); |
| 2404 | 2431 | int rv = encoder_->InitializeExt (¶m_); |
| @@ -2475,7 +2502,7 @@ TEST_F (DecodeParseAPI, ParseOnly_SpecSliceLoss) { · 70 unmodified lines | ||
| 2475 | 2502 | p.height = iHeight_; |
| 2476 | 2503 | p.frameRate = kiFrameRate; |
| 2477 | 2504 | p.numframes = 5; |
| 2478 | − prepareParam (iLayerNum, iSliceNum, p.width, p.height, p.frameRate); | |
| 2505 | + prepareParam (iLayerNum, iSliceNum, p.width, p.height, p.frameRate, ¶m_); | |
| 2479 | 2506 | param_.iSpatialLayerNum = iLayerNum; |
| 2480 | 2507 | encoder_->Uninitialize(); |
| 2481 | 2508 | int rv = encoder_->InitializeExt (¶m_); |
| @@ -2525,3 +2552,434 @@ TEST_F (DecodeParseAPI, ParseOnly_SpecSliceLoss) { · 43 unmodified lines | ||
| 2525 | 2552 | } //while |
| 2526 | 2553 | } |
| 2527 | 2554 | |
| 2555 | +//#define DEBUG_FILE_SAVE2 | |
| 2556 | +TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING1) { | |
| 2557 | + | |
| 2558 | + int iWidth = GetRandWidth(); | |
| 2559 | + int iHeight = GetRandHeight(); | |
| 2560 | + float fFrameRate = rand() + 0.5f; | |
| 2561 | + int iEncFrameNum = 0; | |
| 2562 | + int iSpatialLayerNum = 1; | |
| 2563 | + int iSliceNum = 1; | |
| 2564 | + | |
| 2565 | + // prepare params | |
| 2566 | + SEncParamExt sParam1; | |
| 2567 | + SEncParamExt sParam2; | |
| 2568 | + SEncParamExt sParam3; | |
| 2569 | + encoder_->GetDefaultParams (&sParam1); | |
| 2570 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1); | |
| 2571 | + sParam1.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING; | |
| 2572 | + //prepare param2 | |
| 2573 | + memcpy (&sParam2, &sParam1, sizeof (SEncParamExt)); | |
| 2574 | + while (sParam2.iPicWidth == sParam1.iPicWidth) { | |
| 2575 | + sParam2.iPicWidth = GetRandWidth(); | |
| 2576 | + } | |
| 2577 | + prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2); | |
| 2578 | + sParam2.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING; | |
| 2579 | + //prepare param3 | |
| 2580 | + memcpy (&sParam3, &sParam1, sizeof (SEncParamExt)); | |
| 2581 | + while (sParam3.iPicHeight == sParam1.iPicHeight) { | |
| 2582 | + sParam3.iPicHeight = GetRandHeight(); | |
| 2583 | + } | |
| 2584 | + prepareParam (iSpatialLayerNum, iSliceNum, sParam3.iPicWidth, sParam3.iPicHeight, fFrameRate, &sParam3); | |
| 2585 | + sParam3.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING; | |
| 2586 | + | |
| 2587 | + //prepare output if needed | |
| 2588 | + FILE* fEnc = NULL; | |
| 2589 | +#ifdef DEBUG_FILE_SAVE2 | |
| 2590 | + fEnc = fopen ("enc2.264", "wb"); | |
| 2591 | +#endif | |
| 2592 | + | |
| 2593 | + // Test part#1 | |
| 2594 | + // step#1: pParam1 | |
| 2595 | + //int TraceLevel = WELS_LOG_INFO; | |
| 2596 | + //encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel); | |
| 2597 | + int rv = encoder_->InitializeExt (&sParam1); | |
| 2598 | + ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | |
| 2599 | + sParam1.iPicHeight; | |
| 2600 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2601 | + | |
| 2602 | + // new IDR | |
| 2603 | + rv = encoder_->ForceIntraFrame (true); | |
| 2604 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2605 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2606 | + | |
| 2607 | + // step#2: pParam2 | |
| 2608 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2609 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption: rv = " << rv << " at " << sParam2.iPicWidth << "x" << | |
| 2610 | + sParam2.iPicHeight; | |
| 2611 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2612 | + | |
| 2613 | + // new IDR | |
| 2614 | + rv = encoder_->ForceIntraFrame (true); | |
| 2615 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2616 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2617 | + | |
| 2618 | + // step#3: back to pParam1 | |
| 2619 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam1); | |
| 2620 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | |
| 2621 | + sParam1.iPicHeight; | |
| 2622 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2623 | + | |
| 2624 | + // step#4: back to pParam2 | |
| 2625 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2626 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv << sParam2.iPicWidth << sParam2.iPicHeight; | |
| 2627 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2628 | + | |
| 2629 | +#ifdef DEBUG_FILE_SAVE2 | |
| 2630 | + fclose (fEnc); | |
| 2631 | +#endif | |
| 2632 | + rv = encoder_->Uninitialize(); | |
| 2633 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2634 | + | |
| 2635 | + // Test part#2 | |
| 2636 | + // step#1: pParam1 | |
| 2637 | + rv = encoder_->InitializeExt (&sParam1); | |
| 2638 | + ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt Failed: rv = " << rv; | |
| 2639 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2640 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | |
| 2641 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam3); | |
| 2642 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam3: rv = " << rv; | |
| 2643 | + | |
| 2644 | +#ifdef DEBUG_FILE_SAVE2 | |
| 2645 | + fEnc = fopen ("enc3.264", "wb"); | |
| 2646 | +#endif | |
| 2647 | + iEncFrameNum = 0; | |
| 2648 | + EncDecOneFrame (sParam3.iPicWidth, sParam3.iPicHeight, iEncFrameNum++, fEnc); | |
| 2649 | + | |
| 2650 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2651 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | |
| 2652 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2653 | + | |
| 2654 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam1); | |
| 2655 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | |
| 2656 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2657 | + | |
| 2658 | +#ifdef DEBUG_FILE_SAVE2 | |
| 2659 | + fclose (fEnc); | |
| 2660 | +#endif | |
| 2661 | + rv = encoder_->Uninitialize(); | |
| 2662 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2663 | +} | |
| 2664 | + | |
| 2665 | +#define DEBUG_FILE_SAVE5 | |
| 2666 | +TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING2) { | |
| 2667 | + //usage 3: 2 Params with different num_ref, encode IDR0, P1, IDR2; | |
| 2668 | + //the bs will show two SPS and different PPS | |
| 2669 | + | |
| 2670 | + int iWidth = GetRandWidth(); | |
| 2671 | + int iHeight = GetRandHeight(); | |
| 2672 | + float fFrameRate = rand() + 0.5f; | |
| 2673 | + int iEncFrameNum = 0; | |
| 2674 | + int iSpatialLayerNum = 1; | |
| 2675 | + int iSliceNum = 1; | |
| 2676 | + | |
| 2677 | + // prepare params | |
| 2678 | + SEncParamExt sParam1; | |
| 2679 | + SEncParamExt sParam2; | |
| 2680 | + encoder_->GetDefaultParams (&sParam1); | |
| 2681 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1); | |
| 2682 | + sParam1.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING; | |
| 2683 | + sParam1.iTemporalLayerNum = 1; | |
| 2684 | + //prepare param2 | |
| 2685 | + memcpy (&sParam2, &sParam1, sizeof (SEncParamExt)); | |
| 2686 | + prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2); | |
| 2687 | + sParam2.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING; | |
| 2688 | + sParam2.iTemporalLayerNum = 3; | |
| 2689 | + | |
| 2690 | + //prepare output if needed | |
| 2691 | + FILE* fEnc = NULL; | |
| 2692 | +#ifdef DEBUG_FILE_SAVE5 | |
| 2693 | + fEnc = fopen ("encID2.264", "wb"); | |
| 2694 | +#endif | |
| 2695 | + | |
| 2696 | + // step#1: pParam1 | |
| 2697 | + int rv = encoder_->InitializeExt (&sParam1); | |
| 2698 | + ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | |
| 2699 | + sParam1.iPicHeight; | |
| 2700 | + | |
| 2701 | + // step#2: pParam2 | |
| 2702 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2703 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | |
| 2704 | + | |
| 2705 | + // step#3: set back to pParam1, with a smaller num_ref, it still uses the previous SPS | |
| 2706 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam1); | |
| 2707 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam1: rv = " << rv; | |
| 2708 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2709 | + | |
| 2710 | + // new IDR, PPS increases | |
| 2711 | + rv = encoder_->ForceIntraFrame (true); | |
| 2712 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2713 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2714 | + | |
| 2715 | + rv = encoder_->Uninitialize(); | |
| 2716 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2717 | + | |
| 2718 | +#ifdef DEBUG_FILE_SAVE5 | |
| 2719 | + fclose (fEnc); | |
| 2720 | +#endif | |
| 2721 | +} | |
| 2722 | + | |
| 2723 | +TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING3) { | |
| 2724 | + | |
| 2725 | + int iWidth = GetRandWidth(); | |
| 2726 | + int iHeight = GetRandHeight(); | |
| 2727 | + float fFrameRate = rand() + 0.5f; | |
| 2728 | + int iEncFrameNum = 0; | |
| 2729 | + int iSpatialLayerNum = 1; | |
| 2730 | + int iSliceNum = 1; | |
| 2731 | + | |
| 2732 | + // prepare params | |
| 2733 | + SEncParamExt sParam1; | |
| 2734 | + SEncParamExt sParam2; | |
| 2735 | + encoder_->GetDefaultParams (&sParam1); | |
| 2736 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1); | |
| 2737 | + sParam1.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING; | |
| 2738 | + | |
| 2739 | + //prepare output if needed | |
| 2740 | + FILE* fEnc = NULL; | |
| 2741 | +#ifdef DEBUG_FILE_SAVE2 | |
| 2742 | + fEnc = fopen ("enc4.264", "wb"); | |
| 2743 | +#endif | |
| 2744 | + | |
| 2745 | + // step#1: pParam1 | |
| 2746 | + int rv = encoder_->InitializeExt (&sParam1); | |
| 2747 | + ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt Failed: rv = " << rv; | |
| 2748 | + | |
| 2749 | + int max_count = 65; // make it more then twice as MAX_SPS_COUNT | |
| 2750 | + std::vector<int> vWidthTable; | |
| 2751 | + vWidthTable.push_back (sParam1.iPicWidth); | |
| 2752 | + | |
| 2753 | + std::vector<int>::iterator vWidthTableIt; | |
| 2754 | + for (int times = 0; times < max_count; times++) { | |
| 2755 | + //prepare param2 | |
| 2756 | + memcpy (&sParam2, &sParam1, sizeof (SEncParamExt)); | |
| 2757 | + do { | |
| 2758 | + sParam2.iPicWidth = GetRandWidth(); | |
| 2759 | + vWidthTableIt = std::find (vWidthTable.begin(), vWidthTable.end(), sParam2.iPicWidth); | |
| 2760 | + } while (vWidthTableIt == vWidthTable.end()); | |
| 2761 | + vWidthTable.push_back (sParam2.iPicWidth); | |
| 2762 | + prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2); | |
| 2763 | + sParam2.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING; | |
| 2764 | + | |
| 2765 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2766 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv << ", sParam2.iPicWidth=" << | |
| 2767 | + sParam2.iPicWidth; | |
| 2768 | + } // end of setting loop | |
| 2769 | + | |
| 2770 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2771 | + | |
| 2772 | +#ifdef DEBUG_FILE_SAVE2 | |
| 2773 | + fclose (fEnc); | |
| 2774 | +#endif | |
| 2775 | + rv = encoder_->Uninitialize(); | |
| 2776 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2777 | +} | |
| 2778 | + | |
| 2779 | +//#define DEBUG_FILE_SAVE6 | |
| 2780 | +TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_PPS_LISTING1) { | |
| 2781 | + //usage 1: 1 resolution Params, encode IDR0, P1, IDR2; | |
| 2782 | + //the bs will show same SPS and different PPS | |
| 2783 | + // PPS: pic_parameter_set_id 1 ( 0) | |
| 2784 | + // PPS: seq_parameter_set_id 1 ( 0) | |
| 2785 | + // PPS: pic_parameter_set_id 010 ( 1) | |
| 2786 | + // PPS: seq_parameter_set_id 1 ( 0) | |
| 2787 | + // SH: slice_type 011 ( 2) | |
| 2788 | + // SH: pic_parameter_set_id 1 ( 0) | |
| 2789 | + // SH: slice_type 1 ( 0) | |
| 2790 | + // SH: pic_parameter_set_id 1 ( 0) | |
| 2791 | + // SH: slice_type 011 ( 2) | |
| 2792 | + // SH: pic_parameter_set_id 010 ( 1) | |
| 2793 | + int iWidth = GetRandWidth(); | |
| 2794 | + int iHeight = GetRandHeight(); | |
| 2795 | + float fFrameRate = rand() + 0.5f; | |
| 2796 | + int iEncFrameNum = 0; | |
| 2797 | + int iSpatialLayerNum = 1; | |
| 2798 | + int iSliceNum = 1; | |
| 2799 | + | |
| 2800 | + // prepare params | |
| 2801 | + SEncParamExt sParam1; | |
| 2802 | + encoder_->GetDefaultParams (&sParam1); | |
| 2803 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1); | |
| 2804 | + sParam1.iSpsPpsIdStrategy = SPS_PPS_LISTING; | |
| 2805 | + | |
| 2806 | + //prepare output if needed | |
| 2807 | + FILE* fEnc = NULL; | |
| 2808 | +#ifdef DEBUG_FILE_SAVE6 | |
| 2809 | + fEnc = fopen ("encLIST1.264", "wb"); | |
| 2810 | +#endif | |
| 2811 | + | |
| 2812 | + // step#1: pParam1 | |
| 2813 | + int rv = encoder_->InitializeExt (&sParam1); | |
| 2814 | + ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | |
| 2815 | + sParam1.iPicHeight; | |
| 2816 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2817 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2818 | + | |
| 2819 | + // new IDR | |
| 2820 | + rv = encoder_->ForceIntraFrame (true); | |
| 2821 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2822 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2823 | + | |
| 2824 | + rv = encoder_->Uninitialize(); | |
| 2825 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2826 | + | |
| 2827 | +#ifdef DEBUG_FILE_SAVE6 | |
| 2828 | + fclose (fEnc); | |
| 2829 | +#endif | |
| 2830 | +} | |
| 2831 | + | |
| 2832 | +TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_PPS_LISTING2) { | |
| 2833 | + //usage 2: 2 resolution Params, encode IDR0, IDR1, IDR2; | |
| 2834 | + //the bs will show two SPS and different PPS | |
| 2835 | + // === SPS LIST === | |
| 2836 | + //SPS: seq_parameter_set_id 1 ( 0) -- PARAM1 | |
| 2837 | + //SPS: seq_parameter_set_id 010 ( 1) -- PARAM2 | |
| 2838 | + // === PPS LIST === | |
| 2839 | + //PPS: pic_parameter_set_id 1 ( 0) | |
| 2840 | + //PPS: seq_parameter_set_id 1 ( 0) | |
| 2841 | + //PPS: pic_parameter_set_id 010 ( 1) | |
| 2842 | + //PPS: seq_parameter_set_id 010 ( 1) | |
| 2843 | + //PPS: pic_parameter_set_id 011 ( 2) -- PPS2 - SPS0 | |
| 2844 | + //PPS: seq_parameter_set_id 1 ( 0) | |
| 2845 | + //PPS: pic_parameter_set_id 00100 ( 3) -- PPS3 - SPS1 | |
| 2846 | + //PPS: seq_parameter_set_id 010 ( 1) | |
| 2847 | + //PPS: pic_parameter_set_id 00101 ( 4) -- PPS4 - SPS0 | |
| 2848 | + //PPS: seq_parameter_set_id 1 ( 0) | |
| 2849 | + // === VCL LAYER === | |
| 2850 | + //SH: slice_type 011 ( 2) -- PARAM2 | |
| 2851 | + //SH: pic_parameter_set_id 010 ( 1) -- PPS1 - SPS1 - PARAM2 | |
| 2852 | + //SH: slice_type 011 ( 2) -- PARAM1 | |
| 2853 | + //SH: pic_parameter_set_id 011 ( 2) -- PPS2 - SPS0 - PARAM1 | |
| 2854 | + //SH: slice_type 011 ( 2) -- PARAM1 | |
| 2855 | + //SH: pic_parameter_set_id 00101 ( 4) -- PPS4 - SPS0 - PARAM1 | |
| 2856 | + | |
| 2857 | + int iWidth = GetRandWidth(); | |
| 2858 | + int iHeight = GetRandHeight(); | |
| 2859 | + float fFrameRate = rand() + 0.5f; | |
| 2860 | + int iEncFrameNum = 0; | |
| 2861 | + int iSpatialLayerNum = 1; | |
| 2862 | + int iSliceNum = 1; | |
| 2863 | + | |
| 2864 | + // prepare params | |
| 2865 | + SEncParamExt sParam1; | |
| 2866 | + SEncParamExt sParam2; | |
| 2867 | + encoder_->GetDefaultParams (&sParam1); | |
| 2868 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1); | |
| 2869 | + sParam1.iSpsPpsIdStrategy = SPS_PPS_LISTING; | |
| 2870 | + //prepare param2 | |
| 2871 | + memcpy (&sParam2, &sParam1, sizeof (SEncParamExt)); | |
| 2872 | + while (sParam2.iPicWidth == sParam1.iPicWidth) { | |
| 2873 | + sParam2.iPicWidth = GetRandWidth(); | |
| 2874 | + } | |
| 2875 | + prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2); | |
| 2876 | + sParam2.iSpsPpsIdStrategy = SPS_PPS_LISTING; | |
| 2877 | + | |
| 2878 | + //prepare output if needed | |
| 2879 | + FILE* fEnc = NULL; | |
| 2880 | +#ifdef DEBUG_FILE_SAVE5 | |
| 2881 | + fEnc = fopen ("encLIST2.264", "wb"); | |
| 2882 | +#endif | |
| 2883 | + | |
| 2884 | + // step#1: pParam1 | |
| 2885 | + int rv = encoder_->InitializeExt (&sParam1); | |
| 2886 | + ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | |
| 2887 | + sParam1.iPicHeight; | |
| 2888 | + | |
| 2889 | + // step#2: pParam2 | |
| 2890 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2891 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | |
| 2892 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2893 | + | |
| 2894 | + // step#3: back to pParam1, SHOULD NOT encounter ERROR | |
| 2895 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam1); | |
| 2896 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | |
| 2897 | + sParam1.iPicHeight; | |
| 2898 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2899 | + | |
| 2900 | + // new IDR | |
| 2901 | + rv = encoder_->ForceIntraFrame (true); | |
| 2902 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2903 | + EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | |
| 2904 | + | |
| 2905 | + rv = encoder_->Uninitialize(); | |
| 2906 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2907 | + | |
| 2908 | +#ifdef DEBUG_FILE_SAVE5 | |
| 2909 | + fclose (fEnc); | |
| 2910 | +#endif | |
| 2911 | +} | |
| 2912 | + | |
| 2913 | +TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_PPS_LISTING3) { | |
| 2914 | + | |
| 2915 | + int iWidth = GetRandWidth(); | |
| 2916 | + int iHeight = GetRandHeight(); | |
| 2917 | + float fFrameRate = rand() + 0.5f; | |
| 2918 | + int iEncFrameNum = 0; | |
| 2919 | + int iSpatialLayerNum = 1; | |
| 2920 | + int iSliceNum = 1; | |
| 2921 | + | |
| 2922 | + // prepare params | |
| 2923 | + SEncParamExt sParam1; | |
| 2924 | + SEncParamExt sParam2; | |
| 2925 | + SEncParamExt sParam3; | |
| 2926 | + encoder_->GetDefaultParams (&sParam1); | |
| 2927 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1); | |
| 2928 | + sParam1.iSpsPpsIdStrategy = SPS_PPS_LISTING; | |
| 2929 | + //prepare param2 | |
| 2930 | + memcpy (&sParam2, &sParam1, sizeof (SEncParamExt)); | |
| 2931 | + while (sParam2.iPicWidth == sParam1.iPicWidth) { | |
| 2932 | + sParam2.iPicWidth = GetRandWidth(); | |
| 2933 | + } | |
| 2934 | + prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2); | |
| 2935 | + sParam2.iSpsPpsIdStrategy = SPS_PPS_LISTING; | |
| 2936 | + //prepare param3 | |
| 2937 | + memcpy (&sParam3, &sParam1, sizeof (SEncParamExt)); | |
| 2938 | + while (sParam3.iPicWidth == sParam1.iPicWidth || sParam3.iPicWidth == sParam2.iPicWidth) { | |
| 2939 | + sParam3.iPicWidth = GetRandWidth(); | |
| 2940 | + } | |
| 2941 | + prepareParam (iSpatialLayerNum, iSliceNum, sParam3.iPicWidth, sParam3.iPicHeight, fFrameRate, &sParam3); | |
| 2942 | + sParam3.iSpsPpsIdStrategy = SPS_PPS_LISTING; | |
| 2943 | + | |
| 2944 | + //prepare output if needed | |
| 2945 | + FILE* fEnc = NULL; | |
| 2946 | +#ifdef DEBUG_FILE_SAVE5 | |
| 2947 | + fEnc = fopen ("enc4.264", "wb"); | |
| 2948 | +#endif | |
| 2949 | + | |
| 2950 | + // step#1: ordinary encoding | |
| 2951 | + int rv = encoder_->InitializeExt (&sParam1); | |
| 2952 | + ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | |
| 2953 | + sParam1.iPicHeight; | |
| 2954 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | |
| 2955 | + ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | |
| 2956 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2957 | + | |
| 2958 | + // step#2: set strategy for success | |
| 2959 | + int32_t iNewStra = SPS_PPS_LISTING; | |
| 2960 | + rv = encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iNewStra); | |
| 2961 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv << " iNewStra=" << iNewStra; | |
| 2962 | + | |
| 2963 | + // step#3: setting new strategy, SHOULD encounter ERROR | |
| 2964 | + unsigned int TraceLevel = WELS_LOG_QUIET; | |
| 2965 | + rv = encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel); | |
| 2966 | + ASSERT_TRUE (rv == cmResultSuccess); | |
| 2967 | + iNewStra = CONSTANT_ID; | |
| 2968 | + rv = encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iNewStra); | |
| 2969 | + ASSERT_TRUE (rv != cmResultSuccess); | |
| 2970 | + | |
| 2971 | + EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | |
| 2972 | + | |
| 2973 | + // step#4: pParam3, SHOULD encounter ERROR | |
| 2974 | + rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam3); | |
| 2975 | + ASSERT_TRUE (rv != cmResultSuccess) << "SetOption: rv = " << rv << " at " << sParam3.iPicWidth << "x" << | |
| 2976 | + sParam3.iPicHeight; | |
| 2977 | + | |
| 2978 | + rv = encoder_->Uninitialize(); | |
| 2979 | + ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | |
| 2980 | + | |
| 2981 | +#ifdef DEBUG_FILE_SAVE5 | |
| 2982 | + fclose (fEnc); | |
| 2983 | +#endif | |
| 2984 | +} | |
| 2985 | + | |