shithub: openh264

Download patch

ref: 7188e50acf45189f242b83aa7d5595a3e0145c53
parent: 6d79601d93087fef6b5581d57aa075044e852ac6
parent: c298d66d4837b0821e75ba617b2b65115ee277ba
author: sijchen <sijchen@cisco.com>
date: Wed May 18 05:34:09 EDT 2016

Merge pull request #2465 from ruil2/skip_layers

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);