shithub: openh264

Download patch

ref: e88bb8886af9b10261b4febc21214b32c75b710b
parent: 50a9389f0bacc7c7ee7c806302ac153d01b3ba5b
parent: 945fc0e03ee855bd60e6b5628879b2ad48bb8162
author: HaiboZhu <haibozhu@cisco.com>
date: Mon Aug 8 13:03:08 EDT 2016

Merge pull request #2542 from ruil2/dump1

fix dump file issue that removing redundant operation

--- a/codec/encoder/core/inc/encoder.h
+++ b/codec/encoder/core/inc/encoder.h
@@ -82,17 +82,19 @@
 /*!
  * \brief   initialize frame coding
  */
-void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType,const int32_t kiDidx);
-void LoadBackFrameNum(sWelsEncCtx* pEncCtx,const int32_t kiDidx);
+void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType, const int32_t kiDidx);
+void LoadBackFrameNum (sWelsEncCtx* pEncCtx, const int32_t kiDidx);
 
-EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum,const int32_t kiDidx, bool bSkipFrameFlag);
-void InitBitStream(sWelsEncCtx* pEncCtx);
+EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum, const int32_t kiDidx,
+                                 bool bSkipFrameFlag);
+void InitBitStream (sWelsEncCtx* pEncCtx);
 int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize);
 /*!
  * \brief   Dump reconstruction for dependency layer
  */
 
-extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer);
+extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend,
+                                   SDqLayer* pDqLayer, bool bSimulCastAVC);
 
 /*!
  * \brief   Dump the reconstruction pictures
--- a/codec/encoder/core/inc/encoder_context.h
+++ b/codec/encoder/core/inc/encoder_context.h
@@ -235,7 +235,6 @@
   SStateCtx sWelsCabacContexts[4][WELS_QP_MAX + 1][WELS_CONTEXT_COUNT];
 #ifdef ENABLE_FRAME_DUMP
   bool bDependencyRecFlag[MAX_DEPENDENCY_LAYER];
-  bool bRecFlag;
 #endif
   int64_t            uiLastTimestamp;
 
--- a/codec/encoder/core/src/encoder.cpp
+++ b/codec/encoder/core/src/encoder.cpp
@@ -330,7 +330,8 @@
 #endif//FRAME_INFO_OUTPUT
 }
 
-EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum, const int32_t kiDidx, bool bSkipFrameFlag) {
+EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum, const int32_t kiDidx,
+                                 bool bSkipFrameFlag) {
   SWelsSvcCodingParam* pSvcParam = pEncCtx->pSvcParam;
   SSpatialLayerInternal* pParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDidx];
   EVideoFrameType iFrameType = videoFrameTypeInvalid;
@@ -401,18 +402,21 @@
  */
 
 extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend,
-                                   SDqLayer* pDqLayer) {
+                                   SDqLayer* pDqLayer, bool bSimulCastAVC) {
   WelsFileHandle* pDumpRecFile = NULL;
   int32_t iWrittenSize = 0;
   const char* openMode = bAppend ? "ab" : "wb";
-  SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) :
-                      pDqLayer->sLayerInfo.pSpsP;
+  SWelsSPS* pSpsTmp = NULL;
+  if (bSimulCastAVC || (kiDid == BASE_DEPENDENCY_ID)) {
+    pSpsTmp = pDqLayer->sLayerInfo.pSpsP;
+  } else {
+    pSpsTmp = & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps);
+  }
   bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag;
   SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop;
 
   if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER)
     return;
-
   if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage
     pDumpRecFile = WelsFopen (kpFileName, openMode);
   else {
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -589,8 +589,9 @@
       iMbWidth  = (kiPicWidth + 15) >> 4;
       iMbHeight = (kiPicHeight + 15) >> 4;
       if (pSpatialLayer->sSliceArgument.uiSliceSizeConstraint <= MAX_MACROBLOCK_SIZE_IN_BYTE) {
-        WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid iSliceSize (%d) settings!should be larger than  MAX_MACROBLOCK_SIZE_IN_BYTE(%d)",
-                 pSpatialLayer->sSliceArgument.uiSliceSizeConstraint,MAX_MACROBLOCK_SIZE_IN_BYTE);
+        WelsLog (pLogCtx, WELS_LOG_ERROR,
+                 "ParamValidationExt(), invalid iSliceSize (%d) settings!should be larger than  MAX_MACROBLOCK_SIZE_IN_BYTE(%d)",
+                 pSpatialLayer->sSliceArgument.uiSliceSizeConstraint, MAX_MACROBLOCK_SIZE_IN_BYTE);
         return ENC_RETURN_UNSUPPORTED_PARA;
       }
 
@@ -3593,7 +3594,7 @@
     for (int32_t iDidIdx = 0; iDidIdx < pSvcParam->iSpatialLayerNum; iDidIdx++) {
       SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iDidIdx];
       int32_t iTemporalId =  GetTemporalLevel (pParamInternal, pParamInternal->iCodingIndex,
-                                               pSvcParam->uiGopSize);
+                             pSvcParam->uiGopSize);
       if (iTemporalId == INVALID_TEMPORAL_ID)
         pParamInternal->iCodingIndex ++;
     }
@@ -3971,9 +3972,9 @@
                  "WelsEncoderEncodeExt()MinCr Checking,codec bitstream size is larger than Level limitation");
     }
 #ifdef ENABLE_FRAME_DUMP
-    if (iCurDid + 1 < pSvcParam->iSpatialLayerNum) {
+    {
       DumpDependencyRec (fsnr, &pSvcParam->sDependencyLayers[iCurDid].sRecFileName[0], iCurDid,
-                         pCtx->bDependencyRecFlag[iCurDid], pCtx->pCurDqLayer);
+                         pCtx->bDependencyRecFlag[iCurDid], pCtx->pCurDqLayer, pSvcParam->bSimulcastAVC);
       pCtx->bDependencyRecFlag[iCurDid] = true;
     }
 #endif//ENABLE_FRAME_DUMP
@@ -4161,13 +4162,6 @@
           1]].sSliceArgument.uiSliceNum) {
     AdjustBaseLayer (pCtx);
   }
-
-#ifdef ENABLE_FRAME_DUMP
-  DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0],
-                pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output
-  pCtx->bRecFlag = true;
-
-#endif//ENABLE_FRAME_DUMP
 
   // to check number of layers / nals / slices dependencies
   if (iLayerNum > MAX_LAYER_NUM_OF_FRAME) {