shithub: openh264

Download patch

ref: c17a58efdfa8c03e3a1ae8e7f78483d48700499c
parent: 780101fcfd9b604b288393ec2bd1fbbade01d81e
parent: ac37666cf1b56f70f7a5e13529907caff3c81d05
author: HaiboZhu <[email protected]>
date: Wed May 25 06:00:13 EDT 2016

Merge pull request #2473 from ruil2/update_interface

modify the interface that use a independent subseqID for each layer

--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -578,6 +578,11 @@
   EVideoFrameType eFrameType;
   unsigned char uiLayerType;
 
+  /**
+   * The sub sequence layers are ordered hierarchically based on their dependency on each other so that any picture in a layer shall not be
+   * predicted from any picture on any higher layer.
+  */
+  int   iSubSeqId;                ///< refer to D.2.11 Sub-sequence information SEI message semantics
   int   iNalCount;              ///< count number of NAL coded already
   int*  pNalLengthInByte;       ///< length of NAL size in byte from 0 to iNalCount-1
   unsigned char*  pBsBuf;       ///< buffer of bitstream contained
@@ -587,14 +592,6 @@
 * @brief Frame bit stream info
 */
 typedef struct {
-  int iTemporalId;              ///< temporal ID
-
-  /**
-  * The sub sequence layers are ordered hierarchically based on their dependency on each other so that any picture in a layer shall not be
-  * predicted from any picture on any higher layer.
-  */
-  int iSubSeqId;                ///< refer to D.2.11 Sub-sequence information SEI message semantics
-
   int           iLayerNum;
   SLayerBSInfo  sLayerInfo[MAX_LAYER_NUM_OF_FRAME];
 
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3181,6 +3181,7 @@
   pLayerBsInfo->uiLayerType   = NON_VIDEO_CODING_LAYER;
   pLayerBsInfo->iNalCount     = iCountNal;
   pLayerBsInfo->eFrameType    = videoFrameTypeInvalid;
+  pLayerBsInfo->iSubSeqId     = 0;
   //pCtx->eLastNalPriority      = NRI_PRI_HIGHEST;
   pFbi->iLayerNum             = 1;
   pFbi->eFrameType            = videoFrameTypeInvalid;
@@ -3218,6 +3219,7 @@
   pLayerBsInfo->uiLayerType     = NON_VIDEO_CODING_LAYER;
   pLayerBsInfo->iNalCount       = iCountNal;
   pLayerBsInfo->eFrameType      = videoFrameTypeIDR;
+  pLayerBsInfo->iSubSeqId = GetSubSequenceId (pCtx, videoFrameTypeIDR);
   //point to next pLayerBsInfo
   ++ pLayerBsInfo;
   ++ pCtx->pOut->iLayerBsIndex;
@@ -3262,6 +3264,7 @@
   pLayerBsInfo->uiLayerType   = NON_VIDEO_CODING_LAYER;
   pLayerBsInfo->iNalCount     = iCountNal;
   pLayerBsInfo->eFrameType    = videoFrameTypeIDR;
+  pLayerBsInfo->iSubSeqId     = GetSubSequenceId (pCtx, videoFrameTypeIDR);
   //point to next pLayerBsInfo
   ++ pLayerBsInfo;
   ++ pCtx->pOut->iLayerBsIndex;
@@ -3296,6 +3299,7 @@
   pLayerBsInfo->uiLayerType   = NON_VIDEO_CODING_LAYER;
   pLayerBsInfo->iNalCount     = iCountNal;
   pLayerBsInfo->eFrameType    = videoFrameTypeIDR;
+  pLayerBsInfo->iSubSeqId     = GetSubSequenceId (pCtx, videoFrameTypeIDR);
   //point to next pLayerBsInfo
   ++ pLayerBsInfo;
   ++ pCtx->pOut->iLayerBsIndex;
@@ -3343,6 +3347,7 @@
     pLayerBsInfo->uiLayerType   = NON_VIDEO_CODING_LAYER;
     pLayerBsInfo->iNalCount     = iCountNal;
     pLayerBsInfo->eFrameType    = videoFrameTypeIDR;
+    pLayerBsInfo->iSubSeqId     = GetSubSequenceId (pCtx, videoFrameTypeIDR);
     //point to next pLayerBsInfo
     ++ pLayerBsInfo;
     ++ pCtx->pOut->iLayerBsIndex;
@@ -3376,6 +3381,7 @@
     pLayerBsInfo->uiLayerType   = NON_VIDEO_CODING_LAYER;
     pLayerBsInfo->iNalCount     = iCountNal;
     pLayerBsInfo->eFrameType    = videoFrameTypeIDR;
+    pLayerBsInfo->iSubSeqId     = GetSubSequenceId (pCtx, videoFrameTypeIDR);
     //point to next pLayerBsInfo
     ++ pLayerBsInfo;
     ++ pCtx->pOut->iLayerBsIndex;
@@ -3772,6 +3778,7 @@
       pLayerBsInfo->uiQualityId         = 0;
       pLayerBsInfo->iNalCount           = ++ iNalIdxInLayer;
       pLayerBsInfo->eFrameType          = eFrameType;
+      pLayerBsInfo->iSubSeqId = GetSubSequenceId (pCtx, eFrameType);
     }
     // for dynamic slicing single threading..
     else if ((SM_SIZELIMITED_SLICE == pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) {
@@ -3779,6 +3786,7 @@
       pCtx->iEncoderError = WelsCodeOnePicPartition (pCtx, pFbi, pLayerBsInfo, &iNalIdxInLayer, &iLayerSize, 0,
                             kiLastMbInFrame, 0);
       pLayerBsInfo->eFrameType = eFrameType;
+      pLayerBsInfo->iSubSeqId = GetSubSequenceId (pCtx, eFrameType);
       WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
     } else {
       //other multi-slice uiSliceMode
@@ -3805,6 +3813,7 @@
         pLayerBsInfo->uiQualityId   = 0;
         pLayerBsInfo->iNalCount     = 0;
         pLayerBsInfo->eFrameType    = eFrameType;
+        pLayerBsInfo->iSubSeqId = GetSubSequenceId (pCtx, eFrameType);
         pCtx->pTaskManage->ExecuteTasks();
         if (pCtx->iEncoderError) {
           WelsLog (pLogCtx, WELS_LOG_ERROR,
@@ -3856,7 +3865,7 @@
         pLbi->uiQualityId   = 0;
         pLbi->iNalCount     = 0;
         pLbi->eFrameType = eFrameType;
-
+        pLbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType);
         int32_t iIdx = 0;
         while (iIdx < kiPartitionCnt) {
           pCtx->pSliceThreading->pThreadPEncCtx[iIdx].pFrameBsInfo = pFbi;
@@ -3925,6 +3934,7 @@
         pLayerBsInfo->uiQualityId       = 0;
         pLayerBsInfo->iNalCount         = iNalIdxInLayer;
         pLayerBsInfo->eFrameType        = eFrameType;
+        pLayerBsInfo->iSubSeqId         = GetSubSequenceId (pCtx, eFrameType);
       }
     }
 
@@ -4103,6 +4113,7 @@
       pLayerBsInfo->iNalCount           = 1;
       pLayerBsInfo->pNalLengthInByte[0] = iPaddingNalSize;
       pLayerBsInfo->eFrameType          = eFrameType;
+      pLayerBsInfo->iSubSeqId = GetSubSequenceId (pCtx, eFrameType);
       ++ pLayerBsInfo;
       ++ pCtx->pOut->iLayerBsIndex;
       pLayerBsInfo->pBsBuf           = pCtx->pFrameBs + pCtx->iPosBsBuffer;
@@ -4187,17 +4198,14 @@
 
 
   pFbi->iLayerNum = iLayerNum;
-  pFbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType);
 
-  WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iSubSeqId = %d,iFrameSize = %d",
-           iLayerNum,
-           pFbi->iSubSeqId, iFrameSize);
+  WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iFrameSize = %d",
+           iLayerNum,iFrameSize);
   for (int32_t i = 0; i < iLayerNum; i++)
     WelsLog (pLogCtx, WELS_LOG_DEBUG,
-             "WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d, first Nal Length=%d,uiSpatialId = %d,uiTemporalId = %d",
-             i,
+             "WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d, first Nal Length=%d,uiSpatialId = %d,uiTemporalId = %d,iSubSeqId = %d",i,
              pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount, pFbi->sLayerInfo[i].pNalLengthInByte[0],
-             pFbi->sLayerInfo[i].uiSpatialId, pFbi->sLayerInfo[i].uiTemporalId);
+             pFbi->sLayerInfo[i].uiSpatialId, pFbi->sLayerInfo[i].uiTemporalId,pFbi->sLayerInfo[i].iSubSeqId);
   WelsEmms();
 
   pLayerBsInfo->eFrameType = eFrameType;