HEVC代码追踪(四):compressGOP框架

简介: <p><br></p> <p></p> <pre code_snippet_id="533280" snippet_file_name="blog_20141126_1_6973215" name="code" class="cpp">Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPi


Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, bool isField, bool isTff)
{						
	/*compressGOP的一些初始设定或者说是初始参数*/
	TComPic*        pcPic;
	TComPicYuv*     pcPicYuvRecOut;
	TComSlice*      pcSlice;
	TComOutputBitstream  *pcBitstreamRedirect;
	pcBitstreamRedirect = new TComOutputBitstream;

	AccessUnit::iterator  itLocationToPushSliceHeaderNALU; // used to store location where NALU containing slice header is to be inserted
	UInt                  uiOneBitstreamPerSliceLength = 0;
	TEncSbac* pcSbacCoders = NULL;
	TComOutputBitstream* pcSubstreamsOut = NULL;

	//Set GOP Size(设定GOP的大小)
	xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField );
  
  m_iNumPicCoded = 0;
  SEIPictureTiming pictureTimingSEI;
  Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();
  // Initialize Scalable Nesting SEI with single layer values
  SEIScalableNesting scalableNestingSEI;
  scalableNestingSEI.m_bitStreamSubsetFlag           = 1;      // If the nested SEI messages are picture buffereing SEI mesages, picure timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1
  scalableNestingSEI.m_nestingOpFlag                 = 0;
  scalableNestingSEI.m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
  scalableNestingSEI.m_allLayersFlag                 = 0;
  scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
  scalableNestingSEI.m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
  scalableNestingSEI.m_nestingLayerId[0]             = 0;
  scalableNestingSEI.m_callerOwnsSEIs                = true;
  Int picSptDpbOutputDuDelay = 0;
  UInt *accumBitsDU = NULL;
  UInt *accumNalsDU = NULL;
  SEIDecodingUnitInfo decodingUnitInfoSEI;
#if EFFICIENT_FIELD_IRAP
  Int IRAPGOPid = -1;
  Bool IRAPtoReorder = false;
  Bool swapIRAPForward = false;
  if(isField)
  {
    Int pocCurr;
    for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
    {
      // determine actual POC
      if(iPOCLast == 0) //case first frame or first top field
      {
        pocCurr=0;
      }
      else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value
      {
        pocCurr = 1;
      }
      else
      {
        pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField;
      }

      // check if POC corresponds to IRAP
      NalUnitType tmpUnitType = getNalUnitType(pocCurr, m_iLastIDR, isField);
      if(tmpUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && tmpUnitType <= NAL_UNIT_CODED_SLICE_CRA) // if picture is an IRAP
      {
        if(pocCurr%2 == 0 && iGOPid < m_iGopSize-1 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid+1).m_POC-1)
        { // if top field and following picture in enc order is associated bottom field
          IRAPGOPid = iGOPid;
          IRAPtoReorder = true;
          swapIRAPForward = true; 
          break;
        }
        if(pocCurr%2 != 0 && iGOPid > 0 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid-1).m_POC+1)
        {
          // if picture is an IRAP remember to process it first
          IRAPGOPid = iGOPid;
          IRAPtoReorder = true;
          swapIRAPForward = false; 
          break;
        }
      }
    }
  }
#endif


for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
 {
  大循环:第418行~第1981行
 }
  delete pcBitstreamRedirect;
  
  if( accumBitsDU != NULL) delete accumBitsDU;
  if( accumNalsDU != NULL) delete accumNalsDU;
  
  assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) );
}











目录
相关文章
HEVC代码追踪(十四):解码之xDecodeSlice
<p><br></p> <p></p> <pre name="code" class="cpp">Bool TDecTop::decode(InputNALUnit&amp; nalu, Int&amp; iSkipFrame, Int&amp; iPOCLastDisplay) { // Initialize entropy decoder m_cEntropyDecoder
2378 0
HEVC代码追踪(十五):解码之decompressSlice
<p><br></p> <p></p> <pre name="code" class="cpp">Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic*&amp; rpcPic) { TComSlice* pcSlice = rpcPic-&gt;getSlice(rpcPic-&gt;getC
1187 0
HEVC代码追踪(八。二):estIntraPredChromaQT
<p><br></p> <p></p> <pre code_snippet_id="537345" snippet_file_name="blog_20141130_1_6232807" name="code" class="cpp">Void TEncSearch::estIntraPredChromaQT( TComDataCU* pcCU,
1679 0
HEVC代码追踪(七):xCompressCu
<p><br></p> <p></p> <pre name="code" class="cpp">// ==================================================================================================================== // Protected member functi
2594 0
HEVC代码追踪(八。三):encodeCoeff
<p><br></p> <p></p> <pre name="code" class="cpp">// texture /** encode coefficients * \param pcCU * \param uiAbsPartIdx * \param uiDepth * \param uiWidth * \param uiHeight */ Void TEncEntro
1855 0
HEVC代码追踪(八。一):estIntraPredQT
<p><br></p> <p></p> <pre code_snippet_id="537334" snippet_file_name="blog_20141130_1_4880297" name="code" class="cpp">Void TEncSearch::estIntraPredQT( TComDataCU* pcCU,
2367 0
|
编解码
HEVC代码追踪(六):compressCU
<p><br></p> <p></p> <pre code_snippet_id="537266" snippet_file_name="blog_20141130_1_961923" name="code" class="cpp">Void TEncCu::compressCU( TComDataCU*&amp; rpcCU ) { // initialize CU data
1426 0
HEVC代码追踪(十一。四):运动估计/补偿之xPatternSearch和xPatternSearchFast
<p><br></p> <p></p> <pre name="code" class="cpp">Void TEncSearch::xPatternSearch( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv* pcMvSrchRngLT, TComMv* pcMvSrchRngRB, TComMv&amp;
1792 0
HEVC代码追踪(十一。八):运动估计/补偿之xTZ8PointSquareSearch
<p><br></p> <p></p> <pre code_snippet_id="539588" snippet_file_name="blog_20141202_1_7201235" name="code" class="cpp">__inline Void TEncSearch::xTZ8PointSquareSearch( TComPattern* pcPatternKey,
1105 0
HEVC代码追踪(十一。三):运动估计/补偿之xMotionEstimation
<p><br></p> <p></p> <pre name="code" class="cpp">//!&lt; 运动估计(基本思想就是用TZSearch算法先进行整像素搜索,确定一个局部的最佳值,然后以这个最佳点为中心再进行精度更高的分像素搜索。) Void TEncSearch::xMotionEstimation( TComDataCU* pcCU,
2154 0