add buffer based rc

This commit is contained in:
ruil2 2014-07-14 13:57:03 +08:00
parent 4cdee3b2d1
commit 36cfb3bd32
9 changed files with 56 additions and 24 deletions

View File

@ -198,6 +198,7 @@ typedef enum {
RC_QUALITY_MODE = 0, //Quality mode
RC_BITRATE_MODE = 1, //Bitrate mode
RC_LOW_BW_MODE = 2, //bitrate limited mode
RC_BUFFERBASED_MODE = 3,//no bitrate control,only using buffer status,adjust the video quality
RC_OFF_MODE = -1, // rate control off mode
} RC_MODES;

View File

@ -52,8 +52,6 @@ namespace WelsSVCEnc {
//trace
#define GOM_TRACE_FLAG 0
#define GOM_H_SCC 8
#define WELS_RC_DISABLE 0
#define WELS_RC_GOM 1
enum {
BITS_NORMAL,
@ -71,6 +69,8 @@ GOM_MAX_QP_MODE = 36,
MAX_LOW_BR_QP = 42,
MIN_IDR_QP = 26,
MAX_IDR_QP = 32,
MIN_SCREEN_QP = 26,
MAX_SCREEN_QP = 32,
DELTA_QP = 2,
DELTA_QP_BGD_THD = 3,
@ -232,7 +232,7 @@ PWelsRCMBInitFunc pfWelsRcMbInit;
PWelsRCMBInfoUpdateFunc pfWelsRcMbInfoUpdate;
} SWelsRcFunc;
void WelsRcInitModule (void* pCtx, int32_t iModule);
void WelsRcInitModule (void* pCtx,RC_MODES iRcMode);
void WelsRcFreeMemory (void* pCtx);
}

View File

@ -2042,7 +2042,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
if (pCodingParam->iMultipleThreadIdc > 1)
iRet = CreateSliceThreads (pCtx);
WelsRcInitModule (pCtx, pCtx->pSvcParam->iRCMode != RC_OFF_MODE ? WELS_RC_GOM : WELS_RC_DISABLE);
WelsRcInitModule (pCtx, pCtx->pSvcParam->iRCMode);
pCtx->pVpp = new CWelsPreProcess (pCtx);
if (pCtx->pVpp == NULL) {
@ -2948,17 +2948,19 @@ int32_t GetSubSequenceId (sWelsEncCtx* pCtx, EVideoFrameType eFrameType) {
bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pCtx, int32_t iSpatialNum) {
SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0];
bool bSkipMustFlag = false;
if (RC_OFF_MODE != pCtx->pSvcParam->iRCMode && true == pCtx->pSvcParam->bEnableFrameSkip) {
for (int32_t i = 0; i < iSpatialNum; i++) {
if (0 == pCtx->pSvcParam->sSpatialLayers[i].iMaxSpatialBitrate) {
break;
}
pCtx->uiDependencyId = (uint8_t) (pSpatialIndexMap + i)->iDid;
pCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pCtx);
if (true == pCtx->pWelsSvcRc[pCtx->uiDependencyId].bSkipFlag) {
bSkipMustFlag = true;
break;
if (pCtx->pSvcParam->bEnableFrameSkip) {
if ((RC_QUALITY_MODE == pCtx->pSvcParam->iRCMode) || (RC_BITRATE_MODE == pCtx->pSvcParam->iRCMode)
|| (RC_LOW_BW_MODE == pCtx->pSvcParam->iRCMode)) {
for (int32_t i = 0; i < iSpatialNum; i++) {
if (0 == pCtx->pSvcParam->sSpatialLayers[i].iMaxSpatialBitrate) {
break;
}
pCtx->uiDependencyId = (uint8_t) (pSpatialIndexMap + i)->iDid;
pCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pCtx);
if (true == pCtx->pWelsSvcRc[pCtx->uiDependencyId].bSkipFlag) {
bSkipMustFlag = true;
break;
}
}
}
}

View File

@ -999,20 +999,44 @@ void WelsRcMbInitDisable (void* pCtx, SMB* pCurMb, SSlice* pSlice) {
void WelsRcMbInfoUpdateDisable (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
}
void WelRcPictureInitBufferBasedQp (void* pCtx) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SVAAFrameInfo* pVaa = static_cast<SVAAFrameInfo*> (pEncCtx->pVaa);
void WelsRcInitModule (void* pCtx, int32_t iModule) {
int32_t iMinQp = MIN_SCREEN_QP;
if (pVaa->eSceneChangeIdc == LARGE_CHANGED_SCENE)
iMinQp = MIN_SCREEN_QP + 2;
else if (pVaa->eSceneChangeIdc == MEDIUM_CHANGED_SCENE)
iMinQp = MIN_SCREEN_QP + 1;
else
iMinQp = MIN_SCREEN_QP;
pEncCtx->iGlobalQp += pEncCtx->iDropNumber;
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, MIN_SCREEN_QP, MAX_SCREEN_QP);
}
void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SWelsRcFunc* pRcf = &pEncCtx->pFuncList->pfRc;
switch (iModule) {
case WELS_RC_DISABLE:
switch (iRcMode) {
case RC_OFF_MODE:
pRcf->pfWelsRcPictureInit = WelsRcPictureInitDisable;
pRcf->pfWelsRcPicDelayJudge = NULL;
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateDisable;
pRcf->pfWelsRcMbInit = WelsRcMbInitDisable;
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
break;
case WELS_RC_GOM:
case RC_BUFFERBASED_MODE:
pRcf->pfWelsRcPictureInit = WelRcPictureInitBufferBasedQp;
pRcf->pfWelsRcPicDelayJudge = NULL;
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateDisable;
pRcf->pfWelsRcMbInit = WelsRcMbInitDisable;
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
break;
case RC_QUALITY_MODE:
case RC_BITRATE_MODE:
case RC_LOW_BW_MODE:
default:
pRcf->pfWelsRcPictureInit = WelsRcPictureInitGom;
pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudge;

View File

@ -29,7 +29,8 @@ LoopFilterBetaOffset 0 # BetaOffset (-6..+6): valid range
MultipleThreadIdc 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
#============================== RATE CONTROL ==============================
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode; -1: rc off mode
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode;
# 3: buffer based mode,can't control bitrate; -1: rc off mode;
TargetBitrate 5000 # Unit: kbps, controled by EnableRC also
MaxOverallBitrate 6000 # Unit: kbps, max bitrate overall
EnableFrameSkip 1 #Enable Frame Skip

View File

@ -30,7 +30,8 @@ LoopFilterBetaOffset 0 # BetaOffset (-6..+6): valid range
MultipleThreadIdc 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
#============================== RATE CONTROL ==============================
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode; -1: rc off mode
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode;
# 3: buffer based mode,can't control bitrate; -1: rc off mode;
TargetBitrate 5000 # Unit: kbps, controled by EnableRC also
MaxOverallBitrate 6000 # Unit: kbps, max bitrate overall

View File

@ -30,7 +30,8 @@ LoopFilterBetaOffset 0 # BetaOffset (-6..+6): valid range
MultipleThreadIdc 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
#============================== RATE CONTROL ==============================
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode; -1: rc off mode
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode;
# 3: buffer based mode,can't control bitrate; -1: rc off mode;
TargetBitrate 5000 # Unit: kbps, controled by EnableRC also
MaxOverallBitrate 6000 # Unit: kbps, max bitrate overall
EnableFrameSkip 1 #Enable Frame Skip

View File

@ -30,7 +30,8 @@ LoopFilterBetaOffset 0 # BetaOffset (-6..+6): valid range
MultipleThreadIdc 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
#============================== RATE CONTROL ==============================
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode; -1: rc off mode
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode;
# 3: buffer based mode,can't control bitrate; -1: rc off mode;
TargetBitrate 5000 # Unit: kbps, controled by EnableRC also
MaxOverallBitrate 6000 # Unit: kbps, max bitrate overall

View File

@ -30,7 +30,8 @@ LoopFilterBetaOffset 0 # BetaOffset (-6..+6): valid range
MultipleThreadIdc 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
#============================== RATE CONTROL ==============================
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode; -1: rc off mode
RCMode 0 # 0: quality mode; 1: bitrate mode; 2: bitrate limited mode;
# 3: buffer based mode,can't control bitrate; -1: rc off mode;
TargetBitrate 600 # Unit: kbps, controled by EnableRC also
MaxOverallBitrate 800 # Unit: kbps, max bitrate overall