shithub: openh264

Download patch

ref: 9e4ab64c738171f4329a4c1a8c12890d783c5bf5
parent: 8f981a4282f0bc3356e2ac4d3d9aaa83a01b093b
author: Licai Guo <guolicai@gmail.com>
date: Tue Mar 4 14:23:15 EST 2014

move iTotalNumMbRec from refpic to ctx

--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -271,6 +271,7 @@
   bool				bSubspsAvailFlags[MAX_SPS_COUNT];
   bool				bPpsAvailFlags[MAX_PPS_COUNT];
   bool				bReferenceLostAtT0Flag;
+  int32_t     iTotalNumMbRec; //record current number of decoded MB
 #ifdef LONG_TERM_REF
   bool				bParamSetsLostFlag;	//sps or pps do not exist or not correct
 
--- a/codec/decoder/core/inc/picture.h
+++ b/codec/decoder/core/inc/picture.h
@@ -71,8 +71,6 @@
 int32_t		iFrameNum;		// frame number			//for ref pic management
 int32_t		iLongTermFrameIdx;					//id for long term ref pic
 
-int32_t     iTotalNumMbRec; //show how many MB constructed
-
 int32_t     iSpsId; //against mosaic caused by cross-IDR interval reference.
 int32_t     iPpsId;
 } SPicture, *PPicture;	// "Picture" declaration is comflict with Mac system
--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -97,13 +97,13 @@
     }
 
     ++iCountNumMb;
-    ++pCurLayer->pDec->iTotalNumMbRec;
+    ++pCtx->iTotalNumMbRec;
     if (iCountNumMb >= iTotalNumMb) {
       break;
     }
-    if (pCurLayer->pDec->iTotalNumMbRec > iTotalMbTargetLayer) {
-      WelsLog (pCtx, WELS_LOG_WARNING, "WelsTargetSliceConstruction():::fdec->iTotalNumMbRec:%d, iTotalMbTargetLayer:%d\n",
-               pCurLayer->pDec->iTotalNumMbRec, iTotalMbTargetLayer);
+    if (pCtx->iTotalNumMbRec > iTotalMbTargetLayer) {
+      WelsLog (pCtx, WELS_LOG_WARNING, "WelsTargetSliceConstruction():::pCtx->iTotalNumMbRec:%d, iTotalMbTargetLayer:%d\n",
+               pCtx->iTotalNumMbRec, iTotalMbTargetLayer);
 
       return -1;
     }
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -54,14 +54,14 @@
 
   const int32_t kiTotalNumMbInCurLayer = pCurDq->iMbWidth * pCurDq->iMbHeight;
 
-  if (pPic->iTotalNumMbRec != kiTotalNumMbInCurLayer) {
+  if (pCtx->iTotalNumMbRec != kiTotalNumMbInCurLayer) {
     WelsLog (pCtx, WELS_LOG_WARNING,
              "DecodeFrameConstruction():::iTotalNumMbRec:%d, total_num_mb_sps:%d, cur_layer_mb_width:%d, cur_layer_mb_height:%d \n",
-             pPic->iTotalNumMbRec, kiTotalNumMbInCurLayer, pCurDq->iMbWidth, pCurDq->iMbHeight);
+             pCtx->iTotalNumMbRec, kiTotalNumMbInCurLayer, pCurDq->iMbWidth, pCurDq->iMbHeight);
     return -1;
   }
 #ifdef NO_WAITING_AU
-  pPic->iTotalNumMbRec = 0;
+  pCtx->iTotalNumMbRec = 0;
 #endif
 
   if (I_SLICE == pCurDq->sLayerInfo.sSliceInLayer.eSliceType) {
@@ -1738,16 +1738,16 @@
 
 #ifdef NO_WAITING_AU
     //For fixing the nal lossing issue
-    if ((pCtx->pDec->iTotalNumMbRec != 0) &&
+    if ((pCtx->iTotalNumMbRec != 0) &&
         (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pNalCur->sNalHeaderExt, &pCtx->sLastSliceHeader,
                                      &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
-      pCtx->pDec->iTotalNumMbRec = 0;
+      pCtx->iTotalNumMbRec = 0;
     }
 #else
     //initialize at the starting of AU.
-    pCtx->pDec->iTotalNumMbRec = 0;
+    pCtx->iTotalNumMbRec = 0;
 #endif
-    if (pCtx->pDec->iTotalNumMbRec == 0) { //Picture start to decode
+    if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
       for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
         memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
     }