Unified · Split
| @@ -76,7 +76,7 @@ static inline int32_t WelsCheckLevelLimitation (const SWelsSPS* kpSps, const SLe · 75 unmodified lines | ||
| 76 | 76 | int32_t WelsAdjustLevel (SSpatialLayerConfig* pSpatialLayer, const SLevelLimits* pCurLevel) { |
| 77 | 77 | int32_t iMaxBitrate = pSpatialLayer->iMaxSpatialBitrate; |
| 78 | 78 | do { |
| 79 | − if (iMaxBitrate <= (int32_t)(pCurLevel->uiMaxBR * CpbBrNalFactor)) { | |
| 79 | + if (iMaxBitrate <= (int32_t) (pCurLevel->uiMaxBR * CpbBrNalFactor)) { | |
| 80 | 80 | pSpatialLayer->uiLevelIdc = pCurLevel->uiLevelIdc; |
| 81 | 81 | return 0; |
| 82 | 82 | } |
| @@ -198,12 +198,12 @@ int32_t WelsWriteVUI (SWelsSPS* pSps, SBitStringAux* pBitStringAux) { · 115 unmodified lines | ||
| 198 | 198 | SBitStringAux* pLocalBitStringAux = pBitStringAux; |
| 199 | 199 | assert (pSps != NULL && pBitStringAux != NULL); |
| 200 | 200 | |
| 201 | − BsWriteOneBit(pLocalBitStringAux, pSps->bAspectRatioPresent); //aspect_ratio_info_present_flag | |
| 201 | + BsWriteOneBit (pLocalBitStringAux, pSps->bAspectRatioPresent); //aspect_ratio_info_present_flag | |
| 202 | 202 | if (pSps->bAspectRatioPresent) { |
| 203 | − BsWriteBits(pLocalBitStringAux, 8, pSps->eAspectRatio); // aspect_ratio_idc | |
| 203 | + BsWriteBits (pLocalBitStringAux, 8, pSps->eAspectRatio); // aspect_ratio_idc | |
| 204 | 204 | if (pSps->eAspectRatio == ASP_EXT_SAR) { |
| 205 | − BsWriteBits(pLocalBitStringAux, 16, pSps->sAspectRatioExtWidth); // sar_width | |
| 206 | − BsWriteBits(pLocalBitStringAux, 16, pSps->sAspectRatioExtHeight); // sar_height | |
| 205 | + BsWriteBits (pLocalBitStringAux, 16, pSps->sAspectRatioExtWidth); // sar_width | |
| 206 | + BsWriteBits (pLocalBitStringAux, 16, pSps->sAspectRatioExtHeight); // sar_height | |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | BsWriteOneBit (pLocalBitStringAux, false); //overscan_info_present_flag |
| @@ -364,8 +364,8 @@ void DeblockingInterMb (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFi · 363 unmodified lines | ||
| 364 | 364 | int32_t iMbX = pCurMb->iMbX; |
| 365 | 365 | int32_t iMbY = pCurMb->iMbY; |
| 366 | 366 | |
| 367 | − bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 368 | − bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 367 | + bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 368 | + bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 369 | 369 | |
| 370 | 370 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 371 | 371 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; |
| @@ -450,8 +450,8 @@ void FilteringEdgeLumaHV (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblocking · 78 unmodified lines | ||
| 450 | 450 | int32_t iMbX = pCurMb->iMbX; |
| 451 | 451 | int32_t iMbY = pCurMb->iMbY; |
| 452 | 452 | |
| 453 | − bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 454 | − bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 453 | + bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 454 | + bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 455 | 455 | |
| 456 | 456 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 457 | 457 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; |
| @@ -505,8 +505,8 @@ void FilteringEdgeChromaHV (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblocki · 47 unmodified lines | ||
| 505 | 505 | int32_t iMbX = pCurMb->iMbX; |
| 506 | 506 | int32_t iMbY = pCurMb->iMbY; |
| 507 | 507 | |
| 508 | − bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 509 | − bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 508 | + bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 509 | + bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 510 | 510 | |
| 511 | 511 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 512 | 512 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; |
| @@ -634,8 +634,8 @@ void DeblockingMbAvcbase (SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilte · 121 unmodified lines | ||
| 634 | 634 | int32_t iMbX = pCurMb->iMbX; |
| 635 | 635 | int32_t iMbY = pCurMb->iMbY; |
| 636 | 636 | |
| 637 | − bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 638 | − bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 637 | + bool bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0)&& (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | |
| 638 | + bool bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0)&& (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 639 | 639 | |
| 640 | 640 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 641 | 641 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; |
| @@ -754,7 +754,7 @@ void PerformDeblockingFilter (sWelsEncCtx* pEnc) { · 112 unmodified lines | ||
| 754 | 754 | iSliceCount = GetCurrentSliceNum (pCurLayer); |
| 755 | 755 | do { |
| 756 | 756 | pSlice = pCurLayer->ppSliceInLayer[iSliceIdx]; |
| 757 | − assert( NULL != pSlice); | |
| 757 | + assert (NULL != pSlice); | |
| 758 | 758 | DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, pSlice); |
| 759 | 759 | ++ iSliceIdx; |
| 760 | 760 | } while (iSliceIdx < iSliceCount); |
| @@ -104,15 +104,16 @@ void WelsI4x4LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) · 103 unmodified lines | ||
| 104 | 104 | WelsFillingPred8x2to16 (pPred, uiSrc); |
| 105 | 105 | } |
| 106 | 106 | void WelsI4x4LumaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { |
| 107 | − const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + kiStride - 1] + | |
| 108 | − pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 4) >> 3; | |
| 107 | + const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + | |
| 108 | + kiStride - 1] + | |
| 109 | + pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 4) >> 3; | |
| 109 | 110 | |
| 110 | 111 | WelsFillingPred1to16 (pPred, kuiDcValue); |
| 111 | 112 | } |
| 112 | 113 | |
| 113 | 114 | void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { |
| 114 | 115 | const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + |
| 115 | − kiStride - 1] + 2) >> 2; | |
| 116 | + kiStride - 1] + 2) >> 2; | |
| 116 | 117 | |
| 117 | 118 | WelsFillingPred1to16 (pPred, kuiDcValue); |
| 118 | 119 | } |
| @@ -446,10 +446,14 @@ int32_t AnalysisVaaInfoIntra_c (uint8_t* pDataY, const int32_t kiLineSize) { · 445 unmodified lines | ||
| 446 | 446 | for (; j < 16; j += 4) { |
| 447 | 447 | num = 0; |
| 448 | 448 | for (i = 0; i < 16; i += 4, num ++) { |
| 449 | − pBlock[num] = pEncData[i ] + pEncData[i + 1 ] + pEncData[i + 2 ] + pEncData[i + 3 ]; | |
| 450 | − pBlock[num] += pEncData[i + kiLineSize ] + pEncData[i + kiLineSize + 1] + pEncData[i + kiLineSize + 2] + pEncData[i + kiLineSize + 3]; | |
| 451 | − pBlock[num] += pEncData[i + kiLineSize2] + pEncData[i + kiLineSize2 + 1] + pEncData[i + kiLineSize2 + 2] + pEncData[i + kiLineSize2 + 3]; | |
| 452 | − pBlock[num] += pEncData[i + kiLineSize3] + pEncData[i + kiLineSize3 + 1] + pEncData[i + kiLineSize3 + 2] + pEncData[i + kiLineSize3 + 3]; | |
| 449 | + pBlock[num] = pEncData[i ] + pEncData[i + 1 ] + pEncData[i + 2 ] + pEncData[i + | |
| 450 | + 3 ]; | |
| 451 | + pBlock[num] += pEncData[i + kiLineSize ] + pEncData[i + kiLineSize + 1] + pEncData[i + kiLineSize + 2] + pEncData[i + | |
| 452 | + kiLineSize + 3]; | |
| 453 | + pBlock[num] += pEncData[i + kiLineSize2] + pEncData[i + kiLineSize2 + 1] + pEncData[i + kiLineSize2 + 2] + pEncData[i + | |
| 454 | + kiLineSize2 + 3]; | |
| 455 | + pBlock[num] += pEncData[i + kiLineSize3] + pEncData[i + kiLineSize3 + 1] + pEncData[i + kiLineSize3 + 2] + pEncData[i + | |
| 456 | + kiLineSize3 + 3]; | |
| 453 | 457 | pBlock[num] >>= 4; |
| 454 | 458 | } |
| 455 | 459 | pBlock += 4; |
| @@ -143,21 +143,21 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t · 142 unmodified lines | ||
| 143 | 143 | |
| 144 | 144 | /* NAL Unit Header */ |
| 145 | 145 | *pDstPointer++ = (pRawNal->sNalExt.sNalUnitHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalUnitHeader.eNalUnitType & |
| 146 | − 0x1f); | |
| 146 | + 0x1f); | |
| 147 | 147 | |
| 148 | 148 | if (kbNALExt) { |
| 149 | 149 | SNalUnitHeaderExt* sNalExt = (SNalUnitHeaderExt*)pNalHeaderExt; |
| 150 | 150 | |
| 151 | 151 | /* NAL UNIT Extension Header */ |
| 152 | 152 | *pDstPointer++ = (0x80) | |
| 153 | − (sNalExt->bIdrFlag << 6); | |
| 153 | + (sNalExt->bIdrFlag << 6); | |
| 154 | 154 | |
| 155 | 155 | *pDstPointer++ = (0x80) | |
| 156 | − (sNalExt->uiDependencyId << 4); | |
| 156 | + (sNalExt->uiDependencyId << 4); | |
| 157 | 157 | |
| 158 | 158 | *pDstPointer++ = (sNalExt->uiTemporalId << 5) | |
| 159 | − (sNalExt->bDiscardableFlag << 3) | | |
| 160 | − (0x07); | |
| 159 | + (sNalExt->bDiscardableFlag << 3) | | |
| 160 | + (0x07); | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | while (pSrcPointer < pSrcEnd) { |
| @@ -68,7 +68,7 @@ SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth , const int32_t · 67 unmodified lines | ||
| 68 | 68 | iPicChromaWidth = iPicWidth >> 1; |
| 69 | 69 | iPicChromaHeight = iPicHeight >> 1; |
| 70 | 70 | iPicWidth = WELS_ALIGN (iPicWidth, |
| 71 | − 32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size | |
| 71 | + 32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size | |
| 72 | 72 | iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16); |
| 73 | 73 | iLumaSize = iPicWidth * iPicHeight; |
| 74 | 74 | iChromaSize = iPicChromaWidth * iPicChromaHeight; |
| @@ -450,9 +450,9 @@ bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx) { · 449 unmodified lines | ||
| 450 | 450 | return true; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | −static inline void WelsMarkMMCORefInfoWithBase(SSlice** ppSliceList, | |
| 454 | − SSlice* pBaseSlice, | |
| 455 | − const int32_t kiCountSliceNum) { | |
| 453 | +static inline void WelsMarkMMCORefInfoWithBase (SSlice** ppSliceList, | |
| 454 | + SSlice* pBaseSlice, | |
| 455 | + const int32_t kiCountSliceNum) { | |
| 456 | 456 | int32_t iSliceIdx = 0; |
| 457 | 457 | SSliceHeaderExt* pSliceHdrExt = NULL; |
| 458 | 458 | SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt; |
| @@ -488,7 +488,7 @@ void WelsMarkMMCORefInfo (sWelsEncCtx* pCtx, SLTRState* pLtr, · 29 unmodified lines | ||
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | − WelsMarkMMCORefInfoWithBase(ppSliceList, pBaseSlice, kiCountSliceNum); | |
| 491 | + WelsMarkMMCORefInfoWithBase (ppSliceList, pBaseSlice, kiCountSliceNum); | |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | void WelsMarkPic (sWelsEncCtx* pCtx) { |
| @@ -906,7 +906,7 @@ void WelsMarkMMCORefInfoScreen (sWelsEncCtx* pCtx, SLTRState* pLtr, · 411 unmodified lines | ||
| 906 | 906 | pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount++].iMmcoType = MMCO_LONG; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | − WelsMarkMMCORefInfoWithBase(ppSliceList, pBaseSlice, kiCountSliceNum); | |
| 909 | + WelsMarkMMCORefInfoWithBase (ppSliceList, pBaseSlice, kiCountSliceNum); | |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | void WelsMarkPicScreen (sWelsEncCtx* pCtx) { |
| @@ -53,7 +53,7 @@ const int8_t g_kiClz5Table[32] = { · 52 unmodified lines | ||
| 53 | 53 | |
| 54 | 54 | void PropagateCarry (uint8_t* pBufCur, uint8_t* pBufStart) { |
| 55 | 55 | for (; pBufCur > pBufStart; --pBufCur) |
| 56 | − if (++*(pBufCur - 1)) | |
| 56 | + if (++ * (pBufCur - 1)) | |
| 57 | 57 | break; |
| 58 | 58 | } |
| 59 | 59 | |
| @@ -133,7 +133,7 @@ void WelsCabacEncodeUpdateLowNontrivial_ (SCabacCtx* pCbCtx) { · 73 unmodified lines | ||
| 133 | 133 | void WelsCabacEncodeDecisionLps_ (SCabacCtx* pCbCtx, int32_t iCtx) { |
| 134 | 134 | const int32_t kiState = pCbCtx->m_sStateCtx[iCtx].State(); |
| 135 | 135 | uint32_t uiRange = pCbCtx->m_uiRange; |
| 136 | − uint32_t uiRangeLps = g_kuiCabacRangeLps[kiState][(uiRange & 0xff) >> 6]; | |
| 136 | + uint32_t uiRangeLps = g_kuiCabacRangeLps[kiState][ (uiRange & 0xff) >> 6]; | |
| 137 | 137 | uiRange -= uiRangeLps; |
| 138 | 138 | pCbCtx->m_sStateCtx[iCtx].Set (g_kuiStateTransTable[kiState][0], |
| 139 | 139 | pCbCtx->m_sStateCtx[iCtx].Mps() ^ (kiState == 0)); |
| @@ -193,7 +193,7 @@ void WelsCabacEncodeFlush (SCabacCtx* pCbCtx) { · 53 unmodified lines | ||
| 193 | 193 | if (uiLow & cabac_low_t (1) << (CABAC_LOW_WIDTH - 1)) |
| 194 | 194 | PropagateCarry (pBufCur, pCbCtx->m_pBufStart); |
| 195 | 195 | for (; (iLowBitCnt -= 8) >= 0; uiLow <<= 8) |
| 196 | − *pBufCur++ = (uint8_t) (uiLow >> (CABAC_LOW_WIDTH - 9)); | |
| 196 | + * pBufCur++ = (uint8_t) (uiLow >> (CABAC_LOW_WIDTH - 9)); | |
| 197 | 197 | |
| 198 | 198 | pCbCtx->m_pBufCur = pBufCur; |
| 199 | 199 | } |
| @@ -93,7 +93,7 @@ void CalcSliceComplexRatio (SDqLayer* pCurDq) { · 92 unmodified lines | ||
| 93 | 93 | int32_t iSliceIdx = 0; |
| 94 | 94 | int32_t iAvI[MAX_SLICES_NUM]; |
| 95 | 95 | |
| 96 | − assert(kiSliceCount <= MAX_SLICES_NUM); | |
| 96 | + assert (kiSliceCount <= MAX_SLICES_NUM); | |
| 97 | 97 | WelsEmms(); |
| 98 | 98 | |
| 99 | 99 | while (iSliceIdx < kiSliceCount) { |
| @@ -112,7 +112,7 @@ void CalcSliceComplexRatio (SDqLayer* pCurDq) { · 12 unmodified lines | ||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | int32_t NeedDynamicAdjust (SSlice** ppSliceInLayer, const int32_t iSliceNum) { |
| 115 | − if ( NULL == ppSliceInLayer ) { | |
| 115 | + if (NULL == ppSliceInLayer) { | |
| 116 | 116 | return false; |
| 117 | 117 | } |
| 118 | 118 | |
| @@ -123,7 +123,7 @@ int32_t NeedDynamicAdjust (SSlice** ppSliceInLayer, const int32_t iSliceNum) { · 4 unmodified lines | ||
| 123 | 123 | WelsEmms(); |
| 124 | 124 | |
| 125 | 125 | while (iSliceIdx < iSliceNum) { |
| 126 | − if ( NULL == ppSliceInLayer[iSliceIdx] ) { | |
| 126 | + if (NULL == ppSliceInLayer[iSliceIdx]) { | |
| 127 | 127 | return false; |
| 128 | 128 | } |
| 129 | 129 | |
| @@ -232,7 +232,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 102 unmodified lines | ||
| 232 | 232 | return; |
| 233 | 233 | } |
| 234 | 234 | iRunLen[iSliceIdx] = iNumMbAssigning; |
| 235 | − MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG, | |
| 235 | + MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_DEBUG, | |
| 236 | 236 | "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d", |
| 237 | 237 | iSliceIdx, ppSliceInLayer[iSliceIdx]->iSliceComplexRatio * 1.0f / INT_MULTIPLY, |
| 238 | 238 | ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice, |
| @@ -437,24 +437,24 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 198 unmodified lines | ||
| 437 | 437 | while (iSliceIdx < iSliceCount) { |
| 438 | 438 | pSliceBs = &ppSliceInlayer[iSliceIdx]->sSliceBs; |
| 439 | 439 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { |
| 440 | − int32_t iNalIdx = 0; | |
| 441 | − const int32_t iCountNal = pSliceBs->iNalIndex; | |
| 440 | + int32_t iNalIdx = 0; | |
| 441 | + const int32_t iCountNal = pSliceBs->iNalIndex; | |
| 442 | 442 | |
| 443 | 443 | #if MT_DEBUG_BS_WR |
| 444 | − assert (pSliceBs->bSliceCodedFlag); | |
| 444 | + assert (pSliceBs->bSliceCodedFlag); | |
| 445 | 445 | #endif//MT_DEBUG_BS_WR |
| 446 | 446 | |
| 447 | − memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | |
| 448 | − pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | |
| 447 | + memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | |
| 448 | + pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | |
| 449 | 449 | |
| 450 | − iLayerSize += pSliceBs->uiBsPos; | |
| 450 | + iLayerSize += pSliceBs->uiBsPos; | |
| 451 | 451 | |
| 452 | − while (iNalIdx < iCountNal) { | |
| 452 | + while (iNalIdx < iCountNal) { | |
| 453 | 453 | pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; |
| 454 | 454 | ++ iNalIdx; |
| 455 | − } | |
| 456 | − pLbi->iNalCount += iCountNal; | |
| 457 | − iNalIdxBase += iCountNal; | |
| 455 | + } | |
| 456 | + pLbi->iNalCount += iCountNal; | |
| 457 | + iNalIdxBase += iCountNal; | |
| 458 | 458 | } |
| 459 | 459 | ++ iSliceIdx; |
| 460 | 460 | } |
| @@ -615,7 +615,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 154 unmodified lines | ||
| 615 | 615 | int32_t iMaxI = 0; |
| 616 | 616 | while (i < kuiCountSliceNum) { |
| 617 | 617 | fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6d us consume_time coding_idx %d iDid %d pSlice %d\n", |
| 618 | − ppSliceInLayer[i]->uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/); | |
| 618 | + ppSliceInLayer[i]->uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/); | |
| 619 | 619 | if (ppSliceInLayer[i]->uiSliceConsumeTime > uiMaxT) { |
| 620 | 620 | uiMaxT = ppSliceInLayer[i]->uiSliceConsumeTime; |
| 621 | 621 | iMaxI = i; |
| @@ -67,7 +67,7 @@ int32_t AssignMbMapSingleSlice (void* pMbMap, const int32_t kiCountMbNum, const · 66 unmodified lines | ||
| 67 | 67 | * |
| 68 | 68 | * \return 0 - successful; none 0 - failed |
| 69 | 69 | */ |
| 70 | −int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSliceArgument) { | |
| 70 | +int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq, const SSliceArgument* kpSliceArgument) { | |
| 71 | 71 | SSliceCtx* pSliceSeg = &pCurDq->sSliceEncCtx; |
| 72 | 72 | int32_t iSliceIdx = 0; |
| 73 | 73 | if (NULL == pSliceSeg || SM_SINGLE_SLICE == pSliceSeg->uiSliceMode) |
| @@ -80,8 +80,8 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 6 unmodified lines | ||
| 80 | 80 | iSliceIdx = 0; |
| 81 | 81 | while (iSliceIdx < iSliceNum) { |
| 82 | 82 | const int32_t kiFirstMb = iSliceIdx * kiMbWidth; |
| 83 | − WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx, | |
| 84 | − kiMbWidth, sizeof(uint16_t)); | |
| 83 | + WelsSetMemMultiplebytes_c (pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx, | |
| 84 | + kiMbWidth, sizeof (uint16_t)); | |
| 85 | 85 | ++ iSliceIdx; |
| 86 | 86 | } |
| 87 | 87 | |
| @@ -108,7 +108,7 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 20 unmodified lines | ||
| 108 | 108 | ++ iSliceIdx; |
| 109 | 109 | } while (iSliceIdx < kiCountSliceNumInFrame && iMbIdx < kiCountNumMbInFrame); |
| 110 | 110 | } else if (SM_SIZELIMITED_SLICE == pSliceSeg->uiSliceMode) { |
| 111 | − // do nothing,pSliceSeg->pOverallMbMap will be initial later | |
| 111 | + // do nothing,pSliceSeg->pOverallMbMap will be initial later | |
| 112 | 112 | } else { // any else uiSliceMode? |
| 113 | 113 | assert (0); |
| 114 | 114 | } |
| @@ -139,7 +139,7 @@ bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceAr · 24 unmodified lines | ||
| 139 | 139 | |
| 140 | 140 | pSlicesAssignList[uiSliceIdx] = iNumMbLeft; |
| 141 | 141 | |
| 142 | − if (iNumMbLeft <= 0 || kiMbNumPerSlice <= 0 ) { | |
| 142 | + if (iNumMbLeft <= 0 || kiMbNumPerSlice <= 0) { | |
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | |
| @@ -287,7 +287,7 @@ bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, · 141 unmodified lines | ||
| 287 | 287 | if (iNumMbAssigning < iMinimalMbNum) |
| 288 | 288 | iCurNumMbAssigning = iMinimalMbNum; |
| 289 | 289 | else if (iNumMbAssigning > iMaximalMbNum) |
| 290 | − iCurNumMbAssigning = ( iMaximalMbNum / iGomSize ) * iGomSize; | |
| 290 | + iCurNumMbAssigning = (iMaximalMbNum / iGomSize) * iGomSize; | |
| 291 | 291 | else |
| 292 | 292 | iCurNumMbAssigning = iNumMbAssigning; |
| 293 | 293 | |
| @@ -304,7 +304,7 @@ bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, · 10 unmodified lines | ||
| 304 | 304 | ++ uiSliceIdx; |
| 305 | 305 | } |
| 306 | 306 | pSlicesAssignList[uiSliceIdx] = iNumMbLeft; |
| 307 | − if ( iNumMbLeft < iMinimalMbNum ) { | |
| 307 | + if (iNumMbLeft < iMinimalMbNum) { | |
| 308 | 308 | return false; |
| 309 | 309 | } |
| 310 | 310 | |
| @@ -321,19 +321,18 @@ int32_t GetInitialSliceNum (SSliceArgument* pSliceArgument) { · 10 unmodified lines | ||
| 321 | 321 | return -1; |
| 322 | 322 | |
| 323 | 323 | switch (pSliceArgument->uiSliceMode) { |
| 324 | − case SM_SINGLE_SLICE: | |
| 325 | − case SM_FIXEDSLCNUM_SLICE: | |
| 326 | − case SM_RASTER_SLICE: | |
| 327 | − { | |
| 328 | − return pSliceArgument->uiSliceNum; | |
| 329 | − } | |
| 330 | − case SM_SIZELIMITED_SLICE: { | |
| 331 | − return AVERSLICENUM_CONSTRAINT;//at the beginning of dynamic slicing, set the uiSliceNum to be 1 | |
| 332 | − } | |
| 333 | − case SM_RESERVED: | |
| 334 | − default: { | |
| 335 | − return -1; | |
| 336 | − } | |
| 324 | + case SM_SINGLE_SLICE: | |
| 325 | + case SM_FIXEDSLCNUM_SLICE: | |
| 326 | + case SM_RASTER_SLICE: { | |
| 327 | + return pSliceArgument->uiSliceNum; | |
| 328 | + } | |
| 329 | + case SM_SIZELIMITED_SLICE: { | |
| 330 | + return AVERSLICENUM_CONSTRAINT;//at the beginning of dynamic slicing, set the uiSliceNum to be 1 | |
| 331 | + } | |
| 332 | + case SM_RESERVED: | |
| 333 | + default: { | |
| 334 | + return -1; | |
| 335 | + } | |
| 337 | 336 | } |
| 338 | 337 | |
| 339 | 338 | return -1; |
| @@ -395,13 +394,13 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 55 unmodified lines | ||
| 395 | 394 | return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0])); |
| 396 | 395 | } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode ) |
| 397 | 396 | if (uiSliceMode != SM_FIXEDSLCNUM_SLICE && uiSliceMode != SM_RASTER_SLICE |
| 398 | − && uiSliceMode != SM_SIZELIMITED_SLICE ) | |
| 397 | + && uiSliceMode != SM_SIZELIMITED_SLICE) | |
| 399 | 398 | return 1; |
| 400 | 399 | |
| 401 | 400 | pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMallocz (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap"); |
| 402 | 401 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) |
| 403 | 402 | |
| 404 | − WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap, 0, kiCountMbNum, sizeof(uint16_t)); | |
| 403 | + WelsSetMemMultiplebytes_c (pSliceSeg->pOverallMbMap, 0, kiCountMbNum, sizeof (uint16_t)); | |
| 405 | 404 | |
| 406 | 405 | //SM_SIZELIMITED_SLICE: init, set pSliceSeg->iSliceNumInFrame = 1; |
| 407 | 406 | pSliceSeg->iSliceNumInFrame = GetInitialSliceNum (pSliceArgument); |
| @@ -533,7 +532,7 @@ uint16_t WelsMbToSliceIdc (SDqLayer* pCurDq, const int32_t kiMbXY) { · 125 unmodified lines | ||
| 533 | 532 | * \return iFirstMb - successful; -1 - failed; |
| 534 | 533 | */ |
| 535 | 534 | int32_t WelsGetFirstMbOfSlice (SDqLayer* pCurLayer, const int32_t kuiSliceIdc) { |
| 536 | − if ( NULL == pCurLayer || NULL == pCurLayer->pFirstMbIdxOfSlice ) { | |
| 535 | + if (NULL == pCurLayer || NULL == pCurLayer->pFirstMbIdxOfSlice) { | |
| 537 | 536 | return -1; |
| 538 | 537 | } |
| 539 | 538 | |
| @@ -613,7 +612,7 @@ int32_t WelsGetPrevMbOfSlice (SDqLayer* pCurDq, const int32_t kiMbXY) { · 73 unmodified lines | ||
| 613 | 612 | * |
| 614 | 613 | * \return count_num_of_mb - successful; -1 - failed; |
| 615 | 614 | */ |
| 616 | −int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, SSlice* pSlice, const int32_t kuiSliceIdc) { | |
| 615 | +int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, SSlice* pSlice, const int32_t kuiSliceIdc) { | |
| 617 | 616 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 618 | 617 | bool bInValidFlag = false; |
| 619 | 618 | |
| @@ -623,7 +622,7 @@ int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, SSlice* pSlice, const int32_t ku · 3 unmodified lines | ||
| 623 | 622 | |
| 624 | 623 | bInValidFlag = ((SM_SINGLE_SLICE != pSliceCtx->uiSliceMode) && (kuiSliceIdc >= pSliceCtx->iSliceNumInFrame)) |
| 625 | 624 | || ((SM_SINGLE_SLICE == pSliceCtx->uiSliceMode) && (kuiSliceIdc > 0)); |
| 626 | − if(bInValidFlag) { | |
| 625 | + if (bInValidFlag) { | |
| 627 | 626 | return -1; |
| 628 | 627 | } |
| 629 | 628 | |
| @@ -662,8 +661,8 @@ int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq, · 32 unmodified lines | ||
| 662 | 661 | pCurDq->pFirstMbIdxOfSlice[iSliceIdx] = iFirstMbIdx; |
| 663 | 662 | pCurDq->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; |
| 664 | 663 | |
| 665 | − WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, | |
| 666 | − kiSliceRun, sizeof(uint16_t)); | |
| 664 | + WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, | |
| 665 | + kiSliceRun, sizeof (uint16_t)); | |
| 667 | 666 | |
| 668 | 667 | iFirstMbIdx += kiSliceRun; |
| 669 | 668 | |
| @@ -827,7 +827,7 @@ int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, · 826 unmodified lines | ||
| 827 | 827 | int32_t iFirstMBInSlice = 0; |
| 828 | 828 | int32_t iMbNumInSlice = 0; |
| 829 | 829 | |
| 830 | − for( ;iSliceIdx < kiSliceNumInFrame; iSliceIdx++ ){ | |
| 830 | + for (; iSliceIdx < kiSliceNumInFrame; iSliceIdx++) { | |
| 831 | 831 | if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) { |
| 832 | 832 | iFirstMBInSlice = 0; |
| 833 | 833 | iMbNumInSlice = kiCountNumMbInFrame; |
| @@ -836,7 +836,7 @@ int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, · 2 unmodified lines | ||
| 836 | 836 | iFirstMBInSlice = iSliceIdx * kiMBWidth; |
| 837 | 837 | iMbNumInSlice = kiMBWidth; |
| 838 | 838 | } else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode || |
| 839 | − SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) { | |
| 839 | + SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) { | |
| 840 | 840 | int32_t iMbIdx = 0; |
| 841 | 841 | for (int i = 0; i < iSliceIdx; i++) { |
| 842 | 842 | iMbIdx += kpSlicesAssignList[i]; |
| @@ -864,10 +864,10 @@ int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, · 21 unmodified lines | ||
| 864 | 864 | return ENC_RETURN_SUCCESS; |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | −int32_t SetSliceBoundaryInfo(SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) { | |
| 868 | − if(NULL == pCurLayer || NULL == pSlice || | |
| 869 | − NULL == pCurLayer->pFirstMbIdxOfSlice || | |
| 870 | − NULL == pCurLayer->pCountMbNumInSlice) { | |
| 867 | +int32_t SetSliceBoundaryInfo (SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) { | |
| 868 | + if (NULL == pCurLayer || NULL == pSlice || | |
| 869 | + NULL == pCurLayer->pFirstMbIdxOfSlice || | |
| 870 | + NULL == pCurLayer->pCountMbNumInSlice) { | |
| 871 | 871 | |
| 872 | 872 | return ENC_RETURN_UNEXPECTED; |
| 873 | 873 | } |
| @@ -977,15 +977,15 @@ int32_t InitAllSlicesInThread (sWelsEncCtx* pCtx) { · 103 unmodified lines | ||
| 977 | 977 | int32_t iSliceIdx = 0; |
| 978 | 978 | int32_t iSlcBuffIdx = 0; |
| 979 | 979 | |
| 980 | − for( ; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) { | |
| 981 | − if(NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) { | |
| 980 | + for (; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) { | |
| 981 | + if (NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) { | |
| 982 | 982 | return ENC_RETURN_UNEXPECTED; |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | pCurDqLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx = -1; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | − for( ; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | |
| 988 | + for (; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | |
| 989 | 989 | pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iCodedSliceNum = 0; |
| 990 | 990 | } |
| 991 | 991 | |
| @@ -999,11 +999,11 @@ int32_t InitOneSliceInThread (sWelsEncCtx* pCtx, · 7 unmodified lines | ||
| 999 | 999 | const int32_t kiSliceIdx) { |
| 1000 | 1000 | |
| 1001 | 1001 | if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) { |
| 1002 | − const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iCodedSliceNum; | |
| 1003 | − assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iMaxSliceNum -1 ); | |
| 1004 | − pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiSlcBuffIdx].pSliceBuffer[kiCodedNumInThread]; | |
| 1002 | + const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iCodedSliceNum; | |
| 1003 | + assert (kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iMaxSliceNum - 1); | |
| 1004 | + pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiSlcBuffIdx].pSliceBuffer[kiCodedNumInThread]; | |
| 1005 | 1005 | } else { |
| 1006 | − pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx]; | |
| 1006 | + pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx]; | |
| 1007 | 1007 | } |
| 1008 | 1008 | pSlice->iSliceIdx = kiSliceIdx; |
| 1009 | 1009 | pSlice->uiBufferIdx = kiSlcBuffIdx; |
| @@ -1029,7 +1029,7 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 19 unmodified lines | ||
| 1029 | 1029 | assert (iThreadNum > 0); |
| 1030 | 1030 | |
| 1031 | 1031 | //for fixed slice num case, no need to reallocate, so one slice buffer for all thread |
| 1032 | − if( pDqLayer->bThreadSlcBufferFlag) { | |
| 1032 | + if (pDqLayer->bThreadSlcBufferFlag) { | |
| 1033 | 1033 | iMaxSliceNum = pDqLayer->iMaxSliceNum / iThreadNum + 1; |
| 1034 | 1034 | iSlcBufferNum = iThreadNum; |
| 1035 | 1035 | } else { |
| @@ -1040,7 +1040,8 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 4 unmodified lines | ||
| 1040 | 1040 | while (iIdx < iSlcBufferNum) { |
| 1041 | 1041 | pDqLayer->sSliceBufferInfo[iIdx].iMaxSliceNum = iMaxSliceNum; |
| 1042 | 1042 | pDqLayer->sSliceBufferInfo[iIdx].iCodedSliceNum = 0; |
| 1043 | − pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceBuffer"); | |
| 1043 | + pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, | |
| 1044 | + "pSliceBuffer"); | |
| 1044 | 1045 | if (NULL == pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer) { |
| 1045 | 1046 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| 1046 | 1047 | "CWelsH264SVCEncoder::InitSliceThreadInfo: pSliceThreadInfo->pSliceBuffer[iIdx] is NULL"); |
| @@ -1081,21 +1082,21 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 34 unmodified lines | ||
| 1081 | 1082 | //SM_SINGLE_SLICE mode using single-thread bs writer pOut->sBsWrite |
| 1082 | 1083 | //even though multi-thread is on for other layers |
| 1083 | 1084 | pDqLayer->bSliceBsBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 && |
| 1084 | − SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false; | |
| 1085 | + SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false; | |
| 1085 | 1086 | |
| 1086 | 1087 | pDqLayer->bThreadSlcBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 && |
| 1087 | − SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? true : false; | |
| 1088 | + SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? true : false; | |
| 1088 | 1089 | |
| 1089 | 1090 | iRet = InitSliceThreadInfo (pCtx, |
| 1090 | − pDqLayer, | |
| 1091 | − kiDlayerIndex, | |
| 1092 | − pMa); | |
| 1091 | + pDqLayer, | |
| 1092 | + kiDlayerIndex, | |
| 1093 | + pMa); | |
| 1093 | 1094 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1094 | 1095 | return ENC_RETURN_MEMALLOCERR; |
| 1095 | 1096 | } |
| 1096 | 1097 | |
| 1097 | 1098 | pDqLayer->iMaxSliceNum = 0; |
| 1098 | − for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | |
| 1099 | + for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | |
| 1099 | 1100 | pDqLayer->iMaxSliceNum += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1100 | 1101 | } |
| 1101 | 1102 | |
| @@ -1105,15 +1106,19 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 3 unmodified lines | ||
| 1105 | 1106 | return ENC_RETURN_MEMALLOCERR; |
| 1106 | 1107 | } |
| 1107 | 1108 | |
| 1108 | − pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, "pFirstMbIdxOfSlice"); | |
| 1109 | + pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, | |
| 1110 | + "pFirstMbIdxOfSlice"); | |
| 1109 | 1111 | if (NULL == pDqLayer->pFirstMbIdxOfSlice) { |
| 1110 | − WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL"); | |
| 1112 | + WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, | |
| 1113 | + "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL"); | |
| 1111 | 1114 | return ENC_RETURN_MEMALLOCERR; |
| 1112 | 1115 | } |
| 1113 | 1116 | |
| 1114 | − pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, "pCountMbNumInSlice"); | |
| 1117 | + pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, | |
| 1118 | + "pCountMbNumInSlice"); | |
| 1115 | 1119 | if (NULL == pDqLayer->pCountMbNumInSlice) { |
| 1116 | − WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL"); | |
| 1120 | + WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, | |
| 1121 | + "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL"); | |
| 1117 | 1122 | return ENC_RETURN_MEMALLOCERR; |
| 1118 | 1123 | } |
| 1119 | 1124 | |
| @@ -1123,9 +1128,9 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 3 unmodified lines | ||
| 1123 | 1128 | } |
| 1124 | 1129 | |
| 1125 | 1130 | iStartIdx = 0; |
| 1126 | − for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | |
| 1127 | − for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++ ) { | |
| 1128 | − pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer+ iSliceIdx; | |
| 1131 | + for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | |
| 1132 | + for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) { | |
| 1133 | + pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; | |
| 1129 | 1134 | } |
| 1130 | 1135 | |
| 1131 | 1136 | iStartIdx += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| @@ -1135,7 +1140,7 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 3 unmodified lines | ||
| 1135 | 1140 | } |
| 1136 | 1141 | |
| 1137 | 1142 | void InitSliceHeadWithBase (SSlice* pSlice, SSlice* pBaseSlice) { |
| 1138 | − if(NULL == pSlice || NULL == pBaseSlice) { | |
| 1143 | + if (NULL == pSlice || NULL == pBaseSlice) { | |
| 1139 | 1144 | return; |
| 1140 | 1145 | } |
| 1141 | 1146 | |
| @@ -1150,7 +1155,7 @@ void InitSliceHeadWithBase (SSlice* pSlice, SSlice* pBaseSlice) { · 8 unmodified lines | ||
| 1150 | 1155 | } |
| 1151 | 1156 | |
| 1152 | 1157 | void InitSliceRefInfoWithBase (SSlice* pSlice, SSlice* pBaseSlice, const uint8_t kuiRefCount) { |
| 1153 | − if( NULL == pSlice || NULL == pBaseSlice) { | |
| 1158 | + if (NULL == pSlice || NULL == pBaseSlice) { | |
| 1154 | 1159 | return; |
| 1155 | 1160 | } |
| 1156 | 1161 | |
| @@ -1213,7 +1218,7 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 56 unmodified lines | ||
| 1213 | 1218 | for (iSliceIdx = 0; iSliceIdx < kiMaxSliceNumOld; iSliceIdx++) { |
| 1214 | 1219 | pSlice = pNewSliceList + iSliceIdx; |
| 1215 | 1220 | if (NULL == pSlice) { |
| 1216 | − FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1221 | + FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1217 | 1222 | return ENC_RETURN_MEMALLOCERR; |
| 1218 | 1223 | } |
| 1219 | 1224 | |
| @@ -1224,14 +1229,14 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 4 unmodified lines | ||
| 1224 | 1229 | |
| 1225 | 1230 | pBaseSlice = &pSliceList[0]; |
| 1226 | 1231 | if (NULL == pBaseSlice) { |
| 1227 | − FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()"); | |
| 1232 | + FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()"); | |
| 1228 | 1233 | return ENC_RETURN_MEMALLOCERR; |
| 1229 | 1234 | } |
| 1230 | 1235 | |
| 1231 | 1236 | for (iSliceIdx = kiMaxSliceNumOld; iSliceIdx < kiMaxSliceNumNew; iSliceIdx++) { |
| 1232 | 1237 | pSlice = pNewSliceList + iSliceIdx; |
| 1233 | 1238 | if (NULL == pSlice) { |
| 1234 | − FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1239 | + FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1235 | 1240 | return ENC_RETURN_MEMALLOCERR; |
| 1236 | 1241 | } |
| 1237 | 1242 | |
| @@ -1246,13 +1251,13 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 8 unmodified lines | ||
| 1246 | 1251 | iMaxSliceBufferSize, |
| 1247 | 1252 | pMA); |
| 1248 | 1253 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1249 | − FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1254 | + FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1250 | 1255 | return iRet; |
| 1251 | 1256 | } |
| 1252 | 1257 | |
| 1253 | 1258 | iRet = AllocateSliceMBBuffer (pSlice, pMA); |
| 1254 | 1259 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1255 | − FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1260 | + FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1256 | 1261 | return iRet; |
| 1257 | 1262 | } |
| 1258 | 1263 | |
| @@ -1261,7 +1266,7 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 2 unmodified lines | ||
| 1261 | 1266 | |
| 1262 | 1267 | iRet = InitSliceRC (pSlice, pCtx->iGlobalQp); |
| 1263 | 1268 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1264 | − FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1269 | + FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | |
| 1265 | 1270 | return iRet; |
| 1266 | 1271 | } |
| 1267 | 1272 | } |
| @@ -1276,11 +1281,11 @@ int32_t CalculateNewSliceNum (sWelsEncCtx* pCtx, · 8 unmodified lines | ||
| 1276 | 1281 | SSlice* pLastCodedSlice, |
| 1277 | 1282 | const int32_t iMaxSliceNumOld, |
| 1278 | 1283 | int32_t& iMaxSliceNumNew) { |
| 1279 | − if ( NULL == pCtx || NULL == pLastCodedSlice || 0 == iMaxSliceNumOld ) { | |
| 1284 | + if (NULL == pCtx || NULL == pLastCodedSlice || 0 == iMaxSliceNumOld) { | |
| 1280 | 1285 | return ENC_RETURN_INVALIDINPUT; |
| 1281 | 1286 | } |
| 1282 | 1287 | |
| 1283 | − if ( 1 == pCtx->iActiveThreadsNum ) { | |
| 1288 | + if (1 == pCtx->iActiveThreadsNum) { | |
| 1284 | 1289 | iMaxSliceNumNew = iMaxSliceNumOld * SLICE_NUM_EXPAND_COEF; |
| 1285 | 1290 | return ENC_RETURN_SUCCESS; |
| 1286 | 1291 | } |
| @@ -1292,7 +1297,7 @@ int32_t CalculateNewSliceNum (sWelsEncCtx* pCtx, · 5 unmodified lines | ||
| 1292 | 1297 | - pCtx->pCurDqLayer->LastCodedMbIdxOfPartition[iPartitionID] + 1; |
| 1293 | 1298 | int32_t iIncreaseSlicNum = (iLeftMBNum * INT_MULTIPLY / iMBNumInPatition) * iMaxSliceNumOld; |
| 1294 | 1299 | |
| 1295 | − iIncreaseSlicNum = ( 0 == (iIncreaseSlicNum / INT_MULTIPLY) ) ? 1 : (iIncreaseSlicNum / INT_MULTIPLY); | |
| 1300 | + iIncreaseSlicNum = (0 == (iIncreaseSlicNum / INT_MULTIPLY)) ? 1 : (iIncreaseSlicNum / INT_MULTIPLY); | |
| 1296 | 1301 | iIncreaseSlicNum = (iIncreaseSlicNum < iMaxSliceNumOld / 2) ? (iMaxSliceNumOld / 2) : iIncreaseSlicNum; |
| 1297 | 1302 | iMaxSliceNumNew = iMaxSliceNumOld + iIncreaseSlicNum; |
| 1298 | 1303 | |
| @@ -1332,9 +1337,9 @@ int32_t ReallocateSliceInThread (sWelsEncCtx* pCtx, · 33 unmodified lines | ||
| 1332 | 1337 | return ENC_RETURN_SUCCESS; |
| 1333 | 1338 | } |
| 1334 | 1339 | |
| 1335 | −int32_t ExtendLayerBuffer(sWelsEncCtx* pCtx, | |
| 1336 | − const int32_t kiMaxSliceNumOld, | |
| 1337 | − const int32_t kiMaxSliceNumNew){ | |
| 1340 | +int32_t ExtendLayerBuffer (sWelsEncCtx* pCtx, | |
| 1341 | + const int32_t kiMaxSliceNumOld, | |
| 1342 | + const int32_t kiMaxSliceNumNew) { | |
| 1338 | 1343 | CMemoryAlign* pMA = pCtx->pMemAlign; |
| 1339 | 1344 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 1340 | 1345 | SSlice** ppSlice = NULL; |
| @@ -1356,7 +1361,7 @@ int32_t ExtendLayerBuffer(sWelsEncCtx* pCtx, · 15 unmodified lines | ||
| 1356 | 1361 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pFirstMbIdxOfSlice is NULL"); |
| 1357 | 1362 | return ENC_RETURN_MEMALLOCERR; |
| 1358 | 1363 | } |
| 1359 | − memset (pFirstMbIdxOfSlice, 0, sizeof(int32_t) * kiMaxSliceNumNew); | |
| 1364 | + memset (pFirstMbIdxOfSlice, 0, sizeof (int32_t) * kiMaxSliceNumNew); | |
| 1360 | 1365 | memcpy (pFirstMbIdxOfSlice, pCurLayer->pFirstMbIdxOfSlice, sizeof (int32_t) * kiMaxSliceNumOld); |
| 1361 | 1366 | pMA->WelsFree (pCurLayer->pFirstMbIdxOfSlice, "pFirstMbIdxOfSlice"); |
| 1362 | 1367 | pCurLayer->pFirstMbIdxOfSlice = pFirstMbIdxOfSlice; |
| @@ -1367,7 +1372,7 @@ int32_t ExtendLayerBuffer(sWelsEncCtx* pCtx, · 4 unmodified lines | ||
| 1367 | 1372 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pCountMbNumInSlice is NULL"); |
| 1368 | 1373 | return ENC_RETURN_MEMALLOCERR; |
| 1369 | 1374 | } |
| 1370 | − memset (pCountMbNumInSlice, 0, sizeof(int32_t) * kiMaxSliceNumNew); | |
| 1375 | + memset (pCountMbNumInSlice, 0, sizeof (int32_t) * kiMaxSliceNumNew); | |
| 1371 | 1376 | memcpy (pCountMbNumInSlice, pCurLayer->pCountMbNumInSlice, sizeof (int32_t) * kiMaxSliceNumOld); |
| 1372 | 1377 | pMA->WelsFree (pCurLayer->pCountMbNumInSlice, "pCountMbNumInSlice"); |
| 1373 | 1378 | pCurLayer->pCountMbNumInSlice = pCountMbNumInSlice; |
| @@ -1408,16 +1413,16 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 34 unmodified lines | ||
| 1408 | 1413 | pCurLayer->sSliceBufferInfo[0].iMaxSliceNum = iMaxSliceNumNew; |
| 1409 | 1414 | |
| 1410 | 1415 | iMaxSliceNumNew = 0; |
| 1411 | − for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | |
| 1412 | − iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; | |
| 1416 | + for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | |
| 1417 | + iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; | |
| 1413 | 1418 | } |
| 1414 | 1419 | |
| 1415 | − iRet = ExtendLayerBuffer(pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew); | |
| 1420 | + iRet = ExtendLayerBuffer (pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew); | |
| 1416 | 1421 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1417 | 1422 | return iRet; |
| 1418 | 1423 | } |
| 1419 | 1424 | |
| 1420 | − for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | |
| 1425 | + for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | |
| 1421 | 1426 | for (iSliceIdx = 0; iSliceIdx < pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) { |
| 1422 | 1427 | pCurLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1423 | 1428 | } |
| @@ -1429,14 +1434,14 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 5 unmodified lines | ||
| 1429 | 1434 | return ENC_RETURN_SUCCESS; |
| 1430 | 1435 | } |
| 1431 | 1436 | |
| 1432 | −static inline int32_t CheckAllSliceBuffer(SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) { | |
| 1437 | +static inline int32_t CheckAllSliceBuffer (SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) { | |
| 1433 | 1438 | int32_t iSliceIdx = 0; |
| 1434 | − for(; iSliceIdx <kiCodedSliceNum ; iSliceIdx ++ ) { | |
| 1435 | − if ( NULL == pCurLayer->ppSliceInLayer[iSliceIdx]) { | |
| 1439 | + for (; iSliceIdx < kiCodedSliceNum ; iSliceIdx ++) { | |
| 1440 | + if (NULL == pCurLayer->ppSliceInLayer[iSliceIdx]) { | |
| 1436 | 1441 | return ENC_RETURN_UNEXPECTED; |
| 1437 | 1442 | } |
| 1438 | 1443 | |
| 1439 | − if ( iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx) { | |
| 1444 | + if (iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx) { | |
| 1440 | 1445 | return ENC_RETURN_UNEXPECTED; |
| 1441 | 1446 | } |
| 1442 | 1447 | } |
| @@ -1464,16 +1469,16 @@ int32_t ReOrderSliceInLayer (sWelsEncCtx* pCtx, · 21 unmodified lines | ||
| 1464 | 1469 | |
| 1465 | 1470 | //for non-dynamic slice mode, iPartitionNum = 1, iPartitionOffset = 0 |
| 1466 | 1471 | iPartitionNum = (SM_SIZELIMITED_SLICE == kuiSliceMode) ? kiThreadNum : 1; |
| 1467 | − for(iPartitionIdx = 0; iPartitionIdx < iPartitionNum; iPartitionIdx++) { | |
| 1472 | + for (iPartitionIdx = 0; iPartitionIdx < iPartitionNum; iPartitionIdx++) { | |
| 1468 | 1473 | aiPartitionOffset[iPartitionIdx] = iEncodeSliceNum; |
| 1469 | − if ( SM_SIZELIMITED_SLICE == kuiSliceMode) { | |
| 1474 | + if (SM_SIZELIMITED_SLICE == kuiSliceMode) { | |
| 1470 | 1475 | iEncodeSliceNum += pCurLayer->NumSliceCodedOfPartition[iPartitionIdx]; |
| 1471 | 1476 | } else { |
| 1472 | 1477 | iEncodeSliceNum = pCurLayer->sSliceEncCtx.iSliceNumInFrame; |
| 1473 | 1478 | } |
| 1474 | 1479 | } |
| 1475 | 1480 | |
| 1476 | − if( iEncodeSliceNum != pCurLayer->sSliceEncCtx.iSliceNumInFrame) { | |
| 1481 | + if (iEncodeSliceNum != pCurLayer->sSliceEncCtx.iSliceNumInFrame) { | |
| 1477 | 1482 | return ENC_RETURN_UNEXPECTED; |
| 1478 | 1483 | } |
| 1479 | 1484 | |
| @@ -1482,42 +1487,42 @@ int32_t ReOrderSliceInLayer (sWelsEncCtx* pCtx, · 2 unmodified lines | ||
| 1482 | 1487 | for (iSlcBuffIdx = 0; iSlcBuffIdx < kiThreadNum; iSlcBuffIdx++) { |
| 1483 | 1488 | iSliceNumInThread = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1484 | 1489 | |
| 1485 | − for(iSliceIdx =0; iSliceIdx < iSliceNumInThread; iSliceIdx++) { | |
| 1490 | + for (iSliceIdx = 0; iSliceIdx < iSliceNumInThread; iSliceIdx++) { | |
| 1486 | 1491 | pSliceBuffer = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1487 | 1492 | if (NULL == pSliceBuffer) { |
| 1488 | 1493 | return ENC_RETURN_UNEXPECTED; |
| 1489 | 1494 | } |
| 1490 | 1495 | |
| 1491 | − if( -1 != pSliceBuffer->iSliceIdx) { | |
| 1496 | + if (-1 != pSliceBuffer->iSliceIdx) { | |
| 1492 | 1497 | iPartitionID = pSliceBuffer->iSliceIdx % iPartitionNum; |
| 1493 | 1498 | iActualSliceIdx = aiPartitionOffset[iPartitionID] + pSliceBuffer->iSliceIdx / iPartitionNum; |
| 1494 | 1499 | pSliceBuffer->iSliceIdx = iActualSliceIdx; |
| 1495 | 1500 | pCurLayer->ppSliceInLayer[iActualSliceIdx] = pSliceBuffer; |
| 1496 | 1501 | iUsedSliceNum ++; |
| 1497 | 1502 | } else { |
| 1498 | − pCurLayer->ppSliceInLayer[iEncodeSliceNum + iNonUsedBufferNum] = pSliceBuffer; | |
| 1499 | − iNonUsedBufferNum ++; | |
| 1503 | + pCurLayer->ppSliceInLayer[iEncodeSliceNum + iNonUsedBufferNum] = pSliceBuffer; | |
| 1504 | + iNonUsedBufferNum ++; | |
| 1500 | 1505 | } |
| 1501 | 1506 | } |
| 1502 | 1507 | } |
| 1503 | 1508 | |
| 1504 | − if( iUsedSliceNum != iEncodeSliceNum || | |
| 1505 | − pCurLayer->iMaxSliceNum != (iNonUsedBufferNum + iUsedSliceNum)) { | |
| 1509 | + if (iUsedSliceNum != iEncodeSliceNum || | |
| 1510 | + pCurLayer->iMaxSliceNum != (iNonUsedBufferNum + iUsedSliceNum)) { | |
| 1506 | 1511 | return ENC_RETURN_UNEXPECTED; |
| 1507 | 1512 | } |
| 1508 | 1513 | |
| 1509 | − if (ENC_RETURN_SUCCESS != CheckAllSliceBuffer(pCurLayer, iEncodeSliceNum)) { | |
| 1514 | + if (ENC_RETURN_SUCCESS != CheckAllSliceBuffer (pCurLayer, iEncodeSliceNum)) { | |
| 1510 | 1515 | return ENC_RETURN_UNEXPECTED; |
| 1511 | 1516 | } |
| 1512 | 1517 | |
| 1513 | 1518 | return ENC_RETURN_SUCCESS; |
| 1514 | 1519 | } |
| 1515 | 1520 | |
| 1516 | −int32_t GetCurLayerNalCount(const SDqLayer* pCurDq, const int32_t kiCodedSliceNum) { | |
| 1521 | +int32_t GetCurLayerNalCount (const SDqLayer* pCurDq, const int32_t kiCodedSliceNum) { | |
| 1517 | 1522 | int32_t iTotalNalCount = 0; |
| 1518 | 1523 | int32_t iSliceIdx = 0; |
| 1519 | 1524 | SWelsSliceBs* pSliceBs = NULL; |
| 1520 | − for ( ; iSliceIdx < kiCodedSliceNum; iSliceIdx++ ) { | |
| 1525 | + for (; iSliceIdx < kiCodedSliceNum; iSliceIdx++) { | |
| 1521 | 1526 | pSliceBs = &pCurDq->ppSliceInLayer[iSliceIdx]->sSliceBs; |
| 1522 | 1527 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { |
| 1523 | 1528 | iTotalNalCount += pSliceBs->iNalIndex; |
| @@ -1527,7 +1532,7 @@ int32_t GetCurLayerNalCount(const SDqLayer* pCurDq, const int32_t kiCodedSliceNu · 3 unmodified lines | ||
| 1527 | 1532 | return iTotalNalCount; |
| 1528 | 1533 | } |
| 1529 | 1534 | |
| 1530 | −int32_t GetTotalCodedNalCount(SFrameBSInfo* pFbi) { | |
| 1535 | +int32_t GetTotalCodedNalCount (SFrameBSInfo* pFbi) { | |
| 1531 | 1536 | int32_t iTotalCodedNalCount = 0; |
| 1532 | 1537 | for (int32_t iNalIdx = 0; iNalIdx < MAX_LAYER_NUM_OF_FRAME; iNalIdx++) { |
| 1533 | 1538 | iTotalCodedNalCount += pFbi->sLayerInfo[iNalIdx].iNalCount; |
| @@ -1584,13 +1589,13 @@ int32_t SliceLayerInfoUpdate (sWelsEncCtx* pCtx, · 50 unmodified lines | ||
| 1584 | 1589 | int32_t iCodedNalCount = 0; |
| 1585 | 1590 | int32_t iRet = 0; |
| 1586 | 1591 | |
| 1587 | − for ( int32_t iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | |
| 1592 | + for (int32_t iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | |
| 1588 | 1593 | iMaxSliceNum += pCtx->pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1589 | 1594 | } |
| 1590 | 1595 | |
| 1591 | 1596 | //reallocate ppSliceInLayer if total encoded slice num exceed max slice num |
| 1592 | 1597 | if (iMaxSliceNum > pCtx->pCurDqLayer->iMaxSliceNum) { |
| 1593 | − iRet = ExtendLayerBuffer(pCtx, pCtx->pCurDqLayer->iMaxSliceNum, iMaxSliceNum); | |
| 1598 | + iRet = ExtendLayerBuffer (pCtx, pCtx->pCurDqLayer->iMaxSliceNum, iMaxSliceNum); | |
| 1594 | 1599 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1595 | 1600 | return iRet; |
| 1596 | 1601 | } |
| @@ -1607,12 +1612,12 @@ int32_t SliceLayerInfoUpdate (sWelsEncCtx* pCtx, · 10 unmodified lines | ||
| 1607 | 1612 | |
| 1608 | 1613 | //Extend NalList buffer if exceed |
| 1609 | 1614 | iCodedSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer); |
| 1610 | − pLayerBsInfo->iNalCount = GetCurLayerNalCount(pCtx->pCurDqLayer, iCodedSliceNum); | |
| 1611 | − iCodedNalCount = GetTotalCodedNalCount(pFrameBsInfo); | |
| 1615 | + pLayerBsInfo->iNalCount = GetCurLayerNalCount (pCtx->pCurDqLayer, iCodedSliceNum); | |
| 1616 | + iCodedNalCount = GetTotalCodedNalCount (pFrameBsInfo); | |
| 1612 | 1617 | |
| 1613 | − if( iCodedNalCount > pCtx->pOut->iCountNals) { | |
| 1618 | + if (iCodedNalCount > pCtx->pOut->iCountNals) { | |
| 1614 | 1619 | iRet = FrameBsRealloc (pCtx, pFrameBsInfo, pLayerBsInfo, pCtx->pCurDqLayer->iMaxSliceNum); |
| 1615 | − if(ENC_RETURN_SUCCESS != iRet) { | |
| 1620 | + if (ENC_RETURN_SUCCESS != iRet) { | |
| 1616 | 1621 | return iRet; |
| 1617 | 1622 | } |
| 1618 | 1623 | } |
| @@ -1625,8 +1630,9 @@ int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, const int32_t · 6 unmodified lines | ||
| 1625 | 1630 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 1626 | 1631 | SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; |
| 1627 | 1632 | SBitStringAux* pBs = pCurSlice->pSliceBsa; |
| 1628 | − const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode | |
| 1629 | − == SM_SIZELIMITED_SLICE); | |
| 1633 | + const int32_t kiDynamicSliceFlag = | |
| 1634 | + (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode | |
| 1635 | + == SM_SIZELIMITED_SLICE); | |
| 1630 | 1636 | if (I_SLICE == pEncCtx->eSliceType) { |
| 1631 | 1637 | pNalHeadExt->bIdrFlag = 1; |
| 1632 | 1638 | pCurSlice->sScaleShift = 0; |
| @@ -1639,7 +1645,7 @@ int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, const int32_t · 6 unmodified lines | ||
| 1639 | 1645 | |
| 1640 | 1646 | //RomRC init slice by slice |
| 1641 | 1647 | if (pWelsSvcRc->bGomRC) { |
| 1642 | − GomRCInitForOneSlice(pCurSlice, pWelsSvcRc->iBitsPerMb); | |
| 1648 | + GomRCInitForOneSlice (pCurSlice, pWelsSvcRc->iBitsPerMb); | |
| 1643 | 1649 | } |
| 1644 | 1650 | |
| 1645 | 1651 | g_pWelsWriteSliceHeader[pCurSlice->bSliceHeaderExtFlag] (pEncCtx, pBs, pCurLayer, pCurSlice, |
| @@ -1695,7 +1701,7 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 49 unmodified lines | ||
| 1695 | 1701 | pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; |
| 1696 | 1702 | |
| 1697 | 1703 | //pNextSlice pointer/initialization |
| 1698 | − if(pEncCtx->iActiveThreadsNum > 1) { | |
| 1704 | + if (pEncCtx->iActiveThreadsNum > 1) { | |
| 1699 | 1705 | pNextSlice = &pSliceBuffer[ iCodedSliceNum + 1 ]; |
| 1700 | 1706 | } else { |
| 1701 | 1707 | pNextSlice = &pSliceBuffer[ iNextSliceIdc ]; |
| @@ -173,7 +173,8 @@ void WelsMotionEstimateSearch (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLaye · 172 unmodified lines | ||
| 173 | 173 | kiStrideRef); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | −void WelsMotionEstimateSearchStatic (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe, SSlice* pLpslice) { | |
| 176 | +void WelsMotionEstimateSearchStatic (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe, | |
| 177 | + SSlice* pLpslice) { | |
| 177 | 178 | const int32_t kiStrideEnc = pCurDqLayer->iEncStride[0]; |
| 178 | 179 | const int32_t kiStrideRef = pCurDqLayer->pRefPic->iLineSize[0]; |
| 179 | 180 | |
| @@ -186,7 +187,8 @@ void WelsMotionEstimateSearchStatic (SWelsFuncPtrList* pFuncList, SDqLayer* pCur · 6 unmodified lines | ||
| 186 | 187 | kiStrideRef); |
| 187 | 188 | } |
| 188 | 189 | |
| 189 | −void WelsMotionEstimateSearchScrolled (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe, SSlice* pSlice) { | |
| 190 | +void WelsMotionEstimateSearchScrolled (SWelsFuncPtrList* pFuncList, SDqLayer* pCurDqLayer, SWelsME* pMe, | |
| 191 | + SSlice* pSlice) { | |
| 190 | 192 | const int32_t kiStrideEnc = pCurDqLayer->iEncStride[0]; |
| 191 | 193 | const int32_t kiStrideRef = pCurDqLayer->pRefPic->iLineSize[0]; |
| 192 | 194 | |
| @@ -709,7 +711,7 @@ int32_t RequestScreenBlockFeatureStorage (CMemoryAlign* pMa, const int32_t kiFra · 516 unmodified lines | ||
| 709 | 711 | pScreenBlockFeatureStorage->iIs16x16 = !bIsBlock8x8; |
| 710 | 712 | pScreenBlockFeatureStorage->uiFeatureStrategyIndex = kiFeatureStrategyIndex; |
| 711 | 713 | pScreenBlockFeatureStorage->iActualListSize = kiListSize; |
| 712 | − WelsSetMemMultiplebytes_c (pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL, sizeof(uint32_t)); | |
| 714 | + WelsSetMemMultiplebytes_c (pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL, sizeof (uint32_t)); | |
| 713 | 715 | pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false; |
| 714 | 716 | |
| 715 | 717 | return ENC_RETURN_SUCCESS; |
| @@ -523,9 +523,9 @@ void WelsWriteBlockResidualCabac (SMbCache* pMbCache, SMB* pCurMb, uint32_t iMb · 522 unmodified lines | ||
| 523 | 523 | } |
| 524 | 524 | int32_t WelsCalNonZeroCount2x2Block (int16_t* pBlock) { |
| 525 | 525 | return (pBlock[0] != 0) |
| 526 | − + (pBlock[1] != 0) | |
| 527 | − + (pBlock[2] != 0) | |
| 528 | − + (pBlock[3] != 0); | |
| 526 | + + (pBlock[1] != 0) | |
| 527 | + + (pBlock[2] != 0) | |
| 528 | + + (pBlock[3] != 0); | |
| 529 | 529 | } |
| 530 | 530 | int32_t WelsWriteMbResidualCabac (SWelsFuncPtrList* pFuncList, SSlice* pSlice, SMbCache* sMbCacheInfo, SMB* pCurMb, |
| 531 | 531 | SCabacCtx* pCabacCtx, |
| @@ -116,7 +116,7 @@ WelsErrorType CWelsSliceEncodingTask::InitTask() { · 115 unmodified lines | ||
| 116 | 116 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 117 | 117 | m_pSliceBs = &m_pSlice->sSliceBs; |
| 118 | 118 | |
| 119 | − iReturn = SetSliceBoundaryInfo(m_pCtx->pCurDqLayer, m_pSlice, m_iSliceIdx); | |
| 119 | + iReturn = SetSliceBoundaryInfo (m_pCtx->pCurDqLayer, m_pSlice, m_iSliceIdx); | |
| 120 | 120 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 121 | 121 | |
| 122 | 122 | SetOneSliceBsBufferUnderMultithread (m_pCtx, m_iThreadIdx, m_pSlice); |
| @@ -244,7 +244,7 @@ WelsErrorType CWelsConstrainedSizeSlicingEncodingTask::ExecuteTask() { · 121 unmodified lines | ||
| 244 | 244 | bool bNeedReallocate = false; |
| 245 | 245 | |
| 246 | 246 | int32_t iDiffMbIdx = kiEndMbIdxInPartition - kiFirstMbInPartition; |
| 247 | − if( 0 == iDiffMbIdx) { | |
| 247 | + if (0 == iDiffMbIdx) { | |
| 248 | 248 | m_pSlice->iSliceIdx = -1; |
| 249 | 249 | return ENC_RETURN_SUCCESS; |
| 250 | 250 | } |
| @@ -252,17 +252,17 @@ WelsErrorType CWelsConstrainedSizeSlicingEncodingTask::ExecuteTask() { · 1 unmodified line | ||
| 252 | 252 | int32_t iAnyMbLeftInPartition = iDiffMbIdx + 1; |
| 253 | 253 | int32_t iLocalSliceIdx = m_iSliceIdx; |
| 254 | 254 | while (iAnyMbLeftInPartition > 0) { |
| 255 | − bNeedReallocate = (pCurDq->sSliceBufferInfo[m_iThreadIdx].iCodedSliceNum | |
| 256 | − >= pCurDq->sSliceBufferInfo[m_iThreadIdx].iMaxSliceNum -1) ? true : false; | |
| 257 | − if (bNeedReallocate) { | |
| 258 | − WelsMutexLock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate); | |
| 259 | − //for memory statistic variable | |
| 260 | − iReturn = ReallocateSliceInThread(m_pCtx, pCurDq, m_pCtx->uiDependencyId, m_iThreadIdx); | |
| 261 | − WelsMutexUnlock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate); | |
| 262 | − if (ENC_RETURN_SUCCESS != iReturn) { | |
| 263 | − return iReturn; | |
| 264 | − } | |
| 255 | + bNeedReallocate = (pCurDq->sSliceBufferInfo[m_iThreadIdx].iCodedSliceNum | |
| 256 | + >= pCurDq->sSliceBufferInfo[m_iThreadIdx].iMaxSliceNum - 1) ? true : false; | |
| 257 | + if (bNeedReallocate) { | |
| 258 | + WelsMutexLock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate); | |
| 259 | + //for memory statistic variable | |
| 260 | + iReturn = ReallocateSliceInThread (m_pCtx, pCurDq, m_pCtx->uiDependencyId, m_iThreadIdx); | |
| 261 | + WelsMutexUnlock (&m_pCtx->pSliceThreading->mutexThreadSlcBuffReallocate); | |
| 262 | + if (ENC_RETURN_SUCCESS != iReturn) { | |
| 263 | + return iReturn; | |
| 265 | 264 | } |
| 265 | + } | |
| 266 | 266 | |
| 267 | 267 | iReturn = InitOneSliceInThread (m_pCtx, m_pSlice, m_iThreadIdx, m_pCtx->uiDependencyId, iLocalSliceIdx); |
| 268 | 268 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| @@ -197,7 +197,7 @@ void CWelsTaskManageBase::DestroyTasks() { · 196 unmodified lines | ||
| 197 | 197 | void CWelsTaskManageBase::OnTaskMinusOne() { |
| 198 | 198 | //fprintf(stdout, "OnTaskMinusOne event %x m_iWaitTaskNum=%d\n", &m_hEventMutex, m_iWaitTaskNum); |
| 199 | 199 | WelsCommon::CWelsAutoLock cAutoLock (m_cWaitTaskNumLock); |
| 200 | − WelsEventSignal (&m_hTaskEvent,&m_hEventMutex, &m_iWaitTaskNum); | |
| 200 | + WelsEventSignal (&m_hTaskEvent, &m_hEventMutex, &m_iWaitTaskNum); | |
| 201 | 201 | /*WelsMutexLock(&m_hEventMutex); |
| 202 | 202 | m_iWaitTaskNum --; |
| 203 | 203 | WelsMutexUnlock(&m_hEventMutex); |
| @@ -234,7 +234,7 @@ WelsErrorType CWelsTaskManageBase::ExecuteTaskList (TASKLIST_TYPE** pTaskList) · 30 unmodified lines | ||
| 234 | 234 | iIdx ++; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | − WelsEventWait (&m_hTaskEvent,&m_hEventMutex, m_iWaitTaskNum); | |
| 237 | + WelsEventWait (&m_hTaskEvent, &m_hEventMutex, m_iWaitTaskNum); | |
| 238 | 238 | |
| 239 | 239 | return ENC_RETURN_SUCCESS; |
| 240 | 240 | } |