Merge pull request #174 from volvet/coverity_issue_fix

fix coverity issues 26973, 26974, 26975, 26976, 26972, 26980.
This commit is contained in:
Licai Guo 2014-01-22 23:50:47 -08:00
commit 493c31f6a6
4 changed files with 33 additions and 41 deletions

View File

@ -224,7 +224,7 @@ static inline void HandleLTRMarkFeedback (sWelsEncCtx* pCtx) {
}
pLtr->iLTRMarkSuccessNum++;
pLtr->iCurLtrIdx = (++pLtr->iCurLtrIdx % LONG_TERM_REF_NUM);
pLtr->iCurLtrIdx = (pLtr->iCurLtrIdx+1)%LONG_TERM_REF_NUM;
pLtr->iLTRMarkMode = (pLtr->iLTRMarkSuccessNum >= (LONG_TERM_REF_NUM)) ? (LTR_DELAY_MARK) : (LTR_DIRECT_MARK);
WelsLog (pCtx, WELS_LOG_WARNING, "LTR mark mode =%d", pLtr->iLTRMarkMode);
pLtr->bLTRMarkEnable = TRUE;
@ -350,27 +350,27 @@ BOOL_T WelsUpdateRefList (sWelsEncCtx* pCtx) {
if (NULL == pRefList || NULL == pRefList->pRef[0] || NULL == pRefList->pRef[kiSwapIdx])
return FALSE;
if ((NULL != pCtx->pDecPic)
if (NULL != pCtx->pDecPic) {
#if !defined(ENABLE_FRAME_DUMP) // to save complexity, 1/6/2009
&& (pParamD->iHighestTemporalId == 0 || kuiTid < pParamD->iHighestTemporalId)
if ((pParamD->iHighestTemporalId == 0) || (kuiTid < pParamD->iHighestTemporalId))
#endif// !ENABLE_FRAME_DUMP
)
// Expanding picture for future reference
ExpandReferencingPicture (pCtx->pDecPic, pCtx->pFuncList->pfExpandLumaPicture, pCtx->pFuncList->pfExpandChromaPicture);
// move picture in list
pCtx->pDecPic->uiTemporalId = kuiTid;
pCtx->pDecPic->uiSpatialId = kuiDid;
pCtx->pDecPic->iFrameNum = pCtx->iFrameNum;
pCtx->pDecPic->iFramePoc = pCtx->iPOC;
pCtx->pDecPic->uiRecieveConfirmed = RECIEVE_UNKOWN;
pCtx->pDecPic->bUsedAsRef = true;
// move picture in list
pCtx->pDecPic->uiTemporalId = kuiTid;
pCtx->pDecPic->uiSpatialId = kuiDid;
pCtx->pDecPic->iFrameNum = pCtx->iFrameNum;
pCtx->pDecPic->iFramePoc = pCtx->iPOC;
pCtx->pDecPic->uiRecieveConfirmed = RECIEVE_UNKOWN;
pCtx->pDecPic->bUsedAsRef = true;
for (iRefIdx = pRefList->uiShortRefCount - 1; iRefIdx >= 0; --iRefIdx) {
pRefList->pShortRefList[iRefIdx + 1] = pRefList->pShortRefList[iRefIdx];
for (iRefIdx = pRefList->uiShortRefCount - 1; iRefIdx >= 0; --iRefIdx) {
pRefList->pShortRefList[iRefIdx + 1] = pRefList->pShortRefList[iRefIdx];
}
pRefList->pShortRefList[0] = pCtx->pDecPic;
pRefList->uiShortRefCount++;
}
pRefList->pShortRefList[0] = pCtx->pDecPic;
pRefList->uiShortRefCount++;
if (keSliceType == P_SLICE) {
if (pCtx->uiTemporalId == 0) {
@ -398,7 +398,7 @@ BOOL_T WelsUpdateRefList (sWelsEncCtx* pCtx) {
if (pCtx->pSvcParam->bEnableLongTermReference) {
LTRMarkProcess (pCtx);
pLtr->iCurLtrIdx = (++pLtr->iCurLtrIdx % LONG_TERM_REF_NUM);
pLtr->iCurLtrIdx = (pLtr->iCurLtrIdx+1)%LONG_TERM_REF_NUM;
pLtr->iLTRMarkSuccessNum = 1; //IDR default suceess
pLtr->bLTRMarkEnable = TRUE;
pLtr->uiLtrMarkInterval = 0;

View File

@ -649,21 +649,19 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
(*ppCtx)->pSliceBs = NULL;
}
#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
if (pSmt->pSliceConsumeTime != NULL) {
iIdx = 0;
while (iIdx < pCodingParam->iNumDependencyLayer) {
if (pSmt->pSliceConsumeTime[iIdx]) {
pMa->WelsFree (pSmt->pSliceConsumeTime[iIdx], "pSliceConsumeTime[]");
pSmt->pSliceConsumeTime[iIdx] = NULL;
}
#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
if (pSmt->pSliceComplexRatio[iIdx] != NULL) {
pMa->WelsFree (pSmt->pSliceComplexRatio[iIdx], "pSliceComplexRatio[]");
pSmt->pSliceComplexRatio[iIdx] = NULL;
}
#endif//TRY_SLICING_BALANCE
++ iIdx;
iIdx = 0;
while (iIdx < pCodingParam->iNumDependencyLayer) {
if (pSmt->pSliceConsumeTime[iIdx]) {
pMa->WelsFree (pSmt->pSliceConsumeTime[iIdx], "pSliceConsumeTime[]");
pSmt->pSliceConsumeTime[iIdx] = NULL;
}
#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
if (pSmt->pSliceComplexRatio[iIdx] != NULL) {
pMa->WelsFree (pSmt->pSliceComplexRatio[iIdx], "pSliceComplexRatio[]");
pSmt->pSliceComplexRatio[iIdx] = NULL;
}
#endif//TRY_SLICING_BALANCE
++ iIdx;
}
#endif//#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)

View File

@ -179,20 +179,16 @@ void WelsLogDefault (void* pCtx, const int32_t kiLevel, const str_t* kpFmtStr, v
t_now = (struct tm*)LOCALTIME (&l_time);
gettimeofday (&tv, NULL);
#endif//WIN32
if (iBufLeft > 0) {
#ifdef _MSC_VER
#if _MSC_VER >= 1500
iCurUsed = SNPRINTF (&pBuf[iBufUsed], iBufLeft, iBufLeft, "[0x%p @ ", pEncCtx); // confirmed_safe_unsafe_usage
iCurUsed = SNPRINTF (&pBuf[iBufUsed], iBufLeft, iBufLeft, "[0x%p @ ", pEncCtx); // confirmed_safe_unsafe_usage
#else
iCurUsed = SNPRINTF (&pBuf[iBufUsed], iBufLeft, "[0x%p @ ", pEncCtx); // confirmed_safe_unsafe_usage
iCurUsed = SNPRINTF (&pBuf[iBufUsed], iBufLeft, "[0x%p @ ", pEncCtx); // confirmed_safe_unsafe_usage
#endif//_MSC_VER >= 1500
#endif//_MSC_VER
if (iCurUsed >= 0) {
iBufUsed += iCurUsed;
iBufLeft -= iCurUsed;
}
} else {
return;
if (iCurUsed >= 0) {
iBufUsed += iCurUsed;
iBufLeft -= iCurUsed;
}
if (iBufLeft > 0) {

View File

@ -452,8 +452,6 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (void* pCtx, const SSourcePicture
// spatial layer is able to encode indeed
if ((iTemporalId != INVALID_TEMPORAL_ID)) {
// down sampling performed
if (NULL == pSrcPic)
return -1;
pDstPic = pEncCtx->pSpatialPic[iDependencyId][iPicturePos]; // small
iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId];