History

Merge pull request #2323 from ruil2/rc_timestamp

resolve abnormal timestamp(rollback or jump case)

HaiboZhu committed 10 years ago

Commit cd755412 parents 5398181 0d5db3d1 file · +10 −6Browse files

Unified · Split

codec/encoder/core/src/ratectl.cpp+10−6
@@ -193,10 +193,10 @@ void RcInitTlWeight (sWelsEncCtx* pEncCtx) { · 192 unmodified lines
193193 n = 0;
194194 while (n <= kiHighestTid) {
195195 pTOverRc[n].iTlayerWeight = iWeightArray[kiDecompositionStages][n];
196− pTOverRc[n].iMinQp = pWelsSvcRc->iMinQp + (n<<1);
197− pTOverRc[n].iMinQp = WELS_CLIP3(pTOverRc[n].iMinQp, 0, 51);
198− pTOverRc[n].iMaxQp = pWelsSvcRc->iMaxQp + (n<<1);
199− pTOverRc[n].iMaxQp = WELS_CLIP3(pTOverRc[n].iMaxQp, pTOverRc[n].iMinQp, 51);
196+ pTOverRc[n].iMinQp = pWelsSvcRc->iMinQp + (n << 1);
197+ pTOverRc[n].iMinQp = WELS_CLIP3 (pTOverRc[n].iMinQp, 0, 51);
198+ pTOverRc[n].iMaxQp = pWelsSvcRc->iMaxQp + (n << 1);
199+ pTOverRc[n].iMaxQp = WELS_CLIP3 (pTOverRc[n].iMaxQp, pTOverRc[n].iMinQp, 51);
200200 ++ n;
201201 }
202202 //Calculate the frame index for the current frame and its reference frame
@@ -660,7 +660,7 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { · 457 unmodified lines
660660 int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
661661 int64_t iTargetLeftBits = iLeftBits + pSOverRc->iGomBitsSlice - pSOverRc->iGomTargetBits;
662662
663− if ((iLeftBits <= 0)||(iTargetLeftBits <=0)) {
663+ if ((iLeftBits <= 0) || (iTargetLeftBits <= 0)) {
664664 pSOverRc->iCalculatedQpSlice += 2;
665665 } else {
666666 //globe decision
@@ -1076,7 +1076,7 @@ void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) { · 409 unmodified lines
10761076 const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
10771077
10781078 pSOverRc->iBsPosSlice = BsGetBitsPos (bs);
1079− if((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE)&&(pEncCtx->eSliceType == I_SLICE)){
1079+ if ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) && (pEncCtx->eSliceType == I_SLICE)) {
10801080 pCurMb->uiLumaQp = pEncCtx->iGlobalQp;
10811081 pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)];
10821082 return;
@@ -1288,6 +1288,10 @@ void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFram · 205 unmodified lines
12881288
12891289 int32_t iBitRate = pDLayerConfig->iSpatialBitrate;
12901290 int32_t iEncTimeInv = (pWelsSvcRc->uiLastTimeStamp == 0) ? 0 : (int32_t) (uiTimeStamp - pWelsSvcRc->uiLastTimeStamp);
1291+ if ((iEncTimeInv < 0) || (iEncTimeInv > 1000)) {
1292+ pWelsSvcRc->uiLastTimeStamp = uiTimeStamp - 1000.0 / pDLayerConfig->fFrameRate;
1293+ iEncTimeInv = 1000.0 / pDLayerConfig->fFrameRate;
1294+ }
12911295 int32_t iSentBits = (int32_t) ((double)iBitRate * iEncTimeInv * (1.0E-3) + 0.5);
12921296 iSentBits = WELS_MAX (iSentBits, 0);
12931297

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