shithub: openh264

Download patch

ref: 436da21ccfd7f1fe6d7f38be56da86f83fe8ea33
parent: 4a4ade1201e8864533a38bab337ecb01f345cc65
author: huade <huashi@cisco.com>
date: Thu Nov 26 09:06:01 EST 2015

initial for iReturn and refact PPS Sps bs write function

--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3507,7 +3507,7 @@
 // writing parasets for (simulcast) svc
 int32_t WriteSsvcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum,
                           SLayerBSInfo*& pLayerBsInfo, int32_t& iLayerNum, int32_t& iFrameSize) {
-  int32_t iNonVclSize = 0, iCountNal = 0, iReturn = 0;
+  int32_t iNonVclSize = 0, iCountNal = 0, iReturn = ENC_RETURN_SUCCESS;
   iReturn = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal, &iNonVclSize);
   WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
 
@@ -3532,7 +3532,7 @@
 // writing parasets for simulcast avc
 int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum,
                           SLayerBSInfo*& pLayerBsInfo, int32_t& iLayerNum, int32_t& iFrameSize) {
-  int32_t iNonVclSize = 0, iCountNal = 0, iReturn;
+  int32_t iNonVclSize = 0, iCountNal = 0, iReturn = ENC_RETURN_SUCCESS;
 
   // write SPS
   iNonVclSize = 0;
@@ -3542,7 +3542,9 @@
   for (int32_t iIdx = 0; iIdx < pCtx->iSpsNum; iIdx++) {
     //writing one NAL
     int32_t iNalSize = 0;
-    iReturn = WelsWriteOneSPS (pCtx, iIdx, iNalSize);
+    iCountNal        = 0;
+
+    iReturn          = WelsWriteOneSPS (pCtx, iIdx, iNalSize);
     WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
 
     pLayerBsInfo->pNalLengthInByte[iCountNal] = iNalSize;
@@ -3562,7 +3564,6 @@
     pLayerBsInfo->pBsBuf           = pCtx->pFrameBs + pCtx->iPosBsBuffer;
     pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal;
     //update for external countings
-    iCountNal = 0;
     ++ iLayerNum;
 
   }
@@ -3574,7 +3575,9 @@
   for (int32_t iIdx = 0; iIdx < pCtx->iPpsNum; iIdx++) {
     //writing one NAL
     int32_t iNalSize = 0;
-    iReturn = WelsWriteOnePPS (pCtx, iIdx, iNalSize);
+    iCountNal        = 0;
+
+    iReturn          = WelsWriteOnePPS (pCtx, iIdx, iNalSize);
     WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
 
     pLayerBsInfo->pNalLengthInByte[iCountNal] = iNalSize;
@@ -3594,7 +3597,6 @@
     pLayerBsInfo->pBsBuf           = pCtx->pFrameBs + pCtx->iPosBsBuffer;
     pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal;
     //update for external countings
-    iCountNal = 0;
     ++ iLayerNum;
   }
 
@@ -3612,7 +3614,7 @@
 //cover the logic of simulcast avc + sps_pps_listing
 int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum,
                                   SLayerBSInfo*& pLayerBsInfo, int32_t& iLayerNum, int32_t& iFrameSize) {
-  int32_t iNonVclSize = 0, iCountNal = 0, iReturn;
+  int32_t iNonVclSize = 0, iCountNal = 0, iReturn = ENC_RETURN_SUCCESS;
 
   // write SPS
   iNonVclSize = 0;
@@ -3643,7 +3645,6 @@
     pLayerBsInfo->pBsBuf           = pCtx->pFrameBs + pCtx->iPosBsBuffer;
     pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal;
     //update for external countings
-    iCountNal = 0;
     ++ iLayerNum;
   }
 
@@ -3679,7 +3680,6 @@
     pLayerBsInfo->pBsBuf           = pCtx->pFrameBs + pCtx->iPosBsBuffer;
     pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal;
     //update for external countings
-    iCountNal = 0;
     ++ iLayerNum;
   }