[置顶] HEVC学习(二十六) —— 量化之一

先列出HM中与draft对应的几个表格,随着研究的深入,本文会慢慢补充。

enum ScalingListSize
{
  SCALING_LIST_4x4 = 0,
  SCALING_LIST_8x8,
  SCALING_LIST_16x16,
  SCALING_LIST_32x32,
  SCALING_LIST_SIZE_NUM
}; //!< Table 7-2 (Specification of SizeID)
static const Char MatrixType[4][6][20] =
{
  {
  "INTRA4X4_LUMA",
  "INTRA4X4_CHROMAU",
  "INTRA4X4_CHROMAV",
  "INTER4X4_LUMA",
  "INTER4X4_CHROMAU",
  "INTER4X4_CHROMAV"
  },
  {
  "INTRA8X8_LUMA",
  "INTRA8X8_CHROMAU", 
  "INTRA8X8_CHROMAV", 
  "INTER8X8_LUMA",
  "INTER8X8_CHROMAU", 
  "INTER8X8_CHROMAV"  
  },
  {
  "INTRA16X16_LUMA",
  "INTRA16X16_CHROMAU", 
  "INTRA16X16_CHROMAV", 
  "INTER16X16_LUMA",
  "INTER16X16_CHROMAU", 
  "INTER16X16_CHROMAV"  
  },
  {
  "INTRA32X32_LUMA",
  "INTER32X32_LUMA",
  },
}; //!< Table 7-3 (Specification of MatrixID according to SizeID, prediction type and colour component)Int g_quantTSDefault4x4[16] =
{
  16,16,16,16,
  16,16,16,16,
  16,16,16,16,
  16,16,16,16
}; //!< TU为4x4时的情况
//!< 注意以下两个表格若想与Table 7-5一一对应,需要以up-right diamond方式进行查看
Int g_quantIntraDefault8x8[64] =
{
  16,16,16,16,17,18,21,24,
  16,16,16,16,17,19,22,25,
  16,16,17,18,20,22,25,29,
  16,16,18,21,24,27,31,36,
  17,17,20,24,30,35,41,47,
  18,19,22,27,35,44,54,65,
  21,22,25,31,41,54,70,88,
  24,25,29,36,47,65,88,115
}; //!< Table 7-5 (Specification of default values of ScalingList[1..3][MatrixID][i] with i=0..63)

Int g_quantInterDefault8x8[64] =
{
  16,16,16,16,17,18,20,24,
  16,16,16,17,18,20,24,25,
  16,16,17,18,20,24,25,28,
  16,17,18,20,24,25,28,33,
  17,18,20,24,25,28,33,41,
  18,20,24,25,28,33,41,54,
  20,24,25,28,33,41,54,71,
  24,25,28,33,41,54,71,91
}; //!< Table 7-5 (Specification of default values of ScalingList[1..3][MatrixID][i] with i=0..63)
UInt g_scalingListSize   [4] = {16,64,256,1024}; //!< 对应SizeID下Matrix的尺寸(行数乘列数),4x4,8x8,16x16,32x32
UInt g_scalingListSizeX  [4] = { 4, 8, 16,  32};	//!< 对应SizeID下Matrix的(行数)
UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; //!< 32x32的TU的MatrixID只有0和1,其余情况为0~5
Int  g_eTTable[4] = {0,3,1,2}; //!< 用于辅助计算MatrixID

const UChar g_aucChromaScale[58]=
{
   0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,
  17,18,19,20,21,22,23,24,25,26,27,28,29,29,30,31,32,
  33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44,
  45,46,47,48,49,50,51
}; //!< Table 8-9 (Specification of QPc as a function of qPi)

下面这个函数对qp进行了设置:

/** Set qP for Quantization.
 * \param qpy QPy
 * \param bLowpass
 * \param eSliceType
 * \param eTxtType
 * \param qpBdOffset
 * \param chromaQPOffset
 *
 * return void  
 */
Void TComTrQuant::setQPforQuant( Int qpy, TextType eTxtType, Int qpBdOffset, Int chromaQPOffset)
{
  Int qpScaled;

  if(eTxtType == TEXT_LUMA)
  {
    qpScaled = qpy + qpBdOffset;	//!< draft (8-235)
  }
  else
  {
	  /*                 
	  **	if(eText == TEXT_CHROMA_U)
	  **	{
	  **		curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
	  **	}
	  **	else
	  **	{
	  **		curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
	  **	}
	  **	如上所示,对于Cb,Cr分量,在调用setQPforQuant之前,就对chromaQPOffset进行了赋值
	  */
    qpScaled = Clip3( -qpBdOffset, 57, qpy + chromaQPOffset ); //!< draft (8-236)、(8-237)
	//! 以下为Table 8-9 (Specification of QPc as a function of qPi)
    if(qpScaled < 0)	//!< qpScaled小于0时,不方便查表,但对照表格,qpScaled小于30时,QPc=qPi(qpScaled)
    {
      qpScaled = qpScaled + qpBdOffset;
    }
    else
    {
      qpScaled = g_aucChromaScale[ qpScaled ] + qpBdOffset; //!< draft (8-238)、(8-239)
    }
  }
  m_cQP.setQpParam( qpScaled ); //!<设置最终得到的qp
}
m_cSPS.setQpBDOffsetY ( 6*(g_bitDepthY - 8) ); //!< luma quantization parameter range offset (7-9)
m_cSPS.setQpBDOffsetC ( 6*(g_bitDepthC - 8) ); //!< chroma quantization parameter range offset (7-11)




 

你可能感兴趣的:(scaling,量化,hm,HEVC)