History

add decide frame type for screen content

ruil2 committed 12 years ago

Commit 2eff8081 parent 082248d3 files · +64 −23Browse files

Showing the changes to codec/encoder/core/src/encoder.cpp (1 of 3 files). Show all

Unified · Split

codec/encoder/core/src/encoder.cpp+58−23
@@ -77,8 +77,8 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki · 76 unmodified lines
77 pSrcPic->iPicHeight = kiHeight;77 pSrcPic->iPicHeight = kiHeight;
78 78
79 //currently encoder only supports videoFormatI420.79 //currently encoder only supports videoFormatI420.
80 if((kiColorspace & (~videoFormatVFlip))!= videoFormatI420)80 if ((kiColorspace & (~videoFormatVFlip)) != videoFormatI420)
81 return 2;81 return 2;
82 switch (kiColorspace & (~videoFormatVFlip)) {82 switch (kiColorspace & (~videoFormatVFlip)) {
83 case videoFormatI420:83 case videoFormatI420:
84 case videoFormatYV12:84 case videoFormatYV12:
@@ -184,7 +184,7 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* · 99 unmodified lines
184 WelsInitIntraPredFuncs (pFuncList, uiCpuFlag);184 WelsInitIntraPredFuncs (pFuncList, uiCpuFlag);
185 185
186 /* ME func */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 /* sad, satd, average */189 /* sad, satd, average */
190 WelsInitSampleSadFunc (pFuncList, uiCpuFlag);190 WelsInitSampleSadFunc (pFuncList, uiCpuFlag);
@@ -207,7 +207,7 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* · 16 unmodified lines
207 WelsBlockFuncInit (&pFuncList->pfSetNZCZero, uiCpuFlag);207 WelsBlockFuncInit (&pFuncList->pfSetNZCZero, uiCpuFlag);
208 208
209 InitFillNeighborCacheInterFunc (pFuncList, pParam->bEnableBackgroundDetection);209 InitFillNeighborCacheInterFunc (pFuncList, pParam->bEnableBackgroundDetection);
210 InitRefListMgrFunc(pFuncList,pParam->iUsageType);210 InitRefListMgrFunc (pFuncList, pParam->iUsageType);
211 return iReturn;211 return iReturn;
212}212}
213 213
@@ -285,28 +285,63 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum · 71 unmodified lines
285 EVideoFrameType iFrameType = videoFrameTypeInvalid;285 EVideoFrameType iFrameType = videoFrameTypeInvalid;
286 bool bSceneChangeFlag = false;286 bool bSceneChangeFlag = false;
287 287
288 // perform scene change detection288 if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
289 if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag ||289 if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag ||
290 (kiSpatialNum < pSvcParam->iSpatialLayerNum)290 (kiSpatialNum < pSvcParam->iSpatialLayerNum)) {
291 || (pEncCtx->iFrameIndex < (VGOP_SIZE << 1))) { // avoid too frequent I frame coding, rc control291 bSceneChangeFlag = false;
292 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 } else {322 } else {
294 bSceneChangeFlag = pEncCtx->pVaa->bSceneChangeFlag;323 // perform scene change detection
295 }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->iSpatialLayerNum332 //scene_changed_flag: RC enable && iSpatialNum == pSvcParam->iSpatialLayerNum
298 //bIdrPeriodFlag: RC disable || iSpatialNum != pSvcParam->iSpatialLayerNum333 //bIdrPeriodFlag: RC disable || iSpatialNum != pSvcParam->iSpatialLayerNum
299 //pEncCtx->bEncCurFrmAsIdrFlag: 1. first frame should be IDR; 2. idr pause; 3. idr request334 //pEncCtx->bEncCurFrmAsIdrFlag: 1. first frame should be IDR; 2. idr pause; 3. idr request
300 iFrameType = (pEncCtx->pVaa->bIdrPeriodFlag || bSceneChangeFlag335 iFrameType = (pEncCtx->pVaa->bIdrPeriodFlag || bSceneChangeFlag
301 || pEncCtx->bEncCurFrmAsIdrFlag) ? videoFrameTypeIDR : videoFrameTypeP;336 || pEncCtx->bEncCurFrmAsIdrFlag) ? videoFrameTypeIDR : videoFrameTypeP;
302 337
303 if (videoFrameTypeP == iFrameType && pEncCtx->iSkipFrameFlag > 0) { // for frame skip, 1/5/2010338 if (videoFrameTypeP == iFrameType && pEncCtx->iSkipFrameFlag > 0) { // for frame skip, 1/5/2010
304 -- pEncCtx->iSkipFrameFlag;339 -- pEncCtx->iSkipFrameFlag;
305 iFrameType = videoFrameTypeSkip;340 iFrameType = videoFrameTypeSkip;
306 } else if (videoFrameTypeIDR == iFrameType) {341 } else if (videoFrameTypeIDR == iFrameType) {
307 pEncCtx->iCodingIndex = 0;342 pEncCtx->iCodingIndex = 0;
343 }
308 }344 }
309
310 return iFrameType;345 return iFrameType;
311}346}
312 347

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