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
32543254 }
32553255
32563256 struct EncodeOptionParam {
3257− int iCaseId;
3257+ bool bTestNalSize;
3258+ bool bAllRandom;
3259+ bool bTestDecoder;
32583260 int iNumframes;
32593261 int iWidth;
32603262 int iHeight;
32613263 int iQp;
3264+ SliceModeEnum eSliceMode;
32623265 int uiMaxNalLen;
32633266 float fFramerate;
32643267 int iThreads;
3268+ std::string sFileSave;
32653269 };
32663270
32673271 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, ""},
32823300 };
32833301
32843302 class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public ::EncodeDecodeTestAPIBase {
@@ -3290,11 +3308,12 @@ class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public · 5 unmodified lines
32903308 void TearDown() {
32913309 EncodeDecodeTestAPIBase::TearDown();
32923310 }
3293− void EncodeOneFrameAllRandom (int iCheckTypeIndex) {
3311+ void EncodeOneFrameRandom (int iCheckTypeIndex, bool bAllRandom) {
32943312 int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;
32953313 uint8_t* ptr = buf_.data();
3314+ uint8_t uiVal = rand() % 256;
32963315 for (int i = 0; i < frameSize; i++) {
3297− ptr[i] = rand() % 256;
3316+ ptr[i] = bAllRandom? (rand() % 256) :uiVal;
32983317 }
32993318 int rv = encoder_->EncodeFrame (&EncPic, &info);
33003319 if (0 == iCheckTypeIndex)
@@ -3307,8 +3326,13 @@ class EncodeTestAPI : public ::testing::TestWithParam<EncodeOptionParam>, public · 6 unmodified lines
33073326 INSTANTIATE_TEST_CASE_P (EncodeDecodeTestAPIBase, EncodeTestAPI,
33083327 ::testing::ValuesIn (kOptionParamArray));
33093328
3310−TEST_P (EncodeTestAPI, SetEncOptionNalSize) {
3329+TEST_P (EncodeTestAPI, SetEncOptionSize) {
3330+ srand(1002);
33113331 EncodeOptionParam p = GetParam();
3332+ FILE * pFile = NULL;
3333+ if(!p.sFileSave.empty()) {
3334+ pFile = fopen(p.sFileSave.c_str(), "wb");
3335+ }
33123336 memset (&param_, 0, sizeof (SEncParamExt));
33133337 encoder_->GetDefaultParams (&param_);
33143338 param_.uiMaxNalSize = p.uiMaxNalLen;
@@ -3324,7 +3348,7 @@ TEST_P (EncodeTestAPI, SetEncOptionNalSize) { · 9 unmodified lines
33243348 param_.sSpatialLayers[0].iVideoWidth = p.iWidth ;
33253349 param_.sSpatialLayers[0].iVideoHeight = p.iHeight;
33263350 param_.sSpatialLayers[0].fFrameRate = p.fFramerate;
3327− param_.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_DYN_SLICE;
3351+ param_.sSpatialLayers[0].sSliceCfg.uiSliceMode = p.eSliceMode;
33283352
33293353 encoder_->Uninitialize();
33303354 int rv = encoder_->InitializeExt (&param_);
@@ -3339,16 +3363,28 @@ TEST_P (EncodeTestAPI, SetEncOptionNalSize) { · 8 unmodified lines
33393363 int32_t iIDRPeriod = (int32_t) pow (2.0f, (param_.iTemporalLayerNum - 1)) * ((rand() % 5) + 1);
33403364 encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod);
33413365 int iIdx = 0;
3366+ int iLen;
3367+ unsigned char* pData[3] = { NULL };
33423368 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+ }
33443381 int iLayer = 0;
33453382 while (iLayer < info.iLayerNum) {
33463383 SLayerBSInfo* pLayerBsInfo = &info.sLayerInfo[iLayer];
33473384 if (pLayerBsInfo != NULL) {
33483385 int iNalIdx = WELS_MAX (pLayerBsInfo->iNalCount - 2, 0); // ignore last slice under single slice mode
33493386 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
33523388 ASSERT_GE (((int)param_.uiMaxNalSize), pLayerBsInfo->pNalLengthInByte[iNalIdx]);
33533389 }
33543390 -- iNalIdx;
@@ -3358,7 +3394,9 @@ TEST_P (EncodeTestAPI, SetEncOptionNalSize) { · 3 unmodified lines
33583394 }
33593395 iIdx++;
33603396 }
3397+ if( pFile ) {
3398+ fclose (pFile);
3399+ }
33613400 }
33623401
33633402
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