shithub: openh264

Download patch

ref: 1d86dbdc0f903f07364b6f48b56f8f60017b2281
parent: ae027b83d8f90c0517a37927d28e3483e69747c4
author: volvet <qizh@cisco.com>
date: Tue Jan 21 11:17:56 EST 2014

fix coverity issues

--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -224,7 +224,7 @@
         }
 
         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 @@
   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 @@
     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;
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -649,21 +649,19 @@
     (*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;
-      }
+  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;
+    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)
 
--- a/codec/encoder/core/src/utils.cpp
+++ b/codec/encoder/core/src/utils.cpp
@@ -179,20 +179,16 @@
       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) {
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -451,8 +451,6 @@
       // 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];