shithub: openh264

Download patch

ref: 40b2cc85f30196a9782dfd370d3c4ab3bf96818c
parent: 268e6cf09f5d608da62c0fad3cc1922b87a0ea6e
parent: b60bb67b4e7243979f83256155f26852b1cdca1c
author: HaiboZhu <haibozhu@cisco.com>
date: Thu Nov 19 09:07:29 EST 2015

Merge pull request #2256 from shihuade/MultiThread_V4.1_SliceCtx_V4_Pull_V3

change input paramters for Init/UninitSlicePEncCtx()

--- a/codec/encoder/core/inc/svc_enc_slice_segment.h
+++ b/codec/encoder/core/inc/svc_enc_slice_segment.h
@@ -72,7 +72,8 @@
 #define JUMPPACKETSIZE_JUDGE(len,mb_idx,max_byte)       ( (len) > JUMPPACKETSIZE_CONSTRAINT(max_byte) ) //( (mb_idx+1)%40/*16slice for compare*/ == 0 )        //
 //cur_mb_idx is for early tests, can be omit in optimization
 
-typedef struct TagSlice SSlice;
+typedef struct TagSlice      SSlice;
+typedef struct TagDqLayer    SDqLayer;
 typedef struct TagWelsEncCtx sWelsEncCtx;
 /*!
  * \brief   SSlice context
@@ -110,7 +111,7 @@
 /*!
  * \brief   Initialize Wels SSlice context (Single/multiple slices and FMO)
  *
- * \param   pSliceCtx       SSlice context to be initialized
+ * \param   pCurDq          current layer which its SSlice context will be initialized
  * \param   bFmoUseFlag     flag of using fmo
  * \param   iMbWidth        MB width
  * \param   iMbHeight       MB height
@@ -120,7 +121,7 @@
  *
  * \return  0 - successful; none 0 - failed;
  */
-int32_t InitSlicePEncCtx (SSliceCtx* pSliceCtx,
+int32_t InitSlicePEncCtx (SDqLayer* pCurDq,
                           CMemoryAlign* pMa,
                           bool bFmoUseFlag,
                           int32_t iMbWidth,
@@ -132,11 +133,11 @@
 /*!
  * \brief   Uninitialize Wels SSlice context (Single/multiple slices and FMO)
  *
- * \param   pSliceCtx       SSlice context to be initialized
+ * \param   pCurDq       curent layer which its SSlice context will be initialized
  *
  * \return  NONE;
  */
-void UninitSlicePEncCtx (SSliceCtx* pSliceCtx, CMemoryAlign* pMa);
+void UninitSlicePEncCtx (SDqLayer* pCurDq, CMemoryAlign* pMa);
 
 /*!
  * \brief   Get slice idc for given iMbXY (apply in Single/multiple slices and FMO)
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -1361,7 +1361,7 @@
 
     // Not using FMO in SVC coding so far, come back if need FMO
     {
-      iResult = InitSlicePEncCtx (&(*ppCtx)->ppDqLayerList[iDlayerIndex]->sSliceEncCtx,
+      iResult = InitSlicePEncCtx ((*ppCtx)->ppDqLayerList[iDlayerIndex],
                                   (*ppCtx)->pMemAlign,
                                   false,
                                   pSps->iMbWidth,
@@ -2120,9 +2120,8 @@
             pDq->pFeatureSearchPreparation = NULL;
           }
 
-          SSliceCtx* pSliceCtx = &pDq->sSliceEncCtx;
-          if (NULL != pSliceCtx) {
-            UninitSlicePEncCtx (pSliceCtx, pMa);
+          if (NULL != pDq) {
+            UninitSlicePEncCtx (pDq, pMa);
           }
 
           pMa->WelsFree (pDq, "pDq");
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -39,6 +39,7 @@
  */
 #include <string.h>
 #include "rc.h"
+#include "svc_enc_frame.h"
 
 namespace WelsEnc {
 /*!
@@ -343,7 +344,7 @@
 /*!
  * \brief   Initialize slice segment (Single/multiple slices)
  *
- * \param   pSliceSeg           SSlice segment to be initialized
+ * \param   pCurDq              current layer which its SSlice segment will be initialized
  * \param   uiSliceMode         SSlice mode
  * \param   multi_slice_argv    Multiple slices argument
  * \param   iMbWidth            MB width
@@ -351,13 +352,14 @@
  *
  * \return  0 - successful; none 0 - failed;
  */
-int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
+int32_t InitSliceSegment (SDqLayer* pCurDq,
                           CMemoryAlign* pMa,
                           SSliceArgument* pSliceArgument,
                           const int32_t kiMbWidth,
                           const int32_t kiMbHeight) {
-  const int32_t kiCountMbNum = kiMbWidth * kiMbHeight;
-  SliceModeEnum uiSliceMode = SM_SINGLE_SLICE;
+  SSliceCtx* pSliceSeg        = &pCurDq->sSliceEncCtx;
+  const int32_t kiCountMbNum  = kiMbWidth * kiMbHeight;
+  SliceModeEnum uiSliceMode   = SM_SINGLE_SLICE;
 
   if (NULL == pSliceSeg || NULL == pSliceArgument || kiMbWidth == 0 || kiMbHeight == 0)
     return 1;
@@ -475,11 +477,12 @@
 /*!
  * \brief   Uninitialize slice segment (Single/multiple slices)
  *
- * \param   pSliceSeg           SSlice segment to be uninitialized
+ * \param   pCurDq           current layer which its SSlice segment will be uninitialized
  *
  * \return  none;
  */
-void UninitSliceSegment (SSliceCtx* pSliceSeg, CMemoryAlign* pMa) {
+void UninitSliceSegment (SDqLayer* pCurDq, CMemoryAlign* pMa) {
+  SSliceCtx* pSliceSeg = &pCurDq->sSliceEncCtx;
   if (NULL != pSliceSeg) {
     if (NULL != pSliceSeg->pOverallMbMap) {
       pMa->WelsFree (pSliceSeg->pOverallMbMap, "pSliceSeg->pOverallMbMap");
@@ -514,7 +517,7 @@
 /*!
  * \brief   Initialize Wels SSlice context (Single/multiple slices and FMO)
  *
- * \param   pSliceCtx       SSlice context to be initialized
+ * \param   pCurDq          current layer which its SSlice context will be initialized
  * \param   bFmoUseFlag     flag of using fmo
  * \param   iMbWidth        MB width
  * \param   iMbHeight       MB height
@@ -524,7 +527,7 @@
  *
  * \return  0 - successful; none 0 - failed;
  */
-int32_t InitSlicePEncCtx (SSliceCtx* pSliceCtx,
+int32_t InitSlicePEncCtx (SDqLayer* pCurDq,
                           CMemoryAlign* pMa,
                           bool bFmoUseFlag,
                           int32_t iMbWidth,
@@ -531,10 +534,10 @@
                           int32_t iMbHeight,
                           SSliceArgument* pSliceArgument,
                           void* pPpsArg) {
-  if (NULL == pSliceCtx)
+  if (NULL == pCurDq)
     return 1;
 
-  InitSliceSegment (pSliceCtx,
+  InitSliceSegment (pCurDq,
                     pMa,
                     pSliceArgument,
                     iMbWidth,
@@ -545,13 +548,13 @@
 /*!
  * \brief   Uninitialize Wels SSlice context (Single/multiple slices and FMO)
  *
- * \param   pSliceCtx       SSlice context to be initialized
+ * \param   pCurDq       current layer which its SSlice context will be initialized
  *
  * \return  NONE;
  */
-void UninitSlicePEncCtx (SSliceCtx* pSliceCtx, CMemoryAlign* pMa) {
-  if (NULL != pSliceCtx) {
-    UninitSliceSegment (pSliceCtx, pMa);
+void UninitSlicePEncCtx (SDqLayer* pCurDq, CMemoryAlign* pMa) {
+  if (NULL != pCurDq) {
+    UninitSliceSegment (pCurDq, pMa);
   }
 }