Showing the changes to test/api/encode_decode_api_test.cpp (1 of 1 file). Show all
Unified · Split
| @@ -9,6 +9,34 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <vector> |
| 10 | 10 | using namespace WelsCommon; |
| 11 | 11 | |
| 12 | +#define TRY_TIME_RANGE (10) | |
| 13 | +#define ENCODE_FRAME_NUM (30) | |
| 14 | +#define LEVEL_ID_RANGE (18) | |
| 15 | +#define MAX_WIDTH (4096) | |
| 16 | +#define MAX_HEIGHT (2304) | |
| 17 | +#define MAX_FRAME_RATE (30) | |
| 18 | +#define MIN_FRAME_RATE (1) | |
| 19 | +#define FRAME_RATE_RANGE (2*MAX_FRAME_RATE) | |
| 20 | +#define RC_MODE_RANGE (4) | |
| 21 | +#define BIT_RATE_RANGE (10000) | |
| 22 | +#define MAX_QP (51) | |
| 23 | +#define MIN_QP (0) | |
| 24 | +#define QP_RANGE (2*MAX_QP) | |
| 25 | +#define SPATIAL_LAYER_NUM_RANGE (2*MAX_SPATIAL_LAYER_NUM) | |
| 26 | +#define TEMPORAL_LAYER_NUM_RANGE (2*MAX_TEMPORAL_LAYER_NUM) | |
| 27 | +#define SAVED_NALUNIT_NUM ( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM ) | |
| 28 | +#define MAX_SLICES_NUM ( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM ) / 3 ) | |
| 29 | +#define SLICE_MODE_NUM (6) | |
| 30 | +#define LOOP_FILTER_IDC_NUM (3) | |
| 31 | +#define LOOF_FILTER_OFFSET_RANGE (6) | |
| 32 | +#define MAX_REF_PIC_COUNT (16) | |
| 33 | +#define MIN_REF_PIC_COUNT (1) | |
| 34 | +#define LONG_TERM_REF_NUM (2) | |
| 35 | +#define LONG_TERM_REF_NUM_SCREEN (4) | |
| 36 | +#define MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA (6) | |
| 37 | +#define MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN (8) | |
| 38 | + | |
| 39 | + | |
| 12 | 40 | typedef struct SLost_Sim { |
| 13 | 41 | WelsCommon::EWelsNalUnitType eNalType; |
| 14 | 42 | bool isLost; |
| @@ -122,33 +150,43 @@ class EncodeDecodeTestAPI : public EncodeDecodeTestBase { · 107 unmodified lines | ||
| 122 | 150 | EncodeDecodeTestBase::prepareParam (iLayers, iSlices, width, height, framerate); |
| 123 | 151 | } |
| 124 | 152 | |
| 125 | − void prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam); | |
| 126 | − void EncodeOneFrame() { | |
| 153 | + void InitialEncDec (int iWidth, int iHeight); | |
| 154 | + void RandomParamExtCombination(); | |
| 155 | + void ValidateParamExtCombination(); | |
| 156 | + void SliceParamValidationForMode2 (int iSpatialIdx); | |
| 157 | + void SliceParamValidationForMode3 (int iSpatialIdx); | |
| 158 | + void SliceParamValidationForMode4(); | |
| 159 | + | |
| 160 | + void EncodeOneFrame (int iCheckTypeIndex) { | |
| 127 | 161 | int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2; |
| 128 | 162 | memset (buf_.data(), iRandValue, (frameSize >> 2)); |
| 129 | 163 | memset (buf_.data() + (frameSize >> 2), rand() % 256, (frameSize - (frameSize >> 2))); |
| 130 | 164 | int rv = encoder_->EncodeFrame (&EncPic, &info); |
| 131 | − ASSERT_TRUE (rv == cmResultSuccess || rv == cmUnkonwReason); | |
| 165 | + if (0 == iCheckTypeIndex) | |
| 166 | + ASSERT_TRUE (rv == cmResultSuccess); | |
| 167 | + else if (1 == iCheckTypeIndex) | |
| 168 | + ASSERT_TRUE (rv == cmResultSuccess || rv == cmUnkonwReason); | |
| 132 | 169 | } |
| 133 | 170 | }; |
| 134 | 171 | |
| 135 | −void EncodeDecodeTestAPI::prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam) { | |
| 172 | +void EncodeDecodeTestAPI::InitialEncDec (int iWidth, int iHeight) { | |
| 173 | + | |
| 136 | 174 | // for encoder |
| 137 | 175 | // I420: 1(Y) + 1/4(U) + 1/4(V) |
| 138 | − int frameSize = EncDecFileParam.width * EncDecFileParam.height * 3 / 2; | |
| 176 | + int frameSize = iWidth * iHeight * 3 / 2; | |
| 139 | 177 | |
| 140 | 178 | buf_.SetLength (frameSize); |
| 141 | 179 | ASSERT_TRUE (buf_.Length() == (size_t)frameSize); |
| 142 | 180 | |
| 143 | 181 | memset (&EncPic, 0, sizeof (SSourcePicture)); |
| 144 | − EncPic.iPicWidth = EncDecFileParam.width; | |
| 145 | − EncPic.iPicHeight = EncDecFileParam.height; | |
| 182 | + EncPic.iPicWidth = iWidth; | |
| 183 | + EncPic.iPicHeight = iHeight; | |
| 146 | 184 | EncPic.iColorFormat = videoFormatI420; |
| 147 | − EncPic.iStride[0] = EncPic.iPicWidth; | |
| 148 | − EncPic.iStride[1] = EncPic.iStride[2] = EncPic.iPicWidth >> 1; | |
| 149 | − EncPic.pData[0] = buf_.data(); | |
| 150 | − EncPic.pData[1] = EncPic.pData[0] + EncDecFileParam.width * EncDecFileParam.height; | |
| 151 | − EncPic.pData[2] = EncPic.pData[1] + (EncDecFileParam.width * EncDecFileParam.height >> 2); | |
| 185 | + EncPic.iStride[0] = EncPic.iPicWidth; | |
| 186 | + EncPic.iStride[1] = EncPic.iStride[2] = EncPic.iPicWidth >> 1; | |
| 187 | + EncPic.pData[0] = buf_.data(); | |
| 188 | + EncPic.pData[1] = EncPic.pData[0] + iWidth * iHeight; | |
| 189 | + EncPic.pData[2] = EncPic.pData[1] + (iWidth * iHeight >> 2); | |
| 152 | 190 | |
| 153 | 191 | //for decoder |
| 154 | 192 | memset (&info, 0, sizeof (SFrameBSInfo)); |
| @@ -157,6 +195,245 @@ void EncodeDecodeTestAPI::prepareEncDecParam (const EncodeDecodeFileParamBase En · 2 unmodified lines | ||
| 157 | 195 | iRandValue = rand() % 256; |
| 158 | 196 | } |
| 159 | 197 | |
| 198 | +void EncodeDecodeTestAPI::RandomParamExtCombination() { | |
| 199 | + | |
| 200 | + param_.iPicWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH); | |
| 201 | + param_.iPicHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT); | |
| 202 | + | |
| 203 | + param_.fMaxFrameRate = rand() % FRAME_RATE_RANGE + 0.5f; | |
| 204 | + param_.iUsageType = static_cast<EUsageType> (rand() % 2); | |
| 205 | + param_.iTemporalLayerNum = rand() % TEMPORAL_LAYER_NUM_RANGE; | |
| 206 | + param_.iSpatialLayerNum = rand() % SPATIAL_LAYER_NUM_RANGE; | |
| 207 | + | |
| 208 | + param_.uiIntraPeriod = rand() - 1; | |
| 209 | + param_.iNumRefFrame = rand(); | |
| 210 | + param_.iMultipleThreadIdc = rand(); | |
| 211 | + | |
| 212 | + param_.bEnableSpsPpsIdAddition = (rand() % 2 == 0) ? false : true; | |
| 213 | + param_.bPrefixNalAddingCtrl = (rand() % 2 == 0) ? false : true; | |
| 214 | + param_.bEnableSSEI = (rand() % 2 == 0) ? false : true; | |
| 215 | + param_.iPaddingFlag = rand() % 2; | |
| 216 | + | |
| 217 | + //LTR | |
| 218 | + param_.bEnableLongTermReference = (rand() % 2 == 0) ? false : true; | |
| 219 | + param_.bIsLosslessLink = (rand() % 2 == 0) ? false : true; | |
| 220 | + param_.iLTRRefNum = rand(); | |
| 221 | + param_.iLtrMarkPeriod = rand(); | |
| 222 | + | |
| 223 | + //loop filter | |
| 224 | + param_.iLoopFilterDisableIdc = rand(); | |
| 225 | + param_.iLoopFilterAlphaC0Offset = rand(); | |
| 226 | + param_.iLoopFilterBetaOffset = rand(); | |
| 227 | + | |
| 228 | + param_.bEnableDenoise = (rand() % 2 == 0) ? false : true; | |
| 229 | + param_.bEnableBackgroundDetection = (rand() % 2 == 0) ? false : true; | |
| 230 | + param_.bEnableAdaptiveQuant = (rand() % 2 == 0) ? false : true; | |
| 231 | + param_.bEnableFrameCroppingFlag = (rand() % 2 == 0) ? false : true; | |
| 232 | + param_.bEnableSceneChangeDetect = (rand() % 2 == 0) ? false : true; | |
| 233 | + | |
| 234 | +//for rc | |
| 235 | + param_.iRCMode = static_cast<RC_MODES> (rand() % RC_MODE_RANGE - 1); | |
| 236 | + param_.iMaxBitrate = rand() % BIT_RATE_RANGE; | |
| 237 | + param_.iTargetBitrate = rand() % BIT_RATE_RANGE; | |
| 238 | + param_.iMaxQp = rand() % QP_RANGE; | |
| 239 | + param_.iMinQp = rand() % QP_RANGE; | |
| 240 | + param_.uiMaxNalSize = rand(); | |
| 241 | + param_.bEnableFrameSkip = (rand() % 2 == 0) ? false : true; | |
| 242 | + | |
| 243 | + for (int iSpatialIdx = 0; iSpatialIdx < param_.iSpatialLayerNum; iSpatialIdx++) { | |
| 244 | + if (iSpatialIdx < MAX_SPATIAL_LAYER_NUM) { | |
| 245 | + SSpatialLayerConfig* pSpatialLayer = ¶m_.sSpatialLayers[iSpatialIdx]; | |
| 246 | + | |
| 247 | + //to do: profile and level id | |
| 248 | + //pSpatialLayer->uiProfileIdc = 0; | |
| 249 | + //pSpatialLayer->uiLevelIdc = 0; | |
| 250 | + pSpatialLayer->iVideoWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH); | |
| 251 | + pSpatialLayer->iVideoHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT); | |
| 252 | + pSpatialLayer->fFrameRate = rand() % FRAME_RATE_RANGE + 0.5f; | |
| 253 | + pSpatialLayer->iMaxSpatialBitrate = rand() % BIT_RATE_RANGE; | |
| 254 | + pSpatialLayer->iSpatialBitrate = rand() % BIT_RATE_RANGE; | |
| 255 | + | |
| 256 | + | |
| 257 | + pSpatialLayer->sSliceCfg.uiSliceMode = static_cast<SliceModeEnum> (rand() % SLICE_MODE_NUM); | |
| 258 | + pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = rand(); | |
| 259 | + pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = rand(); | |
| 260 | + } | |
| 261 | + } | |
| 262 | +} | |
| 263 | + | |
| 264 | +void EncodeDecodeTestAPI::ValidateParamExtCombination() { | |
| 265 | + | |
| 266 | + bool bDynSliceModeFlag = false; | |
| 267 | + unsigned int uiGOPSize = 0; | |
| 268 | + unsigned int uiSliceNum = 0; | |
| 269 | + int iTotalBitRate = 0; | |
| 270 | + int iMinQP = 0; | |
| 271 | + | |
| 272 | + param_.iPicWidth = WELS_CLIP3 (param_.iPicWidth, 2, MAX_WIDTH); | |
| 273 | + param_.iPicHeight = WELS_CLIP3 (param_.iPicHeight, 2, MAX_HEIGHT); | |
| 274 | + param_.fMaxFrameRate = WELS_CLIP3 (param_.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); | |
| 275 | + param_.iTemporalLayerNum = WELS_CLIP3 (param_.iTemporalLayerNum, 1, MAX_TEMPORAL_LAYER_NUM); | |
| 276 | + | |
| 277 | + if (CAMERA_VIDEO_REAL_TIME == param_.iUsageType) | |
| 278 | + param_.iSpatialLayerNum = WELS_CLIP3 (param_.iSpatialLayerNum, 1, MAX_SPATIAL_LAYER_NUM); | |
| 279 | + else | |
| 280 | + param_.iSpatialLayerNum = 1; | |
| 281 | + | |
| 282 | + //IntraPeriod | |
| 283 | + uiGOPSize = 1 << (param_.iTemporalLayerNum - 1); | |
| 284 | + param_.uiIntraPeriod -= param_.uiIntraPeriod % uiGOPSize; | |
| 285 | + if (param_.uiIntraPeriod < 0) { | |
| 286 | + param_.uiIntraPeriod = 0; | |
| 287 | + } | |
| 288 | + | |
| 289 | +//RefNum | |
| 290 | + int32_t iRefUpperBound = (param_.iUsageType == CAMERA_VIDEO_REAL_TIME) ? | |
| 291 | + MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN; | |
| 292 | + param_.iNumRefFrame = WELS_CLIP3 (param_.iNumRefFrame, MIN_REF_PIC_COUNT, iRefUpperBound); | |
| 293 | + | |
| 294 | + //to do: will add more validate logic for thread number | |
| 295 | + param_.iMultipleThreadIdc = 1; | |
| 296 | + | |
| 297 | + //LTR | |
| 298 | + //iLTRRefNum: not supported to set it arbitrary yet | |
| 299 | + if (true == param_.bEnableLongTermReference) { | |
| 300 | + param_.iLTRRefNum = (SCREEN_CONTENT_REAL_TIME == param_.iUsageType) ? LONG_TERM_REF_NUM_SCREEN : LONG_TERM_REF_NUM; | |
| 301 | + param_.iLtrMarkPeriod = (0 == param_.iLtrMarkPeriod) ? 1 : param_.iLtrMarkPeriod; | |
| 302 | + | |
| 303 | + } else { | |
| 304 | + param_.iLTRRefNum = 0; | |
| 305 | + } | |
| 306 | + | |
| 307 | + //loop filter | |
| 308 | + param_.iLoopFilterDisableIdc = param_.iLoopFilterDisableIdc % LOOP_FILTER_IDC_NUM; | |
| 309 | + param_.iLoopFilterAlphaC0Offset = param_.iLoopFilterAlphaC0Offset % (2 * LOOF_FILTER_OFFSET_RANGE + 1) - | |
| 310 | + LOOF_FILTER_OFFSET_RANGE; | |
| 311 | + param_.iLoopFilterBetaOffset = param_.iLoopFilterBetaOffset % (2 * LOOF_FILTER_OFFSET_RANGE + 1) - | |
| 312 | + LOOF_FILTER_OFFSET_RANGE; | |
| 313 | + | |
| 314 | + for (int iSpatialIdx = 0; iSpatialIdx < param_.iSpatialLayerNum; iSpatialIdx++) { | |
| 315 | + SSpatialLayerConfig* pSpatialLayer = ¶m_.sSpatialLayers[iSpatialIdx]; | |
| 316 | + pSpatialLayer->iVideoWidth = param_.iPicWidth >> (param_.iSpatialLayerNum - 1 - iSpatialIdx); | |
| 317 | + pSpatialLayer->iVideoHeight = param_.iPicHeight >> (param_.iSpatialLayerNum - 1 - iSpatialIdx); | |
| 318 | + pSpatialLayer->fFrameRate = param_.fMaxFrameRate; | |
| 319 | + | |
| 320 | + pSpatialLayer->iMaxSpatialBitrate = WELS_CLIP3 (pSpatialLayer->iMaxSpatialBitrate, 1, BIT_RATE_RANGE); | |
| 321 | + pSpatialLayer->iSpatialBitrate = WELS_CLIP3 (pSpatialLayer->iSpatialBitrate, 1, pSpatialLayer->iMaxSpatialBitrate); | |
| 322 | + iTotalBitRate += pSpatialLayer->iSpatialBitrate; | |
| 323 | + | |
| 324 | + uiSliceNum = pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum; | |
| 325 | + pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = WELS_CLIP3 (uiSliceNum, 1, MAX_SLICES_NUM); | |
| 326 | + pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0; | |
| 327 | + | |
| 328 | + | |
| 329 | + //for SM_FIXEDSLCNUM_SLICE | |
| 330 | + // to do will add this when GOM bug fixed | |
| 331 | + if (SM_FIXEDSLCNUM_SLICE == pSpatialLayer->sSliceCfg.uiSliceMode) { | |
| 332 | + pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | |
| 333 | + } | |
| 334 | + | |
| 335 | + //for slice mode = SM_DYN_SLICE | |
| 336 | + if (SM_DYN_SLICE == pSpatialLayer->sSliceCfg.uiSliceMode) { | |
| 337 | + bDynSliceModeFlag = true; | |
| 338 | + } | |
| 339 | + | |
| 340 | + //for slice mode = SM_RASTER_SLICE | |
| 341 | + if (SM_RASTER_SLICE == pSpatialLayer->sSliceCfg.uiSliceMode) { | |
| 342 | + SliceParamValidationForMode2 (iSpatialIdx); | |
| 343 | + } | |
| 344 | + //for slice mode = SM_ROWMB_SLICE | |
| 345 | + if (SM_ROWMB_SLICE == pSpatialLayer->sSliceCfg.uiSliceMode) { | |
| 346 | + SliceParamValidationForMode3 (iSpatialIdx); | |
| 347 | + } | |
| 348 | + | |
| 349 | + } | |
| 350 | + | |
| 351 | + //for RC | |
| 352 | + if ((RC_QUALITY_MODE == param_.iRCMode) || (RC_BITRATE_MODE == param_.iRCMode)) { | |
| 353 | + param_.bEnableFrameSkip = true; | |
| 354 | + } | |
| 355 | + if (param_.iTargetBitrate < iTotalBitRate) { | |
| 356 | + param_.iTargetBitrate = iTotalBitRate; | |
| 357 | + } | |
| 358 | + if (param_.iMaxBitrate < param_.iTargetBitrate) { | |
| 359 | + param_.iMaxBitrate = param_.iTargetBitrate; | |
| 360 | + } | |
| 361 | + param_.iMaxQp = WELS_CLIP3 (param_.iMaxQp, MIN_QP, MAX_QP); | |
| 362 | + param_.iMinQp = WELS_CLIP3 (param_.iMinQp, MIN_QP, MAX_QP); | |
| 363 | + iMinQP = (param_.iMaxQp < param_.iMinQp) ? param_.iMaxQp : param_.iMinQp; | |
| 364 | + param_.iMaxQp = (param_.iMaxQp > param_.iMinQp) ? param_.iMaxQp : param_.iMinQp; | |
| 365 | + param_.iMinQp = iMinQP; | |
| 366 | + param_.uiMaxNalSize = 0; | |
| 367 | + | |
| 368 | + //for slice mode = SM_DYN_SLICE | |
| 369 | + if (true == bDynSliceModeFlag) { | |
| 370 | + SliceParamValidationForMode4(); | |
| 371 | + } | |
| 372 | + | |
| 373 | +} | |
| 374 | + | |
| 375 | + | |
| 376 | +void EncodeDecodeTestAPI::SliceParamValidationForMode2 (int iSpatialIdx) { | |
| 377 | + | |
| 378 | + unsigned int uiMbWidth = 0; | |
| 379 | + unsigned int uiMbHeight = 0; | |
| 380 | + unsigned int uiMbNumInFrame = 0; | |
| 381 | + unsigned int uiCountMb = 0; | |
| 382 | + unsigned int uiSliceIdx = 0; | |
| 383 | + unsigned int uiActualSliceCount = 0; | |
| 384 | + | |
| 385 | + uiMbWidth = (param_.iPicWidth + 15) >> 4; | |
| 386 | + uiMbHeight = (param_.iPicHeight + 15) >> 4; | |
| 387 | + uiMbNumInFrame = uiMbWidth * uiMbHeight; | |
| 388 | + | |
| 389 | + uiSliceIdx = 0; | |
| 390 | + while (uiSliceIdx < MAX_SLICES_NUM) { | |
| 391 | + param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx] = rand() % uiMbNumInFrame; | |
| 392 | + uiCountMb += param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx]; | |
| 393 | + uiActualSliceCount = uiSliceIdx + 1; | |
| 394 | + | |
| 395 | + if (uiCountMb >= uiMbNumInFrame) { | |
| 396 | + break; | |
| 397 | + } | |
| 398 | + | |
| 399 | + ++ uiSliceIdx; | |
| 400 | + } | |
| 401 | + | |
| 402 | + if (uiCountMb >= uiMbNumInFrame) { | |
| 403 | + param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiActualSliceCount - 1] -= | |
| 404 | + (uiCountMb - uiMbNumInFrame); | |
| 405 | + | |
| 406 | + } else { | |
| 407 | + param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiActualSliceCount - 1 ] += | |
| 408 | + (uiMbNumInFrame - uiCountMb); | |
| 409 | + } | |
| 410 | + param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceNum = uiActualSliceCount; | |
| 411 | + | |
| 412 | +} | |
| 413 | +void EncodeDecodeTestAPI::SliceParamValidationForMode3 (int iSpatialIdx) { | |
| 414 | + | |
| 415 | + unsigned int uiMbWidth = 0; | |
| 416 | + unsigned int uiMbHeight = 0; | |
| 417 | + unsigned int uiMbNumInFrame = 0; | |
| 418 | + | |
| 419 | + uiMbWidth = (param_.iPicWidth + 15) >> 4; | |
| 420 | + uiMbHeight = (param_.iPicHeight + 15) >> 4; | |
| 421 | + | |
| 422 | + //change slice mode to SM_SINGLE_SLICE | |
| 423 | + if (uiMbHeight > MAX_SLICES_NUM) { | |
| 424 | + param_.sSpatialLayers[iSpatialIdx].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | |
| 425 | + } | |
| 426 | + | |
| 427 | +} | |
| 428 | + | |
| 429 | +void EncodeDecodeTestAPI::SliceParamValidationForMode4() { | |
| 430 | + //slice mode of all spatial layer should be set as SM_DYN_SLICE | |
| 431 | + for (int iSpatialIdx = 0; iSpatialIdx < param_.iSpatialLayerNum; iSpatialIdx++) { | |
| 432 | + param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 600; | |
| 433 | + param_.sSpatialLayers[iSpatialIdx].sSliceCfg.uiSliceMode = SM_DYN_SLICE; | |
| 434 | + } | |
| 435 | + param_.uiMaxNalSize = 1500; | |
| 436 | +} | |
| 160 | 437 | |
| 161 | 438 | static const EncodeDecodeFileParamBase kFileParamArray[] = { |
| 162 | 439 | {300, 160, 96, 6.0f, 2, 1, "000000000000001010101010101010101010101001101010100000010101000011"}, |
| @@ -175,12 +452,12 @@ TEST_P (EncodeDecodeTestAPI, DecoderVclNal) { · 12 unmodified lines | ||
| 175 | 452 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 176 | 453 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 177 | 454 | |
| 178 | − prepareEncDecParam (p); | |
| 455 | + InitialEncDec (p.width, p.height); | |
| 179 | 456 | |
| 180 | 457 | int iIdx = 0; |
| 181 | 458 | while (iIdx <= p.numframes) { |
| 182 | 459 | |
| 183 | − EncodeOneFrame(); | |
| 460 | + EncodeOneFrame (0); | |
| 184 | 461 | |
| 185 | 462 | //decoding after each encoding frame |
| 186 | 463 | int vclNal, len = 0; |
| @@ -211,13 +488,13 @@ TEST_P (EncodeDecodeTestAPI, GetOptionFramenum) { · 24 unmodified lines | ||
| 211 | 488 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 212 | 489 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 213 | 490 | |
| 214 | − prepareEncDecParam (p); | |
| 491 | + InitialEncDec (p.width, p.height); | |
| 215 | 492 | |
| 216 | 493 | int32_t iEncFrameNum = -1; |
| 217 | 494 | int32_t iDecFrameNum; |
| 218 | 495 | int iIdx = 0; |
| 219 | 496 | while (iIdx <= p.numframes) { |
| 220 | − EncodeOneFrame(); | |
| 497 | + EncodeOneFrame (0); | |
| 221 | 498 | //decoding after each encoding frame |
| 222 | 499 | int len = 0; |
| 223 | 500 | encToDecData (info, len); |
| @@ -250,7 +527,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionIDR) { · 26 unmodified lines | ||
| 250 | 527 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 251 | 528 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 252 | 529 | |
| 253 | − prepareEncDecParam (p); | |
| 530 | + InitialEncDec (p.width, p.height); | |
| 254 | 531 | |
| 255 | 532 | int32_t iEncCurIdrPicId = 0; |
| 256 | 533 | int32_t iDecCurIdrPicId; |
| @@ -263,7 +540,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionIDR) { · 6 unmodified lines | ||
| 263 | 540 | encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod); |
| 264 | 541 | encoder_->SetOption (ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, &iSpsPpsIdAddition); |
| 265 | 542 | |
| 266 | − EncodeOneFrame(); | |
| 543 | + EncodeOneFrame (0); | |
| 267 | 544 | |
| 268 | 545 | if (info.eFrameType == videoFrameTypeIDR) { |
| 269 | 546 | iEncCurIdrPicId = (iSpsPpsIdAddition == 0) ? 0 : (iEncCurIdrPicId + 1); |
| @@ -485,7 +762,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_ALLIDR) { · 215 unmodified lines | ||
| 485 | 762 | int rv = encoder_->InitializeExt (¶m_); |
| 486 | 763 | ASSERT_TRUE (rv == cmResultSuccess); |
| 487 | 764 | |
| 488 | − prepareEncDecParam (p); | |
| 765 | + InitialEncDec (p.width, p.height); | |
| 489 | 766 | |
| 490 | 767 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 491 | 768 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -502,7 +779,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_ALLIDR) { · 10 unmodified lines | ||
| 502 | 779 | encoder_->SetOption (ENCODER_LTR_MARKING_PERIOD, &iLtrPeriod); |
| 503 | 780 | int iIdx = 0; |
| 504 | 781 | while (iIdx <= p.numframes) { |
| 505 | − EncodeOneFrame(); | |
| 782 | + EncodeOneFrame (0); | |
| 506 | 783 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 507 | 784 | encoder_->ForceIntraFrame (true); |
| 508 | 785 | iIdx++; |
| @@ -578,7 +855,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_Engine) { · 69 unmodified lines | ||
| 578 | 855 | ASSERT_TRUE (rv == cmResultSuccess); |
| 579 | 856 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 580 | 857 | |
| 581 | − prepareEncDecParam (p); | |
| 858 | + InitialEncDec (p.width, p.height); | |
| 582 | 859 | |
| 583 | 860 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 584 | 861 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -597,7 +874,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_Engine) { · 12 unmodified lines | ||
| 597 | 874 | int iLossIdx = 0; |
| 598 | 875 | bool bVCLLoss = false; |
| 599 | 876 | while (iIdx <= p.numframes) { |
| 600 | − EncodeOneFrame(); | |
| 877 | + EncodeOneFrame (1); | |
| 601 | 878 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 602 | 879 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 603 | 880 | } |
| @@ -641,7 +918,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_DISABLE) { · 37 unmodified lines | ||
| 641 | 918 | ASSERT_EQ (0, rv); |
| 642 | 919 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 643 | 920 | |
| 644 | − prepareEncDecParam (p); | |
| 921 | + InitialEncDec (p.width, p.height); | |
| 645 | 922 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 646 | 923 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 647 | 924 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -660,7 +937,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_DISABLE) { · 12 unmodified lines | ||
| 660 | 937 | int iSkipedBytes; |
| 661 | 938 | bool bVCLLoss = false; |
| 662 | 939 | while (iIdx <= p.numframes) { |
| 663 | − EncodeOneFrame(); | |
| 940 | + EncodeOneFrame (1); | |
| 664 | 941 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 665 | 942 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 666 | 943 | } |
| @@ -695,7 +972,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_SLICE_COPY) { · 28 unmodified lines | ||
| 695 | 972 | ASSERT_TRUE (rv == cmResultSuccess); |
| 696 | 973 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 697 | 974 | |
| 698 | − prepareEncDecParam (p); | |
| 975 | + InitialEncDec (p.width, p.height); | |
| 699 | 976 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 700 | 977 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 701 | 978 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -714,7 +991,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_SLICE_COPY) { · 12 unmodified lines | ||
| 714 | 991 | int iSkipedBytes; |
| 715 | 992 | bool bVCLLoss = false; |
| 716 | 993 | while (iIdx <= p.numframes) { |
| 717 | − EncodeOneFrame(); | |
| 994 | + EncodeOneFrame (1); | |
| 718 | 995 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 719 | 996 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 720 | 997 | } |
| @@ -750,7 +1027,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_NOPREFIX) { · 29 unmodified lines | ||
| 750 | 1027 | int rv = encoder_->InitializeExt (¶m_); |
| 751 | 1028 | ASSERT_TRUE (rv == cmResultSuccess); |
| 752 | 1029 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 753 | − prepareEncDecParam (p); | |
| 1030 | + InitialEncDec (p.width, p.height); | |
| 754 | 1031 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 755 | 1032 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 756 | 1033 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -768,7 +1045,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_NOPREFIX) { · 11 unmodified lines | ||
| 768 | 1045 | int iLossIdx = 0; |
| 769 | 1046 | bool bVCLLoss = false; |
| 770 | 1047 | while (iIdx <= p.numframes) { |
| 771 | − EncodeOneFrame(); | |
| 1048 | + EncodeOneFrame (1); | |
| 772 | 1049 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 773 | 1050 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 774 | 1051 | } |
| @@ -821,7 +1098,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_WITH_PREFIX_NOLOSS) { · 46 unmodified lines | ||
| 821 | 1098 | ASSERT_TRUE (rv == cmResultSuccess); |
| 822 | 1099 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 823 | 1100 | |
| 824 | − prepareEncDecParam (p); | |
| 1101 | + InitialEncDec (p.width, p.height); | |
| 825 | 1102 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 826 | 1103 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 827 | 1104 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -837,7 +1114,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_WITH_PREFIX_NOLOSS) { · 9 unmodified lines | ||
| 837 | 1114 | encoder_->SetOption (ENCODER_LTR_MARKING_PERIOD, &iLtrPeriod); |
| 838 | 1115 | int iIdx = 0; |
| 839 | 1116 | while (iIdx <= p.numframes) { |
| 840 | − EncodeOneFrame(); | |
| 1117 | + EncodeOneFrame (1); | |
| 841 | 1118 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 842 | 1119 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 843 | 1120 | } |
| @@ -875,7 +1152,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_SVC_L1_NOLOSS) { · 31 unmodified lines | ||
| 875 | 1152 | ASSERT_TRUE (rv == cmResultSuccess); |
| 876 | 1153 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 877 | 1154 | |
| 878 | − prepareEncDecParam (p); | |
| 1155 | + InitialEncDec (p.width, p.height); | |
| 879 | 1156 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 880 | 1157 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 881 | 1158 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -891,7 +1168,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_SVC_L1_NOLOSS) { · 9 unmodified lines | ||
| 891 | 1168 | encoder_->SetOption (ENCODER_LTR_MARKING_PERIOD, &iLtrPeriod); |
| 892 | 1169 | int iIdx = 0; |
| 893 | 1170 | while (iIdx <= p.numframes) { |
| 894 | − EncodeOneFrame(); | |
| 1171 | + EncodeOneFrame (1); | |
| 895 | 1172 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 896 | 1173 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 897 | 1174 | } |
| @@ -930,7 +1207,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace) { · 32 unmodified lines | ||
| 930 | 1207 | ASSERT_TRUE (rv == cmResultSuccess); |
| 931 | 1208 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 932 | 1209 | |
| 933 | − prepareEncDecParam (p); | |
| 1210 | + InitialEncDec (p.width, p.height); | |
| 934 | 1211 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 935 | 1212 | pFunc = TestOutPutTrace; |
| 936 | 1213 | pTraceInfo = &sTrace; |
| @@ -960,7 +1237,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace) { · 23 unmodified lines | ||
| 960 | 1237 | sTrace.iTarLevel = iTraceLevel; |
| 961 | 1238 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 962 | 1239 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 963 | − EncodeOneFrame(); | |
| 1240 | + EncodeOneFrame (1); | |
| 964 | 1241 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 965 | 1242 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 966 | 1243 | } |
| @@ -992,7 +1269,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace_NULL) { · 25 unmodified lines | ||
| 992 | 1269 | ASSERT_TRUE (rv == cmResultSuccess); |
| 993 | 1270 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 994 | 1271 | |
| 995 | − prepareEncDecParam (p); | |
| 1272 | + InitialEncDec (p.width, p.height); | |
| 996 | 1273 | |
| 997 | 1274 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 998 | 1275 | pFunc = NULL; |
| @@ -1021,7 +1298,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace_NULL) { · 22 unmodified lines | ||
| 1021 | 1298 | iTraceLevel = rand() % 33; |
| 1022 | 1299 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 1023 | 1300 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 1024 | − EncodeOneFrame(); | |
| 1301 | + EncodeOneFrame (1); | |
| 1025 | 1302 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 1026 | 1303 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 1027 | 1304 | } |
| @@ -1064,7 +1341,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECIDC_GeneralSliceChange) { · 36 unmodified lines | ||
| 1064 | 1341 | |
| 1065 | 1342 | //Start for enc/dec |
| 1066 | 1343 | |
| 1067 | − prepareEncDecParam (p); | |
| 1344 | + InitialEncDec (p.width, p.height); | |
| 1068 | 1345 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 1069 | 1346 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 1070 | 1347 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -1076,7 +1353,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECIDC_GeneralSliceChange) { · 5 unmodified lines | ||
| 1076 | 1353 | |
| 1077 | 1354 | //enc/dec pictures |
| 1078 | 1355 | while (iIdx <= p.numframes) { |
| 1079 | − EncodeOneFrame(); | |
| 1356 | + EncodeOneFrame (1); | |
| 1080 | 1357 | //decoding after each encoding frame |
| 1081 | 1358 | len = 0; |
| 1082 | 1359 | iPacketNum = 0; |
| @@ -1151,9 +1428,9 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 68 unmodified lines | ||
| 1151 | 1428 | int len = 0; |
| 1152 | 1429 | unsigned char* pData[3] = { NULL }; |
| 1153 | 1430 | |
| 1154 | − prepareEncDecParam (p); | |
| 1431 | + InitialEncDec (p.width, p.height); | |
| 1155 | 1432 | //Frame 0: IDR, EC_IDC=DISABLE, loss = 0 |
| 1156 | − EncodeOneFrame(); | |
| 1433 | + EncodeOneFrame (1); | |
| 1157 | 1434 | encToDecData (info, len); |
| 1158 | 1435 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1159 | 1436 | EXPECT_EQ (uiGet, (ERROR_CON_IDC) ERROR_CON_DISABLE); |
| @@ -1168,11 +1445,11 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 8 unmodified lines | ||
| 1168 | 1445 | iIdx++; |
| 1169 | 1446 | |
| 1170 | 1447 | //Frame 1: P, EC_IDC=DISABLE, loss = 1 |
| 1171 | − EncodeOneFrame(); | |
| 1448 | + EncodeOneFrame (1); | |
| 1172 | 1449 | iIdx++; |
| 1173 | 1450 | |
| 1174 | 1451 | //Frame 2: P, EC_IDC=DISABLE, loss = 0 |
| 1175 | − EncodeOneFrame(); | |
| 1452 | + EncodeOneFrame (1); | |
| 1176 | 1453 | encToDecData (info, len); |
| 1177 | 1454 | pData[0] = pData[1] = pData[2] = 0; |
| 1178 | 1455 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1192,7 +1469,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 13 unmodified lines | ||
| 1192 | 1469 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1193 | 1470 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1194 | 1471 | //Frame 3: P, EC_IDC=SLICE_COPY, loss = 0 |
| 1195 | − EncodeOneFrame(); | |
| 1472 | + EncodeOneFrame (1); | |
| 1196 | 1473 | encToDecData (info, len); |
| 1197 | 1474 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1198 | 1475 | EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_SLICE_COPY); |
| @@ -1212,7 +1489,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 13 unmodified lines | ||
| 1212 | 1489 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1213 | 1490 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1214 | 1491 | //Frame 4: P, EC_IDC=DISABLE, loss = 0 |
| 1215 | − EncodeOneFrame(); | |
| 1492 | + EncodeOneFrame (1); | |
| 1216 | 1493 | encToDecData (info, len); |
| 1217 | 1494 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1218 | 1495 | EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_DISABLE); |
| @@ -1228,7 +1505,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 9 unmodified lines | ||
| 1228 | 1505 | iIdx++; |
| 1229 | 1506 | |
| 1230 | 1507 | //Frame 5: P, EC_IDC=DISABLE, loss = 1 |
| 1231 | − EncodeOneFrame(); | |
| 1508 | + EncodeOneFrame (1); | |
| 1232 | 1509 | iIdx++; |
| 1233 | 1510 | |
| 1234 | 1511 | //set EC=FRAME_COPY |
| @@ -1237,12 +1514,12 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 2 unmodified lines | ||
| 1237 | 1514 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1238 | 1515 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1239 | 1516 | //Frame 6: P, EC_IDC=FRAME_COPY, loss = 1 |
| 1240 | − EncodeOneFrame(); | |
| 1517 | + EncodeOneFrame (1); | |
| 1241 | 1518 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1242 | 1519 | iIdx++; |
| 1243 | 1520 | |
| 1244 | 1521 | //Frame 7: P, EC_IDC=FRAME_COPY, loss = 0 |
| 1245 | − EncodeOneFrame(); | |
| 1522 | + EncodeOneFrame (1); | |
| 1246 | 1523 | encToDecData (info, len); |
| 1247 | 1524 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1248 | 1525 | EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_FRAME_COPY); |
| @@ -1285,10 +1562,10 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 36 unmodified lines | ||
| 1285 | 1562 | unsigned char* pData[3] = { NULL }; |
| 1286 | 1563 | int iTotalSliceSize = 0; |
| 1287 | 1564 | |
| 1288 | − prepareEncDecParam (p); | |
| 1565 | + InitialEncDec (p.width, p.height); | |
| 1289 | 1566 | |
| 1290 | 1567 | //Frame 0: IDR, EC_IDC=2, loss = 2 |
| 1291 | − EncodeOneFrame(); | |
| 1568 | + EncodeOneFrame (1); | |
| 1292 | 1569 | iTotalSliceSize = 0; |
| 1293 | 1570 | encToDecSliceData (0, 0, info, len); //SPS |
| 1294 | 1571 | iTotalSliceSize = len; |
| @@ -1310,7 +1587,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 15 unmodified lines | ||
| 1310 | 1587 | |
| 1311 | 1588 | //Frame 1: P, EC_IDC=2, loss = 0 |
| 1312 | 1589 | //will clean SPS/PPS status |
| 1313 | − EncodeOneFrame(); | |
| 1590 | + EncodeOneFrame (1); | |
| 1314 | 1591 | encToDecData (info, len); //all slice together |
| 1315 | 1592 | pData[0] = pData[1] = pData[2] = 0; |
| 1316 | 1593 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1331,7 +1608,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 14 unmodified lines | ||
| 1331 | 1608 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1332 | 1609 | //Frame 2: P, EC_IDC=0, loss = 0 |
| 1333 | 1610 | /////will clean SPS/PPS status |
| 1334 | − EncodeOneFrame(); | |
| 1611 | + EncodeOneFrame (1); | |
| 1335 | 1612 | encToDecData (info, len); //all slice together |
| 1336 | 1613 | pData[0] = pData[1] = pData[2] = 0; |
| 1337 | 1614 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1351,7 +1628,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 13 unmodified lines | ||
| 1351 | 1628 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1352 | 1629 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1353 | 1630 | //Frame 3: P, EC_IDC=2, loss = 1 |
| 1354 | − EncodeOneFrame(); | |
| 1631 | + EncodeOneFrame (1); | |
| 1355 | 1632 | encToDecSliceData (0, 0, info, iTotalSliceSize); //slice 1 lost |
| 1356 | 1633 | encToDecSliceData (0, 1, info, len); //slice 2 |
| 1357 | 1634 | pData[0] = pData[1] = pData[2] = 0; |
| @@ -1372,7 +1649,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 14 unmodified lines | ||
| 1372 | 1649 | decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); |
| 1373 | 1650 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1374 | 1651 | //Frame 4: P, EC_IDC=0, loss = 0 |
| 1375 | − EncodeOneFrame(); | |
| 1652 | + EncodeOneFrame (1); | |
| 1376 | 1653 | encToDecData (info, len); //all slice |
| 1377 | 1654 | pData[0] = pData[1] = pData[2] = 0; |
| 1378 | 1655 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1417,7 +1694,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 38 unmodified lines | ||
| 1417 | 1694 | unsigned char* pData[3] = { NULL }; |
| 1418 | 1695 | int iTotalSliceSize = 0; |
| 1419 | 1696 | |
| 1420 | − prepareEncDecParam (p); | |
| 1697 | + InitialEncDec (p.width, p.height); | |
| 1421 | 1698 | |
| 1422 | 1699 | //set EC=DISABLE |
| 1423 | 1700 | uiEcIdc = (uint32_t) (ERROR_CON_DISABLE); |
| @@ -1426,7 +1703,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 2 unmodified lines | ||
| 1426 | 1703 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1427 | 1704 | //Frame 0: IDR, EC_IDC=0, loss = 0 |
| 1428 | 1705 | //Expected result: all OK, 2nd Output |
| 1429 | − EncodeOneFrame(); | |
| 1706 | + EncodeOneFrame (1); | |
| 1430 | 1707 | encToDecData (info, len); //all slice |
| 1431 | 1708 | pData[0] = pData[1] = pData[2] = 0; |
| 1432 | 1709 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1441,7 +1718,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 8 unmodified lines | ||
| 1441 | 1718 | |
| 1442 | 1719 | //Frame 1: P, EC_IDC=0, loss = 0 |
| 1443 | 1720 | //Expected result: all OK, 2nd Output |
| 1444 | − EncodeOneFrame(); | |
| 1721 | + EncodeOneFrame (1); | |
| 1445 | 1722 | encToDecData (info, len); //all slice together |
| 1446 | 1723 | pData[0] = pData[1] = pData[2] = 0; |
| 1447 | 1724 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1457,7 +1734,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 9 unmodified lines | ||
| 1457 | 1734 | |
| 1458 | 1735 | //Frame 2: P, EC_IDC=0, loss = 1 |
| 1459 | 1736 | //Expected result: all OK, no Output |
| 1460 | − EncodeOneFrame(); | |
| 1737 | + EncodeOneFrame (1); | |
| 1461 | 1738 | encToDecSliceData (0, 0, info, iTotalSliceSize); // slice 1 lost |
| 1462 | 1739 | encToDecSliceData (0, 1, info, len); // slice 2 only |
| 1463 | 1740 | pData[0] = pData[1] = pData[2] = 0; |
| @@ -1479,7 +1756,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 15 unmodified lines | ||
| 1479 | 1756 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1480 | 1757 | //Frame 3: P, EC_IDC=2, loss = 2 |
| 1481 | 1758 | //Expected result: neither OK, 1st Output |
| 1482 | − EncodeOneFrame(); | |
| 1759 | + EncodeOneFrame (1); | |
| 1483 | 1760 | encToDecSliceData (0, 0, info, len); //slice 1 only |
| 1484 | 1761 | pData[0] = pData[1] = pData[2] = 0; |
| 1485 | 1762 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1500,7 +1777,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 14 unmodified lines | ||
| 1500 | 1777 | EXPECT_EQ (uiGet, uiEcIdc); |
| 1501 | 1778 | //Frame 4: P, EC_IDC=0, loss = 0 |
| 1502 | 1779 | //Expected result: depends on DecodeFrame2 result. If OK, output; else ,no output |
| 1503 | − EncodeOneFrame(); | |
| 1780 | + EncodeOneFrame (1); | |
| 1504 | 1781 | encToDecData (info, len); //all slice |
| 1505 | 1782 | pData[0] = pData[1] = pData[2] = 0; |
| 1506 | 1783 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); |
| @@ -1519,7 +1796,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 12 unmodified lines | ||
| 1519 | 1796 | //Expected result: depends on DecodeFrame2 result. If OK, output; else ,no output |
| 1520 | 1797 | int32_t iIDRPeriod = 1; |
| 1521 | 1798 | encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &iIDRPeriod); |
| 1522 | − EncodeOneFrame(); | |
| 1799 | + EncodeOneFrame (1); | |
| 1523 | 1800 | EXPECT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 1524 | 1801 | encToDecSliceData (0, 0, info, len); //SPS |
| 1525 | 1802 | iTotalSliceSize = len; |
| @@ -1577,7 +1854,7 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_I) { · 51 unmodified lines | ||
| 1577 | 1854 | ASSERT_TRUE (rv == cmResultSuccess); |
| 1578 | 1855 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 1579 | 1856 | |
| 1580 | − prepareEncDecParam (p); | |
| 1857 | + InitialEncDec (p.width, p.height); | |
| 1581 | 1858 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 1582 | 1859 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 1583 | 1860 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -1594,7 +1871,7 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_I) { · 10 unmodified lines | ||
| 1594 | 1871 | int iIdx = 0; |
| 1595 | 1872 | int iTarDid = 0; |
| 1596 | 1873 | while (iIdx <= p.numframes) { |
| 1597 | − EncodeOneFrame(); | |
| 1874 | + EncodeOneFrame (1); | |
| 1598 | 1875 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 1599 | 1876 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 1600 | 1877 | } |
| @@ -1642,7 +1919,7 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_P) { · 41 unmodified lines | ||
| 1642 | 1919 | ASSERT_TRUE (rv == cmResultSuccess); |
| 1643 | 1920 | m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET; |
| 1644 | 1921 | |
| 1645 | − prepareEncDecParam (p); | |
| 1922 | + InitialEncDec (p.width, p.height); | |
| 1646 | 1923 | int32_t iTraceLevel = WELS_LOG_QUIET; |
| 1647 | 1924 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 1648 | 1925 | decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| @@ -1659,7 +1936,7 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_P) { · 10 unmodified lines | ||
| 1659 | 1936 | int iIdx = 0; |
| 1660 | 1937 | |
| 1661 | 1938 | while (iIdx <= p.numframes) { |
| 1662 | − EncodeOneFrame(); | |
| 1939 | + EncodeOneFrame (1); | |
| 1663 | 1940 | if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) { |
| 1664 | 1941 | ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR); |
| 1665 | 1942 | } |
| @@ -1711,3 +1988,49 @@ TEST_F (EncodeDecodeTestAPI, Engine_SVC_Switch_P) { · 45 unmodified lines | ||
| 1711 | 1988 | iLastDid = iTarDid; |
| 1712 | 1989 | } |
| 1713 | 1990 | } |
| 1991 | + | |
| 1992 | + | |
| 1993 | +TEST_F (EncodeDecodeTestAPI, SetOptionEncParamExt) { | |
| 1994 | + int iWidth = WELS_CLIP3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH); | |
| 1995 | + int iHeight = WELS_CLIP3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 2, MAX_HEIGHT); | |
| 1996 | + float fFrameRate = rand() + 0.5f; | |
| 1997 | + int iEncFrameNum = WELS_CLIP3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM); | |
| 1998 | + int iSpatialLayerNum = 4; | |
| 1999 | + int iSliceNum = 1; | |
| 2000 | + encoder_->GetDefaultParams (¶m_); | |
| 2001 | + prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate); | |
| 2002 | + int rv = encoder_->InitializeExt (¶m_); | |
| 2003 | + ASSERT_TRUE (rv == cmResultSuccess); | |
| 2004 | + | |
| 2005 | + for (int i = 0; i < iEncFrameNum; i++) { | |
| 2006 | + //for (int i = 0; i < 9; i++) { | |
| 2007 | + int iResult; | |
| 2008 | + int len = 0; | |
| 2009 | + unsigned char* pData[3] = { NULL }; | |
| 2010 | + int iTotalSliceSize = 0; | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + RandomParamExtCombination(); | |
| 2014 | + iResult = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, ¶m_); | |
| 2015 | + //ValidateParamExtCombination(); | |
| 2016 | + //ASSERT_TRUE (iResult == cmResultSuccess); | |
| 2017 | + //to do | |
| 2018 | + // currently, there are still some error cases even though under condition cmResultSuccess == iResult | |
| 2019 | + // so need to enhance the validation check for any random value of each variable in ParamExt | |
| 2020 | + | |
| 2021 | + if (cmResultSuccess == iResult) { | |
| 2022 | + InitialEncDec (param_.iPicWidth, param_.iPicHeight); | |
| 2023 | + EncodeOneFrame (0); | |
| 2024 | + encToDecData (info, len); | |
| 2025 | + pData[0] = pData[1] = pData[2] = 0; | |
| 2026 | + memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); | |
| 2027 | + | |
| 2028 | + iResult = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, iTotalSliceSize, pData, &dstBufInfo_); | |
| 2029 | + ASSERT_TRUE (iResult == cmResultSuccess); | |
| 2030 | + iResult = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); | |
| 2031 | + ASSERT_TRUE (iResult == cmResultSuccess); | |
| 2032 | + EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); | |
| 2033 | + } | |
| 2034 | + } | |
| 2035 | + | |
| 2036 | +} | |