History

add more special resolution and slice-mode tests

sijchen@cisco.com committed 10 years ago

Commit af0427d1 parent 30328b82 files · +98 −61Browse files

Showing the changes to test/api/encode_options_test.cpp (1 of 2 files). Show all

Unified · Split

test/api/encode_options_test.cpp+97−60
@@ -1204,30 +1204,42 @@ static const EncodeOptionParam kOptionParamArray[] = { · 1203 unmodified lines
12041204 {true, true, false, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
12051205 {true, true, false, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
12061206 {true, true, false, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1207− {true, true, false, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1207+ {true, true, false, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""}, //5
12081208 {true, false, true, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 1, ""},
12091209 {true, false, true, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 1, ""},
12101210 {true, false, true, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
12111211 {true, false, true, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1212− {true, false, true, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1212+ {true, false, true, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""}, //10
12131213 {true, false, true, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
12141214 {true, true, true, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 1, ""},
12151215 {true, true, true, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 1, ""},
12161216 {true, true, true, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1217− {true, true, true, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1217+ {true, true, true, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""}, //15
12181218 {true, true, true, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
12191219 {true, true, true, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1220− {false, false, true, 3, 4096, 2304, 2, SM_SINGLE_SLICE, 0, 7.5, 1, ""}, // large picture size
12211220 {false, true, false, 30, 32, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
12221221 {false, true, false, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 4, ""},
1223− {false, true, false, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 2, ""},
1222+ {false, true, false, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 2, ""}, //20
12241223 {false, true, false, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 3, ""},
12251224 {false, true, false, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 2, ""},
12261225 {false, true, false, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 2, ""},
12271226 {false, true, false, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 3, ""},
1228− {false, true, false, 30, 32, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 3, ""},
1227+ {false, true, false, 30, 32, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 3, ""}, //25
12291228 {false, false, true, 30, 600, 460, 1, SM_FIXEDSLCNUM_SLICE, 0, 15.0, 4, ""},
12301229 {false, false, true, 30, 600, 460, 1, SM_FIXEDSLCNUM_SLICE, 0, 15.0, 8, ""},
1230+ //for large size tests
1231+ {true, false, true, 30, 4096, 2304, 1, SM_RESERVED, 0, 7.5, 1, ""}, // large picture size
1232+ {true, false, true, 30, 2304, 4096, 1, SM_RESERVED, 0, 15.0, 1, ""},
1233+ {true, false, true, 30, 3072, 3072, 1, SM_RESERVED, 0, 15.0, 1, ""},
1234+ //{true, false, true, 30, 3072, 3072, 1, SM_RESERVED, 0, 15.0, 4, ""}, //14760
1235+ {false, false, true, 30, 1072, 8576, 1, SM_RESERVED, 0, 15.0, 1, ""},
1236+ //{false, true, true, 30, 8576, 1072, 24, SM_SINGLE_SLICE, 0, 15.0, 1, ""}, //14754
1237+ //{false, false, false, 2, 8576, 1088, 24, SM_SINGLE_SLICE, 0, 15.0, 1, ""}, //14755
1238+ //{false, false, false, 2, 1088, 8576, 24, SM_SINGLE_SLICE, 0, 15.0, 1, ""}, //14755
1239+ {false, false, true, 1, 8688, 1072, 24, SM_SINGLE_SLICE, 0, 15.0, 1, ""}, //Annex A: PicWidthInMbs <= sqrt(36864*8) = 543; 543*16=8688; 36864/543=67; 67*16=1072
1240+ {false, false, true, 1, 1072, 8688, 24, SM_SINGLE_SLICE, 0, 15.0, 1, ""}, //Annex A: FrameHeightInMbs <= sqrt(36864*8) = 543; 543*16=8688; 36864/543=67; 67*16=1072
1241+ //{false, false, true, 30, 589824, 16, 24, SM_RESERVED, 0, 15.0, 1, ""},
1242+ //{false, false, true, 30, 589824, 16, 24, SM_RESERVED, 0, 15.0, 1, ""},
12311243 };
12321244
12331245 class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public ::EncodeDecodeTestAPIBase {
@@ -1259,10 +1271,6 @@ INSTANTIATE_TEST_CASE_P (EncodeDecodeTestAPIBase, EncodeTestAPI, · 25 unmodified lines
12591271
12601272 TEST_P (EncodeTestAPI, SetEncOptionSize) {
12611273 EncodeOptionParam p = GetParam();
1262− FILE* pFile = NULL;
1263− if (p.sFileSave != NULL && strlen (p.sFileSave) > 0) {
1264− pFile = fopen (p.sFileSave, "wb");
1265− }
12661274 memset (&param_, 0, sizeof (SEncParamExt));
12671275 encoder_->GetDefaultParams (&param_);
12681276 param_.uiMaxNalSize = p.uiMaxNalLen;
@@ -1275,66 +1283,95 @@ TEST_P (EncodeTestAPI, SetEncOptionSize) { · 6 unmodified lines
12751283 param_.iRCMode = RC_OFF_MODE; //rc off
12761284 param_.iMultipleThreadIdc = p.iThreads;
12771285 param_.iNumRefFrame = AUTO_REF_PIC_COUNT;
1278− param_.sSpatialLayers[0].iVideoWidth = p.iWidth ;
1286+ param_.sSpatialLayers[0].iVideoWidth = p.iWidth;
12791287 param_.sSpatialLayers[0].iVideoHeight = p.iHeight;
12801288 param_.sSpatialLayers[0].fFrameRate = p.fFramerate;
1281− param_.sSpatialLayers[0].sSliceArgument.uiSliceMode = p.eSliceMode;
1282− if (SM_FIXEDSLCNUM_SLICE == p.eSliceMode) {
1283− param_.sSpatialLayers[0].sSliceArgument.uiSliceNum = 8;
1284− }
12851289
1286− encoder_->Uninitialize();
1287− int rv = encoder_->InitializeExt (&param_);
1288− ASSERT_TRUE (rv == cmResultSuccess);
1289− InitialEncDec (p.iWidth, p.iHeight);
1290+ int iSliceModeTestNum = 1;
1291+ if (SM_RESERVED == p.eSliceMode) {
1292+ iSliceModeTestNum = SLICE_MODE_NUM;
1293+ }
12901294
1291− int32_t iTraceLevel = WELS_LOG_QUIET;
1292− encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
1293− decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
1294− int32_t iSpsPpsIdAddition = 1;
1295− encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iSpsPpsIdAddition);
1296− int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
1297− encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
1298− int iIdx = 0;
1299− int iLen;
1300− unsigned char* pData[3] = { NULL };
1295+ for (int iSliceIdx = 0; iSliceIdx < iSliceModeTestNum; iSliceIdx++) {
1296+ if (1 == iSliceModeTestNum) {
1297+ param_.sSpatialLayers[0].sSliceArgument.uiSliceMode = p.eSliceMode;
1298+ } else {
1299+ param_.sSpatialLayers[0].sSliceArgument.uiSliceMode = static_cast<SliceModeEnum> (iSliceIdx);
1300+ }
13011301
1302− //FIXME: remove this after the multi-thread case is correctly handled in encoder
1303− if (p.iThreads > 1 && SM_SIZELIMITED_SLICE == p.eSliceMode) {
1304− p.bAllRandom = false;
1305− }
1302+ FILE* pFile = NULL;
1303+ if (p.sFileSave != NULL && strlen (p.sFileSave) > 0) {
1304+ pFile = fopen (p.sFileSave, "wb");
1305+ }
13061306
1307− while (iIdx <= p.iNumframes) {
1308− EncodeOneFrameRandom (0, p.bAllRandom);
1309− encToDecData (info, iLen);
1310− if (pFile) {
1311− fwrite (info.sLayerInfo[0].pBsBuf, iLen, 1, pFile);
1312− fflush (pFile);
1307+ if (SM_FIXEDSLCNUM_SLICE == param_.sSpatialLayers[0].sSliceArgument.uiSliceMode) {
1308+ param_.sSpatialLayers[0].sSliceArgument.uiSliceNum = 8;
1309+ } else if (SM_RASTER_SLICE == param_.sSpatialLayers[0].sSliceArgument.uiSliceMode) {
1310+ param_.sSpatialLayers[0].sSliceArgument.uiSliceMbNum[0] =
1311+ param_.sSpatialLayers[0].sSliceArgument.uiSliceMbNum[1] =
1312+ param_.sSpatialLayers[0].sSliceArgument.uiSliceMbNum[2] =
1313+ param_.sSpatialLayers[0].sSliceArgument.uiSliceMbNum[3] = ((p.iWidth * p.iHeight) >> 10);
1314+ } else if (SM_SIZELIMITED_SLICE == param_.sSpatialLayers[0].sSliceArgument.uiSliceMode && 450 > p.uiMaxNalLen) {
1315+ param_.uiMaxNalSize = 450;
1316+ param_.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = 450;
13131317 }
1314− memset (&dstBufInfo_, 0, sizeof (SBufferInfo));
1315− if (iLen && p.bTestDecoder) {
1316− rv = decoder_->DecodeFrameNoDelay (info.sLayerInfo[0].pBsBuf, iLen, pData, &dstBufInfo_);
1317− ASSERT_EQ (rv, 0);
1318− ASSERT_EQ (dstBufInfo_.iBufferStatus, 1);
1318+
1319+ int32_t iTraceLevel = WELS_LOG_QUIET;
1320+ encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
1321+ decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
1322+
1323+ encoder_->Uninitialize();
1324+ int rv = encoder_->InitializeExt (&param_);
1325+ ASSERT_TRUE (rv == cmResultSuccess);
1326+ InitialEncDec (p.iWidth, p.iHeight);
1327+
1328+
1329+ int32_t iSpsPpsIdAddition = 1;
1330+ encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iSpsPpsIdAddition);
1331+ int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
1332+ encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
1333+ int iIdx = 0;
1334+ int iLen;
1335+ unsigned char* pData[3] = { NULL };
1336+
1337+ //FIXME: remove this after the multi-thread case is correctly handled in encoder
1338+ if (p.iThreads > 1 && SM_SIZELIMITED_SLICE == p.eSliceMode) {
1339+ p.bAllRandom = false;
13191340 }
1320− int iLayer = 0;
1321− while (iLayer < info.iLayerNum) {
1322− SLayerBSInfo* pLayerBsInfo = &info.sLayerInfo[iLayer];
1323− if (pLayerBsInfo != NULL) {
1324− int iNalIdx = WELS_MAX (pLayerBsInfo->iNalCount - 2, 0); // ignore last slice under single slice mode
1325− do {
1326− if (p.bTestNalSize) { // ignore the case that 2 MBs in one picture, and the multithreads case, enable them when code is ready
1327− ASSERT_GE (((int)param_.uiMaxNalSize), pLayerBsInfo->pNalLengthInByte[iNalIdx]);
1328− }
1329− -- iNalIdx;
1330− } while (iNalIdx >= 0);
1341+
1342+ while (iIdx <= p.iNumframes) {
1343+ EncodeOneFrameRandom (0, p.bAllRandom);
1344+ encToDecData (info, iLen);
1345+ if (pFile) {
1346+ fwrite (info.sLayerInfo[0].pBsBuf, iLen, 1, pFile);
1347+ fflush (pFile);
13311348 }
1332− ++ iLayer;
1349+ memset (&dstBufInfo_, 0, sizeof (SBufferInfo));
1350+ if (iLen && p.bTestDecoder) {
1351+ rv = decoder_->DecodeFrameNoDelay (info.sLayerInfo[0].pBsBuf, iLen, pData, &dstBufInfo_);
1352+ ASSERT_EQ (rv, 0);
1353+ ASSERT_EQ (dstBufInfo_.iBufferStatus, 1);
1354+ }
1355+ int iLayer = 0;
1356+ while (iLayer < info.iLayerNum) {
1357+ SLayerBSInfo* pLayerBsInfo = &info.sLayerInfo[iLayer];
1358+ if (pLayerBsInfo != NULL) {
1359+ int iNalIdx = WELS_MAX (pLayerBsInfo->iNalCount - 2, 0); // ignore last slice under single slice mode
1360+ do {
1361+ if (SM_SIZELIMITED_SLICE == p.eSliceMode
1362+ && p.bTestNalSize) { // ignore the case that 2 MBs in one picture, and the multithreads case, enable them when code is ready
1363+ ASSERT_GE (((int)param_.uiMaxNalSize), pLayerBsInfo->pNalLengthInByte[iNalIdx]);
1364+ }
1365+ -- iNalIdx;
1366+ } while (iNalIdx >= 0);
1367+ }
1368+ ++ iLayer;
1369+ }
1370+ iIdx++;
1371+ }
1372+ if (pFile) {
1373+ fclose (pFile);
13331374 }
1334− iIdx++;
1335− }
1336− if (pFile) {
1337− fclose (pFile);
13381375 }
13391376 }
13401377

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t