shithub: openh264

Download patch

ref: 67afd91888d4eec0cff164a6fb97d3744684ea0d
parent: 91cd93e5d0c69fa2f9729c3f042c845e8f44296c
author: root <root@ubuntu.(none)>
date: Sun Jun 15 19:14:31 EDT 2014

put EC before output

--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -1641,11 +1641,6 @@
 
   WelsDecodeAccessUnitEnd (pCtx);
 
-  if (!pCtx->bInstantDecFlag) {
-    //Do error concealment here
-    ImplementErrorCon (pCtx);
-  }
-
   pCtx->bNewSeqBegin = false;
   WriteBackActiveParameters (pCtx);
   pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin;
@@ -1943,6 +1938,14 @@
 #endif//#if !CODEC_FOR_TESTBED
 
     if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {
+      if (!pCtx->bInstantDecFlag) {
+        //Do error concealment here
+        if (NeedErrorCon (pCtx)) {
+          ImplementErrorCon (pCtx);
+          pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
+        }
+      }
+
       if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
         return ERR_NONE;
       }
@@ -1979,15 +1982,17 @@
   if ((pCtx->iTotalNumMbRec != 0)
       && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
                                       &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
-    pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
-    DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
-    PPicture pCurPic = pCtx->pDec; //temporally store current picture
     //Do Error Concealment here
-    ImplementErrorCon (pCtx);
-    pCtx->pPreviousDecodedPictureInDpb = pCurPic; //save ECed pic for future use
-    pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
-    if (pCtx->bLastHasMmco5)
-      pCtx->iPrevFrameNum = 0;
+    if (NeedErrorCon (pCtx)) { //should always be true!
+      ImplementErrorCon (pCtx);
+      pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
+      DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
+      pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
+      MarkECFrameAsRef (pCtx);
+      pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
+      if (pCtx->bLastHasMmco5)
+        pCtx->iPrevFrameNum = 0;
+    }
   }
   return ERR_NONE;
 }
--- a/codec/decoder/core/src/error_concealment.cpp
+++ b/codec/decoder/core/src/error_concealment.cpp
@@ -172,9 +172,6 @@
 // ImplementErrorConceal
 // Do actual error concealment
 void ImplementErrorCon (PWelsDecoderContext pCtx) {
-  if (!NeedErrorCon (pCtx))
-    return;
-
   if (ERROR_CON_DISABLE == pCtx->iErrorConMethod) {
     pCtx->iErrorCode |= dsBitstreamError;
     return;
@@ -183,14 +180,6 @@
   } else if (ERROR_CON_SLICE_COPY == pCtx->iErrorConMethod) {
     DoErrorConSliceCopy (pCtx);
   } //TODO add other EC methods here in the future
-
-  //mark the erroneous frame as Ref pic in DPB
-  MarkECFrameAsRef (pCtx);
-  //need update frame_num due current frame is well decoded
-  pCtx->iPrevFrameNum	= pCtx->pSliceHeader->iFrameNum;
-  if (pCtx->bLastHasMmco5)
-    pCtx->iPrevFrameNum = 0;
-
 }
 
 } // namespace WelsDec