codingparameter.cpp

来自「SVC最新更新代码」· C++ 代码 · 共 970 行 · 第 1/4 页

CPP
970
字号
  case HIGH_PROFILE:
  case SCALABLE_HIGH_PROFILE:
    if( ruiLevelIdc < 21 && isInterlaced() )
    {
      ruiLevelIdc = 21;
    }
    else if( ruiLevelIdc > 41 )
    {
      SETREPORT( m_uiMbAff, 0, "MbAff disabled for level compatibility" );
      SETREPORT( m_uiPAff,  0, "PAff disabled for level compatibility" );
    }
    break;
  case SCALABLE_BASELINE_PROFILE:
    if( ruiLevelIdc < 21 && ( m_uiEntropyCodingModeFlag || m_uiEnable8x8Trafo ) )
    {
      ruiLevelIdc = 21;
    }
    break;
  default:
    break;
  }
  m_uiLevelIdc = ruiLevelIdc;
  return Err::m_nOK;
}

Bool
LayerParameters::xIsBaselineProfile( CodingParameter* pcCodingParameter )
{
  ROFRS( m_uiLayerId                    == 0,               false );
  ROFRS( m_uiBaseLayerId                == MSYS_UINT_MAX,   false );
  ROFRS( m_uiPicCodingType              == 1,               false );
  ROFRS( m_uiMbAff                      == 0,               false );
  ROFRS( m_uiPAff                       == 0,               false );
  ROFRS( m_uiScalingMatricesPresent     == 0,               false );
  ROFRS( pcCodingParameter->m_uiIPMode  == 0,               false );
  ROFRS( pcCodingParameter->m_uiIPMode  == 0,               false );
  ROFRS( m_uiEntropyCodingModeFlag      == 0,               false );
  ROFRS( m_uiNumSliceGroupsMinus1       <= 7,               false );
  ROFRS( m_uiEnable8x8Trafo             == 0,               false );
  return true;
}
ErrVal
LayerParameters::xForceBaselineProfile( CodingParameter* pcCodingParameter )
{
  ROT( m_uiLayerId );
  ROF( m_uiBaseLayerId == MSYS_UINT_MAX );
  ROTREPORT( m_uiNumSliceGroupsMinus1     > 7, "NumSliceGrpMns1 must be less than 8 in Baseline profile compatibility mode" );
  SETREPORT( m_uiPicCodingType,             1, "B slices disabled for Baseline profile compatibility" );
  SETREPORT( m_uiMbAff,                     0, "MbAff disabled for Baseline profile compatibility" );
  SETREPORT( m_uiPAff,                      0, "PAff disabled for Baseline profile compatibility" );
  SETREPORT( m_uiScalingMatricesPresent,    0, "Scaling matrices disabled for Baseline profile compatibility" );
  SETREPORT( pcCodingParameter->m_uiIPMode, 0, "Weighted prediction disabled for Baseline profile compatibility" );
  SETREPORT( pcCodingParameter->m_uiIPMode,  0, "Weighted prediction disabled for Baseline profile compatibility" );
  SETREPORT( m_uiEntropyCodingModeFlag,     0, "CABAC disabled for Baseline profile compatibility" );
  SETREPORT( m_uiEnable8x8Trafo,            0, "8x8 transform disabled for Baseline profile compatibility" );
  return Err::m_nOK;
}

Bool
LayerParameters::xIsMainProfile( CodingParameter* pcCodingParameter )
{
  ROFRS( m_uiLayerId                    == 0,               false );
  ROFRS( m_uiBaseLayerId                == MSYS_UINT_MAX,   false );
  ROFRS( m_uiScalingMatricesPresent     == 0,               false );
  ROFRS( m_uiNumSliceGroupsMinus1       == 0,               false );
  ROFRS( m_uiUseRedundantSlice          == 0,               false ); 
  ROFRS( m_uiUseRedundantKeySlice       == 0,               false ); 
  ROFRS( m_uiEnable8x8Trafo             == 0,               false );
  return true;
}
ErrVal
LayerParameters::xForceMainProfile( CodingParameter* pcCodingParameter )
{
  ROT( m_uiLayerId );
  ROF( m_uiBaseLayerId == MSYS_UINT_MAX );
  SETREPORT( m_uiScalingMatricesPresent,  0, "Scaling matrices disabled for Main profile compatibility" );
  SETREPORT( m_uiNumSliceGroupsMinus1,    0, "NumSliceGrpMns1 set to 0 for Main profile compatibility" );
  SETREPORT( m_uiUseRedundantSlice,       0, "Redundant slices disabled for Main profile compatibility" ); 
  SETREPORT( m_uiUseRedundantKeySlice,    0, "Redundant slices disabled for Main profile compatibility" ); 
  SETREPORT( m_uiEnable8x8Trafo,          0, "8x8 transform disabled for Main profile compatibility" );
  return Err::m_nOK;
}

Bool
LayerParameters::xIsExtendedProfile( CodingParameter* pcCodingParameter )
{
  ROFRS( m_uiLayerId                    == 0,               false );
  ROFRS( m_uiBaseLayerId                == MSYS_UINT_MAX,   false );
  ROFRS( m_uiScalingMatricesPresent     == 0,               false );
  ROFRS( m_uiEntropyCodingModeFlag      == 0,               false );
  ROFRS( m_uiNumSliceGroupsMinus1       <= 7,               false );
  ROFRS( m_uiEnable8x8Trafo             == 0,               false );
  return true;
}
ErrVal
LayerParameters::xForceExtendedProfile( CodingParameter* pcCodingParameter )
{
  ROT( m_uiLayerId );
  ROF( m_uiBaseLayerId == MSYS_UINT_MAX );
  ROTREPORT( m_uiNumSliceGroupsMinus1   > 7, "NumSliceGrpMns1 must be less than 8 in Extended profile compatibility mode" );
  SETREPORT( m_uiScalingMatricesPresent,  0, "Scaling matrices disabled for Extended profile compatibility" );
  SETREPORT( m_uiEntropyCodingModeFlag,   0, "CABAC disabled for Extended profile compatibility" );
  SETREPORT( m_uiEnable8x8Trafo,          0, "8x8 transform disabled for Extended profile compatibility" );
  return Err::m_nOK;
}

Bool
LayerParameters::xIsHighProfile( CodingParameter* pcCodingParameter )
{
  ROFRS( m_uiLayerId                    == 0,               false );
  ROFRS( m_uiBaseLayerId                == MSYS_UINT_MAX,   false );
  ROFRS( m_uiNumSliceGroupsMinus1       == 0,               false );
  ROFRS( m_uiUseRedundantSlice          == 0,               false ); 
  ROFRS( m_uiUseRedundantKeySlice       == 0,               false ); 
  return true;
}
ErrVal
LayerParameters::xForceHighProfile( CodingParameter* pcCodingParameter )
{
  ROT( m_uiLayerId );
  ROF( m_uiBaseLayerId == MSYS_UINT_MAX );
  SETREPORT( m_uiNumSliceGroupsMinus1,    0, "NumSliceGrpMns1 set to 0 for High profile compatibility" );
  SETREPORT( m_uiUseRedundantSlice,       0, "Redundant slices disabled for High profile compatibility" ); 
  SETREPORT( m_uiUseRedundantKeySlice,    0, "Redundant slices disabled for High profile compatibility" ); 
  return Err::m_nOK;
}

Bool
LayerParameters::xIsIntraOnly( CodingParameter* pcCodingParameter )
{
  ROTRS( m_uiUseLongTerm,                                                       false );
  ROFRS( m_uiDecompositionStages        == m_uiNotCodedStages,                  false );
  ROFRS( pcCodingParameter->m_uiGOPSize == pcCodingParameter->m_uiIntraPeriod ||
         pcCodingParameter->m_uiGOPSize == (UInt)m_iIDRPeriod,                  false );
  ROTRS( m_uiBaseLayerId                == MSYS_UINT_MAX,                       true  );
  return pcCodingParameter->getLayerParameters( m_uiBaseLayerId ).isIntraOnly();
}

Bool
LayerParameters::xHasRestrictedESS( CodingParameter* pcCodingParameter )
{
  ROTRS( m_uiBaseLayerId                            == MSYS_UINT_MAX, true  );
  ROFRS( m_cResizeParameters.m_iLeftFrmOffset % 16  == 0,             false );
  ROFRS( m_cResizeParameters.m_iTopFrmOffset  % 16  == 0,             false );
  Bool   bHor11 = (     m_cResizeParameters.m_iScaledRefFrmWidth  ==     m_cResizeParameters.m_iRefLayerFrmWidth  );
  Bool   bHor23 = ( 2 * m_cResizeParameters.m_iScaledRefFrmWidth  == 3 * m_cResizeParameters.m_iRefLayerFrmWidth  );
  Bool   bHor12 = (     m_cResizeParameters.m_iScaledRefFrmWidth  == 2 * m_cResizeParameters.m_iRefLayerFrmWidth  );
  Bool   bVer11 = (     m_cResizeParameters.m_iScaledRefFrmHeight ==     m_cResizeParameters.m_iRefLayerFrmHeight );
  Bool   bVer23 = ( 2 * m_cResizeParameters.m_iScaledRefFrmHeight == 3 * m_cResizeParameters.m_iRefLayerFrmHeight );
  Bool   bVer12 = (     m_cResizeParameters.m_iScaledRefFrmHeight == 2 * m_cResizeParameters.m_iRefLayerFrmHeight );
  UInt   uiHor  = ( bHor11 ? 11 : bHor23 ? 23 : bHor12 ? 12 : (UInt)'H' );
  UInt   uiVer  = ( bVer11 ? 11 : bVer23 ? 23 : bVer12 ? 12 : (UInt)'V' );
  ROFRS( uiHor == uiVer,                                              false );
  return true;
}

Bool
LayerParameters::xIsScalableBaselineProfile( CodingParameter* pcCodingParameter )
{
  ROFRS( m_uiLayerId               > 0,                       false );
  ROFRS( m_uiMbAff                == 0,                       false );
  ROFRS( m_uiPAff                 == 0,                       false );
  ROFRS( m_uiNumSliceGroupsMinus1 <= 7,                       false );
  if   ( m_uiNumSliceGroupsMinus1 )
  {
    ROFRS( m_uiSliceGroupMapType  == 2,                       false );
  }
  ROFRS( m_uiBiPred8x8Disable     == 1,                       false );
  ROTRS( m_uiBaseLayerId          == MSYS_UINT_MAX,           true  );
  
  ROFRS( xHasRestrictedESS( pcCodingParameter ),              false );
  LayerParameters& rcBase = pcCodingParameter->getLayerParameters( m_uiBaseLayerId );
  if( m_uiBaseLayerId == 0 )
  {
    ROFRS( rcBase.m_bConstrainedSetFlag0,                     false );
    ROFRS( rcBase.m_bConstrainedSetFlag1,                     false );
    ROFRS( rcBase.m_bConstrainedSetFlag2,                     false );
    ROFRS( rcBase.m_uiProfileIdc == BASELINE_PROFILE ||
           rcBase.m_uiProfileIdc == MAIN_PROFILE     ||
           rcBase.m_uiProfileIdc == EXTENDED_PROFILE,         false );
    return true;
  }

  ROTRS( rcBase.m_uiProfileIdc == SCALABLE_BASELINE_PROFILE,  true  );
  ROTRS( rcBase.m_bConstrainedSetFlag0,                       true  );
  return false;
}
ErrVal
LayerParameters::xForceScalableBaselineProfile( CodingParameter* pcCodingParameter )
{
  ROF( m_uiLayerId );
  ROTREPORT( m_uiNumSliceGroupsMinus1     > 7,          "NumSliceGrpMns1 must be less than 8 in Scalable Baseline profile compatibility mode" );
  if( m_uiNumSliceGroupsMinus1 )
  {
    ROTREPORT( m_uiSliceGroupMapType     != 2,          "SliceGroupMapType must be equal to 2 in Scalable Baseline profile compatibility mode" );
  }
  SETREPORT( m_uiMbAff,                     0,          "MbAff disabled for Scalable Baseline profile compatibility" );
  SETREPORT( m_uiPAff,                      0,          "PAff disabled for Scalable Baseline profile compatibility" );
  SETREPORT( m_uiBiPred8x8Disable,          1,          "BiPred for blocks smaller than 8x8 disabled for Scalable Baseline profile compatibility" );
  ROTRS( m_uiBaseLayerId == MSYS_UINT_MAX,  Err::m_nOK  );
  ROTREPORT( ! xHasRestrictedESS( pcCodingParameter ),  "Spatial scalability parameters must be restricted for Scalable Baseline profile compatibility mode" );
  return Err::m_nOK;
}

Bool
LayerParameters::xIsScalableHighProfile( CodingParameter* pcCodingParameter )
{
  ROFRS( m_uiLayerId               > 0,                       false );
  ROFRS( m_uiNumSliceGroupsMinus1 == 0,                       false );
  ROFRS( m_uiUseRedundantSlice    == 0,                       false ); 
  ROFRS( m_uiUseRedundantKeySlice == 0,                       false ); 
  ROTRS( m_uiBaseLayerId          == MSYS_UINT_MAX,           true  );

  LayerParameters& rcBase = pcCodingParameter->getLayerParameters( m_uiBaseLayerId );
  if( m_uiBaseLayerId == 0 )
  {
    ROTRS( rcBase.m_uiProfileIdc == HIGH_PROFILE,             true  );
    ROFRS( rcBase.m_bConstrainedSetFlag1,                     false );
    ROFRS( rcBase.m_uiProfileIdc == BASELINE_PROFILE ||
           rcBase.m_uiProfileIdc == MAIN_PROFILE     ||
           rcBase.m_uiProfileIdc == EXTENDED_PROFILE,         false );
    return true;
  }

  ROTRS( rcBase.m_uiProfileIdc == SCALABLE_HIGH_PROFILE,      true  );
  ROTRS( rcBase.m_bConstrainedSetFlag1,                       true  );
  return false;
}
ErrVal
LayerParameters::xForceScalableHighProfile( CodingParameter* pcCodingParameter )
{
  ROF( m_uiLayerId );
  SETREPORT( m_uiNumSliceGroupsMinus1,    0, "NumSliceGrpMns1 set to 0 for Scalable High profile compatibility" );
  SETREPORT( m_uiUseRedundantSlice,       0, "Redundant slices disabled for Scalable High profile compatibility" ); 
  SETREPORT( m_uiUseRedundantKeySlice,    0, "Redundant slices disabled for Scalable High profile compatibility" ); 
  return Err::m_nOK;
}


H264AVC_NAMESPACE_END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?