| 1 | /** \file TAppEncLayerCfg.cpp |
|---|
| 2 | \brief Handle encoder configuration parameters |
|---|
| 3 | */ |
|---|
| 4 | |
|---|
| 5 | #include <stdlib.h> |
|---|
| 6 | #include <cassert> |
|---|
| 7 | #include <cstring> |
|---|
| 8 | #include <string> |
|---|
| 9 | #include "TLibCommon/TComRom.h" |
|---|
| 10 | #include "TAppEncCfg.h" |
|---|
| 11 | #include "TAppEncLayerCfg.h" |
|---|
| 12 | #include "TAppCommon/program_options_lite.h" |
|---|
| 13 | |
|---|
| 14 | #ifdef WIN32 |
|---|
| 15 | #define strdup _strdup |
|---|
| 16 | #endif |
|---|
| 17 | |
|---|
| 18 | using namespace std; |
|---|
| 19 | namespace po = df::program_options_lite; |
|---|
| 20 | |
|---|
| 21 | //! \ingroup TAppEncoder |
|---|
| 22 | //! \{ |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | #if AUXILIARY_PICTURES |
|---|
| 26 | static inline ChromaFormat numberToChromaFormat(const Int val) |
|---|
| 27 | { |
|---|
| 28 | switch (val) |
|---|
| 29 | { |
|---|
| 30 | case 400: return CHROMA_400; break; |
|---|
| 31 | case 420: return CHROMA_420; break; |
|---|
| 32 | case 422: return CHROMA_422; break; |
|---|
| 33 | case 444: return CHROMA_444; break; |
|---|
| 34 | default: return NUM_CHROMA_FORMAT; |
|---|
| 35 | } |
|---|
| 36 | } |
|---|
| 37 | #endif |
|---|
| 38 | |
|---|
| 39 | // ==================================================================================================================== |
|---|
| 40 | // Constructor / destructor / initialization / destroy |
|---|
| 41 | // ==================================================================================================================== |
|---|
| 42 | #if SVC_EXTENSION |
|---|
| 43 | TAppEncLayerCfg::TAppEncLayerCfg() |
|---|
| 44 | :m_cInputFile(string("")), |
|---|
| 45 | m_cReconFile(string("")), |
|---|
| 46 | m_conformanceMode( 0 ), |
|---|
| 47 | m_aidQP(NULL) |
|---|
| 48 | #if REPN_FORMAT_IN_VPS |
|---|
| 49 | , m_repFormatIdx (-1) |
|---|
| 50 | #endif |
|---|
| 51 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 52 | , m_colourRemapSEIFileRoot(string("")) |
|---|
| 53 | #endif |
|---|
| 54 | { |
|---|
| 55 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 56 | for( Int c=0 ; c<3 ; c++) |
|---|
| 57 | { |
|---|
| 58 | m_colourRemapSEIPreLutCodedValue[c] = NULL; |
|---|
| 59 | m_colourRemapSEIPreLutTargetValue[c] = NULL; |
|---|
| 60 | m_colourRemapSEIPostLutCodedValue[c] = NULL; |
|---|
| 61 | m_colourRemapSEIPostLutTargetValue[c] = NULL; |
|---|
| 62 | } |
|---|
| 63 | #endif |
|---|
| 64 | m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0; |
|---|
| 65 | m_aiPad[1] = m_aiPad[0] = 0; |
|---|
| 66 | m_numRefLayerLocationOffsets = 0; |
|---|
| 67 | #if O0098_SCALED_REF_LAYER_ID |
|---|
| 68 | ::memset(m_refLocationOffsetLayerId, 0, sizeof(m_refLocationOffsetLayerId)); |
|---|
| 69 | #endif |
|---|
| 70 | ::memset(m_scaledRefLayerLeftOffset, 0, sizeof(m_scaledRefLayerLeftOffset)); |
|---|
| 71 | ::memset(m_scaledRefLayerTopOffset, 0, sizeof(m_scaledRefLayerTopOffset)); |
|---|
| 72 | ::memset(m_scaledRefLayerRightOffset, 0, sizeof(m_scaledRefLayerRightOffset)); |
|---|
| 73 | ::memset(m_scaledRefLayerBottomOffset, 0, sizeof(m_scaledRefLayerBottomOffset)); |
|---|
| 74 | ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag)); |
|---|
| 75 | ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag)); |
|---|
| 76 | ::memset(m_refRegionLeftOffset, 0, sizeof(m_refRegionLeftOffset)); |
|---|
| 77 | ::memset(m_refRegionTopOffset, 0, sizeof(m_refRegionTopOffset)); |
|---|
| 78 | ::memset(m_refRegionRightOffset, 0, sizeof(m_refRegionRightOffset)); |
|---|
| 79 | ::memset(m_refRegionBottomOffset, 0, sizeof(m_refRegionBottomOffset)); |
|---|
| 80 | ::memset(m_resamplePhaseSetPresentFlag, 0, sizeof(m_resamplePhaseSetPresentFlag)); |
|---|
| 81 | ::memset(m_phaseHorLuma, 0, sizeof(m_phaseHorLuma)); |
|---|
| 82 | ::memset(m_phaseVerLuma, 0, sizeof(m_phaseVerLuma)); |
|---|
| 83 | ::memset(m_phaseHorChroma, 0, sizeof(m_phaseHorChroma)); |
|---|
| 84 | ::memset(m_phaseVerChroma, 0, sizeof(m_phaseVerChroma)); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | TAppEncLayerCfg::~TAppEncLayerCfg() |
|---|
| 88 | { |
|---|
| 89 | if ( m_aidQP ) |
|---|
| 90 | { |
|---|
| 91 | delete[] m_aidQP; |
|---|
| 92 | } |
|---|
| 93 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 94 | for( Int c=0 ; c<3 ; c++) |
|---|
| 95 | { |
|---|
| 96 | if ( m_colourRemapSEIPreLutCodedValue[c] ) |
|---|
| 97 | { |
|---|
| 98 | delete[] m_colourRemapSEIPreLutCodedValue[c]; |
|---|
| 99 | } |
|---|
| 100 | if ( m_colourRemapSEIPreLutTargetValue[c] ) |
|---|
| 101 | { |
|---|
| 102 | delete[] m_colourRemapSEIPreLutTargetValue[c]; |
|---|
| 103 | } |
|---|
| 104 | if ( m_colourRemapSEIPostLutCodedValue[c] ) |
|---|
| 105 | { |
|---|
| 106 | delete[] m_colourRemapSEIPostLutCodedValue[c]; |
|---|
| 107 | } |
|---|
| 108 | if ( m_colourRemapSEIPostLutTargetValue[c] ) |
|---|
| 109 | { |
|---|
| 110 | delete[] m_colourRemapSEIPostLutTargetValue[c]; |
|---|
| 111 | } |
|---|
| 112 | } |
|---|
| 113 | #endif |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | Void TAppEncLayerCfg::create() |
|---|
| 117 | { |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | Void TAppEncLayerCfg::destroy() |
|---|
| 121 | { |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | // ==================================================================================================================== |
|---|
| 126 | // Public member functions |
|---|
| 127 | // ==================================================================================================================== |
|---|
| 128 | |
|---|
| 129 | /** \param argc number of arguments |
|---|
| 130 | \param argv array of arguments |
|---|
| 131 | \retval true when success |
|---|
| 132 | */ |
|---|
| 133 | bool TAppEncLayerCfg::parseCfg( const string& cfgFileName ) |
|---|
| 134 | { |
|---|
| 135 | string cfg_InputFile; |
|---|
| 136 | string cfg_ReconFile; |
|---|
| 137 | string cfg_dQPFile; |
|---|
| 138 | #if AUXILIARY_PICTURES |
|---|
| 139 | Int tmpInputChromaFormat; |
|---|
| 140 | Int tmpChromaFormat; |
|---|
| 141 | #endif |
|---|
| 142 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 143 | string cfg_colourRemapSEIFileRoot; |
|---|
| 144 | #endif |
|---|
| 145 | |
|---|
| 146 | po::Options opts; |
|---|
| 147 | opts.addOptions() |
|---|
| 148 | ("InputFile,i", cfg_InputFile, string(""), "original YUV input file name") |
|---|
| 149 | #if AVC_BASE |
|---|
| 150 | ("InputBLFile,-ibl", cfg_InputFile, string(""), "original YUV input file name") |
|---|
| 151 | #endif |
|---|
| 152 | ("ReconFile,o", cfg_ReconFile, string(""), "reconstructed YUV output file name") |
|---|
| 153 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
|---|
| 154 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
|---|
| 155 | ("CroppingMode", m_conformanceMode, 0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping") |
|---|
| 156 | #if AUXILIARY_PICTURES |
|---|
| 157 | ("InputChromaFormat", tmpInputChromaFormat, 420, "InputChromaFormatIDC") |
|---|
| 158 | ("ChromaFormatIDC", tmpChromaFormat, 420, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)") |
|---|
| 159 | #endif |
|---|
| 160 | ("ConfLeft", m_confWinLeft, 0, "Deprecated alias of ConfWinLeft") |
|---|
| 161 | ("ConfRight", m_confWinRight, 0, "Deprecated alias of ConfWinRight") |
|---|
| 162 | ("ConfTop", m_confWinTop, 0, "Deprecated alias of ConfWinTop") |
|---|
| 163 | ("ConfBottom", m_confWinBottom, 0, "Deprecated alias of ConfWinBottom") |
|---|
| 164 | ("ConfWinLeft", m_confWinLeft, 0, "Left offset for window conformance mode 3") |
|---|
| 165 | ("ConfWinRight", m_confWinRight, 0, "Right offset for window conformance mode 3") |
|---|
| 166 | ("ConfWinTop", m_confWinTop, 0, "Top offset for window conformance mode 3") |
|---|
| 167 | ("ConfWinBottom", m_confWinBottom, 0, "Bottom offset for window conformance mode 3") |
|---|
| 168 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "horizontal source padding for cropping mode 2") |
|---|
| 169 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "vertical source padding for cropping mode 2") |
|---|
| 170 | ("IntraPeriod,-ip", m_iIntraPeriod, -1, "intra period in frames, (-1: only first frame)") |
|---|
| 171 | ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") |
|---|
| 172 | ("dQPFile,m", cfg_dQPFile, string(""), "dQP file name") |
|---|
| 173 | ("QP,q", m_fQP, 30.0, "Qp value, if value is float, QP is switched once during encoding") |
|---|
| 174 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 175 | ("SEIColourRemappingInfoFileRoot", cfg_colourRemapSEIFileRoot, string(""), "Colour Remapping Information SEI parameters file name") |
|---|
| 176 | #endif |
|---|
| 177 | ; |
|---|
| 178 | |
|---|
| 179 | po::setDefaults(opts); |
|---|
| 180 | po::parseConfigFile(opts, cfgFileName); |
|---|
| 181 | |
|---|
| 182 | m_cInputFile = cfg_InputFile; |
|---|
| 183 | m_cReconFile = cfg_ReconFile; |
|---|
| 184 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
|---|
| 185 | #if AUXILIARY_PICTURES |
|---|
| 186 | m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat); |
|---|
| 187 | m_chromaFormatIDC = ((tmpChromaFormat == 0) ? (m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat))); |
|---|
| 188 | #endif |
|---|
| 189 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 190 | m_colourRemapSEIFileRoot = cfg_colourRemapSEIFileRoot.empty() ? NULL : strdup(cfg_colourRemapSEIFileRoot.c_str()); |
|---|
| 191 | #endif |
|---|
| 192 | |
|---|
| 193 | // reading external dQP description from file |
|---|
| 194 | if ( m_pchdQPFile ) |
|---|
| 195 | { |
|---|
| 196 | FILE* fpt=fopen( m_pchdQPFile, "r" ); |
|---|
| 197 | if ( fpt ) |
|---|
| 198 | { |
|---|
| 199 | Int iValue; |
|---|
| 200 | Int iPOC = 0; |
|---|
| 201 | while ( iPOC < m_cAppEncCfg->getNumFrameToBeEncoded() ) |
|---|
| 202 | { |
|---|
| 203 | if ( fscanf(fpt, "%d", &iValue ) == EOF ) break; |
|---|
| 204 | m_aidQP[ iPOC ] = iValue; |
|---|
| 205 | iPOC++; |
|---|
| 206 | } |
|---|
| 207 | fclose(fpt); |
|---|
| 208 | } |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | return true; |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | Void TAppEncLayerCfg::xPrintParameter() |
|---|
| 215 | { |
|---|
| 216 | printf("Input File : %s\n", m_cInputFile.c_str() ); |
|---|
| 217 | printf("Reconstruction File : %s\n", m_cReconFile.c_str() ); |
|---|
| 218 | #if REPN_FORMAT_IN_VPS |
|---|
| 219 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - ( m_confWinLeft + m_confWinRight ) * TComSPS::getWinUnitX( m_chromaFormatIDC ), m_iSourceHeight - ( m_confWinTop + m_confWinBottom ) * TComSPS::getWinUnitY( m_chromaFormatIDC ), m_iFrameRate ); |
|---|
| 220 | #else |
|---|
| 221 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate ); |
|---|
| 222 | #endif |
|---|
| 223 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
|---|
| 224 | #if MULTIPLE_PTL_SUPPORT |
|---|
| 225 | printf("PTL index : %d\n", m_layerPTLIdx ); |
|---|
| 226 | #endif |
|---|
| 227 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
|---|
| 228 | printf("Input bit depth : (Y:%d, C:%d)\n", m_inputBitDepth[CHANNEL_TYPE_LUMA], m_inputBitDepth[CHANNEL_TYPE_CHROMA] ); |
|---|
| 229 | printf("Internal bit depth : (Y:%d, C:%d)\n", m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA] ); |
|---|
| 230 | printf("PCM sample bit depth : (Y:%d, C:%d)\n", m_cAppEncCfg->getPCMInputBitDepthFlag() ? m_inputBitDepth[CHANNEL_TYPE_LUMA] : m_internalBitDepth[CHANNEL_TYPE_LUMA], m_cAppEncCfg->getPCMInputBitDepthFlag() ? m_inputBitDepth[CHANNEL_TYPE_CHROMA] : m_internalBitDepth[CHANNEL_TYPE_CHROMA] ); |
|---|
| 231 | #endif |
|---|
| 232 | std::cout << "Input ChromaFormatIDC :"; |
|---|
| 233 | |
|---|
| 234 | switch (m_InputChromaFormatIDC) |
|---|
| 235 | { |
|---|
| 236 | case CHROMA_400: std::cout << " 4:0:0"; break; |
|---|
| 237 | case CHROMA_420: std::cout << " 4:2:0"; break; |
|---|
| 238 | case CHROMA_422: std::cout << " 4:2:2"; break; |
|---|
| 239 | case CHROMA_444: std::cout << " 4:4:4"; break; |
|---|
| 240 | default: |
|---|
| 241 | std::cerr << "Invalid"; |
|---|
| 242 | exit(1); |
|---|
| 243 | } |
|---|
| 244 | std::cout << std::endl; |
|---|
| 245 | |
|---|
| 246 | std::cout << "Output (internal) ChromaFormatIDC :"; |
|---|
| 247 | switch (m_chromaFormatIDC) |
|---|
| 248 | { |
|---|
| 249 | case CHROMA_400: std::cout << " 4:0:0"; break; |
|---|
| 250 | case CHROMA_420: std::cout << " 4:2:0"; break; |
|---|
| 251 | case CHROMA_422: std::cout << " 4:2:2"; break; |
|---|
| 252 | case CHROMA_444: std::cout << " 4:4:4"; break; |
|---|
| 253 | default: |
|---|
| 254 | std::cerr << "Invalid"; |
|---|
| 255 | exit(1); |
|---|
| 256 | } |
|---|
| 257 | printf("\n"); |
|---|
| 258 | #if LAYER_CTB |
|---|
| 259 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
|---|
| 260 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
|---|
| 261 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
|---|
| 262 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
|---|
| 263 | #endif |
|---|
| 264 | printf("QP : %5.2f\n", m_fQP ); |
|---|
| 265 | printf("Intra period : %d\n", m_iIntraPeriod ); |
|---|
| 266 | #if RC_SHVC_HARMONIZATION |
|---|
| 267 | printf("RateControl : %d\n", m_RCEnableRateControl ); |
|---|
| 268 | if(m_RCEnableRateControl) |
|---|
| 269 | { |
|---|
| 270 | printf("TargetBitrate : %d\n", m_RCTargetBitrate ); |
|---|
| 271 | printf("KeepHierarchicalBit : %d\n", m_RCKeepHierarchicalBit ); |
|---|
| 272 | printf("LCULevelRC : %d\n", m_RCLCULevelRC ); |
|---|
| 273 | printf("UseLCUSeparateModel : %d\n", m_RCUseLCUSeparateModel ); |
|---|
| 274 | printf("InitialQP : %d\n", m_RCInitialQP ); |
|---|
| 275 | printf("ForceIntraQP : %d\n", m_RCForceIntraQP ); |
|---|
| 276 | } |
|---|
| 277 | #endif |
|---|
| 278 | printf("WaveFrontSynchro : %d\n", m_waveFrontSynchro); |
|---|
| 279 | printf("WaveFrontSubstreams : %d\n", m_iWaveFrontSubstreams); |
|---|
| 280 | #if LAYER_CTB |
|---|
| 281 | printf("PCM : %d ", (m_cAppEncCfg->getUsePCM() && (1<<m_cAppEncCfg->getPCMLog2MinSize()) <= m_uiMaxCUWidth)? 1 : 0); |
|---|
| 282 | #endif |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | Bool confirmPara(Bool bflag, const char* message); |
|---|
| 286 | |
|---|
| 287 | Bool TAppEncLayerCfg::xCheckParameter( Bool isField ) |
|---|
| 288 | { |
|---|
| 289 | switch (m_conformanceMode) |
|---|
| 290 | { |
|---|
| 291 | case 0: |
|---|
| 292 | { |
|---|
| 293 | // no cropping or padding |
|---|
| 294 | m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0; |
|---|
| 295 | m_aiPad[1] = m_aiPad[0] = 0; |
|---|
| 296 | break; |
|---|
| 297 | } |
|---|
| 298 | case 1: |
|---|
| 299 | { |
|---|
| 300 | // conformance |
|---|
| 301 | if ((m_confWinLeft != 0) || (m_confWinRight != 0) || (m_confWinTop != 0) || (m_confWinBottom != 0)) |
|---|
| 302 | { |
|---|
| 303 | fprintf(stderr, "Warning: Automatic padding enabled, but cropping parameters are set. Undesired size possible.\n"); |
|---|
| 304 | } |
|---|
| 305 | if ((m_aiPad[1] != 0) || (m_aiPad[0] != 0)) |
|---|
| 306 | { |
|---|
| 307 | fprintf(stderr, "Warning: Automatic padding enabled, but padding parameters are also set\n"); |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | // automatic padding to minimum CU size |
|---|
| 311 | #if LAYER_CTB |
|---|
| 312 | Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); |
|---|
| 313 | #else |
|---|
| 314 | Int minCuSize = m_cAppEncCfg->getMaxCUHeight() >> (m_cAppEncCfg->getMaxCUDepth() - 1); |
|---|
| 315 | #endif |
|---|
| 316 | if (m_iSourceWidth % minCuSize) |
|---|
| 317 | { |
|---|
| 318 | m_aiPad[0] = m_confWinRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth; |
|---|
| 319 | m_iSourceWidth += m_confWinRight; |
|---|
| 320 | #if REPN_FORMAT_IN_VPS |
|---|
| 321 | m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC ); |
|---|
| 322 | #endif |
|---|
| 323 | } |
|---|
| 324 | if (m_iSourceHeight % minCuSize) |
|---|
| 325 | { |
|---|
| 326 | m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; |
|---|
| 327 | m_iSourceHeight += m_confWinBottom; |
|---|
| 328 | if ( isField ) |
|---|
| 329 | { |
|---|
| 330 | m_iSourceHeightOrg += m_confWinBottom << 1; |
|---|
| 331 | m_aiPad[1] = m_confWinBottom << 1; |
|---|
| 332 | } |
|---|
| 333 | #if REPN_FORMAT_IN_VPS |
|---|
| 334 | m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC ); |
|---|
| 335 | #endif |
|---|
| 336 | } |
|---|
| 337 | break; |
|---|
| 338 | } |
|---|
| 339 | case 2: |
|---|
| 340 | { |
|---|
| 341 | // conformance |
|---|
| 342 | if ((m_confWinLeft != 0) || (m_confWinRight != 0) || (m_confWinTop != 0) || (m_confWinBottom != 0)) |
|---|
| 343 | { |
|---|
| 344 | fprintf(stderr, "Warning: Automatic padding enabled, but cropping parameters are set. Undesired size possible.\n"); |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | //padding |
|---|
| 348 | m_iSourceWidth += m_aiPad[0]; |
|---|
| 349 | m_iSourceHeight += m_aiPad[1]; |
|---|
| 350 | m_confWinRight = m_aiPad[0]; |
|---|
| 351 | m_confWinBottom = m_aiPad[1]; |
|---|
| 352 | #if REPN_FORMAT_IN_VPS |
|---|
| 353 | m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC ); |
|---|
| 354 | m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC ); |
|---|
| 355 | #endif |
|---|
| 356 | break; |
|---|
| 357 | } |
|---|
| 358 | case 3: |
|---|
| 359 | { |
|---|
| 360 | // conformance |
|---|
| 361 | if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0)) |
|---|
| 362 | { |
|---|
| 363 | fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n"); |
|---|
| 364 | } |
|---|
| 365 | if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0)) |
|---|
| 366 | { |
|---|
| 367 | fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n"); |
|---|
| 368 | } |
|---|
| 369 | m_aiPad[1] = m_aiPad[0] = 0; |
|---|
| 370 | break; |
|---|
| 371 | } |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | // allocate slice-based dQP values |
|---|
| 375 | Int iFrameToBeEncoded = m_cAppEncCfg->getNumFrameToBeEncoded(); |
|---|
| 376 | Int iGOPSize = m_cAppEncCfg->getGOPSize(); |
|---|
| 377 | if( m_aidQP == NULL ) |
|---|
| 378 | m_aidQP = new Int[iFrameToBeEncoded + iGOPSize + 1 ]; |
|---|
| 379 | ::memset( m_aidQP, 0, sizeof(Int)*( iFrameToBeEncoded + iGOPSize + 1 ) ); |
|---|
| 380 | |
|---|
| 381 | // handling of floating-point QP values |
|---|
| 382 | // if QP is not integer, sequence is split into two sections having QP and QP+1 |
|---|
| 383 | m_iQP = (Int)( m_fQP ); |
|---|
| 384 | if ( m_iQP < m_fQP ) |
|---|
| 385 | { |
|---|
| 386 | Int iSwitchPOC = (Int)( iFrameToBeEncoded - (m_fQP - m_iQP)*iFrameToBeEncoded + 0.5 ); |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | iSwitchPOC = (Int)( (Double)iSwitchPOC / iGOPSize + 0.5 )*iGOPSize; |
|---|
| 390 | for ( Int i=iSwitchPOC; i<iFrameToBeEncoded + iGOPSize + 1; i++ ) |
|---|
| 391 | { |
|---|
| 392 | m_aidQP[i] = 1; |
|---|
| 393 | } |
|---|
| 394 | } |
|---|
| 395 | |
|---|
| 396 | #if LAYER_CTB |
|---|
| 397 | UInt maxCUWidth = m_uiMaxCUWidth; |
|---|
| 398 | UInt maxCUHeight = m_uiMaxCUHeight; |
|---|
| 399 | UInt maxCUDepth = m_uiMaxCUDepth; |
|---|
| 400 | #else |
|---|
| 401 | UInt maxCUWidth = m_cAppEncCfg->getMaxCUWidth(); |
|---|
| 402 | UInt maxCUHeight = m_cAppEncCfg->getMaxCUHeight(); |
|---|
| 403 | UInt maxCUDepth = m_cAppEncCfg->getMaxCUDepth(); |
|---|
| 404 | #endif |
|---|
| 405 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
|---|
| 406 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
|---|
| 407 | // check range of parameters |
|---|
| 408 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
|---|
| 409 | xConfirmPara( (m_iSourceWidth % (maxCUWidth >> (maxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size"); |
|---|
| 410 | xConfirmPara( (m_iSourceHeight % (maxCUHeight >> (maxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size"); |
|---|
| 411 | xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" ); |
|---|
| 412 | if (m_cAppEncCfg->getDecodingRefreshType() == 2) |
|---|
| 413 | { |
|---|
| 414 | xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= iGOPSize , "Intra period must be larger than GOP size for periodic IDR pictures"); |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
|---|
| 418 | xConfirmPara( m_iQP < -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
|---|
| 419 | #else |
|---|
| 420 | xConfirmPara( m_iQP < -6 * ((Int)m_cAppEncCfg->getInternalBitDepthY() - 8) || m_iQP > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
|---|
| 421 | #endif |
|---|
| 422 | |
|---|
| 423 | m_iWaveFrontSubstreams = m_waveFrontSynchro ? (m_iSourceHeight + maxCUHeight - 1) / maxCUHeight : 1; |
|---|
| 424 | xConfirmPara( m_waveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" ); |
|---|
| 425 | xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" ); |
|---|
| 426 | xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_waveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" ); |
|---|
| 427 | |
|---|
| 428 | //chekc parameters |
|---|
| 429 | xConfirmPara( m_iSourceWidth % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); |
|---|
| 430 | xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); |
|---|
| 431 | |
|---|
| 432 | xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling"); |
|---|
| 433 | xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling"); |
|---|
| 434 | |
|---|
| 435 | #if !REPN_FORMAT_IN_VPS |
|---|
| 436 | xConfirmPara( m_confLeft % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling"); |
|---|
| 437 | xConfirmPara( m_confRight % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling"); |
|---|
| 438 | xConfirmPara( m_confTop % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling"); |
|---|
| 439 | xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling"); |
|---|
| 440 | #endif |
|---|
| 441 | |
|---|
| 442 | #if LAYER_CTB |
|---|
| 443 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
|---|
| 444 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
|---|
| 445 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
|---|
| 446 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
|---|
| 447 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
|---|
| 448 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
|---|
| 449 | xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth, "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller."); |
|---|
| 450 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
|---|
| 451 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
|---|
| 452 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
|---|
| 453 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
|---|
| 454 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
|---|
| 455 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
|---|
| 456 | xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthInter - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" ); |
|---|
| 457 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
|---|
| 458 | xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthIntra - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" ); |
|---|
| 459 | |
|---|
| 460 | // max CU width and height should be power of 2 |
|---|
| 461 | UInt ui = m_uiMaxCUWidth; |
|---|
| 462 | while(ui) |
|---|
| 463 | { |
|---|
| 464 | ui >>= 1; |
|---|
| 465 | if( (ui & 1) == 1) |
|---|
| 466 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
|---|
| 467 | } |
|---|
| 468 | ui = m_uiMaxCUHeight; |
|---|
| 469 | while(ui) |
|---|
| 470 | { |
|---|
| 471 | ui >>= 1; |
|---|
| 472 | if( (ui & 1) == 1) |
|---|
| 473 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
|---|
| 474 | } |
|---|
| 475 | #endif |
|---|
| 476 | |
|---|
| 477 | #undef xConfirmPara |
|---|
| 478 | return check_failed; |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | #endif //SVC_EXTENSION |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | //! \} |
|---|