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
1204 {true, true, false, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1204 {true, true, false, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1205 {true, true, false, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1205 {true, true, false, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1206 {true, true, false, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1206 {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
1208 {true, false, true, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 1, ""},1208 {true, false, true, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 1, ""},
1209 {true, false, true, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 1, ""},1209 {true, false, true, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 1, ""},
1210 {true, false, true, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1210 {true, false, true, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1211 {true, false, true, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1211 {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
1213 {true, false, true, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1213 {true, false, true, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1214 {true, true, true, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 1, ""},1214 {true, true, true, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 1, ""},
1215 {true, true, true, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 1, ""},1215 {true, true, true, 30, 340, 96, 24, SM_SIZELIMITED_SLICE, 1000, 30.0, 1, ""},
1216 {true, true, true, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1216 {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
1218 {true, true, true, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1218 {true, true, true, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1219 {true, true, true, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1219 {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
1221 {false, true, false, 30, 32, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},1220 {false, true, false, 30, 32, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 1, ""},
1222 {false, true, false, 30, 600, 460, 1, SM_SIZELIMITED_SLICE, 450, 15.0, 4, ""},1221 {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
1224 {false, true, false, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 3, ""},1223 {false, true, false, 30, 140, 196, 51, SM_SIZELIMITED_SLICE, 500, 7.5, 3, ""},
1225 {false, true, false, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 2, ""},1224 {false, true, false, 30, 110, 296, 50, SM_SIZELIMITED_SLICE, 500, 7.5, 2, ""},
1226 {false, true, false, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 2, ""},1225 {false, true, false, 30, 104, 416, 44, SM_SIZELIMITED_SLICE, 500, 7.5, 2, ""},
1227 {false, true, false, 30, 16, 16, 2, SM_SIZELIMITED_SLICE, 500, 7.5, 3, ""},1226 {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
1229 {false, false, true, 30, 600, 460, 1, SM_FIXEDSLCNUM_SLICE, 0, 15.0, 4, ""},1228 {false, false, true, 30, 600, 460, 1, SM_FIXEDSLCNUM_SLICE, 0, 15.0, 4, ""},
1230 {false, false, true, 30, 600, 460, 1, SM_FIXEDSLCNUM_SLICE, 0, 15.0, 8, ""},1229 {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, ""},
1231};1243};
1232 1244
1233class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public ::EncodeDecodeTestAPIBase {1245class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public ::EncodeDecodeTestAPIBase {
@@ -1259,10 +1271,6 @@ INSTANTIATE_TEST_CASE_P (EncodeDecodeTestAPIBase, EncodeTestAPI, · 25 unmodified lines
1259 1271
1260TEST_P (EncodeTestAPI, SetEncOptionSize) {1272TEST_P (EncodeTestAPI, SetEncOptionSize) {
1261 EncodeOptionParam p = GetParam();1273 EncodeOptionParam p = GetParam();
1262 FILE* pFile = NULL;
1263 if (p.sFileSave != NULL && strlen (p.sFileSave) > 0) {
1264 pFile = fopen (p.sFileSave, "wb");
1265 }
1266 memset (&param_, 0, sizeof (SEncParamExt));1274 memset (&param_, 0, sizeof (SEncParamExt));
1267 encoder_->GetDefaultParams (&param_);1275 encoder_->GetDefaultParams (&param_);
1268 param_.uiMaxNalSize = p.uiMaxNalLen;1276 param_.uiMaxNalSize = p.uiMaxNalLen;
@@ -1275,66 +1283,95 @@ TEST_P (EncodeTestAPI, SetEncOptionSize) { · 6 unmodified lines
1275 param_.iRCMode = RC_OFF_MODE; //rc off1283 param_.iRCMode = RC_OFF_MODE; //rc off
1276 param_.iMultipleThreadIdc = p.iThreads;1284 param_.iMultipleThreadIdc = p.iThreads;
1277 param_.iNumRefFrame = AUTO_REF_PIC_COUNT;1285 param_.iNumRefFrame = AUTO_REF_PIC_COUNT;
1278 param_.sSpatialLayers[0].iVideoWidth = p.iWidth ;1286 param_.sSpatialLayers[0].iVideoWidth = p.iWidth;
1279 param_.sSpatialLayers[0].iVideoHeight = p.iHeight;1287 param_.sSpatialLayers[0].iVideoHeight = p.iHeight;
1280 param_.sSpatialLayers[0].fFrameRate = p.fFramerate;1288 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 }
1285 1289
1286 encoder_->Uninitialize();1290 int iSliceModeTestNum = 1;
1287 int rv = encoder_->InitializeExt (&param_);1291 if (SM_RESERVED == p.eSliceMode) {
1288 ASSERT_TRUE (rv == cmResultSuccess);1292 iSliceModeTestNum = SLICE_MODE_NUM;
1289 InitialEncDec (p.iWidth, p.iHeight);1293 }
1290 1294
1291 int32_t iTraceLevel = WELS_LOG_QUIET;1295 for (int iSliceIdx = 0; iSliceIdx < iSliceModeTestNum; iSliceIdx++) {
1292 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);1296 if (1 == iSliceModeTestNum) {
1293 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);1297 param_.sSpatialLayers[0].sSliceArgument.uiSliceMode = p.eSliceMode;
1294 int32_t iSpsPpsIdAddition = 1;1298 } else {
1295 encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iSpsPpsIdAddition);1299 param_.sSpatialLayers[0].sSliceArgument.uiSliceMode = static_cast<SliceModeEnum> (iSliceIdx);
1296 int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);1300 }
1297 encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
1298 int iIdx = 0;
1299 int iLen;
1300 unsigned char* pData[3] = { NULL };
1301 1301
1302 //FIXME: remove this after the multi-thread case is correctly handled in encoder1302 FILE* pFile = NULL;
1303 if (p.iThreads > 1 && SM_SIZELIMITED_SLICE == p.eSliceMode) {1303 if (p.sFileSave != NULL && strlen (p.sFileSave) > 0) {
1304 p.bAllRandom = false;1304 pFile = fopen (p.sFileSave, "wb");
1305 }1305 }
1306 1306
1307 while (iIdx <= p.iNumframes) {1307 if (SM_FIXEDSLCNUM_SLICE == param_.sSpatialLayers[0].sSliceArgument.uiSliceMode) {
1308 EncodeOneFrameRandom (0, p.bAllRandom);1308 param_.sSpatialLayers[0].sSliceArgument.uiSliceNum = 8;
1309 encToDecData (info, iLen);1309 } else if (SM_RASTER_SLICE == param_.sSpatialLayers[0].sSliceArgument.uiSliceMode) {
1310 if (pFile) {1310 param_.sSpatialLayers[0].sSliceArgument.uiSliceMbNum[0] =
1311 fwrite (info.sLayerInfo[0].pBsBuf, iLen, 1, pFile);1311 param_.sSpatialLayers[0].sSliceArgument.uiSliceMbNum[1] =
1312 fflush (pFile);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;
1313 }1317 }
1314 memset (&dstBufInfo_, 0, sizeof (SBufferInfo));1318
1315 if (iLen && p.bTestDecoder) {1319 int32_t iTraceLevel = WELS_LOG_QUIET;
1316 rv = decoder_->DecodeFrameNoDelay (info.sLayerInfo[0].pBsBuf, iLen, pData, &dstBufInfo_);1320 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
1317 ASSERT_EQ (rv, 0);1321 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
1318 ASSERT_EQ (dstBufInfo_.iBufferStatus, 1);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;
1319 }1340 }
1320 int iLayer = 0;1341
1321 while (iLayer < info.iLayerNum) {1342 while (iIdx <= p.iNumframes) {
1322 SLayerBSInfo* pLayerBsInfo = &info.sLayerInfo[iLayer];1343 EncodeOneFrameRandom (0, p.bAllRandom);
1323 if (pLayerBsInfo != NULL) {1344 encToDecData (info, iLen);
1324 int iNalIdx = WELS_MAX (pLayerBsInfo->iNalCount - 2, 0); // ignore last slice under single slice mode1345 if (pFile) {
1325 do {1346 fwrite (info.sLayerInfo[0].pBsBuf, iLen, 1, pFile);
1326 if (p.bTestNalSize) { // ignore the case that 2 MBs in one picture, and the multithreads case, enable them when code is ready1347 fflush (pFile);
1327 ASSERT_GE (((int)param_.uiMaxNalSize), pLayerBsInfo->pNalLengthInByte[iNalIdx]);
1328 }
1329 -- iNalIdx;
1330 } while (iNalIdx >= 0);
1331 }1348 }
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);
1333 }1374 }
1334 iIdx++;
1335 }
1336 if (pFile) {
1337 fclose (pFile);
1338 }1375 }
1339}1376}
1340 1377

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