shithub: openh264

Download patch

ref: 1ec213d5a7d8a1b0ee7ca4f00c725e53c2e38e66
parent: 5a60d0fef40e21860d31109dd766bfe807c9b18c
author: huili2 <huili2@cisco.com>
date: Mon Jul 7 14:57:46 EDT 2014

stop early error for parse/recon MB

--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -85,6 +85,10 @@
   }
 
   do {
+    if (iCountNumMb >= iTotalNumMb) {
+      break;
+    }
+
     if (WelsTargetMbConstruction (pCtx)) {
       WelsLog (&(pCtx->sLogCtx), WELS_LOG_WARNING, "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d\n",
                pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType);
@@ -98,9 +102,6 @@
       ++pCtx->iTotalNumMbRec;
     }
 
-    if (iCountNumMb >= iTotalNumMb) {
-      break;
-    }
     if (pCtx->iTotalNumMbRec > iTotalMbTargetLayer) {
       WelsLog (&(pCtx->sLogCtx), WELS_LOG_WARNING, "WelsTargetSliceConstruction():::pCtx->iTotalNumMbRec:%d, iTotalMbTargetLayer:%d\n",
                pCtx->iTotalNumMbRec, iTotalMbTargetLayer);
@@ -390,6 +391,10 @@
   }
 
   do {
+    if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) {	// slice group boundary or end of a frame
+      break;
+    }
+
     pCurLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc;
     iRet = pDecMbCavlcFunc (pCtx,  pNalCur);
 
@@ -403,9 +408,6 @@
       iNextMbXyIndex = FmoNextMb (pFmo, iNextMbXyIndex);
     } else {
       ++iNextMbXyIndex;
-    }
-    if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) {	// slice group boundary or end of a frame
-      break;
     }
 
     // check whether there is left bits to read next time in case multiple slices