fix codingIdx update issue

This commit is contained in:
Karina 2016-06-02 21:17:31 +08:00
parent f6b6a0f6aa
commit 4f41c3a5bf
4 changed files with 4632 additions and 4633 deletions

View File

@ -2454,7 +2454,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
WelsCabacInit (pCtx); WelsCabacInit (pCtx);
WelsRcInitModule (pCtx, pCtx->pSvcParam->iRCMode); WelsRcInitModule (pCtx, pCtx->pSvcParam->iRCMode);
pCtx->pVpp = CWelsPreProcess::CreatePreProcess(pCtx); pCtx->pVpp = CWelsPreProcess::CreatePreProcess (pCtx);
if (pCtx->pVpp == NULL) { if (pCtx->pVpp == NULL) {
iRet = 1; iRet = 1;
WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pOut of memory in case new CWelsPreProcess()."); WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pOut of memory in case new CWelsPreProcess().");
@ -3453,7 +3453,7 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam; SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0]; SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0];
bool bSkipFrameFlag = WelsRcCheckFrameStatus (pCtx,uiTimeStamp,iSpatialNum,iCurDid); bool bSkipFrameFlag = WelsRcCheckFrameStatus (pCtx, uiTimeStamp, iSpatialNum, iCurDid);
EVideoFrameType eFrameType = DecideFrameType (pCtx, iSpatialNum, iCurDid, bSkipFrameFlag); EVideoFrameType eFrameType = DecideFrameType (pCtx, iSpatialNum, iCurDid, bSkipFrameFlag);
if (eFrameType == videoFrameTypeSkip) { if (eFrameType == videoFrameTypeSkip) {
if (pSvcParam->bSimulcastAVC) { if (pSvcParam->bSimulcastAVC) {
@ -3498,17 +3498,6 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
++ pCtx->uiIdrPicId; ++ pCtx->uiIdrPicId;
} }
} }
if (!pSvcParam->bSimulcastAVC) {
for (int32_t i = 0; i < pSvcParam->iSpatialLayerNum; i++) {
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[i];
pParamInternal->iCodingIndex ++;
pCtx->pWelsSvcRc[i].iContinualSkipFrames = 0;
}
} else {
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iCurDid];
pParamInternal->iCodingIndex++;
pCtx->pWelsSvcRc[iCurDid].iContinualSkipFrames = 0;
}
} }
return eFrameType; return eFrameType;
} }
@ -4138,9 +4127,17 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
&& (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) { && (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) {
pCtx->bRefOfCurTidIsLtr[iCurDid][iCurTid] = true; pCtx->bRefOfCurTidIsLtr[iCurDid][iCurTid] = true;
} }
// ++ pParamInternal->iCodingIndex; if (pSvcParam->bSimulcastAVC)
++ pParamInternal->iCodingIndex;
}//end of (iSpatialIdx/iSpatialNum) }//end of (iSpatialIdx/iSpatialNum)
if (!pSvcParam->bSimulcastAVC) {
for (int32_t i = 0; i < pSvcParam->iSpatialLayerNum; i++) {
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[i];
pParamInternal->iCodingIndex ++;
}
}
if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) { if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) {
pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid); pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid);
ForceCodingIDR (pCtx); ForceCodingIDR (pCtx);
@ -4183,12 +4180,13 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
pFbi->iLayerNum = iLayerNum; pFbi->iLayerNum = iLayerNum;
WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iFrameSize = %d", WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iFrameSize = %d",
iLayerNum,iFrameSize); iLayerNum, iFrameSize);
for (int32_t i = 0; i < iLayerNum; i++) for (int32_t i = 0; i < iLayerNum; i++)
WelsLog (pLogCtx, WELS_LOG_DEBUG, WelsLog (pLogCtx, WELS_LOG_DEBUG,
"WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d, first Nal Length=%d,uiSpatialId = %d,uiTemporalId = %d,iSubSeqId = %d",i, "WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d, first Nal Length=%d,uiSpatialId = %d,uiTemporalId = %d,iSubSeqId = %d",
i,
pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount, pFbi->sLayerInfo[i].pNalLengthInByte[0], pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount, pFbi->sLayerInfo[i].pNalLengthInByte[0],
pFbi->sLayerInfo[i].uiSpatialId, pFbi->sLayerInfo[i].uiTemporalId,pFbi->sLayerInfo[i].iSubSeqId); pFbi->sLayerInfo[i].uiSpatialId, pFbi->sLayerInfo[i].uiTemporalId, pFbi->sLayerInfo[i].iSubSeqId);
WelsEmms(); WelsEmms();
pLayerBsInfo->eFrameType = eFrameType; pLayerBsInfo->eFrameType = eFrameType;

View File

@ -123,7 +123,7 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iCost2BitsIntra = 1; pWelsSvcRc->iCost2BitsIntra = 1;
pWelsSvcRc->iAvgCost2Bits = 1; pWelsSvcRc->iAvgCost2Bits = 1;
pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO; pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
pWelsSvcRc->iContinualSkipFrames = 0;
pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - (( pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) * QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) *
pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE; pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
@ -1056,6 +1056,7 @@ int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
void WelsRcPictureInitGom (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { void WelsRcPictureInitGom (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
pWelsSvcRc->iContinualSkipFrames = 0;
if (pEncCtx->eSliceType == I_SLICE) { if (pEncCtx->eSliceType == I_SLICE) {
if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed