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 | #if HHI_VSO_LS_TABLE |
---|
271 | ("LambdaScaleVSO", m_dLambdaScaleVSO , (Double) 1 , "Lambda Scaling for VSO") |
---|
272 | #else |
---|
273 | ("LambdaScaleVSO", m_dLambdaScaleVSO , (Double) 0.5 , "Lambda Scaling for VSO") |
---|
274 | #endif |
---|
275 | ("ForceLambdaScaleVSO", m_bForceLambdaScaleVSO , false , "Force using Lambda Scale VSO also in non-VSO-Mode") |
---|
276 | #if HHI_VSO_DIST_INT |
---|
277 | ("AllowNegDist", m_bAllowNegDist , true , "Allow negative Distortion in VSO") |
---|
278 | #endif |
---|
279 | |
---|
280 | ("NumberOfExternalRefs", m_iNumberOfExternalRefs , 0 , "Number of virtual external reference views") |
---|
281 | ("ERRefFile_%d,er_%d", m_pchERRefFileList , (char *) 0 , MAX_ERREF_VIEW_NUM , "virtual external reference view file name %d") |
---|
282 | ("VSERViewReferences_%d,evr_%d" , m_aaiERViewRefInd , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view") |
---|
283 | ("VSBaseViewReferences_%d,bvr_%d", m_aaiBaseViewRefInd , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view") |
---|
284 | #endif |
---|
285 | |
---|
286 | /* Coding tools */ |
---|
287 | ("MRG", m_bUseMRG, true, "merging of motion partitions") |
---|
288 | |
---|
289 | #if LM_CHROMA |
---|
290 | ("LMChroma", m_bUseLMChroma, true, "intra chroma prediction based on recontructed luma") |
---|
291 | #endif |
---|
292 | |
---|
293 | ("ALF", m_abUseALF, std::vector<Bool>(1,true), "Enables ALF") |
---|
294 | #if MTK_SAO |
---|
295 | ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO") |
---|
296 | #endif |
---|
297 | |
---|
298 | #if MQT_ALF_NPASS |
---|
299 | ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding") |
---|
300 | #endif |
---|
301 | #if HHI_RMP_SWITCH |
---|
302 | ("RMP", m_bUseRMP ,true, "Rectangular motion partition" ) |
---|
303 | #endif |
---|
304 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
305 | ("RoundingControlBipred", m_useRoundingControlBipred, false, "Rounding control for bi-prediction") |
---|
306 | #endif |
---|
307 | ("SliceMode", m_iSliceMode, 0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes") |
---|
308 | ("SliceArgument", m_iSliceArgument, 0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.") |
---|
309 | ("EntropySliceMode", m_iEntropySliceMode, 0, "0: Disable all entropy slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based entropy slices") |
---|
310 | ("EntropySliceArgument", m_iEntropySliceArgument,0, "if EntropySliceMode==1 SliceArgument represents max # of LCUs. if EntropySliceMode==2 EntropySliceArgument represents max # of bins.") |
---|
311 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
312 | ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true) |
---|
313 | #endif |
---|
314 | #if CONSTRAINED_INTRA_PRED |
---|
315 | ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction") |
---|
316 | #endif |
---|
317 | /* Misc. */ |
---|
318 | ("SEIpictureDigest", m_pictureDigestEnabled, false, "Control generation of picture_digest SEI messages\n" |
---|
319 | "\t1: use MD5\n" |
---|
320 | "\t0: disable") |
---|
321 | ("FEN", m_bUseFastEnc, false, "fast encoder setting") |
---|
322 | |
---|
323 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
324 | ("DMM", m_bUseDMM, false, "add depth modes intra") |
---|
325 | #endif |
---|
326 | #if HHI_MPI |
---|
327 | ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding") |
---|
328 | #endif |
---|
329 | |
---|
330 | /* Multiview tools */ |
---|
331 | #if DEPTH_MAP_GENERATION |
---|
332 | ("PredDepthMapGen", m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" ) |
---|
333 | #endif |
---|
334 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
335 | ("MultiviewMvPred", m_uiMultiviewMvPredMode, (UInt)0, "usage of predicted depth maps" ) |
---|
336 | ("MultiviewMvRegMode", m_uiMultiviewMvRegMode, (UInt)0, "regularization mode for multiview motion vectors" ) |
---|
337 | ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" ) |
---|
338 | #endif |
---|
339 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
340 | ("MultiviewResPred", m_uiMultiviewResPredMode, (UInt)0, "usage of inter-view residual prediction" ) |
---|
341 | #endif |
---|
342 | |
---|
343 | ("QpChangeFrame", m_iQpChangeFrame, PicOrderCnt(0), "start frame for QP change") |
---|
344 | ("QpChangeOffsetVideo", m_iQpChangeOffsetVideo, 0, "QP change offset for video") |
---|
345 | ("QpChangeOffsetDepth", m_iQpChangeOffsetDepth, 0, "QP change offset for depth") |
---|
346 | #if HHI_INTERVIEW_SKIP |
---|
347 | ("InterViewSkip", m_uiInterViewSkip, (UInt)0, "usage of interview skip" ) |
---|
348 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
349 | ("InterViewSkipLambdaScale", m_dInterViewSkipLambdaScale, (Double)8, "lambda scale for interview skip" ) |
---|
350 | #endif |
---|
351 | #endif |
---|
352 | |
---|
353 | /* Compatability with old style -1 FOO or -0 FOO options. */ |
---|
354 | ("1", doOldStyleCmdlineOn, "turn option <name> on") |
---|
355 | ("0", doOldStyleCmdlineOff, "turn option <name> off") |
---|
356 | ; |
---|
357 | |
---|
358 | po::setDefaults(opts); |
---|
359 | const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv); |
---|
360 | |
---|
361 | for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++) |
---|
362 | { |
---|
363 | fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it); |
---|
364 | } |
---|
365 | |
---|
366 | if (argc == 1 || do_help) |
---|
367 | { |
---|
368 | /* argc == 1: no options have been specified */ |
---|
369 | po::doHelp(cout, opts); |
---|
370 | xPrintUsage(); |
---|
371 | return false; |
---|
372 | } |
---|
373 | |
---|
374 | /* |
---|
375 | * Set any derived parameters |
---|
376 | */ |
---|
377 | /* convert std::string to c string for compatability */ |
---|
378 | m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
379 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
---|
380 | |
---|
381 | |
---|
382 | // GT FIX |
---|
383 | if ( m_bUsingDepthMaps ) |
---|
384 | { |
---|
385 | for(Int i = 0; i < m_pchDepthReconFileList.size() ; i++) |
---|
386 | { |
---|
387 | if ((m_pchDepthInputFileList[i] != NULL) && (m_pchReconFileList[i] != NULL) && (i < m_iNumberOfViews) ) |
---|
388 | { |
---|
389 | if (m_pchDepthReconFileList[i] == NULL ) |
---|
390 | { |
---|
391 | xAppendToFileNameEnd( m_pchReconFileList[i], "_depth", m_pchDepthReconFileList[i] ); |
---|
392 | } |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | m_pchDepthReconFileList[i] = NULL; |
---|
397 | } |
---|
398 | }; |
---|
399 | } |
---|
400 | // GT FIX END |
---|
401 | |
---|
402 | if (m_iRateGOPSize == -1) |
---|
403 | { |
---|
404 | /* if rateGOPSize has not been specified, the default value is GOPSize */ |
---|
405 | m_iRateGOPSize = m_iGOPSize; |
---|
406 | } |
---|
407 | |
---|
408 | // compute source padding size |
---|
409 | if ( m_bUsePAD ) |
---|
410 | { |
---|
411 | if ( m_iSourceWidth%MAX_PAD_SIZE ) |
---|
412 | { |
---|
413 | m_aiPad[0] = (m_iSourceWidth/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceWidth; |
---|
414 | } |
---|
415 | |
---|
416 | if ( m_iSourceHeight%MAX_PAD_SIZE ) |
---|
417 | { |
---|
418 | m_aiPad[1] = (m_iSourceHeight/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceHeight; |
---|
419 | } |
---|
420 | } |
---|
421 | m_iSourceWidth += m_aiPad[0]; |
---|
422 | m_iSourceHeight += m_aiPad[1]; |
---|
423 | |
---|
424 | //GT QP Depth |
---|
425 | if ( m_adQP.size() < 2 ) |
---|
426 | { |
---|
427 | m_adQP.push_back( m_adQP[0] ); |
---|
428 | }; |
---|
429 | for (UInt uiK = 0; uiK < m_adQP.size(); uiK++) |
---|
430 | { |
---|
431 | m_aiQP.push_back( (Int)( m_adQP[uiK] ) ); |
---|
432 | } |
---|
433 | //GT QP Depth end |
---|
434 | |
---|
435 | #if HHI_VSO |
---|
436 | m_bUseVSO = m_bUseVSO && m_bUsingDepthMaps && (m_uiVSOMode != 0); |
---|
437 | #endif |
---|
438 | |
---|
439 | xCleanUpVectors(); |
---|
440 | |
---|
441 | #if HHI_VSO |
---|
442 | if ( m_abUseALF .size() < 2) |
---|
443 | m_abUseALF .push_back( m_bUseVSO ? false : m_abUseALF[0] ); |
---|
444 | |
---|
445 | if ( m_abUseRDOQ.size() < 2) |
---|
446 | m_abUseRDOQ.push_back( m_bUseVSO ? true : m_abUseRDOQ[0] ); |
---|
447 | |
---|
448 | if ( m_abLoopFilterDisable.size() < 2) |
---|
449 | m_abLoopFilterDisable.push_back( m_bUseVSO ? true : m_abLoopFilterDisable[0] ); |
---|
450 | |
---|
451 | if (m_abUseSAO.size() < 2) |
---|
452 | m_abUseSAO.push_back ( m_bUseVSO ? false : m_abUseSAO[0] ); |
---|
453 | #else |
---|
454 | if ( m_abUseALF .size() < 2) |
---|
455 | m_abUseALF .push_back( m_abUseALF[0] ); |
---|
456 | |
---|
457 | if ( m_abUseRDOQ.size() < 2) |
---|
458 | m_abUseRDOQ.push_back( m_abUseRDOQ[0] ); |
---|
459 | |
---|
460 | if ( m_abLoopFilterDisable.size() < 2) |
---|
461 | m_abLoopFilterDisable.push_back( m_abLoopFilterDisable[0] ); |
---|
462 | |
---|
463 | if (m_abUseSAO.size() < 2) |
---|
464 | m_abUseSAO.push_back ( m_abUseSAO[0] ); |
---|
465 | #endif |
---|
466 | |
---|
467 | #if HHI_VSO |
---|
468 | if ( m_bUseVSO ) |
---|
469 | { |
---|
470 | if ( m_iNumberOfExternalRefs != 0 ) |
---|
471 | { |
---|
472 | xCleanUpVector( m_aaiERViewRefInd, vector<Int>() ); |
---|
473 | xCleanUpVector( m_aaiBaseViewRefInd, vector<Int>() ); |
---|
474 | } |
---|
475 | else |
---|
476 | { |
---|
477 | m_aaiERViewRefInd .clear(); |
---|
478 | m_aaiERViewRefInd .resize( m_iNumberOfViews ); |
---|
479 | m_aaiERViewRefLutInd.clear(); |
---|
480 | m_aaiERViewRefLutInd.resize( m_iNumberOfViews ); |
---|
481 | m_aaiBaseViewRefInd .clear(); |
---|
482 | m_aaiBaseViewRefInd .resize( m_iNumberOfViews ); |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | #if HHI_VSO_LS_TABLE |
---|
487 | // Q&D |
---|
488 | Double adLambdaScaleTable[] = |
---|
489 | { 0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755, |
---|
490 | 0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648, |
---|
491 | 0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542, |
---|
492 | 0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388, |
---|
493 | 0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100, |
---|
494 | 0.753550, 0.800000 |
---|
495 | }; |
---|
496 | AOT( (m_aiQP[1] < 0) || (m_aiQP[1] > 51)); |
---|
497 | m_dLambdaScaleVSO *= adLambdaScaleTable[m_aiQP[1]]; |
---|
498 | #endif |
---|
499 | #endif |
---|
500 | |
---|
501 | // set global variables |
---|
502 | xSetGlobal(); |
---|
503 | |
---|
504 | // read and check camera parameters |
---|
505 | #if HHI_VSO |
---|
506 | if ( m_bUseVSO && m_uiVSOMode == 4) |
---|
507 | { |
---|
508 | m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig ); |
---|
509 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
510 | m_uiInputBitDepth, |
---|
511 | (UInt)m_iCodedCamParPrecision, |
---|
512 | m_FrameSkip, |
---|
513 | (UInt)m_iFrameToBeEncoded, |
---|
514 | m_pchCameraParameterFile, |
---|
515 | m_pchBaseViewCameraNumbers, |
---|
516 | NULL, |
---|
517 | m_cRenModStrParser.getSynthViews(), |
---|
518 | LOG2_DISP_PREC_LUT ); |
---|
519 | } |
---|
520 | else if ( m_bUseVSO && m_uiVSOMode != 4 ) |
---|
521 | { |
---|
522 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
523 | m_uiInputBitDepth, |
---|
524 | (UInt)m_iCodedCamParPrecision, |
---|
525 | m_FrameSkip, |
---|
526 | (UInt)m_iFrameToBeEncoded, |
---|
527 | m_pchCameraParameterFile, |
---|
528 | m_pchBaseViewCameraNumbers, |
---|
529 | m_pchVSOConfig, |
---|
530 | NULL, |
---|
531 | LOG2_DISP_PREC_LUT ); |
---|
532 | } |
---|
533 | else |
---|
534 | { |
---|
535 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
536 | m_uiInputBitDepth, |
---|
537 | (UInt)m_iCodedCamParPrecision, |
---|
538 | m_FrameSkip, |
---|
539 | (UInt)m_iFrameToBeEncoded, |
---|
540 | m_pchCameraParameterFile, |
---|
541 | m_pchBaseViewCameraNumbers, |
---|
542 | NULL, |
---|
543 | NULL, |
---|
544 | LOG2_DISP_PREC_LUT ); |
---|
545 | } |
---|
546 | #else |
---|
547 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
548 | m_uiInputBitDepth, |
---|
549 | (UInt)m_iCodedCamParPrecision, |
---|
550 | m_FrameSkip, |
---|
551 | (UInt)m_iFrameToBeEncoded, |
---|
552 | m_pchCameraParameterFile, |
---|
553 | m_pchBaseViewCameraNumbers, |
---|
554 | NULL, |
---|
555 | NULL, |
---|
556 | LOG2_DISP_PREC_LUT ); |
---|
557 | #endif |
---|
558 | |
---|
559 | |
---|
560 | // check validity of input parameters |
---|
561 | xCheckParameter(); |
---|
562 | m_cCameraData.check( false, true ); |
---|
563 | |
---|
564 | // print-out parameters |
---|
565 | xPrintParameter(); |
---|
566 | |
---|
567 | return true; |
---|
568 | } |
---|
569 | |
---|
570 | // ==================================================================================================================== |
---|
571 | // Private member functions |
---|
572 | // ==================================================================================================================== |
---|
573 | |
---|
574 | Bool confirmPara(Bool bflag, const char* message); |
---|
575 | |
---|
576 | Void TAppEncCfg::xCheckParameter() |
---|
577 | { |
---|
578 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
579 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
580 | // check range of parameters |
---|
581 | #if ENABLE_IBDI |
---|
582 | xConfirmPara( m_uiInternalBitDepth > 0 && (int)m_uiBitIncrement != -1, "InternalBitDepth and BitIncrement may not be specified simultaneously"); |
---|
583 | #else |
---|
584 | xConfirmPara( m_uiInputBitDepth < 8, "InputBitDepth must be at least 8" ); |
---|
585 | #endif |
---|
586 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
---|
587 | xConfirmPara( m_iFrameToBeEncoded <= 0, "Total Number Of Frames encoded must be more than 1" ); |
---|
588 | xConfirmPara( m_iGOPSize < 1 , "GOP Size must be more than 1" ); |
---|
589 | #if DCM_DECODING_REFRESH |
---|
590 | xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2, "Decoding Refresh Type must be equal to 0, 1 or 2" ); |
---|
591 | #endif |
---|
592 | //GT QP Depth |
---|
593 | xConfirmPara( m_aiQP[0] < 0 || m_aiQP[0] > 51, "QP exceeds supported range (0 to 51)" ); |
---|
594 | if ( m_aiQP.size() >= 2 ) |
---|
595 | { |
---|
596 | xConfirmPara( m_aiQP[1] < 0 || m_aiQP[1] > 51, "QP Depth exceeds supported range (0 to 51)" ); |
---|
597 | } |
---|
598 | //GT QP Depth End |
---|
599 | #if MQT_ALF_NPASS |
---|
600 | xConfirmPara( m_iALFEncodePassReduction < 0 || m_iALFEncodePassReduction > 2, "ALFEncodePassReduction must be equal to 0, 1 or 2"); |
---|
601 | #endif |
---|
602 | xConfirmPara( m_iLoopFilterAlphaC0Offset < -26 || m_iLoopFilterAlphaC0Offset > 26, "Loop Filter Alpha Offset exceeds supported range (-26 to 26)" ); |
---|
603 | xConfirmPara( m_iLoopFilterBetaOffset < -26 || m_iLoopFilterBetaOffset > 26, "Loop Filter Beta Offset exceeds supported range (-26 to 26)"); |
---|
604 | xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2, "Fast Search Mode is not supported value (0:Full search 1:Diamond 2:PMVFAST)" ); |
---|
605 | xConfirmPara( m_iSearchRange < 0 , "Search Range must be more than 0" ); |
---|
606 | xConfirmPara( m_bipredSearchRange < 0 , "Search Range must be more than 0" ); |
---|
607 | xConfirmPara( m_iMaxDeltaQP > 7, "Absolute Delta QP exceeds supported range (0 to 7)" ); |
---|
608 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
---|
609 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
---|
610 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
---|
611 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
---|
612 | xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Frame width should be multiple of minimum CU size"); |
---|
613 | xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Frame height should be multiple of minimum CU size"); |
---|
614 | |
---|
615 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
---|
616 | xConfirmPara( m_uiQuadtreeTULog2MinSize > 5, "QuadtreeTULog2MinSize must be 5 or smaller."); |
---|
617 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2, "QuadtreeTULog2MaxSize must be 2 or greater."); |
---|
618 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
---|
619 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
---|
620 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
621 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
622 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
---|
623 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
---|
624 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
---|
625 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
626 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
---|
627 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
628 | |
---|
629 | xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 2, "SliceMode exceeds supported range (0 to 2)" ); |
---|
630 | if (m_iSliceMode!=0) |
---|
631 | { |
---|
632 | xConfirmPara( m_iSliceArgument < 1 , "SliceArgument should be larger than or equal to 1" ); |
---|
633 | } |
---|
634 | xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" ); |
---|
635 | if (m_iEntropySliceMode!=0) |
---|
636 | { |
---|
637 | xConfirmPara( m_iEntropySliceArgument < 1 , "EntropySliceArgument should be larger than or equal to 1" ); |
---|
638 | } |
---|
639 | |
---|
640 | xConfirmPara( m_iSymbolMode < 0 || m_iSymbolMode > 1, "SymbolMode must be equal to 0 or 1" ); |
---|
641 | |
---|
642 | // Check MultiView stuff |
---|
643 | xConfirmPara ( m_iNumberOfViews > MAX_INPUT_VIEW_NUM , "NumberOfViews must be less than or equal to MAX_INPUT_VIEW_NUM"); |
---|
644 | xConfirmPara ( Int( m_pchInputFileList.size() ) < m_iNumberOfViews, "Number of InputFiles must be greater than or equal to NumberOfViews" ); |
---|
645 | xConfirmPara ( Int( m_pchReconFileList.size() ) < m_iNumberOfViews, "Number of ReconFiles must be greater than or equal to NumberOfViews" ); |
---|
646 | |
---|
647 | xConfirmPara ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5, "CodedCamParsPrecision must be in range of 0..5" ); |
---|
648 | #if DEPTH_MAP_GENERATION |
---|
649 | xConfirmPara ( m_uiPredDepthMapGeneration > 2, "PredDepthMapGen must be less than or equal to 2" ); |
---|
650 | xConfirmPara ( m_uiPredDepthMapGeneration >= 2 && !m_bUsingDepthMaps, "PredDepthMapGen >= 2 requires CodeDepthMaps = 1" ); |
---|
651 | #endif |
---|
652 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
653 | xConfirmPara ( m_uiMultiviewMvPredMode > 7, "MultiviewMvPred must be less than or equal to 7" ); |
---|
654 | xConfirmPara ( m_uiMultiviewMvPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewMvPred > 0 requires PredDepthMapGen > 0" ); |
---|
655 | xConfirmPara ( m_uiMultiviewMvRegMode > 1, "MultiviewMvRegMode must be less than or equal to 1" ); |
---|
656 | xConfirmPara ( m_dMultiviewMvRegLambdaScale < 0.0, "MultiviewMvRegLambdaScale must not be negative" ); |
---|
657 | if( m_uiMultiviewMvRegMode ) |
---|
658 | { |
---|
659 | xConfirmPara ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews, "MultiviewMvRegMode > 0 requires the presence of input depth maps" ); |
---|
660 | } |
---|
661 | #endif |
---|
662 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
663 | xConfirmPara ( m_uiMultiviewResPredMode > 1, "MultiviewResPred must be less than or equal to 1" ); |
---|
664 | xConfirmPara ( m_uiMultiviewResPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewResPred > 0 requires PredDepthMapGen > 0" ); |
---|
665 | #endif |
---|
666 | |
---|
667 | #if HHI_INTERVIEW_SKIP |
---|
668 | xConfirmPara ( m_uiInterViewSkip > 1, "RenderingSkipMode > 1 not supported" ); |
---|
669 | xConfirmPara ( m_uiInterViewSkip > 0 && !m_bUsingDepthMaps, "RenderingSkipMode > 0 requires CodeDepthMaps = 1" ); |
---|
670 | #endif |
---|
671 | if( m_bUsingDepthMaps ) |
---|
672 | { |
---|
673 | xConfirmPara ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews, "Number of DepthInputFiles must be greater than or equal to NumberOfViews" ); |
---|
674 | xConfirmPara ( Int( m_pchDepthReconFileList.size() ) < m_iNumberOfViews, "Number of DepthReconFiles must be greater than or equal to NumberOfViews" ); |
---|
675 | |
---|
676 | #if HHI_VSO |
---|
677 | if( m_bUseVSO ) |
---|
678 | { |
---|
679 | xConfirmPara( m_pchCameraParameterFile == 0 , "CameraParameterFile must be given"); |
---|
680 | xConfirmPara( m_pchVSOConfig == 0 , "VSO Setup string must be given"); |
---|
681 | xConfirmPara( m_pchBaseViewCameraNumbers == 0 , "BaseViewCameraNumbers must be given" ); |
---|
682 | xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size(), "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" ); |
---|
683 | xConfirmPara( m_uiVSOMode < 0 || m_uiVSOMode > 4 , "VSO Mode must be greater than or equal to 0 and less than 5"); |
---|
684 | xConfirmPara( m_iNumberOfExternalRefs > MAX_ERREF_VIEW_NUM, "NumberOfExternalRefs must be less than of equal to TAppMVEncCfg::MAX_ERREF_VIEW_NUM" ); |
---|
685 | xConfirmPara( Int( m_pchERRefFileList .size() ) < m_iNumberOfExternalRefs, "Number of ERRefFileFiles must be greater than or equal to NumberOfExternalRefs" ); |
---|
686 | } |
---|
687 | #endif |
---|
688 | } |
---|
689 | |
---|
690 | #if DCM_COMB_LIST |
---|
691 | #if !HHI_NO_LowDelayCoding |
---|
692 | xConfirmPara( m_bUseLComb==false && m_bUseLDC==false, "LComb can only be 0 if LowDelayCoding is 1" ); |
---|
693 | #else |
---|
694 | xConfirmPara( m_bUseLComb==false, "LComb can only be 0 if LowDelayCoding is 1" ); |
---|
695 | #endif |
---|
696 | #endif |
---|
697 | |
---|
698 | // max CU width and height should be power of 2 |
---|
699 | UInt ui = m_uiMaxCUWidth; |
---|
700 | while(ui) |
---|
701 | { |
---|
702 | ui >>= 1; |
---|
703 | if( (ui & 1) == 1) |
---|
704 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
---|
705 | } |
---|
706 | ui = m_uiMaxCUHeight; |
---|
707 | while(ui) |
---|
708 | { |
---|
709 | ui >>= 1; |
---|
710 | if( (ui & 1) == 1) |
---|
711 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
---|
712 | } |
---|
713 | |
---|
714 | // SBACRD is supported only for SBAC |
---|
715 | if ( m_iSymbolMode == 0 ) |
---|
716 | { |
---|
717 | m_bUseSBACRD = false; |
---|
718 | } |
---|
719 | |
---|
720 | #undef xConfirmPara |
---|
721 | if (check_failed) |
---|
722 | { |
---|
723 | exit(EXIT_FAILURE); |
---|
724 | } |
---|
725 | } |
---|
726 | |
---|
727 | template <class T> |
---|
728 | Void |
---|
729 | TAppEncCfg::xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid ) |
---|
730 | { |
---|
731 | Int iFirstInv = (Int)rcVec.size(); |
---|
732 | for( Int iIdx = 0; iIdx < (Int)rcVec.size(); iIdx++ ) |
---|
733 | { |
---|
734 | if( rcVec[ iIdx ] == rcInvalid ) |
---|
735 | { |
---|
736 | iFirstInv = iIdx; |
---|
737 | break; |
---|
738 | } |
---|
739 | } |
---|
740 | while( (Int)rcVec.size() > iFirstInv ) |
---|
741 | { |
---|
742 | rcVec.pop_back(); |
---|
743 | } |
---|
744 | } |
---|
745 | |
---|
746 | Void |
---|
747 | TAppEncCfg::xCleanUpVectors() |
---|
748 | { |
---|
749 | xCleanUpVector( m_pchInputFileList, (char*)0 ); |
---|
750 | xCleanUpVector( m_pchDepthInputFileList, (char*)0 ); |
---|
751 | xCleanUpVector( m_pchReconFileList, (char*)0 ); |
---|
752 | xCleanUpVector( m_pchDepthReconFileList, (char*)0 ); |
---|
753 | |
---|
754 | #if HHI_VSO |
---|
755 | if ( m_bUseVSO) |
---|
756 | { |
---|
757 | xCleanUpVector( m_pchERRefFileList, (char*)0 ); |
---|
758 | } |
---|
759 | #endif |
---|
760 | } |
---|
761 | |
---|
762 | /** \todo use of global variables should be removed later |
---|
763 | */ |
---|
764 | Void TAppEncCfg::xSetGlobal() |
---|
765 | { |
---|
766 | // set max CU width & height |
---|
767 | g_uiMaxCUWidth = m_uiMaxCUWidth; |
---|
768 | g_uiMaxCUHeight = m_uiMaxCUHeight; |
---|
769 | |
---|
770 | // compute actual CU depth with respect to config depth and max transform size |
---|
771 | g_uiAddCUDepth = 0; |
---|
772 | while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth ) ) ) g_uiAddCUDepth++; |
---|
773 | |
---|
774 | m_uiMaxCUDepth += g_uiAddCUDepth; |
---|
775 | g_uiAddCUDepth++; |
---|
776 | g_uiMaxCUDepth = m_uiMaxCUDepth; |
---|
777 | |
---|
778 | // set internal bit-depth and constants |
---|
779 | #if ENABLE_IBDI |
---|
780 | if ((int)m_uiBitIncrement != -1) |
---|
781 | { |
---|
782 | g_uiBitDepth = m_uiInputBitDepth; |
---|
783 | g_uiBitIncrement = m_uiBitIncrement; |
---|
784 | m_uiInternalBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
785 | } |
---|
786 | else |
---|
787 | { |
---|
788 | g_uiBitDepth = min(8u, m_uiInputBitDepth); |
---|
789 | if (m_uiInternalBitDepth == 0) { |
---|
790 | /* default increement = 2 */ |
---|
791 | m_uiInternalBitDepth = 2 + g_uiBitDepth; |
---|
792 | } |
---|
793 | g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth; |
---|
794 | } |
---|
795 | #else |
---|
796 | #if FULL_NBIT |
---|
797 | g_uiBitDepth = m_uiInternalBitDepth; |
---|
798 | g_uiBitIncrement = 0; |
---|
799 | #else |
---|
800 | g_uiBitDepth = 8; |
---|
801 | g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth; |
---|
802 | #endif |
---|
803 | #endif |
---|
804 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
805 | g_dDeltaDCsQuantOffset = Double(g_uiBitIncrement) - 2.0; |
---|
806 | #endif |
---|
807 | |
---|
808 | g_uiBASE_MAX = ((1<<(g_uiBitDepth))-1); |
---|
809 | |
---|
810 | #if IBDI_NOCLIP_RANGE |
---|
811 | g_uiIBDI_MAX = g_uiBASE_MAX << g_uiBitIncrement; |
---|
812 | #else |
---|
813 | g_uiIBDI_MAX = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1); |
---|
814 | #endif |
---|
815 | |
---|
816 | if (m_uiOutputBitDepth == 0) |
---|
817 | { |
---|
818 | m_uiOutputBitDepth = m_uiInternalBitDepth; |
---|
819 | } |
---|
820 | } |
---|
821 | |
---|
822 | Void TAppEncCfg::xPrintParameter() |
---|
823 | { |
---|
824 | printf("\n"); |
---|
825 | for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++) |
---|
826 | { |
---|
827 | printf("Input File %i : %s\n", iCounter, m_pchInputFileList[iCounter]); |
---|
828 | } |
---|
829 | for( Int iCounter = 0; iCounter < (Int)m_pchDepthInputFileList.size(); iCounter++) |
---|
830 | { |
---|
831 | printf("DepthInput File %i : %s\n", iCounter, m_pchDepthInputFileList[iCounter]); |
---|
832 | } |
---|
833 | printf("Bitstream File : %s\n", m_pchBitstreamFile ); |
---|
834 | for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++) |
---|
835 | { |
---|
836 | printf("Reconstruction File %i : %s\n", iCounter, m_pchReconFileList[iCounter]); |
---|
837 | } |
---|
838 | |
---|
839 | for( Int iCounter = 0; iCounter<(Int)m_pchDepthReconFileList.size(); iCounter++) |
---|
840 | { |
---|
841 | printf("Reconstruction Depth File %i : %s\n", iCounter, m_pchDepthReconFileList[iCounter]); |
---|
842 | } |
---|
843 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_aiPad[0], m_iSourceHeight-m_aiPad[1], m_iFrameRate ); |
---|
844 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
---|
845 | printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded ); |
---|
846 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
---|
847 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
848 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
---|
849 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
---|
850 | printf("Motion search range : %d\n", m_iSearchRange ); |
---|
851 | #if DCM_DECODING_REFRESH |
---|
852 | printf("Decoding refresh type : %d\n", m_iDecodingRefreshType ); |
---|
853 | #endif |
---|
854 | printf("QP : %5.2f\n", m_adQP[0] ); |
---|
855 | printf("QP Depth : %5.2f\n", m_adQP[ m_adQP.size() < 2 ? 0 : 1] ); |
---|
856 | printf("Coded Picture Store Size : %d\n", m_uiCodedPictureStoreSize); |
---|
857 | printf("GOP size : %d\n", m_iGOPSize ); |
---|
858 | printf("Rate GOP size : %d\n", m_iRateGOPSize ); |
---|
859 | printf("Internal bit depth : %d\n", m_uiInternalBitDepth ); |
---|
860 | |
---|
861 | if ( m_iSymbolMode == 0 ) |
---|
862 | { |
---|
863 | printf("Entropy coder : VLC\n"); |
---|
864 | } |
---|
865 | else if( m_iSymbolMode == 1 ) |
---|
866 | { |
---|
867 | printf("Entropy coder : CABAC\n"); |
---|
868 | } |
---|
869 | else if( m_iSymbolMode == 2 ) |
---|
870 | { |
---|
871 | printf("Entropy coder : PIPE\n"); |
---|
872 | } |
---|
873 | else |
---|
874 | { |
---|
875 | assert(0); |
---|
876 | } |
---|
877 | |
---|
878 | printf("GOP Format String : %s\n", m_cInputFormatString.c_str() ); |
---|
879 | printf("Loop Filter Disabled : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0, m_abLoopFilterDisable[1] ? 1 : 0 ); |
---|
880 | printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision); |
---|
881 | |
---|
882 | #if HHI_VSO |
---|
883 | printf("Force use of Lambda Scale : %d\n", m_bForceLambdaScaleVSO ); |
---|
884 | |
---|
885 | if ( m_bUseVSO ) |
---|
886 | { |
---|
887 | printf("VSO Lambda Scale : %5.2f\n", m_dLambdaScaleVSO ); |
---|
888 | printf("VSO Mode : %d\n", m_uiVSOMode ); |
---|
889 | printf("VSO Config : %s\n", m_pchVSOConfig ); |
---|
890 | #if HHI_VSO_DIST_INT |
---|
891 | printf("VSO Negative Distortion : %d\n", m_bAllowNegDist ? 1 : 0); |
---|
892 | #endif |
---|
893 | } |
---|
894 | #endif |
---|
895 | |
---|
896 | |
---|
897 | printf("\n"); |
---|
898 | |
---|
899 | printf("TOOL CFG GENERAL: "); |
---|
900 | printf("IBD:%d ", !!g_uiBitIncrement); |
---|
901 | printf("HAD:%d ", m_bUseHADME ); |
---|
902 | printf("SRD:%d ", m_bUseSBACRD ); |
---|
903 | printf("SQP:%d ", m_uiDeltaQpRD ); |
---|
904 | printf("ASR:%d ", m_bUseASR ); |
---|
905 | printf("PAD:%d ", m_bUsePAD ); |
---|
906 | printf("LDC:%d ", m_bUseLDC ); |
---|
907 | #if DCM_COMB_LIST |
---|
908 | printf("LComb:%d ", m_bUseLComb ); |
---|
909 | printf("LCMod:%d ", m_bLCMod ); |
---|
910 | #endif |
---|
911 | printf("FEN:%d ", m_bUseFastEnc ); |
---|
912 | printf("RQT:%d ", 1 ); |
---|
913 | printf("MRG:%d ", m_bUseMRG ); // SOPH: Merge Mode |
---|
914 | #if LM_CHROMA |
---|
915 | printf("LMC:%d ", m_bUseLMChroma ); |
---|
916 | #endif |
---|
917 | #if HHI_RMP_SWITCH |
---|
918 | printf("RMP:%d ", m_bUseRMP); |
---|
919 | #endif |
---|
920 | printf("Slice:%d ",m_iSliceMode); |
---|
921 | if (m_iSliceMode!=0) |
---|
922 | { |
---|
923 | printf("(%d) ", m_iSliceArgument); |
---|
924 | } |
---|
925 | printf("EntropySlice:%d ",m_iEntropySliceMode); |
---|
926 | if (m_iEntropySliceMode!=0) |
---|
927 | { |
---|
928 | printf("(%d) ", m_iEntropySliceArgument); |
---|
929 | } |
---|
930 | #if CONSTRAINED_INTRA_PRED |
---|
931 | printf("CIP:%d ", m_bUseConstrainedIntraPred); |
---|
932 | #endif |
---|
933 | #if MTK_SAO |
---|
934 | #endif |
---|
935 | printf("\n"); |
---|
936 | printf("TOOL CFG VIDEO : "); |
---|
937 | printf("ALF:%d ", (m_abUseALF [0] ? 1 : 0) ); |
---|
938 | printf("SAO:%d ", (m_abUseSAO [0] ? 1 : 0)); |
---|
939 | printf("RDQ:%d ", (m_abUseRDOQ[0] ? 1 : 0) ); |
---|
940 | printf("\n"); |
---|
941 | |
---|
942 | printf("TOOL CFG DEPTH : "); |
---|
943 | printf("ALF:%d ", (m_abUseALF [1] ? 1 : 0)); |
---|
944 | printf("SAO:%d ", (m_abUseSAO [1] ? 1 : 0)); |
---|
945 | printf("RDQ:%d ", (m_abUseRDOQ[1] ? 1 : 0)); |
---|
946 | #if HHI_VSO |
---|
947 | printf("VSO:%d ", m_bUseVSO ); |
---|
948 | #endif |
---|
949 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
950 | printf("DMM:%d ", m_bUseDMM ); |
---|
951 | #endif |
---|
952 | #if HHI_MPI |
---|
953 | printf("MVI:%d ", m_bUseMVI ? 1 : 0 ); |
---|
954 | #endif |
---|
955 | printf("\n"); |
---|
956 | |
---|
957 | fflush(stdout); |
---|
958 | } |
---|
959 | |
---|
960 | Void TAppEncCfg::xPrintUsage() |
---|
961 | { |
---|
962 | printf( " <name> = ALF - adaptive loop filter\n"); |
---|
963 | printf( " IBD - bit-depth increasement\n"); |
---|
964 | printf( " GPB - generalized B instead of P in low-delay mode\n"); |
---|
965 | printf( " HAD - hadamard ME for fractional-pel\n"); |
---|
966 | printf( " SRD - SBAC based RD estimation\n"); |
---|
967 | printf( " RDQ - RDOQ\n"); |
---|
968 | printf( " LDC - low-delay mode\n"); |
---|
969 | printf( " NRF - non-reference frame marking in last layer\n"); |
---|
970 | printf( " BQP - hier-P style QP assignment in low-delay mode\n"); |
---|
971 | printf( " PAD - automatic source padding of multiple of 16\n"); |
---|
972 | printf( " ASR - adaptive motion search range\n"); |
---|
973 | printf( " FEN - fast encoder setting\n"); |
---|
974 | printf( " MRG - merging of motion partitions\n"); // SOPH: Merge Mode |
---|
975 | |
---|
976 | #if LM_CHROMA |
---|
977 | printf( " LMC - intra chroma prediction based on luma\n"); |
---|
978 | #endif |
---|
979 | |
---|
980 | printf( "\n" ); |
---|
981 | printf( " Example 1) TAppEncoder.exe -c test.cfg -q 32 -g 8 -f 9 -s 64 -h 4\n"); |
---|
982 | printf(" -> QP 32, hierarchical-B GOP 8, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n"); |
---|
983 | printf( " Example 2) TAppEncoder.exe -c test.cfg -q 32 -g 4 -f 9 -s 64 -h 4 -1 LDC\n"); |
---|
984 | printf(" -> QP 32, hierarchical-P GOP 4, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n"); |
---|
985 | } |
---|
986 | |
---|
987 | Bool confirmPara(Bool bflag, const char* message) |
---|
988 | { |
---|
989 | if (!bflag) |
---|
990 | return false; |
---|
991 | |
---|
992 | printf("Error: %s\n",message); |
---|
993 | return true; |
---|
994 | } |
---|
995 | |
---|
996 | /* helper function */ |
---|
997 | /* for handling "-1/-0 FOO" */ |
---|
998 | void translateOldStyleCmdline(const char* value, po::Options& opts, const std::string& arg) |
---|
999 | { |
---|
1000 | const char* argv[] = {arg.c_str(), value}; |
---|
1001 | /* replace some short names with their long name varients */ |
---|
1002 | if (arg == "LDC") |
---|
1003 | { |
---|
1004 | argv[0] = "LowDelayCoding"; |
---|
1005 | } |
---|
1006 | else if (arg == "RDQ") |
---|
1007 | { |
---|
1008 | argv[0] = "RDOQ"; |
---|
1009 | } |
---|
1010 | else if (arg == "HAD") |
---|
1011 | { |
---|
1012 | argv[0] = "HadamardME"; |
---|
1013 | } |
---|
1014 | else if (arg == "SRD") |
---|
1015 | { |
---|
1016 | argv[0] = "SBACRD"; |
---|
1017 | } |
---|
1018 | else if (arg == "IBD") |
---|
1019 | { |
---|
1020 | argv[0] = "BitIncrement"; |
---|
1021 | } |
---|
1022 | /* issue a warning for change in FEN behaviour */ |
---|
1023 | if (arg == "FEN") |
---|
1024 | { |
---|
1025 | /* xxx todo */ |
---|
1026 | } |
---|
1027 | po::storePair(opts, argv[0], argv[1]); |
---|
1028 | } |
---|
1029 | |
---|
1030 | void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg) |
---|
1031 | { |
---|
1032 | if (arg == "IBD") |
---|
1033 | { |
---|
1034 | translateOldStyleCmdline("4", opts, arg); |
---|
1035 | return; |
---|
1036 | } |
---|
1037 | translateOldStyleCmdline("1", opts, arg); |
---|
1038 | } |
---|
1039 | |
---|
1040 | void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg) |
---|
1041 | { |
---|
1042 | translateOldStyleCmdline("0", opts, arg); |
---|
1043 | } |
---|
1044 | |
---|
1045 | Void TAppEncCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName) |
---|
1046 | { |
---|
1047 | size_t iInLength = strlen(pchInputFileName); |
---|
1048 | size_t iAppendLength = strlen(pchStringToAppend); |
---|
1049 | |
---|
1050 | rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1); |
---|
1051 | Char* pCDot = strrchr(pchInputFileName,'.'); |
---|
1052 | pCDot = pCDot ? pCDot : pchInputFileName + iInLength; |
---|
1053 | size_t iCharsToDot = pCDot - pchInputFileName ; |
---|
1054 | size_t iCharsToEnd = iInLength - iCharsToDot; |
---|
1055 | strncpy(rpchOutputFileName , pchInputFileName , iCharsToDot ); |
---|
1056 | strncpy(rpchOutputFileName+ iCharsToDot , pchStringToAppend , iAppendLength); |
---|
1057 | strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength , pchInputFileName+iCharsToDot, iCharsToEnd ); |
---|
1058 | rpchOutputFileName[iInLength+iAppendLength] = '\0'; |
---|
1059 | } |
---|