ref: 43c62d06ebc993bd151ca45db76581e57a6e601f
parent: 5d6b20119a82ae4ca52c314a4348f1ee77f9657f
parent: 4e89e71e8fc62210cd60f8a07cf56165ad32a637
author: sijchen <[email protected]>
date: Fri Oct 24 05:00:36 EDT 2014
Merge pull request #1439 from sijchen/for_format [Reformat] format cpp files for next release
--- a/codec/common/src/utils.cpp
+++ b/codec/common/src/utils.cpp
@@ -68,7 +68,7 @@
WelsSnprintf (pTraceTag, MAX_LOG_SIZE, "[OpenH264] Detail:");
break;
}
- WelsStrcat(pTraceTag,MAX_LOG_SIZE,kpFmt);
+ WelsStrcat (pTraceTag, MAX_LOG_SIZE, kpFmt);
va_start (vl, kpFmt);
logCtx->pfLog (logCtx->pLogCtx, iLevel, pTraceTag, vl);
va_end (vl);
--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -1065,9 +1065,9 @@
#endif
#ifdef HAVE_NEON_AARCH64
- if (iCpu & WELS_CPU_NEON) {
- pFunc->pWelsSetNonZeroCountFunc = SetNonZeroCount_AArch64_neon;
- }
+ if (iCpu & WELS_CPU_NEON) {
+ pFunc->pWelsSetNonZeroCountFunc = SetNonZeroCount_AArch64_neon;
+ }
#endif
}
--- a/codec/encoder/core/src/encoder.cpp
+++ b/codec/encoder/core/src/encoder.cpp
@@ -365,11 +365,13 @@
* \brief Dump reconstruction for dependency layer
*/
-extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) {
+extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend,
+ SDqLayer* pDqLayer) {
WelsFileHandle* pDumpRecFile = NULL;
int32_t iWrittenSize = 0;
const char* openMode = bAppend ? "ab" : "wb";
- SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP;
+ SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) :
+ pDqLayer->sLayerInfo.pSpsP;
bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag;
SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop;
@@ -390,12 +392,15 @@
int32_t i = 0;
int32_t j = 0;
const int32_t kiStrideY = pCurPicture->iLineSize[0];
- const int32_t kiLumaWidth = bFrameCroppingFlag?(pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel;
- const int32_t kiLumaHeight = bFrameCroppingFlag?(pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel;
+ const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft +
+ pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel;
+ const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop +
+ pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel;
const int32_t kiChromaWidth = kiLumaWidth >> 1;
const int32_t kiChromaHeight = kiLumaHeight >> 1;
uint8_t* pSrc = NULL;
- pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0];
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) +
+ (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0];
for (j = 0; j < kiLumaHeight; ++ j) {
iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile);
assert (iWrittenSize == kiLumaWidth);
@@ -407,7 +412,8 @@
}
for (i = 1; i < I420_PLANES; ++ i) {
const int32_t kiStrideUV = pCurPicture->iLineSize[i];
- pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i];
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) :
+ pCurPicture->pData[i];
for (j = 0; j < kiChromaHeight; ++ j) {
iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile);
assert (iWrittenSize == kiChromaWidth);
@@ -427,9 +433,11 @@
* \brief Dump the reconstruction pictures
*/
-void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) {
+void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend,
+ SDqLayer* pDqLayer) {
WelsFileHandle* pDumpRecFile = NULL;
- SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP;
+ SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) :
+ pDqLayer->sLayerInfo.pSpsP;
bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag;
SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop;
@@ -451,12 +459,15 @@
int32_t i = 0;
int32_t j = 0;
const int32_t kiStrideY = pCurPicture->iLineSize[0];
- const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel;
- const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel;
+ const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft +
+ pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel;
+ const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop +
+ pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel;
const int32_t kiChromaWidth = kiLumaWidth >> 1;
const int32_t kiChromaHeight = kiLumaHeight >> 1;
uint8_t* pSrc = NULL;
- pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0];
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) +
+ (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0];
for (j = 0; j < kiLumaHeight; ++ j) {
iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile);
assert (iWrittenSize == kiLumaWidth);
@@ -468,7 +479,8 @@
}
for (i = 1; i < I420_PLANES; ++ i) {
const int32_t kiStrideUV = pCurPicture->iLineSize[i];
- pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i];
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) :
+ pCurPicture->pData[i];
for (j = 0; j < kiChromaHeight; ++ j) {
iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile);
assert (iWrittenSize == kiChromaWidth);
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -156,9 +156,9 @@
}
if (pSpatialLayer->iMaxSpatialBitrate < pSpatialLayer->iSpatialBitrate * 1.1f) {
WelsLog (pLogCtx, WELS_LOG_WARNING,
- "MaxSpatialBitrate (%d) should set be larger than 1.1 times of SpatialBitrate (%d)",
- pSpatialLayer->iMaxSpatialBitrate, pSpatialLayer->iSpatialBitrate);
- // pSpatialLayer->iSpatialBitrate = (int32_t) (pSpatialLayer->iMaxSpatialBitrate/1.1f);
+ "MaxSpatialBitrate (%d) should set be larger than 1.1 times of SpatialBitrate (%d)",
+ pSpatialLayer->iMaxSpatialBitrate, pSpatialLayer->iSpatialBitrate);
+// pSpatialLayer->iSpatialBitrate = (int32_t) (pSpatialLayer->iMaxSpatialBitrate/1.1f);
}
}
if (iTotalBitrate > pCfg->iTargetBitrate) {
@@ -1357,7 +1357,9 @@
iTargetSpatialBsSize = iLayerBsSize;
iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount;
- pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, (pParam->iUsageType==CAMERA_VIDEO_REAL_TIME?MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA:MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN));
+ pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT,
+ (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA :
+ MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN));
// Output
(*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMalloc (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput");
@@ -2015,7 +2017,9 @@
}
iRet = pCodingParam->DetermineTemporalSettings();
if (iRet != ENC_RETURN_SUCCESS) {
- WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting!)", iRet);
+ WelsLog (pLogCtx, WELS_LOG_ERROR,
+ "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting!)",
+ iRet);
return iRet;
}
iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags);
@@ -3031,7 +3035,8 @@
if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate)
++ pCtx->iCodingIndex;
pFbi->eFrameType = videoFrameTypeSkip;
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] Frame timestamp = %8" PRId64", skip one frame", (int64_t)pSrcPic->uiTimeStamp);
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %8" PRId64", skip one frame",
+ (int64_t)pSrcPic->uiTimeStamp);
return ENC_RETURN_SUCCESS;
}
@@ -3038,7 +3043,8 @@
eFrameType = DecideFrameType (pCtx, iSpatialNum);
if (eFrameType == videoFrameTypeSkip) {
pFbi->eFrameType = eFrameType;
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] Frame timestamp = %8" PRId64", skip one frame", (int64_t)pSrcPic->uiTimeStamp);
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %8" PRId64", skip one frame",
+ (int64_t)pSrcPic->uiTimeStamp);
return ENC_RETURN_SUCCESS;
}
@@ -3045,7 +3051,8 @@
//loop each layer to check if have skip frame when RC and frame skip enable
if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, (uint32_t)pSrcPic->uiTimeStamp)) {
pFbi->eFrameType = videoFrameTypeSkip;
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] Frame timestamp = %8" PRId64", skip one frame", (int64_t)pSrcPic->uiTimeStamp);
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %8" PRId64", skip one frame",
+ (int64_t)pSrcPic->uiTimeStamp);
return ENC_RETURN_SUCCESS;
}
@@ -3429,7 +3436,7 @@
}
pCtx->pFuncList->pfRc.pfWelsRcPictureInfoUpdate (pCtx, iLayerSize);
- RcTraceFrameBits (pCtx,pSrcPic->uiTimeStamp);
+ RcTraceFrameBits (pCtx, pSrcPic->uiTimeStamp);
pCtx->pDecPic->iFrameAverageQp = pCtx->pWelsSvcRc->iAverageFrameQp;
//update scc related
@@ -3760,7 +3767,8 @@
} else {
/* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */
pNewParam->iNumRefFrame = WELS_CLIP3 (pNewParam->iNumRefFrame, MIN_REF_PIC_COUNT,
- (pNewParam->iUsageType==CAMERA_VIDEO_REAL_TIME?MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA:MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN));
+ (pNewParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA :
+ MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN));
pNewParam->iLoopFilterDisableIdc = WELS_CLIP3 (pNewParam->iLoopFilterDisableIdc, 0, 6);
pNewParam->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pNewParam->iLoopFilterAlphaC0Offset, -6, 6);
pNewParam->iLoopFilterBetaOffset = WELS_CLIP3 (pNewParam->iLoopFilterBetaOffset, -6, 6);
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -52,7 +52,7 @@
#define VIRTUAL_BUFFER_LOW_TH 120 //*INT_MULTIPLY
#define VIRTUAL_BUFFER_HIGH_TH 180 //*INT_MULTIPLY
-
+
//#define _TEST_TEMP_RC_
#ifdef _TEST_TEMP_RC_
//#define _NOT_USE_AQ_FOR_TEST_
@@ -61,855 +61,857 @@
#endif
#define _BITS_RANGE 0
const int32_t g_kiQpToQstepTable[52] = { 63, 71, 79, 89, 100, 112, 126, 141, 159, 178,
- 200, 224, 252, 283, 317, 356, 400, 449, 504, 566,
- 635, 713, 800, 898, 1008, 1131, 1270, 1425, 1600, 1796,
- 2016, 2263, 2540, 2851, 3200, 3592, 4032, 4525, 5080, 5702,
- 6400, 7184, 8063, 9051, 10159, 11404, 12800, 14368, 16127, 18102,
- 20319, 22807
- }; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
-
+200, 224, 252, 283, 317, 356, 400, 449, 504, 566,
+635, 713, 800, 898, 1008, 1131, 1270, 1425, 1600, 1796,
+2016, 2263, 2540, 2851, 3200, 3592, 4032, 4525, 5080, 5702,
+6400, 7184, 8063, 9051, 10159, 11404, 12800, 14368, 16127, 18102,
+20319, 22807
+}; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
+
void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) {
- const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
- const int32_t kiGomSize = pWelsSvcRc->iGomSize;
- const int32_t kiGomSizeD = kiGomSize * sizeof (double);
- const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t);
- const int32_t kiLayerRcSize = kiGomSizeD + (kiGomSizeI * 3) + sizeof (SRCTemporal) * kiMaxTl;
- uint8_t* pBaseMem = (uint8_t*)pMA->WelsMalloc (kiLayerRcSize, "pWelsSvcRc->pTemporalOverRc");
-
- if (NULL == pBaseMem)
- return;
-
- pWelsSvcRc->pTemporalOverRc = (SRCTemporal*)pBaseMem;
- pBaseMem += sizeof (SRCTemporal) * kiMaxTl;
- pWelsSvcRc->pGomComplexity = (double*)pBaseMem;
- pBaseMem += kiGomSizeD;
- pWelsSvcRc->pGomForegroundBlockNum = (int32_t*)pBaseMem;
- pBaseMem += kiGomSizeI;
- pWelsSvcRc->pCurrentFrameGomSad = (int32_t*)pBaseMem;
- pBaseMem += kiGomSizeI;
- pWelsSvcRc->pGomCost = (int32_t*)pBaseMem;
-
- pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC");
+const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
+const int32_t kiGomSize = pWelsSvcRc->iGomSize;
+const int32_t kiGomSizeD = kiGomSize * sizeof (double);
+const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t);
+const int32_t kiLayerRcSize = kiGomSizeD + (kiGomSizeI * 3) + sizeof (SRCTemporal) * kiMaxTl;
+uint8_t* pBaseMem = (uint8_t*)pMA->WelsMalloc (kiLayerRcSize, "pWelsSvcRc->pTemporalOverRc");
+
+if (NULL == pBaseMem)
+return;
+
+pWelsSvcRc->pTemporalOverRc = (SRCTemporal*)pBaseMem;
+pBaseMem += sizeof (SRCTemporal) * kiMaxTl;
+pWelsSvcRc->pGomComplexity = (double*)pBaseMem;
+pBaseMem += kiGomSizeD;
+pWelsSvcRc->pGomForegroundBlockNum = (int32_t*)pBaseMem;
+pBaseMem += kiGomSizeI;
+pWelsSvcRc->pCurrentFrameGomSad = (int32_t*)pBaseMem;
+pBaseMem += kiGomSizeI;
+pWelsSvcRc->pGomCost = (int32_t*)pBaseMem;
+
+pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC");
}
-
+
void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) {
- if (pWelsSvcRc != NULL && pWelsSvcRc->pSlicingOverRc != NULL) {
- pMA->WelsFree (pWelsSvcRc->pSlicingOverRc, "SlicingOverRC");
- pWelsSvcRc->pSlicingOverRc = NULL;
- }
- if (pWelsSvcRc != NULL && pWelsSvcRc->pTemporalOverRc != NULL) {
- pMA->WelsFree (pWelsSvcRc->pTemporalOverRc, "pWelsSvcRc->pTemporalOverRc");
- pWelsSvcRc->pTemporalOverRc = NULL;
- pWelsSvcRc->pGomComplexity = NULL;
- pWelsSvcRc->pGomForegroundBlockNum = NULL;
- pWelsSvcRc->pCurrentFrameGomSad = NULL;
- pWelsSvcRc->pGomCost = NULL;
- }
+if (pWelsSvcRc != NULL && pWelsSvcRc->pSlicingOverRc != NULL) {
+pMA->WelsFree (pWelsSvcRc->pSlicingOverRc, "SlicingOverRC");
+pWelsSvcRc->pSlicingOverRc = NULL;
}
-
+if (pWelsSvcRc != NULL && pWelsSvcRc->pTemporalOverRc != NULL) {
+pMA->WelsFree (pWelsSvcRc->pTemporalOverRc, "pWelsSvcRc->pTemporalOverRc");
+pWelsSvcRc->pTemporalOverRc = NULL;
+pWelsSvcRc->pGomComplexity = NULL;
+pWelsSvcRc->pGomForegroundBlockNum = NULL;
+pWelsSvcRc->pCurrentFrameGomSad = NULL;
+pWelsSvcRc->pGomCost = NULL;
+}
+}
+
static inline int32_t RcConvertQp2QStep (int32_t iQP) {
- return g_kiQpToQstepTable[iQP];
+return g_kiQpToQstepTable[iQP];
}
static inline int32_t RcConvertQStep2Qp (int32_t iQpStep) {
- return WELS_ROUND ((6 * log (iQpStep * 1.0f / INT_MULTIPLY) / log (2.0) + 4.0));
+return WELS_ROUND ((6 * log (iQpStep * 1.0f / INT_MULTIPLY) / log (2.0) + 4.0));
}
-
+
void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = NULL;
- SSpatialLayerConfig* pDLayerParam = NULL;
-
- int32_t j = 0;
- int32_t iMbWidth = 0;
-
- bool bMultiSliceMode = false;
- int32_t iGomRowMode0 = 1, iGomRowMode1 = 1;
+SWelsSvcRc* pWelsSvcRc = NULL;
+SSpatialLayerConfig* pDLayerParam = NULL;
+
+int32_t j = 0;
+int32_t iMbWidth = 0;
+
+bool bMultiSliceMode = false;
+int32_t iGomRowMode0 = 1, iGomRowMode1 = 1;
#ifdef _TEST_TEMP_RC_
- fp_test_rc = fopen ("testRC.dat", "w");
- fp_vgop = fopen ("vgop.dat", "w");
+fp_test_rc = fopen ("testRC.dat", "w");
+fp_vgop = fopen ("vgop.dat", "w");
#endif
- for (j = 0; j < pEncCtx->pSvcParam->iSpatialLayerNum; j++) {
- SSliceCtx* pSliceCtx = &pEncCtx->pSliceCtxList[j];
- pWelsSvcRc = &pEncCtx->pWelsSvcRc[j];
- pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[j];
- iMbWidth = (pDLayerParam->iVideoWidth >> 4);
- pWelsSvcRc->iNumberMbFrame = iMbWidth * (pDLayerParam->iVideoHeight >> 4);
- pWelsSvcRc->iSliceNum = pSliceCtx->iSliceNumInFrame;
-
- pWelsSvcRc->iRcVaryPercentage = _BITS_RANGE; // % -- for temp
- pWelsSvcRc->iRcVaryRatio = pWelsSvcRc->iRcVaryPercentage;
-
- pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
-
- pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
- QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) *
- pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
- pWelsSvcRc->iQpRangeLowerInFrame = (QP_RANGE_LOWER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
- QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) *
- pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
-
- if (iMbWidth <= MB_WIDTH_THRESHOLD_90P) {
- pWelsSvcRc->iSkipQpValue = SKIP_QP_90P;
- iGomRowMode0 = GOM_ROW_MODE0_90P;
- iGomRowMode1 = GOM_ROW_MODE1_90P;
- } else if (iMbWidth <= MB_WIDTH_THRESHOLD_180P) {
- pWelsSvcRc->iSkipQpValue = SKIP_QP_180P;
- iGomRowMode0 = GOM_ROW_MODE0_180P;
- iGomRowMode1 = GOM_ROW_MODE1_180P;
- } else if (iMbWidth <= MB_WIDTH_THRESHOLD_360P) {
- pWelsSvcRc->iSkipQpValue = SKIP_QP_360P;
- iGomRowMode0 = GOM_ROW_MODE0_360P;
- iGomRowMode1 = GOM_ROW_MODE1_360P;
- } else {
- pWelsSvcRc->iSkipQpValue = SKIP_QP_720P;
- iGomRowMode0 = GOM_ROW_MODE0_720P;
- iGomRowMode1 = GOM_ROW_MODE1_720P;
- }
- iGomRowMode0 = iGomRowMode1 + ((iGomRowMode0 - iGomRowMode1) * pWelsSvcRc->iRcVaryRatio / MAX_BITS_VARY_PERCENTAGE);
-
- pWelsSvcRc->iNumberMbGom = iMbWidth * iGomRowMode0;
-
- pWelsSvcRc->iMinQp = GOM_MIN_QP_MODE;
- pWelsSvcRc->iMaxQp = GOM_MAX_QP_MODE;
-
- pWelsSvcRc->iFrameDeltaQpUpper = LAST_FRAME_QP_RANGE_UPPER_MODE1 - ((LAST_FRAME_QP_RANGE_UPPER_MODE1 -
- LAST_FRAME_QP_RANGE_UPPER_MODE0) * pWelsSvcRc->iRcVaryRatio / MAX_BITS_VARY_PERCENTAGE);
- pWelsSvcRc->iFrameDeltaQpLower = LAST_FRAME_QP_RANGE_LOWER_MODE1 - ((LAST_FRAME_QP_RANGE_LOWER_MODE1 -
- LAST_FRAME_QP_RANGE_LOWER_MODE0) * pWelsSvcRc->iRcVaryRatio / MAX_BITS_VARY_PERCENTAGE);
-
- pWelsSvcRc->iSkipFrameNum = 0;
- pWelsSvcRc->iGomSize = (pWelsSvcRc->iNumberMbFrame + pWelsSvcRc->iNumberMbGom - 1) / pWelsSvcRc->iNumberMbGom;
-
-
- RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pEncCtx->pSvcParam->sDependencyLayers[j].iHighestTemporalId);
-
- bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
- (SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
- (SM_DYN_SLICE == pDLayerParam->sSliceCfg.uiSliceMode));
- if (bMultiSliceMode)
- pWelsSvcRc->iNumberMbGom = pWelsSvcRc->iNumberMbFrame;
- }
+for (j = 0; j < pEncCtx->pSvcParam->iSpatialLayerNum; j++) {
+SSliceCtx* pSliceCtx = &pEncCtx->pSliceCtxList[j];
+pWelsSvcRc = &pEncCtx->pWelsSvcRc[j];
+pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[j];
+iMbWidth = (pDLayerParam->iVideoWidth >> 4);
+pWelsSvcRc->iNumberMbFrame = iMbWidth * (pDLayerParam->iVideoHeight >> 4);
+pWelsSvcRc->iSliceNum = pSliceCtx->iSliceNumInFrame;
+
+pWelsSvcRc->iRcVaryPercentage = _BITS_RANGE; // % -- for temp
+pWelsSvcRc->iRcVaryRatio = pWelsSvcRc->iRcVaryPercentage;
+
+pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
+
+pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
+QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) *
+pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
+pWelsSvcRc->iQpRangeLowerInFrame = (QP_RANGE_LOWER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
+QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) *
+pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
+
+if (iMbWidth <= MB_WIDTH_THRESHOLD_90P) {
+pWelsSvcRc->iSkipQpValue = SKIP_QP_90P;
+iGomRowMode0 = GOM_ROW_MODE0_90P;
+iGomRowMode1 = GOM_ROW_MODE1_90P;
+} else if (iMbWidth <= MB_WIDTH_THRESHOLD_180P) {
+pWelsSvcRc->iSkipQpValue = SKIP_QP_180P;
+iGomRowMode0 = GOM_ROW_MODE0_180P;
+iGomRowMode1 = GOM_ROW_MODE1_180P;
+} else if (iMbWidth <= MB_WIDTH_THRESHOLD_360P) {
+pWelsSvcRc->iSkipQpValue = SKIP_QP_360P;
+iGomRowMode0 = GOM_ROW_MODE0_360P;
+iGomRowMode1 = GOM_ROW_MODE1_360P;
+} else {
+pWelsSvcRc->iSkipQpValue = SKIP_QP_720P;
+iGomRowMode0 = GOM_ROW_MODE0_720P;
+iGomRowMode1 = GOM_ROW_MODE1_720P;
}
-
-
+iGomRowMode0 = iGomRowMode1 + ((iGomRowMode0 - iGomRowMode1) * pWelsSvcRc->iRcVaryRatio / MAX_BITS_VARY_PERCENTAGE);
+
+pWelsSvcRc->iNumberMbGom = iMbWidth * iGomRowMode0;
+
+pWelsSvcRc->iMinQp = GOM_MIN_QP_MODE;
+pWelsSvcRc->iMaxQp = GOM_MAX_QP_MODE;
+
+pWelsSvcRc->iFrameDeltaQpUpper = LAST_FRAME_QP_RANGE_UPPER_MODE1 - ((LAST_FRAME_QP_RANGE_UPPER_MODE1 -
+LAST_FRAME_QP_RANGE_UPPER_MODE0) * pWelsSvcRc->iRcVaryRatio / MAX_BITS_VARY_PERCENTAGE);
+pWelsSvcRc->iFrameDeltaQpLower = LAST_FRAME_QP_RANGE_LOWER_MODE1 - ((LAST_FRAME_QP_RANGE_LOWER_MODE1 -
+LAST_FRAME_QP_RANGE_LOWER_MODE0) * pWelsSvcRc->iRcVaryRatio / MAX_BITS_VARY_PERCENTAGE);
+
+pWelsSvcRc->iSkipFrameNum = 0;
+pWelsSvcRc->iGomSize = (pWelsSvcRc->iNumberMbFrame + pWelsSvcRc->iNumberMbGom - 1) / pWelsSvcRc->iNumberMbGom;
+
+
+RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pEncCtx->pSvcParam->sDependencyLayers[j].iHighestTemporalId);
+
+bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
+(SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
+(SM_DYN_SLICE == pDLayerParam->sSliceCfg.uiSliceMode));
+if (bMultiSliceMode)
+pWelsSvcRc->iNumberMbGom = pWelsSvcRc->iNumberMbFrame;
+}
+}
+
+
void RcInitTlWeight (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
- SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
- const int32_t kiDecompositionStages = pDLayerParam->iDecompositionStages;
- const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId;
-
- //Index 0:Virtual GOP size, Index 1:Frame rate
- //double WeightArray[4][4] = { {1.0, 0, 0, 0}, {0.6, 0.4, 0, 0}, {0.4, 0.3, 0.15, 0}, {0.25, 0.15, 0.125, 0.0875}};
- int32_t iWeightArray[4][4] = { {2000, 0, 0, 0}, {1200, 800, 0, 0}, {800, 600, 300, 0}, {500, 300, 250, 175}}; // original*WEIGHT_MULTIPLY
- const int32_t kiGopSize = (1 << kiDecompositionStages);
- int32_t i, k, n;
-
- n = 0;
- while (n <= kiHighestTid) {
- pTOverRc[n].iTlayerWeight = iWeightArray[kiDecompositionStages][n];
- ++ n;
- }
- //Calculate the frame index for the current frame and its reference frame
- for (n = 0; n < VGOP_SIZE; n += kiGopSize) {
- pWelsSvcRc->iTlOfFrames[n] = 0;
- for (i = 1; i <= kiDecompositionStages; i++) {
- for (k = 1 << (kiDecompositionStages - i); k < kiGopSize; k += (kiGopSize >> (i - 1))) {
- pWelsSvcRc->iTlOfFrames[k + n] = i;
- }
- }
- }
- pWelsSvcRc->iPreviousGopSize = kiGopSize;
- pWelsSvcRc->iGopNumberInVGop = VGOP_SIZE / kiGopSize;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
+SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
+const int32_t kiDecompositionStages = pDLayerParam->iDecompositionStages;
+const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId;
+
+//Index 0:Virtual GOP size, Index 1:Frame rate
+//double WeightArray[4][4] = { {1.0, 0, 0, 0}, {0.6, 0.4, 0, 0}, {0.4, 0.3, 0.15, 0}, {0.25, 0.15, 0.125, 0.0875}};
+int32_t iWeightArray[4][4] = { {2000, 0, 0, 0}, {1200, 800, 0, 0}, {800, 600, 300, 0}, {500, 300, 250, 175}}; // original*WEIGHT_MULTIPLY
+const int32_t kiGopSize = (1 << kiDecompositionStages);
+int32_t i, k, n;
+
+n = 0;
+while (n <= kiHighestTid) {
+pTOverRc[n].iTlayerWeight = iWeightArray[kiDecompositionStages][n];
+++ n;
}
-
+//Calculate the frame index for the current frame and its reference frame
+for (n = 0; n < VGOP_SIZE; n += kiGopSize) {
+pWelsSvcRc->iTlOfFrames[n] = 0;
+for (i = 1; i <= kiDecompositionStages; i++) {
+for (k = 1 << (kiDecompositionStages - i); k < kiGopSize; k += (kiGopSize >> (i - 1))) {
+pWelsSvcRc->iTlOfFrames[k + n] = i;
+}
+}
+}
+pWelsSvcRc->iPreviousGopSize = kiGopSize;
+pWelsSvcRc->iGopNumberInVGop = VGOP_SIZE / kiGopSize;
+}
+
void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
-
- SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
- SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
- const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
- const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
- int32_t input_iBitsPerFrame = WELS_ROUND (pDLayerParam->iSpatialBitrate * INT_MULTIPLY /
- pDLayerParamInternal->fInputFrameRate);
- const int32_t kiGopBits = WELS_DIV_ROUND (input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
- int32_t i;
-
- pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
- pWelsSvcRc->fFrameRate = pDLayerParamInternal->fInputFrameRate;
-
- int32_t iTargetVaryRange = FRAME_iTargetBits_VARY_RANGE * (MAX_BITS_VARY_PERCENTAGE - pWelsSvcRc->iRcVaryRatio);
- int32_t iMinBitsRatio = (MAX_BITS_VARY_PERCENTAGE) * INT_MULTIPLY - iTargetVaryRange;
- int32_t iMaxBitsRatio = (MAX_BITS_VARY_PERCENTAGE) * (INT_MULTIPLY + FRAME_iTargetBits_VARY_RANGE);
-
- for (i = 0; i <= kiHighestTid; i++) {
- const int64_t kdConstraitBits = kiGopBits * pTOverRc[i].iTlayerWeight;
- pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMinBitsRatio,
- INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
- pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMaxBitsRatio,
- INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
- }
- //When bitrate is changed, pBuffer size should be updated
- pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY);
- pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
-
- //change remaining bits
- if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH)
- pWelsSvcRc->iRemainingBits = pWelsSvcRc->iRemainingBits * input_iBitsPerFrame / pWelsSvcRc->iBitsPerFrame;
- pWelsSvcRc->iBitsPerFrame = input_iBitsPerFrame;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
+
+SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
+SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
+const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
+const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
+int32_t input_iBitsPerFrame = WELS_ROUND (pDLayerParam->iSpatialBitrate * INT_MULTIPLY /
+pDLayerParamInternal->fInputFrameRate);
+const int32_t kiGopBits = WELS_DIV_ROUND (input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
+int32_t i;
+
+pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
+pWelsSvcRc->fFrameRate = pDLayerParamInternal->fInputFrameRate;
+
+int32_t iTargetVaryRange = FRAME_iTargetBits_VARY_RANGE * (MAX_BITS_VARY_PERCENTAGE - pWelsSvcRc->iRcVaryRatio);
+int32_t iMinBitsRatio = (MAX_BITS_VARY_PERCENTAGE) * INT_MULTIPLY - iTargetVaryRange;
+int32_t iMaxBitsRatio = (MAX_BITS_VARY_PERCENTAGE) * (INT_MULTIPLY + FRAME_iTargetBits_VARY_RANGE);
+
+for (i = 0; i <= kiHighestTid; i++) {
+const int64_t kdConstraitBits = kiGopBits * pTOverRc[i].iTlayerWeight;
+pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMinBitsRatio,
+INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
+pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMaxBitsRatio,
+INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
}
-
-
+//When bitrate is changed, pBuffer size should be updated
+pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY);
+pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
+
+//change remaining bits
+if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH)
+pWelsSvcRc->iRemainingBits = pWelsSvcRc->iRemainingBits * input_iBitsPerFrame / pWelsSvcRc->iBitsPerFrame;
+pWelsSvcRc->iBitsPerFrame = input_iBitsPerFrame;
+}
+
+
void RcInitVGop (sWelsEncCtx* pEncCtx) {
- const int32_t kiDid = pEncCtx->uiDependencyId;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
- SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
- const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
-
- pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND (VGOP_SIZE * pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
- pWelsSvcRc->iRemainingWeights = pWelsSvcRc->iGopNumberInVGop * WEIGHT_MULTIPLY;
-
- pWelsSvcRc->iFrameCodedInVGop = 0;
- pWelsSvcRc->iGopIndexInVGop = 0;
-
- for (int32_t i = 0; i <= kiHighestTid; ++ i)
- pTOverRc[i].iGopBitsDq = 0;
- pWelsSvcRc->iSkipFrameInVGop = 0;
+const int32_t kiDid = pEncCtx->uiDependencyId;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
+SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
+const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
+
+pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND (VGOP_SIZE * pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
+pWelsSvcRc->iRemainingWeights = pWelsSvcRc->iGopNumberInVGop * WEIGHT_MULTIPLY;
+
+pWelsSvcRc->iFrameCodedInVGop = 0;
+pWelsSvcRc->iGopIndexInVGop = 0;
+
+for (int32_t i = 0; i <= kiHighestTid; ++ i)
+pTOverRc[i].iGopBitsDq = 0;
+pWelsSvcRc->iSkipFrameInVGop = 0;
}
-
+
void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) {
- const int32_t kiDid = pEncCtx->uiDependencyId;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
- SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
- SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[kiDid];
- SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
- const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
- int32_t i;
-
- //I frame R-Q Model
- pWelsSvcRc->iIntraComplexity = 0;
- pWelsSvcRc->iIntraMbCount = 0;
-
- //P frame R-Q Model
- for (i = 0; i <= kiHighestTid; i++) {
- pTOverRc[i].iPFrameNum = 0;
- pTOverRc[i].iLinearCmplx = 0;
- pTOverRc[i].iFrameCmplxMean = 0;
- }
-
- pWelsSvcRc->iBufferFullnessSkip = 0;
- pWelsSvcRc->iBufferFullnessPadding = 0;
-
- pWelsSvcRc->iGopIndexInVGop = 0;
- pWelsSvcRc->iRemainingBits = 0;
- pWelsSvcRc->iBitsPerFrame = 0;
-
- //Backup the initial bitrate and fps
- pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
- pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
-
- memset (pWelsSvcRc->pCurrentFrameGomSad, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
-
- RcInitTlWeight (pEncCtx);
- RcUpdateBitrateFps (pEncCtx);
- RcInitVGop (pEncCtx);
+const int32_t kiDid = pEncCtx->uiDependencyId;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
+SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
+SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[kiDid];
+SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
+const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
+int32_t i;
+
+//I frame R-Q Model
+pWelsSvcRc->iIntraComplexity = 0;
+pWelsSvcRc->iIntraMbCount = 0;
+
+//P frame R-Q Model
+for (i = 0; i <= kiHighestTid; i++) {
+pTOverRc[i].iPFrameNum = 0;
+pTOverRc[i].iLinearCmplx = 0;
+pTOverRc[i].iFrameCmplxMean = 0;
}
-
+
+pWelsSvcRc->iBufferFullnessSkip = 0;
+pWelsSvcRc->iBufferFullnessPadding = 0;
+
+pWelsSvcRc->iGopIndexInVGop = 0;
+pWelsSvcRc->iRemainingBits = 0;
+pWelsSvcRc->iBitsPerFrame = 0;
+
+//Backup the initial bitrate and fps
+pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
+pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
+
+memset (pWelsSvcRc->pCurrentFrameGomSad, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
+
+RcInitTlWeight (pEncCtx);
+RcUpdateBitrateFps (pEncCtx);
+RcInitVGop (pEncCtx);
+}
+
bool RcJudgeBitrateFpsUpdate (sWelsEncCtx* pEncCtx) {
- int32_t iCurDid = pEncCtx->uiDependencyId;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[iCurDid];
- SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[iCurDid];
- SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[iCurDid];
-
- if ((pWelsSvcRc->iPreviousBitrate != pDLayerParam->iSpatialBitrate) ||
- (pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) > EPSN ||
- (pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) < -EPSN) {
- pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
- pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
- return true;
- } else
- return false;
+int32_t iCurDid = pEncCtx->uiDependencyId;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[iCurDid];
+SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[iCurDid];
+SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[iCurDid];
+
+if ((pWelsSvcRc->iPreviousBitrate != pDLayerParam->iSpatialBitrate) ||
+(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) > EPSN ||
+(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) < -EPSN) {
+pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
+pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
+return true;
+} else
+return false;
}
-
+
#if GOM_TRACE_FLAG
void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) {
- const int32_t kiDid = pEncCtx->uiDependencyId;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
-
- if (pWelsSvcRc->iFrameCodedInVGop) {
- const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
- SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
- int32_t iVGopBitrate = 0;
- int32_t iTotalBits = pWelsSvcRc->iPaddingBitrateStat;
- int32_t iTid = 0;
- while (iTid <= kiHighestTid) {
- iTotalBits += pTOverRc[iTid].iGopBitsDq;
- ++ iTid;
- }
- int32_t iFrameInVGop = pWelsSvcRc->iFrameCodedInVGop + pWelsSvcRc->iSkipFrameInVGop;
- if (0 != iFrameInVGop)
- iVGopBitrate = WELS_ROUND (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate);
+const int32_t kiDid = pEncCtx->uiDependencyId;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
+
+if (pWelsSvcRc->iFrameCodedInVGop) {
+const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
+SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
+int32_t iVGopBitrate = 0;
+int32_t iTotalBits = pWelsSvcRc->iPaddingBitrateStat;
+int32_t iTid = 0;
+while (iTid <= kiHighestTid) {
+iTotalBits += pTOverRc[iTid].iGopBitsDq;
+++ iTid;
+}
+int32_t iFrameInVGop = pWelsSvcRc->iFrameCodedInVGop + pWelsSvcRc->iSkipFrameInVGop;
+if (0 != iFrameInVGop)
+iVGopBitrate = WELS_ROUND (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate);
#ifdef _TEST_TEMP_Rc_
- fprintf (fp_vgop, "%d\n", WELS_ROUND ((double)iTotalBits / iFrameInVGop));
+fprintf (fp_vgop, "%d\n", WELS_ROUND ((double)iTotalBits / iFrameInVGop));
#endif
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[Rc] VGOPbitrate%d: %d ", kiDid, iVGopBitrate);
- if (iTotalBits > 0) {
- iTid = 0;
- while (iTid <= kiHighestTid) {
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "T%d=%8.3f ", iTid, (double) (pTOverRc[iTid].iGopBitsDq / iTotalBits));
- ++ iTid;
- }
- }
- }
+WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[Rc] VGOPbitrate%d: %d ", kiDid, iVGopBitrate);
+if (iTotalBits > 0) {
+iTid = 0;
+while (iTid <= kiHighestTid) {
+WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "T%d=%8.3f ", iTid, (double) (pTOverRc[iTid].iGopBitsDq / iTotalBits));
+++ iTid;
}
+}
+}
+}
#endif
-
+
void RcUpdateTemporalZero (sWelsEncCtx* pEncCtx) {
- const int32_t kiDid = pEncCtx->uiDependencyId;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
- SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
- const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages);
-
- if (pWelsSvcRc->iPreviousGopSize != kiGopSize) {
+const int32_t kiDid = pEncCtx->uiDependencyId;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
+SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
+const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages);
+
+if (pWelsSvcRc->iPreviousGopSize != kiGopSize) {
#if GOM_TRACE_FLAG
- RcTraceVGopBitrate (pEncCtx);
+RcTraceVGopBitrate (pEncCtx);
#endif
- RcInitTlWeight (pEncCtx);
- RcInitVGop (pEncCtx);
- } else if (pWelsSvcRc->iGopIndexInVGop == pWelsSvcRc->iGopNumberInVGop || pEncCtx->eSliceType == I_SLICE) {
+RcInitTlWeight (pEncCtx);
+RcInitVGop (pEncCtx);
+} else if (pWelsSvcRc->iGopIndexInVGop == pWelsSvcRc->iGopNumberInVGop || pEncCtx->eSliceType == I_SLICE) {
#if GOM_TRACE_FLAG
- RcTraceVGopBitrate (pEncCtx);
+RcTraceVGopBitrate (pEncCtx);
#endif
- RcInitVGop (pEncCtx);
- }
- pWelsSvcRc->iGopIndexInVGop++;
+RcInitVGop (pEncCtx);
}
-
-
+pWelsSvcRc->iGopIndexInVGop++;
+}
+
+
void RcInitIdrQp (sWelsEncCtx* pEncCtx) {
- double dBpp = 0;
- int32_t i;
-
- //64k@6fps for 90p: bpp 0.74 QP:24
- //192k@12fps for 180p: bpp 0.28 QP:26
- //512k@24fps for 360p: bpp 0.09 QP:30
- //1500k@30fps for 720p: bpp 0.05 QP:32
- double dBppArray[4][3] = {{0.5, 0.75, 1.0}, {0.2, 0.3, 0.4}, {0.05, 0.09, 0.13}, {0.03, 0.06, 0.1}};
- int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}};
- int32_t iBppIndex = 0;
-
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
-
- if (pDLayerParam->fFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight)
- dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate * pDLayerParam->iVideoWidth *
- pDLayerParam->iVideoHeight);
- else
- dBpp = 0.1;
-
- //Area*2
- if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 28800) // 90p video:160*90
- iBppIndex = 0;
- else if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 115200) // 180p video:320*180
- iBppIndex = 1;
- else if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 460800) // 360p video:640*360
- iBppIndex = 2;
- else
- iBppIndex = 3;
-
- //Search
- for (i = 0; i < 3; i++) {
- if (dBpp <= dBppArray[iBppIndex][i])
- break;
- }
- pWelsSvcRc->iInitialQp = dInitialQPArray[iBppIndex][i];
- pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
- pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
- pWelsSvcRc->iQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp);
- pWelsSvcRc->iLastCalculatedQScale = pEncCtx->iGlobalQp;
+double dBpp = 0;
+int32_t i;
+
+//64k@6fps for 90p: bpp 0.74 QP:24
+//192k@12fps for 180p: bpp 0.28 QP:26
+//512k@24fps for 360p: bpp 0.09 QP:30
+//1500k@30fps for 720p: bpp 0.05 QP:32
+double dBppArray[4][3] = {{0.5, 0.75, 1.0}, {0.2, 0.3, 0.4}, {0.05, 0.09, 0.13}, {0.03, 0.06, 0.1}};
+int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}};
+int32_t iBppIndex = 0;
+
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
+
+if (pDLayerParam->fFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight)
+dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate * pDLayerParam->iVideoWidth *
+pDLayerParam->iVideoHeight);
+else
+dBpp = 0.1;
+
+//Area*2
+if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 28800) // 90p video:160*90
+iBppIndex = 0;
+else if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 115200) // 180p video:320*180
+iBppIndex = 1;
+else if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 460800) // 360p video:640*360
+iBppIndex = 2;
+else
+iBppIndex = 3;
+
+//Search
+for (i = 0; i < 3; i++) {
+if (dBpp <= dBppArray[iBppIndex][i])
+break;
}
-
+pWelsSvcRc->iInitialQp = dInitialQPArray[iBppIndex][i];
+pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
+pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
+pWelsSvcRc->iQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp);
+pWelsSvcRc->iLastCalculatedQScale = pEncCtx->iGlobalQp;
+}
+
void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- //obtain the idr qp using previous idr complexity
- if (pWelsSvcRc->iNumberMbFrame != pWelsSvcRc->iIntraMbCount) {
- pWelsSvcRc->iIntraComplexity = pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame /
- pWelsSvcRc->iIntraMbCount;
- }
- pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iIntraComplexity /
- pWelsSvcRc->iTargetBits);
- pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
- pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
- pWelsSvcRc->iQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp);
- pWelsSvcRc->iLastCalculatedQScale = pEncCtx->iGlobalQp;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+//obtain the idr qp using previous idr complexity
+if (pWelsSvcRc->iNumberMbFrame != pWelsSvcRc->iIntraMbCount) {
+pWelsSvcRc->iIntraComplexity = pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame /
+pWelsSvcRc->iIntraMbCount;
}
-
-
+pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iIntraComplexity /
+pWelsSvcRc->iTargetBits);
+pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
+pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
+pWelsSvcRc->iQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp);
+pWelsSvcRc->iLastCalculatedQScale = pEncCtx->iGlobalQp;
+}
+
+
void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- int32_t iTl = pEncCtx->uiTemporalId;
- SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];
- int32_t iLumaQp = 0;
-
- if (0 == pTOverRc->iPFrameNum) {
- iLumaQp = pWelsSvcRc->iInitialQp;
- } else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) {
- iLumaQp = MAX_LOW_BR_QP;
- //limit QP
- int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1;
- if (iLastIdxCodecInVGop < 0)
- iLastIdxCodecInVGop += VGOP_SIZE;
- int32_t iTlLast = pWelsSvcRc->iTlOfFrames[iLastIdxCodecInVGop];
- int32_t iDeltaQpTemporal = iTl - iTlLast;
- if (0 == iTlLast && iTl > 0)
- iDeltaQpTemporal += 3;
- else if (0 == iTl && iTlLast > 0)
- iDeltaQpTemporal -= 3;
-
- iLumaQp = WELS_CLIP3 (iLumaQp,
- pWelsSvcRc->iLastCalculatedQScale - pWelsSvcRc->iFrameDeltaQpLower + iDeltaQpTemporal,
- pWelsSvcRc->iLastCalculatedQScale + pWelsSvcRc->iFrameDeltaQpUpper + iDeltaQpTemporal);
- iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
-
- pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
- pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
-
- if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
- iLumaQp = WELS_CLIP3 ((iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) /
- INT_MULTIPLY, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
- }
-
- pEncCtx->iGlobalQp = iLumaQp;
-
- return;
- } else {
- int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
- pTOverRc->iFrameCmplxMean);
- iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
-
- pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
- iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
-
- //limit QP
- int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1;
- if (iLastIdxCodecInVGop < 0)
- iLastIdxCodecInVGop += VGOP_SIZE;
- int32_t iTlLast = pWelsSvcRc->iTlOfFrames[iLastIdxCodecInVGop];
- int32_t iDeltaQpTemporal = iTl - iTlLast;
- if (0 == iTlLast && iTl > 0)
- iDeltaQpTemporal += 3;
- else if (0 == iTl && iTlLast > 0)
- iDeltaQpTemporal -= 3;
-
- iLumaQp = WELS_CLIP3 (iLumaQp,
- pWelsSvcRc->iLastCalculatedQScale - pWelsSvcRc->iFrameDeltaQpLower + iDeltaQpTemporal,
- pWelsSvcRc->iLastCalculatedQScale + pWelsSvcRc->iFrameDeltaQpUpper + iDeltaQpTemporal);
- }
-
- iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
-
- pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
- pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+int32_t iTl = pEncCtx->uiTemporalId;
+SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];
+int32_t iLumaQp = 0;
+
+if (0 == pTOverRc->iPFrameNum) {
+iLumaQp = pWelsSvcRc->iInitialQp;
+} else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) {
+iLumaQp = MAX_LOW_BR_QP;
+//limit QP
+int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1;
+if (iLastIdxCodecInVGop < 0)
+iLastIdxCodecInVGop += VGOP_SIZE;
+int32_t iTlLast = pWelsSvcRc->iTlOfFrames[iLastIdxCodecInVGop];
+int32_t iDeltaQpTemporal = iTl - iTlLast;
+if (0 == iTlLast && iTl > 0)
+iDeltaQpTemporal += 3;
+else if (0 == iTl && iTlLast > 0)
+iDeltaQpTemporal -= 3;
+
+iLumaQp = WELS_CLIP3 (iLumaQp,
+pWelsSvcRc->iLastCalculatedQScale - pWelsSvcRc->iFrameDeltaQpLower + iDeltaQpTemporal,
+pWelsSvcRc->iLastCalculatedQScale + pWelsSvcRc->iFrameDeltaQpUpper + iDeltaQpTemporal);
+iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
+
+pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
+pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
+
+if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
+iLumaQp = WELS_CLIP3 ((iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) /
+INT_MULTIPLY, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
+}
+
+pEncCtx->iGlobalQp = iLumaQp;
+
+return;
+} else {
+int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
+pTOverRc->iFrameCmplxMean);
+iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
+
+pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
+iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
+
+//limit QP
+int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1;
+if (iLastIdxCodecInVGop < 0)
+iLastIdxCodecInVGop += VGOP_SIZE;
+int32_t iTlLast = pWelsSvcRc->iTlOfFrames[iLastIdxCodecInVGop];
+int32_t iDeltaQpTemporal = iTl - iTlLast;
+if (0 == iTlLast && iTl > 0)
+iDeltaQpTemporal += 3;
+else if (0 == iTl && iTlLast > 0)
+iDeltaQpTemporal -= 3;
+
+iLumaQp = WELS_CLIP3 (iLumaQp,
+pWelsSvcRc->iLastCalculatedQScale - pWelsSvcRc->iFrameDeltaQpLower + iDeltaQpTemporal,
+pWelsSvcRc->iLastCalculatedQScale + pWelsSvcRc->iFrameDeltaQpUpper + iDeltaQpTemporal);
+}
+
+iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
+
+pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
+pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
#ifndef _NOT_USE_AQ_FOR_TEST_
- if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
-
- iLumaQp = WELS_DIV_ROUND (iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp,
- INT_MULTIPLY);
-
- if (! ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) && (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
- iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
-
- }
+if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
+
+iLumaQp = WELS_DIV_ROUND (iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp,
+INT_MULTIPLY);
+
+if (! ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) && (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
+iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
+
+}
#endif
- pEncCtx->iGlobalQp = iLumaQp;
+pEncCtx->iGlobalQp = iLumaQp;
}
-
+
void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
- SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
- const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
- const int32_t kiBitsPerMb = WELS_DIV_ROUND (pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
-
- for (int32_t i = 0; i < kiSliceNum; i++) {
- pSOverRc->iStartMbSlice =
- pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i];
- pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1);
- pSOverRc->iTotalQpSlice = 0;
- pSOverRc->iTotalMbSlice = 0;
- pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY);
- pSOverRc->iFrameBitsSlice = 0;
- pSOverRc->iGomBitsSlice = 0;
- ++ pSOverRc;
- }
+SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
+const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
+const int32_t kiBitsPerMb = WELS_DIV_ROUND (pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
+
+for (int32_t i = 0; i < kiSliceNum; i++) {
+pSOverRc->iStartMbSlice =
+pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i];
+pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1);
+pSOverRc->iTotalQpSlice = 0;
+pSOverRc->iTotalMbSlice = 0;
+pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY);
+pSOverRc->iFrameBitsSlice = 0;
+pSOverRc->iGomBitsSlice = 0;
+++ pSOverRc;
}
-
+}
+
void RcDecideTargetBits (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId];
-
- pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL;
- //allocate bits
- if (pEncCtx->eSliceType == I_SLICE) {
- pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO, INT_MULTIPLY);
- } else {
- if (pWelsSvcRc->iRemainingWeights > pTOverRc->iTlayerWeight)
- pWelsSvcRc->iTargetBits = (int32_t) ((int64_t)pWelsSvcRc->iRemainingBits * pTOverRc->iTlayerWeight /
- pWelsSvcRc->iRemainingWeights);
- else //this case should be not hit. needs to more test case to verify this
- pWelsSvcRc->iTargetBits = pWelsSvcRc->iRemainingBits;
- if ((pWelsSvcRc->iTargetBits <= 0) && ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE)
- && (pEncCtx->pSvcParam->bEnableFrameSkip == false))) {
- pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED;
- }
- pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, pTOverRc->iMinBitsTl, pTOverRc->iMaxBitsTl);
- }
- pWelsSvcRc->iRemainingWeights -= pTOverRc->iTlayerWeight;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId];
+
+pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL;
+//allocate bits
+if (pEncCtx->eSliceType == I_SLICE) {
+pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO, INT_MULTIPLY);
+} else {
+if (pWelsSvcRc->iRemainingWeights > pTOverRc->iTlayerWeight)
+pWelsSvcRc->iTargetBits = (int32_t) ((int64_t)pWelsSvcRc->iRemainingBits * pTOverRc->iTlayerWeight /
+pWelsSvcRc->iRemainingWeights);
+else //this case should be not hit. needs to more test case to verify this
+pWelsSvcRc->iTargetBits = pWelsSvcRc->iRemainingBits;
+if ((pWelsSvcRc->iTargetBits <= 0) && ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE)
+&& (pEncCtx->pSvcParam->bEnableFrameSkip == false))) {
+pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED;
}
-
-
+pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, pTOverRc->iMinBitsTl, pTOverRc->iMaxBitsTl);
+}
+pWelsSvcRc->iRemainingWeights -= pTOverRc->iTlayerWeight;
+}
+
+
void RcInitGomParameters (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
- const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
- const int32_t kiGlobalQp = pEncCtx->iGlobalQp;
-
- pWelsSvcRc->iAverageFrameQp = 0;
- pWelsSvcRc->iMinFrameQp = 51;;
- pWelsSvcRc->iMaxFrameQp = 0;
- for (int32_t i = 0; i < kiSliceNum; ++i) {
- pSOverRc->iComplexityIndexSlice = 0;
- pSOverRc->iCalculatedQpSlice = kiGlobalQp;
- ++ pSOverRc;
- }
- memset (pWelsSvcRc->pGomComplexity, 0, pWelsSvcRc->iGomSize * sizeof (double));
- memset (pWelsSvcRc->pGomCost, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
+const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
+const int32_t kiGlobalQp = pEncCtx->iGlobalQp;
+
+pWelsSvcRc->iAverageFrameQp = 0;
+pWelsSvcRc->iMinFrameQp = 51;;
+pWelsSvcRc->iMaxFrameQp = 0;
+for (int32_t i = 0; i < kiSliceNum; ++i) {
+pSOverRc->iComplexityIndexSlice = 0;
+pSOverRc->iCalculatedQpSlice = kiGlobalQp;
+++ pSOverRc;
}
-
+memset (pWelsSvcRc->pGomComplexity, 0, pWelsSvcRc->iGomSize * sizeof (double));
+memset (pWelsSvcRc->pGomCost, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
+}
+
void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
- int32_t iLumaQp = pSOverRc->iCalculatedQpSlice;
- SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
- const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
+int32_t iLumaQp = pSOverRc->iCalculatedQpSlice;
+SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
+const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
#ifndef _NOT_USE_AQ_FOR_TEST_
- if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
- iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp +
- pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, 51);
- }
+if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
+iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp +
+pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, 51);
+}
#endif
- pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)];
- pCurMb->uiLumaQp = iLumaQp;
+pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)];
+pCurMb->uiLumaQp = iLumaQp;
}
-
+
SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = NULL, *pWelsSvcRc_Base = NULL;
- SSpatialLayerConfig* pDlpBase = NULL, *pDLayerParam = NULL;
- SSpatialLayerInternal* pDlpBaseInternal = NULL;
- if (pEncCtx->uiDependencyId <= 0)
- return NULL;
- pDlpBaseInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId - 1];
- pDlpBase = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId - 1];
- pWelsSvcRc_Base = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId - 1];
- if (pEncCtx->uiTemporalId <= pDlpBaseInternal->iDecompositionStages) {
- pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- pWelsSvcRc_Base = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId - 1];
- pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
- pDlpBase = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId - 1];
- if ((pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight / pWelsSvcRc->iNumberMbGom) ==
- (pDlpBase->iVideoWidth * pDlpBase->iVideoHeight / pWelsSvcRc_Base->iNumberMbGom))
- return pWelsSvcRc_Base;
- else
- return NULL;
- } else
- return NULL;
+SWelsSvcRc* pWelsSvcRc = NULL, *pWelsSvcRc_Base = NULL;
+SSpatialLayerConfig* pDlpBase = NULL, *pDLayerParam = NULL;
+SSpatialLayerInternal* pDlpBaseInternal = NULL;
+if (pEncCtx->uiDependencyId <= 0)
+return NULL;
+pDlpBaseInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId - 1];
+pDlpBase = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId - 1];
+pWelsSvcRc_Base = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId - 1];
+if (pEncCtx->uiTemporalId <= pDlpBaseInternal->iDecompositionStages) {
+pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+pWelsSvcRc_Base = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId - 1];
+pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
+pDlpBase = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId - 1];
+if ((pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight / pWelsSvcRc->iNumberMbGom) ==
+(pDlpBase->iVideoWidth * pDlpBase->iVideoHeight / pWelsSvcRc_Base->iNumberMbGom))
+return pWelsSvcRc_Base;
+else
+return NULL;
+} else
+return NULL;
}
-
+
void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SWelsSvcRc* pWelsSvcRc_Base = NULL;
- SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
-
- int32_t iAllocateBits = 0;
- int32_t iSumSad = 0;
- int32_t iLastGomIndex = 0;
- int32_t iLeftBits = 0;
- const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
- int32_t i;
-
- iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom;
- iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
-
- if (iLeftBits <= 0) {
- pSOverRc->iGomTargetBits = 0;
- return;
- } else if (kiComplexityIndex >= iLastGomIndex) {
- iAllocateBits = iLeftBits;
- } else {
- pWelsSvcRc_Base = RcJudgeBaseUsability (pEncCtx);
- pWelsSvcRc_Base = (pWelsSvcRc_Base) ? pWelsSvcRc_Base : pWelsSvcRc;
- for (i = kiComplexityIndex; i <= iLastGomIndex; i++) {
- iSumSad += pWelsSvcRc_Base->pCurrentFrameGomSad[i];
- }
- if (0 == iSumSad)
- iAllocateBits = WELS_DIV_ROUND (iLeftBits, (iLastGomIndex - kiComplexityIndex));
- else
- iAllocateBits = WELS_DIV_ROUND ((int64_t)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1],
- iSumSad);
-
- }
- pSOverRc->iGomTargetBits = iAllocateBits;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SWelsSvcRc* pWelsSvcRc_Base = NULL;
+SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
+
+int32_t iAllocateBits = 0;
+int32_t iSumSad = 0;
+int32_t iLastGomIndex = 0;
+int32_t iLeftBits = 0;
+const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
+int32_t i;
+
+iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom;
+iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
+
+if (iLeftBits <= 0) {
+pSOverRc->iGomTargetBits = 0;
+return;
+} else if (kiComplexityIndex >= iLastGomIndex) {
+iAllocateBits = iLeftBits;
+} else {
+pWelsSvcRc_Base = RcJudgeBaseUsability (pEncCtx);
+pWelsSvcRc_Base = (pWelsSvcRc_Base) ? pWelsSvcRc_Base : pWelsSvcRc;
+for (i = kiComplexityIndex; i <= iLastGomIndex; i++) {
+iSumSad += pWelsSvcRc_Base->pCurrentFrameGomSad[i];
}
-
-
-
+if (0 == iSumSad)
+iAllocateBits = WELS_DIV_ROUND (iLeftBits, (iLastGomIndex - kiComplexityIndex));
+else
+iAllocateBits = WELS_DIV_ROUND ((int64_t)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1],
+iSumSad);
+
+}
+pSOverRc->iGomTargetBits = iAllocateBits;
+}
+
+
+
void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId];
- int64_t iBitsRatio = 1;
-
- int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
- int64_t iTargetLeftBits = iLeftBits + pSOverRc->iGomBitsSlice - pSOverRc->iGomTargetBits;
-
- if (iLeftBits <= 0) {
- pSOverRc->iCalculatedQpSlice += 2;
- } else {
- //globe decision
- iBitsRatio = 10000 * iLeftBits / (iTargetLeftBits + 1);
- if (iBitsRatio < 8409) //2^(-1.5/6)*10000
- pSOverRc->iCalculatedQpSlice += 2;
- else if (iBitsRatio < 9439) //2^(-0.5/6)*10000
- pSOverRc->iCalculatedQpSlice += 1;
- else if (iBitsRatio > 10600) //2^(0.5/6)*10000
- pSOverRc->iCalculatedQpSlice -= 1;
- else if (iBitsRatio > 11900) //2^(1.5/6)*10000
- pSOverRc->iCalculatedQpSlice -= 2;
- }
-
- pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice,
- pEncCtx->iGlobalQp - pWelsSvcRc->iQpRangeLowerInFrame, pEncCtx->iGlobalQp + pWelsSvcRc->iQpRangeUpperInFrame);
- if (! ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) && (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
- pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
-
- pSOverRc->iGomBitsSlice = 0;
-
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId];
+int64_t iBitsRatio = 1;
+
+int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
+int64_t iTargetLeftBits = iLeftBits + pSOverRc->iGomBitsSlice - pSOverRc->iGomTargetBits;
+
+if (iLeftBits <= 0) {
+pSOverRc->iCalculatedQpSlice += 2;
+} else {
+//globe decision
+iBitsRatio = 10000 * iLeftBits / (iTargetLeftBits + 1);
+if (iBitsRatio < 8409) //2^(-1.5/6)*10000
+pSOverRc->iCalculatedQpSlice += 2;
+else if (iBitsRatio < 9439) //2^(-0.5/6)*10000
+pSOverRc->iCalculatedQpSlice += 1;
+else if (iBitsRatio > 10600) //2^(0.5/6)*10000
+pSOverRc->iCalculatedQpSlice -= 1;
+else if (iBitsRatio > 11900) //2^(1.5/6)*10000
+pSOverRc->iCalculatedQpSlice -= 2;
}
-
+
+pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice,
+pEncCtx->iGlobalQp - pWelsSvcRc->iQpRangeLowerInFrame, pEncCtx->iGlobalQp + pWelsSvcRc->iQpRangeUpperInFrame);
+if (! ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) && (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
+pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
+
+pSOverRc->iGomBitsSlice = 0;
+
+}
+
void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
- const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
- //condition 1: whole pBuffer fullness
- pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
- //condition 2: VGOP bits constraint
- int32_t iVGopBitsPred = 0;
- for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
- iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl;
- iVGopBitsPred -= pWelsSvcRc->iRemainingBits;
- double dIncPercent = iVGopBitsPred * 100.0 * INT_MULTIPLY / (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE) -
- (double)VGOP_BITS_PERCENTAGE_DIFF;
-
- if ((pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip
- && pWelsSvcRc->iAverageFrameQp > pWelsSvcRc->iSkipQpValue)
- || (dIncPercent > pWelsSvcRc->iRcVaryPercentage)) {
- pEncCtx->iSkipFrameFlag = 1;
- pWelsSvcRc->iBufferFullnessSkip = pWelsSvcRc->iBufferFullnessSkip - kiOutputBits;
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
- }
-
- pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
-
- if (pEncCtx->iSkipFrameFlag == 1) {
- pWelsSvcRc->iRemainingBits += kiOutputBits;
- pWelsSvcRc->iSkipFrameNum++;
- pWelsSvcRc->iSkipFrameInVGop++;
- }
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
+const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
+//condition 1: whole pBuffer fullness
+pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
+WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %3d", pWelsSvcRc->iBufferFullnessSkip);
+//condition 2: VGOP bits constraint
+int32_t iVGopBitsPred = 0;
+for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
+iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl;
+iVGopBitsPred -= pWelsSvcRc->iRemainingBits;
+double dIncPercent = iVGopBitsPred * 100.0 * INT_MULTIPLY / (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE) -
+(double)VGOP_BITS_PERCENTAGE_DIFF;
+
+if ((pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip
+&& pWelsSvcRc->iAverageFrameQp > pWelsSvcRc->iSkipQpValue)
+|| (dIncPercent > pWelsSvcRc->iRcVaryPercentage)) {
+pEncCtx->iSkipFrameFlag = 1;
+pWelsSvcRc->iBufferFullnessSkip = pWelsSvcRc->iBufferFullnessSkip - kiOutputBits;
+WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %3d", pWelsSvcRc->iBufferFullnessSkip);
}
-
+
+pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
+
+if (pEncCtx->iSkipFrameFlag == 1) {
+pWelsSvcRc->iRemainingBits += kiOutputBits;
+pWelsSvcRc->iSkipFrameNum++;
+pWelsSvcRc->iSkipFrameInVGop++;
+}
+}
+
void WelsRcFrameDelayJudge (void* pCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
- sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
- SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
-
- int32_t iSentBits = WELS_ROUND (pDLayerParam->iSpatialBitrate / pDLayerParamInternal->fOutputFrameRate);
-
- pWelsSvcRc->bSkipFlag = false;
- if (pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip) {
- pWelsSvcRc->bSkipFlag = true;
- pWelsSvcRc->iSkipFrameNum++;
- pWelsSvcRc->iSkipFrameInVGop++;
- pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
- pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
- }
+sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
+SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
+
+int32_t iSentBits = WELS_ROUND (pDLayerParam->iSpatialBitrate / pDLayerParamInternal->fOutputFrameRate);
+
+pWelsSvcRc->bSkipFlag = false;
+if (pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip) {
+pWelsSvcRc->bSkipFlag = true;
+pWelsSvcRc->iSkipFrameNum++;
+pWelsSvcRc->iSkipFrameInVGop++;
+pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
+WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %3d", pWelsSvcRc->iBufferFullnessSkip);
+pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
}
-
+}
+
void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
- const int32_t kiBufferThreshold = WELS_DIV_ROUND (PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding), INT_MULTIPLY);
-
- pWelsSvcRc->iBufferFullnessPadding += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
-
- if (pWelsSvcRc->iBufferFullnessPadding < kiBufferThreshold) {
- pWelsSvcRc->iPaddingSize = -pWelsSvcRc->iBufferFullnessPadding;
- pWelsSvcRc->iPaddingSize >>= 3; // /8
- pWelsSvcRc->iBufferFullnessPadding = 0;
- } else
- pWelsSvcRc->iPaddingSize = 0;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
+const int32_t kiBufferThreshold = WELS_DIV_ROUND (PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding), INT_MULTIPLY);
+
+pWelsSvcRc->iBufferFullnessPadding += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
+
+if (pWelsSvcRc->iBufferFullnessPadding < kiBufferThreshold) {
+pWelsSvcRc->iPaddingSize = -pWelsSvcRc->iBufferFullnessPadding;
+pWelsSvcRc->iPaddingSize >>= 3; // /8
+pWelsSvcRc->iBufferFullnessPadding = 0;
+} else
+pWelsSvcRc->iPaddingSize = 0;
}
-
-
+
+
void RcTraceFrameBits (void* pCtx, long long uiTimeStamp) {
- sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
-
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
- "[Rc] Frame timestamp = %8d, Frame type =%d, encoding_qp%d, average qp = %3d, max qp = %3d, min qp = %3d, index = %8d,\
+sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+
+WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
+"[Rc] Frame timestamp = %8d, Frame type =%d, encoding_qp%d, average qp = %3d, max qp = %3d, min qp = %3d, index = %8d,\
iTid = %1d, used = %8d, bitsperframe = %8d, target = %8d, remaingbits = %8d, skipbuffersize = %8d",
- (uint32_t)uiTimeStamp,pEncCtx->eSliceType, pEncCtx->uiDependencyId, pWelsSvcRc->iAverageFrameQp,pWelsSvcRc->iMaxFrameQp,pWelsSvcRc->iMinFrameQp,
- pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits,WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY),
- pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
-
+(uint32_t)uiTimeStamp, pEncCtx->eSliceType, pEncCtx->uiDependencyId, pWelsSvcRc->iAverageFrameQp,
+pWelsSvcRc->iMaxFrameQp, pWelsSvcRc->iMinFrameQp,
+pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits, WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame,
+INT_MULTIPLY),
+pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
+
}
-
+
void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
- SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx;
- int32_t iTotalQp = 0, iTotalMb = 0;
- int32_t i;
-
- if (pEncCtx->eSliceType == P_SLICE) {
- for (i = 0; i < pCurSliceCtx->iSliceNumInFrame; i++) {
- iTotalQp += pSOverRc->iTotalQpSlice;
- iTotalMb += pSOverRc->iTotalMbSlice;
- ++ pSOverRc;
- }
- if (iTotalMb > 0)
- pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND (INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY);
- else
- pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
- } else {
- pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
- }
- pWelsSvcRc->iFrameDqBits = iCodedBits;
- pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId].iGopBitsDq += pWelsSvcRc->iFrameDqBits;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
+SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx;
+int32_t iTotalQp = 0, iTotalMb = 0;
+int32_t i;
+
+if (pEncCtx->eSliceType == P_SLICE) {
+for (i = 0; i < pCurSliceCtx->iSliceNumInFrame; i++) {
+iTotalQp += pSOverRc->iTotalQpSlice;
+iTotalMb += pSOverRc->iTotalMbSlice;
+++ pSOverRc;
}
-
+if (iTotalMb > 0)
+pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND (INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY);
+else
+pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
+} else {
+pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
+}
+pWelsSvcRc->iFrameDqBits = iCodedBits;
+pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId].iGopBitsDq += pWelsSvcRc->iFrameDqBits;
+}
+
void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
- if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
-
- int64_t iIntraCmplx = pWelsSvcRc->iQStep * pWelsSvcRc->iFrameDqBits;
- pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
- iIntraCmplx), INT_MULTIPLY);
- pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
-
- pWelsSvcRc->iIdrNum++;
- if (pWelsSvcRc->iIdrNum > 255)
- pWelsSvcRc->iIdrNum = 255;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
+if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
+
+int64_t iIntraCmplx = pWelsSvcRc->iQStep * pWelsSvcRc->iFrameDqBits;
+pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
+iIntraCmplx), INT_MULTIPLY);
+pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
+
+pWelsSvcRc->iIdrNum++;
+if (pWelsSvcRc->iIdrNum > 255)
+pWelsSvcRc->iIdrNum = 255;
}
-
+
void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- const int32_t kiTl = pEncCtx->uiTemporalId;
- SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
-
- if (0 == pTOverRc->iPFrameNum) {
- pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep;
- } else {
- pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
- + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)),
- INT_MULTIPLY);
- }
- int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
- if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
- iAlpha = SMOOTH_FACTOR_MIN_VALUE;
- pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
- pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
-
- pTOverRc->iPFrameNum++;
- if (pTOverRc->iPFrameNum > 255)
- pTOverRc->iPFrameNum = 255;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+const int32_t kiTl = pEncCtx->uiTemporalId;
+SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
+
+if (0 == pTOverRc->iPFrameNum) {
+pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep;
+} else {
+pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
++ (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)),
+INT_MULTIPLY);
}
-
+int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
+if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
+iAlpha = SMOOTH_FACTOR_MIN_VALUE;
+pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
+pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
+
+pTOverRc->iPFrameNum++;
+if (pTOverRc->iPFrameNum > 255)
+pTOverRc->iPFrameNum = 255;
+}
+
int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
- int32_t iTemporalQp = 0;
- if (pEncCtx->pSvcParam->iDecompStages) {
- if (pEncCtx->uiTemporalId == 0)
- iTemporalQp = iQp - 3 - (pEncCtx->pSvcParam->iDecompStages - 1);
- else
- iTemporalQp = iQp - (pEncCtx->pSvcParam->iDecompStages - pEncCtx->uiTemporalId);
- iTemporalQp = WELS_CLIP3 (iTemporalQp, 1, 51);
- } else
- iTemporalQp = iQp;
- return iTemporalQp;
+int32_t iTemporalQp = 0;
+if (pEncCtx->pSvcParam->iDecompStages) {
+if (pEncCtx->uiTemporalId == 0)
+iTemporalQp = iQp - 3 - (pEncCtx->pSvcParam->iDecompStages - 1);
+else
+iTemporalQp = iQp - (pEncCtx->pSvcParam->iDecompStages - pEncCtx->uiTemporalId);
+iTemporalQp = WELS_CLIP3 (iTemporalQp, 1, 51);
+} else
+iTemporalQp = iQp;
+return iTemporalQp;
}
-
+
void WelsRcPictureInitGom (void* pCtx) {
- sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
-
- if (pEncCtx->eSliceType == I_SLICE) {
- if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed
- RcInitRefreshParameter (pEncCtx);
- }
- }
- if (RcJudgeBitrateFpsUpdate (pEncCtx)) {
- RcUpdateBitrateFps (pEncCtx);
- }
- if (pEncCtx->uiTemporalId == 0) {
- RcUpdateTemporalZero (pEncCtx);
- }
- RcDecideTargetBits (pEncCtx);
- //decide globe_qp
- if (pEncCtx->eSliceType == I_SLICE) {
- if (0 == pWelsSvcRc->iIdrNum)
- RcInitIdrQp (pEncCtx);
- else {
- RcCalculateIdrQp (pEncCtx);
- }
- } else {
- RcCalculatePictureQp (pEncCtx);
- }
- RcInitSliceInformation (pEncCtx);
- RcInitGomParameters (pEncCtx);
-
+sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+
+if (pEncCtx->eSliceType == I_SLICE) {
+if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed
+RcInitRefreshParameter (pEncCtx);
}
-
-
-
+}
+if (RcJudgeBitrateFpsUpdate (pEncCtx)) {
+RcUpdateBitrateFps (pEncCtx);
+}
+if (pEncCtx->uiTemporalId == 0) {
+RcUpdateTemporalZero (pEncCtx);
+}
+RcDecideTargetBits (pEncCtx);
+//decide globe_qp
+if (pEncCtx->eSliceType == I_SLICE) {
+if (0 == pWelsSvcRc->iIdrNum)
+RcInitIdrQp (pEncCtx);
+else {
+RcCalculateIdrQp (pEncCtx);
+}
+} else {
+RcCalculatePictureQp (pEncCtx);
+}
+RcInitSliceInformation (pEncCtx);
+RcInitGomParameters (pEncCtx);
+
+}
+
+
+
void WelsRcPictureInfoUpdateGom (void* pCtx, int32_t iLayerSize) {
- sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
- SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- int32_t iCodedBits = (iLayerSize << 3);
-
- RcUpdatePictureQpBits (pEncCtx, iCodedBits);
-
- if (pEncCtx->eSliceType == P_SLICE) {
- RcUpdateFrameComplexity (pEncCtx);
- } else {
- RcUpdateIntraComplexity (pEncCtx);
- }
- pWelsSvcRc->iRemainingBits -= pWelsSvcRc->iFrameDqBits;
-
- if (pEncCtx->pSvcParam->bEnableFrameSkip /*&&
+sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
+SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
+int32_t iCodedBits = (iLayerSize << 3);
+
+RcUpdatePictureQpBits (pEncCtx, iCodedBits);
+
+if (pEncCtx->eSliceType == P_SLICE) {
+RcUpdateFrameComplexity (pEncCtx);
+} else {
+RcUpdateIntraComplexity (pEncCtx);
+}
+pWelsSvcRc->iRemainingBits -= pWelsSvcRc->iFrameDqBits;
+
+if (pEncCtx->pSvcParam->bEnableFrameSkip /*&&
pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iSpatialLayerNum - 1*/) {
- RcVBufferCalculationSkip (pEncCtx);
- }
+RcVBufferCalculationSkip (pEncCtx);
+}
- if (pEncCtx->pSvcParam->iPaddingFlag)
- RcVBufferCalculationPadding (pEncCtx);
- pWelsSvcRc->iFrameCodedInVGop++;
+if (pEncCtx->pSvcParam->iPaddingFlag)
+ RcVBufferCalculationPadding (pEncCtx);
+pWelsSvcRc->iFrameCodedInVGop++;
#ifdef _TEST_TEMP_Rc_
- fprintf (fp_test_rc, "%d\n", pWelsSvcRc->iFrameDqBits);
- if (pEncCtx->iSkipFrameFlag)
- fprintf (fp_test_rc, "0\n");
- fflush (fp_test_rc);
+fprintf (fp_test_rc, "%d\n", pWelsSvcRc->iFrameDqBits);
+if (pEncCtx->iSkipFrameFlag)
+ fprintf (fp_test_rc, "0\n");
+fflush (fp_test_rc);
#endif
}
@@ -955,8 +957,8 @@
pWelsSvcRc->pGomCost[kiComplexityIndex] += iCostLuma;
- pWelsSvcRc->iMinFrameQp = WELS_MIN(pWelsSvcRc->iMinFrameQp,pCurMb->uiLumaQp);
- pWelsSvcRc->iMaxFrameQp = WELS_MAX(pWelsSvcRc->iMaxFrameQp,pCurMb->uiLumaQp);
+ pWelsSvcRc->iMinFrameQp = WELS_MIN (pWelsSvcRc->iMinFrameQp, pCurMb->uiLumaQp);
+ pWelsSvcRc->iMaxFrameQp = WELS_MAX (pWelsSvcRc->iMaxFrameQp, pCurMb->uiLumaQp);
if (iCurMbBits > 0) {
pSOverRc->iTotalQpSlice += pCurMb->uiLumaQp;
pSOverRc->iTotalMbSlice++;
@@ -1054,7 +1056,7 @@
pEncCtx->iGlobalQp = WELS_CLIP3 (iQp, MIN_IDR_QP, MAX_IDR_QP);
} else {
int32_t iTargetBits = WELS_ROUND (((float)iBitRate / pDLayerConfig->fFrameRate)); //iBitRate / 10;
- int32_t iQstep = (int32_t)(WELS_DIV_ROUND64 (iFrameCplx * pWelsSvcRc->iAvgCost2Bits, iTargetBits));
+ int32_t iQstep = (int32_t) (WELS_DIV_ROUND64 (iFrameCplx * pWelsSvcRc->iAvgCost2Bits, iTargetBits));
int32_t iQp = RcConvertQStep2Qp (iQstep);
iDeltaQp = iQp - iBaseQp;
if (pWelsSvcRc->iBufferFullnessSkip > iBitRate) {
@@ -1108,7 +1110,7 @@
iSentBits = WELS_MAX (iSentBits, 0);
const int32_t iVbufferThRatio = (eFrameType == videoFrameTypeI
- || eFrameType == videoFrameTypeIDR) ? VIRTUAL_BUFFER_HIGH_TH : VIRTUAL_BUFFER_LOW_TH;
+ || eFrameType == videoFrameTypeIDR) ? VIRTUAL_BUFFER_HIGH_TH : VIRTUAL_BUFFER_LOW_TH;
const int32_t iVbufferTh = WELS_DIV_ROUND ((((int64_t)iBitRate) * iVbufferThRatio), INT_MULTIPLY);
pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
@@ -1120,7 +1122,9 @@
}
if (pWelsSvcRc->bSkipFlag) {
pWelsSvcRc->iSkipFrameNum++;
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "SCC iSkipFrameNum = %d,buffer = %d,threadhold = %d,bitrate = %d,timestamp=%lld\n", pWelsSvcRc->iSkipFrameNum,pWelsSvcRc->iBufferFullnessSkip,iVbufferTh,iBitRate,uiTimeStamp);
+ WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO,
+ "SCC iSkipFrameNum = %d,buffer = %d,threadhold = %d,bitrate = %d,timestamp=%lld\n", pWelsSvcRc->iSkipFrameNum,
+ pWelsSvcRc->iBufferFullnessSkip, iVbufferTh, iBitRate, uiTimeStamp);
}
pWelsSvcRc->uiLastTimeStamp = uiTimeStamp;
}
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -71,7 +71,7 @@
for (i = 0; i < pCtx->pSvcParam->iLTRRefNum + 1; i++)
pRefList->pLongRefList[i] = NULL;
for (i = 0; i < pCtx->pSvcParam->iNumRefFrame + 1; i++)
- pRefList->pRef[i]->SetUnref ();
+ pRefList->pRef[i]->SetUnref();
pRefList->uiLongRefCount = 0;
pRefList->uiShortRefCount = 0;
@@ -106,7 +106,7 @@
SPicture* pRef = pRefList->pLongRefList[i];
if (pRef != NULL && pRef->bUsedAsRef && pRef->bIsLongRef && (!pRef->bIsSceneLTR) &&
(pCtx->uiTemporalId < pRef->uiTemporalId || pCtx->bCurFrameMarkedAsSceneLtr)) {
- pRef->SetUnref ();
+ pRef->SetUnref();
DeleteLTRFromLongList (pCtx, i);
i--;
}
@@ -162,7 +162,7 @@
iMaxFrameNumPlus1) & (FRAME_NUM_EQUAL | FRAME_NUM_SMALLER))) {
WelsLog (pLogCtx, WELS_LOG_WARNING, "LTR ,invalid LTR delete ,long_term_idx = %d , iFrameNum =%d ",
pLongRefList[i]->iLongTermPicNum, pLongRefList[i]->iFrameNum);
- pLongRefList[i]->SetUnref ();
+ pLongRefList[i]->SetUnref();
DeleteLTRFromLongList (pCtx, i);
pLtr->bLTRMarkEnable = true;
if (pRefList->uiLongRefCount == 0) {
@@ -175,7 +175,7 @@
&& pLtr->iLTRMarkMode == LTR_DELAY_MARK) {
WelsLog (pLogCtx, WELS_LOG_WARNING, "LTR ,iMarkFrameNum invalid LTR delete ,long_term_idx = %d , iFrameNum =%d ",
pLongRefList[i]->iLongTermPicNum, pLongRefList[i]->iFrameNum);
- pLongRefList[i]->SetUnref ();
+ pLongRefList[i]->SetUnref();
DeleteLTRFromLongList (pCtx, i);
pLtr->bLTRMarkEnable = true;
if (pRefList->uiLongRefCount == 0) {
@@ -211,7 +211,7 @@
for (j = 0; j < pRefList->uiLongRefCount; j++) {
if (pLongRefList[j]->iLongTermPicNum != pLtr->iCurLtrIdx) {
- pLongRefList[j]->SetUnref ();
+ pLongRefList[j]->SetUnref();
DeleteLTRFromLongList (pCtx, j);
}
}
@@ -228,7 +228,7 @@
} else if (pLtr->uiLtrMarkState == LTR_MARKING_FAILED) {
for (i = 0; i < pRefList->uiLongRefCount; i++) {
if (pLongRefList[i]->iFrameNum == pLtr->iLtrMarkFbFrameNum) {
- pLongRefList[i]->SetUnref ();
+ pLongRefList[i]->SetUnref();
DeleteLTRFromLongList (pCtx, i);
break;
}
@@ -297,7 +297,7 @@
pLongRefList[0] = pShortRefList[i];
pRefList->uiLongRefCount++;
if (pRefList->uiLongRefCount > pCtx->pSvcParam->iLTRRefNum) {
- pRefList->pLongRefList[pRefList->uiLongRefCount - 1]->SetUnref ();
+ pRefList->pLongRefList[pRefList->uiLongRefCount - 1]->SetUnref();
DeleteLTRFromLongList (pCtx, pRefList->uiLongRefCount - 1);
}
DeleteSTRFromShortList (pCtx, i);
@@ -311,7 +311,7 @@
pCtx->pVaa->uiMarkLongTermPicIdx = pCtx->pDecPic->iLongTermPicNum;
if (pLongRefList[iLtrIdx] != NULL) {
- pLongRefList[iLtrIdx]->SetUnref ();
+ pLongRefList[iLtrIdx]->SetUnref();
DeleteLTRFromLongList (pCtx, iLtrIdx);
}
pLongRefList[iLtrIdx] = pCtx->pDecPic;
@@ -334,7 +334,7 @@
if (pRefList->pNextBuffer == NULL && pRefList->uiShortRefCount > 0) {
pRefList->pNextBuffer = pRefList->pShortRefList[pRefList->uiShortRefCount - 1];
- pRefList->pNextBuffer->SetUnref ();
+ pRefList->pNextBuffer->SetUnref();
}
pCtx->pDecPic = pRefList->pNextBuffer;
@@ -398,12 +398,12 @@
}
for (i = pRefList->uiShortRefCount - 1; i > 0; i--) {
- pRefList->pShortRefList[i]->SetUnref ();
+ pRefList->pShortRefList[i]->SetUnref();
DeleteSTRFromShortList (pCtx, i);
}
if (pRefList->uiShortRefCount > 0 && (pRefList->pShortRefList[0]->uiTemporalId > 0
|| pRefList->pShortRefList[0]->iFrameNum != pCtx->iFrameNum)) {
- pRefList->pShortRefList[0]->SetUnref ();
+ pRefList->pShortRefList[0]->SetUnref();
DeleteSTRFromShortList (pCtx, 0);
}
}
@@ -698,7 +698,8 @@
//update info in src list
UpdateOriginalPicInfo (pCtx->pEncPic, pCtx->pDecPic);
PrefetchNextBuffer (pCtx);
- pCtx->pVpp->UpdateSrcListLosslessScreenRefSelectionWithLtr (pCtx->pEncPic, iDIdx, pCtx->pVaa->uiMarkLongTermPicIdx, pCtx->ppRefPicListExt[iDIdx]->pLongRefList);
+ pCtx->pVpp->UpdateSrcListLosslessScreenRefSelectionWithLtr (pCtx->pEncPic, iDIdx, pCtx->pVaa->uiMarkLongTermPicIdx,
+ pCtx->ppRefPicListExt[iDIdx]->pLongRefList);
}
static void UpdateSrcPicList (void* pEncCtx) {
@@ -707,7 +708,8 @@
//update info in src list
UpdateOriginalPicInfo (pCtx->pEncPic, pCtx->pDecPic);
PrefetchNextBuffer (pCtx);
- pCtx->pVpp->UpdateSrcList (pCtx->pEncPic, iDIdx, pCtx->ppRefPicListExt[iDIdx]->pShortRefList, pCtx->ppRefPicListExt[iDIdx]->uiShortRefCount);
+ pCtx->pVpp->UpdateSrcList (pCtx->pEncPic, iDIdx, pCtx->ppRefPicListExt[iDIdx]->pShortRefList,
+ pCtx->ppRefPicListExt[iDIdx]->uiShortRefCount);
}
bool WelsUpdateRefListScreen (void* pEncCtx) {
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -1195,7 +1195,8 @@
*ppPic2 = tmp;
}
-void CWelsPreProcess::UpdateSrcListLosslessScreenRefSelectionWithLtr (SPicture* pCurPicture, const int32_t kiCurDid, const int32_t kuiMarkLongTermPicIdx, SPicture** pLongRefList) {
+void CWelsPreProcess::UpdateSrcListLosslessScreenRefSelectionWithLtr (SPicture* pCurPicture, const int32_t kiCurDid,
+ const int32_t kuiMarkLongTermPicIdx, SPicture** pLongRefList) {
SPicture** pLongRefSrcList = &m_pSpatialPic[kiCurDid][0];
for (int32_t i = 0; i < MAX_REF_PIC_COUNT; ++i) {
if (NULL == pLongRefSrcList[i + 1] || (NULL != pLongRefList[i] && pLongRefList[i]->bUsedAsRef
@@ -1202,23 +1203,24 @@
&& pLongRefList[i]->bIsLongRef)) {
continue;
} else {
- pLongRefSrcList[i + 1]->SetUnref ();
+ pLongRefSrcList[i + 1]->SetUnref();
}
}
WelsExchangeSpatialPictures (&m_pSpatialPic[kiCurDid][0],
&m_pSpatialPic[kiCurDid][1 + kuiMarkLongTermPicIdx]);
m_iAvaliableRefInSpatialPicList = MAX_REF_PIC_COUNT;
- (GetCurrentFrameFromOrigList(kiCurDid))->SetUnref ();
+ (GetCurrentFrameFromOrigList (kiCurDid))->SetUnref();
}
-void CWelsPreProcess::UpdateSrcList (SPicture* pCurPicture, const int32_t kiCurDid, SPicture** pShortRefList, const uint32_t kuiShortRefCount) {
+void CWelsPreProcess::UpdateSrcList (SPicture* pCurPicture, const int32_t kiCurDid, SPicture** pShortRefList,
+ const uint32_t kuiShortRefCount) {
SPicture** pRefSrcList = &m_pSpatialPic[kiCurDid][0];
//pRefSrcList[0] is for current frame
if (pCurPicture->bUsedAsRef || pCurPicture->bIsLongRef) {
- if (pCurPicture->iPictureType == P_SLICE && pCurPicture->uiTemporalId != 0 ) {
+ if (pCurPicture->iPictureType == P_SLICE && pCurPicture->uiTemporalId != 0) {
for (int iRefIdx = kuiShortRefCount - 1; iRefIdx >= 0; --iRefIdx) {
WelsExchangeSpatialPictures (&pRefSrcList[iRefIdx + 1],
- &pRefSrcList[iRefIdx]);
+ &pRefSrcList[iRefIdx]);
}
m_iAvaliableRefInSpatialPicList = kuiShortRefCount;
} else {
@@ -1225,13 +1227,13 @@
WelsExchangeSpatialPictures (&pRefSrcList[0], &pRefSrcList[1]);
for (int32_t i = MAX_SHORT_REF_COUNT - 1; i > 0 ; --i) {
if (pRefSrcList[i + 1] != NULL) {
- pRefSrcList[i + 1]->SetUnref ();
+ pRefSrcList[i + 1]->SetUnref();
}
}
m_iAvaliableRefInSpatialPicList = 1;
}
}
- (GetCurrentFrameFromOrigList(kiCurDid))->SetUnref ();
+ (GetCurrentFrameFromOrigList (kiCurDid))->SetUnref();
}
//TODO: may opti later
--- a/test/api/BaseEncoderTest.cpp
+++ b/test/api/BaseEncoderTest.cpp
@@ -70,7 +70,8 @@
void BaseEncoderTest::EncodeStream (InputStream* in, EUsageType usageType, int width, int height,
float frameRate, SliceModeEnum slices, bool denoise, int layers, bool losslessLink, bool enableLtr, Callback* cbk) {
- int rv = InitWithParam (encoder_, usageType, width, height, frameRate, slices, denoise, layers, losslessLink, enableLtr);
+ int rv = InitWithParam (encoder_, usageType, width, height, frameRate, slices, denoise, layers, losslessLink,
+ enableLtr);
ASSERT_TRUE (rv == cmResultSuccess);
// I420: 1(Y) + 1/4(U) + 1/4(V)
--- a/test/api/decode_encode_test.cpp
+++ b/test/api/decode_encode_test.cpp
@@ -99,7 +99,8 @@
#else
ASSERT_TRUE (Open (p.fileName));
#endif
- EncodeStream (this, CAMERA_VIDEO_REAL_TIME, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, false, false, this);
+ EncodeStream (this, CAMERA_VIDEO_REAL_TIME, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, false, false,
+ this);
unsigned char digest[SHA_DIGEST_LENGTH];
SHA1Result (&ctx_, digest);
if (!HasFatalFailure()) {
--- a/test/api/encoder_test.cpp
+++ b/test/api/encoder_test.cpp
@@ -61,9 +61,11 @@
EncodeFileParam p = GetParam();
#if defined(ANDROID_NDK)
std::string filename = std::string ("/sdcard/") + p.fileName;
- EncodeFile (filename.c_str(), p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless, p.enableLtr, this);
+ EncodeFile (filename.c_str(), p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless,
+ p.enableLtr, this);
#else
- EncodeFile (p.fileName, p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless, p.enableLtr, this);
+ EncodeFile (p.fileName, p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless,
+ p.enableLtr, this);
#endif
//will remove this after screen content algorithms are ready,
//because the bitstream output will vary when the different algorithms are added.
--- a/test/encoder/EncUT_EncoderExt.cpp
+++ b/test/encoder/EncUT_EncoderExt.cpp
@@ -85,11 +85,11 @@
pSrcPic->iPicHeight = pParamExt->iPicHeight;
pYUV[0] = rand() % 256;
- for (int i = 1; i < m_iPicResSize; i++){
- if((i%256) == 0)
+ for (int i = 1; i < m_iPicResSize; i++) {
+ if ((i % 256) == 0)
pYUV[i] = rand() % 256;
else
- pYUV[i] = WELS_CLIP3(pYUV[i-1]+(rand()%3)-1,0,255);
+ pYUV[i] = WELS_CLIP3 (pYUV[i - 1] + (rand() % 3) - 1, 0, 255);
}
pSrcPic->iStride[0] = m_iWidth;
pSrcPic->iStride[1] = pSrcPic->iStride[2] = pSrcPic->iStride[0] >> 1;
@@ -153,7 +153,7 @@
iValue = rand() % 256;
iResult = pPtrEnc->SetOption (eOptionId, &iValue);
- if (iValue ==0)
+ if (iValue == 0)
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
else
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
@@ -186,9 +186,9 @@
fValue = static_cast<int> (rand() % 60 - 5);
iResult = pPtrEnc->SetOption (eOptionId, &fValue);
- if (fValue <=0)
+ if (fValue <= 0)
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
- else{
+ else {
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
iResult = pPtrEnc->GetOption (eOptionId, &fReturn);
@@ -201,15 +201,15 @@
pSrcPic->uiTimeStamp += 30;
eOptionId = ENCODER_OPTION_BITRATE;
- SBitrateInfo sInfo,sReturn;
+ SBitrateInfo sInfo, sReturn;
sInfo.iBitrate = rand() % 100000 - 100;
- sInfo.iLayer = static_cast<LAYER_NUM>(pParamExt->iSpatialLayerNum);
+ sInfo.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum);
iResult = pPtrEnc->SetOption (eOptionId, &sInfo);
- if (sInfo.iBitrate <=0)
+ if (sInfo.iBitrate <= 0)
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
- else{
+ else {
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
- sReturn.iLayer = static_cast<LAYER_NUM>(pParamExt->iSpatialLayerNum);
+ sReturn.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum);
iResult = pPtrEnc->GetOption (eOptionId, &sReturn);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
EXPECT_EQ (WELS_CLIP3 (sInfo.iBitrate, 1, 2147483647), sReturn.iBitrate);
@@ -221,13 +221,13 @@
eOptionId = ENCODER_OPTION_MAX_BITRATE;
sInfo.iBitrate = rand() % 100000 - 100;
- sInfo.iLayer = static_cast<LAYER_NUM>(pParamExt->iSpatialLayerNum);
+ sInfo.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum);
iResult = pPtrEnc->SetOption (eOptionId, &sInfo);
- if (sInfo.iBitrate <=0)
+ if (sInfo.iBitrate <= 0)
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
- else{
+ else {
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
- sReturn.iLayer = static_cast<LAYER_NUM>(pParamExt->iSpatialLayerNum);
+ sReturn.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum);
iResult = pPtrEnc->GetOption (eOptionId, &sReturn);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
EXPECT_EQ (WELS_CLIP3 (sInfo.iBitrate, 1, 2147483647), sReturn.iBitrate);
@@ -261,8 +261,8 @@
pParamExt->iTemporalLayerNum = 1;
pParamExt->iSpatialLayerNum = 1;
- for(int i = 0; i < 2; i++){
- pParamExt->iUsageType = (( i == 0 ) ? SCREEN_CONTENT_REAL_TIME : CAMERA_VIDEO_REAL_TIME);
+ for (int i = 0; i < 2; i++) {
+ pParamExt->iUsageType = ((i == 0) ? SCREEN_CONTENT_REAL_TIME : CAMERA_VIDEO_REAL_TIME);
int iResult = pPtrEnc->InitializeExt (pParamExt);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
@@ -328,9 +328,9 @@
ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT;
memcpy (pOption, pParamExt, sizeof (SEncParamExt));
- for(int i = 0; i < kiFrameNumber; i ++){
- if ((i%7) == 0){
- if (pOption->iTemporalLayerNum<4){
+ for (int i = 0; i < kiFrameNumber; i ++) {
+ if ((i % 7) == 0) {
+ if (pOption->iTemporalLayerNum < 4) {
pOption->iTemporalLayerNum++;
} else {
pOption->iTemporalLayerNum--;
@@ -371,7 +371,7 @@
pYUV = new unsigned char [m_iPicResSize];
PrepareOneSrcFrame();
- for(int i = 0; i < kiFrameNumber; i ++){
+ for (int i = 0; i < kiFrameNumber; i ++) {
int iStartX = rand() % (m_iPicResSize >> 1);
int iEndX = (iStartX + (rand() % MEM_VARY_SIZE)) % m_iPicResSize;
for (int j = iStartX; j < iEndX; j++)
@@ -400,7 +400,7 @@
iResult = pPtrEnc->SetOption (eOptionId, pOption);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
- for(int i = 0; i < kiFrameNumber; i ++){
+ for (int i = 0; i < kiFrameNumber; i ++) {
int iStartX = rand() % (m_iPicResSize >> 1);
int iEndX = (iStartX + (rand() % MEM_VARY_SIZE)) % m_iPicResSize;
for (int j = iStartX; j < iEndX; j++)
@@ -415,7 +415,7 @@
iResult = pPtrEnc->SetOption (eOptionId, pOption);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
- for(int i = 0; i < kiFrameNumber; i ++){
+ for (int i = 0; i < kiFrameNumber; i ++) {
int iStartX = rand() % (m_iPicResSize >> 1);
int iEndX = (iStartX + (rand() % MEM_VARY_SIZE)) % m_iPicResSize;
for (int j = iStartX; j < iEndX; j++)
@@ -434,8 +434,8 @@
pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME;
pEncParamBase->iPicWidth = 2 + ((rand() % ((MAX_WIDTH >> 1) - 1)) << 1);
pEncParamBase->iPicHeight = 2 + ((rand() % ((MAX_HEIGHT >> 1) - 1)) << 1);
- pEncParamBase->iPicWidth = VALID_SIZE(pEncParamBase->iPicWidth);
- pEncParamBase->iPicHeight = VALID_SIZE(pEncParamBase->iPicHeight);
+ pEncParamBase->iPicWidth = VALID_SIZE (pEncParamBase->iPicWidth);
+ pEncParamBase->iPicHeight = VALID_SIZE (pEncParamBase->iPicHeight);
pEncParamBase->iTargetBitrate = rand() + 1; //!=0
pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2
pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0
--- a/test/encoder/EncUT_SVC_me.cpp
+++ b/test/encoder/EncUT_SVC_me.cpp
@@ -80,18 +80,18 @@
void InitializeHashforFeature_ref (uint32_t* pTimesOfFeatureValue, uint16_t* pBuf, const int32_t kiListSize,
- uint16_t** pLocationOfFeature, uint16_t** pFeatureValuePointerList) {
- //assign location pointer
+ uint16_t** pLocationOfFeature, uint16_t** pFeatureValuePointerList) {
+ //assign location pointer
uint16_t* pBufPos = pBuf;
for (int32_t i = 0 ; i < kiListSize; ++i) {
pLocationOfFeature[i] =
- pFeatureValuePointerList[i] = pBufPos;
+ pFeatureValuePointerList[i] = pBufPos;
pBufPos += (pTimesOfFeatureValue[i] << 1);
}
}
void FillQpelLocationByFeatureValue_ref (uint16_t* pFeatureOfBlock, const int32_t kiWidth, const int32_t kiHeight,
- uint16_t** pFeatureValuePointerList) {
- //assign each pixel's position
+ uint16_t** pFeatureValuePointerList) {
+ //assign each pixel's position
uint16_t* pSrcPointer = pFeatureOfBlock;
int32_t iQpelY = 0;
for (int32_t y = 0; y < kiHeight; y++) {
@@ -246,9 +246,11 @@
GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_c, 640, 320)
#ifdef X86_ASM
GENERATE_InitializeHashforFeature (InitializeHashforFeature_ref, InitializeHashforFeature_sse2, 10, 10)
-GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_sse2, 16, 16)
+GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_sse2, 16,
+ 16)
GENERATE_InitializeHashforFeature (InitializeHashforFeature_ref, InitializeHashforFeature_sse2, 640, 320)
-GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_sse2, 640, 320)
+GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_sse2, 640,
+ 320)
#endif
GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_c, 1, 1)
@@ -282,9 +284,11 @@
GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_neon, 640, 320)
GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_neon, 640, 320)
GENERATE_InitializeHashforFeature (InitializeHashforFeature_ref, InitializeHashforFeature_neon, 10, 10)
-GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_neon, 16, 16)
+GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_neon, 16,
+ 16)
GENERATE_InitializeHashforFeature (InitializeHashforFeature_ref, InitializeHashforFeature_neon, 640, 320)
-GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_neon, 640, 320)
+GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_neon, 640,
+ 320)
#endif
#ifdef HAVE_NEON_AARCH64
@@ -295,7 +299,9 @@
GENERATE_SumOfFrame (SumOf8x8BlockOfFrame_ref, SumOf8x8BlockOfFrame_AArch64_neon, 640, 320)
GENERATE_SumOfFrame (SumOf16x16BlockOfFrame_ref, SumOf16x16BlockOfFrame_AArch64_neon, 640, 320)
GENERATE_InitializeHashforFeature (InitializeHashforFeature_ref, InitializeHashforFeature_AArch64_neon, 10, 10)
-GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_AArch64_neon, 16, 16)
+GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref,
+ FillQpelLocationByFeatureValue_AArch64_neon, 16, 16)
GENERATE_InitializeHashforFeature (InitializeHashforFeature_ref, InitializeHashforFeature_AArch64_neon, 640, 320)
-GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref, FillQpelLocationByFeatureValue_AArch64_neon, 640, 320)
+GENERATE_FillQpelLocationByFeatureValue (FillQpelLocationByFeatureValue_ref,
+ FillQpelLocationByFeatureValue_AArch64_neon, 640, 320)
#endif
--- a/test/encoder/EncUT_Sample.cpp
+++ b/test/encoder/EncUT_Sample.cpp
@@ -103,26 +103,26 @@
}
#ifdef X86_ASM
-GENERATE_Intra16x16_UT(WelsIntra16x16Combined3Sad_ssse3, WelsSampleSadIntra16x16Combined3_c, 1, WELS_CPU_SSSE3)
-GENERATE_Intra16x16_UT(WelsIntra16x16Combined3Satd_sse41, WelsSampleSatdIntra16x16Combined3_c, 1, WELS_CPU_SSE41)
-GENERATE_Intra8x8_UT(WelsIntraChroma8x8Combined3Satd_sse41, WelsSampleSatdIntra8x8Combined3_c, 1, WELS_CPU_SSE41)
-GENERATE_Intra4x4_UT(WelsSampleSatdThree4x4_sse2, 1, WELS_CPU_SSE2)
+GENERATE_Intra16x16_UT (WelsIntra16x16Combined3Sad_ssse3, WelsSampleSadIntra16x16Combined3_c, 1, WELS_CPU_SSSE3)
+GENERATE_Intra16x16_UT (WelsIntra16x16Combined3Satd_sse41, WelsSampleSatdIntra16x16Combined3_c, 1, WELS_CPU_SSE41)
+GENERATE_Intra8x8_UT (WelsIntraChroma8x8Combined3Satd_sse41, WelsSampleSatdIntra8x8Combined3_c, 1, WELS_CPU_SSE41)
+GENERATE_Intra4x4_UT (WelsSampleSatdThree4x4_sse2, 1, WELS_CPU_SSE2)
#endif
#ifdef HAVE_NEON
-GENERATE_Intra16x16_UT(WelsIntra16x16Combined3Sad_neon, WelsSampleSadIntra16x16Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra16x16_UT(WelsIntra16x16Combined3Satd_neon, WelsSampleSatdIntra16x16Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra8x8_UT(WelsIntra8x8Combined3Satd_neon, WelsSampleSatdIntra8x8Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra8x8_UT(WelsIntra8x8Combined3Sad_neon, WelsSampleSadIntra8x8Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra4x4_UT(WelsIntra4x4Combined3Satd_neon, 1, WELS_CPU_NEON)
+GENERATE_Intra16x16_UT (WelsIntra16x16Combined3Sad_neon, WelsSampleSadIntra16x16Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra16x16_UT (WelsIntra16x16Combined3Satd_neon, WelsSampleSatdIntra16x16Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra8x8_UT (WelsIntra8x8Combined3Satd_neon, WelsSampleSatdIntra8x8Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra8x8_UT (WelsIntra8x8Combined3Sad_neon, WelsSampleSadIntra8x8Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra4x4_UT (WelsIntra4x4Combined3Satd_neon, 1, WELS_CPU_NEON)
#endif
#ifdef HAVE_NEON_AARCH64
-GENERATE_Intra16x16_UT(WelsIntra16x16Combined3Sad_AArch64_neon, WelsSampleSadIntra16x16Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra16x16_UT(WelsIntra16x16Combined3Satd_AArch64_neon, WelsSampleSatdIntra16x16Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra8x8_UT(WelsIntra8x8Combined3Satd_AArch64_neon, WelsSampleSatdIntra8x8Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra8x8_UT(WelsIntra8x8Combined3Sad_AArch64_neon, WelsSampleSadIntra8x8Combined3_c, 1, WELS_CPU_NEON)
-GENERATE_Intra4x4_UT(WelsIntra4x4Combined3Satd_AArch64_neon, 1, WELS_CPU_NEON)
+GENERATE_Intra16x16_UT (WelsIntra16x16Combined3Sad_AArch64_neon, WelsSampleSadIntra16x16Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra16x16_UT (WelsIntra16x16Combined3Satd_AArch64_neon, WelsSampleSatdIntra16x16Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra8x8_UT (WelsIntra8x8Combined3Satd_AArch64_neon, WelsSampleSatdIntra8x8Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra8x8_UT (WelsIntra8x8Combined3Sad_AArch64_neon, WelsSampleSadIntra8x8Combined3_c, 1, WELS_CPU_NEON)
+GENERATE_Intra4x4_UT (WelsIntra4x4Combined3Satd_AArch64_neon, 1, WELS_CPU_NEON)
#endif
#define ASSERT_MEMORY_FAIL2X(A, B) \
@@ -537,51 +537,51 @@
}
#ifdef X86_ASM
-GENERATE_Sad4x4_UT(WelsSampleSad4x4_mmx, WelsSampleSad4x4_c, WELS_CPU_MMXEXT)
-GENERATE_Sad8x8_UT(WelsSampleSad8x8_sse21, WelsSampleSad8x8_c, WELS_CPU_SSE2)
-GENERATE_Sad8x16_UT(WelsSampleSad8x16_sse2, WelsSampleSad8x16_c, WELS_CPU_SSE2)
-GENERATE_Sad16x8_UT(WelsSampleSad16x8_sse2, WelsSampleSad16x8_c, WELS_CPU_SSE2)
-GENERATE_Sad16x16_UT(WelsSampleSad16x16_sse2, WelsSampleSad16x16_c, WELS_CPU_SSE2)
+GENERATE_Sad4x4_UT (WelsSampleSad4x4_mmx, WelsSampleSad4x4_c, WELS_CPU_MMXEXT)
+GENERATE_Sad8x8_UT (WelsSampleSad8x8_sse21, WelsSampleSad8x8_c, WELS_CPU_SSE2)
+GENERATE_Sad8x16_UT (WelsSampleSad8x16_sse2, WelsSampleSad8x16_c, WELS_CPU_SSE2)
+GENERATE_Sad16x8_UT (WelsSampleSad16x8_sse2, WelsSampleSad16x8_c, WELS_CPU_SSE2)
+GENERATE_Sad16x16_UT (WelsSampleSad16x16_sse2, WelsSampleSad16x16_c, WELS_CPU_SSE2)
-GENERATE_Sad4x4_UT(WelsSampleSatd4x4_sse2, WelsSampleSatd4x4_c, WELS_CPU_SSE2)
-GENERATE_Sad8x8_UT(WelsSampleSatd8x8_sse2, WelsSampleSatd8x8_c, WELS_CPU_SSE2)
-GENERATE_Sad8x16_UT(WelsSampleSatd8x16_sse2, WelsSampleSatd8x16_c, WELS_CPU_SSE2)
-GENERATE_Sad16x8_UT(WelsSampleSatd16x8_sse2, WelsSampleSatd16x8_c, WELS_CPU_SSE2)
-GENERATE_Sad16x16_UT(WelsSampleSatd16x16_sse2, WelsSampleSatd16x16_c, WELS_CPU_SSE2)
+GENERATE_Sad4x4_UT (WelsSampleSatd4x4_sse2, WelsSampleSatd4x4_c, WELS_CPU_SSE2)
+GENERATE_Sad8x8_UT (WelsSampleSatd8x8_sse2, WelsSampleSatd8x8_c, WELS_CPU_SSE2)
+GENERATE_Sad8x16_UT (WelsSampleSatd8x16_sse2, WelsSampleSatd8x16_c, WELS_CPU_SSE2)
+GENERATE_Sad16x8_UT (WelsSampleSatd16x8_sse2, WelsSampleSatd16x8_c, WELS_CPU_SSE2)
+GENERATE_Sad16x16_UT (WelsSampleSatd16x16_sse2, WelsSampleSatd16x16_c, WELS_CPU_SSE2)
-GENERATE_Sad4x4_UT(WelsSampleSatd4x4_sse41, WelsSampleSatd4x4_c, WELS_CPU_SSE41)
-GENERATE_Sad8x8_UT(WelsSampleSatd8x8_sse41, WelsSampleSatd8x8_c, WELS_CPU_SSE41)
-GENERATE_Sad8x16_UT(WelsSampleSatd8x16_sse41, WelsSampleSatd8x16_c, WELS_CPU_SSE41)
-GENERATE_Sad16x8_UT(WelsSampleSatd16x8_sse41, WelsSampleSatd16x8_c, WELS_CPU_SSE41)
-GENERATE_Sad16x16_UT(WelsSampleSatd16x16_sse41, WelsSampleSatd16x16_c, WELS_CPU_SSE41)
+GENERATE_Sad4x4_UT (WelsSampleSatd4x4_sse41, WelsSampleSatd4x4_c, WELS_CPU_SSE41)
+GENERATE_Sad8x8_UT (WelsSampleSatd8x8_sse41, WelsSampleSatd8x8_c, WELS_CPU_SSE41)
+GENERATE_Sad8x16_UT (WelsSampleSatd8x16_sse41, WelsSampleSatd8x16_c, WELS_CPU_SSE41)
+GENERATE_Sad16x8_UT (WelsSampleSatd16x8_sse41, WelsSampleSatd16x8_c, WELS_CPU_SSE41)
+GENERATE_Sad16x16_UT (WelsSampleSatd16x16_sse41, WelsSampleSatd16x16_c, WELS_CPU_SSE41)
#endif
#ifdef HAVE_NEON
-GENERATE_Sad4x4_UT(WelsSampleSad4x4_neon, WelsSampleSad4x4_c, WELS_CPU_NEON)
-GENERATE_Sad8x8_UT(WelsSampleSad8x8_neon, WelsSampleSad8x8_c, WELS_CPU_NEON)
-GENERATE_Sad8x16_UT(WelsSampleSad8x16_neon, WelsSampleSad8x16_c, WELS_CPU_NEON)
-GENERATE_Sad16x8_UT(WelsSampleSad16x8_neon, WelsSampleSad16x8_c, WELS_CPU_NEON)
-GENERATE_Sad16x16_UT(WelsSampleSad16x16_neon, WelsSampleSad16x16_c, WELS_CPU_NEON)
+GENERATE_Sad4x4_UT (WelsSampleSad4x4_neon, WelsSampleSad4x4_c, WELS_CPU_NEON)
+GENERATE_Sad8x8_UT (WelsSampleSad8x8_neon, WelsSampleSad8x8_c, WELS_CPU_NEON)
+GENERATE_Sad8x16_UT (WelsSampleSad8x16_neon, WelsSampleSad8x16_c, WELS_CPU_NEON)
+GENERATE_Sad16x8_UT (WelsSampleSad16x8_neon, WelsSampleSad16x8_c, WELS_CPU_NEON)
+GENERATE_Sad16x16_UT (WelsSampleSad16x16_neon, WelsSampleSad16x16_c, WELS_CPU_NEON)
-GENERATE_Sad4x4_UT(WelsSampleSatd4x4_neon, WelsSampleSatd4x4_c, WELS_CPU_NEON)
-GENERATE_Sad8x8_UT(WelsSampleSatd8x8_neon, WelsSampleSatd8x8_c, WELS_CPU_NEON)
-GENERATE_Sad8x16_UT(WelsSampleSatd8x16_neon, WelsSampleSatd8x16_c, WELS_CPU_NEON)
-GENERATE_Sad16x8_UT(WelsSampleSatd16x8_neon, WelsSampleSatd16x8_c, WELS_CPU_NEON)
-GENERATE_Sad16x16_UT(WelsSampleSatd16x16_neon, WelsSampleSatd16x16_c, WELS_CPU_NEON)
+GENERATE_Sad4x4_UT (WelsSampleSatd4x4_neon, WelsSampleSatd4x4_c, WELS_CPU_NEON)
+GENERATE_Sad8x8_UT (WelsSampleSatd8x8_neon, WelsSampleSatd8x8_c, WELS_CPU_NEON)
+GENERATE_Sad8x16_UT (WelsSampleSatd8x16_neon, WelsSampleSatd8x16_c, WELS_CPU_NEON)
+GENERATE_Sad16x8_UT (WelsSampleSatd16x8_neon, WelsSampleSatd16x8_c, WELS_CPU_NEON)
+GENERATE_Sad16x16_UT (WelsSampleSatd16x16_neon, WelsSampleSatd16x16_c, WELS_CPU_NEON)
#endif
#ifdef HAVE_NEON_AARCH64
-GENERATE_Sad4x4_UT(WelsSampleSad4x4_AArch64_neon, WelsSampleSad4x4_c, WELS_CPU_NEON)
-GENERATE_Sad8x8_UT(WelsSampleSad8x8_AArch64_neon, WelsSampleSad8x8_c, WELS_CPU_NEON)
-GENERATE_Sad8x16_UT(WelsSampleSad8x16_AArch64_neon, WelsSampleSad8x16_c, WELS_CPU_NEON)
-GENERATE_Sad16x8_UT(WelsSampleSad16x8_AArch64_neon, WelsSampleSad16x8_c, WELS_CPU_NEON)
-GENERATE_Sad16x16_UT(WelsSampleSad16x16_AArch64_neon, WelsSampleSad16x16_c, WELS_CPU_NEON)
+GENERATE_Sad4x4_UT (WelsSampleSad4x4_AArch64_neon, WelsSampleSad4x4_c, WELS_CPU_NEON)
+GENERATE_Sad8x8_UT (WelsSampleSad8x8_AArch64_neon, WelsSampleSad8x8_c, WELS_CPU_NEON)
+GENERATE_Sad8x16_UT (WelsSampleSad8x16_AArch64_neon, WelsSampleSad8x16_c, WELS_CPU_NEON)
+GENERATE_Sad16x8_UT (WelsSampleSad16x8_AArch64_neon, WelsSampleSad16x8_c, WELS_CPU_NEON)
+GENERATE_Sad16x16_UT (WelsSampleSad16x16_AArch64_neon, WelsSampleSad16x16_c, WELS_CPU_NEON)
-GENERATE_Sad4x4_UT(WelsSampleSatd4x4_AArch64_neon, WelsSampleSatd4x4_c, WELS_CPU_NEON)
-GENERATE_Sad8x8_UT(WelsSampleSatd8x8_AArch64_neon, WelsSampleSatd8x8_c, WELS_CPU_NEON)
-GENERATE_Sad8x16_UT(WelsSampleSatd8x16_AArch64_neon, WelsSampleSatd8x16_c, WELS_CPU_NEON)
-GENERATE_Sad16x8_UT(WelsSampleSatd16x8_AArch64_neon, WelsSampleSatd16x8_c, WELS_CPU_NEON)
-GENERATE_Sad16x16_UT(WelsSampleSatd16x16_AArch64_neon, WelsSampleSatd16x16_c, WELS_CPU_NEON)
+GENERATE_Sad4x4_UT (WelsSampleSatd4x4_AArch64_neon, WelsSampleSatd4x4_c, WELS_CPU_NEON)
+GENERATE_Sad8x8_UT (WelsSampleSatd8x8_AArch64_neon, WelsSampleSatd8x8_c, WELS_CPU_NEON)
+GENERATE_Sad8x16_UT (WelsSampleSatd8x16_AArch64_neon, WelsSampleSatd8x16_c, WELS_CPU_NEON)
+GENERATE_Sad16x8_UT (WelsSampleSatd16x8_AArch64_neon, WelsSampleSatd16x8_c, WELS_CPU_NEON)
+GENERATE_Sad16x16_UT (WelsSampleSatd16x16_AArch64_neon, WelsSampleSatd16x16_c, WELS_CPU_NEON)
#endif
#define GENERATE_SadFour_UT(func, CPUFLAGS, width, height) \
@@ -610,25 +610,25 @@
}
#ifdef X86_ASM
-GENERATE_SadFour_UT(WelsSampleSadFour4x4_sse2, WELS_CPU_SSE2, 4, 4)
-GENERATE_SadFour_UT(WelsSampleSadFour8x8_sse2, WELS_CPU_SSE2, 8, 8)
-GENERATE_SadFour_UT(WelsSampleSadFour8x16_sse2, WELS_CPU_SSE2, 8, 16)
-GENERATE_SadFour_UT(WelsSampleSadFour16x8_sse2, WELS_CPU_SSE2, 16, 8)
-GENERATE_SadFour_UT(WelsSampleSadFour16x16_sse2, WELS_CPU_SSE2, 16, 16)
+GENERATE_SadFour_UT (WelsSampleSadFour4x4_sse2, WELS_CPU_SSE2, 4, 4)
+GENERATE_SadFour_UT (WelsSampleSadFour8x8_sse2, WELS_CPU_SSE2, 8, 8)
+GENERATE_SadFour_UT (WelsSampleSadFour8x16_sse2, WELS_CPU_SSE2, 8, 16)
+GENERATE_SadFour_UT (WelsSampleSadFour16x8_sse2, WELS_CPU_SSE2, 16, 8)
+GENERATE_SadFour_UT (WelsSampleSadFour16x16_sse2, WELS_CPU_SSE2, 16, 16)
#endif
#ifdef HAVE_NEON
-GENERATE_SadFour_UT(WelsSampleSadFour4x4_neon, WELS_CPU_NEON, 4, 4)
-GENERATE_SadFour_UT(WelsSampleSadFour8x8_neon, WELS_CPU_NEON, 8, 8)
-GENERATE_SadFour_UT(WelsSampleSadFour8x16_neon, WELS_CPU_NEON, 8, 16)
-GENERATE_SadFour_UT(WelsSampleSadFour16x8_neon, WELS_CPU_NEON, 16, 8)
-GENERATE_SadFour_UT(WelsSampleSadFour16x16_neon, WELS_CPU_NEON, 16, 16)
+GENERATE_SadFour_UT (WelsSampleSadFour4x4_neon, WELS_CPU_NEON, 4, 4)
+GENERATE_SadFour_UT (WelsSampleSadFour8x8_neon, WELS_CPU_NEON, 8, 8)
+GENERATE_SadFour_UT (WelsSampleSadFour8x16_neon, WELS_CPU_NEON, 8, 16)
+GENERATE_SadFour_UT (WelsSampleSadFour16x8_neon, WELS_CPU_NEON, 16, 8)
+GENERATE_SadFour_UT (WelsSampleSadFour16x16_neon, WELS_CPU_NEON, 16, 16)
#endif
#ifdef HAVE_NEON_AARCH64
-GENERATE_SadFour_UT(WelsSampleSadFour4x4_AArch64_neon, WELS_CPU_NEON, 4, 4)
-GENERATE_SadFour_UT(WelsSampleSadFour8x8_AArch64_neon, WELS_CPU_NEON, 8, 8)
-GENERATE_SadFour_UT(WelsSampleSadFour8x16_AArch64_neon, WELS_CPU_NEON, 8, 16)
-GENERATE_SadFour_UT(WelsSampleSadFour16x8_AArch64_neon, WELS_CPU_NEON, 16, 8)
-GENERATE_SadFour_UT(WelsSampleSadFour16x16_AArch64_neon, WELS_CPU_NEON, 16, 16)
+GENERATE_SadFour_UT (WelsSampleSadFour4x4_AArch64_neon, WELS_CPU_NEON, 4, 4)
+GENERATE_SadFour_UT (WelsSampleSadFour8x8_AArch64_neon, WELS_CPU_NEON, 8, 8)
+GENERATE_SadFour_UT (WelsSampleSadFour8x16_AArch64_neon, WELS_CPU_NEON, 8, 16)
+GENERATE_SadFour_UT (WelsSampleSadFour16x8_AArch64_neon, WELS_CPU_NEON, 16, 8)
+GENERATE_SadFour_UT (WelsSampleSadFour16x16_AArch64_neon, WELS_CPU_NEON, 16, 16)
#endif
\ No newline at end of file
--- a/test/processing/ProcessUT_DownSample.cpp
+++ b/test/processing/ProcessUT_DownSample.cpp
@@ -9,8 +9,8 @@
using namespace WelsVP;
void DyadicBilinearDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride,
- uint8_t* pSrc, const int32_t kiSrcStride,
- const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
+ uint8_t* pSrc, const int32_t kiSrcStride,
+ const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
uint8_t* pDstLine = pDst;
uint8_t* pSrcLine = pSrc;
const int32_t kiSrcStridex2 = kiSrcStride << 1;
@@ -30,8 +30,9 @@
}
}
-void GeneralBilinearFastDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, const int32_t kiDstHeight,
- uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
+void GeneralBilinearFastDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
+ const int32_t kiDstHeight,
+ uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
const uint32_t kuiScaleBitWidth = 16, kuiScaleBitHeight = 15;
const uint32_t kuiScaleWidth = (1 << kuiScaleBitWidth), kuiScaleHeight = (1 << kuiScaleBitHeight);
int32_t fScalex = WELS_ROUND ((float)kiSrcWidth / (float)kiDstWidth * kuiScaleWidth);
@@ -98,7 +99,8 @@
}
}
-void GeneralBilinearAccurateDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, const int32_t kiDstHeight,
+void GeneralBilinearAccurateDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth,
+ const int32_t kiDstHeight,
uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
const int32_t kiScaleBit = 15;
const int32_t kiScale = (1 << kiScaleBit);
@@ -243,7 +245,8 @@
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsampler_c, 0, 0)
GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearFastDownsampler_c, GeneralBilinearFastDownsampler_ref, 0, 0)
-GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsampler_c, GeneralBilinearAccurateDownsampler_ref, 0, 0)
+GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsampler_c, GeneralBilinearAccurateDownsampler_ref, 0,
+ 0)
#if defined(X86_ASM)
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsamplerWidthx32_sse, 1, WELS_CPU_SSE)
@@ -256,8 +259,10 @@
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsamplerWidthx32_sse4, 1, WELS_CPU_SSE41)
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsamplerWidthx16_sse4, 1, WELS_CPU_SSE41)
-GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearFastDownsamplerWrap_sse2, GeneralBilinearFastDownsampler_ref, 1, WELS_CPU_SSE2)
-GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsamplerWrap_sse2, GeneralBilinearAccurateDownsampler_ref, 1, WELS_CPU_SSE2)
+GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearFastDownsamplerWrap_sse2, GeneralBilinearFastDownsampler_ref, 1,
+ WELS_CPU_SSE2)
+GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsamplerWrap_sse2,
+ GeneralBilinearAccurateDownsampler_ref, 1, WELS_CPU_SSE2)
#endif
#if defined(HAVE_NEON)
@@ -264,7 +269,8 @@
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsamplerWidthx32_neon, 1, WELS_CPU_NEON)
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsampler_neon, 1, WELS_CPU_NEON)
-GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsamplerWrap_neon, GeneralBilinearAccurateDownsampler_ref, 1, WELS_CPU_NEON)
+GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsamplerWrap_neon,
+ GeneralBilinearAccurateDownsampler_ref, 1, WELS_CPU_NEON)
#endif
#if defined(HAVE_NEON_AARCH64)
@@ -271,5 +277,6 @@
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsamplerWidthx32_AArch64_neon, 1, WELS_CPU_NEON)
GENERATE_DyadicBilinearDownsampler_UT (DyadicBilinearDownsampler_AArch64_neon, 1, WELS_CPU_NEON)
-GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsamplerWrap_AArch64_neon, GeneralBilinearAccurateDownsampler_ref, 1, WELS_CPU_NEON)
+GENERATE_GeneralBilinearDownsampler_UT (GeneralBilinearAccurateDownsamplerWrap_AArch64_neon,
+ GeneralBilinearAccurateDownsampler_ref, 1, WELS_CPU_NEON)
#endif