History

add a UT for large picture

dong zhang committed 11 years ago

Commit 7d6d86b1 parent 4e9e5f51 file · +61 −23Browse files

Showing the changes to test/api/encode_decode_api_test.cpp (1 of 1 file). Show all

Unified · Split

test/api/encode_decode_api_test.cpp+61−23
@@ -3254,31 +3254,49 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVC) { · 3253 unmodified lines
3254}3254}
3255 3255
3256struct EncodeOptionParam {3256struct EncodeOptionParam {
3257 int iCaseId;3257 bool bTestNalSize;
3258 bool bAllRandom;
3259 bool bTestDecoder;
3258 int iNumframes;3260 int iNumframes;
3259 int iWidth;3261 int iWidth;
3260 int iHeight;3262 int iHeight;
3261 int iQp;3263 int iQp;
3264 SliceModeEnum eSliceMode;
3262 int uiMaxNalLen;3265 int uiMaxNalLen;
3263 float fFramerate;3266 float fFramerate;
3264 int iThreads;3267 int iThreads;
3268 std::string sFileSave;
3265};3269};
3266 3270
3267static const EncodeOptionParam kOptionParamArray[] = {3271static const EncodeOptionParam kOptionParamArray[] = {
3268 {0, 30, 600, 460, 1, 450, 15.0, 1},3272 {true, true, false, 30, 600, 460, 1, SM_DYN_SLICE, 450, 15.0, 1, ""},
3269 {1, 30, 340, 96, 24, 1000, 30.0, 1},3273 {true, true, false, 30, 340, 96, 24, SM_DYN_SLICE, 1000, 30.0, 1, ""},
3270 {2, 30, 140, 196, 51, 500, 7.5, 1},3274 {true, true, false, 30, 140, 196, 51, SM_DYN_SLICE, 500, 7.5, 1, ""},
3271 {3, 30, 110, 296, 50, 500, 7.5, 1},3275 {true, true, false, 30, 110, 296, 50, SM_DYN_SLICE, 500, 7.5, 1, ""},
3272 {4, 30, 104, 416, 44, 500, 7.5, 1},3276 {true, true, false, 30, 104, 416, 44, SM_DYN_SLICE, 500, 7.5, 1, ""},
3273 {5, 30, 16, 16, 2, 500, 7.5, 1},3277 {true, true, false, 30, 16, 16, 2, SM_DYN_SLICE, 500, 7.5, 1, ""},
3274 {6, 30, 32, 16, 2, 500, 7.5, 1},3278 {true, false, true, 30, 600, 460, 1, SM_DYN_SLICE, 450, 15.0, 1, ""},
3275 {7, 30, 600, 460, 1, 450, 15.0, 4},3279 {true, false, true, 30, 340, 96, 24, SM_DYN_SLICE, 1000, 30.0, 1, ""},
3276 {8, 30, 340, 96, 24, 1000, 30.0, 2},3280 {true, false, true, 30, 140, 196, 51, SM_DYN_SLICE, 500, 7.5, 1, ""},
3277 {9, 30, 140, 196, 51, 500, 7.5, 3},3281 {true, false, true, 30, 110, 296, 50, SM_DYN_SLICE, 500, 7.5, 1, ""},
3278 {10, 30, 110, 296, 50, 500, 7.5, 2},3282 {true, false, true, 30, 104, 416, 44, SM_DYN_SLICE, 500, 7.5, 1, ""},
3279 {11, 30, 104, 416, 44, 500, 7.5, 2},3283 {true, false, true, 30, 16, 16, 2, SM_DYN_SLICE, 500, 7.5, 1, ""},
3280 {12, 30, 16, 16, 2, 500, 7.5, 3},3284 // enable the following when all random input is supported
3281 {13, 30, 32, 16, 2, 500, 7.5, 3},3285 //{true, true, true, 30, 600, 460, 1, SM_DYN_SLICE, 450, 15.0, 1, ""},
3286 //{true, true, true, 30, 340, 96, 24, SM_DYN_SLICE, 1000, 30.0, 1, ""},
3287 //{true, true, true, 30, 140, 196, 51, SM_DYN_SLICE, 500, 7.5, 1, ""},
3288 //{true, true, true, 30, 110, 296, 50, SM_DYN_SLICE, 500, 7.5, 1, ""},
3289 //{true, true, true, 30, 104, 416, 44, SM_DYN_SLICE, 500, 7.5, 1, ""},
3290 //{true, true, true, 30, 16, 16, 2, SM_DYN_SLICE, 500, 7.5, 1, ""},
3291 {false, false, true, 3, 4096, 2304, 2, SM_SINGLE_SLICE, 0, 7.5, 1, ""}, // large picture size
3292 {false, true, false, 30, 32, 16, 2, SM_DYN_SLICE, 500, 7.5, 1, ""},
3293 {false, true, false, 30, 600, 460, 1, SM_DYN_SLICE, 450, 15.0, 4, ""},
3294 {false, true, false, 30, 340, 96, 24, SM_DYN_SLICE, 1000, 30.0, 2, ""},
3295 {false, true, false, 30, 140, 196, 51, SM_DYN_SLICE, 500, 7.5, 3, ""},
3296 {false, true, false, 30, 110, 296, 50, SM_DYN_SLICE, 500, 7.5, 2, ""},
3297 {false, true, false, 30, 104, 416, 44, SM_DYN_SLICE, 500, 7.5, 2, ""},
3298 {false, true, false, 30, 16, 16, 2, SM_DYN_SLICE, 500, 7.5, 3, ""},
3299 {false, true, false, 30, 32, 16, 2, SM_DYN_SLICE, 500, 7.5, 3, ""},
3282};3300};
3283 3301
3284class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public ::EncodeDecodeTestAPIBase {3302class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public ::EncodeDecodeTestAPIBase {
@@ -3290,11 +3308,12 @@ class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public · 5 unmodified lines
3290 void TearDown() {3308 void TearDown() {
3291 EncodeDecodeTestAPIBase::TearDown();3309 EncodeDecodeTestAPIBase::TearDown();
3292 }3310 }
3293 void EncodeOneFrameAllRandom (int iCheckTypeIndex) {3311 void EncodeOneFrameRandom (int iCheckTypeIndex, bool bAllRandom) {
3294 int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;3312 int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;
3295 uint8_t* ptr = buf_.data();3313 uint8_t* ptr = buf_.data();
3314 uint8_t uiVal = rand() % 256;
3296 for (int i = 0; i < frameSize; i++) {3315 for (int i = 0; i < frameSize; i++) {
3297 ptr[i] = rand() % 256;3316 ptr[i] = bAllRandom? (rand() % 256) :uiVal;
3298 }3317 }
3299 int rv = encoder_->EncodeFrame (&EncPic, &info);3318 int rv = encoder_->EncodeFrame (&EncPic, &info);
3300 if (0 == iCheckTypeIndex)3319 if (0 == iCheckTypeIndex)
@@ -3307,8 +3326,13 @@ class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public · 6 unmodified lines
3307INSTANTIATE_TEST_CASE_P (EncodeDecodeTestAPIBase, EncodeTestAPI,3326INSTANTIATE_TEST_CASE_P (EncodeDecodeTestAPIBase, EncodeTestAPI,
3308 ::testing::ValuesIn (kOptionParamArray));3327 ::testing::ValuesIn (kOptionParamArray));
3309 3328
3310TEST_P (EncodeTestAPI, SetEncOptionNalSize) {3329TEST_P (EncodeTestAPI, SetEncOptionSize) {
3330 srand(1002);
3311 EncodeOptionParam p = GetParam();3331 EncodeOptionParam p = GetParam();
3332 FILE * pFile = NULL;
3333 if(!p.sFileSave.empty()) {
3334 pFile = fopen(p.sFileSave.c_str(), "wb");
3335 }
3312 memset (&param_, 0, sizeof (SEncParamExt));3336 memset (&param_, 0, sizeof (SEncParamExt));
3313 encoder_->GetDefaultParams (&param_);3337 encoder_->GetDefaultParams (&param_);
3314 param_.uiMaxNalSize = p.uiMaxNalLen;3338 param_.uiMaxNalSize = p.uiMaxNalLen;
@@ -3324,7 +3348,7 @@ TEST_P (EncodeTestAPI, SetEncOptionNalSize) { · 9 unmodified lines
3324 param_.sSpatialLayers[0].iVideoWidth = p.iWidth ;3348 param_.sSpatialLayers[0].iVideoWidth = p.iWidth ;
3325 param_.sSpatialLayers[0].iVideoHeight = p.iHeight;3349 param_.sSpatialLayers[0].iVideoHeight = p.iHeight;
3326 param_.sSpatialLayers[0].fFrameRate = p.fFramerate;3350 param_.sSpatialLayers[0].fFrameRate = p.fFramerate;
3327 param_.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_DYN_SLICE;3351 param_.sSpatialLayers[0].sSliceCfg.uiSliceMode = p.eSliceMode;
3328 3352
3329 encoder_->Uninitialize();3353 encoder_->Uninitialize();
3330 int rv = encoder_->InitializeExt (&param_);3354 int rv = encoder_->InitializeExt (&param_);
@@ -3339,16 +3363,28 @@ TEST_P (EncodeTestAPI, SetEncOptionNalSize) { · 8 unmodified lines
3339 int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);3363 int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
3340 encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);3364 encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
3341 int iIdx = 0;3365 int iIdx = 0;
3366 int iLen;
3367 unsigned char* pData[3] = { NULL };
3342 while (iIdx <= p.iNumframes) {3368 while (iIdx <= p.iNumframes) {
3343 EncodeOneFrameAllRandom (1);3369 EncodeOneFrameRandom (0, p.bAllRandom);
3370 encToDecData(info, iLen);
3371 if( pFile ) {
3372 fwrite (info.sLayerInfo[0].pBsBuf, iLen, 1, pFile);
3373 fflush (pFile);
3374 }
3375 memset(&dstBufInfo_, 0, sizeof(SBufferInfo));
3376 if(iLen && p.bTestDecoder) {
3377 rv = decoder_->DecodeFrameNoDelay(info.sLayerInfo[0].pBsBuf, iLen, pData, &dstBufInfo_);
3378 ASSERT_EQ(rv, 0);
3379 ASSERT_EQ(dstBufInfo_.iBufferStatus, 1);
3380 }
3344 int iLayer = 0;3381 int iLayer = 0;
3345 while (iLayer < info.iLayerNum) {3382 while (iLayer < info.iLayerNum) {
3346 SLayerBSInfo* pLayerBsInfo = &info.sLayerInfo[iLayer];3383 SLayerBSInfo* pLayerBsInfo = &info.sLayerInfo[iLayer];
3347 if (pLayerBsInfo != NULL) {3384 if (pLayerBsInfo != NULL) {
3348 int iNalIdx = WELS_MAX (pLayerBsInfo->iNalCount - 2, 0); // ignore last slice under single slice mode3385 int iNalIdx = WELS_MAX (pLayerBsInfo->iNalCount - 2, 0); // ignore last slice under single slice mode
3349 do {3386 do {
3350 if (p.iCaseId <3387 if (p.bTestNalSize) { // ignore the case that 2 MBs in one picture, and the multithreads case, enable them when code is ready
3351 6) { // ignore the case that 2 MBs in one picture, and the multithreads case, enable them when code is ready
3352 ASSERT_GE (((int)param_.uiMaxNalSize), pLayerBsInfo->pNalLengthInByte[iNalIdx]);3388 ASSERT_GE (((int)param_.uiMaxNalSize), pLayerBsInfo->pNalLengthInByte[iNalIdx]);
3353 }3389 }
3354 -- iNalIdx;3390 -- iNalIdx;
@@ -3358,7 +3394,9 @@ TEST_P (EncodeTestAPI, SetEncOptionNalSize) { · 3 unmodified lines
3358 }3394 }
3359 iIdx++;3395 iIdx++;
3360 }3396 }
3397 if( pFile ) {
3398 fclose (pFile);
3399 }
3361}3400}
3362 3401
3363 3402
3364

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