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