ref: 6015c6afade889670fcd52c48bf1bb8b1a548a09
parent: 13e13e343fcbf6777795c2cd20f61ae9b64c4f6b
parent: 3d150f043c8152a8d080b21fd77bfbd2cea357a7
author: ruil2 <ruil2@cisco.com>
date: Mon Oct 23 06:54:17 EDT 2017
Merge pull request #2862 from GuangweiWang/astyle-code-enc astyle code style for enc
--- a/codec/encoder/core/src/au_set.cpp
+++ b/codec/encoder/core/src/au_set.cpp
@@ -76,7 +76,7 @@
int32_t WelsAdjustLevel (SSpatialLayerConfig* pSpatialLayer, const SLevelLimits* pCurLevel) {
int32_t iMaxBitrate = pSpatialLayer->iMaxSpatialBitrate;
do {
- if (iMaxBitrate <= (int32_t)(pCurLevel->uiMaxBR * CpbBrNalFactor)) {
+ if (iMaxBitrate <= (int32_t) (pCurLevel->uiMaxBR * CpbBrNalFactor)) {
pSpatialLayer->uiLevelIdc = pCurLevel->uiLevelIdc;
return 0;
}
@@ -198,12 +198,12 @@
SBitStringAux* pLocalBitStringAux = pBitStringAux;
assert (pSps != NULL && pBitStringAux != NULL);
- BsWriteOneBit(pLocalBitStringAux, pSps->bAspectRatioPresent); //aspect_ratio_info_present_flag
+ BsWriteOneBit (pLocalBitStringAux, pSps->bAspectRatioPresent); //aspect_ratio_info_present_flag
if (pSps->bAspectRatioPresent) {
- BsWriteBits(pLocalBitStringAux, 8, pSps->eAspectRatio); // aspect_ratio_idc
+ BsWriteBits (pLocalBitStringAux, 8, pSps->eAspectRatio); // aspect_ratio_idc
if (pSps->eAspectRatio == ASP_EXT_SAR) {
- BsWriteBits(pLocalBitStringAux, 16, pSps->sAspectRatioExtWidth); // sar_width
- BsWriteBits(pLocalBitStringAux, 16, pSps->sAspectRatioExtHeight); // sar_height
+ BsWriteBits (pLocalBitStringAux, 16, pSps->sAspectRatioExtWidth); // sar_width
+ BsWriteBits (pLocalBitStringAux, 16, pSps->sAspectRatioExtHeight); // sar_height
}
}
BsWriteOneBit (pLocalBitStringAux, false); //overscan_info_present_flag
--- a/codec/encoder/core/src/deblocking.cpp
+++ b/codec/encoder/core/src/deblocking.cpp
@@ -364,8 +364,8 @@
int32_t iMbX = pCurMb->iMbX;
int32_t iMbY = pCurMb->iMbY;
- bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
- bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
+ bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
+ bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc];
int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc];
@@ -450,8 +450,8 @@
int32_t iMbX = pCurMb->iMbX;
int32_t iMbY = pCurMb->iMbY;
- bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
- bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
+ bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
+ bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc];
int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc];
@@ -505,8 +505,8 @@
int32_t iMbX = pCurMb->iMbX;
int32_t iMbY = pCurMb->iMbY;
- bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
- bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
+ bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
+ bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc];
int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc];
@@ -634,8 +634,8 @@
int32_t iMbX = pCurMb->iMbX;
int32_t iMbY = pCurMb->iMbY;
- bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
- bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
+ bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))};
+ bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))};
int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc];
int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc];
@@ -754,7 +754,7 @@
iSliceCount = GetCurrentSliceNum (pCurLayer);
do {
pSlice = pCurLayer->ppSliceInLayer[iSliceIdx];
- assert( NULL != pSlice);
+ assert (NULL != pSlice);
DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, pSlice);
++ iSliceIdx;
} while (iSliceIdx < iSliceCount);
--- a/codec/encoder/core/src/get_intra_predictor.cpp
+++ b/codec/encoder/core/src/get_intra_predictor.cpp
@@ -104,8 +104,9 @@
WelsFillingPred8x2to16 (pPred, uiSrc);
}
void WelsI4x4LumaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
- const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + kiStride - 1] +
- pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 4) >> 3;
+ const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) +
+ kiStride - 1] +
+ pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 4) >> 3;
WelsFillingPred1to16 (pPred, kuiDcValue);
}
@@ -112,7 +113,7 @@
void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) +
- kiStride - 1] + 2) >> 2;
+ kiStride - 1] + 2) >> 2;
WelsFillingPred1to16 (pPred, kuiDcValue);
}
--- a/codec/encoder/core/src/md.cpp
+++ b/codec/encoder/core/src/md.cpp
@@ -446,10 +446,14 @@
for (; j < 16; j += 4) {
num = 0;
for (i = 0; i < 16; i += 4, num ++) {
- pBlock[num] = pEncData[i ] + pEncData[i + 1 ] + pEncData[i + 2 ] + pEncData[i + 3 ];
- pBlock[num] += pEncData[i + kiLineSize ] + pEncData[i + kiLineSize + 1] + pEncData[i + kiLineSize + 2] + pEncData[i + kiLineSize + 3];
- pBlock[num] += pEncData[i + kiLineSize2] + pEncData[i + kiLineSize2 + 1] + pEncData[i + kiLineSize2 + 2] + pEncData[i + kiLineSize2 + 3];
- pBlock[num] += pEncData[i + kiLineSize3] + pEncData[i + kiLineSize3 + 1] + pEncData[i + kiLineSize3 + 2] + pEncData[i + kiLineSize3 + 3];
+ pBlock[num] = pEncData[i ] + pEncData[i + 1 ] + pEncData[i + 2 ] + pEncData[i +
+ 3 ];
+ pBlock[num] += pEncData[i + kiLineSize ] + pEncData[i + kiLineSize + 1] + pEncData[i + kiLineSize + 2] + pEncData[i +
+ kiLineSize + 3];
+ pBlock[num] += pEncData[i + kiLineSize2] + pEncData[i + kiLineSize2 + 1] + pEncData[i + kiLineSize2 + 2] + pEncData[i +
+ kiLineSize2 + 3];
+ pBlock[num] += pEncData[i + kiLineSize3] + pEncData[i + kiLineSize3 + 1] + pEncData[i + kiLineSize3 + 2] + pEncData[i +
+ kiLineSize3 + 3];
pBlock[num] >>= 4;
}
pBlock += 4;
--- a/codec/encoder/core/src/nal_encap.cpp
+++ b/codec/encoder/core/src/nal_encap.cpp
@@ -143,7 +143,7 @@
/* NAL Unit Header */
*pDstPointer++ = (pRawNal->sNalExt.sNalUnitHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalUnitHeader.eNalUnitType &
- 0x1f);
+ 0x1f);
if (kbNALExt) {
SNalUnitHeaderExt* sNalExt = (SNalUnitHeaderExt*)pNalHeaderExt;
@@ -150,14 +150,14 @@
/* NAL UNIT Extension Header */
*pDstPointer++ = (0x80) |
- (sNalExt->bIdrFlag << 6);
+ (sNalExt->bIdrFlag << 6);
*pDstPointer++ = (0x80) |
- (sNalExt->uiDependencyId << 4);
+ (sNalExt->uiDependencyId << 4);
*pDstPointer++ = (sNalExt->uiTemporalId << 5) |
- (sNalExt->bDiscardableFlag << 3) |
- (0x07);
+ (sNalExt->bDiscardableFlag << 3) |
+ (0x07);
}
while (pSrcPointer < pSrcEnd) {
--- a/codec/encoder/core/src/picture_handle.cpp
+++ b/codec/encoder/core/src/picture_handle.cpp
@@ -68,7 +68,7 @@
iPicChromaWidth = iPicWidth >> 1;
iPicChromaHeight = iPicHeight >> 1;
iPicWidth = WELS_ALIGN (iPicWidth,
- 32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size
+ 32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size
iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16);
iLumaSize = iPicWidth * iPicHeight;
iChromaSize = iPicChromaWidth * iPicChromaHeight;
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -450,9 +450,9 @@
return true;
}
-static inline void WelsMarkMMCORefInfoWithBase(SSlice** ppSliceList,
- SSlice* pBaseSlice,
- const int32_t kiCountSliceNum) {
+static inline void WelsMarkMMCORefInfoWithBase (SSlice** ppSliceList,
+ SSlice* pBaseSlice,
+ const int32_t kiCountSliceNum) {
int32_t iSliceIdx = 0;
SSliceHeaderExt* pSliceHdrExt = NULL;
SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt;
@@ -488,7 +488,7 @@
}
}
- WelsMarkMMCORefInfoWithBase(ppSliceList, pBaseSlice, kiCountSliceNum);
+ WelsMarkMMCORefInfoWithBase (ppSliceList, pBaseSlice, kiCountSliceNum);
}
void WelsMarkPic (sWelsEncCtx* pCtx) {
@@ -906,7 +906,7 @@
pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount++].iMmcoType = MMCO_LONG;
}
- WelsMarkMMCORefInfoWithBase(ppSliceList, pBaseSlice, kiCountSliceNum);
+ WelsMarkMMCORefInfoWithBase (ppSliceList, pBaseSlice, kiCountSliceNum);
}
void WelsMarkPicScreen (sWelsEncCtx* pCtx) {
--- a/codec/encoder/core/src/set_mb_syn_cabac.cpp
+++ b/codec/encoder/core/src/set_mb_syn_cabac.cpp
@@ -53,7 +53,7 @@
void PropagateCarry (uint8_t* pBufCur, uint8_t* pBufStart) {
for (; pBufCur > pBufStart; --pBufCur)
- if (++*(pBufCur - 1))
+ if (++ * (pBufCur - 1))
break;
}
@@ -133,7 +133,7 @@
void WelsCabacEncodeDecisionLps_ (SCabacCtx* pCbCtx, int32_t iCtx) {
const int32_t kiState = pCbCtx->m_sStateCtx[iCtx].State();
uint32_t uiRange = pCbCtx->m_uiRange;
- uint32_t uiRangeLps = g_kuiCabacRangeLps[kiState][(uiRange & 0xff) >> 6];
+ uint32_t uiRangeLps = g_kuiCabacRangeLps[kiState][ (uiRange & 0xff) >> 6];
uiRange -= uiRangeLps;
pCbCtx->m_sStateCtx[iCtx].Set (g_kuiStateTransTable[kiState][0],
pCbCtx->m_sStateCtx[iCtx].Mps() ^ (kiState == 0));
@@ -193,7 +193,7 @@
if (uiLow & cabac_low_t (1) << (CABAC_LOW_WIDTH - 1))
PropagateCarry (pBufCur, pCbCtx->m_pBufStart);
for (; (iLowBitCnt -= 8) >= 0; uiLow <<= 8)
- *pBufCur++ = (uint8_t) (uiLow >> (CABAC_LOW_WIDTH - 9));
+ * pBufCur++ = (uint8_t) (uiLow >> (CABAC_LOW_WIDTH - 9));
pCbCtx->m_pBufCur = pBufCur;
}
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -93,7 +93,7 @@
int32_t iSliceIdx = 0;
int32_t iAvI[MAX_SLICES_NUM];
- assert(kiSliceCount <= MAX_SLICES_NUM);
+ assert (kiSliceCount <= MAX_SLICES_NUM);
WelsEmms();
while (iSliceIdx < kiSliceCount) {
@@ -112,7 +112,7 @@
}
int32_t NeedDynamicAdjust (SSlice** ppSliceInLayer, const int32_t iSliceNum) {
- if ( NULL == ppSliceInLayer ) {
+ if (NULL == ppSliceInLayer) {
return false;
}
@@ -123,7 +123,7 @@
WelsEmms();
while (iSliceIdx < iSliceNum) {
- if ( NULL == ppSliceInLayer[iSliceIdx] ) {
+ if (NULL == ppSliceInLayer[iSliceIdx]) {
return false;
}
@@ -232,7 +232,7 @@
return;
}
iRunLen[iSliceIdx] = iNumMbAssigning;
- MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG,
+ MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
"[MT] DynamicAdjustSlicing(), iSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
iSliceIdx, ppSliceInLayer[iSliceIdx]->iSliceComplexRatio * 1.0f / INT_MULTIPLY,
ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice,
@@ -437,25 +437,25 @@
while (iSliceIdx < iSliceCount) {
pSliceBs = &ppSliceInlayer[iSliceIdx]->sSliceBs;
if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
- int32_t iNalIdx = 0;
- const int32_t iCountNal = pSliceBs->iNalIndex;
+ int32_t iNalIdx = 0;
+ const int32_t iCountNal = pSliceBs->iNalIndex;
#if MT_DEBUG_BS_WR
- assert (pSliceBs->bSliceCodedFlag);
+ assert (pSliceBs->bSliceCodedFlag);
#endif//MT_DEBUG_BS_WR
- memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage
- pCtx->iPosBsBuffer += pSliceBs->uiBsPos;
+ memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage
+ pCtx->iPosBsBuffer += pSliceBs->uiBsPos;
- iLayerSize += pSliceBs->uiBsPos;
+ iLayerSize += pSliceBs->uiBsPos;
- while (iNalIdx < iCountNal) {
+ while (iNalIdx < iCountNal) {
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
++ iNalIdx;
+ }
+ pLbi->iNalCount += iCountNal;
+ iNalIdxBase += iCountNal;
}
- pLbi->iNalCount += iCountNal;
- iNalIdxBase += iCountNal;
- }
++ iSliceIdx;
}
@@ -615,7 +615,7 @@
int32_t iMaxI = 0;
while (i < kuiCountSliceNum) {
fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6d us consume_time coding_idx %d iDid %d pSlice %d\n",
- ppSliceInLayer[i]->uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/);
+ ppSliceInLayer[i]->uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/);
if (ppSliceInLayer[i]->uiSliceConsumeTime > uiMaxT) {
uiMaxT = ppSliceInLayer[i]->uiSliceConsumeTime;
iMaxI = i;
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -67,7 +67,7 @@
*
* \return 0 - successful; none 0 - failed
*/
-int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSliceArgument) {
+int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq, const SSliceArgument* kpSliceArgument) {
SSliceCtx* pSliceSeg = &pCurDq->sSliceEncCtx;
int32_t iSliceIdx = 0;
if (NULL == pSliceSeg || SM_SINGLE_SLICE == pSliceSeg->uiSliceMode)
@@ -80,8 +80,8 @@
iSliceIdx = 0;
while (iSliceIdx < iSliceNum) {
const int32_t kiFirstMb = iSliceIdx * kiMbWidth;
- WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx,
- kiMbWidth, sizeof(uint16_t));
+ WelsSetMemMultiplebytes_c (pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx,
+ kiMbWidth, sizeof (uint16_t));
++ iSliceIdx;
}
@@ -108,7 +108,7 @@
++ iSliceIdx;
} while (iSliceIdx < kiCountSliceNumInFrame && iMbIdx < kiCountNumMbInFrame);
} else if (SM_SIZELIMITED_SLICE == pSliceSeg->uiSliceMode) {
- // do nothing,pSliceSeg->pOverallMbMap will be initial later
+ // do nothing,pSliceSeg->pOverallMbMap will be initial later
} else { // any else uiSliceMode?
assert (0);
}
@@ -139,7 +139,7 @@
pSlicesAssignList[uiSliceIdx] = iNumMbLeft;
- if (iNumMbLeft <= 0 || kiMbNumPerSlice <= 0 ) {
+ if (iNumMbLeft <= 0 || kiMbNumPerSlice <= 0) {
return false;
}
@@ -287,7 +287,7 @@
if (iNumMbAssigning < iMinimalMbNum)
iCurNumMbAssigning = iMinimalMbNum;
else if (iNumMbAssigning > iMaximalMbNum)
- iCurNumMbAssigning = ( iMaximalMbNum / iGomSize ) * iGomSize;
+ iCurNumMbAssigning = (iMaximalMbNum / iGomSize) * iGomSize;
else
iCurNumMbAssigning = iNumMbAssigning;
@@ -304,7 +304,7 @@
++ uiSliceIdx;
}
pSlicesAssignList[uiSliceIdx] = iNumMbLeft;
- if ( iNumMbLeft < iMinimalMbNum ) {
+ if (iNumMbLeft < iMinimalMbNum) {
return false;
}
@@ -321,20 +321,19 @@
return -1;
switch (pSliceArgument->uiSliceMode) {
- case SM_SINGLE_SLICE:
- case SM_FIXEDSLCNUM_SLICE:
- case SM_RASTER_SLICE:
- {
- return pSliceArgument->uiSliceNum;
- }
- case SM_SIZELIMITED_SLICE: {
- return AVERSLICENUM_CONSTRAINT;//at the beginning of dynamic slicing, set the uiSliceNum to be 1
- }
- case SM_RESERVED:
- default: {
- return -1;
- }
+ case SM_SINGLE_SLICE:
+ case SM_FIXEDSLCNUM_SLICE:
+ case SM_RASTER_SLICE: {
+ return pSliceArgument->uiSliceNum;
}
+ case SM_SIZELIMITED_SLICE: {
+ return AVERSLICENUM_CONSTRAINT;//at the beginning of dynamic slicing, set the uiSliceNum to be 1
+ }
+ case SM_RESERVED:
+ default: {
+ return -1;
+ }
+ }
return -1;
}
@@ -395,13 +394,13 @@
return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0]));
} else { //if ( SM_MULTIPLE_SLICE == uiSliceMode )
if (uiSliceMode != SM_FIXEDSLCNUM_SLICE && uiSliceMode != SM_RASTER_SLICE
- && uiSliceMode != SM_SIZELIMITED_SLICE )
+ && uiSliceMode != SM_SIZELIMITED_SLICE)
return 1;
pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMallocz (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap");
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap)
- WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap, 0, kiCountMbNum, sizeof(uint16_t));
+ WelsSetMemMultiplebytes_c (pSliceSeg->pOverallMbMap, 0, kiCountMbNum, sizeof (uint16_t));
//SM_SIZELIMITED_SLICE: init, set pSliceSeg->iSliceNumInFrame = 1;
pSliceSeg->iSliceNumInFrame = GetInitialSliceNum (pSliceArgument);
@@ -533,7 +532,7 @@
* \return iFirstMb - successful; -1 - failed;
*/
int32_t WelsGetFirstMbOfSlice (SDqLayer* pCurLayer, const int32_t kuiSliceIdc) {
- if ( NULL == pCurLayer || NULL == pCurLayer->pFirstMbIdxOfSlice ) {
+ if (NULL == pCurLayer || NULL == pCurLayer->pFirstMbIdxOfSlice) {
return -1;
}
@@ -613,7 +612,7 @@
*
* \return count_num_of_mb - successful; -1 - failed;
*/
-int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, SSlice* pSlice, const int32_t kuiSliceIdc) {
+int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, SSlice* pSlice, const int32_t kuiSliceIdc) {
SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
bool bInValidFlag = false;
@@ -623,7 +622,7 @@
bInValidFlag = ((SM_SINGLE_SLICE != pSliceCtx->uiSliceMode) && (kuiSliceIdc >= pSliceCtx->iSliceNumInFrame))
|| ((SM_SINGLE_SLICE == pSliceCtx->uiSliceMode) && (kuiSliceIdc > 0));
- if(bInValidFlag) {
+ if (bInValidFlag) {
return -1;
}
@@ -662,8 +661,8 @@
pCurDq->pFirstMbIdxOfSlice[iSliceIdx] = iFirstMbIdx;
pCurDq->pCountMbNumInSlice[iSliceIdx] = kiSliceRun;
- WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx,
- kiSliceRun, sizeof(uint16_t));
+ WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx,
+ kiSliceRun, sizeof (uint16_t));
iFirstMbIdx += kiSliceRun;
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -827,7 +827,7 @@
int32_t iFirstMBInSlice = 0;
int32_t iMbNumInSlice = 0;
- for( ;iSliceIdx < kiSliceNumInFrame; iSliceIdx++ ){
+ for (; iSliceIdx < kiSliceNumInFrame; iSliceIdx++) {
if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) {
iFirstMBInSlice = 0;
iMbNumInSlice = kiCountNumMbInFrame;
@@ -836,7 +836,7 @@
iFirstMBInSlice = iSliceIdx * kiMBWidth;
iMbNumInSlice = kiMBWidth;
} else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode ||
- SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) {
+ SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) {
int32_t iMbIdx = 0;
for (int i = 0; i < iSliceIdx; i++) {
iMbIdx += kpSlicesAssignList[i];
@@ -864,10 +864,10 @@
return ENC_RETURN_SUCCESS;
}
-int32_t SetSliceBoundaryInfo(SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) {
- if(NULL == pCurLayer || NULL == pSlice ||
- NULL == pCurLayer->pFirstMbIdxOfSlice ||
- NULL == pCurLayer->pCountMbNumInSlice) {
+int32_t SetSliceBoundaryInfo (SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) {
+ if (NULL == pCurLayer || NULL == pSlice ||
+ NULL == pCurLayer->pFirstMbIdxOfSlice ||
+ NULL == pCurLayer->pCountMbNumInSlice) {
return ENC_RETURN_UNEXPECTED;
}
@@ -977,8 +977,8 @@
int32_t iSliceIdx = 0;
int32_t iSlcBuffIdx = 0;
- for( ; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) {
- if(NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) {
+ for (; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) {
+ if (NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) {
return ENC_RETURN_UNEXPECTED;
}
@@ -985,7 +985,7 @@
pCurDqLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx = -1;
}
- for( ; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) {
+ for (; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) {
pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iCodedSliceNum = 0;
}
@@ -999,11 +999,11 @@
const int32_t kiSliceIdx) {
if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) {
- const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iCodedSliceNum;
- assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iMaxSliceNum -1 );
- pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiSlcBuffIdx].pSliceBuffer[kiCodedNumInThread];
+ const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iCodedSliceNum;
+ assert (kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iMaxSliceNum - 1);
+ pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiSlcBuffIdx].pSliceBuffer[kiCodedNumInThread];
} else {
- pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx];
+ pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx];
}
pSlice->iSliceIdx = kiSliceIdx;
pSlice->uiBufferIdx = kiSlcBuffIdx;
@@ -1029,7 +1029,7 @@
assert (iThreadNum > 0);
//for fixed slice num case, no need to reallocate, so one slice buffer for all thread
- if( pDqLayer->bThreadSlcBufferFlag) {
+ if (pDqLayer->bThreadSlcBufferFlag) {
iMaxSliceNum = pDqLayer->iMaxSliceNum / iThreadNum + 1;
iSlcBufferNum = iThreadNum;
} else {
@@ -1040,7 +1040,8 @@
while (iIdx < iSlcBufferNum) {
pDqLayer->sSliceBufferInfo[iIdx].iMaxSliceNum = iMaxSliceNum;
pDqLayer->sSliceBufferInfo[iIdx].iCodedSliceNum = 0;
- pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceBuffer");
+ pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum,
+ "pSliceBuffer");
if (NULL == pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
"CWelsH264SVCEncoder::InitSliceThreadInfo: pSliceThreadInfo->pSliceBuffer[iIdx] is NULL");
@@ -1081,21 +1082,21 @@
//SM_SINGLE_SLICE mode using single-thread bs writer pOut->sBsWrite
//even though multi-thread is on for other layers
pDqLayer->bSliceBsBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 &&
- SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false;
+ SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false;
pDqLayer->bThreadSlcBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 &&
- SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? true : false;
+ SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? true : false;
iRet = InitSliceThreadInfo (pCtx,
- pDqLayer,
- kiDlayerIndex,
- pMa);
+ pDqLayer,
+ kiDlayerIndex,
+ pMa);
if (ENC_RETURN_SUCCESS != iRet) {
return ENC_RETURN_MEMALLOCERR;
}
pDqLayer->iMaxSliceNum = 0;
- for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) {
+ for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) {
pDqLayer->iMaxSliceNum += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum;
}
@@ -1105,15 +1106,19 @@
return ENC_RETURN_MEMALLOCERR;
}
- pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, "pFirstMbIdxOfSlice");
+ pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum,
+ "pFirstMbIdxOfSlice");
if (NULL == pDqLayer->pFirstMbIdxOfSlice) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL");
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
+ "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL");
return ENC_RETURN_MEMALLOCERR;
}
- pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, "pCountMbNumInSlice");
+ pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum,
+ "pCountMbNumInSlice");
if (NULL == pDqLayer->pCountMbNumInSlice) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL");
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
+ "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL");
return ENC_RETURN_MEMALLOCERR;
}
@@ -1123,9 +1128,9 @@
}
iStartIdx = 0;
- for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) {
- for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++ ) {
- pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer+ iSliceIdx;
+ for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) {
+ for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) {
+ pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx;
}
iStartIdx += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum;
@@ -1135,7 +1140,7 @@
}
void InitSliceHeadWithBase (SSlice* pSlice, SSlice* pBaseSlice) {
- if(NULL == pSlice || NULL == pBaseSlice) {
+ if (NULL == pSlice || NULL == pBaseSlice) {
return;
}
@@ -1150,7 +1155,7 @@
}
void InitSliceRefInfoWithBase (SSlice* pSlice, SSlice* pBaseSlice, const uint8_t kuiRefCount) {
- if( NULL == pSlice || NULL == pBaseSlice) {
+ if (NULL == pSlice || NULL == pBaseSlice) {
return;
}
@@ -1213,7 +1218,7 @@
for (iSliceIdx = 0; iSliceIdx < kiMaxSliceNumOld; iSliceIdx++) {
pSlice = pNewSliceList + iSliceIdx;
if (NULL == pSlice) {
- FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
+ FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
return ENC_RETURN_MEMALLOCERR;
}
@@ -1224,7 +1229,7 @@
pBaseSlice = &pSliceList[0];
if (NULL == pBaseSlice) {
- FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
+ FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
return ENC_RETURN_MEMALLOCERR;
}
@@ -1231,7 +1236,7 @@
for (iSliceIdx = kiMaxSliceNumOld; iSliceIdx < kiMaxSliceNumNew; iSliceIdx++) {
pSlice = pNewSliceList + iSliceIdx;
if (NULL == pSlice) {
- FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
+ FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
return ENC_RETURN_MEMALLOCERR;
}
@@ -1246,13 +1251,13 @@
iMaxSliceBufferSize,
pMA);
if (ENC_RETURN_SUCCESS != iRet) {
- FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
+ FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
return iRet;
}
iRet = AllocateSliceMBBuffer (pSlice, pMA);
if (ENC_RETURN_SUCCESS != iRet) {
- FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
+ FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
return iRet;
}
@@ -1261,7 +1266,7 @@
iRet = InitSliceRC (pSlice, pCtx->iGlobalQp);
if (ENC_RETURN_SUCCESS != iRet) {
- FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
+ FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer");
return iRet;
}
}
@@ -1276,11 +1281,11 @@
SSlice* pLastCodedSlice,
const int32_t iMaxSliceNumOld,
int32_t& iMaxSliceNumNew) {
- if ( NULL == pCtx || NULL == pLastCodedSlice || 0 == iMaxSliceNumOld ) {
+ if (NULL == pCtx || NULL == pLastCodedSlice || 0 == iMaxSliceNumOld) {
return ENC_RETURN_INVALIDINPUT;
}
- if ( 1 == pCtx->iActiveThreadsNum ) {
+ if (1 == pCtx->iActiveThreadsNum) {
iMaxSliceNumNew = iMaxSliceNumOld * SLICE_NUM_EXPAND_COEF;
return ENC_RETURN_SUCCESS;
}
@@ -1292,7 +1297,7 @@
- pCtx->pCurDqLayer->LastCodedMbIdxOfPartition[iPartitionID] + 1;
int32_t iIncreaseSlicNum = (iLeftMBNum * INT_MULTIPLY / iMBNumInPatition) * iMaxSliceNumOld;
- iIncreaseSlicNum = ( 0 == (iIncreaseSlicNum / INT_MULTIPLY) ) ? 1 : (iIncreaseSlicNum / INT_MULTIPLY);
+ iIncreaseSlicNum = (0 == (iIncreaseSlicNum / INT_MULTIPLY)) ? 1 : (iIncreaseSlicNum / INT_MULTIPLY);
iIncreaseSlicNum = (iIncreaseSlicNum < iMaxSliceNumOld / 2) ? (iMaxSliceNumOld / 2) : iIncreaseSlicNum;
iMaxSliceNumNew = iMaxSliceNumOld + iIncreaseSlicNum;
@@ -1332,9 +1337,9 @@
return ENC_RETURN_SUCCESS;
}
-int32_t ExtendLayerBuffer(sWelsEncCtx* pCtx,
- const int32_t kiMaxSliceNumOld,
- const int32_t kiMaxSliceNumNew){
+int32_t ExtendLayerBuffer (sWelsEncCtx* pCtx,
+ const int32_t kiMaxSliceNumOld,
+ const int32_t kiMaxSliceNumNew) {
CMemoryAlign* pMA = pCtx->pMemAlign;
SDqLayer* pCurLayer = pCtx->pCurDqLayer;
SSlice** ppSlice = NULL;
@@ -1356,7 +1361,7 @@
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pFirstMbIdxOfSlice is NULL");
return ENC_RETURN_MEMALLOCERR;
}
- memset (pFirstMbIdxOfSlice, 0, sizeof(int32_t) * kiMaxSliceNumNew);
+ memset (pFirstMbIdxOfSlice, 0, sizeof (int32_t) * kiMaxSliceNumNew);
memcpy (pFirstMbIdxOfSlice, pCurLayer->pFirstMbIdxOfSlice, sizeof (int32_t) * kiMaxSliceNumOld);
pMA->WelsFree (pCurLayer->pFirstMbIdxOfSlice, "pFirstMbIdxOfSlice");
pCurLayer->pFirstMbIdxOfSlice = pFirstMbIdxOfSlice;
@@ -1367,7 +1372,7 @@
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pCountMbNumInSlice is NULL");
return ENC_RETURN_MEMALLOCERR;
}
- memset (pCountMbNumInSlice, 0, sizeof(int32_t) * kiMaxSliceNumNew);
+ memset (pCountMbNumInSlice, 0, sizeof (int32_t) * kiMaxSliceNumNew);
memcpy (pCountMbNumInSlice, pCurLayer->pCountMbNumInSlice, sizeof (int32_t) * kiMaxSliceNumOld);
pMA->WelsFree (pCurLayer->pCountMbNumInSlice, "pCountMbNumInSlice");
pCurLayer->pCountMbNumInSlice = pCountMbNumInSlice;
@@ -1408,16 +1413,16 @@
pCurLayer->sSliceBufferInfo[0].iMaxSliceNum = iMaxSliceNumNew;
iMaxSliceNumNew = 0;
- for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) {
- iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum;
+ for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) {
+ iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum;
}
- iRet = ExtendLayerBuffer(pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew);
+ iRet = ExtendLayerBuffer (pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew);
if (ENC_RETURN_SUCCESS != iRet) {
return iRet;
}
- for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) {
+ for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) {
for (iSliceIdx = 0; iSliceIdx < pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) {
pCurLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx;
}
@@ -1429,14 +1434,14 @@
return ENC_RETURN_SUCCESS;
}
-static inline int32_t CheckAllSliceBuffer(SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) {
+static inline int32_t CheckAllSliceBuffer (SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) {
int32_t iSliceIdx = 0;
- for(; iSliceIdx <kiCodedSliceNum ; iSliceIdx ++ ) {
- if ( NULL == pCurLayer->ppSliceInLayer[iSliceIdx]) {
+ for (; iSliceIdx < kiCodedSliceNum ; iSliceIdx ++) {
+ if (NULL == pCurLayer->ppSliceInLayer[iSliceIdx]) {
return ENC_RETURN_UNEXPECTED;
}
- if ( iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx) {
+ if (iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx) {
return ENC_RETURN_UNEXPECTED;
}
}
@@ -1464,9 +1469,9 @@
//for non-dynamic slice mode, iPartitionNum = 1, iPartitionOffset = 0
iPartitionNum = (SM_SIZELIMITED_SLICE == kuiSliceMode) ? kiThreadNum : 1;
- for(iPartitionIdx = 0; iPartitionIdx < iPartitionNum; iPartitionIdx++) {
+ for (iPartitionIdx = 0; iPartitionIdx < iPartitionNum; iPartitionIdx++) {
aiPartitionOffset[iPartitionIdx] = iEncodeSliceNum;
- if ( SM_SIZELIMITED_SLICE == kuiSliceMode) {
+ if (SM_SIZELIMITED_SLICE == kuiSliceMode) {
iEncodeSliceNum += pCurLayer->NumSliceCodedOfPartition[iPartitionIdx];
} else {
iEncodeSliceNum = pCurLayer->sSliceEncCtx.iSliceNumInFrame;
@@ -1473,7 +1478,7 @@
}
}
- if( iEncodeSliceNum != pCurLayer->sSliceEncCtx.iSliceNumInFrame) {
+ if (iEncodeSliceNum != pCurLayer->sSliceEncCtx.iSliceNumInFrame) {
return ENC_RETURN_UNEXPECTED;
}
@@ -1482,13 +1487,13 @@
for (iSlcBuffIdx = 0; iSlcBuffIdx < kiThreadNum; iSlcBuffIdx++) {
iSliceNumInThread = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum;
- for(iSliceIdx =0; iSliceIdx < iSliceNumInThread; iSliceIdx++) {
+ for (iSliceIdx = 0; iSliceIdx < iSliceNumInThread; iSliceIdx++) {
pSliceBuffer = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx;
if (NULL == pSliceBuffer) {
return ENC_RETURN_UNEXPECTED;
}
- if( -1 != pSliceBuffer->iSliceIdx) {
+ if (-1 != pSliceBuffer->iSliceIdx) {
iPartitionID = pSliceBuffer->iSliceIdx % iPartitionNum;
iActualSliceIdx = aiPartitionOffset[iPartitionID] + pSliceBuffer->iSliceIdx / iPartitionNum;
pSliceBuffer->iSliceIdx = iActualSliceIdx;
@@ -1495,18 +1500,18 @@
pCurLayer->ppSliceInLayer[iActualSliceIdx] = pSliceBuffer;
iUsedSliceNum ++;
} else {
- pCurLayer->ppSliceInLayer[iEncodeSliceNum + iNonUsedBufferNum] = pSliceBuffer;
- iNonUsedBufferNum ++;
+ pCurLayer->ppSliceInLayer[iEncodeSliceNum + iNonUsedBufferNum] = pSliceBuffer;
+ iNonUsedBufferNum ++;
}
}
}
- if( iUsedSliceNum != iEncodeSliceNum ||
- pCurLayer->iMaxSliceNum != (iNonUsedBufferNum + iUsedSliceNum)) {
+ if (iUsedSliceNum != iEncodeSliceNum ||
+ pCurLayer->iMaxSliceNum != (iNonUsedBufferNum + iUsedSliceNum)) {
return ENC_RETURN_UNEXPECTED;
}
- if (ENC_RETURN_SUCCESS != CheckAllSliceBuffer(pCurLayer, iEncodeSliceNum)) {
+ if (ENC_RETURN_SUCCESS != CheckAllSliceBuffer (pCurLayer, iEncodeSliceNum)) {
return ENC_RETURN_UNEXPECTED;
}
@@ -1513,11 +1518,11 @@
return ENC_RETURN_SUCCESS;
}
-int32_t GetCurLayerNalCount(const SDqLayer* pCurDq, const int32_t kiCodedSliceNum) {
+int32_t GetCurLayerNalCount (const SDqLayer* pCurDq, const int32_t kiCodedSliceNum) {
int32_t iTotalNalCount = 0;
int32_t iSliceIdx = 0;
SWelsSliceBs* pSliceBs = NULL;
- for ( ; iSliceIdx < kiCodedSliceNum; iSliceIdx++ ) {
+ for (; iSliceIdx < kiCodedSliceNum; iSliceIdx++) {
pSliceBs = &pCurDq->ppSliceInLayer[iSliceIdx]->sSliceBs;
if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
iTotalNalCount += pSliceBs->iNalIndex;
@@ -1527,7 +1532,7 @@
return iTotalNalCount;
}
-int32_t GetTotalCodedNalCount(SFrameBSInfo* pFbi) {
+int32_t GetTotalCodedNalCount (SFrameBSInfo* pFbi) {
int32_t iTotalCodedNalCount = 0;
for (int32_t iNalIdx = 0; iNalIdx < MAX_LAYER_NUM_OF_FRAME; iNalIdx++) {
iTotalCodedNalCount += pFbi->sLayerInfo[iNalIdx].iNalCount;
@@ -1584,13 +1589,13 @@
int32_t iCodedNalCount = 0;
int32_t iRet = 0;
- for ( int32_t iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) {
+ for (int32_t iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) {
iMaxSliceNum += pCtx->pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum;
}
//reallocate ppSliceInLayer if total encoded slice num exceed max slice num
if (iMaxSliceNum > pCtx->pCurDqLayer->iMaxSliceNum) {
- iRet = ExtendLayerBuffer(pCtx, pCtx->pCurDqLayer->iMaxSliceNum, iMaxSliceNum);
+ iRet = ExtendLayerBuffer (pCtx, pCtx->pCurDqLayer->iMaxSliceNum, iMaxSliceNum);
if (ENC_RETURN_SUCCESS != iRet) {
return iRet;
}
@@ -1607,12 +1612,12 @@
//Extend NalList buffer if exceed
iCodedSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer);
- pLayerBsInfo->iNalCount = GetCurLayerNalCount(pCtx->pCurDqLayer, iCodedSliceNum);
- iCodedNalCount = GetTotalCodedNalCount(pFrameBsInfo);
+ pLayerBsInfo->iNalCount = GetCurLayerNalCount (pCtx->pCurDqLayer, iCodedSliceNum);
+ iCodedNalCount = GetTotalCodedNalCount (pFrameBsInfo);
- if( iCodedNalCount > pCtx->pOut->iCountNals) {
+ if (iCodedNalCount > pCtx->pOut->iCountNals) {
iRet = FrameBsRealloc (pCtx, pFrameBsInfo, pLayerBsInfo, pCtx->pCurDqLayer->iMaxSliceNum);
- if(ENC_RETURN_SUCCESS != iRet) {
+ if (ENC_RETURN_SUCCESS != iRet) {
return iRet;
}
}
@@ -1625,8 +1630,9 @@
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
SBitStringAux* pBs = pCurSlice->pSliceBsa;
- const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode
- == SM_SIZELIMITED_SLICE);
+ const int32_t kiDynamicSliceFlag =
+ (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode
+ == SM_SIZELIMITED_SLICE);
if (I_SLICE == pEncCtx->eSliceType) {
pNalHeadExt->bIdrFlag = 1;
pCurSlice->sScaleShift = 0;
@@ -1639,7 +1645,7 @@
//RomRC init slice by slice
if (pWelsSvcRc->bGomRC) {
- GomRCInitForOneSlice(pCurSlice, pWelsSvcRc->iBitsPerMb);
+ GomRCInitForOneSlice (pCurSlice, pWelsSvcRc->iBitsPerMb);
}
g_pWelsWriteSliceHeader[pCurSlice->bSliceHeaderExtFlag] (pEncCtx, pBs, pCurLayer, pCurSlice,
@@ -1695,7 +1701,7 @@
pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
//pNextSlice pointer/initialization
- if(pEncCtx->iActiveThreadsNum > 1) {
+ if (pEncCtx->iActiveThreadsNum > 1) {
pNextSlice = &pSliceBuffer[ iCodedSliceNum + 1 ];
} else {
pNextSlice = &pSliceBuffer[ iNextSliceIdc ];
--- a/codec/encoder/core/src/svc_motion_estimate.cpp
+++ b/codec/encoder/core/src/svc_motion_estimate.cpp
@@ -173,7 +173,8 @@
kiStrideRef);
}
-void WelsMotionEstimateSearchStatic (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe, SSlice* pLpslice) {
+void WelsMotionEstimateSearchStatic (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe,
+ SSlice* pLpslice) {
const int32_t kiStrideEnc = pCurDqLayer->iEncStride[0];
const int32_t kiStrideRef = pCurDqLayer->pRefPic->iLineSize[0];
@@ -186,7 +187,8 @@
kiStrideRef);
}
-void WelsMotionEstimateSearchScrolled (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe, SSlice* pSlice) {
+void WelsMotionEstimateSearchScrolled (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe,
+ SSlice* pSlice) {
const int32_t kiStrideEnc = pCurDqLayer->iEncStride[0];
const int32_t kiStrideRef = pCurDqLayer->pRefPic->iLineSize[0];
@@ -709,7 +711,7 @@
pScreenBlockFeatureStorage->iIs16x16 = !bIsBlock8x8;
pScreenBlockFeatureStorage->uiFeatureStrategyIndex = kiFeatureStrategyIndex;
pScreenBlockFeatureStorage->iActualListSize = kiListSize;
- WelsSetMemMultiplebytes_c (pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL, sizeof(uint32_t));
+ WelsSetMemMultiplebytes_c (pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL, sizeof (uint32_t));
pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false;
return ENC_RETURN_SUCCESS;
--- a/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp
+++ b/codec/encoder/core/src/svc_set_mb_syn_cabac.cpp
@@ -523,9 +523,9 @@
}
int32_t WelsCalNonZeroCount2x2Block (int16_t* pBlock) {
return (pBlock[0] != 0)
- + (pBlock[1] != 0)
- + (pBlock[2] != 0)
- + (pBlock[3] != 0);
+ + (pBlock[1] != 0)
+ + (pBlock[2] != 0)
+ + (pBlock[3] != 0);
}
int32_t WelsWriteMbResidualCabac (SWelsFuncPtrList* pFuncList, SSlice* pSlice, SMbCache* sMbCacheInfo, SMB* pCurMb,
SCabacCtx* pCabacCtx,
--- a/codec/encoder/core/src/wels_task_encoder.cpp
+++ b/codec/encoder/core/src/wels_task_encoder.cpp
@@ -116,7 +116,7 @@
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
m_pSliceBs = &m_pSlice->sSliceBs;
- iReturn = SetSliceBoundaryInfo(m_pCtx->pCurDqLayer, m_pSlice, m_iSliceIdx);
+ iReturn = SetSliceBoundaryInfo (m_pCtx->pCurDqLayer, m_pSlice, m_iSliceIdx);
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
SetOneSliceBsBufferUnderMultithread (m_pCtx, m_iThreadIdx, m_pSlice);
@@ -244,7 +244,7 @@
bool bNeedReallocate = false;
int32_t iDiffMbIdx = kiEndMbIdxInPartition - kiFirstMbInPartition;
- if( 0 == iDiffMbIdx) {
+ if (0 == iDiffMbIdx) {
m_pSlice->iSliceIdx = -1;
return ENC_RETURN_SUCCESS;
}
@@ -252,17 +252,17 @@
int32_t iAnyMbLeftInPartition = iDiffMbIdx + 1;
int32_t iLocalSliceIdx = m_iSliceIdx;
while (iAnyMbLeftInPartition > 0) {
- bNeedReallocate = (pCurDq->sSliceBufferInfo[m_iThreadIdx].iCodedSliceNum
- >= pCurDq->sSliceBufferInfo[m_iThreadIdx].iMaxSliceNum -1) ? true : false;
- if (bNeedReallocate) {
- WelsMutexLock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate);
- //for memory statistic variable
- iReturn = ReallocateSliceInThread(m_pCtx, pCurDq, m_pCtx->uiDependencyId, m_iThreadIdx);
- WelsMutexUnlock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate);
- if (ENC_RETURN_SUCCESS != iReturn) {
- return iReturn;
- }
+ bNeedReallocate = (pCurDq->sSliceBufferInfo[m_iThreadIdx].iCodedSliceNum
+ >= pCurDq->sSliceBufferInfo[m_iThreadIdx].iMaxSliceNum - 1) ? true : false;
+ if (bNeedReallocate) {
+ WelsMutexLock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate);
+ //for memory statistic variable
+ iReturn = ReallocateSliceInThread (m_pCtx, pCurDq, m_pCtx->uiDependencyId, m_iThreadIdx);
+ WelsMutexUnlock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate);
+ if (ENC_RETURN_SUCCESS != iReturn) {
+ return iReturn;
}
+ }
iReturn = InitOneSliceInThread (m_pCtx, m_pSlice, m_iThreadIdx, m_pCtx->uiDependencyId, iLocalSliceIdx);
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
--- a/codec/encoder/core/src/wels_task_management.cpp
+++ b/codec/encoder/core/src/wels_task_management.cpp
@@ -197,7 +197,7 @@
void CWelsTaskManageBase::OnTaskMinusOne() {
//fprintf(stdout, "OnTaskMinusOne event %x m_iWaitTaskNum=%d\n", &m_hEventMutex, m_iWaitTaskNum);
WelsCommon::CWelsAutoLock cAutoLock (m_cWaitTaskNumLock);
- WelsEventSignal (&m_hTaskEvent,&m_hEventMutex, &m_iWaitTaskNum);
+ WelsEventSignal (&m_hTaskEvent, &m_hEventMutex, &m_iWaitTaskNum);
/*WelsMutexLock(&m_hEventMutex);
m_iWaitTaskNum --;
WelsMutexUnlock(&m_hEventMutex);
@@ -234,7 +234,7 @@
iIdx ++;
}
- WelsEventWait (&m_hTaskEvent,&m_hEventMutex, m_iWaitTaskNum);
+ WelsEventWait (&m_hTaskEvent, &m_hEventMutex, m_iWaitTaskNum);
return ENC_RETURN_SUCCESS;
}