shithub: openh264

Download patch

ref: c298d66d4837b0821e75ba617b2b65115ee277ba
parent: 6d79601d93087fef6b5581d57aa075044e852ac6
author: Karina <ruil2@cisco.com>
date: Wed May 18 05:47:49 EDT 2016

fix temporal layer skip issue

--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3489,22 +3489,29 @@
     pCtx->iContinualSkipFrames = 0;
     iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[iCurDid], pParamInternal->iCodingIndex,
                                 pSvcParam->uiGopSize);
-    pCtx->uiTemporalId = iCurTid;
-    if (eFrameType == videoFrameTypeIDR) {
-      // write parameter sets bitstream or SEI/SSEI (if any) here
-      // TODO: use function pointer instead
-      if (! (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy)) {
-        if (pSvcParam->bSimulcastAVC) {
-          pCtx->iEncoderError = WriteSavcParaset (pCtx, iCurDid, pLayerBsInfo, iLayerNum, iFrameSize);
-          ++ pCtx->uiIdrPicId;
+    //skip this spatial layer
+    if (iCurTid == INVALID_TEMPORAL_ID) {
+      pParamInternal->iCodingIndex ++;
+      eFrameType = videoFrameTypeSkip;
+      pLayerBsInfo->eFrameType = videoFrameTypeSkip;
+    } else {
+      pCtx->uiTemporalId = iCurTid;
+      if (eFrameType == videoFrameTypeIDR) {
+        // write parameter sets bitstream or SEI/SSEI (if any) here
+        // TODO: use function pointer instead
+        if (! (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy)) {
+          if (pSvcParam->bSimulcastAVC) {
+            pCtx->iEncoderError = WriteSavcParaset (pCtx, iCurDid, pLayerBsInfo, iLayerNum, iFrameSize);
+            ++ pCtx->uiIdrPicId;
+          } else {
+            pCtx->iEncoderError = WriteSsvcParaset (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize);
+            ++ pCtx->uiIdrPicId;
+          }
         } else {
-          pCtx->iEncoderError = WriteSsvcParaset (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize);
+          pCtx->iEncoderError = WriteSavcParaset_Listing (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize);
+
           ++ pCtx->uiIdrPicId;
         }
-      } else {
-        pCtx->iEncoderError = WriteSavcParaset_Listing (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize);
-
-        ++ pCtx->uiIdrPicId;
       }
     }
 
@@ -3609,12 +3616,7 @@
     int32_t  iDecompositionStages = pSvcParam->sDependencyLayers[iCurDid].iDecompositionStages;
     pCtx->pCurDqLayer           = pCtx->ppDqLayerList[iCurDid];
     pCtx->uiDependencyId        =  iCurDid;
-    //skip this spatial layer
-    if (GetTemporalLevel (pParamInternal, pParamInternal->iCodingIndex, pSvcParam->uiGopSize) == INVALID_TEMPORAL_ID) {
-      ++iSpatialIdx;
-      pParamInternal->iCodingIndex ++;
-      continue;
-    }
+
     if (pSvcParam->bSimulcastAVC) {
       eFrameType = PrepareEncodeFrame (pCtx, pLayerBsInfo, iSpatialNum , iCurDid, iCurTid, iLayerNum, iFrameSize,
                                        pFbi->uiTimeStamp);