History

fix defect7654 that the encoder won't generate IDR when temporal layer setting changes

ruil2 committed 12 years ago

Commit 0a1b6151 parent 3f333b05 files · +85 −35Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+21−19
@@ -156,6 +156,8 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 155 unmodified lines
156156 }
157157
158158 }
159+ return WelsCheckRefFrameLimitation (pLogCtx, pCfg);
160+
159161 return ENC_RETURN_SUCCESS;
160162 }
161163
@@ -753,7 +755,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 591 unmodified lines
753755 pMa = (*ppCtx)->pMemAlign;
754756 pParam = (*ppCtx)->pSvcParam;
755757 iDlayerCount = pParam->iSpatialLayerNum;
756− iNumRef = pParam->iNumRefFrame;
758+ iNumRef = pParam->iMaxNumRefFrame;
757759
758760 const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX;
759761 const int32_t kiMe16x16 = ME_DIA_CROSS;
@@ -927,7 +929,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 167 unmodified lines
927929
928930 // Need port pSps/pPps initialization due to spatial scalability changed
929931 if (!bUseSubsetSps) {
930− WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, pParam->iNumRefFrame,
932+ WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
933+ pParam->iMaxNumRefFrame,
931934 iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
932935
933936 if (iDlayerCount > 1) {
@@ -937,7 +940,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 3 unmodified lines
937940 }
938941 } else {
939942 WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
940− pParam->iNumRefFrame,
943+ pParam->iMaxNumRefFrame,
941944 iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
942945 }
943946
@@ -1420,7 +1423,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 476 unmodified lines
14201423 if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
14211424 (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");
14221425 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
1423− if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)) {
1426+ if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iMaxNumRefFrame, iCountMaxMbNum << 2)) {
14241427 WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!");
14251428 FreeMemorySvc (ppCtx);
14261429 return 1;
@@ -1674,7 +1677,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 247 unmodified lines
16741677 FreePicture (pMa, &pRefList->pRef[iRef]);
16751678 }
16761679 ++ iRef;
1677− } while (iRef < 1 + pParam->iNumRefFrame);
1680+ } while (iRef < 1 + pParam->iMaxNumRefFrame);
16781681
16791682 pMa->WelsFree (pCtx->ppRefPicListExt[ilayer], "ppRefPicListExt[]");
16801683 pCtx->ppRefPicListExt[ilayer] = NULL;
@@ -1727,7 +1730,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 46 unmodified lines
17271730 pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL;
17281731 }
17291732 if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
1730− ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iNumRefFrame);
1733+ ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iMaxNumRefFrame);
17311734 pMa->WelsFree (pCtx->pVaa, "pVaa");
17321735 pCtx->pVaa = NULL;
17331736 }
@@ -3568,16 +3571,18 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 1834 unmodified lines
35683571 /* Decide whether need reset for IDR frame based on adjusting prarameters changed */
35693572 /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */
35703573 bNeedReset = (pOldParam == NULL) ||
3571− (pOldParam->iTemporalLayerNum != pNewParam->iTemporalLayerNum) ||
3572− (pOldParam->uiGopSize != pNewParam->uiGopSize) ||
35733574 (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) ||
3574− (pOldParam->iDecompStages != pNewParam->iDecompStages) ||
35753575 (pOldParam->iPicWidth != pNewParam->iPicWidth
35763576 || pOldParam->iPicHeight != pNewParam->iPicHeight) ||
35773577 (pOldParam->SUsedPicRect.iWidth != pNewParam->SUsedPicRect.iWidth
35783578 || pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) ||
35793579 (pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference) ||
35803580 (pOldParam->iLTRRefNum != pNewParam->iLTRRefNum);
3581+ if (pNewParam->iMaxNumRefFrame > pOldParam->iMaxNumRefFrame) {
3582+ pNewParam->iMaxNumRefFrame = pOldParam->iMaxNumRefFrame;
3583+ bNeedReset = true;
3584+ }
3585+
35813586 if (!bNeedReset) { // Check its picture resolutions/quality settings respectively in each dependency layer
35823587 iIndexD = 0;
35833588 assert (pOldParam->iSpatialLayerNum == pNewParam->iSpatialLayerNum);
@@ -3615,12 +3620,6 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 31 unmodified lines
36153620 bNeedReset = true;
36163621 break;
36173622 }
3618−
3619− if (kpOldDlp->iHighestTemporalId != kpNewDlp->iHighestTemporalId) {
3620− bNeedReset = true;
3621− break;
3622− }
3623−
36243623 ++ iIndexD;
36253624 } while (iIndexD < pOldParam->iSpatialLayerNum);
36263625 }
@@ -3801,12 +3800,13 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 174 unmodified lines
38013800 int16_t* pFirstMbInSlice = (int16_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int16_t), "pSliceSeg->pFirstMbInSlice");
38023801 if (NULL == pFirstMbInSlice)
38033802 return ENC_RETURN_MEMALLOCERR;
3804− memset(pFirstMbInSlice, 0, sizeof(int16_t) * iMaxSliceNum);
3803+ memset (pFirstMbInSlice, 0, sizeof (int16_t) * iMaxSliceNum);
38053804 memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int16_t) * iMaxSliceNumOld);
38063805 pMA->WelsFree (pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice");
38073806 pCurLayer->pSliceEncCtx->pFirstMbInSlice = pFirstMbInSlice;
38083807
3809− int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t),"pSliceSeg->pCountMbNumInSlice");
3808+ int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t),
3809+ "pSliceSeg->pCountMbNumInSlice");
38103810 if (NULL == pCountMbNumInSlice)
38113811 return ENC_RETURN_MEMALLOCERR;
38123812 memcpy (pCountMbNumInSlice, pCurLayer->pSliceEncCtx->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld);
@@ -3824,13 +3824,15 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 11 unmodified lines
38243824 memcpy (pSlcingOverRc, pCtx->pWelsSvcRc->pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld);
38253825 uiSliceIdx = iMaxSliceNumOld;
38263826 SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx];
3827− const int32_t kiBitsPerMb = WELS_DIV_ROUND(pCtx->pWelsSvcRc->iTargetBits * INT_MULTIPLY, pCtx->pWelsSvcRc->iNumberMbFrame);
3827+ const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc->iTargetBits * INT_MULTIPLY,
3828+ pCtx->pWelsSvcRc->iNumberMbFrame);
38283829 while (uiSliceIdx < iMaxSliceNum) {
38293830 pSORC->iComplexityIndexSlice = 0;
38303831 pSORC->iCalculatedQpSlice = pCtx->iGlobalQp;
38313832 pSORC->iTotalQpSlice = 0;
38323833 pSORC->iTotalMbSlice = 0;
3833− pSORC->iTargetBitsSlice = WELS_DIV_ROUND(kiBitsPerMb * pCurLayer->pSliceEncCtx->pCountMbNumInSlice[uiSliceIdx], INT_MULTIPLY);
3834+ pSORC->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurLayer->pSliceEncCtx->pCountMbNumInSlice[uiSliceIdx],
3835+ INT_MULTIPLY);
38343836 pSORC->iFrameBitsSlice = 0;
38353837 pSORC->iGomBitsSlice = 0;
38363838 pSORC ++;

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