[2] | 1 | |
---|
| 2 | |
---|
| 3 | /** \file TAppEncCfg.cpp |
---|
| 4 | \brief Handle encoder configuration parameters |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | #include <stdlib.h> |
---|
| 8 | #include <math.h> |
---|
| 9 | #include <cassert> |
---|
| 10 | #include <cstring> |
---|
| 11 | #include <string> |
---|
| 12 | #include "TAppEncCfg.h" |
---|
| 13 | #include "../../App/TAppCommon/program_options_lite.h" |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | using namespace std; |
---|
| 17 | namespace po = df::program_options_lite; |
---|
| 18 | |
---|
| 19 | /* configuration helper funcs */ |
---|
| 20 | void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg); |
---|
| 21 | void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg); |
---|
| 22 | |
---|
| 23 | // ==================================================================================================================== |
---|
| 24 | // Local constants |
---|
| 25 | // ==================================================================================================================== |
---|
| 26 | |
---|
| 27 | /// max value of source padding size |
---|
| 28 | /** \todo replace it by command line option |
---|
| 29 | */ |
---|
| 30 | #define MAX_PAD_SIZE 16 |
---|
| 31 | #define MAX_INPUT_VIEW_NUM 10 |
---|
| 32 | #define MAX_ERREF_VIEW_NUM 15 |
---|
| 33 | |
---|
| 34 | // ==================================================================================================================== |
---|
| 35 | // Constructor / destructor / initialization / destroy |
---|
| 36 | // ==================================================================================================================== |
---|
| 37 | |
---|
| 38 | TAppEncCfg::TAppEncCfg() |
---|
| 39 | { |
---|
| 40 | m_aidQP = NULL; |
---|
| 41 | //GT VSO |
---|
| 42 | m_aaiERViewRefLutInd.resize( MAX_INPUT_VIEW_NUM ); |
---|
| 43 | //GT VSO end |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | TAppEncCfg::~TAppEncCfg() |
---|
| 47 | { |
---|
| 48 | if ( m_aidQP ) |
---|
| 49 | { |
---|
| 50 | delete[] m_aidQP; m_aidQP = NULL; |
---|
| 51 | } |
---|
| 52 | for(Int i = 0; i< m_pchInputFileList.size(); i++ ) |
---|
| 53 | { |
---|
| 54 | if ( m_pchInputFileList[i] != NULL ) |
---|
| 55 | free (m_pchInputFileList[i]); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ ) |
---|
| 59 | { |
---|
| 60 | if ( m_pchDepthInputFileList[i] != NULL ) |
---|
| 61 | free (m_pchDepthInputFileList[i]); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | for(Int i = 0; i< m_pchReconFileList.size(); i++ ) |
---|
| 65 | { |
---|
| 66 | if ( m_pchReconFileList[i] != NULL ) |
---|
| 67 | free (m_pchReconFileList[i]); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | for(Int i = 0; i< m_pchERRefFileList.size(); i++ ) |
---|
| 71 | { |
---|
| 72 | if ( m_pchERRefFileList[i] != NULL ) |
---|
| 73 | free (m_pchERRefFileList[i]); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | if (m_pchBitstreamFile != NULL) |
---|
| 77 | free (m_pchBitstreamFile) ; |
---|
| 78 | |
---|
| 79 | for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ ) |
---|
| 80 | { |
---|
| 81 | if ( m_pchDepthReconFileList[i] != NULL ) |
---|
| 82 | free (m_pchDepthReconFileList[i]); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | if (m_pchCameraParameterFile != NULL) |
---|
| 86 | free (m_pchCameraParameterFile); |
---|
| 87 | |
---|
| 88 | if (m_pchBaseViewCameraNumbers != NULL) |
---|
| 89 | free (m_pchBaseViewCameraNumbers); |
---|
| 90 | |
---|
| 91 | if ( m_pchVSOConfig != NULL) |
---|
| 92 | free ( m_pchVSOConfig ); |
---|
| 93 | |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | Void TAppEncCfg::create() |
---|
| 97 | { |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | Void TAppEncCfg::destroy() |
---|
| 101 | { |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | // ==================================================================================================================== |
---|
| 105 | // Public member functions |
---|
| 106 | // ==================================================================================================================== |
---|
| 107 | |
---|
| 108 | /** \param argc number of arguments |
---|
| 109 | \param argv array of arguments |
---|
| 110 | \retval true when success |
---|
| 111 | */ |
---|
| 112 | Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] ) |
---|
| 113 | { |
---|
| 114 | bool do_help = false; |
---|
| 115 | |
---|
| 116 | string cfg_InputFile; |
---|
| 117 | string cfg_BitstreamFile; |
---|
| 118 | string cfg_ReconFile; |
---|
| 119 | string cfg_dQPFile; |
---|
| 120 | po::Options opts; |
---|
| 121 | opts.addOptions() |
---|
| 122 | ("help", do_help, false, "this help text") |
---|
| 123 | ("c", po::parseConfigFile, "configuration file name") |
---|
| 124 | |
---|
| 125 | /* File, I/O and source parameters */ |
---|
| 126 | ("InputFile_%d,i_%d", m_pchInputFileList, (char *) 0 , MAX_INPUT_VIEW_NUM , "original Yuv input file name %d") |
---|
| 127 | ("DepthInputFile_%d,di_%d", m_pchDepthInputFileList, (char *) 0 , MAX_INPUT_VIEW_NUM , "original Yuv depth input file name %d") |
---|
| 128 | ("ReconFile_%d,o_%d", m_pchReconFileList, (char *) 0 , MAX_INPUT_VIEW_NUM , "reconstructed Yuv output file name %d") |
---|
| 129 | ("DepthReconFile_%d,do_%d", m_pchDepthReconFileList, (char *) 0 , MAX_INPUT_VIEW_NUM , "reconstructed Yuv depth output file name %d") |
---|
| 130 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream output file name") |
---|
| 131 | |
---|
| 132 | ("CodeDepthMaps", m_bUsingDepthMaps, false, "Encode depth maps" ) |
---|
| 133 | ("CodedCamParsPrecision", m_iCodedCamParPrecision, STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" ) |
---|
| 134 | |
---|
| 135 | #ifdef WEIGHT_PRED |
---|
| 136 | ("weighted_pred_flag,-wpP", m_bUseWeightPred, false, "weighted prediction flag (P-Slices)") |
---|
| 137 | ("weighted_bipred_idc,-wpBidc", m_uiBiPredIdc, 0u, "weighted bipred idc (B-Slices)") |
---|
| 138 | #endif |
---|
| 139 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
---|
| 140 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
---|
| 141 | ("InputBitDepth", m_uiInputBitDepth, 8u, "bit-depth of input file") |
---|
| 142 | ("BitDepth", m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth") |
---|
| 143 | ("OutputBitDepth", m_uiOutputBitDepth, 0u, "bit-depth of output file") |
---|
| 144 | #if ENABLE_IBDI |
---|
| 145 | ("BitIncrement", m_uiBitIncrement, 0xffffffffu, "bit-depth increasement") |
---|
| 146 | #endif |
---|
| 147 | ("InternalBitDepth", m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)") |
---|
| 148 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "horizontal source padding size") |
---|
| 149 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "vertical source padding size") |
---|
| 150 | ("PAD", m_bUsePAD, false, "automatic source padding of multiple of 16" ) |
---|
| 151 | ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") |
---|
| 152 | ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") |
---|
| 153 | ("FramesToBeEncoded,f", m_iFrameToBeEncoded, 0, "number of frames to be encoded (default=all)") |
---|
| 154 | ("FrameToBeEncoded", m_iFrameToBeEncoded, 0, "depricated alias of FramesToBeEncoded") |
---|
| 155 | |
---|
| 156 | ("NumberOfViews", m_iNumberOfViews, 0, "Number of views") |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | /* Unit definition parameters */ |
---|
| 160 | ("MaxCUWidth", m_uiMaxCUWidth, 64u) |
---|
| 161 | ("MaxCUHeight", m_uiMaxCUHeight, 64u) |
---|
| 162 | /* todo: remove defaults from MaxCUSize */ |
---|
| 163 | ("MaxCUSize,s", m_uiMaxCUWidth, 64u, "max CU size") |
---|
| 164 | ("MaxCUSize,s", m_uiMaxCUHeight, 64u, "max CU size") |
---|
| 165 | ("MaxPartitionDepth,h", m_uiMaxCUDepth, 4u, "CU depth") |
---|
| 166 | |
---|
| 167 | ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u) |
---|
| 168 | ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u) |
---|
| 169 | |
---|
| 170 | ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u) |
---|
| 171 | ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u) |
---|
| 172 | |
---|
| 173 | /* Coding structure paramters */ |
---|
| 174 | ("CodecPictureStoreSize,cpss", m_uiCodedPictureStoreSize, 16u, "Size of coded picture Buffer") |
---|
| 175 | #if DCM_DECODING_REFRESH |
---|
| 176 | ("DecodingRefreshType,-dr",m_iDecodingRefreshType, 0, "intra refresh, (0:none 1:CDR 2:IDR)") |
---|
| 177 | #endif |
---|
| 178 | ("GOPSize,g", m_iGOPSize, 1, "GOP size of temporal structure") |
---|
| 179 | ("RateGOPSize,-rg",m_iRateGOPSize, -1, "GOP size of hierarchical QP assignment (-1: implies inherit GOPSize value)") |
---|
| 180 | #if !SB_NO_LowDelayCoding |
---|
| 181 | ("LowDelayCoding", m_bUseLDC, false, "low-delay mode") |
---|
| 182 | #endif |
---|
| 183 | #if DCM_COMB_LIST |
---|
| 184 | ("ListCombination, -lc", m_bUseLComb, true, "combined reference list for uni-prediction in B-slices") |
---|
| 185 | ("LCModification", m_bLCMod, false, "enables signalling of combined reference list derivation") |
---|
| 186 | #endif |
---|
| 187 | |
---|
| 188 | ("GOPFormatString,gfs", m_cInputFormatString, string(""), "Group of pictures") |
---|
| 189 | |
---|
| 190 | /* motion options */ |
---|
| 191 | ("FastSearch", m_iFastSearch, 1, "0:Full search 1:Diamond 2:PMVFAST") |
---|
| 192 | ("SearchRange,-sr",m_iSearchRange, 96, "motion search range") |
---|
| 193 | ("BipredSearchRange", m_bipredSearchRange, 4, "motion search range for bipred refinement") |
---|
| 194 | ("HadamardME", m_bUseHADME, true, "hadamard ME for fractional-pel") |
---|
| 195 | ("ASR", m_bUseASR, false, "adaptive motion search range") |
---|
| 196 | |
---|
| 197 | /* Quantization parameters */ |
---|
| 198 | ("QP,q", m_adQP, std::vector<double>(1,32), "Qp value, if value is float, QP is switched once during encoding, if two values are given the second is used for depth") |
---|
| 199 | ("DeltaQpRD,-dqr",m_uiDeltaQpRD, 0u, "max dQp offset for slice") |
---|
| 200 | ("MaxDeltaQP,d", m_iMaxDeltaQP, 0, "max dQp offset for block") |
---|
| 201 | ("dQPFile,m", m_pchdQPFile , (char*) 0, "dQP file name") |
---|
| 202 | ("RDOQ", m_abUseRDOQ, std::vector<Bool>(1,true), "Enable RDOQ") |
---|
| 203 | ("TemporalLayerQPOffset_L0,-tq0", m_aiTLayerQPOffset[0], 0, "QP offset of temporal layer 0") |
---|
| 204 | ("TemporalLayerQPOffset_L1,-tq1", m_aiTLayerQPOffset[1], 0, "QP offset of temporal layer 1") |
---|
| 205 | ("TemporalLayerQPOffset_L2,-tq2", m_aiTLayerQPOffset[2], 0, "QP offset of temporal layer 2") |
---|
| 206 | ("TemporalLayerQPOffset_L3,-tq3", m_aiTLayerQPOffset[3], 0, "QP offset of temporal layer 3") |
---|
| 207 | ("TemporalLayerQPOffset_L4,-tq4", m_aiTLayerQPOffset[4], 0, "QP offset of temporal layer 3") |
---|
| 208 | ("TemporalLayerQPOffset_L5,-tq5", m_aiTLayerQPOffset[5], 0, "QP offset of temporal layer 3") |
---|
| 209 | ("TemporalLayerQPOffset_L6,-tq6", m_aiTLayerQPOffset[6], 0, "QP offset of temporal layer 3") |
---|
| 210 | ("TemporalLayerQPOffset_L7,-tq7", m_aiTLayerQPOffset[7], 0, "QP offset of temporal layer 3") |
---|
| 211 | ("TemporalLayerQPOffset_L8,-tq8", m_aiTLayerQPOffset[8], 0, "QP offset of temporal layer 3") |
---|
| 212 | ("TemporalLayerQPOffset_L9,-tq9", m_aiTLayerQPOffset[9], 0, "QP offset of temporal layer 3") |
---|
| 213 | |
---|
| 214 | /* Entropy coding parameters */ |
---|
| 215 | ("SymbolMode,-sym", m_iSymbolMode, 1, "symbol mode (0=VLC, 1=SBAC)") |
---|
| 216 | ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation") |
---|
| 217 | |
---|
| 218 | /* Deblocking filter parameters */ |
---|
| 219 | ("LoopFilterDisable", m_abLoopFilterDisable, std::vector<Bool>(1,false), "Disables LoopFilter") |
---|
| 220 | ("LoopFilterAlphaC0Offset", m_iLoopFilterAlphaC0Offset, 0) |
---|
| 221 | ("LoopFilterBetaOffset", m_iLoopFilterBetaOffset, 0 ) |
---|
| 222 | |
---|
| 223 | //GT campara |
---|
| 224 | ("CameraParameterFile,cpf", m_pchCameraParameterFile, (Char *) 0, "Camera Parameter File Name") |
---|
| 225 | ("BaseViewCameraNumbers" , m_pchBaseViewCameraNumbers, (Char *) 0, "Numbers of base views") |
---|
| 226 | //GT campara end |
---|
| 227 | |
---|
| 228 | /* View Synthesis Optimization */ |
---|
| 229 | //GT VSO |
---|
| 230 | ("VSOConfig", m_pchVSOConfig , (Char *) 0 , "VSO configuration") |
---|
| 231 | ("VSO", m_bUseVSO , false , "Use VSO" ) |
---|
| 232 | // GT: For development, will be removed later |
---|
| 233 | ("VSOMode", m_uiVSOMode , (UInt) 4 , "VSO Mode") |
---|
| 234 | ("LambdaScaleVSO", m_dLambdaScaleVSO , (Double) 0.6 , "Lambda Scaling for VSO") |
---|
| 235 | ("ForceLambdaScaleVSO", m_bForceLambdaScaleVSO , false , "Force using Lambda Scale VSO also in non-VSO-Mode") |
---|
| 236 | #if RDO_DIST_INT |
---|
| 237 | ("AllowNegDist", m_bAllowNegDist , true , "Allow negative Distortion in VSO") |
---|
| 238 | #endif |
---|
| 239 | |
---|
| 240 | ("NumberOfExternalRefs", m_iNumberOfExternalRefs , 0 , "Number of virtual external reference views") |
---|
| 241 | ("ERRefFile_%d,er_%d", m_pchERRefFileList , (char *) 0 , MAX_ERREF_VIEW_NUM , "virtual external reference view file name %d") |
---|
| 242 | ("VSERViewReferences_%d,evr_%d" , m_aaiERViewRefInd , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view") |
---|
| 243 | ("VSBaseViewReferences_%d,bvr_%d", m_aaiBaseViewRefInd , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view") |
---|
| 244 | //GT VSO end |
---|
| 245 | |
---|
| 246 | /* Coding tools */ |
---|
| 247 | ("MRG", m_bUseMRG, true, "merging of motion partitions") |
---|
| 248 | |
---|
| 249 | #if LM_CHROMA |
---|
| 250 | ("LMChroma", m_bUseLMChroma, true, "intra chroma prediction based on recontructed luma") |
---|
| 251 | #endif |
---|
| 252 | |
---|
| 253 | ("ALF", m_abUseALF, std::vector<Bool>(1,true), "Enables ALF") |
---|
| 254 | #if MTK_SAO |
---|
| 255 | ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO") |
---|
| 256 | #endif |
---|
| 257 | |
---|
| 258 | #if MQT_ALF_NPASS |
---|
| 259 | ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding") |
---|
| 260 | #endif |
---|
| 261 | #if HHI_RMP_SWITCH |
---|
| 262 | ("RMP", m_bUseRMP ,true, "Rectangular motion partition" ) |
---|
| 263 | #endif |
---|
| 264 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
| 265 | ("RoundingControlBipred", m_useRoundingControlBipred, false, "Rounding control for bi-prediction") |
---|
| 266 | #endif |
---|
| 267 | ("SliceMode", m_iSliceMode, 0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes") |
---|
| 268 | ("SliceArgument", m_iSliceArgument, 0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.") |
---|
| 269 | ("EntropySliceMode", m_iEntropySliceMode, 0, "0: Disable all entropy slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based entropy slices") |
---|
| 270 | ("EntropySliceArgument", m_iEntropySliceArgument,0, "if EntropySliceMode==1 SliceArgument represents max # of LCUs. if EntropySliceMode==2 EntropySliceArgument represents max # of bins.") |
---|
| 271 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
| 272 | ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true) |
---|
| 273 | #endif |
---|
| 274 | #if CONSTRAINED_INTRA_PRED |
---|
| 275 | ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction") |
---|
| 276 | #endif |
---|
| 277 | /* Misc. */ |
---|
| 278 | ("SEIpictureDigest", m_pictureDigestEnabled, false, "Control generation of picture_digest SEI messages\n" |
---|
| 279 | "\t1: use MD5\n" |
---|
| 280 | "\t0: disable") |
---|
| 281 | ("FEN", m_bUseFastEnc, false, "fast encoder setting") |
---|
| 282 | |
---|
| 283 | #if HHI_DMM_INTRA |
---|
| 284 | ("DMM", m_bUseDepthModelModes, false, "add depth modes intra") |
---|
| 285 | #endif |
---|
| 286 | ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding") |
---|
| 287 | |
---|
| 288 | /* Multiview tools */ |
---|
| 289 | ("PredDepthMapGen", m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" ) |
---|
| 290 | ("MultiviewMvPred", m_uiMultiviewMvPredMode, (UInt)0, "usage of predicted depth maps" ) |
---|
| 291 | ("MultiviewMvRegMode", m_uiMultiviewMvRegMode, (UInt)0, "regularization mode for multiview motion vectors" ) |
---|
| 292 | ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" ) |
---|
| 293 | ("MultiviewResPred", m_uiMultiviewResPredMode, (UInt)0, "usage of inter-view residual prediction" ) |
---|
| 294 | |
---|
| 295 | ("OmitUnusedBlocks", m_bOmitUnusedBlocks, false, "omit blocks not used for rendering") |
---|
| 296 | |
---|
| 297 | ("QpChangeFrame", m_iQpChangeFrame, PicOrderCnt(0), "start frame for QP change") |
---|
| 298 | ("QpChangeOffsetVideo", m_iQpChangeOffsetVideo, 0, "QP change offset for video") |
---|
| 299 | ("QpChangeOffsetDepth", m_iQpChangeOffsetDepth, 0, "QP change offset for depth") |
---|
| 300 | #if SB_INTERVIEW_SKIP |
---|
| 301 | ("InterViewSkip", m_uiInterViewSkip, (UInt)0, "usage of interview skip" ) |
---|
| 302 | #if SB_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
| 303 | ("InterViewSkipLambdaScale", m_dInterViewSkipLambdaScale, (Double)8, "lambda scale for interview skip" ) |
---|
| 304 | #endif |
---|
| 305 | #endif |
---|
| 306 | |
---|
| 307 | /* Compatability with old style -1 FOO or -0 FOO options. */ |
---|
| 308 | ("1", doOldStyleCmdlineOn, "turn option <name> on") |
---|
| 309 | ("0", doOldStyleCmdlineOff, "turn option <name> off") |
---|
| 310 | ; |
---|
| 311 | |
---|
| 312 | po::setDefaults(opts); |
---|
| 313 | const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv); |
---|
| 314 | |
---|
| 315 | for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++) |
---|
| 316 | { |
---|
| 317 | fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it); |
---|
| 318 | } |
---|
| 319 | |
---|
| 320 | if (argc == 1 || do_help) |
---|
| 321 | { |
---|
| 322 | /* argc == 1: no options have been specified */ |
---|
| 323 | po::doHelp(cout, opts); |
---|
| 324 | xPrintUsage(); |
---|
| 325 | return false; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | /* |
---|
| 329 | * Set any derived parameters |
---|
| 330 | */ |
---|
| 331 | /* convert std::string to c string for compatability */ |
---|
| 332 | m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
| 333 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
---|
| 334 | |
---|
| 335 | |
---|
| 336 | // GT FIX |
---|
| 337 | if ( m_bUsingDepthMaps ) |
---|
| 338 | { |
---|
| 339 | for(Int i = 0; i < m_pchDepthReconFileList.size() ; i++) |
---|
| 340 | { |
---|
| 341 | if ((m_pchDepthInputFileList[i] != NULL) && (m_pchReconFileList[i] != NULL) && (i < m_iNumberOfViews) ) |
---|
| 342 | { |
---|
| 343 | if (m_pchDepthReconFileList[i] == NULL ) |
---|
| 344 | { |
---|
| 345 | xAppendToFileNameEnd( m_pchReconFileList[i], "_depth", m_pchDepthReconFileList[i] ); |
---|
| 346 | } |
---|
| 347 | } |
---|
| 348 | else |
---|
| 349 | { |
---|
| 350 | m_pchDepthReconFileList[i] = NULL; |
---|
| 351 | } |
---|
| 352 | }; |
---|
| 353 | } |
---|
| 354 | // GT FIX END |
---|
| 355 | |
---|
| 356 | if (m_iRateGOPSize == -1) |
---|
| 357 | { |
---|
| 358 | /* if rateGOPSize has not been specified, the default value is GOPSize */ |
---|
| 359 | m_iRateGOPSize = m_iGOPSize; |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | // compute source padding size |
---|
| 363 | if ( m_bUsePAD ) |
---|
| 364 | { |
---|
| 365 | if ( m_iSourceWidth%MAX_PAD_SIZE ) |
---|
| 366 | { |
---|
| 367 | m_aiPad[0] = (m_iSourceWidth/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceWidth; |
---|
| 368 | } |
---|
| 369 | |
---|
| 370 | if ( m_iSourceHeight%MAX_PAD_SIZE ) |
---|
| 371 | { |
---|
| 372 | m_aiPad[1] = (m_iSourceHeight/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceHeight; |
---|
| 373 | } |
---|
| 374 | } |
---|
| 375 | m_iSourceWidth += m_aiPad[0]; |
---|
| 376 | m_iSourceHeight += m_aiPad[1]; |
---|
| 377 | |
---|
| 378 | //GT QP Depth |
---|
| 379 | if ( m_adQP.size() < 2 ) |
---|
| 380 | { |
---|
| 381 | m_adQP.push_back( m_adQP[0] ); |
---|
| 382 | }; |
---|
| 383 | for (UInt uiK = 0; uiK < m_adQP.size(); uiK++) |
---|
| 384 | { |
---|
| 385 | m_aiQP.push_back( (Int)( m_adQP[uiK] ) ); |
---|
| 386 | } |
---|
| 387 | //GT QP Depth end |
---|
| 388 | |
---|
| 389 | //GT VSO |
---|
| 390 | m_bUseVSO = m_bUseVSO && m_bUsingDepthMaps && (m_uiVSOMode != 0); |
---|
| 391 | //GT VSO end |
---|
| 392 | |
---|
| 393 | xCleanUpVectors(); |
---|
| 394 | |
---|
| 395 | if ( m_abUseALF .size() < 2) |
---|
| 396 | m_abUseALF .push_back( m_bUseVSO ? false : m_abUseALF[0] ); |
---|
| 397 | |
---|
| 398 | if ( m_abUseRDOQ.size() < 2) |
---|
| 399 | m_abUseRDOQ.push_back( m_bUseVSO ? false : m_abUseRDOQ[0] ); |
---|
| 400 | |
---|
| 401 | if ( m_abLoopFilterDisable.size() < 2) |
---|
| 402 | m_abLoopFilterDisable.push_back( m_bUseVSO ? true : m_abLoopFilterDisable[0] ); |
---|
| 403 | |
---|
| 404 | if (m_abUseSAO.size() < 2) |
---|
| 405 | m_abUseSAO.push_back ( m_bUseVSO ? false : m_abUseSAO[0] ); |
---|
| 406 | |
---|
| 407 | //GT VSO |
---|
| 408 | if ( m_bUseVSO ) |
---|
| 409 | { |
---|
| 410 | if ( m_iNumberOfExternalRefs != 0 ) |
---|
| 411 | { |
---|
| 412 | xCleanUpVector( m_aaiERViewRefInd, vector<Int>() ); |
---|
| 413 | xCleanUpVector( m_aaiBaseViewRefInd, vector<Int>() ); |
---|
| 414 | } |
---|
| 415 | else |
---|
| 416 | { |
---|
| 417 | m_aaiERViewRefInd .clear(); |
---|
| 418 | m_aaiERViewRefInd .resize( m_iNumberOfViews ); |
---|
| 419 | m_aaiERViewRefLutInd.clear(); |
---|
| 420 | m_aaiERViewRefLutInd.resize( m_iNumberOfViews ); |
---|
| 421 | m_aaiBaseViewRefInd .clear(); |
---|
| 422 | m_aaiBaseViewRefInd .resize( m_iNumberOfViews ); |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | //GT VSO end |
---|
| 426 | |
---|
| 427 | // set global variables |
---|
| 428 | xSetGlobal(); |
---|
| 429 | |
---|
| 430 | // read and check camera parameters |
---|
| 431 | if ( m_bUseVSO && m_uiVSOMode == 4) |
---|
| 432 | { |
---|
| 433 | m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig ); |
---|
| 434 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
| 435 | m_uiInputBitDepth, |
---|
| 436 | (UInt)m_iCodedCamParPrecision, |
---|
| 437 | m_FrameSkip, |
---|
| 438 | (UInt)m_iFrameToBeEncoded, |
---|
| 439 | m_pchCameraParameterFile, |
---|
| 440 | m_pchBaseViewCameraNumbers, |
---|
| 441 | NULL, |
---|
| 442 | m_cRenModStrParser.getSynthViews(), |
---|
| 443 | LOG2_DISP_PREC_LUT ); |
---|
| 444 | } |
---|
| 445 | else if ( m_bUseVSO && m_uiVSOMode != 4 ) |
---|
| 446 | { |
---|
| 447 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
| 448 | m_uiInputBitDepth, |
---|
| 449 | (UInt)m_iCodedCamParPrecision, |
---|
| 450 | m_FrameSkip, |
---|
| 451 | (UInt)m_iFrameToBeEncoded, |
---|
| 452 | m_pchCameraParameterFile, |
---|
| 453 | m_pchBaseViewCameraNumbers, |
---|
| 454 | m_pchVSOConfig, |
---|
| 455 | NULL, |
---|
| 456 | LOG2_DISP_PREC_LUT ); |
---|
| 457 | } |
---|
| 458 | else |
---|
| 459 | { |
---|
| 460 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
| 461 | m_uiInputBitDepth, |
---|
| 462 | (UInt)m_iCodedCamParPrecision, |
---|
| 463 | m_FrameSkip, |
---|
| 464 | (UInt)m_iFrameToBeEncoded, |
---|
| 465 | m_pchCameraParameterFile, |
---|
| 466 | m_pchBaseViewCameraNumbers, |
---|
| 467 | NULL, |
---|
| 468 | NULL, |
---|
| 469 | LOG2_DISP_PREC_LUT ); |
---|
| 470 | |
---|
| 471 | } |
---|
| 472 | // check validity of input parameters |
---|
| 473 | xCheckParameter(); |
---|
| 474 | m_cCameraData.check( false, true ); |
---|
| 475 | |
---|
| 476 | // print-out parameters |
---|
| 477 | xPrintParameter(); |
---|
| 478 | |
---|
| 479 | return true; |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | // ==================================================================================================================== |
---|
| 483 | // Private member functions |
---|
| 484 | // ==================================================================================================================== |
---|
| 485 | |
---|
| 486 | Bool confirmPara(Bool bflag, const char* message); |
---|
| 487 | |
---|
| 488 | Void TAppEncCfg::xCheckParameter() |
---|
| 489 | { |
---|
| 490 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
| 491 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
| 492 | // check range of parameters |
---|
| 493 | #if ENABLE_IBDI |
---|
| 494 | xConfirmPara( m_uiInternalBitDepth > 0 && (int)m_uiBitIncrement != -1, "InternalBitDepth and BitIncrement may not be specified simultaneously"); |
---|
| 495 | #else |
---|
| 496 | xConfirmPara( m_uiInputBitDepth < 8, "InputBitDepth must be at least 8" ); |
---|
| 497 | #endif |
---|
| 498 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
---|
| 499 | xConfirmPara( m_iFrameToBeEncoded <= 0, "Total Number Of Frames encoded must be more than 1" ); |
---|
| 500 | xConfirmPara( m_iGOPSize < 1 , "GOP Size must be more than 1" ); |
---|
| 501 | #if DCM_DECODING_REFRESH |
---|
| 502 | xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2, "Decoding Refresh Type must be equal to 0, 1 or 2" ); |
---|
| 503 | #endif |
---|
| 504 | //GT QP Depth |
---|
| 505 | xConfirmPara( m_aiQP[0] < 0 || m_aiQP[0] > 51, "QP exceeds supported range (0 to 51)" ); |
---|
| 506 | if ( m_aiQP.size() >= 2 ) |
---|
| 507 | { |
---|
| 508 | xConfirmPara( m_aiQP[1] < 0 || m_aiQP[1] > 51, "QP Depth exceeds supported range (0 to 51)" ); |
---|
| 509 | } |
---|
| 510 | //GT QP Depth End |
---|
| 511 | #if MQT_ALF_NPASS |
---|
| 512 | xConfirmPara( m_iALFEncodePassReduction < 0 || m_iALFEncodePassReduction > 2, "ALFEncodePassReduction must be equal to 0, 1 or 2"); |
---|
| 513 | #endif |
---|
| 514 | xConfirmPara( m_iLoopFilterAlphaC0Offset < -26 || m_iLoopFilterAlphaC0Offset > 26, "Loop Filter Alpha Offset exceeds supported range (-26 to 26)" ); |
---|
| 515 | xConfirmPara( m_iLoopFilterBetaOffset < -26 || m_iLoopFilterBetaOffset > 26, "Loop Filter Beta Offset exceeds supported range (-26 to 26)"); |
---|
| 516 | xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2, "Fast Search Mode is not supported value (0:Full search 1:Diamond 2:PMVFAST)" ); |
---|
| 517 | xConfirmPara( m_iSearchRange < 0 , "Search Range must be more than 0" ); |
---|
| 518 | xConfirmPara( m_bipredSearchRange < 0 , "Search Range must be more than 0" ); |
---|
| 519 | xConfirmPara( m_iMaxDeltaQP > 7, "Absolute Delta QP exceeds supported range (0 to 7)" ); |
---|
| 520 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
---|
| 521 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
---|
| 522 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
---|
| 523 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
---|
| 524 | xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Frame width should be multiple of minimum CU size"); |
---|
| 525 | xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Frame height should be multiple of minimum CU size"); |
---|
| 526 | |
---|
| 527 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
---|
| 528 | xConfirmPara( m_uiQuadtreeTULog2MinSize > 5, "QuadtreeTULog2MinSize must be 5 or smaller."); |
---|
| 529 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2, "QuadtreeTULog2MaxSize must be 2 or greater."); |
---|
| 530 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
---|
| 531 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
---|
| 532 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
| 533 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
| 534 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
---|
| 535 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
---|
| 536 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
---|
| 537 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
| 538 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
---|
| 539 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
| 540 | |
---|
| 541 | xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 2, "SliceMode exceeds supported range (0 to 2)" ); |
---|
| 542 | if (m_iSliceMode!=0) |
---|
| 543 | { |
---|
| 544 | xConfirmPara( m_iSliceArgument < 1 , "SliceArgument should be larger than or equal to 1" ); |
---|
| 545 | } |
---|
| 546 | xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" ); |
---|
| 547 | if (m_iEntropySliceMode!=0) |
---|
| 548 | { |
---|
| 549 | xConfirmPara( m_iEntropySliceArgument < 1 , "EntropySliceArgument should be larger than or equal to 1" ); |
---|
| 550 | } |
---|
| 551 | |
---|
| 552 | xConfirmPara( m_iSymbolMode < 0 || m_iSymbolMode > 1, "SymbolMode must be equal to 0 or 1" ); |
---|
| 553 | |
---|
| 554 | // Check MultiView stuff |
---|
| 555 | xConfirmPara ( m_iNumberOfViews > MAX_INPUT_VIEW_NUM , "NumberOfViews must be less than or equal to MAX_INPUT_VIEW_NUM"); |
---|
| 556 | xConfirmPara ( Int( m_pchInputFileList.size() ) < m_iNumberOfViews, "Number of InputFiles must be greater than or equal to NumberOfViews" ); |
---|
| 557 | xConfirmPara ( Int( m_pchReconFileList.size() ) < m_iNumberOfViews, "Number of ReconFiles must be greater than or equal to NumberOfViews" ); |
---|
| 558 | |
---|
| 559 | xConfirmPara ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5, "CodedCamParsPrecision must be in range of 0..5" ); |
---|
| 560 | xConfirmPara ( m_uiPredDepthMapGeneration > 3, "PredDepthMapGen must be less than or equal to 3" ); |
---|
| 561 | xConfirmPara ( m_uiPredDepthMapGeneration >= 2 && !m_bUsingDepthMaps, "PredDepthMapGen >= 2 requires CodeDepthMaps = 1" ); |
---|
| 562 | xConfirmPara ( m_uiMultiviewMvPredMode > 7, "MultiviewMvPred must be less than or equal to 7" ); |
---|
| 563 | xConfirmPara ( m_uiMultiviewMvPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewMvPred > 0 requires PredDepthMapGen > 0" ); |
---|
| 564 | xConfirmPara ( m_uiMultiviewMvRegMode > 1, "MultiviewMvRegMode must be less than or equal to 1" ); |
---|
| 565 | xConfirmPara ( m_dMultiviewMvRegLambdaScale < 0.0, "MultiviewMvRegLambdaScale must not be negative" ); |
---|
| 566 | if( m_uiMultiviewMvRegMode ) |
---|
| 567 | { |
---|
| 568 | xConfirmPara ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews, "MultiviewMvRegMode > 0 requires the presence of input depth maps" ); |
---|
| 569 | } |
---|
| 570 | xConfirmPara ( m_uiMultiviewResPredMode > 1, "MultiviewResPred must be less than or equal to 1" ); |
---|
| 571 | xConfirmPara ( m_uiMultiviewResPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewResPred > 0 requires PredDepthMapGen > 0" ); |
---|
| 572 | |
---|
| 573 | #if SB_INTERVIEW_SKIP |
---|
| 574 | xConfirmPara ( m_uiInterViewSkip > 1, "RenderingSkipMode > 1 not supported" ); |
---|
| 575 | xConfirmPara ( m_uiInterViewSkip > 0 && !m_bUsingDepthMaps, "RenderingSkipMode > 0 requires CodeDepthMaps = 1" ); |
---|
| 576 | xConfirmPara ( m_uiInterViewSkip > 0 && !m_bOmitUnusedBlocks, "RenderingSkipMode > 0 requires OmitUnusedBlocks = 1" ); |
---|
| 577 | #endif |
---|
| 578 | if( m_bUsingDepthMaps ) |
---|
| 579 | { |
---|
| 580 | xConfirmPara ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews, "Number of DepthInputFiles must be greater than or equal to NumberOfViews" ); |
---|
| 581 | xConfirmPara ( Int( m_pchDepthReconFileList.size() ) < m_iNumberOfViews, "Number of DepthReconFiles must be greater than or equal to NumberOfViews" ); |
---|
| 582 | |
---|
| 583 | //GT VSO |
---|
| 584 | if( m_bUseVSO ) |
---|
| 585 | { |
---|
| 586 | xConfirmPara( m_pchCameraParameterFile == 0 , "CameraParameterFile must be given"); |
---|
| 587 | xConfirmPara( m_pchVSOConfig == 0 , "VSO Setup string must be given"); |
---|
| 588 | xConfirmPara( m_pchBaseViewCameraNumbers == 0 , "BaseViewCameraNumbers must be given" ); |
---|
| 589 | xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size(), "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" ); |
---|
| 590 | xConfirmPara( m_uiVSOMode < 0 || m_uiVSOMode > 4 , "VSO Mode must be greater than or equal to 0 and less than 5"); |
---|
| 591 | xConfirmPara( m_iNumberOfExternalRefs > MAX_ERREF_VIEW_NUM, "NumberOfExternalRefs must be less than of equal to TAppMVEncCfg::MAX_ERREF_VIEW_NUM" ); |
---|
| 592 | xConfirmPara( Int( m_pchERRefFileList .size() ) < m_iNumberOfExternalRefs, "Number of ERRefFileFiles must be greater than or equal to NumberOfExternalRefs" ); |
---|
| 593 | } |
---|
| 594 | //GT VSO end |
---|
| 595 | } |
---|
| 596 | |
---|
| 597 | #if DCM_COMB_LIST |
---|
| 598 | #if !SB_NO_LowDelayCoding |
---|
| 599 | xConfirmPara( m_bUseLComb==false && m_bUseLDC==false, "LComb can only be 0 if LowDelayCoding is 1" ); |
---|
| 600 | #else |
---|
| 601 | xConfirmPara( m_bUseLComb==false, "LComb can only be 0 if LowDelayCoding is 1" ); |
---|
| 602 | #endif |
---|
| 603 | #endif |
---|
| 604 | |
---|
| 605 | // max CU width and height should be power of 2 |
---|
| 606 | UInt ui = m_uiMaxCUWidth; |
---|
| 607 | while(ui) |
---|
| 608 | { |
---|
| 609 | ui >>= 1; |
---|
| 610 | if( (ui & 1) == 1) |
---|
| 611 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
---|
| 612 | } |
---|
| 613 | ui = m_uiMaxCUHeight; |
---|
| 614 | while(ui) |
---|
| 615 | { |
---|
| 616 | ui >>= 1; |
---|
| 617 | if( (ui & 1) == 1) |
---|
| 618 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | // SBACRD is supported only for SBAC |
---|
| 622 | if ( m_iSymbolMode == 0 ) |
---|
| 623 | { |
---|
| 624 | m_bUseSBACRD = false; |
---|
| 625 | } |
---|
| 626 | |
---|
| 627 | #undef xConfirmPara |
---|
| 628 | if (check_failed) |
---|
| 629 | { |
---|
| 630 | exit(EXIT_FAILURE); |
---|
| 631 | } |
---|
| 632 | } |
---|
| 633 | |
---|
| 634 | template <class T> |
---|
| 635 | Void |
---|
| 636 | TAppEncCfg::xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid ) |
---|
| 637 | { |
---|
| 638 | Int iFirstInv = (Int)rcVec.size(); |
---|
| 639 | for( Int iIdx = 0; iIdx < (Int)rcVec.size(); iIdx++ ) |
---|
| 640 | { |
---|
| 641 | if( rcVec[ iIdx ] == rcInvalid ) |
---|
| 642 | { |
---|
| 643 | iFirstInv = iIdx; |
---|
| 644 | break; |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | while( (Int)rcVec.size() > iFirstInv ) |
---|
| 648 | { |
---|
| 649 | rcVec.pop_back(); |
---|
| 650 | } |
---|
| 651 | } |
---|
| 652 | |
---|
| 653 | Void |
---|
| 654 | TAppEncCfg::xCleanUpVectors() |
---|
| 655 | { |
---|
| 656 | xCleanUpVector( m_pchInputFileList, (char*)0 ); |
---|
| 657 | xCleanUpVector( m_pchDepthInputFileList, (char*)0 ); |
---|
| 658 | xCleanUpVector( m_pchReconFileList, (char*)0 ); |
---|
| 659 | xCleanUpVector( m_pchDepthReconFileList, (char*)0 ); |
---|
| 660 | |
---|
| 661 | //GT VSO |
---|
| 662 | if ( m_bUseVSO) |
---|
| 663 | { |
---|
| 664 | xCleanUpVector( m_pchERRefFileList, (char*)0 ); |
---|
| 665 | } |
---|
| 666 | //GT VSO end |
---|
| 667 | } |
---|
| 668 | |
---|
| 669 | /** \todo use of global variables should be removed later |
---|
| 670 | */ |
---|
| 671 | Void TAppEncCfg::xSetGlobal() |
---|
| 672 | { |
---|
| 673 | // set max CU width & height |
---|
| 674 | g_uiMaxCUWidth = m_uiMaxCUWidth; |
---|
| 675 | g_uiMaxCUHeight = m_uiMaxCUHeight; |
---|
| 676 | |
---|
| 677 | // compute actual CU depth with respect to config depth and max transform size |
---|
| 678 | g_uiAddCUDepth = 0; |
---|
| 679 | while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth ) ) ) g_uiAddCUDepth++; |
---|
| 680 | |
---|
| 681 | m_uiMaxCUDepth += g_uiAddCUDepth; |
---|
| 682 | g_uiAddCUDepth++; |
---|
| 683 | g_uiMaxCUDepth = m_uiMaxCUDepth; |
---|
| 684 | |
---|
| 685 | // set internal bit-depth and constants |
---|
| 686 | #if ENABLE_IBDI |
---|
| 687 | if ((int)m_uiBitIncrement != -1) |
---|
| 688 | { |
---|
| 689 | g_uiBitDepth = m_uiInputBitDepth; |
---|
| 690 | g_uiBitIncrement = m_uiBitIncrement; |
---|
| 691 | m_uiInternalBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
| 692 | } |
---|
| 693 | else |
---|
| 694 | { |
---|
| 695 | g_uiBitDepth = min(8u, m_uiInputBitDepth); |
---|
| 696 | if (m_uiInternalBitDepth == 0) { |
---|
| 697 | /* default increement = 2 */ |
---|
| 698 | m_uiInternalBitDepth = 2 + g_uiBitDepth; |
---|
| 699 | } |
---|
| 700 | g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth; |
---|
| 701 | } |
---|
| 702 | #else |
---|
| 703 | #if FULL_NBIT |
---|
| 704 | g_uiBitDepth = m_uiInternalBitDepth; |
---|
| 705 | g_uiBitIncrement = 0; |
---|
| 706 | #else |
---|
| 707 | g_uiBitDepth = 8; |
---|
| 708 | g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth; |
---|
| 709 | #endif |
---|
| 710 | #endif |
---|
| 711 | |
---|
| 712 | g_uiBASE_MAX = ((1<<(g_uiBitDepth))-1); |
---|
| 713 | |
---|
| 714 | #if IBDI_NOCLIP_RANGE |
---|
| 715 | g_uiIBDI_MAX = g_uiBASE_MAX << g_uiBitIncrement; |
---|
| 716 | #else |
---|
| 717 | g_uiIBDI_MAX = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1); |
---|
| 718 | #endif |
---|
| 719 | |
---|
| 720 | if (m_uiOutputBitDepth == 0) |
---|
| 721 | { |
---|
| 722 | m_uiOutputBitDepth = m_uiInternalBitDepth; |
---|
| 723 | } |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | Void TAppEncCfg::xPrintParameter() |
---|
| 727 | { |
---|
| 728 | printf("\n"); |
---|
| 729 | for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++) |
---|
| 730 | { |
---|
| 731 | printf("Input File %i : %s\n", iCounter, m_pchInputFileList[iCounter]); |
---|
| 732 | } |
---|
| 733 | for( Int iCounter = 0; iCounter < (Int)m_pchDepthInputFileList.size(); iCounter++) |
---|
| 734 | { |
---|
| 735 | printf("DepthInput File %i : %s\n", iCounter, m_pchDepthInputFileList[iCounter]); |
---|
| 736 | } |
---|
| 737 | printf("Bitstream File : %s\n", m_pchBitstreamFile ); |
---|
| 738 | for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++) |
---|
| 739 | { |
---|
| 740 | printf("Reconstruction File %i : %s\n", iCounter, m_pchReconFileList[iCounter]); |
---|
| 741 | } |
---|
| 742 | |
---|
| 743 | for( Int iCounter = 0; iCounter<(Int)m_pchDepthReconFileList.size(); iCounter++) |
---|
| 744 | { |
---|
| 745 | printf("Reconstruction Depth File %i : %s\n", iCounter, m_pchDepthReconFileList[iCounter]); |
---|
| 746 | } |
---|
| 747 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_aiPad[0], m_iSourceHeight-m_aiPad[1], m_iFrameRate ); |
---|
| 748 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
---|
| 749 | printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded ); |
---|
| 750 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
---|
| 751 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
| 752 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
---|
| 753 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
---|
| 754 | printf("Motion search range : %d\n", m_iSearchRange ); |
---|
| 755 | #if DCM_DECODING_REFRESH |
---|
| 756 | printf("Decoding refresh type : %d\n", m_iDecodingRefreshType ); |
---|
| 757 | #endif |
---|
| 758 | printf("QP : %5.2f\n", m_adQP[0] ); |
---|
| 759 | printf("QP Depth : %5.2f\n", m_adQP[ m_adQP.size() < 2 ? 0 : 1] ); |
---|
| 760 | printf("Coded Picture Store Size : %d\n", m_uiCodedPictureStoreSize); |
---|
| 761 | printf("GOP size : %d\n", m_iGOPSize ); |
---|
| 762 | printf("Rate GOP size : %d\n", m_iRateGOPSize ); |
---|
| 763 | printf("Internal bit depth : %d\n", m_uiInternalBitDepth ); |
---|
| 764 | |
---|
| 765 | if ( m_iSymbolMode == 0 ) |
---|
| 766 | { |
---|
| 767 | printf("Entropy coder : VLC\n"); |
---|
| 768 | } |
---|
| 769 | else if( m_iSymbolMode == 1 ) |
---|
| 770 | { |
---|
| 771 | printf("Entropy coder : CABAC\n"); |
---|
| 772 | } |
---|
| 773 | else if( m_iSymbolMode == 2 ) |
---|
| 774 | { |
---|
| 775 | printf("Entropy coder : PIPE\n"); |
---|
| 776 | } |
---|
| 777 | else |
---|
| 778 | { |
---|
| 779 | assert(0); |
---|
| 780 | } |
---|
| 781 | |
---|
| 782 | printf("GOP Format String : %s\n", m_cInputFormatString.c_str() ); |
---|
| 783 | printf("Loop Filter Disabled : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0, m_abLoopFilterDisable[1] ? 1 : 0 ); |
---|
| 784 | printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision); |
---|
| 785 | |
---|
| 786 | //GT VSO |
---|
| 787 | printf("Force use of Lambda Scale : %d\n", m_bForceLambdaScaleVSO ); |
---|
| 788 | |
---|
| 789 | if ( m_bUseVSO ) |
---|
| 790 | { |
---|
| 791 | printf("VSO Lambda Scale : %5.2f\n", m_dLambdaScaleVSO ); |
---|
| 792 | printf("VSO Mode : %d\n", m_uiVSOMode ); |
---|
| 793 | printf("VSO Config : %s\n", m_pchVSOConfig ); |
---|
| 794 | #if RDO_DIST_INT |
---|
| 795 | printf("VSO Negative Distortion : %d\n", m_bAllowNegDist ? 1 : 0); |
---|
| 796 | #endif |
---|
| 797 | } |
---|
| 798 | //GT VSO end |
---|
| 799 | |
---|
| 800 | printf("Omit unused blocks : %d\n", (m_bOmitUnusedBlocks )?(1):(0)); |
---|
| 801 | |
---|
| 802 | printf("\n"); |
---|
| 803 | |
---|
| 804 | printf("TOOL CFG GENERAL: "); |
---|
| 805 | printf("IBD:%d ", !!g_uiBitIncrement); |
---|
| 806 | printf("HAD:%d ", m_bUseHADME ); |
---|
| 807 | printf("SRD:%d ", m_bUseSBACRD ); |
---|
| 808 | printf("SQP:%d ", m_uiDeltaQpRD ); |
---|
| 809 | printf("ASR:%d ", m_bUseASR ); |
---|
| 810 | printf("PAD:%d ", m_bUsePAD ); |
---|
| 811 | printf("LDC:%d ", m_bUseLDC ); |
---|
| 812 | #if DCM_COMB_LIST |
---|
| 813 | printf("LComb:%d ", m_bUseLComb ); |
---|
| 814 | printf("LCMod:%d ", m_bLCMod ); |
---|
| 815 | #endif |
---|
| 816 | printf("FEN:%d ", m_bUseFastEnc ); |
---|
| 817 | printf("RQT:%d ", 1 ); |
---|
| 818 | printf("MRG:%d ", m_bUseMRG ); // SOPH: Merge Mode |
---|
| 819 | #if LM_CHROMA |
---|
| 820 | printf("LMC:%d ", m_bUseLMChroma ); |
---|
| 821 | #endif |
---|
| 822 | #if HHI_RMP_SWITCH |
---|
| 823 | printf("RMP:%d ", m_bUseRMP); |
---|
| 824 | #endif |
---|
| 825 | printf("Slice:%d ",m_iSliceMode); |
---|
| 826 | if (m_iSliceMode!=0) |
---|
| 827 | { |
---|
| 828 | printf("(%d) ", m_iSliceArgument); |
---|
| 829 | } |
---|
| 830 | printf("EntropySlice:%d ",m_iEntropySliceMode); |
---|
| 831 | if (m_iEntropySliceMode!=0) |
---|
| 832 | { |
---|
| 833 | printf("(%d) ", m_iEntropySliceArgument); |
---|
| 834 | } |
---|
| 835 | #if CONSTRAINED_INTRA_PRED |
---|
| 836 | printf("CIP:%d ", m_bUseConstrainedIntraPred); |
---|
| 837 | #endif |
---|
| 838 | #if MTK_SAO |
---|
| 839 | #endif |
---|
| 840 | printf("\n"); |
---|
| 841 | printf("TOOL CFG VIDEO : "); |
---|
| 842 | printf("ALF:%d ", (m_abUseALF [0] ? 1 : 0) ); |
---|
| 843 | printf("SAO:%d ", (m_abUseSAO [0] ? 1 : 0)); |
---|
| 844 | printf("RDQ:%d ", (m_abUseRDOQ[0] ? 1 : 0) ); |
---|
| 845 | printf("\n"); |
---|
| 846 | |
---|
| 847 | printf("TOOL CFG DEPTH : "); |
---|
| 848 | printf("ALF:%d ", (m_abUseALF [1] ? 1 : 0)); |
---|
| 849 | printf("SAO:%d ", (m_abUseSAO [1] ? 1 : 0)); |
---|
| 850 | printf("RDQ:%d ", (m_abUseRDOQ[1] ? 1 : 0)); |
---|
| 851 | printf("VSO:%d ", m_bUseVSO ); |
---|
| 852 | #if HHI_DMM_INTRA |
---|
| 853 | printf("DMM:%d ", m_bUseDepthModelModes ); |
---|
| 854 | #endif |
---|
| 855 | printf("MVI:%d ", m_bUseMVI ? 1 : 0 ); |
---|
| 856 | printf("\n"); |
---|
| 857 | |
---|
| 858 | fflush(stdout); |
---|
| 859 | } |
---|
| 860 | |
---|
| 861 | Void TAppEncCfg::xPrintUsage() |
---|
| 862 | { |
---|
| 863 | printf( " <name> = ALF - adaptive loop filter\n"); |
---|
| 864 | printf( " IBD - bit-depth increasement\n"); |
---|
| 865 | printf( " GPB - generalized B instead of P in low-delay mode\n"); |
---|
| 866 | printf( " HAD - hadamard ME for fractional-pel\n"); |
---|
| 867 | printf( " SRD - SBAC based RD estimation\n"); |
---|
| 868 | printf( " RDQ - RDOQ\n"); |
---|
| 869 | printf( " LDC - low-delay mode\n"); |
---|
| 870 | printf( " NRF - non-reference frame marking in last layer\n"); |
---|
| 871 | printf( " BQP - hier-P style QP assignment in low-delay mode\n"); |
---|
| 872 | printf( " PAD - automatic source padding of multiple of 16\n"); |
---|
| 873 | printf( " ASR - adaptive motion search range\n"); |
---|
| 874 | printf( " FEN - fast encoder setting\n"); |
---|
| 875 | printf( " MRG - merging of motion partitions\n"); // SOPH: Merge Mode |
---|
| 876 | |
---|
| 877 | #if LM_CHROMA |
---|
| 878 | printf( " LMC - intra chroma prediction based on luma\n"); |
---|
| 879 | #endif |
---|
| 880 | |
---|
| 881 | printf( "\n" ); |
---|
| 882 | printf( " Example 1) TAppEncoder.exe -c test.cfg -q 32 -g 8 -f 9 -s 64 -h 4\n"); |
---|
| 883 | printf(" -> QP 32, hierarchical-B GOP 8, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n"); |
---|
| 884 | printf( " Example 2) TAppEncoder.exe -c test.cfg -q 32 -g 4 -f 9 -s 64 -h 4 -1 LDC\n"); |
---|
| 885 | printf(" -> QP 32, hierarchical-P GOP 4, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n"); |
---|
| 886 | } |
---|
| 887 | |
---|
| 888 | Bool confirmPara(Bool bflag, const char* message) |
---|
| 889 | { |
---|
| 890 | if (!bflag) |
---|
| 891 | return false; |
---|
| 892 | |
---|
| 893 | printf("Error: %s\n",message); |
---|
| 894 | return true; |
---|
| 895 | } |
---|
| 896 | |
---|
| 897 | /* helper function */ |
---|
| 898 | /* for handling "-1/-0 FOO" */ |
---|
| 899 | void translateOldStyleCmdline(const char* value, po::Options& opts, const std::string& arg) |
---|
| 900 | { |
---|
| 901 | const char* argv[] = {arg.c_str(), value}; |
---|
| 902 | /* replace some short names with their long name varients */ |
---|
| 903 | if (arg == "LDC") |
---|
| 904 | { |
---|
| 905 | argv[0] = "LowDelayCoding"; |
---|
| 906 | } |
---|
| 907 | else if (arg == "RDQ") |
---|
| 908 | { |
---|
| 909 | argv[0] = "RDOQ"; |
---|
| 910 | } |
---|
| 911 | else if (arg == "HAD") |
---|
| 912 | { |
---|
| 913 | argv[0] = "HadamardME"; |
---|
| 914 | } |
---|
| 915 | else if (arg == "SRD") |
---|
| 916 | { |
---|
| 917 | argv[0] = "SBACRD"; |
---|
| 918 | } |
---|
| 919 | else if (arg == "IBD") |
---|
| 920 | { |
---|
| 921 | argv[0] = "BitIncrement"; |
---|
| 922 | } |
---|
| 923 | /* issue a warning for change in FEN behaviour */ |
---|
| 924 | if (arg == "FEN") |
---|
| 925 | { |
---|
| 926 | /* xxx todo */ |
---|
| 927 | } |
---|
| 928 | po::storePair(opts, argv[0], argv[1]); |
---|
| 929 | } |
---|
| 930 | |
---|
| 931 | void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg) |
---|
| 932 | { |
---|
| 933 | if (arg == "IBD") |
---|
| 934 | { |
---|
| 935 | translateOldStyleCmdline("4", opts, arg); |
---|
| 936 | return; |
---|
| 937 | } |
---|
| 938 | translateOldStyleCmdline("1", opts, arg); |
---|
| 939 | } |
---|
| 940 | |
---|
| 941 | void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg) |
---|
| 942 | { |
---|
| 943 | translateOldStyleCmdline("0", opts, arg); |
---|
| 944 | } |
---|
| 945 | |
---|
| 946 | Void TAppEncCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName) |
---|
| 947 | { |
---|
| 948 | size_t iInLength = strlen(pchInputFileName); |
---|
| 949 | size_t iAppendLength = strlen(pchStringToAppend); |
---|
| 950 | |
---|
| 951 | rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1); |
---|
| 952 | Char* pCDot = strrchr(pchInputFileName,'.'); |
---|
| 953 | pCDot = pCDot ? pCDot : pchInputFileName + iInLength; |
---|
| 954 | size_t iCharsToDot = pCDot - pchInputFileName ; |
---|
| 955 | size_t iCharsToEnd = iInLength - iCharsToDot; |
---|
| 956 | strncpy(rpchOutputFileName , pchInputFileName , iCharsToDot ); |
---|
| 957 | strncpy(rpchOutputFileName+ iCharsToDot , pchStringToAppend , iAppendLength); |
---|
| 958 | strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength , pchInputFileName+iCharsToDot, iCharsToEnd ); |
---|
| 959 | rpchOutputFileName[iInLength+iAppendLength] = '\0'; |
---|
| 960 | } |
---|