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