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