ref: 685b6144a5874619ff3659cc196d35525e84f4bc
parent: a5e4cca71021faff8cf3f1747ac99c963e0e7a65
parent: 9b2dd5532413ff34804a1d402d4783ac497b32fa
author: HaiboZhu <haibozhu@cisco.com>
date: Mon May 23 05:49:45 EDT 2016
Merge pull request #2469 from ruil2/fix_bitrate add GetBsPostion for cabac and cavlc
--- a/codec/encoder/core/inc/svc_set_mb_syn.h
+++ b/codec/encoder/core/inc/svc_set_mb_syn.h
@@ -64,5 +64,7 @@
//for Base Layer CAVLC writing
int32_t WelsSpatialWriteMbSyn (sWelsEncCtx* Ctx, SSlice* pSlice, SMB* pCurMb);
int32_t WelsSpatialWriteMbSynCabac (sWelsEncCtx* pCtx, SSlice* pSlice, SMB* pCurMb);
+int32_t GetBsPosCavlc(SSlice *pSlice);
+int32_t GetBsPosCabac(SSlice *pSlice);
}
#endif
--- a/codec/encoder/core/inc/wels_func_ptr_def.h
+++ b/codec/encoder/core/inc/wels_func_ptr_def.h
@@ -192,7 +192,7 @@
typedef int32_t (*PWelsSpatialWriteMbSyn) (sWelsEncCtx* pCtx, SSlice* pSlice, SMB* pCurMb);
typedef void (*PStashMBStatus) (SDynamicSlicingStack* pDss, SSlice* pSlice, int32_t iMbSkipRun);
typedef int32_t (*PStashPopMBStatus) (SDynamicSlicingStack* pDss, SSlice* pSlice);
-
+typedef int32_t (*PGetBsPosition)(SSlice *pSlice);
class IWelsParametersetStrategy;
struct TagWelsFuncPointerList {
@@ -288,6 +288,7 @@
PCavlcParamCalFunc pfCavlcParamCal;
PWelsSpatialWriteMbSyn pfWelsSpatialWriteMbSyn;
+ PGetBsPosition pfGetBsPosition;
PStashMBStatus pfStashMBStatus;
PStashPopMBStatus pfStashPopMBStatus;
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -1076,11 +1076,10 @@
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
const int32_t kiSliceId = pSlice->uiSliceIdx;
SRCSlicing* pSOverRc = &pSliceInLayer[kiSliceId].sSlicingOverRc;
- SBitStringAux* bs = pSlice->pSliceBsa;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
- pSOverRc->iBsPosSlice = BsGetBitsPos (bs);
+ pSOverRc->iBsPosSlice = pEncCtx->pFuncList->pfGetBsPosition (pSlice);
if ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) && (pEncCtx->eSliceType == I_SLICE)) {
pCurMb->uiLumaQp = pEncCtx->iGlobalQp;
pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)];
@@ -1101,13 +1100,12 @@
void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SBitStringAux* bs = pSlice->pSliceBsa;
int32_t iSliceId = pSlice->uiSliceIdx;
SRCSlicing* pSOverRc = &pSliceInLayer[iSliceId].sSlicingOverRc;
const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
- int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice;
+ int32_t iCurMbBits = pEncCtx->pFuncList->pfGetBsPosition (pSlice) - pSOverRc->iBsPosSlice;
pSOverRc->iFrameBitsSlice += iCurMbBits;
pSOverRc->iGomBitsSlice += iCurMbBits;
--- a/codec/encoder/core/src/set_mb_syn_cavlc.cpp
+++ b/codec/encoder/core/src/set_mb_syn_cavlc.cpp
@@ -259,7 +259,12 @@
pSlice->uiLastMbQp = pDss->uiLastMbQp;
return pDss->iMbSkipRunStack;
}
-
+int32_t GetBsPosCavlc(SSlice *pSlice){
+ return BsGetBitsPos (pSlice->pSliceBsa);
+}
+int32_t GetBsPosCabac(SSlice *pSlice){
+ return (int32_t) ((pSlice->sCabacCtx.m_pBufCur - pSlice->sCabacCtx.m_pBufStart) << 3) + (pSlice->sCabacCtx.m_iLowBitCnt - 9);
+}
void WelsWriteSliceEndSyn (SSlice* pSlice, bool bEntropyCodingModeFlag) {
SBitStringAux* pBs = pSlice->pSliceBsa;
if (bEntropyCodingModeFlag) {
@@ -288,11 +293,12 @@
pFuncList->pfStashMBStatus = StashMBStatusCabac;
pFuncList->pfStashPopMBStatus = StashPopMBStatusCabac;
pFuncList->pfWelsSpatialWriteMbSyn = WelsSpatialWriteMbSynCabac;
+ pFuncList->pfGetBsPosition = GetBsPosCabac;
} else {
pFuncList->pfStashMBStatus = StashMBStatusCavlc;
pFuncList->pfStashPopMBStatus = StashPopMBStatusCavlc;
pFuncList->pfWelsSpatialWriteMbSyn = WelsSpatialWriteMbSyn;
-
+ pFuncList->pfGetBsPosition = GetBsPosCavlc;
}
}
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -631,7 +631,7 @@
if (ENC_RETURN_SUCCESS != iEncReturn)
return iEncReturn;
- sDss.iCurrentPos = BsGetBitsPos (pBs);
+ sDss.iCurrentPos = pEncCtx->pFuncList->pfGetBsPosition (pSlice);
if (DynSlcJudgeSliceBoundaryStepBack (pEncCtx, pSlice, pSliceCtx, pCurMb, &sDss)) { //islice
pEncCtx->pFuncList->pfStashPopMBStatus (&sDss, pSlice);
@@ -1254,7 +1254,7 @@
//DYNAMIC_SLICING_ONE_THREAD - MultiD
- sDss.iCurrentPos = BsGetBitsPos (pBs);
+ sDss.iCurrentPos = pEncCtx->pFuncList->pfGetBsPosition (pSlice);
if (DynSlcJudgeSliceBoundaryStepBack (pEncCtx, pSlice, pSliceCtx, pCurMb, &sDss)) {
pSlice->iMbSkipRun = pEncCtx->pFuncList->pfStashPopMBStatus (&sDss, pSlice);
pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = iCurMbIdx -
--- a/test/api/encoder_test.cpp
+++ b/test/api/encoder_test.cpp
@@ -157,15 +157,15 @@
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
- "a0c97ec484e8a8cca8868c893e38a5a7312a70a8", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, true //turn on cabac
+ "04ad01bb3872f7dae055c1ec661218f41a020dac", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, true //turn on cabac
},
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
- "c87ff55413efb14d95acd1de3be02bd601fcc3df", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_SIZELIMITED_SLICE, false, 1, false, false, true
+ "8942c8811fd0cb086d709734bf9fd5b184772f5e", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_SIZELIMITED_SLICE, false, 1, false, false, true
},
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
- "fbc231e3ec66b426561bc80b902106fc4b5d2ccb", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_FIXEDSLCNUM_SLICE, false, 1, false, false, true
+ "a27539982433279faa9975c96eaec28df770223e", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_FIXEDSLCNUM_SLICE, false, 1, false, false, true
},
};