HEVC代码追踪(三):encode->compressGOP

/**
 - Application has picture buffer list with size of GOP + 1
 - Picture buffer list acts like as ring buffer
 - End of the list has the latest picture
 .
 \param   flush               cause encoder to encode a partial GOP
 \param   pcPicYuvOrg         original YUV picture
 \retval  rcListPicYuvRecOut  list of reconstruction YUV pictures
 \retval  rcListBitstreamOut  list of output bitstreams
 \retval  iNumEncoded         number of encoded pictures
 */
Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
{
	if (pcPicYuvOrg) 
	{
		// get original YUV
		TComPic* pcPicCurr = NULL;
		xGetNewPicBuffer( pcPicCurr );
		pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );

		// compute image characteristics
		if ( getUseAdaptiveQP() )
		{
			m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
		}
	}
  
	if (!m_iNumPicRcvd || (!flush && m_iPOCLast != 0 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize))
	{
		iNumEncoded = 0;
		return;
	}
  
	if ( m_RCEnableRateControl )
	{
		m_cRateCtrl.initRCGOP( m_iNumPicRcvd );
	}

	// compress GOP

	m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false);

	if ( m_RCEnableRateControl )
	{
		m_cRateCtrl.destroyRCGOP();
	}
  
	iNumEncoded         = m_iNumPicRcvd;
	m_iNumPicRcvd       = 0;
	m_uiNumAllPicCoded += iNumEncoded;
}

你可能感兴趣的:(HEVC)