Showing the changes to codec/encoder/core/src/encoder.cpp (1 of 3 files). Show all
Unified · Split
| @@ -77,8 +77,8 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki · 76 unmodified lines | ||
| 77 | 77 | pSrcPic->iPicHeight = kiHeight; |
| 78 | 78 | |
| 79 | 79 | //currently encoder only supports videoFormatI420. |
| 80 | − if((kiColorspace & (~videoFormatVFlip))!= videoFormatI420) | |
| 81 | − return 2; | |
| 80 | + if ((kiColorspace & (~videoFormatVFlip)) != videoFormatI420) | |
| 81 | + return 2; | |
| 82 | 82 | switch (kiColorspace & (~videoFormatVFlip)) { |
| 83 | 83 | case videoFormatI420: |
| 84 | 84 | case videoFormatYV12: |
| @@ -184,7 +184,7 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* · 99 unmodified lines | ||
| 184 | 184 | WelsInitIntraPredFuncs (pFuncList, uiCpuFlag); |
| 185 | 185 | |
| 186 | 186 | /* ME func */ |
| 187 | − WelsInitMeFunc(pFuncList, uiCpuFlag, SCREEN_CONTENT_REAL_TIME==pParam->iUsageType); | |
| 187 | + WelsInitMeFunc (pFuncList, uiCpuFlag, SCREEN_CONTENT_REAL_TIME == pParam->iUsageType); | |
| 188 | 188 | |
| 189 | 189 | /* sad, satd, average */ |
| 190 | 190 | WelsInitSampleSadFunc (pFuncList, uiCpuFlag); |
| @@ -207,7 +207,7 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* · 16 unmodified lines | ||
| 207 | 207 | WelsBlockFuncInit (&pFuncList->pfSetNZCZero, uiCpuFlag); |
| 208 | 208 | |
| 209 | 209 | InitFillNeighborCacheInterFunc (pFuncList, pParam->bEnableBackgroundDetection); |
| 210 | − InitRefListMgrFunc(pFuncList,pParam->iUsageType); | |
| 210 | + InitRefListMgrFunc (pFuncList, pParam->iUsageType); | |
| 211 | 211 | return iReturn; |
| 212 | 212 | } |
| 213 | 213 | |
| @@ -285,28 +285,63 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum · 71 unmodified lines | ||
| 285 | 285 | EVideoFrameType iFrameType = videoFrameTypeInvalid; |
| 286 | 286 | bool bSceneChangeFlag = false; |
| 287 | 287 | |
| 288 | − // perform scene change detection | |
| 289 | − if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag || | |
| 290 | − (kiSpatialNum < pSvcParam->iSpatialLayerNum) | |
| 291 | − || (pEncCtx->iFrameIndex < (VGOP_SIZE << 1))) { // avoid too frequent I frame coding, rc control | |
| 292 | − bSceneChangeFlag = false; | |
| 288 | + if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { | |
| 289 | + if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag || | |
| 290 | + (kiSpatialNum < pSvcParam->iSpatialLayerNum)) { | |
| 291 | + bSceneChangeFlag = false; | |
| 292 | + } else { | |
| 293 | + bSceneChangeFlag = pEncCtx->pVaa->bSceneChangeFlag; | |
| 294 | + } | |
| 295 | + pEncCtx->bCurFrameMarkedAsSceneLtr = false; | |
| 296 | + if (pEncCtx->pVaa->bIdrPeriodFlag || pEncCtx->bEncCurFrmAsIdrFlag || (!pSvcParam->bEnableLongTermReference | |
| 297 | + && bSceneChangeFlag)) { | |
| 298 | + iFrameType = videoFrameTypeIDR; | |
| 299 | + } else if (pSvcParam->bEnableLongTermReference && (bSceneChangeFlag | |
| 300 | + || pEncCtx->pVaa->eSceneChangeIdc == LARGE_CHANGED_SCENE)) { | |
| 301 | + int iActualLtrcount = 0; | |
| 302 | + SPicture** pLongTermRefList = pEncCtx->ppRefPicListExt[0]->pLongRefList; | |
| 303 | + for (int i = 0; i < pSvcParam->iLTRRefNum; ++i) { | |
| 304 | + if (NULL != pLongTermRefList[i] && pLongTermRefList[i]->bUsedAsRef && pLongTermRefList[i]->bIsLongRef | |
| 305 | + && pLongTermRefList[i]->bIsSceneLTR) { | |
| 306 | + ++iActualLtrcount; | |
| 307 | + } | |
| 308 | + } | |
| 309 | + if (iActualLtrcount == pSvcParam->iLTRRefNum && bSceneChangeFlag) { | |
| 310 | + iFrameType = videoFrameTypeIDR; | |
| 311 | + } else { | |
| 312 | + iFrameType = videoFrameTypeP; | |
| 313 | + pEncCtx->bCurFrameMarkedAsSceneLtr = true; | |
| 314 | + } | |
| 315 | + } else { | |
| 316 | + iFrameType = videoFrameTypeP; | |
| 317 | + } | |
| 318 | + if (videoFrameTypeIDR == iFrameType) { | |
| 319 | + pEncCtx->iCodingIndex = 0; | |
| 320 | + pEncCtx->bCurFrameMarkedAsSceneLtr = true; | |
| 321 | + } | |
| 293 | 322 | } else { |
| 294 | − bSceneChangeFlag = pEncCtx->pVaa->bSceneChangeFlag; | |
| 295 | − } | |
| 323 | + // perform scene change detection | |
| 324 | + if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag || | |
| 325 | + (kiSpatialNum < pSvcParam->iSpatialLayerNum) | |
| 326 | + || (pEncCtx->iFrameIndex < (VGOP_SIZE << 1))) { // avoid too frequent I frame coding, rc control | |
| 327 | + bSceneChangeFlag = false; | |
| 328 | + } else { | |
| 329 | + bSceneChangeFlag = pEncCtx->pVaa->bSceneChangeFlag; | |
| 330 | + } | |
| 296 | 331 | |
| 297 | − //scene_changed_flag: RC enable && iSpatialNum == pSvcParam->iSpatialLayerNum | |
| 298 | − //bIdrPeriodFlag: RC disable || iSpatialNum != pSvcParam->iSpatialLayerNum | |
| 299 | − //pEncCtx->bEncCurFrmAsIdrFlag: 1. first frame should be IDR; 2. idr pause; 3. idr request | |
| 300 | − iFrameType = (pEncCtx->pVaa->bIdrPeriodFlag || bSceneChangeFlag | |
| 301 | − || pEncCtx->bEncCurFrmAsIdrFlag) ? videoFrameTypeIDR : videoFrameTypeP; | |
| 302 | − | |
| 303 | − if (videoFrameTypeP == iFrameType && pEncCtx->iSkipFrameFlag > 0) { // for frame skip, 1/5/2010 | |
| 304 | − -- pEncCtx->iSkipFrameFlag; | |
| 305 | − iFrameType = videoFrameTypeSkip; | |
| 306 | − } else if (videoFrameTypeIDR == iFrameType) { | |
| 307 | − pEncCtx->iCodingIndex = 0; | |
| 332 | + //scene_changed_flag: RC enable && iSpatialNum == pSvcParam->iSpatialLayerNum | |
| 333 | + //bIdrPeriodFlag: RC disable || iSpatialNum != pSvcParam->iSpatialLayerNum | |
| 334 | + //pEncCtx->bEncCurFrmAsIdrFlag: 1. first frame should be IDR; 2. idr pause; 3. idr request | |
| 335 | + iFrameType = (pEncCtx->pVaa->bIdrPeriodFlag || bSceneChangeFlag | |
| 336 | + || pEncCtx->bEncCurFrmAsIdrFlag) ? videoFrameTypeIDR : videoFrameTypeP; | |
| 337 | + | |
| 338 | + if (videoFrameTypeP == iFrameType && pEncCtx->iSkipFrameFlag > 0) { // for frame skip, 1/5/2010 | |
| 339 | + -- pEncCtx->iSkipFrameFlag; | |
| 340 | + iFrameType = videoFrameTypeSkip; | |
| 341 | + } else if (videoFrameTypeIDR == iFrameType) { | |
| 342 | + pEncCtx->iCodingIndex = 0; | |
| 343 | + } | |
| 308 | 344 | } |
| 309 | − | |
| 310 | 345 | return iFrameType; |
| 311 | 346 | } |
| 312 | 347 | |