[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TAppEncCfg.cpp |
---|
| 35 | \brief Handle encoder configuration parameters |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <stdlib.h> |
---|
| 39 | #include <cassert> |
---|
| 40 | #include <cstring> |
---|
| 41 | #include <string> |
---|
| 42 | #include "TLibCommon/TComRom.h" |
---|
| 43 | #include "TAppEncCfg.h" |
---|
| 44 | |
---|
| 45 | static istream& operator>>(istream &, Level::Name &); |
---|
| 46 | static istream& operator>>(istream &, Level::Tier &); |
---|
| 47 | static istream& operator>>(istream &, Profile::Name &); |
---|
| 48 | |
---|
| 49 | #include "TAppCommon/program_options_lite.h" |
---|
| 50 | #include "TLibEncoder/TEncRateCtrl.h" |
---|
| 51 | #ifdef WIN32 |
---|
| 52 | #define strdup _strdup |
---|
| 53 | #endif |
---|
| 54 | |
---|
| 55 | using namespace std; |
---|
| 56 | namespace po = df::program_options_lite; |
---|
| 57 | |
---|
| 58 | //! \ingroup TAppEncoder |
---|
| 59 | //! \{ |
---|
| 60 | |
---|
| 61 | // ==================================================================================================================== |
---|
| 62 | // Constructor / destructor / initialization / destroy |
---|
| 63 | // ==================================================================================================================== |
---|
| 64 | |
---|
| 65 | #if SVC_EXTENSION |
---|
| 66 | TAppEncCfg::TAppEncCfg() |
---|
| 67 | : m_pBitstreamFile() |
---|
| 68 | #if AVC_BASE |
---|
| 69 | , m_avcBaseLayerFlag(0) |
---|
| 70 | #endif |
---|
| 71 | , m_pColumnWidth() |
---|
| 72 | , m_pRowHeight() |
---|
| 73 | , m_scalingListFile() |
---|
| 74 | #if REF_IDX_FRAMEWORK |
---|
| 75 | , m_elRapSliceBEnabled(0) |
---|
| 76 | #endif |
---|
| 77 | { |
---|
| 78 | for(UInt layer=0; layer<MAX_LAYERS; layer++) |
---|
| 79 | { |
---|
| 80 | m_acLayerCfg[layer].setAppEncCfg(this); |
---|
| 81 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 82 | m_ilSampleOnlyPred[layer] = 0; |
---|
| 83 | #endif |
---|
| 84 | } |
---|
| 85 | memset( m_scalabilityMask, 0, sizeof(m_scalabilityMask) ); |
---|
| 86 | } |
---|
| 87 | #else |
---|
| 88 | TAppEncCfg::TAppEncCfg() |
---|
| 89 | : m_pchInputFile() |
---|
| 90 | , m_pchBitstreamFile() |
---|
| 91 | , m_pchReconFile() |
---|
| 92 | , m_pchdQPFile() |
---|
| 93 | , m_pColumnWidth() |
---|
| 94 | , m_pRowHeight() |
---|
| 95 | , m_scalingListFile() |
---|
| 96 | { |
---|
| 97 | m_aidQP = NULL; |
---|
| 98 | m_startOfCodedInterval = NULL; |
---|
| 99 | m_codedPivotValue = NULL; |
---|
| 100 | m_targetPivotValue = NULL; |
---|
| 101 | } |
---|
| 102 | #endif |
---|
| 103 | |
---|
| 104 | TAppEncCfg::~TAppEncCfg() |
---|
| 105 | { |
---|
| 106 | #if SVC_EXTENSION |
---|
| 107 | free(m_pBitstreamFile); |
---|
| 108 | #else |
---|
| 109 | free(m_pchBitstreamFile); |
---|
| 110 | if ( m_aidQP ) |
---|
| 111 | { |
---|
| 112 | delete[] m_aidQP; |
---|
| 113 | } |
---|
| 114 | if ( m_startOfCodedInterval ) |
---|
| 115 | { |
---|
| 116 | delete[] m_startOfCodedInterval; |
---|
| 117 | m_startOfCodedInterval = NULL; |
---|
| 118 | } |
---|
| 119 | if ( m_codedPivotValue ) |
---|
| 120 | { |
---|
| 121 | delete[] m_codedPivotValue; |
---|
| 122 | m_codedPivotValue = NULL; |
---|
| 123 | } |
---|
| 124 | if ( m_targetPivotValue ) |
---|
| 125 | { |
---|
| 126 | delete[] m_targetPivotValue; |
---|
| 127 | m_targetPivotValue = NULL; |
---|
| 128 | } |
---|
| 129 | free(m_pchInputFile); |
---|
| 130 | #endif |
---|
| 131 | #if !SVC_EXTENSION |
---|
| 132 | free(m_pchReconFile); |
---|
| 133 | free(m_pchdQPFile); |
---|
| 134 | #endif |
---|
| 135 | free(m_pColumnWidth); |
---|
| 136 | free(m_pRowHeight); |
---|
| 137 | free(m_scalingListFile); |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | Void TAppEncCfg::create() |
---|
| 141 | { |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | Void TAppEncCfg::destroy() |
---|
| 145 | { |
---|
| 146 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 147 | #if M0457_PREDICTION_INDICATIONS |
---|
| 148 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 149 | { |
---|
| 150 | if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 ) |
---|
| 151 | { |
---|
| 152 | delete [] m_acLayerCfg[layer].m_samplePredRefLayerIds; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 156 | { |
---|
| 157 | if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 ) |
---|
| 158 | { |
---|
| 159 | delete [] m_acLayerCfg[layer].m_motionPredRefLayerIds; |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | #else |
---|
| 163 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 164 | { |
---|
| 165 | if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 ) |
---|
| 166 | { |
---|
| 167 | delete [] m_acLayerCfg[layer].m_refLayerIds; |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | #endif |
---|
| 171 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 172 | { |
---|
| 173 | if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 ) |
---|
| 174 | { |
---|
| 175 | delete [] m_acLayerCfg[layer].m_predLayerIds; |
---|
| 176 | } |
---|
| 177 | } |
---|
| 178 | #endif |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry) //input |
---|
| 182 | { |
---|
| 183 | in>>entry.m_sliceType; |
---|
| 184 | in>>entry.m_POC; |
---|
| 185 | in>>entry.m_QPOffset; |
---|
| 186 | in>>entry.m_QPFactor; |
---|
| 187 | in>>entry.m_tcOffsetDiv2; |
---|
| 188 | in>>entry.m_betaOffsetDiv2; |
---|
| 189 | in>>entry.m_temporalId; |
---|
| 190 | in>>entry.m_numRefPicsActive; |
---|
| 191 | in>>entry.m_numRefPics; |
---|
| 192 | for ( Int i = 0; i < entry.m_numRefPics; i++ ) |
---|
| 193 | { |
---|
| 194 | in>>entry.m_referencePics[i]; |
---|
| 195 | } |
---|
| 196 | in>>entry.m_interRPSPrediction; |
---|
| 197 | #if AUTO_INTER_RPS |
---|
| 198 | if (entry.m_interRPSPrediction==1) |
---|
| 199 | { |
---|
| 200 | in>>entry.m_deltaRPS; |
---|
| 201 | in>>entry.m_numRefIdc; |
---|
| 202 | for ( Int i = 0; i < entry.m_numRefIdc; i++ ) |
---|
| 203 | { |
---|
| 204 | in>>entry.m_refIdc[i]; |
---|
| 205 | } |
---|
| 206 | } |
---|
| 207 | else if (entry.m_interRPSPrediction==2) |
---|
| 208 | { |
---|
| 209 | in>>entry.m_deltaRPS; |
---|
| 210 | } |
---|
| 211 | #else |
---|
| 212 | if (entry.m_interRPSPrediction) |
---|
| 213 | { |
---|
| 214 | in>>entry.m_deltaRPS; |
---|
| 215 | in>>entry.m_numRefIdc; |
---|
| 216 | for ( Int i = 0; i < entry.m_numRefIdc; i++ ) |
---|
| 217 | { |
---|
| 218 | in>>entry.m_refIdc[i]; |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | #endif |
---|
[357] | 222 | #if EXTERNAL_USEDBYCURR_N0082 |
---|
| 223 | if(entry.m_numRefPics>0){ |
---|
| 224 | in>>entry.m_UseExtusedByCurrPic; |
---|
| 225 | if(entry.m_UseExtusedByCurrPic) |
---|
| 226 | { |
---|
| 227 | for ( Int i = 0; i < entry.m_numRefPics; i++ ) |
---|
| 228 | { |
---|
| 229 | in>>entry.m_ExtusedByCurrPic[i]; |
---|
| 230 | } |
---|
| 231 | } |
---|
| 232 | } |
---|
| 233 | #endif |
---|
[313] | 234 | return in; |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | #if SVC_EXTENSION |
---|
| 238 | void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path) |
---|
| 239 | { |
---|
| 240 | size_t pos = path.find_last_of("\\"); |
---|
| 241 | if(pos != std::string::npos) |
---|
| 242 | { |
---|
| 243 | filename.assign(path.begin() + pos + 1, path.end()); |
---|
| 244 | dir.assign(path.begin(), path.begin() + pos + 1); |
---|
| 245 | } |
---|
| 246 | else |
---|
| 247 | { |
---|
| 248 | pos = path.find_last_of("/"); |
---|
| 249 | if(pos != std::string::npos) |
---|
| 250 | { |
---|
| 251 | filename.assign(path.begin() + pos + 1, path.end()); |
---|
| 252 | dir.assign(path.begin(), path.begin() + pos + 1); |
---|
| 253 | } |
---|
| 254 | else |
---|
| 255 | { |
---|
| 256 | filename = path; |
---|
| 257 | dir.assign(""); |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | } |
---|
| 261 | #endif |
---|
| 262 | |
---|
| 263 | static const struct MapStrToProfile { |
---|
| 264 | const Char* str; |
---|
| 265 | Profile::Name value; |
---|
| 266 | } strToProfile[] = { |
---|
| 267 | {"none", Profile::NONE}, |
---|
| 268 | {"main", Profile::MAIN}, |
---|
| 269 | {"main10", Profile::MAIN10}, |
---|
| 270 | {"main-still-picture", Profile::MAINSTILLPICTURE}, |
---|
| 271 | }; |
---|
| 272 | |
---|
| 273 | static const struct MapStrToTier { |
---|
| 274 | const Char* str; |
---|
| 275 | Level::Tier value; |
---|
| 276 | } strToTier[] = { |
---|
| 277 | {"main", Level::MAIN}, |
---|
| 278 | {"high", Level::HIGH}, |
---|
| 279 | }; |
---|
| 280 | |
---|
| 281 | static const struct MapStrToLevel { |
---|
| 282 | const Char* str; |
---|
| 283 | Level::Name value; |
---|
| 284 | } strToLevel[] = { |
---|
| 285 | {"none",Level::NONE}, |
---|
| 286 | {"1", Level::LEVEL1}, |
---|
| 287 | {"2", Level::LEVEL2}, |
---|
| 288 | {"2.1", Level::LEVEL2_1}, |
---|
| 289 | {"3", Level::LEVEL3}, |
---|
| 290 | {"3.1", Level::LEVEL3_1}, |
---|
| 291 | {"4", Level::LEVEL4}, |
---|
| 292 | {"4.1", Level::LEVEL4_1}, |
---|
| 293 | {"5", Level::LEVEL5}, |
---|
| 294 | {"5.1", Level::LEVEL5_1}, |
---|
| 295 | {"5.2", Level::LEVEL5_2}, |
---|
| 296 | {"6", Level::LEVEL6}, |
---|
| 297 | {"6.1", Level::LEVEL6_1}, |
---|
| 298 | {"6.2", Level::LEVEL6_2}, |
---|
| 299 | }; |
---|
| 300 | |
---|
| 301 | template<typename T, typename P> |
---|
| 302 | static istream& readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val) |
---|
| 303 | { |
---|
| 304 | string str; |
---|
| 305 | in >> str; |
---|
| 306 | |
---|
| 307 | for (Int i = 0; i < mapLen; i++) |
---|
| 308 | { |
---|
| 309 | if (str == map[i].str) |
---|
| 310 | { |
---|
| 311 | val = map[i].value; |
---|
| 312 | goto found; |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | /* not found */ |
---|
| 316 | in.setstate(ios::failbit); |
---|
| 317 | found: |
---|
| 318 | return in; |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | static istream& operator>>(istream &in, Profile::Name &profile) |
---|
| 322 | { |
---|
| 323 | return readStrToEnum(strToProfile, sizeof(strToProfile)/sizeof(*strToProfile), in, profile); |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | static istream& operator>>(istream &in, Level::Tier &tier) |
---|
| 327 | { |
---|
| 328 | return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | static istream& operator>>(istream &in, Level::Name &level) |
---|
| 332 | { |
---|
| 333 | return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level); |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | // ==================================================================================================================== |
---|
| 337 | // Public member functions |
---|
| 338 | // ==================================================================================================================== |
---|
| 339 | |
---|
| 340 | /** \param argc number of arguments |
---|
| 341 | \param argv array of arguments |
---|
| 342 | \retval true when success |
---|
| 343 | */ |
---|
| 344 | Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] ) |
---|
| 345 | { |
---|
| 346 | Bool do_help = false; |
---|
| 347 | |
---|
| 348 | #if SVC_EXTENSION |
---|
| 349 | string cfg_LayerCfgFile [MAX_LAYERS]; |
---|
| 350 | string cfg_BitstreamFile; |
---|
| 351 | string* cfg_InputFile [MAX_LAYERS]; |
---|
| 352 | string* cfg_ReconFile [MAX_LAYERS]; |
---|
| 353 | Double* cfg_fQP [MAX_LAYERS]; |
---|
| 354 | |
---|
| 355 | Int* cfg_SourceWidth [MAX_LAYERS]; |
---|
| 356 | Int* cfg_SourceHeight [MAX_LAYERS]; |
---|
| 357 | Int* cfg_FrameRate [MAX_LAYERS]; |
---|
| 358 | Int* cfg_IntraPeriod [MAX_LAYERS]; |
---|
| 359 | Int* cfg_conformanceMode [MAX_LAYERS]; |
---|
| 360 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 361 | #if M0457_PREDICTION_INDICATIONS |
---|
| 362 | Int* cfg_numSamplePredRefLayers [MAX_LAYERS]; |
---|
| 363 | string cfg_samplePredRefLayerIds [MAX_LAYERS]; |
---|
| 364 | string* cfg_samplePredRefLayerIdsPtr[MAX_LAYERS]; |
---|
| 365 | Int* cfg_numMotionPredRefLayers [MAX_LAYERS]; |
---|
| 366 | string cfg_motionPredRefLayerIds [MAX_LAYERS]; |
---|
| 367 | string* cfg_motionPredRefLayerIdsPtr[MAX_LAYERS]; |
---|
| 368 | #else |
---|
| 369 | Int* cfg_numDirectRefLayers [MAX_LAYERS]; |
---|
| 370 | string cfg_refLayerIds [MAX_LAYERS]; |
---|
| 371 | string* cfg_refLayerIdsPtr [MAX_LAYERS]; |
---|
| 372 | #endif |
---|
| 373 | Int* cfg_numActiveRefLayers [MAX_LAYERS]; |
---|
| 374 | string cfg_predLayerIds [MAX_LAYERS]; |
---|
| 375 | string* cfg_predLayerIdsPtr [MAX_LAYERS]; |
---|
| 376 | #endif |
---|
| 377 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 378 | string cfg_scaledRefLayerLeftOffset [MAX_LAYERS]; |
---|
| 379 | string cfg_scaledRefLayerTopOffset [MAX_LAYERS]; |
---|
| 380 | string cfg_scaledRefLayerRightOffset [MAX_LAYERS]; |
---|
| 381 | string cfg_scaledRefLayerBottomOffset [MAX_LAYERS]; |
---|
| 382 | Int* cfg_numScaledRefLayerOffsets[MAX_LAYERS]; |
---|
| 383 | |
---|
| 384 | string* cfg_scaledRefLayerLeftOffsetPtr [MAX_LAYERS]; |
---|
| 385 | string* cfg_scaledRefLayerTopOffsetPtr [MAX_LAYERS]; |
---|
| 386 | string* cfg_scaledRefLayerRightOffsetPtr [MAX_LAYERS]; |
---|
| 387 | string* cfg_scaledRefLayerBottomOffsetPtr [MAX_LAYERS]; |
---|
| 388 | #endif |
---|
| 389 | #if RC_SHVC_HARMONIZATION |
---|
| 390 | Bool* cfg_RCEnableRateControl [MAX_LAYERS]; |
---|
| 391 | Int* cfg_RCTargetBitRate [MAX_LAYERS]; |
---|
| 392 | Bool* cfg_RCKeepHierarchicalBit[MAX_LAYERS]; |
---|
| 393 | Bool* cfg_RCLCULevelRC [MAX_LAYERS]; |
---|
| 394 | Bool* cfg_RCUseLCUSeparateModel[MAX_LAYERS]; |
---|
| 395 | Int* cfg_RCInitialQP [MAX_LAYERS]; |
---|
| 396 | Bool* cfg_RCForceIntraQP [MAX_LAYERS]; |
---|
| 397 | #endif |
---|
| 398 | for(UInt layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 399 | { |
---|
| 400 | cfg_InputFile[layer] = &m_acLayerCfg[layer].m_cInputFile; |
---|
| 401 | cfg_ReconFile[layer] = &m_acLayerCfg[layer].m_cReconFile; |
---|
| 402 | cfg_fQP[layer] = &m_acLayerCfg[layer].m_fQP; |
---|
| 403 | cfg_SourceWidth[layer] = &m_acLayerCfg[layer].m_iSourceWidth; |
---|
| 404 | cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight; |
---|
| 405 | cfg_FrameRate[layer] = &m_acLayerCfg[layer].m_iFrameRate; |
---|
| 406 | cfg_IntraPeriod[layer] = &m_acLayerCfg[layer].m_iIntraPeriod; |
---|
| 407 | cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode; |
---|
| 408 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 409 | #if M0457_PREDICTION_INDICATIONS |
---|
| 410 | cfg_numSamplePredRefLayers [layer] = &m_acLayerCfg[layer].m_numSamplePredRefLayers; |
---|
| 411 | cfg_samplePredRefLayerIdsPtr[layer] = &cfg_samplePredRefLayerIds[layer]; |
---|
| 412 | cfg_numMotionPredRefLayers [layer] = &m_acLayerCfg[layer].m_numMotionPredRefLayers; |
---|
| 413 | cfg_motionPredRefLayerIdsPtr[layer] = &cfg_motionPredRefLayerIds[layer]; |
---|
| 414 | #else |
---|
| 415 | cfg_numDirectRefLayers [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers; |
---|
| 416 | cfg_refLayerIdsPtr [layer] = &cfg_refLayerIds[layer]; |
---|
| 417 | #endif |
---|
| 418 | cfg_numActiveRefLayers [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers; |
---|
| 419 | cfg_predLayerIdsPtr [layer] = &cfg_predLayerIds[layer]; |
---|
| 420 | #endif |
---|
| 421 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 422 | cfg_numScaledRefLayerOffsets [layer] = &m_acLayerCfg[layer].m_numScaledRefLayerOffsets; |
---|
| 423 | for(Int i = 0; i < MAX_LAYERS; i++) |
---|
| 424 | { |
---|
| 425 | cfg_scaledRefLayerLeftOffsetPtr [layer] = &cfg_scaledRefLayerLeftOffset[layer] ; |
---|
| 426 | cfg_scaledRefLayerTopOffsetPtr [layer] = &cfg_scaledRefLayerTopOffset[layer] ; |
---|
| 427 | cfg_scaledRefLayerRightOffsetPtr [layer] = &cfg_scaledRefLayerRightOffset[layer] ; |
---|
| 428 | cfg_scaledRefLayerBottomOffsetPtr[layer] = &cfg_scaledRefLayerBottomOffset[layer]; |
---|
| 429 | } |
---|
| 430 | #endif |
---|
| 431 | #if RC_SHVC_HARMONIZATION |
---|
| 432 | cfg_RCEnableRateControl[layer] = &m_acLayerCfg[layer].m_RCEnableRateControl; |
---|
| 433 | cfg_RCTargetBitRate[layer] = &m_acLayerCfg[layer].m_RCTargetBitrate; |
---|
| 434 | cfg_RCKeepHierarchicalBit[layer] = &m_acLayerCfg[layer].m_RCKeepHierarchicalBit; |
---|
| 435 | cfg_RCLCULevelRC[layer] = &m_acLayerCfg[layer].m_RCLCULevelRC; |
---|
| 436 | cfg_RCUseLCUSeparateModel[layer] = &m_acLayerCfg[layer].m_RCUseLCUSeparateModel; |
---|
| 437 | cfg_RCInitialQP[layer] = &m_acLayerCfg[layer].m_RCInitialQP; |
---|
| 438 | cfg_RCForceIntraQP[layer] = &m_acLayerCfg[layer].m_RCForceIntraQP; |
---|
| 439 | #endif |
---|
| 440 | } |
---|
| 441 | #if AVC_BASE |
---|
| 442 | string cfg_BLInputFile; |
---|
| 443 | #endif |
---|
| 444 | #if AVC_SYNTAX |
---|
| 445 | string cfg_BLSyntaxFile; |
---|
| 446 | #endif |
---|
| 447 | #else |
---|
| 448 | string cfg_InputFile; |
---|
| 449 | string cfg_BitstreamFile; |
---|
| 450 | string cfg_ReconFile; |
---|
| 451 | string cfg_dQPFile; |
---|
| 452 | #endif |
---|
| 453 | string cfg_ColumnWidth; |
---|
| 454 | string cfg_RowHeight; |
---|
| 455 | string cfg_ScalingListFile; |
---|
| 456 | string cfg_startOfCodedInterval; |
---|
| 457 | string cfg_codedPivotValue; |
---|
| 458 | string cfg_targetPivotValue; |
---|
| 459 | po::Options opts; |
---|
| 460 | opts.addOptions() |
---|
| 461 | ("help", do_help, false, "this help text") |
---|
| 462 | ("c", po::parseConfigFile, "configuration file name") |
---|
| 463 | |
---|
| 464 | // File, I/O and source parameters |
---|
| 465 | #if SVC_EXTENSION |
---|
| 466 | ("InputFile%d,-i%d", cfg_InputFile, string(""), MAX_LAYERS, "original YUV input file name for layer %d") |
---|
| 467 | ("ReconFile%d,-o%d", cfg_ReconFile, string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d") |
---|
| 468 | ("LayerConfig%d,-lc%d", cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name") |
---|
| 469 | ("SourceWidth%d,-wdt%d", cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d") |
---|
| 470 | ("SourceHeight%d,-hgt%d", cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d") |
---|
| 471 | ("FrameRate%d,-fr%d", cfg_FrameRate, 0, MAX_LAYERS, "Frame rate for layer %d") |
---|
| 472 | ("LambdaModifier%d,-LM%d", m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d") |
---|
| 473 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 474 | #if M0457_PREDICTION_INDICATIONS |
---|
| 475 | ("NumSamplePredRefLayers%d",cfg_numSamplePredRefLayers, -1, MAX_LAYERS, "Number of sample prediction reference layers") |
---|
| 476 | ("SamplePredRefLayerIds%d", cfg_samplePredRefLayerIdsPtr, string(""), MAX_LAYERS, "sample pred reference layer IDs") |
---|
| 477 | ("NumMotionPredRefLayers%d",cfg_numMotionPredRefLayers, -1, MAX_LAYERS, "Number of motion prediction reference layers") |
---|
| 478 | ("MotionPredRefLayerIds%d", cfg_motionPredRefLayerIdsPtr, string(""), MAX_LAYERS, "motion pred reference layer IDs") |
---|
| 479 | #else |
---|
| 480 | ("NumDirectRefLayers%d", cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers") |
---|
| 481 | ("RefLayerIds%d", cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs") |
---|
| 482 | #endif |
---|
| 483 | ("NumActiveRefLayers%d", cfg_numActiveRefLayers, -1, MAX_LAYERS, "Number of active reference layers") |
---|
| 484 | ("PredLayerIds%d", cfg_predLayerIdsPtr, string(""), MAX_LAYERS, "inter-layer prediction layer IDs") |
---|
| 485 | #endif |
---|
| 486 | ("NumLayers", m_numLayers, 1, "Number of layers to code") |
---|
| 487 | ("ConformanceMode%d", cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping") |
---|
| 488 | ("ScalabilityMask0", m_scalabilityMask[0], 0, "scalability_mask[0] (multiview)") |
---|
| 489 | ("ScalabilityMask1", m_scalabilityMask[1], 1, "scalability_mask[1] (scalable)" ) |
---|
| 490 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "Bitstream output file name") |
---|
| 491 | ("InputBitDepth", m_inputBitDepthY, 8, "Bit-depth of input file") |
---|
| 492 | ("OutputBitDepth", m_outputBitDepthY, 0, "Bit-depth of output file (default:InternalBitDepth)") |
---|
| 493 | ("InternalBitDepth", m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)" |
---|
| 494 | "If different to InputBitDepth, source data will be converted") |
---|
| 495 | ("InputBitDepthC", m_inputBitDepthC, 0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)") |
---|
| 496 | ("OutputBitDepthC", m_outputBitDepthC, 0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)") |
---|
| 497 | ("InternalBitDepthC", m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)") |
---|
| 498 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 499 | ("NumScaledRefLayerOffsets%d", cfg_numScaledRefLayerOffsets, 0, MAX_LAYERS, "Number of scaled offset layer sets ") |
---|
| 500 | ("ScaledRefLayerLeftOffset%d", cfg_scaledRefLayerLeftOffsetPtr, string(""), MAX_LAYERS, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to" |
---|
| 501 | " top-left luma sample of the EL picture, in units of two luma samples") |
---|
| 502 | ("ScaledRefLayerTopOffset%d", cfg_scaledRefLayerTopOffsetPtr, string(""), MAX_LAYERS, "Vertical offset of top-left luma sample of scaled base layer picture with respect to" |
---|
| 503 | " top-left luma sample of the EL picture, in units of two luma samples") |
---|
| 504 | ("ScaledRefLayerRightOffset%d", cfg_scaledRefLayerRightOffsetPtr, string(""), MAX_LAYERS, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to" |
---|
| 505 | " bottom-right luma sample of the EL picture, in units of two luma samples") |
---|
| 506 | ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to" |
---|
| 507 | " bottom-right luma sample of the EL picture, in units of two luma samples") |
---|
| 508 | #endif |
---|
| 509 | #if AVC_BASE |
---|
| 510 | ("AvcBase,-avc", m_avcBaseLayerFlag, 0, "avc_base_layer_flag") |
---|
| 511 | ("InputBLFile,-ibl", cfg_BLInputFile, string(""), "Base layer rec YUV input file name") |
---|
| 512 | #if AVC_SYNTAX |
---|
| 513 | ("InputBLSyntaxFile,-ibs", cfg_BLSyntaxFile, string(""), "Base layer syntax input file name") |
---|
| 514 | #endif |
---|
| 515 | #endif |
---|
| 516 | #if REF_IDX_FRAMEWORK |
---|
| 517 | ("EnableElRapB,-use-rap-b", m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)") |
---|
| 518 | #endif |
---|
| 519 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 520 | ("IlSampleOnlyPred%d", m_ilSampleOnlyPred, 0, MAX_LAYERS, "Set inter_layer_sample_pred_only_flag for all slices") |
---|
| 521 | #endif |
---|
| 522 | #else |
---|
| 523 | ("InputFile,i", cfg_InputFile, string(""), "Original YUV input file name") |
---|
| 524 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "Bitstream output file name") |
---|
| 525 | ("ReconFile,o", cfg_ReconFile, string(""), "Reconstructed YUV output file name") |
---|
| 526 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
---|
| 527 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
---|
| 528 | ("InputBitDepth", m_inputBitDepthY, 8, "Bit-depth of input file") |
---|
| 529 | ("OutputBitDepth", m_outputBitDepthY, 0, "Bit-depth of output file (default:InternalBitDepth)") |
---|
| 530 | ("InternalBitDepth", m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)" |
---|
| 531 | "If different to InputBitDepth, source data will be converted") |
---|
| 532 | ("InputBitDepthC", m_inputBitDepthC, 0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)") |
---|
| 533 | ("OutputBitDepthC", m_outputBitDepthC, 0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)") |
---|
| 534 | ("InternalBitDepthC", m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)") |
---|
| 535 | ("ConformanceMode", m_conformanceMode, 0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance") |
---|
| 536 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "Horizontal source padding for conformance window mode 2") |
---|
| 537 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "Vertical source padding for conformance window mode 2") |
---|
| 538 | ("ConfLeft", m_confLeft, 0, "Left offset for window conformance mode 3") |
---|
| 539 | ("ConfRight", m_confRight, 0, "Right offset for window conformance mode 3") |
---|
| 540 | ("ConfTop", m_confTop, 0, "Top offset for window conformance mode 3") |
---|
| 541 | ("ConfBottom", m_confBottom, 0, "Bottom offset for window conformance mode 3") |
---|
| 542 | ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") |
---|
| 543 | #endif |
---|
| 544 | ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") |
---|
| 545 | ("FramesToBeEncoded,f", m_framesToBeEncoded, 0, "Number of frames to be encoded (default=all)") |
---|
| 546 | |
---|
| 547 | // Profile and level |
---|
| 548 | ("Profile", m_profile, Profile::NONE, "Profile to be used when encoding (Incomplete)") |
---|
| 549 | ("Level", m_level, Level::NONE, "Level limit to be used, eg 5.1 (Incomplete)") |
---|
| 550 | ("Tier", m_levelTier, Level::MAIN, "Tier to use for interpretation of --Level") |
---|
| 551 | |
---|
| 552 | ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive") |
---|
| 553 | ("InterlacedSource", m_interlacedSourceFlag, false, "Indicate that source is interlaced") |
---|
| 554 | ("NonPackedSource", m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing") |
---|
| 555 | ("FrameOnly", m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames") |
---|
| 556 | |
---|
| 557 | // Unit definition parameters |
---|
| 558 | ("MaxCUWidth", m_uiMaxCUWidth, 64u) |
---|
| 559 | ("MaxCUHeight", m_uiMaxCUHeight, 64u) |
---|
| 560 | // todo: remove defaults from MaxCUSize |
---|
| 561 | ("MaxCUSize,s", m_uiMaxCUWidth, 64u, "Maximum CU size") |
---|
| 562 | ("MaxCUSize,s", m_uiMaxCUHeight, 64u, "Maximum CU size") |
---|
| 563 | ("MaxPartitionDepth,h", m_uiMaxCUDepth, 4u, "CU depth") |
---|
| 564 | |
---|
| 565 | ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u, "Maximum TU size in logarithm base 2") |
---|
| 566 | ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u, "Minimum TU size in logarithm base 2") |
---|
| 567 | |
---|
| 568 | ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs") |
---|
| 569 | ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs") |
---|
| 570 | |
---|
| 571 | // Coding structure paramters |
---|
| 572 | #if SVC_EXTENSION |
---|
| 573 | ("IntraPeriod%d,-ip%d", cfg_IntraPeriod, -1, MAX_LAYERS, "intra period in frames for layer %d, (-1: only first frame)") |
---|
| 574 | #else |
---|
| 575 | ("IntraPeriod,-ip", m_iIntraPeriod, -1, "Intra period in frames, (-1: only first frame)") |
---|
| 576 | #endif |
---|
| 577 | ("DecodingRefreshType,-dr", m_iDecodingRefreshType, 0, "Intra refresh type (0:none 1:CRA 2:IDR)") |
---|
| 578 | ("GOPSize,g", m_iGOPSize, 1, "GOP size of temporal structure") |
---|
| 579 | // motion options |
---|
| 580 | ("FastSearch", m_iFastSearch, 1, "0:Full search 1:Diamond 2:PMVFAST") |
---|
| 581 | ("SearchRange,-sr", m_iSearchRange, 96, "Motion search range") |
---|
| 582 | ("BipredSearchRange", m_bipredSearchRange, 4, "Motion search range for bipred refinement") |
---|
| 583 | ("HadamardME", m_bUseHADME, true, "Hadamard ME for fractional-pel") |
---|
| 584 | ("ASR", m_bUseASR, false, "Adaptive motion search range") |
---|
| 585 | |
---|
| 586 | #if SVC_EXTENSION |
---|
| 587 | ("LambdaModifier%d,-LM%d", m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d") |
---|
| 588 | #else |
---|
| 589 | // Mode decision parameters |
---|
| 590 | ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0") |
---|
| 591 | ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( Double )1.0, "Lambda modifier for temporal layer 1") |
---|
| 592 | ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( Double )1.0, "Lambda modifier for temporal layer 2") |
---|
| 593 | ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( Double )1.0, "Lambda modifier for temporal layer 3") |
---|
| 594 | ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( Double )1.0, "Lambda modifier for temporal layer 4") |
---|
| 595 | ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( Double )1.0, "Lambda modifier for temporal layer 5") |
---|
| 596 | ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6") |
---|
| 597 | ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7") |
---|
| 598 | #endif |
---|
| 599 | |
---|
| 600 | /* Quantization parameters */ |
---|
| 601 | #if SVC_EXTENSION |
---|
| 602 | ("QP%d,-q%d", cfg_fQP, 30.0, MAX_LAYERS, "Qp value for layer %d, if value is float, QP is switched once during encoding") |
---|
| 603 | #else |
---|
| 604 | ("QP,q", m_fQP, 30.0, "Qp value, if value is float, QP is switched once during encoding") |
---|
| 605 | #endif |
---|
| 606 | ("DeltaQpRD,-dqr",m_uiDeltaQpRD, 0u, "max dQp offset for slice") |
---|
| 607 | ("MaxDeltaQP,d", m_iMaxDeltaQP, 0, "max dQp offset for block") |
---|
| 608 | ("MaxCuDQPDepth,-dqd", m_iMaxCuDQPDepth, 0, "max depth for a minimum CuDQP") |
---|
| 609 | |
---|
| 610 | ("CbQpOffset,-cbqpofs", m_cbQpOffset, 0, "Chroma Cb QP Offset") |
---|
| 611 | ("CrQpOffset,-crqpofs", m_crQpOffset, 0, "Chroma Cr QP Offset") |
---|
| 612 | |
---|
| 613 | #if ADAPTIVE_QP_SELECTION |
---|
| 614 | ("AdaptiveQpSelection,-aqps", m_bUseAdaptQpSelect, false, "AdaptiveQpSelection") |
---|
| 615 | #endif |
---|
| 616 | |
---|
| 617 | ("AdaptiveQP,-aq", m_bUseAdaptiveQP, false, "QP adaptation based on a psycho-visual model") |
---|
| 618 | ("MaxQPAdaptationRange,-aqr", m_iQPAdaptationRange, 6, "QP adaptation range") |
---|
| 619 | #if !SVC_EXTENSION |
---|
| 620 | ("dQPFile,m", cfg_dQPFile, string(""), "dQP file name") |
---|
| 621 | #endif |
---|
| 622 | ("RDOQ", m_useRDOQ, true ) |
---|
| 623 | ("RDOQTS", m_useRDOQTS, true ) |
---|
| 624 | ("RDpenalty", m_rdPenalty, 0, "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled 1:RD-penalty 2:maximum RD-penalty") |
---|
| 625 | // Entropy coding parameters |
---|
| 626 | ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation") |
---|
| 627 | |
---|
| 628 | // Deblocking filter parameters |
---|
| 629 | ("LoopFilterDisable", m_bLoopFilterDisable, false ) |
---|
| 630 | ("LoopFilterOffsetInPPS", m_loopFilterOffsetInPPS, false ) |
---|
| 631 | ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0 ) |
---|
| 632 | ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0 ) |
---|
| 633 | ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false ) |
---|
| 634 | ("DeblockingFilterMetric", m_DeblockingFilterMetric, false ) |
---|
| 635 | |
---|
| 636 | // Coding tools |
---|
| 637 | ("AMP", m_enableAMP, true, "Enable asymmetric motion partitions") |
---|
| 638 | ("TransformSkip", m_useTransformSkip, false, "Intra transform skipping") |
---|
| 639 | ("TransformSkipFast", m_useTransformSkipFast, false, "Fast intra transform skipping") |
---|
| 640 | ("SAO", m_bUseSAO, true, "Enable Sample Adaptive Offset") |
---|
| 641 | ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "Max number of SAO offset per picture (Default: 2048)") |
---|
| 642 | ("SAOLcuBoundary", m_saoLcuBoundary, false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas") |
---|
| 643 | ("SAOLcuBasedOptimization", m_saoLcuBasedOptimization, true, "0: SAO picture-based optimization, 1: SAO LCU-based optimization ") |
---|
| 644 | ("SliceMode", m_sliceMode, 0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice") |
---|
| 645 | ("SliceArgument", m_sliceArgument, 0, "Depending on SliceMode being:" |
---|
| 646 | "\t1: max number of CTUs per slice" |
---|
| 647 | "\t2: max number of bytes per slice" |
---|
| 648 | "\t3: max number of tiles per slice") |
---|
| 649 | ("SliceSegmentMode", m_sliceSegmentMode, 0, "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice") |
---|
| 650 | ("SliceSegmentArgument", m_sliceSegmentArgument, 0, "Depending on SliceSegmentMode being:" |
---|
| 651 | "\t1: max number of CTUs per slice segment" |
---|
| 652 | "\t2: max number of bytes per slice segment" |
---|
| 653 | "\t3: max number of tiles per slice segment") |
---|
| 654 | ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true) |
---|
| 655 | |
---|
| 656 | ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction") |
---|
| 657 | |
---|
| 658 | ("PCMEnabledFlag", m_usePCM, false) |
---|
| 659 | ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u) |
---|
| 660 | ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u) |
---|
| 661 | ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true) |
---|
| 662 | ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false) |
---|
| 663 | |
---|
| 664 | ("LosslessCuEnabled", m_useLossless, false) |
---|
| 665 | |
---|
| 666 | ("WeightedPredP,-wpP", m_useWeightedPred, false, "Use weighted prediction in P slices") |
---|
| 667 | ("WeightedPredB,-wpB", m_useWeightedBiPred, false, "Use weighted (bidirectional) prediction in B slices") |
---|
| 668 | ("Log2ParallelMergeLevel", m_log2ParallelMergeLevel, 2u, "Parallel merge estimation region") |
---|
| 669 | ("UniformSpacingIdc", m_iUniformSpacingIdr, 0, "Indicates if the column and row boundaries are distributed uniformly") |
---|
| 670 | ("NumTileColumnsMinus1", m_iNumColumnsMinus1, 0, "Number of columns in a picture minus 1") |
---|
| 671 | ("ColumnWidthArray", cfg_ColumnWidth, string(""), "Array containing ColumnWidth values in units of LCU") |
---|
| 672 | ("NumTileRowsMinus1", m_iNumRowsMinus1, 0, "Number of rows in a picture minus 1") |
---|
| 673 | ("RowHeightArray", cfg_RowHeight, string(""), "Array containing RowHeight values in units of LCU") |
---|
| 674 | ("LFCrossTileBoundaryFlag", m_bLFCrossTileBoundaryFlag, true, "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering") |
---|
| 675 | ("WaveFrontSynchro", m_iWaveFrontSynchro, 0, "0: no synchro; 1 synchro with TR; 2 TRR etc") |
---|
| 676 | ("ScalingList", m_useScalingListId, 0, "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile") |
---|
| 677 | ("ScalingListFile", cfg_ScalingListFile, string(""), "Scaling list file name") |
---|
| 678 | ("SignHideFlag,-SBH", m_signHideFlag, 1) |
---|
| 679 | ("MaxNumMergeCand", m_maxNumMergeCand, 5u, "Maximum number of merge candidates") |
---|
| 680 | |
---|
| 681 | /* Misc. */ |
---|
| 682 | ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n" |
---|
| 683 | "\t3: checksum\n" |
---|
| 684 | "\t2: CRC\n" |
---|
| 685 | "\t1: use MD5\n" |
---|
| 686 | "\t0: disable") |
---|
| 687 | ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash") |
---|
| 688 | ("TMVPMode", m_TMVPModeId, 1, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only") |
---|
| 689 | ("FEN", m_bUseFastEnc, false, "fast encoder setting") |
---|
| 690 | ("ECU", m_bUseEarlyCU, false, "Early CU setting") |
---|
| 691 | ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") |
---|
| 692 | ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting") |
---|
| 693 | ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting") |
---|
| 694 | #if FAST_INTRA_SHVC |
---|
| 695 | ("FIS", m_useFastIntraScalable, false, "Fast Intra Decision for Scalable HEVC") |
---|
| 696 | #endif |
---|
| 697 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 698 | #if RC_SHVC_HARMONIZATION |
---|
| 699 | ("RateControl%d", cfg_RCEnableRateControl, false, MAX_LAYERS, "Rate control: enable rate control for layer %d") |
---|
| 700 | ("TargetBitrate%d", cfg_RCTargetBitRate, 0, MAX_LAYERS, "Rate control: target bitrate for layer %d") |
---|
| 701 | ("KeepHierarchicalBit%d", cfg_RCKeepHierarchicalBit, false, MAX_LAYERS, "Rate control: keep hierarchical bit allocation for layer %d") |
---|
| 702 | ("LCULevelRateControl%d", cfg_RCLCULevelRC, true, MAX_LAYERS, "Rate control: LCU level RC") |
---|
| 703 | ("RCLCUSeparateModel%d", cfg_RCUseLCUSeparateModel, true, MAX_LAYERS, "Rate control: Use LCU level separate R-lambda model") |
---|
| 704 | ("InitialQP%d", cfg_RCInitialQP, 0, MAX_LAYERS, "Rate control: initial QP") |
---|
| 705 | ("RCForceIntraQP%d", cfg_RCForceIntraQP, false, MAX_LAYERS, "Rate control: force intra QP to be equal to initial QP") |
---|
| 706 | #else |
---|
| 707 | ( "RateControl", m_RCEnableRateControl, false, "Rate control: enable rate control" ) |
---|
| 708 | ( "TargetBitrate", m_RCTargetBitrate, 0, "Rate control: target bitrate" ) |
---|
| 709 | #if M0036_RC_IMPROVEMENT |
---|
| 710 | ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, 0, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" ) |
---|
| 711 | #else |
---|
| 712 | ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" ) |
---|
| 713 | #endif |
---|
| 714 | ( "LCULevelRateControl", m_RCLCULevelRC, true, "Rate control: true: LCU level RC; false: picture level RC" ) |
---|
| 715 | ( "RCLCUSeparateModel", m_RCUseLCUSeparateModel, true, "Rate control: use LCU level separate R-lambda model" ) |
---|
| 716 | ( "InitialQP", m_RCInitialQP, 0, "Rate control: initial QP" ) |
---|
| 717 | ( "RCForceIntraQP", m_RCForceIntraQP, false, "Rate control: force intra QP to be equal to initial QP" ) |
---|
| 718 | #endif |
---|
| 719 | #else |
---|
| 720 | ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off") |
---|
| 721 | ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate") |
---|
| 722 | ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit") |
---|
| 723 | #endif |
---|
| 724 | |
---|
| 725 | ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS") |
---|
| 726 | ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled") |
---|
| 727 | ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case") |
---|
| 728 | ("StrongIntraSmoothing,-sis", m_useStrongIntraSmoothing, true, "Enable strong intra smoothing for 32x32 blocks") |
---|
| 729 | ("SEIActiveParameterSets", m_activeParameterSetsSEIEnabled, 0, "Enable generation of active parameter sets SEI messages") |
---|
| 730 | ("VuiParametersPresent,-vui", m_vuiParametersPresentFlag, false, "Enable generation of vui_parameters()") |
---|
| 731 | ("AspectRatioInfoPresent", m_aspectRatioInfoPresentFlag, false, "Signals whether aspect_ratio_idc is present") |
---|
| 732 | ("AspectRatioIdc", m_aspectRatioIdc, 0, "aspect_ratio_idc") |
---|
| 733 | ("SarWidth", m_sarWidth, 0, "horizontal size of the sample aspect ratio") |
---|
| 734 | ("SarHeight", m_sarHeight, 0, "vertical size of the sample aspect ratio") |
---|
| 735 | ("OverscanInfoPresent", m_overscanInfoPresentFlag, false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n") |
---|
| 736 | ("OverscanAppropriate", m_overscanAppropriateFlag, false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n") |
---|
| 737 | ("VideoSignalTypePresent", m_videoSignalTypePresentFlag, false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present") |
---|
| 738 | ("VideoFormat", m_videoFormat, 5, "Indicates representation of pictures") |
---|
| 739 | ("VideoFullRange", m_videoFullRangeFlag, false, "Indicates the black level and range of luma and chroma signals") |
---|
| 740 | ("ColourDescriptionPresent", m_colourDescriptionPresentFlag, false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present") |
---|
| 741 | ("ColourPrimaries", m_colourPrimaries, 2, "Indicates chromaticity coordinates of the source primaries") |
---|
| 742 | ("TransferCharateristics", m_transferCharacteristics, 2, "Indicates the opto-electronic transfer characteristics of the source") |
---|
| 743 | ("MatrixCoefficients", m_matrixCoefficients, 2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries") |
---|
| 744 | ("ChromaLocInfoPresent", m_chromaLocInfoPresentFlag, false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present") |
---|
| 745 | ("ChromaSampleLocTypeTopField", m_chromaSampleLocTypeTopField, 0, "Specifies the location of chroma samples for top field") |
---|
| 746 | ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField, 0, "Specifies the location of chroma samples for bottom field") |
---|
| 747 | ("NeutralChromaIndication", m_neutralChromaIndicationFlag, false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)") |
---|
| 748 | ("DefaultDisplayWindowFlag", m_defaultDisplayWindowFlag, false, "Indicates the presence of the Default Window parameters") |
---|
| 749 | ("DefDispWinLeftOffset", m_defDispWinLeftOffset, 0, "Specifies the left offset of the default display window from the conformance window") |
---|
| 750 | ("DefDispWinRightOffset", m_defDispWinRightOffset, 0, "Specifies the right offset of the default display window from the conformance window") |
---|
| 751 | ("DefDispWinTopOffset", m_defDispWinTopOffset, 0, "Specifies the top offset of the default display window from the conformance window") |
---|
| 752 | ("DefDispWinBottomOffset", m_defDispWinBottomOffset, 0, "Specifies the bottom offset of the default display window from the conformance window") |
---|
| 753 | ("FrameFieldInfoPresentFlag", m_frameFieldInfoPresentFlag, false, "Indicates that pic_struct and field coding related values are present in picture timing SEI messages") |
---|
| 754 | ("PocProportionalToTimingFlag", m_pocProportionalToTimingFlag, false, "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS") |
---|
| 755 | ("NumTicksPocDiffOneMinus1", m_numTicksPocDiffOneMinus1, 0, "Number of ticks minus 1 that for a POC difference of one") |
---|
| 756 | ("BitstreamRestriction", m_bitstreamRestrictionFlag, false, "Signals whether bitstream restriction parameters are present") |
---|
| 757 | ("TilesFixedStructure", m_tilesFixedStructureFlag, false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles") |
---|
| 758 | ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false, "Indicates that no samples outside the picture boundaries are used for inter prediction") |
---|
| 759 | ("MaxBytesPerPicDenom", m_maxBytesPerPicDenom, 2, "Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture") |
---|
| 760 | ("MaxBitsPerMinCuDenom", m_maxBitsPerMinCuDenom, 1, "Indicates an upper bound for the number of bits of coding_unit() data") |
---|
| 761 | ("Log2MaxMvLengthHorizontal", m_log2MaxMvLengthHorizontal, 15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units") |
---|
| 762 | ("Log2MaxMvLengthVertical", m_log2MaxMvLengthVertical, 15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units") |
---|
| 763 | ("SEIRecoveryPoint", m_recoveryPointSEIEnabled, 0, "Control generation of recovery point SEI messages") |
---|
| 764 | ("SEIBufferingPeriod", m_bufferingPeriodSEIEnabled, 0, "Control generation of buffering period SEI messages") |
---|
| 765 | ("SEIPictureTiming", m_pictureTimingSEIEnabled, 0, "Control generation of picture timing SEI messages") |
---|
| 766 | ("SEIToneMappingInfo", m_toneMappingInfoSEIEnabled, false, "Control generation of Tone Mapping SEI messages") |
---|
| 767 | ("SEIToneMapId", m_toneMapId, 0, "Specifies Id of Tone Mapping SEI message for a given session") |
---|
| 768 | ("SEIToneMapCancelFlag", m_toneMapCancelFlag, false, "Indicates that Tone Mapping SEI message cancels the persistance or follows") |
---|
| 769 | ("SEIToneMapPersistenceFlag", m_toneMapPersistenceFlag, true, "Specifies the persistence of the Tone Mapping SEI message") |
---|
| 770 | ("SEIToneMapCodedDataBitDepth", m_toneMapCodedDataBitDepth, 8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages") |
---|
| 771 | ("SEIToneMapTargetBitDepth", m_toneMapTargetBitDepth, 8, "Specifies Output BitDepth of Tome mapping function") |
---|
| 772 | ("SEIToneMapModelId", m_toneMapModelId, 0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n" |
---|
| 773 | "\t0: linear mapping with clipping\n" |
---|
| 774 | "\t1: sigmoidal mapping\n" |
---|
| 775 | "\t2: user-defined table mapping\n" |
---|
| 776 | "\t3: piece-wise linear mapping\n" |
---|
| 777 | "\t4: luminance dynamic range information ") |
---|
| 778 | ("SEIToneMapMinValue", m_toneMapMinValue, 0, "Specifies the minimum value in mode 0") |
---|
| 779 | ("SEIToneMapMaxValue", m_toneMapMaxValue, 1023, "Specifies the maxmum value in mode 0") |
---|
| 780 | ("SEIToneMapSigmoidMidpoint", m_sigmoidMidpoint, 512, "Specifies the centre point in mode 1") |
---|
| 781 | ("SEIToneMapSigmoidWidth", m_sigmoidWidth, 960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1") |
---|
| 782 | ("SEIToneMapStartOfCodedInterval", cfg_startOfCodedInterval, string(""), "Array of user-defined mapping table") |
---|
| 783 | ("SEIToneMapNumPivots", m_numPivots, 0, "Specifies the number of pivot points in mode 3") |
---|
| 784 | ("SEIToneMapCodedPivotValue", cfg_codedPivotValue, string(""), "Array of pivot point") |
---|
| 785 | ("SEIToneMapTargetPivotValue", cfg_targetPivotValue, string(""), "Array of pivot point") |
---|
| 786 | ("SEIToneMapCameraIsoSpeedIdc", m_cameraIsoSpeedIdc, 0, "Indicates the camera ISO speed for daylight illumination") |
---|
| 787 | ("SEIToneMapCameraIsoSpeedValue", m_cameraIsoSpeedValue, 400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO") |
---|
| 788 | ("SEIToneMapExposureCompensationValueSignFlag", m_exposureCompensationValueSignFlag, 0, "Specifies the sign of ExposureCompensationValue") |
---|
| 789 | ("SEIToneMapExposureCompensationValueNumerator", m_exposureCompensationValueNumerator, 0, "Specifies the numerator of ExposureCompensationValue") |
---|
| 790 | ("SEIToneMapExposureCompensationValueDenomIdc", m_exposureCompensationValueDenomIdc, 2, "Specifies the denominator of ExposureCompensationValue") |
---|
| 791 | ("SEIToneMapRefScreenLuminanceWhite", m_refScreenLuminanceWhite, 350, "Specifies reference screen brightness setting in units of candela per square metre") |
---|
| 792 | ("SEIToneMapExtendedRangeWhiteLevel", m_extendedRangeWhiteLevel, 800, "Indicates the luminance dynamic range") |
---|
| 793 | ("SEIToneMapNominalBlackLevelLumaCodeValue", m_nominalBlackLevelLumaCodeValue, 16, "Specifies luma sample value of the nominal black level assigned decoded pictures") |
---|
| 794 | ("SEIToneMapNominalWhiteLevelLumaCodeValue", m_nominalWhiteLevelLumaCodeValue, 235, "Specifies luma sample value of the nominal white level assigned decoded pictures") |
---|
| 795 | ("SEIToneMapExtendedWhiteLevelLumaCodeValue", m_extendedWhiteLevelLumaCodeValue, 300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures") |
---|
| 796 | ("SEIFramePacking", m_framePackingSEIEnabled, 0, "Control generation of frame packing SEI messages") |
---|
| 797 | ("SEIFramePackingType", m_framePackingSEIType, 0, "Define frame packing arrangement\n" |
---|
| 798 | "\t0: checkerboard - pixels alternatively represent either frames\n" |
---|
| 799 | "\t1: column alternation - frames are interlaced by column\n" |
---|
| 800 | "\t2: row alternation - frames are interlaced by row\n" |
---|
| 801 | "\t3: side by side - frames are displayed horizontally\n" |
---|
| 802 | "\t4: top bottom - frames are displayed vertically\n" |
---|
| 803 | "\t5: frame alternation - one frame is alternated with the other") |
---|
| 804 | ("SEIFramePackingId", m_framePackingSEIId, 0, "Id of frame packing SEI message for a given session") |
---|
| 805 | ("SEIFramePackingQuincunx", m_framePackingSEIQuincunx, 0, "Indicate the presence of a Quincunx type video frame") |
---|
| 806 | ("SEIFramePackingInterpretation", m_framePackingSEIInterpretation, 0, "Indicate the interpretation of the frame pair\n" |
---|
| 807 | "\t0: unspecified\n" |
---|
| 808 | "\t1: stereo pair, frame0 represents left view\n" |
---|
| 809 | "\t2: stereo pair, frame0 represents right view") |
---|
| 810 | ("SEIDisplayOrientation", m_displayOrientationSEIAngle, 0, "Control generation of display orientation SEI messages\n" |
---|
| 811 | "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n" |
---|
| 812 | "\t0: disable") |
---|
| 813 | ("SEITemporalLevel0Index", m_temporalLevel0IndexSEIEnabled, 0, "Control generation of temporal level 0 index SEI messages") |
---|
| 814 | ("SEIGradualDecodingRefreshInfo", m_gradualDecodingRefreshInfoEnabled, 0, "Control generation of gradual decoding refresh information SEI message") |
---|
| 815 | ("SEIDecodingUnitInfo", m_decodingUnitInfoSEIEnabled, 0, "Control generation of decoding unit information SEI message.") |
---|
| 816 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 817 | ("SEILayersPresent", m_layersPresentSEIEnabled, 0, "Control generation of layers present SEI message") |
---|
| 818 | #endif |
---|
| 819 | ("SEISOPDescription", m_SOPDescriptionSEIEnabled, 0, "Control generation of SOP description SEI messages") |
---|
| 820 | ("SEIScalableNesting", m_scalableNestingSEIEnabled, 0, "Control generation of scalable nesting SEI messages") |
---|
| 821 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 822 | ("AdaptiveResolutionChange", m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)") |
---|
| 823 | #endif |
---|
| 824 | ; |
---|
| 825 | |
---|
| 826 | for(Int i=1; i<MAX_GOP+1; i++) { |
---|
| 827 | std::ostringstream cOSS; |
---|
| 828 | cOSS<<"Frame"<<i; |
---|
| 829 | opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry()); |
---|
| 830 | } |
---|
[334] | 831 | #if FINAL_RPL_CHANGE_N0082 |
---|
| 832 | for(Int i=1; i<MAX_GOP+1; i++) { |
---|
| 833 | std::ostringstream cOSS; |
---|
| 834 | cOSS<<"FrameEL"<<i; |
---|
| 835 | opts.addOptions()(cOSS.str(), m_acLayerCfg[1].m_GOPListLayer[i-1], GOPEntry()); |
---|
| 836 | } |
---|
| 837 | #endif |
---|
[313] | 838 | po::setDefaults(opts); |
---|
| 839 | const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv); |
---|
| 840 | |
---|
| 841 | for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++) |
---|
| 842 | { |
---|
| 843 | fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it); |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | if (argc == 1 || do_help) |
---|
| 847 | { |
---|
| 848 | /* argc == 1: no options have been specified */ |
---|
| 849 | po::doHelp(cout, opts); |
---|
| 850 | return false; |
---|
| 851 | } |
---|
| 852 | |
---|
| 853 | /* |
---|
| 854 | * Set any derived parameters |
---|
| 855 | */ |
---|
| 856 | /* convert std::string to c string for compatability */ |
---|
| 857 | #if SVC_EXTENSION |
---|
| 858 | #if AVC_BASE |
---|
| 859 | if( m_avcBaseLayerFlag ) |
---|
| 860 | { |
---|
| 861 | *cfg_InputFile[0] = cfg_BLInputFile; |
---|
| 862 | } |
---|
| 863 | #endif |
---|
| 864 | m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
| 865 | #if AVC_SYNTAX |
---|
| 866 | m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str()); |
---|
| 867 | #endif |
---|
| 868 | #else |
---|
| 869 | m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str()); |
---|
| 870 | m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
| 871 | m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str()); |
---|
| 872 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
---|
| 873 | #endif |
---|
| 874 | |
---|
| 875 | Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str()); |
---|
| 876 | Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str()); |
---|
| 877 | if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 ) |
---|
| 878 | { |
---|
| 879 | char *columnWidth; |
---|
| 880 | int i=0; |
---|
| 881 | m_pColumnWidth = new UInt[m_iNumColumnsMinus1]; |
---|
| 882 | columnWidth = strtok(pColumnWidth, " ,-"); |
---|
| 883 | while(columnWidth!=NULL) |
---|
| 884 | { |
---|
| 885 | if( i>=m_iNumColumnsMinus1 ) |
---|
| 886 | { |
---|
| 887 | printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
| 888 | exit( EXIT_FAILURE ); |
---|
| 889 | } |
---|
| 890 | *( m_pColumnWidth + i ) = atoi( columnWidth ); |
---|
| 891 | columnWidth = strtok(NULL, " ,-"); |
---|
| 892 | i++; |
---|
| 893 | } |
---|
| 894 | if( i<m_iNumColumnsMinus1 ) |
---|
| 895 | { |
---|
| 896 | printf( "The width of some columns is not defined.\n" ); |
---|
| 897 | exit( EXIT_FAILURE ); |
---|
| 898 | } |
---|
| 899 | } |
---|
| 900 | else |
---|
| 901 | { |
---|
| 902 | m_pColumnWidth = NULL; |
---|
| 903 | } |
---|
| 904 | |
---|
| 905 | if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 ) |
---|
| 906 | { |
---|
| 907 | char *rowHeight; |
---|
| 908 | int i=0; |
---|
| 909 | m_pRowHeight = new UInt[m_iNumRowsMinus1]; |
---|
| 910 | rowHeight = strtok(pRowHeight, " ,-"); |
---|
| 911 | while(rowHeight!=NULL) |
---|
| 912 | { |
---|
| 913 | if( i>=m_iNumRowsMinus1 ) |
---|
| 914 | { |
---|
| 915 | printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" ); |
---|
| 916 | exit( EXIT_FAILURE ); |
---|
| 917 | } |
---|
| 918 | *( m_pRowHeight + i ) = atoi( rowHeight ); |
---|
| 919 | rowHeight = strtok(NULL, " ,-"); |
---|
| 920 | i++; |
---|
| 921 | } |
---|
| 922 | if( i<m_iNumRowsMinus1 ) |
---|
| 923 | { |
---|
| 924 | printf( "The height of some rows is not defined.\n" ); |
---|
| 925 | exit( EXIT_FAILURE ); |
---|
| 926 | } |
---|
| 927 | } |
---|
| 928 | else |
---|
| 929 | { |
---|
| 930 | m_pRowHeight = NULL; |
---|
| 931 | } |
---|
| 932 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 933 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 934 | { |
---|
| 935 | // If number of scaled ref. layer offsets is non-zero, at least one of the offsets should be specified |
---|
| 936 | if(m_acLayerCfg[layer].m_numScaledRefLayerOffsets) |
---|
| 937 | { |
---|
| 938 | assert( strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(), "") || |
---|
| 939 | strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(), "") || |
---|
| 940 | strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(), "") || |
---|
| 941 | strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"") |
---|
| 942 | ); |
---|
| 943 | } |
---|
| 944 | |
---|
| 945 | Int *tempArray = NULL; // Contain the value |
---|
| 946 | // Left offset // |
---|
| 947 | if(strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(), "")) |
---|
| 948 | { |
---|
| 949 | cfgStringToArray( &tempArray, cfg_scaledRefLayerLeftOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "LeftOffset"); |
---|
| 950 | if(tempArray) |
---|
| 951 | { |
---|
| 952 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
| 953 | { |
---|
| 954 | m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i] = tempArray[i]; |
---|
| 955 | } |
---|
| 956 | delete [] tempArray; tempArray = NULL; |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | |
---|
| 960 | // Top offset // |
---|
| 961 | if(strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(), "")) |
---|
| 962 | { |
---|
| 963 | cfgStringToArray( &tempArray, cfg_scaledRefLayerTopOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "TopOffset"); |
---|
| 964 | if(tempArray) |
---|
| 965 | { |
---|
| 966 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
| 967 | { |
---|
| 968 | m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i] = tempArray[i]; |
---|
| 969 | } |
---|
| 970 | delete [] tempArray; tempArray = NULL; |
---|
| 971 | } |
---|
| 972 | } |
---|
| 973 | |
---|
| 974 | // Right offset // |
---|
| 975 | if(strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(), "")) |
---|
| 976 | { |
---|
| 977 | cfgStringToArray( &tempArray, cfg_scaledRefLayerRightOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RightOffset"); |
---|
| 978 | if(tempArray) |
---|
| 979 | { |
---|
| 980 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
| 981 | { |
---|
| 982 | m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i] = tempArray[i]; |
---|
| 983 | } |
---|
| 984 | delete [] tempArray; tempArray = NULL; |
---|
| 985 | } |
---|
| 986 | } |
---|
| 987 | |
---|
| 988 | // Bottom offset // |
---|
| 989 | if(strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(), "")) |
---|
| 990 | { |
---|
| 991 | cfgStringToArray( &tempArray, cfg_scaledRefLayerBottomOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "BottomOffset"); |
---|
| 992 | if(tempArray) |
---|
| 993 | { |
---|
| 994 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
| 995 | { |
---|
| 996 | m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i] = tempArray[i]; |
---|
| 997 | } |
---|
| 998 | delete [] tempArray; tempArray = NULL; |
---|
| 999 | } |
---|
| 1000 | } |
---|
| 1001 | } |
---|
| 1002 | #endif |
---|
| 1003 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1004 | #if M0457_PREDICTION_INDICATIONS |
---|
| 1005 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 1006 | { |
---|
| 1007 | Char* pSamplePredRefLayerIds = cfg_samplePredRefLayerIds[layer].empty() ? NULL: strdup(cfg_samplePredRefLayerIds[layer].c_str()); |
---|
| 1008 | if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 ) |
---|
| 1009 | { |
---|
| 1010 | char *samplePredRefLayerId; |
---|
| 1011 | int i=0; |
---|
| 1012 | m_acLayerCfg[layer].m_samplePredRefLayerIds = new Int[m_acLayerCfg[layer].m_numSamplePredRefLayers]; |
---|
| 1013 | samplePredRefLayerId = strtok(pSamplePredRefLayerIds, " ,-"); |
---|
| 1014 | while(samplePredRefLayerId != NULL) |
---|
| 1015 | { |
---|
| 1016 | if( i >= m_acLayerCfg[layer].m_numSamplePredRefLayers ) |
---|
| 1017 | { |
---|
| 1018 | printf( "NumSamplePredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
| 1019 | exit( EXIT_FAILURE ); |
---|
| 1020 | } |
---|
| 1021 | *( m_acLayerCfg[layer].m_samplePredRefLayerIds + i ) = atoi( samplePredRefLayerId ); |
---|
| 1022 | samplePredRefLayerId = strtok(NULL, " ,-"); |
---|
| 1023 | i++; |
---|
| 1024 | } |
---|
| 1025 | if( i < m_acLayerCfg[layer].m_numSamplePredRefLayers ) |
---|
| 1026 | { |
---|
| 1027 | printf( "NumSamplePredRefLayers: The width of some columns is not defined.\n" ); |
---|
| 1028 | exit( EXIT_FAILURE ); |
---|
| 1029 | } |
---|
| 1030 | } |
---|
| 1031 | else |
---|
| 1032 | { |
---|
| 1033 | m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL; |
---|
| 1034 | } |
---|
| 1035 | } |
---|
| 1036 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 1037 | { |
---|
| 1038 | Char* pMotionPredRefLayerIds = cfg_motionPredRefLayerIds[layer].empty() ? NULL: strdup(cfg_motionPredRefLayerIds[layer].c_str()); |
---|
| 1039 | if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 ) |
---|
| 1040 | { |
---|
| 1041 | char *motionPredRefLayerId; |
---|
| 1042 | int i=0; |
---|
| 1043 | m_acLayerCfg[layer].m_motionPredRefLayerIds = new Int[m_acLayerCfg[layer].m_numMotionPredRefLayers]; |
---|
| 1044 | motionPredRefLayerId = strtok(pMotionPredRefLayerIds, " ,-"); |
---|
| 1045 | while(motionPredRefLayerId != NULL) |
---|
| 1046 | { |
---|
| 1047 | if( i >= m_acLayerCfg[layer].m_numMotionPredRefLayers ) |
---|
| 1048 | { |
---|
| 1049 | printf( "NumMotionPredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
| 1050 | exit( EXIT_FAILURE ); |
---|
| 1051 | } |
---|
| 1052 | *( m_acLayerCfg[layer].m_motionPredRefLayerIds + i ) = atoi( motionPredRefLayerId ); |
---|
| 1053 | motionPredRefLayerId = strtok(NULL, " ,-"); |
---|
| 1054 | i++; |
---|
| 1055 | } |
---|
| 1056 | if( i < m_acLayerCfg[layer].m_numMotionPredRefLayers ) |
---|
| 1057 | { |
---|
| 1058 | printf( "NumMotionPredRefLayers: The width of some columns is not defined.\n" ); |
---|
| 1059 | exit( EXIT_FAILURE ); |
---|
| 1060 | } |
---|
| 1061 | } |
---|
| 1062 | else |
---|
| 1063 | { |
---|
| 1064 | m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL; |
---|
| 1065 | } |
---|
| 1066 | } |
---|
| 1067 | #else |
---|
| 1068 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 1069 | { |
---|
| 1070 | Char* pRefLayerIds = cfg_refLayerIds[layer].empty() ? NULL: strdup(cfg_refLayerIds[layer].c_str()); |
---|
| 1071 | if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 ) |
---|
| 1072 | { |
---|
| 1073 | char *refLayerId; |
---|
| 1074 | int i=0; |
---|
| 1075 | m_acLayerCfg[layer].m_refLayerIds = new Int[m_acLayerCfg[layer].m_numDirectRefLayers]; |
---|
| 1076 | refLayerId = strtok(pRefLayerIds, " ,-"); |
---|
| 1077 | while(refLayerId != NULL) |
---|
| 1078 | { |
---|
| 1079 | if( i >= m_acLayerCfg[layer].m_numDirectRefLayers ) |
---|
| 1080 | { |
---|
| 1081 | printf( "NumDirectRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
| 1082 | exit( EXIT_FAILURE ); |
---|
| 1083 | } |
---|
| 1084 | *( m_acLayerCfg[layer].m_refLayerIds + i ) = atoi( refLayerId ); |
---|
| 1085 | refLayerId = strtok(NULL, " ,-"); |
---|
| 1086 | i++; |
---|
| 1087 | } |
---|
| 1088 | if( i < m_acLayerCfg[layer].m_numDirectRefLayers ) |
---|
| 1089 | { |
---|
| 1090 | printf( "NumDirectRefLayers: The width of some columns is not defined.\n" ); |
---|
| 1091 | exit( EXIT_FAILURE ); |
---|
| 1092 | } |
---|
| 1093 | } |
---|
| 1094 | else |
---|
| 1095 | { |
---|
| 1096 | m_acLayerCfg[layer].m_refLayerIds = NULL; |
---|
| 1097 | } |
---|
| 1098 | } |
---|
| 1099 | #endif |
---|
| 1100 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 1101 | { |
---|
| 1102 | Char* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str()); |
---|
| 1103 | if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 ) |
---|
| 1104 | { |
---|
| 1105 | char *refLayerId; |
---|
| 1106 | int i=0; |
---|
| 1107 | m_acLayerCfg[layer].m_predLayerIds = new Int[m_acLayerCfg[layer].m_numActiveRefLayers]; |
---|
| 1108 | refLayerId = strtok(pPredLayerIds, " ,-"); |
---|
| 1109 | while(refLayerId != NULL) |
---|
| 1110 | { |
---|
| 1111 | if( i >= m_acLayerCfg[layer].m_numActiveRefLayers ) |
---|
| 1112 | { |
---|
| 1113 | printf( "NumActiveRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
| 1114 | exit( EXIT_FAILURE ); |
---|
| 1115 | } |
---|
| 1116 | *( m_acLayerCfg[layer].m_predLayerIds + i ) = atoi( refLayerId ); |
---|
| 1117 | refLayerId = strtok(NULL, " ,-"); |
---|
| 1118 | i++; |
---|
| 1119 | } |
---|
| 1120 | if( i < m_acLayerCfg[layer].m_numActiveRefLayers ) |
---|
| 1121 | { |
---|
| 1122 | printf( "NumActiveRefLayers: The width of some columns is not defined.\n" ); |
---|
| 1123 | exit( EXIT_FAILURE ); |
---|
| 1124 | } |
---|
| 1125 | } |
---|
| 1126 | else |
---|
| 1127 | { |
---|
| 1128 | m_acLayerCfg[layer].m_predLayerIds = NULL; |
---|
| 1129 | } |
---|
| 1130 | } |
---|
| 1131 | #endif |
---|
| 1132 | m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str()); |
---|
| 1133 | |
---|
| 1134 | /* rules for input, output and internal bitdepths as per help text */ |
---|
| 1135 | if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; } |
---|
| 1136 | if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; } |
---|
| 1137 | if (!m_inputBitDepthC) { m_inputBitDepthC = m_inputBitDepthY; } |
---|
| 1138 | if (!m_outputBitDepthY) { m_outputBitDepthY = m_internalBitDepthY; } |
---|
| 1139 | if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; } |
---|
| 1140 | |
---|
| 1141 | #if !SVC_EXTENSION |
---|
| 1142 | // TODO:ChromaFmt assumes 4:2:0 below |
---|
| 1143 | switch (m_conformanceMode) |
---|
| 1144 | { |
---|
| 1145 | case 0: |
---|
| 1146 | { |
---|
| 1147 | // no conformance or padding |
---|
| 1148 | m_confLeft = m_confRight = m_confTop = m_confBottom = 0; |
---|
| 1149 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
| 1150 | break; |
---|
| 1151 | } |
---|
| 1152 | case 1: |
---|
| 1153 | { |
---|
| 1154 | // automatic padding to minimum CU size |
---|
| 1155 | Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); |
---|
| 1156 | if (m_iSourceWidth % minCuSize) |
---|
| 1157 | { |
---|
| 1158 | m_aiPad[0] = m_confRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth; |
---|
| 1159 | m_iSourceWidth += m_confRight; |
---|
| 1160 | } |
---|
| 1161 | if (m_iSourceHeight % minCuSize) |
---|
| 1162 | { |
---|
| 1163 | m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; |
---|
| 1164 | m_iSourceHeight += m_confBottom; |
---|
| 1165 | } |
---|
| 1166 | if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0) |
---|
| 1167 | { |
---|
| 1168 | fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n"); |
---|
| 1169 | exit(EXIT_FAILURE); |
---|
| 1170 | } |
---|
| 1171 | if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0) |
---|
| 1172 | { |
---|
| 1173 | fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n"); |
---|
| 1174 | exit(EXIT_FAILURE); |
---|
| 1175 | } |
---|
| 1176 | break; |
---|
| 1177 | } |
---|
| 1178 | case 2: |
---|
| 1179 | { |
---|
| 1180 | //padding |
---|
| 1181 | m_iSourceWidth += m_aiPad[0]; |
---|
| 1182 | m_iSourceHeight += m_aiPad[1]; |
---|
| 1183 | m_confRight = m_aiPad[0]; |
---|
| 1184 | m_confBottom = m_aiPad[1]; |
---|
| 1185 | break; |
---|
| 1186 | } |
---|
| 1187 | case 3: |
---|
| 1188 | { |
---|
| 1189 | // conformance |
---|
| 1190 | if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0)) |
---|
| 1191 | { |
---|
| 1192 | fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n"); |
---|
| 1193 | } |
---|
| 1194 | if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0)) |
---|
| 1195 | { |
---|
| 1196 | fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n"); |
---|
| 1197 | } |
---|
| 1198 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
| 1199 | break; |
---|
| 1200 | } |
---|
| 1201 | } |
---|
| 1202 | |
---|
| 1203 | // allocate slice-based dQP values |
---|
| 1204 | m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ]; |
---|
| 1205 | ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) ); |
---|
| 1206 | |
---|
| 1207 | // handling of floating-point QP values |
---|
| 1208 | // if QP is not integer, sequence is split into two sections having QP and QP+1 |
---|
| 1209 | m_iQP = (Int)( m_fQP ); |
---|
| 1210 | if ( m_iQP < m_fQP ) |
---|
| 1211 | { |
---|
| 1212 | Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP - m_iQP)*m_framesToBeEncoded + 0.5 ); |
---|
| 1213 | |
---|
| 1214 | iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize; |
---|
| 1215 | for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ ) |
---|
| 1216 | { |
---|
| 1217 | m_aidQP[i] = 1; |
---|
| 1218 | } |
---|
| 1219 | } |
---|
| 1220 | |
---|
| 1221 | // reading external dQP description from file |
---|
| 1222 | if ( m_pchdQPFile ) |
---|
| 1223 | { |
---|
| 1224 | FILE* fpt=fopen( m_pchdQPFile, "r" ); |
---|
| 1225 | if ( fpt ) |
---|
| 1226 | { |
---|
| 1227 | Int iValue; |
---|
| 1228 | Int iPOC = 0; |
---|
| 1229 | while ( iPOC < m_framesToBeEncoded ) |
---|
| 1230 | { |
---|
| 1231 | if ( fscanf(fpt, "%d", &iValue ) == EOF ) break; |
---|
| 1232 | m_aidQP[ iPOC ] = iValue; |
---|
| 1233 | iPOC++; |
---|
| 1234 | } |
---|
| 1235 | fclose(fpt); |
---|
| 1236 | } |
---|
| 1237 | } |
---|
| 1238 | m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; |
---|
| 1239 | #endif |
---|
| 1240 | if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag ) |
---|
| 1241 | { |
---|
| 1242 | Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str()); |
---|
| 1243 | Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str()); |
---|
| 1244 | Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str()); |
---|
| 1245 | if( m_toneMapModelId == 2 && pcStartOfCodedInterval ) |
---|
| 1246 | { |
---|
| 1247 | char *startOfCodedInterval; |
---|
| 1248 | UInt num = 1u<< m_toneMapTargetBitDepth; |
---|
| 1249 | m_startOfCodedInterval = new Int[num]; |
---|
| 1250 | ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num ); |
---|
| 1251 | startOfCodedInterval = strtok(pcStartOfCodedInterval, " ."); |
---|
| 1252 | int i = 0; |
---|
| 1253 | while( startOfCodedInterval && ( i < num ) ) |
---|
| 1254 | { |
---|
| 1255 | m_startOfCodedInterval[i] = atoi( startOfCodedInterval ); |
---|
| 1256 | startOfCodedInterval = strtok(NULL, " ."); |
---|
| 1257 | i++; |
---|
| 1258 | } |
---|
| 1259 | } |
---|
| 1260 | else |
---|
| 1261 | { |
---|
| 1262 | m_startOfCodedInterval = NULL; |
---|
| 1263 | } |
---|
| 1264 | if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) ) |
---|
| 1265 | { |
---|
| 1266 | if( pcCodedPivotValue && pcTargetPivotValue ) |
---|
| 1267 | { |
---|
| 1268 | char *codedPivotValue; |
---|
| 1269 | char *targetPivotValue; |
---|
| 1270 | m_codedPivotValue = new Int[m_numPivots]; |
---|
| 1271 | m_targetPivotValue = new Int[m_numPivots]; |
---|
| 1272 | ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) ); |
---|
| 1273 | ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) ); |
---|
| 1274 | codedPivotValue = strtok(pcCodedPivotValue, " ."); |
---|
| 1275 | int i=0; |
---|
| 1276 | while(codedPivotValue&&i<m_numPivots) |
---|
| 1277 | { |
---|
| 1278 | m_codedPivotValue[i] = atoi( codedPivotValue ); |
---|
| 1279 | codedPivotValue = strtok(NULL, " ."); |
---|
| 1280 | i++; |
---|
| 1281 | } |
---|
| 1282 | i=0; |
---|
| 1283 | targetPivotValue = strtok(pcTargetPivotValue, " ."); |
---|
| 1284 | while(targetPivotValue&&i<m_numPivots) |
---|
| 1285 | { |
---|
| 1286 | m_targetPivotValue[i]= atoi( targetPivotValue ); |
---|
| 1287 | targetPivotValue = strtok(NULL, " ."); |
---|
| 1288 | i++; |
---|
| 1289 | } |
---|
| 1290 | } |
---|
| 1291 | } |
---|
| 1292 | else |
---|
| 1293 | { |
---|
| 1294 | m_codedPivotValue = NULL; |
---|
| 1295 | m_targetPivotValue = NULL; |
---|
| 1296 | } |
---|
| 1297 | } |
---|
| 1298 | // check validity of input parameters |
---|
| 1299 | xCheckParameter(); |
---|
| 1300 | |
---|
| 1301 | // set global varibles |
---|
| 1302 | xSetGlobal(); |
---|
| 1303 | |
---|
| 1304 | // print-out parameters |
---|
| 1305 | xPrintParameter(); |
---|
| 1306 | |
---|
| 1307 | return true; |
---|
| 1308 | } |
---|
| 1309 | // ==================================================================================================================== |
---|
| 1310 | // Private member functions |
---|
| 1311 | // ==================================================================================================================== |
---|
| 1312 | |
---|
| 1313 | Bool confirmPara(Bool bflag, const Char* message); |
---|
| 1314 | |
---|
| 1315 | Void TAppEncCfg::xCheckParameter() |
---|
| 1316 | { |
---|
| 1317 | if (!m_decodedPictureHashSEIEnabled) |
---|
| 1318 | { |
---|
| 1319 | fprintf(stderr, "******************************************************************\n"); |
---|
| 1320 | fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n"); |
---|
| 1321 | fprintf(stderr, "** Automatic verification of decoded pictures by a **\n"); |
---|
| 1322 | fprintf(stderr, "** decoder requires this option to be enabled. **\n"); |
---|
| 1323 | fprintf(stderr, "******************************************************************\n"); |
---|
| 1324 | } |
---|
| 1325 | if( m_profile==Profile::NONE ) |
---|
| 1326 | { |
---|
| 1327 | fprintf(stderr, "***************************************************************************\n"); |
---|
| 1328 | fprintf(stderr, "** WARNING: For conforming bitstreams a valid Profile value must be set! **\n"); |
---|
| 1329 | fprintf(stderr, "***************************************************************************\n"); |
---|
| 1330 | } |
---|
| 1331 | if( m_level==Level::NONE ) |
---|
| 1332 | { |
---|
| 1333 | fprintf(stderr, "***************************************************************************\n"); |
---|
| 1334 | fprintf(stderr, "** WARNING: For conforming bitstreams a valid Level value must be set! **\n"); |
---|
| 1335 | fprintf(stderr, "***************************************************************************\n"); |
---|
| 1336 | } |
---|
| 1337 | |
---|
| 1338 | Bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
| 1339 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
| 1340 | // check range of parameters |
---|
| 1341 | xConfirmPara( m_inputBitDepthY < 8, "InputBitDepth must be at least 8" ); |
---|
| 1342 | xConfirmPara( m_inputBitDepthC < 8, "InputBitDepthC must be at least 8" ); |
---|
| 1343 | #if !SVC_EXTENSION |
---|
| 1344 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
---|
| 1345 | #endif |
---|
| 1346 | xConfirmPara( m_framesToBeEncoded <= 0, "Total Number Of Frames encoded must be more than 0" ); |
---|
| 1347 | xConfirmPara( m_iGOPSize < 1 , "GOP Size must be greater or equal to 1" ); |
---|
| 1348 | xConfirmPara( m_iGOPSize > 1 && m_iGOPSize % 2, "GOP Size must be a multiple of 2, if GOP Size is greater than 1" ); |
---|
| 1349 | #if !SVC_EXTENSION |
---|
| 1350 | xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" ); |
---|
| 1351 | #endif |
---|
| 1352 | xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2, "Decoding Refresh Type must be equal to 0, 1 or 2" ); |
---|
| 1353 | #if !SVC_EXTENSION |
---|
| 1354 | xConfirmPara( m_iQP < -6 * (m_internalBitDepthY - 8) || m_iQP > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
---|
| 1355 | #endif |
---|
| 1356 | xConfirmPara( m_loopFilterBetaOffsetDiv2 < -6 || m_loopFilterBetaOffsetDiv2 > 6, "Loop Filter Beta Offset div. 2 exceeds supported range (-6 to 6)"); |
---|
| 1357 | xConfirmPara( m_loopFilterTcOffsetDiv2 < -6 || m_loopFilterTcOffsetDiv2 > 6, "Loop Filter Tc Offset div. 2 exceeds supported range (-6 to 6)"); |
---|
| 1358 | xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2, "Fast Search Mode is not supported value (0:Full search 1:Diamond 2:PMVFAST)" ); |
---|
| 1359 | xConfirmPara( m_iSearchRange < 0 , "Search Range must be more than 0" ); |
---|
| 1360 | xConfirmPara( m_bipredSearchRange < 0 , "Search Range must be more than 0" ); |
---|
| 1361 | xConfirmPara( m_iMaxDeltaQP > 7, "Absolute Delta QP exceeds supported range (0 to 7)" ); |
---|
| 1362 | xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1, "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" ); |
---|
| 1363 | |
---|
| 1364 | xConfirmPara( m_cbQpOffset < -12, "Min. Chroma Cb QP Offset is -12" ); |
---|
| 1365 | xConfirmPara( m_cbQpOffset > 12, "Max. Chroma Cb QP Offset is 12" ); |
---|
| 1366 | xConfirmPara( m_crQpOffset < -12, "Min. Chroma Cr QP Offset is -12" ); |
---|
| 1367 | xConfirmPara( m_crQpOffset > 12, "Max. Chroma Cr QP Offset is 12" ); |
---|
| 1368 | |
---|
| 1369 | xConfirmPara( m_iQPAdaptationRange <= 0, "QP Adaptation Range must be more than 0" ); |
---|
| 1370 | #if !SVC_EXTENSION |
---|
| 1371 | if (m_iDecodingRefreshType == 2) |
---|
| 1372 | { |
---|
| 1373 | xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize , "Intra period must be larger than GOP size for periodic IDR pictures"); |
---|
| 1374 | } |
---|
| 1375 | #endif |
---|
| 1376 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
---|
| 1377 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
---|
| 1378 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
---|
| 1379 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
---|
| 1380 | #if !SVC_EXTENSION |
---|
| 1381 | xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size"); |
---|
| 1382 | xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size"); |
---|
| 1383 | #endif |
---|
| 1384 | |
---|
| 1385 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
---|
| 1386 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
---|
| 1387 | xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth, "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller."); |
---|
| 1388 | |
---|
| 1389 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
---|
| 1390 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
| 1391 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
| 1392 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
---|
| 1393 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
---|
| 1394 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
---|
| 1395 | 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" ); |
---|
| 1396 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
---|
| 1397 | 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" ); |
---|
| 1398 | |
---|
| 1399 | xConfirmPara( m_maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater."); |
---|
| 1400 | xConfirmPara( m_maxNumMergeCand > 5, "MaxNumMergeCand must be 5 or smaller."); |
---|
| 1401 | |
---|
| 1402 | #if !SVC_EXTENSION |
---|
| 1403 | #if ADAPTIVE_QP_SELECTION |
---|
| 1404 | xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0, "AdaptiveQpSelection must be disabled when QP < 0."); |
---|
| 1405 | xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ), "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0."); |
---|
| 1406 | #endif |
---|
| 1407 | #endif |
---|
| 1408 | |
---|
| 1409 | if( m_usePCM) |
---|
| 1410 | { |
---|
| 1411 | xConfirmPara( m_uiPCMLog2MinSize < 3, "PCMLog2MinSize must be 3 or greater."); |
---|
| 1412 | xConfirmPara( m_uiPCMLog2MinSize > 5, "PCMLog2MinSize must be 5 or smaller."); |
---|
| 1413 | xConfirmPara( m_pcmLog2MaxSize > 5, "PCMLog2MaxSize must be 5 or smaller."); |
---|
| 1414 | xConfirmPara( m_pcmLog2MaxSize < m_uiPCMLog2MinSize, "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize."); |
---|
| 1415 | } |
---|
| 1416 | |
---|
| 1417 | xConfirmPara( m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)" ); |
---|
| 1418 | if (m_sliceMode!=0) |
---|
| 1419 | { |
---|
| 1420 | xConfirmPara( m_sliceArgument < 1 , "SliceArgument should be larger than or equal to 1" ); |
---|
| 1421 | } |
---|
| 1422 | xConfirmPara( m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)" ); |
---|
| 1423 | if (m_sliceSegmentMode!=0) |
---|
| 1424 | { |
---|
| 1425 | xConfirmPara( m_sliceSegmentArgument < 1 , "SliceSegmentArgument should be larger than or equal to 1" ); |
---|
| 1426 | } |
---|
| 1427 | |
---|
| 1428 | Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 ); |
---|
| 1429 | xConfirmPara( tileFlag && m_iWaveFrontSynchro, "Tile and Wavefront can not be applied together"); |
---|
| 1430 | |
---|
| 1431 | //TODO:ChromaFmt assumes 4:2:0 below |
---|
| 1432 | #if !SVC_EXTENSION |
---|
| 1433 | xConfirmPara( m_iSourceWidth % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); |
---|
| 1434 | xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); |
---|
| 1435 | |
---|
| 1436 | xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling"); |
---|
| 1437 | xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling"); |
---|
| 1438 | |
---|
| 1439 | xConfirmPara( m_confLeft % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
| 1440 | xConfirmPara( m_confRight % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
| 1441 | xConfirmPara( m_confTop % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
| 1442 | xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
| 1443 | #endif |
---|
| 1444 | |
---|
| 1445 | // max CU width and height should be power of 2 |
---|
| 1446 | UInt ui = m_uiMaxCUWidth; |
---|
| 1447 | while(ui) |
---|
| 1448 | { |
---|
| 1449 | ui >>= 1; |
---|
| 1450 | if( (ui & 1) == 1) |
---|
| 1451 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
---|
| 1452 | } |
---|
| 1453 | ui = m_uiMaxCUHeight; |
---|
| 1454 | while(ui) |
---|
| 1455 | { |
---|
| 1456 | ui >>= 1; |
---|
| 1457 | if( (ui & 1) == 1) |
---|
| 1458 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
---|
| 1459 | } |
---|
| 1460 | |
---|
| 1461 | |
---|
| 1462 | /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure |
---|
| 1463 | * This permits the ability to omit a GOP structure specification */ |
---|
| 1464 | #if SVC_EXTENSION |
---|
| 1465 | for(UInt layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 1466 | { |
---|
| 1467 | Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod; |
---|
| 1468 | #endif |
---|
| 1469 | if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) { |
---|
| 1470 | m_GOPList[0] = GOPEntry(); |
---|
| 1471 | m_GOPList[0].m_QPFactor = 1; |
---|
| 1472 | m_GOPList[0].m_betaOffsetDiv2 = 0; |
---|
| 1473 | m_GOPList[0].m_tcOffsetDiv2 = 0; |
---|
| 1474 | m_GOPList[0].m_POC = 1; |
---|
| 1475 | m_GOPList[0].m_numRefPicsActive = 4; |
---|
| 1476 | } |
---|
| 1477 | #if SVC_EXTENSION |
---|
| 1478 | } |
---|
| 1479 | #endif |
---|
| 1480 | |
---|
[357] | 1481 | #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 |
---|
[313] | 1482 | Bool verifiedGOP=false; |
---|
[334] | 1483 | #endif |
---|
[313] | 1484 | Bool errorGOP=false; |
---|
[357] | 1485 | #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 |
---|
[313] | 1486 | Int checkGOP=1; |
---|
| 1487 | Int numRefs = 1; |
---|
[334] | 1488 | #endif |
---|
[313] | 1489 | Int refList[MAX_NUM_REF_PICS+1]; |
---|
| 1490 | refList[0]=0; |
---|
| 1491 | Bool isOK[MAX_GOP]; |
---|
| 1492 | for(Int i=0; i<MAX_GOP; i++) |
---|
| 1493 | { |
---|
| 1494 | isOK[i]=false; |
---|
| 1495 | } |
---|
[357] | 1496 | #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 |
---|
[313] | 1497 | Int numOK=0; |
---|
[334] | 1498 | #endif |
---|
[313] | 1499 | #if !SVC_EXTENSION |
---|
| 1500 | xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" ); |
---|
| 1501 | #endif |
---|
| 1502 | |
---|
| 1503 | for(Int i=0; i<m_iGOPSize; i++) |
---|
| 1504 | { |
---|
| 1505 | if(m_GOPList[i].m_POC==m_iGOPSize) |
---|
| 1506 | { |
---|
| 1507 | xConfirmPara( m_GOPList[i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " ); |
---|
| 1508 | } |
---|
| 1509 | } |
---|
| 1510 | |
---|
| 1511 | #if SVC_EXTENSION |
---|
| 1512 | xConfirmPara( m_numLayers > MAX_LAYERS , "Number of layers in config file is greater than MAX_LAYERS" ); |
---|
| 1513 | m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers; |
---|
| 1514 | |
---|
| 1515 | // verify layer configuration parameters |
---|
| 1516 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1517 | { |
---|
| 1518 | if(m_acLayerCfg[layer].xCheckParameter()) |
---|
| 1519 | { |
---|
| 1520 | printf("\nError: invalid configuration parameter found in layer %d \n", layer); |
---|
| 1521 | check_failed = true; |
---|
| 1522 | } |
---|
| 1523 | } |
---|
| 1524 | |
---|
| 1525 | // verify layer configuration parameters |
---|
| 1526 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1527 | { |
---|
| 1528 | Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod; |
---|
| 1529 | #endif |
---|
| 1530 | if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) ) |
---|
| 1531 | { |
---|
| 1532 | for(Int i=0; i<m_iGOPSize; i++) |
---|
| 1533 | { |
---|
| 1534 | xConfirmPara( (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 || (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" ); |
---|
| 1535 | xConfirmPara( (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 || (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" ); |
---|
| 1536 | } |
---|
| 1537 | } |
---|
| 1538 | #if SVC_EXTENSION |
---|
| 1539 | } |
---|
| 1540 | #endif |
---|
[334] | 1541 | #if FINAL_RPL_CHANGE_N0082 |
---|
| 1542 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1543 | { |
---|
[357] | 1544 | if (m_acLayerCfg[layer].m_GOPListLayer[0].m_POC<0) |
---|
| 1545 | { |
---|
[334] | 1546 | memcpy( m_acLayerCfg[layer].m_GOPListLayer, m_GOPList, sizeof(GOPEntry)*MAX_GOP ); |
---|
| 1547 | } |
---|
| 1548 | errorGOP = xconfirmExtraGOP( m_acLayerCfg[layer].m_GOPListLayer ); |
---|
| 1549 | xConfirmPara(errorGOP,"Invalid GOP structure given"); |
---|
| 1550 | } |
---|
[357] | 1551 | #if !EXTERNAL_USEDBYCURR_N0082 |
---|
[334] | 1552 | #else |
---|
[357] | 1553 | #endif |
---|
[313] | 1554 | m_extraRPSs=0; |
---|
| 1555 | //start looping through frames in coding order until we can verify that the GOP structure is correct. |
---|
| 1556 | while(!verifiedGOP&&!errorGOP) |
---|
| 1557 | { |
---|
| 1558 | Int curGOP = (checkGOP-1)%m_iGOPSize; |
---|
| 1559 | Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPList[curGOP].m_POC; |
---|
| 1560 | if(m_GOPList[curGOP].m_POC<0) |
---|
| 1561 | { |
---|
| 1562 | printf("\nError: found fewer Reference Picture Sets than GOPSize\n"); |
---|
| 1563 | errorGOP=true; |
---|
| 1564 | } |
---|
| 1565 | else |
---|
| 1566 | { |
---|
| 1567 | //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP. |
---|
| 1568 | Bool beforeI = false; |
---|
| 1569 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
| 1570 | { |
---|
| 1571 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
| 1572 | if(absPOC < 0) |
---|
| 1573 | { |
---|
| 1574 | beforeI=true; |
---|
| 1575 | } |
---|
| 1576 | else |
---|
| 1577 | { |
---|
| 1578 | Bool found=false; |
---|
| 1579 | for(Int j=0; j<numRefs; j++) |
---|
| 1580 | { |
---|
| 1581 | if(refList[j]==absPOC) |
---|
| 1582 | { |
---|
| 1583 | found=true; |
---|
| 1584 | for(Int k=0; k<m_iGOPSize; k++) |
---|
| 1585 | { |
---|
| 1586 | if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize) |
---|
| 1587 | { |
---|
| 1588 | if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId) |
---|
| 1589 | { |
---|
| 1590 | m_GOPList[k].m_refPic = true; |
---|
| 1591 | } |
---|
| 1592 | m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId; |
---|
| 1593 | } |
---|
| 1594 | } |
---|
| 1595 | } |
---|
| 1596 | } |
---|
| 1597 | if(!found) |
---|
| 1598 | { |
---|
| 1599 | printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1); |
---|
| 1600 | errorGOP=true; |
---|
| 1601 | } |
---|
| 1602 | } |
---|
| 1603 | } |
---|
| 1604 | if(!beforeI&&!errorGOP) |
---|
| 1605 | { |
---|
| 1606 | //all ref frames were present |
---|
| 1607 | if(!isOK[curGOP]) |
---|
| 1608 | { |
---|
| 1609 | numOK++; |
---|
| 1610 | isOK[curGOP]=true; |
---|
| 1611 | if(numOK==m_iGOPSize) |
---|
| 1612 | { |
---|
| 1613 | verifiedGOP=true; |
---|
| 1614 | } |
---|
| 1615 | } |
---|
| 1616 | } |
---|
| 1617 | else |
---|
| 1618 | { |
---|
| 1619 | //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0) |
---|
| 1620 | m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP]; |
---|
| 1621 | Int newRefs=0; |
---|
| 1622 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
| 1623 | { |
---|
| 1624 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
| 1625 | if(absPOC>=0) |
---|
| 1626 | { |
---|
| 1627 | m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i]; |
---|
| 1628 | m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i]; |
---|
| 1629 | newRefs++; |
---|
| 1630 | } |
---|
| 1631 | } |
---|
| 1632 | Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive; |
---|
| 1633 | |
---|
| 1634 | for(Int offset = -1; offset>-checkGOP; offset--) |
---|
| 1635 | { |
---|
| 1636 | //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0. |
---|
| 1637 | Int offGOP = (checkGOP-1+offset)%m_iGOPSize; |
---|
| 1638 | Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC; |
---|
| 1639 | if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId) |
---|
| 1640 | { |
---|
| 1641 | Bool newRef=false; |
---|
| 1642 | for(Int i=0; i<numRefs; i++) |
---|
| 1643 | { |
---|
| 1644 | if(refList[i]==offPOC) |
---|
| 1645 | { |
---|
| 1646 | newRef=true; |
---|
| 1647 | } |
---|
| 1648 | } |
---|
| 1649 | for(Int i=0; i<newRefs; i++) |
---|
| 1650 | { |
---|
| 1651 | if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC) |
---|
| 1652 | { |
---|
| 1653 | newRef=false; |
---|
| 1654 | } |
---|
| 1655 | } |
---|
| 1656 | if(newRef) |
---|
| 1657 | { |
---|
| 1658 | Int insertPoint=newRefs; |
---|
| 1659 | //this picture can be added, find appropriate place in list and insert it. |
---|
| 1660 | if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId) |
---|
| 1661 | { |
---|
| 1662 | m_GOPList[offGOP].m_refPic = true; |
---|
| 1663 | } |
---|
| 1664 | for(Int j=0; j<newRefs; j++) |
---|
| 1665 | { |
---|
| 1666 | if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0) |
---|
| 1667 | { |
---|
| 1668 | insertPoint = j; |
---|
| 1669 | break; |
---|
| 1670 | } |
---|
| 1671 | } |
---|
| 1672 | Int prev = offPOC-curPOC; |
---|
| 1673 | Int prevUsed = m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId; |
---|
| 1674 | for(Int j=insertPoint; j<newRefs+1; j++) |
---|
| 1675 | { |
---|
| 1676 | Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]; |
---|
| 1677 | Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]; |
---|
| 1678 | m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev; |
---|
| 1679 | m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed; |
---|
| 1680 | prevUsed=newUsed; |
---|
| 1681 | prev=newPrev; |
---|
| 1682 | } |
---|
| 1683 | newRefs++; |
---|
| 1684 | } |
---|
| 1685 | } |
---|
| 1686 | if(newRefs>=numPrefRefs) |
---|
| 1687 | { |
---|
| 1688 | break; |
---|
| 1689 | } |
---|
| 1690 | } |
---|
| 1691 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs; |
---|
| 1692 | m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC; |
---|
| 1693 | if (m_extraRPSs == 0) |
---|
| 1694 | { |
---|
| 1695 | m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0; |
---|
| 1696 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0; |
---|
| 1697 | } |
---|
| 1698 | else |
---|
| 1699 | { |
---|
| 1700 | Int rIdx = m_iGOPSize + m_extraRPSs - 1; |
---|
| 1701 | Int refPOC = m_GOPList[rIdx].m_POC; |
---|
| 1702 | Int refPics = m_GOPList[rIdx].m_numRefPics; |
---|
| 1703 | Int newIdc=0; |
---|
| 1704 | for(Int i = 0; i<= refPics; i++) |
---|
| 1705 | { |
---|
| 1706 | Int deltaPOC = ((i != refPics)? m_GOPList[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0 |
---|
| 1707 | Int absPOCref = refPOC+deltaPOC; |
---|
| 1708 | Int refIdc = 0; |
---|
| 1709 | for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++) |
---|
| 1710 | { |
---|
| 1711 | if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]) |
---|
| 1712 | { |
---|
| 1713 | if (m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]) |
---|
| 1714 | { |
---|
| 1715 | refIdc = 1; |
---|
| 1716 | } |
---|
| 1717 | else |
---|
| 1718 | { |
---|
| 1719 | refIdc = 2; |
---|
| 1720 | } |
---|
| 1721 | } |
---|
| 1722 | } |
---|
| 1723 | m_GOPList[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc; |
---|
| 1724 | newIdc++; |
---|
| 1725 | } |
---|
| 1726 | m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1; |
---|
| 1727 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc; |
---|
| 1728 | m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC; |
---|
| 1729 | } |
---|
| 1730 | curGOP=m_iGOPSize+m_extraRPSs; |
---|
| 1731 | m_extraRPSs++; |
---|
| 1732 | } |
---|
| 1733 | numRefs=0; |
---|
| 1734 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
| 1735 | { |
---|
| 1736 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
| 1737 | if(absPOC >= 0) |
---|
| 1738 | { |
---|
| 1739 | refList[numRefs]=absPOC; |
---|
| 1740 | numRefs++; |
---|
| 1741 | } |
---|
| 1742 | } |
---|
| 1743 | refList[numRefs]=curPOC; |
---|
| 1744 | numRefs++; |
---|
| 1745 | } |
---|
| 1746 | checkGOP++; |
---|
| 1747 | } |
---|
| 1748 | xConfirmPara(errorGOP,"Invalid GOP structure given"); |
---|
[357] | 1749 | #if !EXTERNAL_USEDBYCURR_N0082 |
---|
[334] | 1750 | #endif |
---|
[357] | 1751 | #endif |
---|
| 1752 | #if EXTERNAL_USEDBYCURR_N0082 |
---|
| 1753 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 1754 | { |
---|
| 1755 | for (Int i=0; i< m_iGOPSize; i++){ |
---|
| 1756 | if (m_acLayerCfg[layer].m_GOPListLayer[i].m_UseExtusedByCurrPic == 1 ) |
---|
| 1757 | { |
---|
| 1758 | for(Int j=0; j<m_acLayerCfg[layer].m_GOPListLayer[i].m_numRefPics; j++ ) |
---|
| 1759 | { |
---|
| 1760 | m_acLayerCfg[layer].m_GOPListLayer[i].m_usedByCurrPic[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j]; |
---|
| 1761 | m_acLayerCfg[layer].m_GOPListLayer[i].m_refIdc[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j]; |
---|
| 1762 | } |
---|
| 1763 | } |
---|
| 1764 | } |
---|
| 1765 | } |
---|
| 1766 | #endif |
---|
[313] | 1767 | m_maxTempLayer = 1; |
---|
| 1768 | for(Int i=0; i<m_iGOPSize; i++) |
---|
| 1769 | { |
---|
| 1770 | if(m_GOPList[i].m_temporalId >= m_maxTempLayer) |
---|
| 1771 | { |
---|
| 1772 | m_maxTempLayer = m_GOPList[i].m_temporalId+1; |
---|
| 1773 | } |
---|
| 1774 | xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P', "Slice type must be equal to B or P"); |
---|
| 1775 | } |
---|
| 1776 | for(Int i=0; i<MAX_TLAYER; i++) |
---|
| 1777 | { |
---|
| 1778 | m_numReorderPics[i] = 0; |
---|
| 1779 | m_maxDecPicBuffering[i] = 1; |
---|
| 1780 | } |
---|
| 1781 | for(Int i=0; i<m_iGOPSize; i++) |
---|
| 1782 | { |
---|
| 1783 | if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId]) |
---|
| 1784 | { |
---|
| 1785 | m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1; |
---|
| 1786 | } |
---|
| 1787 | |
---|
| 1788 | Int highestDecodingNumberWithLowerPOC = 0; |
---|
| 1789 | for(Int j=0; j<m_iGOPSize; j++) |
---|
| 1790 | { |
---|
| 1791 | if(m_GOPList[j].m_POC <= m_GOPList[i].m_POC) |
---|
| 1792 | { |
---|
| 1793 | highestDecodingNumberWithLowerPOC = j; |
---|
| 1794 | } |
---|
| 1795 | } |
---|
| 1796 | Int numReorder = 0; |
---|
| 1797 | for(Int j=0; j<highestDecodingNumberWithLowerPOC; j++) |
---|
| 1798 | { |
---|
| 1799 | if(m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId && |
---|
| 1800 | m_GOPList[j].m_POC > m_GOPList[i].m_POC) |
---|
| 1801 | { |
---|
| 1802 | numReorder++; |
---|
| 1803 | } |
---|
| 1804 | } |
---|
| 1805 | if(numReorder > m_numReorderPics[m_GOPList[i].m_temporalId]) |
---|
| 1806 | { |
---|
| 1807 | m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder; |
---|
| 1808 | } |
---|
| 1809 | } |
---|
| 1810 | for(Int i=0; i<MAX_TLAYER-1; i++) |
---|
| 1811 | { |
---|
| 1812 | // a lower layer can not have higher value of m_numReorderPics than a higher layer |
---|
| 1813 | if(m_numReorderPics[i+1] < m_numReorderPics[i]) |
---|
| 1814 | { |
---|
| 1815 | m_numReorderPics[i+1] = m_numReorderPics[i]; |
---|
| 1816 | } |
---|
| 1817 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive |
---|
| 1818 | if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1) |
---|
| 1819 | { |
---|
| 1820 | m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1; |
---|
| 1821 | } |
---|
| 1822 | // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer |
---|
| 1823 | if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i]) |
---|
| 1824 | { |
---|
| 1825 | m_maxDecPicBuffering[i+1] = m_maxDecPicBuffering[i]; |
---|
| 1826 | } |
---|
| 1827 | } |
---|
| 1828 | |
---|
| 1829 | |
---|
| 1830 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive |
---|
| 1831 | if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1) |
---|
| 1832 | { |
---|
| 1833 | m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1; |
---|
| 1834 | } |
---|
| 1835 | |
---|
| 1836 | #if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers |
---|
| 1837 | for(UInt layer = 0; layer < MAX_LAYERS; layer++) |
---|
| 1838 | { |
---|
| 1839 | Int m_iSourceWidth = m_acLayerCfg[layer].m_iSourceWidth; |
---|
| 1840 | Int m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight; |
---|
| 1841 | #endif |
---|
| 1842 | if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag) |
---|
| 1843 | { |
---|
| 1844 | Int PicSizeInSamplesY = m_iSourceWidth * m_iSourceHeight; |
---|
| 1845 | if(tileFlag) |
---|
| 1846 | { |
---|
| 1847 | Int maxTileWidth = 0; |
---|
| 1848 | Int maxTileHeight = 0; |
---|
| 1849 | Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth; |
---|
| 1850 | Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight; |
---|
| 1851 | if(m_iUniformSpacingIdr) |
---|
| 1852 | { |
---|
| 1853 | maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1)); |
---|
| 1854 | maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1)); |
---|
| 1855 | // if only the last tile-row is one treeblock higher than the others |
---|
| 1856 | // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others |
---|
| 1857 | if(!((heightInCU-1)%(m_iNumRowsMinus1+1))) |
---|
| 1858 | { |
---|
| 1859 | maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight); |
---|
| 1860 | } |
---|
| 1861 | // if only the last tile-column is one treeblock wider than the others |
---|
| 1862 | // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others |
---|
| 1863 | if(!((widthInCU-1)%(m_iNumColumnsMinus1+1))) |
---|
| 1864 | { |
---|
| 1865 | maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth); |
---|
| 1866 | } |
---|
| 1867 | } |
---|
| 1868 | else // not uniform spacing |
---|
| 1869 | { |
---|
| 1870 | if(m_iNumColumnsMinus1<1) |
---|
| 1871 | { |
---|
| 1872 | maxTileWidth = m_iSourceWidth; |
---|
| 1873 | } |
---|
| 1874 | else |
---|
| 1875 | { |
---|
| 1876 | Int accColumnWidth = 0; |
---|
| 1877 | for(Int col=0; col<(m_iNumColumnsMinus1); col++) |
---|
| 1878 | { |
---|
| 1879 | maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth; |
---|
| 1880 | accColumnWidth += m_pColumnWidth[col]; |
---|
| 1881 | } |
---|
| 1882 | maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth; |
---|
| 1883 | } |
---|
| 1884 | if(m_iNumRowsMinus1<1) |
---|
| 1885 | { |
---|
| 1886 | maxTileHeight = m_iSourceHeight; |
---|
| 1887 | } |
---|
| 1888 | else |
---|
| 1889 | { |
---|
| 1890 | Int accRowHeight = 0; |
---|
| 1891 | for(Int row=0; row<(m_iNumRowsMinus1); row++) |
---|
| 1892 | { |
---|
| 1893 | maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight; |
---|
| 1894 | accRowHeight += m_pRowHeight[row]; |
---|
| 1895 | } |
---|
| 1896 | maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight; |
---|
| 1897 | } |
---|
| 1898 | } |
---|
| 1899 | Int maxSizeInSamplesY = maxTileWidth*maxTileHeight; |
---|
| 1900 | m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/maxSizeInSamplesY-4; |
---|
| 1901 | } |
---|
| 1902 | else if(m_iWaveFrontSynchro) |
---|
| 1903 | { |
---|
| 1904 | m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4; |
---|
| 1905 | } |
---|
| 1906 | else if(m_sliceMode == 1) |
---|
| 1907 | { |
---|
| 1908 | m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/(m_sliceArgument*m_uiMaxCUWidth*m_uiMaxCUHeight)-4; |
---|
| 1909 | } |
---|
| 1910 | else |
---|
| 1911 | { |
---|
| 1912 | m_minSpatialSegmentationIdc = 0; |
---|
| 1913 | } |
---|
| 1914 | } |
---|
| 1915 | #if SVC_EXTENSION |
---|
| 1916 | } |
---|
| 1917 | #endif |
---|
| 1918 | xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" ); |
---|
| 1919 | #if !SVC_EXTENSION |
---|
| 1920 | xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" ); |
---|
| 1921 | xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" ); |
---|
| 1922 | #endif |
---|
| 1923 | |
---|
| 1924 | xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n"); |
---|
| 1925 | |
---|
| 1926 | if (m_toneMappingInfoSEIEnabled) |
---|
| 1927 | { |
---|
| 1928 | xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14"); |
---|
| 1929 | xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255"); |
---|
| 1930 | xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4"); |
---|
| 1931 | xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0"); |
---|
| 1932 | xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100"); |
---|
| 1933 | xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue"); |
---|
| 1934 | xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue"); |
---|
| 1935 | } |
---|
| 1936 | |
---|
| 1937 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 1938 | #if RC_SHVC_HARMONIZATION |
---|
| 1939 | for ( Int layer=0; layer<m_numLayers; layer++ ) |
---|
| 1940 | { |
---|
| 1941 | if ( m_acLayerCfg[layer].m_RCEnableRateControl ) |
---|
| 1942 | { |
---|
| 1943 | if ( m_acLayerCfg[layer].m_RCForceIntraQP ) |
---|
| 1944 | { |
---|
| 1945 | if ( m_acLayerCfg[layer].m_RCInitialQP == 0 ) |
---|
| 1946 | { |
---|
| 1947 | printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" ); |
---|
| 1948 | m_acLayerCfg[layer].m_RCForceIntraQP = false; |
---|
| 1949 | } |
---|
| 1950 | } |
---|
| 1951 | } |
---|
| 1952 | xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" ); |
---|
| 1953 | } |
---|
| 1954 | #else |
---|
| 1955 | if ( m_RCEnableRateControl ) |
---|
| 1956 | { |
---|
| 1957 | if ( m_RCForceIntraQP ) |
---|
| 1958 | { |
---|
| 1959 | if ( m_RCInitialQP == 0 ) |
---|
| 1960 | { |
---|
| 1961 | printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" ); |
---|
| 1962 | m_RCForceIntraQP = false; |
---|
| 1963 | } |
---|
| 1964 | } |
---|
| 1965 | xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" ); |
---|
| 1966 | } |
---|
| 1967 | #endif |
---|
| 1968 | #else |
---|
| 1969 | if(m_enableRateCtrl) |
---|
| 1970 | { |
---|
| 1971 | Int numLCUInWidth = (m_iSourceWidth / m_uiMaxCUWidth) + (( m_iSourceWidth % m_uiMaxCUWidth ) ? 1 : 0); |
---|
| 1972 | Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight)+ (( m_iSourceHeight % m_uiMaxCUHeight) ? 1 : 0); |
---|
| 1973 | Int numLCUInPic = numLCUInWidth * numLCUInHeight; |
---|
| 1974 | |
---|
| 1975 | xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" ); |
---|
| 1976 | |
---|
| 1977 | m_iMaxDeltaQP = MAX_DELTA_QP; |
---|
| 1978 | m_iMaxCuDQPDepth = MAX_CUDQP_DEPTH; |
---|
| 1979 | } |
---|
| 1980 | #endif |
---|
| 1981 | |
---|
| 1982 | xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0"); |
---|
| 1983 | |
---|
| 1984 | xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2"); |
---|
| 1985 | if (m_framePackingSEIEnabled) |
---|
| 1986 | { |
---|
| 1987 | xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5"); |
---|
| 1988 | } |
---|
| 1989 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1990 | #if M0457_PREDICTION_INDICATIONS |
---|
| 1991 | xConfirmPara( (m_acLayerCfg[0].m_numSamplePredRefLayers != 0) && (m_acLayerCfg[0].m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" ); |
---|
| 1992 | // NOTE: m_numSamplePredRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
| 1993 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
| 1994 | { |
---|
| 1995 | xConfirmPara(m_acLayerCfg[layer].m_numSamplePredRefLayers > layer, "Cannot reference more layers than before current layer"); |
---|
| 1996 | for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++) |
---|
| 1997 | { |
---|
| 1998 | xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] > layer, "Cannot reference higher layers"); |
---|
| 1999 | xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] == layer, "Cannot reference the current layer itself"); |
---|
| 2000 | } |
---|
| 2001 | } |
---|
| 2002 | xConfirmPara( (m_acLayerCfg[0].m_numMotionPredRefLayers != 0) && (m_acLayerCfg[0].m_numMotionPredRefLayers != -1), "Layer 0 cannot have any reference layers" ); |
---|
| 2003 | // NOTE: m_numMotionPredRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
| 2004 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
| 2005 | { |
---|
| 2006 | xConfirmPara(m_acLayerCfg[layer].m_numMotionPredRefLayers > layer, "Cannot reference more layers than before current layer"); |
---|
| 2007 | for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++) |
---|
| 2008 | { |
---|
| 2009 | xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] > layer, "Cannot reference higher layers"); |
---|
| 2010 | xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] == layer, "Cannot reference the current layer itself"); |
---|
| 2011 | } |
---|
| 2012 | } |
---|
| 2013 | #else |
---|
| 2014 | xConfirmPara( (m_acLayerCfg[0].m_numDirectRefLayers != 0) && (m_acLayerCfg[0].m_numDirectRefLayers != -1), "Layer 0 cannot have any reference layers" ); |
---|
| 2015 | // NOTE: m_numDirectRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
| 2016 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
| 2017 | { |
---|
| 2018 | xConfirmPara(m_acLayerCfg[layer].m_numDirectRefLayers > layer, "Cannot reference more layers than before current layer"); |
---|
| 2019 | for(Int i = 0; i < m_acLayerCfg[layer].m_numDirectRefLayers; i++) |
---|
| 2020 | { |
---|
| 2021 | xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] > layer, "Cannot reference higher layers"); |
---|
| 2022 | xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] == layer, "Cannot reference the current layer itself"); |
---|
| 2023 | } |
---|
| 2024 | } |
---|
| 2025 | #endif |
---|
| 2026 | xConfirmPara( (m_acLayerCfg[0].m_numActiveRefLayers != 0) && (m_acLayerCfg[0].m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" ); |
---|
| 2027 | // NOTE: m_numActiveRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
| 2028 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
| 2029 | { |
---|
| 2030 | #if M0457_PREDICTION_INDICATIONS |
---|
| 2031 | Bool predEnabledFlag[MAX_LAYERS]; |
---|
| 2032 | for (Int refLayer = 0; refLayer < layer; refLayer++) |
---|
| 2033 | { |
---|
| 2034 | predEnabledFlag[refLayer] = false; |
---|
| 2035 | } |
---|
| 2036 | for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++) |
---|
| 2037 | { |
---|
| 2038 | predEnabledFlag[m_acLayerCfg[layer].m_samplePredRefLayerIds[i]] = true; |
---|
| 2039 | } |
---|
| 2040 | for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++) |
---|
| 2041 | { |
---|
| 2042 | predEnabledFlag[m_acLayerCfg[layer].m_motionPredRefLayerIds[i]] = true; |
---|
| 2043 | } |
---|
| 2044 | Int numDirectRefLayers = 0; |
---|
| 2045 | for (Int refLayer = 0; refLayer < layer; refLayer++) |
---|
| 2046 | { |
---|
| 2047 | if (predEnabledFlag[refLayer] == true) numDirectRefLayers++; |
---|
| 2048 | } |
---|
| 2049 | xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers"); |
---|
| 2050 | for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++) |
---|
| 2051 | { |
---|
| 2052 | xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] >= numDirectRefLayers, "Cannot reference higher layers"); |
---|
| 2053 | } |
---|
| 2054 | #else |
---|
| 2055 | xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers"); |
---|
| 2056 | for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++) |
---|
| 2057 | { |
---|
| 2058 | xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] >= m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference higher layers"); |
---|
| 2059 | } |
---|
| 2060 | #endif |
---|
| 2061 | } |
---|
| 2062 | #endif |
---|
| 2063 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 2064 | if (m_adaptiveResolutionChange > 0) |
---|
| 2065 | { |
---|
| 2066 | xConfirmPara(m_numLayers != 2, "Adaptive resolution change works with 2 layers only"); |
---|
| 2067 | xConfirmPara(m_acLayerCfg[1].m_iIntraPeriod == 0 || (m_adaptiveResolutionChange % m_acLayerCfg[1].m_iIntraPeriod) != 0, "Adaptive resolution change must happen at enhancement layer RAP picture"); |
---|
| 2068 | } |
---|
| 2069 | #endif |
---|
| 2070 | #undef xConfirmPara |
---|
| 2071 | if (check_failed) |
---|
| 2072 | { |
---|
| 2073 | exit(EXIT_FAILURE); |
---|
| 2074 | } |
---|
| 2075 | } |
---|
| 2076 | |
---|
| 2077 | /** \todo use of global variables should be removed later |
---|
| 2078 | */ |
---|
| 2079 | Void TAppEncCfg::xSetGlobal() |
---|
| 2080 | { |
---|
| 2081 | // set max CU width & height |
---|
| 2082 | g_uiMaxCUWidth = m_uiMaxCUWidth; |
---|
| 2083 | g_uiMaxCUHeight = m_uiMaxCUHeight; |
---|
| 2084 | |
---|
| 2085 | // compute actual CU depth with respect to config depth and max transform size |
---|
| 2086 | g_uiAddCUDepth = 0; |
---|
| 2087 | while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth ) ) ) g_uiAddCUDepth++; |
---|
| 2088 | |
---|
| 2089 | m_uiMaxCUDepth += g_uiAddCUDepth; |
---|
| 2090 | g_uiAddCUDepth++; |
---|
| 2091 | g_uiMaxCUDepth = m_uiMaxCUDepth; |
---|
| 2092 | |
---|
| 2093 | // set internal bit-depth and constants |
---|
| 2094 | g_bitDepthY = m_internalBitDepthY; |
---|
| 2095 | g_bitDepthC = m_internalBitDepthC; |
---|
| 2096 | |
---|
| 2097 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY; |
---|
| 2098 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC; |
---|
| 2099 | } |
---|
| 2100 | |
---|
| 2101 | Void TAppEncCfg::xPrintParameter() |
---|
| 2102 | { |
---|
| 2103 | printf("\n"); |
---|
| 2104 | #if SVC_EXTENSION |
---|
| 2105 | printf("Total number of layers : %d\n", m_numLayers ); |
---|
| 2106 | printf("Multiview : %d\n", m_scalabilityMask[0] ); |
---|
| 2107 | printf("Scalable : %d\n", m_scalabilityMask[1] ); |
---|
| 2108 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 2109 | printf("Adaptive Resolution Change : %d\n", m_adaptiveResolutionChange ); |
---|
| 2110 | #endif |
---|
| 2111 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
| 2112 | { |
---|
| 2113 | printf("=== Layer %d settings === \n", layer); |
---|
| 2114 | #if AVC_SYNTAX |
---|
| 2115 | m_acLayerCfg[layer].xPrintParameter( layer ); |
---|
| 2116 | #else |
---|
| 2117 | m_acLayerCfg[layer].xPrintParameter(); |
---|
| 2118 | #endif |
---|
| 2119 | printf("\n"); |
---|
| 2120 | } |
---|
| 2121 | printf("=== Common configuration settings === \n"); |
---|
| 2122 | printf("Bitstream File : %s\n", m_pBitstreamFile ); |
---|
| 2123 | #else |
---|
| 2124 | printf("Input File : %s\n", m_pchInputFile ); |
---|
| 2125 | printf("Bitstream File : %s\n", m_pchBitstreamFile ); |
---|
| 2126 | printf("Reconstruction File : %s\n", m_pchReconFile ); |
---|
| 2127 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate ); |
---|
| 2128 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
---|
| 2129 | #endif |
---|
| 2130 | printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded ); |
---|
| 2131 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
---|
| 2132 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
| 2133 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
---|
| 2134 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
---|
| 2135 | printf("Min PCM size : %d\n", 1 << m_uiPCMLog2MinSize); |
---|
| 2136 | printf("Motion search range : %d\n", m_iSearchRange ); |
---|
| 2137 | #if !SVC_EXTENSION |
---|
| 2138 | printf("Intra period : %d\n", m_iIntraPeriod ); |
---|
| 2139 | #endif |
---|
| 2140 | printf("Decoding refresh type : %d\n", m_iDecodingRefreshType ); |
---|
| 2141 | #if !SVC_EXTENSION |
---|
| 2142 | printf("QP : %5.2f\n", m_fQP ); |
---|
| 2143 | #endif |
---|
| 2144 | printf("Max dQP signaling depth : %d\n", m_iMaxCuDQPDepth); |
---|
| 2145 | |
---|
| 2146 | printf("Cb QP Offset : %d\n", m_cbQpOffset ); |
---|
| 2147 | printf("Cr QP Offset : %d\n", m_crQpOffset); |
---|
| 2148 | |
---|
| 2149 | printf("QP adaptation : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) ); |
---|
| 2150 | printf("GOP size : %d\n", m_iGOPSize ); |
---|
| 2151 | printf("Internal bit depth : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC ); |
---|
| 2152 | printf("PCM sample bit depth : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma ); |
---|
| 2153 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 2154 | #if !RC_SHVC_HARMONIZATION |
---|
| 2155 | printf("RateControl : %d\n", m_RCEnableRateControl ); |
---|
| 2156 | if(m_RCEnableRateControl) |
---|
| 2157 | { |
---|
| 2158 | printf("TargetBitrate : %d\n", m_RCTargetBitrate ); |
---|
| 2159 | printf("KeepHierarchicalBit : %d\n", m_RCKeepHierarchicalBit ); |
---|
| 2160 | printf("LCULevelRC : %d\n", m_RCLCULevelRC ); |
---|
| 2161 | printf("UseLCUSeparateModel : %d\n", m_RCUseLCUSeparateModel ); |
---|
| 2162 | printf("InitialQP : %d\n", m_RCInitialQP ); |
---|
| 2163 | printf("ForceIntraQP : %d\n", m_RCForceIntraQP ); |
---|
| 2164 | } |
---|
| 2165 | #endif |
---|
| 2166 | #else |
---|
| 2167 | printf("RateControl : %d\n", m_enableRateCtrl); |
---|
| 2168 | if(m_enableRateCtrl) |
---|
| 2169 | { |
---|
| 2170 | printf("TargetBitrate : %d\n", m_targetBitrate); |
---|
| 2171 | printf("NumLCUInUnit : %d\n", m_numLCUInUnit); |
---|
| 2172 | } |
---|
| 2173 | #endif |
---|
| 2174 | printf("Max Num Merge Candidates : %d\n", m_maxNumMergeCand); |
---|
| 2175 | printf("\n"); |
---|
| 2176 | |
---|
| 2177 | printf("TOOL CFG: "); |
---|
| 2178 | printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC); |
---|
| 2179 | printf("HAD:%d ", m_bUseHADME ); |
---|
| 2180 | printf("SRD:%d ", m_bUseSBACRD ); |
---|
| 2181 | printf("RDQ:%d ", m_useRDOQ ); |
---|
| 2182 | printf("RDQTS:%d ", m_useRDOQTS ); |
---|
| 2183 | printf("RDpenalty:%d ", m_rdPenalty ); |
---|
| 2184 | printf("SQP:%d ", m_uiDeltaQpRD ); |
---|
| 2185 | printf("ASR:%d ", m_bUseASR ); |
---|
| 2186 | printf("FEN:%d ", m_bUseFastEnc ); |
---|
| 2187 | printf("ECU:%d ", m_bUseEarlyCU ); |
---|
| 2188 | printf("FDM:%d ", m_useFastDecisionForMerge ); |
---|
| 2189 | printf("CFM:%d ", m_bUseCbfFastMode ); |
---|
| 2190 | printf("ESD:%d ", m_useEarlySkipDetection ); |
---|
| 2191 | #if FAST_INTRA_SHVC |
---|
| 2192 | printf("FIS:%d ", m_useFastIntraScalable ); |
---|
| 2193 | #endif |
---|
| 2194 | printf("RQT:%d ", 1 ); |
---|
| 2195 | printf("TransformSkip:%d ", m_useTransformSkip ); |
---|
| 2196 | printf("TransformSkipFast:%d ", m_useTransformSkipFast ); |
---|
| 2197 | printf("Slice: M=%d ", m_sliceMode); |
---|
| 2198 | if (m_sliceMode!=0) |
---|
| 2199 | { |
---|
| 2200 | printf("A=%d ", m_sliceArgument); |
---|
| 2201 | } |
---|
| 2202 | printf("SliceSegment: M=%d ",m_sliceSegmentMode); |
---|
| 2203 | if (m_sliceSegmentMode!=0) |
---|
| 2204 | { |
---|
| 2205 | printf("A=%d ", m_sliceSegmentArgument); |
---|
| 2206 | } |
---|
| 2207 | printf("CIP:%d ", m_bUseConstrainedIntraPred); |
---|
| 2208 | printf("SAO:%d ", (m_bUseSAO)?(1):(0)); |
---|
| 2209 | printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0); |
---|
| 2210 | printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0)); |
---|
| 2211 | |
---|
| 2212 | printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 ); |
---|
| 2213 | printf("WPP:%d ", (Int)m_useWeightedPred); |
---|
| 2214 | printf("WPB:%d ", (Int)m_useWeightedBiPred); |
---|
| 2215 | printf("PME:%d ", m_log2ParallelMergeLevel); |
---|
| 2216 | #if !SVC_EXTENSION |
---|
| 2217 | printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d", |
---|
| 2218 | m_iWaveFrontSynchro, m_iWaveFrontSubstreams); |
---|
| 2219 | #endif |
---|
| 2220 | printf(" ScalingList:%d ", m_useScalingListId ); |
---|
| 2221 | printf("TMVPMode:%d ", m_TMVPModeId ); |
---|
| 2222 | #if ADAPTIVE_QP_SELECTION |
---|
| 2223 | printf("AQpS:%d", m_bUseAdaptQpSelect ); |
---|
| 2224 | #endif |
---|
| 2225 | |
---|
| 2226 | printf(" SignBitHidingFlag:%d ", m_signHideFlag); |
---|
| 2227 | #if SVC_EXTENSION |
---|
| 2228 | printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 ); |
---|
| 2229 | #if AVC_BASE |
---|
| 2230 | printf("AvcBase:%d ", m_avcBaseLayerFlag ? 1 : 0); |
---|
| 2231 | #else |
---|
| 2232 | printf("AvcBase:%d ", 0); |
---|
| 2233 | #endif |
---|
| 2234 | #if REF_IDX_FRAMEWORK |
---|
| 2235 | printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK); |
---|
| 2236 | printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled); |
---|
| 2237 | printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV); |
---|
| 2238 | printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE); |
---|
| 2239 | printf("REF_IDX_MFM: %d ", REF_IDX_MFM); |
---|
| 2240 | #endif |
---|
| 2241 | #else |
---|
| 2242 | printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 ); |
---|
| 2243 | #endif |
---|
| 2244 | printf("\n\n"); |
---|
| 2245 | |
---|
| 2246 | fflush(stdout); |
---|
| 2247 | } |
---|
| 2248 | |
---|
| 2249 | Bool confirmPara(Bool bflag, const Char* message) |
---|
| 2250 | { |
---|
| 2251 | if (!bflag) |
---|
| 2252 | return false; |
---|
| 2253 | |
---|
| 2254 | printf("Error: %s\n",message); |
---|
| 2255 | return true; |
---|
| 2256 | } |
---|
| 2257 | |
---|
| 2258 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 2259 | Void TAppEncCfg::cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString) |
---|
| 2260 | { |
---|
| 2261 | Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str()); |
---|
| 2262 | if( numEntries > 0 ) |
---|
| 2263 | { |
---|
| 2264 | Char *arrayEntry; |
---|
| 2265 | Int i = 0; |
---|
| 2266 | *arr = new Int[numEntries]; |
---|
| 2267 | |
---|
| 2268 | arrayEntry = strtok( tempChar, " ,"); |
---|
| 2269 | while(arrayEntry != NULL) |
---|
| 2270 | { |
---|
| 2271 | if( i >= numEntries ) |
---|
| 2272 | { |
---|
| 2273 | printf( "%s: The number of entries specified is larger than the allowed number.\n", logString ); |
---|
| 2274 | exit( EXIT_FAILURE ); |
---|
| 2275 | } |
---|
| 2276 | *( *arr + i ) = atoi( arrayEntry ); |
---|
| 2277 | arrayEntry = strtok(NULL, " ,"); |
---|
| 2278 | i++; |
---|
| 2279 | } |
---|
| 2280 | if( i < numEntries ) |
---|
| 2281 | { |
---|
| 2282 | printf( "%s: Some entries are not specified.\n", logString ); |
---|
| 2283 | exit( EXIT_FAILURE ); |
---|
| 2284 | } |
---|
| 2285 | } |
---|
| 2286 | else |
---|
| 2287 | { |
---|
| 2288 | *arr = NULL; |
---|
| 2289 | } |
---|
| 2290 | } |
---|
| 2291 | #endif |
---|
[334] | 2292 | |
---|
| 2293 | #if FINAL_RPL_CHANGE_N0082 |
---|
| 2294 | Bool TAppEncCfg::xconfirmExtraGOP (GOPEntry * ge) |
---|
| 2295 | { |
---|
| 2296 | Bool verifiedGOP=false; |
---|
| 2297 | Bool errorGOP=false; |
---|
| 2298 | Int checkGOP=1; |
---|
| 2299 | Int numRefs = 1; |
---|
| 2300 | Int refList[MAX_NUM_REF_PICS+1]; |
---|
| 2301 | refList[0]=0; |
---|
| 2302 | Bool isOK[MAX_GOP]; |
---|
| 2303 | for(Int i=0; i<MAX_GOP; i++) |
---|
| 2304 | { |
---|
| 2305 | isOK[i]=false; |
---|
| 2306 | } |
---|
| 2307 | Int numOK=0; |
---|
| 2308 | |
---|
| 2309 | m_extraRPSs=0; |
---|
| 2310 | //start looping through frames in coding order until we can verify that the GOP structure is correct. |
---|
| 2311 | while(!verifiedGOP&&!errorGOP) |
---|
| 2312 | { |
---|
| 2313 | Int curGOP = (checkGOP-1)%m_iGOPSize; |
---|
| 2314 | Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + ge[curGOP].m_POC; |
---|
| 2315 | if(ge[curGOP].m_POC<0) |
---|
| 2316 | { |
---|
| 2317 | printf("\nError: found fewer Reference Picture Sets than GOPSize\n"); |
---|
| 2318 | errorGOP=true; |
---|
| 2319 | } |
---|
| 2320 | else |
---|
| 2321 | { |
---|
| 2322 | //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP. |
---|
| 2323 | Bool beforeI = false; |
---|
| 2324 | for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) |
---|
| 2325 | { |
---|
| 2326 | Int absPOC = curPOC+ge[curGOP].m_referencePics[i]; |
---|
| 2327 | if(absPOC < 0) |
---|
| 2328 | { |
---|
| 2329 | beforeI=true; |
---|
| 2330 | } |
---|
| 2331 | else |
---|
| 2332 | { |
---|
| 2333 | Bool found=false; |
---|
| 2334 | for(Int j=0; j<numRefs; j++) |
---|
| 2335 | { |
---|
| 2336 | if(refList[j]==absPOC) |
---|
| 2337 | { |
---|
| 2338 | found=true; |
---|
| 2339 | for(Int k=0; k<m_iGOPSize; k++) |
---|
| 2340 | { |
---|
| 2341 | if(absPOC%m_iGOPSize == ge[k].m_POC%m_iGOPSize) |
---|
| 2342 | { |
---|
| 2343 | if(ge[k].m_temporalId==ge[curGOP].m_temporalId) |
---|
| 2344 | { |
---|
| 2345 | ge[k].m_refPic = true; |
---|
| 2346 | } |
---|
| 2347 | ge[curGOP].m_usedByCurrPic[i]=ge[k].m_temporalId<=ge[curGOP].m_temporalId; |
---|
| 2348 | } |
---|
| 2349 | } |
---|
| 2350 | } |
---|
| 2351 | } |
---|
| 2352 | if(!found) |
---|
| 2353 | { |
---|
| 2354 | printf("\nError: ref pic %d is not available for GOP frame %d\n",ge[curGOP].m_referencePics[i],curGOP+1); |
---|
| 2355 | errorGOP=true; |
---|
| 2356 | } |
---|
| 2357 | } |
---|
| 2358 | } |
---|
| 2359 | if(!beforeI&&!errorGOP) |
---|
| 2360 | { |
---|
| 2361 | //all ref frames were present |
---|
| 2362 | if(!isOK[curGOP]) |
---|
| 2363 | { |
---|
| 2364 | numOK++; |
---|
| 2365 | isOK[curGOP]=true; |
---|
| 2366 | if(numOK==m_iGOPSize) |
---|
| 2367 | { |
---|
| 2368 | verifiedGOP=true; |
---|
| 2369 | } |
---|
| 2370 | } |
---|
| 2371 | } |
---|
| 2372 | else |
---|
| 2373 | { |
---|
| 2374 | //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0) |
---|
| 2375 | ge[m_iGOPSize+m_extraRPSs]=ge[curGOP]; |
---|
| 2376 | Int newRefs=0; |
---|
| 2377 | for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) |
---|
| 2378 | { |
---|
| 2379 | Int absPOC = curPOC+ge[curGOP].m_referencePics[i]; |
---|
| 2380 | if(absPOC>=0) |
---|
| 2381 | { |
---|
| 2382 | ge[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=ge[curGOP].m_referencePics[i]; |
---|
| 2383 | ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=ge[curGOP].m_usedByCurrPic[i]; |
---|
| 2384 | newRefs++; |
---|
| 2385 | } |
---|
| 2386 | } |
---|
| 2387 | Int numPrefRefs = ge[curGOP].m_numRefPicsActive; |
---|
| 2388 | |
---|
| 2389 | for(Int offset = -1; offset>-checkGOP; offset--) |
---|
| 2390 | { |
---|
| 2391 | //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0. |
---|
| 2392 | Int offGOP = (checkGOP-1+offset)%m_iGOPSize; |
---|
| 2393 | Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + ge[offGOP].m_POC; |
---|
| 2394 | if(offPOC>=0&&ge[offGOP].m_temporalId<=ge[curGOP].m_temporalId) |
---|
| 2395 | { |
---|
| 2396 | Bool newRef=false; |
---|
| 2397 | for(Int i=0; i<numRefs; i++) |
---|
| 2398 | { |
---|
| 2399 | if(refList[i]==offPOC) |
---|
| 2400 | { |
---|
| 2401 | newRef=true; |
---|
| 2402 | } |
---|
| 2403 | } |
---|
| 2404 | for(Int i=0; i<newRefs; i++) |
---|
| 2405 | { |
---|
| 2406 | if(ge[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC) |
---|
| 2407 | { |
---|
| 2408 | newRef=false; |
---|
| 2409 | } |
---|
| 2410 | } |
---|
| 2411 | if(newRef) |
---|
| 2412 | { |
---|
| 2413 | Int insertPoint=newRefs; |
---|
| 2414 | //this picture can be added, find appropriate place in list and insert it. |
---|
| 2415 | if(ge[offGOP].m_temporalId==ge[curGOP].m_temporalId) |
---|
| 2416 | { |
---|
| 2417 | ge[offGOP].m_refPic = true; |
---|
| 2418 | } |
---|
| 2419 | for(Int j=0; j<newRefs; j++) |
---|
| 2420 | { |
---|
| 2421 | if(ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0) |
---|
| 2422 | { |
---|
| 2423 | insertPoint = j; |
---|
| 2424 | break; |
---|
| 2425 | } |
---|
| 2426 | } |
---|
| 2427 | Int prev = offPOC-curPOC; |
---|
| 2428 | Int prevUsed = ge[offGOP].m_temporalId<=ge[curGOP].m_temporalId; |
---|
| 2429 | for(Int j=insertPoint; j<newRefs+1; j++) |
---|
| 2430 | { |
---|
| 2431 | Int newPrev = ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]; |
---|
| 2432 | Int newUsed = ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]; |
---|
| 2433 | ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev; |
---|
| 2434 | ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed; |
---|
| 2435 | prevUsed=newUsed; |
---|
| 2436 | prev=newPrev; |
---|
| 2437 | } |
---|
| 2438 | newRefs++; |
---|
| 2439 | } |
---|
| 2440 | } |
---|
| 2441 | if(newRefs>=numPrefRefs) |
---|
| 2442 | { |
---|
| 2443 | break; |
---|
| 2444 | } |
---|
| 2445 | } |
---|
| 2446 | ge[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs; |
---|
| 2447 | ge[m_iGOPSize+m_extraRPSs].m_POC = curPOC; |
---|
| 2448 | if (m_extraRPSs == 0) |
---|
| 2449 | { |
---|
| 2450 | ge[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0; |
---|
| 2451 | ge[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0; |
---|
| 2452 | } |
---|
| 2453 | else |
---|
| 2454 | { |
---|
| 2455 | Int rIdx = m_iGOPSize + m_extraRPSs - 1; |
---|
| 2456 | Int refPOC = ge[rIdx].m_POC; |
---|
| 2457 | Int refPics = ge[rIdx].m_numRefPics; |
---|
| 2458 | Int newIdc=0; |
---|
| 2459 | for(Int i = 0; i<= refPics; i++) |
---|
| 2460 | { |
---|
| 2461 | Int deltaPOC = ((i != refPics)? ge[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0 |
---|
| 2462 | Int absPOCref = refPOC+deltaPOC; |
---|
| 2463 | Int refIdc = 0; |
---|
| 2464 | for (Int j = 0; j < ge[m_iGOPSize+m_extraRPSs].m_numRefPics; j++) |
---|
| 2465 | { |
---|
| 2466 | if ( (absPOCref - curPOC) == ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]) |
---|
| 2467 | { |
---|
| 2468 | if (ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]) |
---|
| 2469 | { |
---|
| 2470 | refIdc = 1; |
---|
| 2471 | } |
---|
| 2472 | else |
---|
| 2473 | { |
---|
| 2474 | refIdc = 2; |
---|
| 2475 | } |
---|
| 2476 | } |
---|
| 2477 | } |
---|
| 2478 | ge[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc; |
---|
| 2479 | newIdc++; |
---|
| 2480 | } |
---|
| 2481 | ge[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1; |
---|
| 2482 | ge[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc; |
---|
| 2483 | ge[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - ge[m_iGOPSize+m_extraRPSs].m_POC; |
---|
| 2484 | } |
---|
| 2485 | curGOP=m_iGOPSize+m_extraRPSs; |
---|
| 2486 | m_extraRPSs++; |
---|
| 2487 | } |
---|
| 2488 | numRefs=0; |
---|
| 2489 | for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) |
---|
| 2490 | { |
---|
| 2491 | Int absPOC = curPOC+ge[curGOP].m_referencePics[i]; |
---|
| 2492 | if(absPOC >= 0) |
---|
| 2493 | { |
---|
| 2494 | refList[numRefs]=absPOC; |
---|
| 2495 | numRefs++; |
---|
| 2496 | } |
---|
| 2497 | } |
---|
| 2498 | refList[numRefs]=curPOC; |
---|
| 2499 | numRefs++; |
---|
| 2500 | } |
---|
| 2501 | checkGOP++; |
---|
| 2502 | } |
---|
| 2503 | |
---|
| 2504 | return errorGOP; //update |
---|
| 2505 | } |
---|
| 2506 | #endif |
---|
[313] | 2507 | //! \} |
---|