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-2012, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TAppEncCfg.cpp |
---|
35 | \brief Handle encoder configuration parameters |
---|
36 | */ |
---|
37 | |
---|
38 | #include <stdlib.h> |
---|
39 | #include <cassert> |
---|
40 | #include <cstring> |
---|
41 | #include <string> |
---|
42 | #include "TLibCommon/TComRom.h" |
---|
43 | #include "TAppEncCfg.h" |
---|
44 | #include "TAppCommon/program_options_lite.h" |
---|
45 | |
---|
46 | #ifdef WIN32 |
---|
47 | #define strdup _strdup |
---|
48 | #endif |
---|
49 | |
---|
50 | using namespace std; |
---|
51 | namespace po = df::program_options_lite; |
---|
52 | |
---|
53 | //! \ingroup TAppEncoder |
---|
54 | //! \{ |
---|
55 | |
---|
56 | /* configuration helper funcs */ |
---|
57 | void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg); |
---|
58 | void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg); |
---|
59 | |
---|
60 | // ==================================================================================================================== |
---|
61 | // Local constants |
---|
62 | // ==================================================================================================================== |
---|
63 | |
---|
64 | /// max value of source padding size |
---|
65 | /** \todo replace it by command line option |
---|
66 | */ |
---|
67 | #define MAX_PAD_SIZE 16 |
---|
68 | |
---|
69 | // ==================================================================================================================== |
---|
70 | // Constructor / destructor / initialization / destroy |
---|
71 | // ==================================================================================================================== |
---|
72 | |
---|
73 | TAppEncCfg::TAppEncCfg() |
---|
74 | { |
---|
75 | m_aidQP = NULL; |
---|
76 | } |
---|
77 | |
---|
78 | TAppEncCfg::~TAppEncCfg() |
---|
79 | { |
---|
80 | if ( m_aidQP ) |
---|
81 | { |
---|
82 | delete[] m_aidQP; m_aidQP = NULL; |
---|
83 | } |
---|
84 | for(Int i = 0; i< m_pchInputFileList.size(); i++ ) |
---|
85 | { |
---|
86 | if ( m_pchInputFileList[i] != NULL ) |
---|
87 | free (m_pchInputFileList[i]); |
---|
88 | } |
---|
89 | for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ ) |
---|
90 | { |
---|
91 | if ( m_pchDepthInputFileList[i] != NULL ) |
---|
92 | free (m_pchDepthInputFileList[i]); |
---|
93 | } |
---|
94 | for(Int i = 0; i< m_pchReconFileList.size(); i++ ) |
---|
95 | { |
---|
96 | if ( m_pchReconFileList[i] != NULL ) |
---|
97 | free (m_pchReconFileList[i]); |
---|
98 | } |
---|
99 | for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ ) |
---|
100 | { |
---|
101 | if ( m_pchDepthReconFileList[i] != NULL ) |
---|
102 | free (m_pchDepthReconFileList[i]); |
---|
103 | } |
---|
104 | if (m_pchBitstreamFile != NULL) |
---|
105 | free (m_pchBitstreamFile) ; |
---|
106 | #if HHI_VSO |
---|
107 | if ( m_pchVSOConfig != NULL) |
---|
108 | free ( m_pchVSOConfig ); |
---|
109 | #endif |
---|
110 | |
---|
111 | } |
---|
112 | |
---|
113 | Void TAppEncCfg::create() |
---|
114 | { |
---|
115 | } |
---|
116 | |
---|
117 | Void TAppEncCfg::destroy() |
---|
118 | { |
---|
119 | } |
---|
120 | |
---|
121 | std::istringstream &operator>>( std::istringstream &in, GOPEntryMvc &entry ) //input |
---|
122 | { |
---|
123 | in>>entry.m_sliceType; |
---|
124 | in>>entry.m_POC; |
---|
125 | in>>entry.m_QPOffset; |
---|
126 | in>>entry.m_QPFactor; |
---|
127 | in>>entry.m_temporalId; |
---|
128 | in>>entry.m_numRefPicsActive; |
---|
129 | in>>entry.m_refPic; |
---|
130 | in>>entry.m_numRefPics; |
---|
131 | for ( Int i = 0; i < entry.m_numRefPics; i++ ) |
---|
132 | { |
---|
133 | in>>entry.m_referencePics[i]; |
---|
134 | } |
---|
135 | in>>entry.m_interRPSPrediction; |
---|
136 | if (entry.m_interRPSPrediction) |
---|
137 | { |
---|
138 | in>>entry.m_deltaRIdxMinus1; |
---|
139 | in>>entry.m_deltaRPS; |
---|
140 | in>>entry.m_numRefIdc; |
---|
141 | for ( Int i = 0; i < entry.m_numRefIdc; i++ ) |
---|
142 | { |
---|
143 | in>>entry.m_refIdc[i]; |
---|
144 | } |
---|
145 | } |
---|
146 | in>>entry.m_numInterViewRefPics; |
---|
147 | for( Int i = 0; i < entry.m_numInterViewRefPics; i++ ) |
---|
148 | { |
---|
149 | in>>entry.m_interViewRefs[i]; |
---|
150 | } |
---|
151 | for( Int i = 0; i < entry.m_numInterViewRefPics; i++ ) |
---|
152 | { |
---|
153 | in>>entry.m_interViewRefPosL0[i]; |
---|
154 | } |
---|
155 | for( Int i = 0; i < entry.m_numInterViewRefPics; i++ ) |
---|
156 | { |
---|
157 | in>>entry.m_interViewRefPosL1[i]; |
---|
158 | } |
---|
159 | return in; |
---|
160 | } |
---|
161 | |
---|
162 | // ==================================================================================================================== |
---|
163 | // Public member functions |
---|
164 | // ==================================================================================================================== |
---|
165 | |
---|
166 | /** \param argc number of arguments |
---|
167 | \param argv array of arguments |
---|
168 | \retval true when success |
---|
169 | */ |
---|
170 | Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] ) |
---|
171 | { |
---|
172 | bool do_help = false; |
---|
173 | |
---|
174 | string cfg_BitstreamFile; |
---|
175 | string cfg_dQPFile; |
---|
176 | string cfg_ColumnWidth; |
---|
177 | string cfg_RowHeight; |
---|
178 | string cfg_ScalingListFile; |
---|
179 | po::Options opts; |
---|
180 | opts.addOptions() |
---|
181 | ("help", do_help, false, "this help text") |
---|
182 | ("c", po::parseConfigFile, "configuration file name") |
---|
183 | |
---|
184 | /* File, I/O and source parameters */ |
---|
185 | ("InputFile_%d,i_%d", m_pchInputFileList, (char *) 0 , MAX_VIEW_NUM , "original Yuv input file name %d") |
---|
186 | ("DepthInputFile_%d,di_%d", m_pchDepthInputFileList, (char *) 0 , MAX_VIEW_NUM , "original Yuv depth input file name %d") |
---|
187 | ("ReconFile_%d,o_%d", m_pchReconFileList, (char *) 0 , MAX_VIEW_NUM , "reconstructed Yuv output file name %d") |
---|
188 | ("DepthReconFile_%d,do_%d", m_pchDepthReconFileList, (char *) 0 , MAX_VIEW_NUM , "reconstructed Yuv depth output file name %d") |
---|
189 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream output file name") |
---|
190 | ("CodeDepthMaps", m_bUsingDepthMaps, false, "Encode depth maps" ) |
---|
191 | ("CodedCamParsPrecision", m_iCodedCamParPrecision, STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" ) |
---|
192 | ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( double )1.0, "Lambda modifier for temporal layer 0") |
---|
193 | ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( double )1.0, "Lambda modifier for temporal layer 1") |
---|
194 | ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( double )1.0, "Lambda modifier for temporal layer 2") |
---|
195 | ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( double )1.0, "Lambda modifier for temporal layer 3") |
---|
196 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
---|
197 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
---|
198 | #if PIC_CROPPING |
---|
199 | ("CroppingMode", m_croppingMode, 0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping") |
---|
200 | ("CropLeft", m_cropLeft, 0, "Left cropping/padding for cropping mode 3") |
---|
201 | ("CropRight", m_cropRight, 0, "Right cropping/padding for cropping mode 3") |
---|
202 | ("CropTop", m_cropTop, 0, "Top cropping/padding for cropping mode 3") |
---|
203 | ("CropBottom", m_cropBottom, 0, "Bottom cropping/padding for cropping mode 3") |
---|
204 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "horizontal source padding for cropping mode 2") |
---|
205 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "vertical source padding for cropping mode 2") |
---|
206 | #endif |
---|
207 | ("InputBitDepth", m_uiInputBitDepth, 8u, "bit-depth of input file") |
---|
208 | ("BitDepth", m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth") |
---|
209 | ("OutputBitDepth", m_uiOutputBitDepth, 0u, "bit-depth of output file") |
---|
210 | ("InternalBitDepth", m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)") |
---|
211 | #if !PIC_CROPPING |
---|
212 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "horizontal source padding size") |
---|
213 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "vertical source padding size") |
---|
214 | ("PAD", m_bUsePAD, false, "automatic source padding of multiple of 16" ) |
---|
215 | #endif |
---|
216 | ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") |
---|
217 | ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") |
---|
218 | ("FramesToBeEncoded,f", m_iFrameToBeEncoded, 0, "number of frames to be encoded (default=all)") |
---|
219 | ("FrameToBeEncoded", m_iFrameToBeEncoded, 0, "depricated alias of FramesToBeEncoded") |
---|
220 | |
---|
221 | ("NumberOfViews", m_iNumberOfViews, 0, "Number of views") |
---|
222 | /* Unit definition parameters */ |
---|
223 | ("MaxCUWidth", m_uiMaxCUWidth, 64u) |
---|
224 | ("MaxCUHeight", m_uiMaxCUHeight, 64u) |
---|
225 | /* todo: remove defaults from MaxCUSize */ |
---|
226 | ("MaxCUSize,s", m_uiMaxCUWidth, 64u, "max CU size") |
---|
227 | ("MaxCUSize,s", m_uiMaxCUHeight, 64u, "max CU size") |
---|
228 | ("MaxPartitionDepth,h", m_uiMaxCUDepth, 4u, "CU depth") |
---|
229 | |
---|
230 | ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u) |
---|
231 | ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u) |
---|
232 | |
---|
233 | ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u) |
---|
234 | ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u) |
---|
235 | |
---|
236 | /* Coding structure paramters */ |
---|
237 | ("IntraPeriod,-ip",m_iIntraPeriod, -1, "intra period in frames, (-1: only first frame)") |
---|
238 | ("DecodingRefreshType,-dr",m_iDecodingRefreshType, 0, "intra refresh, (0:none 1:CRA 2:IDR)") |
---|
239 | ("GOPSize,g", m_iGOPSize, 1, "GOP size of temporal structure") |
---|
240 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
241 | ("MaxNumberOfReorderPictures", m_numReorderFrames, -1, "Max. number of reorder pictures: -1: encoder determines value, >=0: set explicitly") |
---|
242 | ("MaxNumberOfReferencePictures", m_maxNumberOfReferencePictures, 6, "Max. number of reference pictures") |
---|
243 | #endif |
---|
244 | ("ListCombination,-lc", m_bUseLComb, true, "combined reference list flag for uni-prediction in B-slices") |
---|
245 | ("LCModification", m_bLCMod, false, "enables signalling of combined reference list derivation") |
---|
246 | ("DisableInter4x4", m_bDisInter4x4, true, "Disable Inter 4x4") |
---|
247 | ("NSQT", m_enableNSQT, true, "Enable non-square transforms") |
---|
248 | ("AMP", m_enableAMP, true, "Enable asymmetric motion partitions") |
---|
249 | /* motion options */ |
---|
250 | ("FastSearch", m_iFastSearch, 1, "0:Full search 1:Diamond 2:PMVFAST") |
---|
251 | ("SearchRange,-sr",m_iSearchRange, 96, "motion search range") |
---|
252 | ("BipredSearchRange", m_bipredSearchRange, 4, "motion search range for bipred refinement") |
---|
253 | ("HadamardME", m_bUseHADME, true, "hadamard ME for fractional-pel") |
---|
254 | ("ASR", m_bUseASR, false, "adaptive motion search range") |
---|
255 | |
---|
256 | /* Quantization parameters */ |
---|
257 | ("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") |
---|
258 | ("DeltaQpRD,-dqr",m_uiDeltaQpRD, 0u, "max dQp offset for slice") |
---|
259 | ("MaxDeltaQP,d", m_iMaxDeltaQP, 0, "max dQp offset for block") |
---|
260 | ("MaxCuDQPDepth,-dqd", m_iMaxCuDQPDepth, 0, "max depth for a minimum CuDQP") |
---|
261 | |
---|
262 | ("ChromaQpOffset, -cqo", m_iChromaQpOffset, 0, "ChromaQpOffset") |
---|
263 | ("ChromaQpOffset2nd,-cqo2", m_iChromaQpOffset2nd, 0, "ChromaQpOffset2nd") |
---|
264 | |
---|
265 | #if ADAPTIVE_QP_SELECTION |
---|
266 | ("AdaptiveQpSelection,-aqps", m_bUseAdaptQpSelect, false, "AdaptiveQpSelection") |
---|
267 | #endif |
---|
268 | |
---|
269 | ("AdaptiveQP,-aq", m_bUseAdaptiveQP, false, "QP adaptation based on a psycho-visual model") |
---|
270 | ("MaxQPAdaptationRange,-aqr", m_iQPAdaptationRange, 6, "QP adaptation range") |
---|
271 | ("dQPFile,m", cfg_dQPFile, string(""), "dQP file name") |
---|
272 | ("RDOQ", m_abUseRDOQ, std::vector<Bool>(1,true), "Enable RDOQ") |
---|
273 | ("TemporalLayerQPOffset_L0,-tq0", m_aiTLayerQPOffset[0], MAX_QP + 1, "QP offset of temporal layer 0") |
---|
274 | ("TemporalLayerQPOffset_L1,-tq1", m_aiTLayerQPOffset[1], MAX_QP + 1, "QP offset of temporal layer 1") |
---|
275 | ("TemporalLayerQPOffset_L2,-tq2", m_aiTLayerQPOffset[2], MAX_QP + 1, "QP offset of temporal layer 2") |
---|
276 | ("TemporalLayerQPOffset_L3,-tq3", m_aiTLayerQPOffset[3], MAX_QP + 1, "QP offset of temporal layer 3") |
---|
277 | |
---|
278 | #if !H0566_TLA |
---|
279 | ("TLayeringBasedOnCodingStruct,-tl", m_bTLayering, false, "Temporal ID is set based on the hierarchical coding structure") |
---|
280 | |
---|
281 | ("TLayerSwitchingFlag_L0,-ts0", m_abTLayerSwitchingFlag[0], false, "Switching flag for temporal layer 0") |
---|
282 | ("TLayerSwitchingFlag_L1,-ts1", m_abTLayerSwitchingFlag[1], false, "Switching flag for temporal layer 1") |
---|
283 | ("TLayerSwitchingFlag_L2,-ts2", m_abTLayerSwitchingFlag[2], false, "Switching flag for temporal layer 2") |
---|
284 | ("TLayerSwitchingFlag_L3,-ts3", m_abTLayerSwitchingFlag[3], false, "Switching flag for temporal layer 3") |
---|
285 | #endif |
---|
286 | |
---|
287 | /* Entropy coding parameters */ |
---|
288 | ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation") |
---|
289 | |
---|
290 | /* Deblocking filter parameters */ |
---|
291 | ("LoopFilterDisable", m_abLoopFilterDisable, std::vector<Bool>(1,false), "Disables LoopFilter") |
---|
292 | |
---|
293 | ("LoopFilterOffsetInAPS", m_loopFilterOffsetInAPS, false) |
---|
294 | ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0 ) |
---|
295 | ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0 ) |
---|
296 | #if DBL_CONTROL |
---|
297 | ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false) |
---|
298 | #endif |
---|
299 | |
---|
300 | /* Camera Paremetes */ |
---|
301 | ("CameraParameterFile,cpf", m_pchCameraParameterFile, (Char *) 0, "Camera Parameter File Name") |
---|
302 | ("BaseViewCameraNumbers" , m_pchBaseViewCameraNumbers, (Char *) 0, "Numbers of base views") |
---|
303 | |
---|
304 | /* View Synthesis Optimization */ |
---|
305 | |
---|
306 | #if HHI_VSO |
---|
307 | ("VSOConfig", m_pchVSOConfig , (Char *) 0 , "VSO configuration") |
---|
308 | ("VSO", m_bUseVSO , false , "Use VSO" ) |
---|
309 | // GT: For development, will be removed later |
---|
310 | ("VSOMode", m_uiVSOMode , (UInt) 4 , "VSO Mode") |
---|
311 | #if HHI_VSO_LS_TABLE |
---|
312 | ("LambdaScaleVSO", m_dLambdaScaleVSO , (Double) 1 , "Lambda Scaling for VSO") |
---|
313 | #else |
---|
314 | ("LambdaScaleVSO", m_dLambdaScaleVSO , (Double) 0.5 , "Lambda Scaling for VSO") |
---|
315 | #endif |
---|
316 | ("ForceLambdaScaleVSO", m_bForceLambdaScaleVSO , false , "Force using Lambda Scale VSO also in non-VSO-Mode") |
---|
317 | #if HHI_VSO_DIST_INT |
---|
318 | ("AllowNegDist", m_bAllowNegDist , true , "Allow negative Distortion in VSO") |
---|
319 | #endif |
---|
320 | |
---|
321 | #endif |
---|
322 | |
---|
323 | #if DEPTH_MAP_GENERATION |
---|
324 | ("PredDepthMapGen", m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" ) |
---|
325 | #endif |
---|
326 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
327 | ("MultiviewMvPred", m_uiMultiviewMvPredMode, (UInt)0, "usage of predicted depth maps" ) |
---|
328 | ("MultiviewMvRegMode", m_uiMultiviewMvRegMode, (UInt)0, "regularization mode for multiview motion vectors" ) |
---|
329 | ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" ) |
---|
330 | #endif |
---|
331 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
332 | ("MultiviewResPred", m_uiMultiviewResPredMode, (UInt)0, "usage of inter-view residual prediction" ) |
---|
333 | #endif |
---|
334 | |
---|
335 | /* Coding tools */ |
---|
336 | ("LMChroma", m_bUseLMChroma, true, "intra chroma prediction based on recontructed luma") |
---|
337 | |
---|
338 | ("ALF", m_abUseALF, std::vector<Bool>(1,true), "Enables ALF") |
---|
339 | ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO") |
---|
340 | #if SAO_UNIT_INTERLEAVING |
---|
341 | ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "2048: default") |
---|
342 | ("SAOInterleaving", m_saoInterleavingFlag, false, "0: SAO Picture Mode, 1: SAO Interleaving ") |
---|
343 | #endif |
---|
344 | |
---|
345 | ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding") |
---|
346 | |
---|
347 | ("ALFMaxNumFilter,-ALFMNF", m_iALFMaxNumberFilters, 16, "16: No Constrained, 1-15: Constrained max number of filter") |
---|
348 | #if LCU_SYNTAX_ALF |
---|
349 | ("ALFParamInSlice", m_bALFParamInSlice, false, "ALF parameters in 0: APS, 1: slice header") |
---|
350 | ("ALFPicBasedEncode", m_bALFPicBasedEncode, true, "ALF picture-based encoding 0: false, 1: true") |
---|
351 | #endif |
---|
352 | |
---|
353 | ("SliceMode", m_iSliceMode, 0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes") |
---|
354 | ("SliceArgument", m_iSliceArgument, 0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.") |
---|
355 | ("EntropySliceMode", m_iEntropySliceMode, 0, "0: Disable all entropy slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based entropy slices") |
---|
356 | ("EntropySliceArgument", m_iEntropySliceArgument,0, "if EntropySliceMode==1 SliceArgument represents max # of LCUs. if EntropySliceMode==2 EntropySliceArgument represents max # of bins.") |
---|
357 | ("SliceGranularity", m_iSliceGranularity, 0, "0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.") |
---|
358 | ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true) |
---|
359 | |
---|
360 | ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction") |
---|
361 | ("PCMEnabledFlag", m_usePCM , false) |
---|
362 | ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u) |
---|
363 | ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u) |
---|
364 | |
---|
365 | ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true) |
---|
366 | ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false) |
---|
367 | #if LOSSLESS_CODING |
---|
368 | ("LosslessCuEnabled", m_useLossless, false) |
---|
369 | #endif |
---|
370 | ("weighted_pred_flag,-wpP", m_bUseWeightPred, false, "weighted prediction flag (P-Slices)") |
---|
371 | ("weighted_bipred_idc,-wpBidc", m_uiBiPredIdc, 0u, "weighted bipred idc (B-Slices)") |
---|
372 | ("TileInfoPresentFlag", m_iColumnRowInfoPresent, 1, "0: tiles parameters are NOT present in the PPS. 1: tiles parameters are present in the PPS") |
---|
373 | ("UniformSpacingIdc", m_iUniformSpacingIdr, 0, "Indicates if the column and row boundaries are distributed uniformly") |
---|
374 | #if !REMOVE_TILE_DEPENDENCE |
---|
375 | ("TileBoundaryIndependenceIdc", m_iTileBoundaryIndependenceIdr, 1, "Indicates if the column and row boundaries break the prediction") |
---|
376 | #endif |
---|
377 | ("NumTileColumnsMinus1", m_iNumColumnsMinus1, 0, "Number of columns in a picture minus 1") |
---|
378 | ("ColumnWidthArray", cfg_ColumnWidth, string(""), "Array containing ColumnWidth values in units of LCU") |
---|
379 | ("NumTileRowsMinus1", m_iNumRowsMinus1, 0, "Number of rows in a picture minus 1") |
---|
380 | ("RowHeightArray", cfg_RowHeight, string(""), "Array containing RowHeight values in units of LCU") |
---|
381 | ("TileLocationInSliceHeaderFlag", m_iTileLocationInSliceHeaderFlag, 0, "0: Disable transmission of tile location in slice header. 1: Transmit tile locations in slice header.") |
---|
382 | ("TileMarkerFlag", m_iTileMarkerFlag, 0, "0: Disable transmission of lightweight tile marker. 1: Transmit light weight tile marker.") |
---|
383 | ("MaxTileMarkerEntryPoints", m_iMaxTileMarkerEntryPoints, 4, "Maximum number of uniformly-spaced tile entry points (using light weigh tile markers). Default=4. If number of tiles < MaxTileMarkerEntryPoints then all tiles have entry points.") |
---|
384 | ("TileControlPresentFlag", m_iTileBehaviorControlPresentFlag, 1, "0: tiles behavior control parameters are NOT present in the PPS. 1: tiles behavior control parameters are present in the PPS") |
---|
385 | ("LFCrossTileBoundaryFlag", m_bLFCrossTileBoundaryFlag, true, "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering") |
---|
386 | ("WaveFrontSynchro", m_iWaveFrontSynchro, 0, "0: no synchro; 1 synchro with TR; 2 TRR etc") |
---|
387 | ("WaveFrontFlush", m_iWaveFrontFlush, 0, "Flush and terminate CABAC coding for each LCU line") |
---|
388 | ("WaveFrontSubstreams", m_iWaveFrontSubstreams, 1, "# coded substreams wanted; per tile if TileBoundaryIndependenceIdc is 1, otherwise per frame") |
---|
389 | ("ScalingList", m_useScalingListId, 0, "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile") |
---|
390 | ("ScalingListFile", cfg_ScalingListFile, string(""), "Scaling list file name") |
---|
391 | #if MULTIBITS_DATA_HIDING |
---|
392 | ("SignHideFlag,-SBH", m_signHideFlag, 1) |
---|
393 | ("SignHideThreshold,-TSIG", m_signHidingThreshold, 4) |
---|
394 | #endif |
---|
395 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
396 | ("DMM", m_bUseDMM, false, "depth model modes flag") |
---|
397 | #endif |
---|
398 | |
---|
399 | /* Misc. */ |
---|
400 | ("SEIpictureDigest", m_pictureDigestEnabled, true, "Control generation of picture_digest SEI messages\n" |
---|
401 | "\t1: use MD5\n" |
---|
402 | "\t0: disable") |
---|
403 | |
---|
404 | ("TMVP", m_enableTMVP, true, "Enable TMVP" ) |
---|
405 | |
---|
406 | ("FEN", m_bUseFastEnc, false, "fast encoder setting") |
---|
407 | ("ECU", m_bUseEarlyCU, false, "Early CU setting") |
---|
408 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
409 | ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") |
---|
410 | #endif |
---|
411 | ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting") |
---|
412 | #if HHI_INTERVIEW_SKIP |
---|
413 | ("InterViewSkip", m_bInterViewSkip, false, "usage of interview skip" ) |
---|
414 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
415 | ("InterViewSkipLambdaScale", m_dInterViewSkipLambdaScale, (Double)8, "lambda scale for interview skip" ) |
---|
416 | #endif |
---|
417 | #endif |
---|
418 | /* Compatability with old style -1 FOO or -0 FOO options. */ |
---|
419 | ("1", doOldStyleCmdlineOn, "turn option <name> on") |
---|
420 | ("0", doOldStyleCmdlineOff, "turn option <name> off") |
---|
421 | #if HHI_MPI |
---|
422 | ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding") |
---|
423 | #endif |
---|
424 | ; |
---|
425 | |
---|
426 | // parse coding structure |
---|
427 | for( Int k = 0; k < MAX_VIEW_NUM; k++ ) |
---|
428 | { |
---|
429 | if( k == 0 ) |
---|
430 | { |
---|
431 | for( Int i = 1; i < MAX_GOP + 1; i++ ) |
---|
432 | { |
---|
433 | std::ostringstream cOSS; |
---|
434 | cOSS<<"Frame"<<i; |
---|
435 | opts.addOptions()( cOSS.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc() ); |
---|
436 | } |
---|
437 | } |
---|
438 | else |
---|
439 | { |
---|
440 | std::ostringstream cOSS1; |
---|
441 | cOSS1<<"FrameI"<<"_v"<<k; |
---|
442 | opts.addOptions()(cOSS1.str(), m_GOPListsMvc[k][MAX_GOP], GOPEntryMvc()); |
---|
443 | |
---|
444 | for( Int i = 1; i < MAX_GOP + 1; i++ ) |
---|
445 | { |
---|
446 | std::ostringstream cOSS2; |
---|
447 | cOSS2<<"Frame"<<i<<"_v"<<k; |
---|
448 | opts.addOptions()(cOSS2.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc()); |
---|
449 | } |
---|
450 | } |
---|
451 | } |
---|
452 | |
---|
453 | po::setDefaults(opts); |
---|
454 | const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv); |
---|
455 | |
---|
456 | for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++) |
---|
457 | { |
---|
458 | fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it); |
---|
459 | } |
---|
460 | |
---|
461 | if (argc == 1 || do_help) |
---|
462 | { |
---|
463 | /* argc == 1: no options have been specified */ |
---|
464 | po::doHelp(cout, opts); |
---|
465 | xPrintUsage(); |
---|
466 | return false; |
---|
467 | } |
---|
468 | |
---|
469 | /* |
---|
470 | * Set any derived parameters |
---|
471 | */ |
---|
472 | /* convert std::string to c string for compatability */ |
---|
473 | m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
474 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
---|
475 | |
---|
476 | m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str()); |
---|
477 | m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str()); |
---|
478 | m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str()); |
---|
479 | |
---|
480 | if ( m_bUsingDepthMaps ) |
---|
481 | { |
---|
482 | for(Int i = 0; i < m_pchDepthReconFileList.size() ; i++) |
---|
483 | { |
---|
484 | if ((m_pchDepthInputFileList[i] != NULL) && (m_pchReconFileList[i] != NULL) && (i < m_iNumberOfViews) ) |
---|
485 | { |
---|
486 | if (m_pchDepthReconFileList[i] == NULL ) |
---|
487 | { |
---|
488 | xAppendToFileNameEnd( m_pchReconFileList[i], "_depth", m_pchDepthReconFileList[i] ); |
---|
489 | } |
---|
490 | } |
---|
491 | else |
---|
492 | { |
---|
493 | m_pchDepthReconFileList[i] = NULL; |
---|
494 | } |
---|
495 | }; |
---|
496 | } |
---|
497 | if ( m_adQP.size() < 2 ) |
---|
498 | { |
---|
499 | m_adQP.push_back( m_adQP[0] ); |
---|
500 | }; |
---|
501 | for (UInt uiK = 0; uiK < m_adQP.size(); uiK++) |
---|
502 | { |
---|
503 | m_aiQP.push_back( (Int)( m_adQP[uiK] ) ); |
---|
504 | } |
---|
505 | |
---|
506 | #if PIC_CROPPING |
---|
507 | switch (m_croppingMode) |
---|
508 | { |
---|
509 | case 0: |
---|
510 | { |
---|
511 | // no cropping or padding |
---|
512 | m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0; |
---|
513 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
514 | break; |
---|
515 | } |
---|
516 | case 1: |
---|
517 | { |
---|
518 | // automatic padding to minimum CU size |
---|
519 | Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); |
---|
520 | if (m_iSourceWidth % minCuSize) |
---|
521 | { |
---|
522 | m_aiPad[0] = m_cropRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth; |
---|
523 | m_iSourceWidth += m_cropRight; |
---|
524 | } |
---|
525 | if (m_iSourceHeight % minCuSize) |
---|
526 | { |
---|
527 | m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; |
---|
528 | m_iSourceHeight += m_cropBottom; |
---|
529 | } |
---|
530 | break; |
---|
531 | } |
---|
532 | case 2: |
---|
533 | { |
---|
534 | //padding |
---|
535 | m_iSourceWidth += m_aiPad[0]; |
---|
536 | m_iSourceHeight += m_aiPad[1]; |
---|
537 | m_cropRight = m_aiPad[0]; |
---|
538 | m_cropBottom = m_aiPad[1]; |
---|
539 | break; |
---|
540 | } |
---|
541 | case 3: |
---|
542 | { |
---|
543 | // cropping |
---|
544 | if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0)) |
---|
545 | { |
---|
546 | fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n"); |
---|
547 | } |
---|
548 | if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0)) |
---|
549 | { |
---|
550 | fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n"); |
---|
551 | } |
---|
552 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
553 | break; |
---|
554 | } |
---|
555 | } |
---|
556 | #else |
---|
557 | |
---|
558 | // compute source padding size |
---|
559 | if ( m_bUsePAD ) |
---|
560 | { |
---|
561 | if ( m_iSourceWidth%MAX_PAD_SIZE ) |
---|
562 | { |
---|
563 | m_aiPad[0] = (m_iSourceWidth/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceWidth; |
---|
564 | } |
---|
565 | |
---|
566 | if ( m_iSourceHeight%MAX_PAD_SIZE ) |
---|
567 | { |
---|
568 | m_aiPad[1] = (m_iSourceHeight/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceHeight; |
---|
569 | } |
---|
570 | } |
---|
571 | m_iSourceWidth += m_aiPad[0]; |
---|
572 | m_iSourceHeight += m_aiPad[1]; |
---|
573 | #endif |
---|
574 | |
---|
575 | // allocate slice-based dQP values |
---|
576 | m_aidQP = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ]; |
---|
577 | m_aidQPdepth = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ]; |
---|
578 | ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) ); |
---|
579 | ::memset( m_aidQPdepth, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) ); |
---|
580 | |
---|
581 | // handling of floating-point QP values |
---|
582 | // if QP is not integer, sequence is split into two sections having QP and QP+1 |
---|
583 | m_aiQP[0] = (Int)( m_adQP[0] ); |
---|
584 | if ( m_aiQP[0] < m_adQP[0] ) |
---|
585 | { |
---|
586 | Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[0] - m_aiQP[0])*m_iFrameToBeEncoded + 0.5 ); |
---|
587 | |
---|
588 | iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize; |
---|
589 | for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ ) |
---|
590 | { |
---|
591 | m_aidQP[i] = 1; |
---|
592 | } |
---|
593 | } |
---|
594 | |
---|
595 | m_aiQP[1] = (Int)( m_adQP[1] ); |
---|
596 | if ( m_aiQP[1] < m_adQP[1] ) |
---|
597 | { |
---|
598 | Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[1] - m_aiQP[1])*m_iFrameToBeEncoded + 0.5 ); |
---|
599 | |
---|
600 | iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize; |
---|
601 | for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ ) |
---|
602 | { |
---|
603 | m_aidQPdepth[i] = 1; |
---|
604 | } |
---|
605 | } |
---|
606 | |
---|
607 | // reading external dQP description from file |
---|
608 | if ( m_pchdQPFile ) |
---|
609 | { |
---|
610 | FILE* fpt=fopen( m_pchdQPFile, "r" ); |
---|
611 | if ( fpt ) |
---|
612 | { |
---|
613 | Int iValue; |
---|
614 | Int iPOC = 0; |
---|
615 | while ( iPOC < m_iFrameToBeEncoded ) |
---|
616 | { |
---|
617 | if ( fscanf(fpt, "%d", &iValue ) == EOF ) break; |
---|
618 | m_aidQP[ iPOC ] = iValue; |
---|
619 | iPOC++; |
---|
620 | } |
---|
621 | fclose(fpt); |
---|
622 | } |
---|
623 | } |
---|
624 | |
---|
625 | #if HHI_VSO |
---|
626 | m_bUseVSO = m_bUseVSO && m_bUsingDepthMaps && (m_uiVSOMode != 0); |
---|
627 | #endif |
---|
628 | |
---|
629 | xCleanUpVectors(); |
---|
630 | |
---|
631 | #if HHI_VSO |
---|
632 | if ( m_abUseALF .size() < 2) |
---|
633 | m_abUseALF .push_back( m_bUseVSO ? false : m_abUseALF[0] ); |
---|
634 | |
---|
635 | if ( m_abUseRDOQ.size() < 2) |
---|
636 | m_abUseRDOQ.push_back( m_bUseVSO ? true : m_abUseRDOQ[0] ); |
---|
637 | |
---|
638 | if ( m_abLoopFilterDisable.size() < 2) |
---|
639 | m_abLoopFilterDisable.push_back( m_bUseVSO ? true : m_abLoopFilterDisable[0] ); |
---|
640 | |
---|
641 | if (m_abUseSAO.size() < 2) |
---|
642 | m_abUseSAO.push_back ( m_bUseVSO ? false : m_abUseSAO[0] ); |
---|
643 | #else |
---|
644 | if ( m_abUseALF .size() < 2) |
---|
645 | m_abUseALF .push_back( m_abUseALF[0] ); |
---|
646 | |
---|
647 | if ( m_abUseRDOQ.size() < 2) |
---|
648 | m_abUseRDOQ.push_back( m_abUseRDOQ[0] ); |
---|
649 | |
---|
650 | if ( m_abLoopFilterDisable.size() < 2) |
---|
651 | m_abLoopFilterDisable.push_back( m_abLoopFilterDisable[0] ); |
---|
652 | |
---|
653 | if (m_abUseSAO.size() < 2) |
---|
654 | m_abUseSAO.push_back ( m_abUseSAO[0] ); |
---|
655 | #endif |
---|
656 | |
---|
657 | #if HHI_VSO |
---|
658 | |
---|
659 | #if HHI_VSO_LS_TABLE |
---|
660 | // Q&D |
---|
661 | Double adLambdaScaleTable[] = |
---|
662 | { 0.031250, 0.031639, 0.032029, 0.032418, 0.032808, 0.033197, 0.033586, 0.033976, 0.034365, 0.034755, |
---|
663 | 0.035144, 0.035533, 0.035923, 0.036312, 0.036702, 0.037091, 0.037480, 0.037870, 0.038259, 0.038648, |
---|
664 | 0.039038, 0.039427, 0.039817, 0.040206, 0.040595, 0.040985, 0.041374, 0.041764, 0.042153, 0.042542, |
---|
665 | 0.042932, 0.043321, 0.043711, 0.044100, 0.044194, 0.053033, 0.061872, 0.070711, 0.079550, 0.088388, |
---|
666 | 0.117851, 0.147314, 0.176777, 0.235702, 0.294628, 0.353553, 0.471405, 0.589256, 0.707107, 0.707100, |
---|
667 | 0.753550, 0.800000 |
---|
668 | }; |
---|
669 | AOT( (m_aiQP[1] < 0) || (m_aiQP[1] > 51)); |
---|
670 | m_dLambdaScaleVSO *= adLambdaScaleTable[m_aiQP[1]]; |
---|
671 | #endif |
---|
672 | #endif |
---|
673 | |
---|
674 | // set global variables |
---|
675 | xSetGlobal(); |
---|
676 | |
---|
677 | // read and check camera parameters |
---|
678 | #if HHI_VSO |
---|
679 | if ( m_bUseVSO && m_uiVSOMode == 4) |
---|
680 | { |
---|
681 | m_cRenModStrParser.setString( m_iNumberOfViews, m_pchVSOConfig ); |
---|
682 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
683 | m_uiInputBitDepth, |
---|
684 | (UInt)m_iCodedCamParPrecision, |
---|
685 | m_FrameSkip, |
---|
686 | (UInt)m_iFrameToBeEncoded, |
---|
687 | m_pchCameraParameterFile, |
---|
688 | m_pchBaseViewCameraNumbers, |
---|
689 | NULL, |
---|
690 | m_cRenModStrParser.getSynthViews(), |
---|
691 | LOG2_DISP_PREC_LUT ); |
---|
692 | } |
---|
693 | else if ( m_bUseVSO && m_uiVSOMode != 4 ) |
---|
694 | { |
---|
695 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
696 | m_uiInputBitDepth, |
---|
697 | (UInt)m_iCodedCamParPrecision, |
---|
698 | m_FrameSkip, |
---|
699 | (UInt)m_iFrameToBeEncoded, |
---|
700 | m_pchCameraParameterFile, |
---|
701 | m_pchBaseViewCameraNumbers, |
---|
702 | m_pchVSOConfig, |
---|
703 | NULL, |
---|
704 | LOG2_DISP_PREC_LUT ); |
---|
705 | } |
---|
706 | else |
---|
707 | { |
---|
708 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
709 | m_uiInputBitDepth, |
---|
710 | (UInt)m_iCodedCamParPrecision, |
---|
711 | m_FrameSkip, |
---|
712 | (UInt)m_iFrameToBeEncoded, |
---|
713 | m_pchCameraParameterFile, |
---|
714 | m_pchBaseViewCameraNumbers, |
---|
715 | NULL, |
---|
716 | NULL, |
---|
717 | LOG2_DISP_PREC_LUT ); |
---|
718 | } |
---|
719 | #else |
---|
720 | m_cCameraData .init ( (UInt)m_iNumberOfViews, |
---|
721 | m_uiInputBitDepth, |
---|
722 | (UInt)m_iCodedCamParPrecision, |
---|
723 | m_FrameSkip, |
---|
724 | (UInt)m_iFrameToBeEncoded, |
---|
725 | m_pchCameraParameterFile, |
---|
726 | m_pchBaseViewCameraNumbers, |
---|
727 | NULL, |
---|
728 | NULL, |
---|
729 | LOG2_DISP_PREC_LUT ); |
---|
730 | #endif |
---|
731 | |
---|
732 | |
---|
733 | // check validity of input parameters |
---|
734 | xCheckParameter(); |
---|
735 | m_cCameraData.check( false, true ); |
---|
736 | |
---|
737 | // print-out parameters |
---|
738 | xPrintParameter(); |
---|
739 | |
---|
740 | return true; |
---|
741 | } |
---|
742 | |
---|
743 | // ==================================================================================================================== |
---|
744 | // Private member functions |
---|
745 | // ==================================================================================================================== |
---|
746 | |
---|
747 | Bool confirmPara(Bool bflag, const char* message); |
---|
748 | |
---|
749 | Void TAppEncCfg::xCheckParameter() |
---|
750 | { |
---|
751 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
752 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
753 | // check range of parameters |
---|
754 | xConfirmPara( m_uiInputBitDepth < 8, "InputBitDepth must be at least 8" ); |
---|
755 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
---|
756 | xConfirmPara( m_iFrameToBeEncoded <= 0, "Total Number Of Frames encoded must be more than 0" ); |
---|
757 | xConfirmPara( m_iGOPSize < 1 , "GOP Size must be greater or equal to 1" ); |
---|
758 | xConfirmPara( m_iGOPSize > 1 && m_iGOPSize % 2, "GOP Size must be a multiple of 2, if GOP Size is greater than 1" ); |
---|
759 | xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" ); |
---|
760 | xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2, "Decoding Refresh Type must be equal to 0, 1 or 2" ); |
---|
761 | #if H0736_AVC_STYLE_QP_RANGE |
---|
762 | xConfirmPara( m_aiQP[0] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[0] > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
---|
763 | if ( m_aiQP.size() >= 2 ) |
---|
764 | { |
---|
765 | xConfirmPara( m_aiQP[1] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[1] > 51, "QP depth exceeds supported range (-QpBDOffsety to 51)" ); |
---|
766 | } |
---|
767 | #else |
---|
768 | xConfirmPara( m_aiQP[0] < 0 || m_aiQP[0] > 51, "QP exceeds supported range (0 to 51)" ); |
---|
769 | if ( m_aiQP.size() >= 2 ) |
---|
770 | { |
---|
771 | xConfirmPara( m_aiQP[1] < 0 || m_aiQP[1] > 51, "QP Depth exceeds supported range (0 to 51)" ); |
---|
772 | } |
---|
773 | #endif |
---|
774 | xConfirmPara( m_iALFEncodePassReduction < 0 || m_iALFEncodePassReduction > 2, "ALFEncodePassReduction must be equal to 0, 1 or 2"); |
---|
775 | #if LCU_SYNTAX_ALF |
---|
776 | xConfirmPara( m_iALFMaxNumberFilters < 1, "ALFMaxNumFilter should be larger than 1"); |
---|
777 | #else |
---|
778 | xConfirmPara( m_iALFMaxNumberFilters < 1 || m_iALFMaxNumberFilters > 16, "ALFMaxNumFilter exceeds supported range (1 to 16)"); |
---|
779 | #endif |
---|
780 | xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13, "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)"); |
---|
781 | xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13, "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)"); |
---|
782 | xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2, "Fast Search Mode is not supported value (0:Full search 1:Diamond 2:PMVFAST)" ); |
---|
783 | xConfirmPara( m_iSearchRange < 0 , "Search Range must be more than 0" ); |
---|
784 | xConfirmPara( m_bipredSearchRange < 0 , "Search Range must be more than 0" ); |
---|
785 | xConfirmPara( m_iMaxDeltaQP > 7, "Absolute Delta QP exceeds supported range (0 to 7)" ); |
---|
786 | xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1, "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" ); |
---|
787 | |
---|
788 | xConfirmPara( m_iChromaQpOffset < -12, "Min. Chroma Qp Offset is -12" ); |
---|
789 | xConfirmPara( m_iChromaQpOffset > 12, "Max. Chroma Qp Offset is 12" ); |
---|
790 | xConfirmPara( m_iChromaQpOffset2nd < -12, "Min. Chroma Qp Offset 2nd is -12" ); |
---|
791 | xConfirmPara( m_iChromaQpOffset2nd > 12, "Max. Chroma Qp Offset 2nd is 12" ); |
---|
792 | |
---|
793 | xConfirmPara( m_iQPAdaptationRange <= 0, "QP Adaptation Range must be more than 0" ); |
---|
794 | if (m_iDecodingRefreshType == 2) |
---|
795 | { |
---|
796 | xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize , "Intra period must be larger than GOP size for periodic IDR pictures"); |
---|
797 | } |
---|
798 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
---|
799 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
---|
800 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
---|
801 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
---|
802 | #if PIC_CROPPING |
---|
803 | xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size"); |
---|
804 | xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size"); |
---|
805 | #else |
---|
806 | xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Frame width should be multiple of minimum CU size"); |
---|
807 | xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Frame height should be multiple of minimum CU size"); |
---|
808 | #endif |
---|
809 | |
---|
810 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
---|
811 | xConfirmPara( m_uiQuadtreeTULog2MinSize > 5, "QuadtreeTULog2MinSize must be 5 or smaller."); |
---|
812 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2, "QuadtreeTULog2MaxSize must be 2 or greater."); |
---|
813 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
---|
814 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
---|
815 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
816 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
817 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
---|
818 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
---|
819 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
---|
820 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
821 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
---|
822 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
823 | |
---|
824 | xConfirmPara( m_iNumberOfViews > MAX_VIEW_NUM , "NumberOfViews must be less than or equal to MAX_VIEW_NUM"); |
---|
825 | xConfirmPara ( Int( m_pchInputFileList.size() ) < m_iNumberOfViews, "Number of InputFiles must be greater than or equal to NumberOfViews" ); |
---|
826 | xConfirmPara ( Int( m_pchReconFileList.size() ) < m_iNumberOfViews, "Number of ReconFiles must be greater than or equal to NumberOfViews" ); |
---|
827 | xConfirmPara ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5, "CodedCamParsPrecision must be in range of 0..5" ); |
---|
828 | #if HHI_INTERVIEW_SKIP |
---|
829 | xConfirmPara ( m_bInterViewSkip && !m_bUsingDepthMaps, "RenderingSkipMode requires CodeDepthMaps = 1" ); |
---|
830 | #endif |
---|
831 | #if DEPTH_MAP_GENERATION |
---|
832 | xConfirmPara ( m_uiPredDepthMapGeneration > 2, "PredDepthMapGen must be less than or equal to 2" ); |
---|
833 | xConfirmPara ( m_uiPredDepthMapGeneration >= 2 && !m_bUsingDepthMaps, "PredDepthMapGen >= 2 requires CodeDepthMaps = 1" ); |
---|
834 | #endif |
---|
835 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
836 | xConfirmPara ( m_uiMultiviewMvPredMode > 7, "MultiviewMvPred must be less than or equal to 7" ); |
---|
837 | xConfirmPara ( m_uiMultiviewMvPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewMvPred > 0 requires PredDepthMapGen > 0" ); |
---|
838 | xConfirmPara ( m_uiMultiviewMvRegMode > 1, "MultiviewMvRegMode must be less than or equal to 1" ); |
---|
839 | xConfirmPara ( m_dMultiviewMvRegLambdaScale < 0.0, "MultiviewMvRegLambdaScale must not be negative" ); |
---|
840 | if( m_uiMultiviewMvRegMode ) |
---|
841 | { |
---|
842 | xConfirmPara ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews, "MultiviewMvRegMode > 0 requires the presence of input depth maps" ); |
---|
843 | } |
---|
844 | #endif |
---|
845 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
846 | xConfirmPara ( m_uiMultiviewResPredMode > 1, "MultiviewResPred must be less than or equal to 1" ); |
---|
847 | xConfirmPara ( m_uiMultiviewResPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewResPred > 0 requires PredDepthMapGen > 0" ); |
---|
848 | #endif |
---|
849 | if( m_bUsingDepthMaps ) |
---|
850 | { |
---|
851 | xConfirmPara ( Int( m_pchDepthInputFileList.size() ) < m_iNumberOfViews, "Number of DepthInputFiles must be greater than or equal to NumberOfViews" ); |
---|
852 | xConfirmPara ( Int( m_pchDepthReconFileList.size() ) < m_iNumberOfViews, "Number of DepthReconFiles must be greater than or equal to NumberOfViews" ); |
---|
853 | |
---|
854 | #if HHI_VSO |
---|
855 | if( m_bUseVSO ) |
---|
856 | { |
---|
857 | xConfirmPara( m_pchCameraParameterFile == 0 , "CameraParameterFile must be given"); |
---|
858 | xConfirmPara( m_pchVSOConfig == 0 , "VSO Setup string must be given"); |
---|
859 | xConfirmPara( m_pchBaseViewCameraNumbers == 0 , "BaseViewCameraNumbers must be given" ); |
---|
860 | xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size(), "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" ); |
---|
861 | xConfirmPara( m_uiVSOMode > 4 , "VSO Mode must be less than 5"); |
---|
862 | } |
---|
863 | #endif |
---|
864 | } |
---|
865 | #if ADAPTIVE_QP_SELECTION |
---|
866 | #if H0736_AVC_STYLE_QP_RANGE |
---|
867 | xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[0] < 0, "AdaptiveQpSelection must be disabled when QP < 0."); |
---|
868 | xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[1] < 0, "AdaptiveQpSelection must be disabled when QP < 0."); |
---|
869 | xConfirmPara( m_bUseAdaptQpSelect == true && (m_iChromaQpOffset !=0 || m_iChromaQpOffset2nd != 0 ), "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0."); |
---|
870 | #endif |
---|
871 | #endif |
---|
872 | |
---|
873 | if( m_usePCM) |
---|
874 | { |
---|
875 | xConfirmPara( m_uiPCMLog2MinSize < 3, "PCMLog2MinSize must be 3 or greater."); |
---|
876 | xConfirmPara( m_uiPCMLog2MinSize > 5, "PCMLog2MinSize must be 5 or smaller."); |
---|
877 | xConfirmPara( m_pcmLog2MaxSize > 5, "PCMLog2MaxSize must be 5 or smaller."); |
---|
878 | xConfirmPara( m_pcmLog2MaxSize < m_uiPCMLog2MinSize, "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize."); |
---|
879 | } |
---|
880 | |
---|
881 | #if FIXED_NUMBER_OF_TILES_SLICE_MODE |
---|
882 | xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 3, "SliceMode exceeds supported range (0 to 3)" ); |
---|
883 | #endif |
---|
884 | if (m_iSliceMode!=0) |
---|
885 | { |
---|
886 | xConfirmPara( m_iSliceArgument < 1 , "SliceArgument should be larger than or equal to 1" ); |
---|
887 | } |
---|
888 | #if FIXED_NUMBER_OF_TILES_SLICE_MODE |
---|
889 | if (m_iSliceMode==3) |
---|
890 | { |
---|
891 | xConfirmPara( m_iSliceGranularity > 0 , "When SliceMode == 3 is chosen, the SliceGranularity must be 0" ); |
---|
892 | } |
---|
893 | #endif |
---|
894 | xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" ); |
---|
895 | if (m_iEntropySliceMode!=0) |
---|
896 | { |
---|
897 | xConfirmPara( m_iEntropySliceArgument < 1 , "EntropySliceArgument should be larger than or equal to 1" ); |
---|
898 | } |
---|
899 | xConfirmPara( m_iSliceGranularity >= m_uiMaxCUDepth, "SliceGranularity must be smaller than maximum cu depth"); |
---|
900 | xConfirmPara( m_iSliceGranularity <0 || m_iSliceGranularity > 3, "SliceGranularity exceeds supported range (0 to 3)" ); |
---|
901 | xConfirmPara( m_iSliceGranularity > m_iMaxCuDQPDepth, "SliceGranularity must be smaller smaller than or equal to maximum dqp depth" ); |
---|
902 | |
---|
903 | #if NO_COMBINED_PARALLEL |
---|
904 | bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 ); |
---|
905 | xConfirmPara( tileFlag && m_iEntropySliceMode, "Tile and Entropy Slice can not be applied together"); |
---|
906 | xConfirmPara( tileFlag && m_iWaveFrontSynchro, "Tile and Wavefront can not be applied together"); |
---|
907 | xConfirmPara( m_iWaveFrontSynchro && m_iEntropySliceMode, "Wavefront and Entropy Slice can not be applied together"); |
---|
908 | #endif |
---|
909 | |
---|
910 | // max CU width and height should be power of 2 |
---|
911 | UInt ui = m_uiMaxCUWidth; |
---|
912 | while(ui) |
---|
913 | { |
---|
914 | ui >>= 1; |
---|
915 | if( (ui & 1) == 1) |
---|
916 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
---|
917 | } |
---|
918 | ui = m_uiMaxCUHeight; |
---|
919 | while(ui) |
---|
920 | { |
---|
921 | ui >>= 1; |
---|
922 | if( (ui & 1) == 1) |
---|
923 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
---|
924 | } |
---|
925 | |
---|
926 | xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" ); |
---|
927 | xConfirmPara( m_iWaveFrontFlush < 0, "WaveFrontFlush cannot be negative" ); |
---|
928 | xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" ); |
---|
929 | xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" ); |
---|
930 | |
---|
931 | #undef xConfirmPara |
---|
932 | if (check_failed) |
---|
933 | { |
---|
934 | exit(EXIT_FAILURE); |
---|
935 | } |
---|
936 | |
---|
937 | xCheckCodingStructureMvc(); |
---|
938 | } |
---|
939 | |
---|
940 | Void TAppEncCfg::xCheckCodingStructureMvc() |
---|
941 | { |
---|
942 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
943 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
944 | |
---|
945 | // validate that POC of same frame is identical across multiple views |
---|
946 | Bool bErrorMvePoc = false; |
---|
947 | if( m_iNumberOfViews > 1 ) |
---|
948 | { |
---|
949 | for( Int k = 1; k < m_iNumberOfViews; k++ ) |
---|
950 | { |
---|
951 | for( Int i = 0; i < MAX_GOP; i++ ) |
---|
952 | { |
---|
953 | if( m_GOPListsMvc[k][i].m_POC != m_GOPListsMvc[0][i].m_POC ) |
---|
954 | { |
---|
955 | printf( "\nError: Frame%d_v%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListsMvc[k][i].m_POC, i ); |
---|
956 | bErrorMvePoc = true; |
---|
957 | } |
---|
958 | } |
---|
959 | } |
---|
960 | } |
---|
961 | xConfirmPara( bErrorMvePoc, "Invalid inter-view POC structure given" ); |
---|
962 | |
---|
963 | // validate that baseview has no inter-view refs |
---|
964 | Bool bErrorIvpBase = false; |
---|
965 | for( Int i = 0; i < MAX_GOP; i++ ) |
---|
966 | { |
---|
967 | if( m_GOPListsMvc[0][i].m_numInterViewRefPics != 0 ) |
---|
968 | { |
---|
969 | printf( "\nError: Frame%d inter_view refs not available in view 0\n", i ); |
---|
970 | bErrorIvpBase = true; |
---|
971 | } |
---|
972 | } |
---|
973 | xConfirmPara( bErrorIvpBase, "Inter-view refs not possible in base view" ); |
---|
974 | |
---|
975 | // validate inter-view refs |
---|
976 | Bool bErrorIvpEnhV = false; |
---|
977 | if( m_iNumberOfViews > 1 ) |
---|
978 | { |
---|
979 | for( Int k = 1; k < m_iNumberOfViews; k++ ) |
---|
980 | { |
---|
981 | for( Int i = 0; i < MAX_GOP+1; i++ ) |
---|
982 | { |
---|
983 | for( Int j = 0; j < m_GOPListsMvc[k][i].m_numInterViewRefPics; j++ ) |
---|
984 | { |
---|
985 | Int iAbsViewId = m_GOPListsMvc[k][i].m_interViewRefs[j] + k; |
---|
986 | if( iAbsViewId < 0 || iAbsViewId >= k ) |
---|
987 | { |
---|
988 | printf( "\nError: inter-view ref pic %d is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefs[j], i, k ); |
---|
989 | bErrorIvpEnhV = true; |
---|
990 | } |
---|
991 | if( m_GOPListsMvc[k][i].m_interViewRefPosL0[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL0[j] > m_GOPListsMvc[k][i].m_numRefPicsActive ) |
---|
992 | { |
---|
993 | printf( "\nError: inter-view ref pos %d on L0 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL0[j], i, k ); |
---|
994 | bErrorIvpEnhV = true; |
---|
995 | } |
---|
996 | if( m_GOPListsMvc[k][i].m_interViewRefPosL1[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL1[j] > m_GOPListsMvc[k][i].m_numRefPicsActive ) |
---|
997 | { |
---|
998 | printf( "\nError: inter-view ref pos %d on L1 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL1[j], i, k ); |
---|
999 | bErrorIvpEnhV = true; |
---|
1000 | } |
---|
1001 | } |
---|
1002 | if( i == MAX_GOP ) // inter-view refs at I pic position in base view |
---|
1003 | { |
---|
1004 | if( m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'B' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'P' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'I' ) |
---|
1005 | { |
---|
1006 | printf( "\nError: slice type of FrameI_v%d must be equal to B or P or I\n", k ); |
---|
1007 | bErrorIvpEnhV = true; |
---|
1008 | } |
---|
1009 | |
---|
1010 | if( m_GOPListsMvc[k][MAX_GOP].m_POC != 0 ) |
---|
1011 | { |
---|
1012 | printf( "\nError: POC %d not possible for FrameI_v%d, must be 0\n", m_GOPListsMvc[k][MAX_GOP].m_POC, k ); |
---|
1013 | bErrorIvpEnhV = true; |
---|
1014 | } |
---|
1015 | |
---|
1016 | if( m_GOPListsMvc[k][MAX_GOP].m_temporalId != 0 ) |
---|
1017 | { |
---|
1018 | printf( "\nWarning: Temporal id of FrameI_v%d must be 0 (cp. I-frame in base view)\n", k ); |
---|
1019 | m_GOPListsMvc[k][MAX_GOP].m_temporalId = 0; |
---|
1020 | } |
---|
1021 | |
---|
1022 | if( !(m_GOPListsMvc[k][MAX_GOP].m_refPic) ) |
---|
1023 | { |
---|
1024 | printf( "\nWarning: FrameI_v%d must be ref pic (cp. I-frame in base view)\n", k ); |
---|
1025 | m_GOPListsMvc[k][MAX_GOP].m_refPic = true; |
---|
1026 | } |
---|
1027 | |
---|
1028 | if( m_GOPListsMvc[k][MAX_GOP].m_numRefPics != 0 ) |
---|
1029 | { |
---|
1030 | printf( "\nWarning: temporal references not possible for FrameI_v%d\n", k ); |
---|
1031 | for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numRefPics; j++ ) |
---|
1032 | { |
---|
1033 | m_GOPListsMvc[k][MAX_GOP].m_referencePics[j] = 0; |
---|
1034 | } |
---|
1035 | m_GOPListsMvc[k][MAX_GOP].m_numRefPics = 0; |
---|
1036 | } |
---|
1037 | |
---|
1038 | if( m_GOPListsMvc[k][MAX_GOP].m_interRPSPrediction ) |
---|
1039 | { |
---|
1040 | printf( "\nError: inter RPS prediction not possible for FrameI_v%d, must be 0\n", k ); |
---|
1041 | bErrorIvpEnhV = true; |
---|
1042 | } |
---|
1043 | |
---|
1044 | if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics != 0 ) |
---|
1045 | { |
---|
1046 | printf( "\nError: inter-view prediction not possible for FrameI_v%d with slice type I, #IV_ref_pics must be 0\n", k ); |
---|
1047 | bErrorIvpEnhV = true; |
---|
1048 | } |
---|
1049 | |
---|
1050 | if( m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics ) |
---|
1051 | { |
---|
1052 | m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics; |
---|
1053 | } |
---|
1054 | |
---|
1055 | if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'P' ) |
---|
1056 | { |
---|
1057 | if( m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 ) |
---|
1058 | { |
---|
1059 | printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type P\n", k ); |
---|
1060 | bErrorIvpEnhV = true; |
---|
1061 | } |
---|
1062 | else |
---|
1063 | { |
---|
1064 | for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics; j++ ) |
---|
1065 | { |
---|
1066 | if( m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j] != 0 ) |
---|
1067 | { |
---|
1068 | printf( "\nError: inter-view ref pos %d on L1 not possible for FrameI_v%d with slice type P\n", m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j], k ); |
---|
1069 | bErrorIvpEnhV = true; |
---|
1070 | } |
---|
1071 | } |
---|
1072 | } |
---|
1073 | } |
---|
1074 | |
---|
1075 | if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 ) |
---|
1076 | { |
---|
1077 | printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type B\n", k ); |
---|
1078 | bErrorIvpEnhV = true; |
---|
1079 | } |
---|
1080 | } |
---|
1081 | } |
---|
1082 | } |
---|
1083 | } |
---|
1084 | xConfirmPara( bErrorIvpEnhV, "Invalid inter-view coding structure for enhancement views given" ); |
---|
1085 | |
---|
1086 | // validate temporal coding structure |
---|
1087 | if( !bErrorMvePoc && !bErrorIvpBase && !bErrorIvpEnhV ) |
---|
1088 | { |
---|
1089 | for( Int viewId = 0; viewId < m_iNumberOfViews; viewId++ ) |
---|
1090 | { |
---|
1091 | Bool verifiedGOP = false; |
---|
1092 | Bool errorGOP = false; |
---|
1093 | Int checkGOP = 1; |
---|
1094 | Int numRefs = 1; |
---|
1095 | Int refList[MAX_NUM_REF_PICS+1]; |
---|
1096 | refList[0] = 0; |
---|
1097 | Bool isOK[MAX_GOP]; |
---|
1098 | for( Int i = 0; i < MAX_GOP; i++ ) { isOK[i] = false; } |
---|
1099 | Int numOK = 0; |
---|
1100 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1101 | Int numReorderFramesRequired=0; |
---|
1102 | m_maxNumberOfReferencePictures=0; |
---|
1103 | Int lastDisp = -1; |
---|
1104 | #endif |
---|
1105 | m_extraRPSs[viewId] = 0; |
---|
1106 | //start looping through frames in coding order until we can verify that the GOP structure is correct. |
---|
1107 | while( !verifiedGOP && !errorGOP ) |
---|
1108 | { |
---|
1109 | Int curGOP = (checkGOP-1)%m_iGOPSize; |
---|
1110 | Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPListsMvc[viewId][curGOP].m_POC; |
---|
1111 | if( m_GOPListsMvc[viewId][curGOP].m_POC < 0 ) |
---|
1112 | { |
---|
1113 | printf( "\nError: found fewer Reference Picture Sets than GOPSize for view %d\n", viewId ); |
---|
1114 | errorGOP = true; |
---|
1115 | } |
---|
1116 | else |
---|
1117 | { |
---|
1118 | //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP. |
---|
1119 | Bool beforeI = false; |
---|
1120 | for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ ) |
---|
1121 | { |
---|
1122 | Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i]; |
---|
1123 | if( absPOC < 0 ) |
---|
1124 | { |
---|
1125 | beforeI = true; |
---|
1126 | } |
---|
1127 | else |
---|
1128 | { |
---|
1129 | Bool found = false; |
---|
1130 | for( Int j = 0; j < numRefs; j++ ) |
---|
1131 | { |
---|
1132 | if( refList[j] == absPOC ) |
---|
1133 | { |
---|
1134 | found = true; |
---|
1135 | for( Int k = 0; k < m_iGOPSize; k++ ) |
---|
1136 | { |
---|
1137 | if( absPOC%m_iGOPSize == m_GOPListsMvc[viewId][k].m_POC%m_iGOPSize ) |
---|
1138 | { |
---|
1139 | m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i] = (m_GOPListsMvc[viewId][k].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId); |
---|
1140 | } |
---|
1141 | } |
---|
1142 | } |
---|
1143 | } |
---|
1144 | if( !found ) |
---|
1145 | { |
---|
1146 | printf("\nError: ref pic %d is not available for GOP frame %d of view %d\n", m_GOPListsMvc[viewId][curGOP].m_referencePics[i], curGOP+1, viewId ); |
---|
1147 | errorGOP = true; |
---|
1148 | } |
---|
1149 | } |
---|
1150 | } |
---|
1151 | if( !beforeI && !errorGOP ) |
---|
1152 | { |
---|
1153 | //all ref frames were present |
---|
1154 | if( !isOK[curGOP] ) |
---|
1155 | { |
---|
1156 | numOK++; |
---|
1157 | isOK[curGOP] = true; |
---|
1158 | if( numOK == m_iGOPSize ) |
---|
1159 | { |
---|
1160 | verifiedGOP = true; |
---|
1161 | } |
---|
1162 | } |
---|
1163 | } |
---|
1164 | else |
---|
1165 | { |
---|
1166 | //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0) |
---|
1167 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]] = m_GOPListsMvc[viewId][curGOP]; |
---|
1168 | Int newRefs = 0; |
---|
1169 | for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ ) |
---|
1170 | { |
---|
1171 | Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i]; |
---|
1172 | if( absPOC >= 0 ) |
---|
1173 | { |
---|
1174 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[newRefs] = m_GOPListsMvc[viewId][curGOP].m_referencePics[i]; |
---|
1175 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[newRefs] = m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i]; |
---|
1176 | newRefs++; |
---|
1177 | } |
---|
1178 | } |
---|
1179 | Int numPrefRefs = m_GOPListsMvc[viewId][curGOP].m_numRefPicsActive; |
---|
1180 | |
---|
1181 | for( Int offset = -1; offset > -checkGOP; offset-- ) |
---|
1182 | { |
---|
1183 | //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0. |
---|
1184 | Int offGOP = (checkGOP - 1 + offset)%m_iGOPSize; |
---|
1185 | Int offPOC = ((checkGOP - 1 + offset)/m_iGOPSize) * m_iGOPSize + m_GOPListsMvc[viewId][offGOP].m_POC; |
---|
1186 | if( offPOC >= 0 && m_GOPListsMvc[viewId][offGOP].m_refPic && m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId ) |
---|
1187 | { |
---|
1188 | Bool newRef = false; |
---|
1189 | for( Int i = 0; i < numRefs; i++ ) |
---|
1190 | { |
---|
1191 | if( refList[i] == offPOC ) |
---|
1192 | { |
---|
1193 | newRef = true; |
---|
1194 | } |
---|
1195 | } |
---|
1196 | for( Int i = 0; i < newRefs; i++ ) |
---|
1197 | { |
---|
1198 | if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[i] == (offPOC - curPOC) ) |
---|
1199 | { |
---|
1200 | newRef = false; |
---|
1201 | } |
---|
1202 | } |
---|
1203 | if( newRef ) |
---|
1204 | { |
---|
1205 | Int insertPoint = newRefs; |
---|
1206 | //this picture can be added, find appropriate place in list and insert it. |
---|
1207 | for( Int j = 0; j < newRefs; j++ ) |
---|
1208 | { |
---|
1209 | if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] < (offPOC - curPOC) || |
---|
1210 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] > 0 ) |
---|
1211 | { |
---|
1212 | insertPoint = j; |
---|
1213 | break; |
---|
1214 | } |
---|
1215 | } |
---|
1216 | Int prev = offPOC - curPOC; |
---|
1217 | Int prevUsed = (m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId); |
---|
1218 | for( Int j = insertPoint; j < newRefs+1; j++ ) |
---|
1219 | { |
---|
1220 | Int newPrev = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j]; |
---|
1221 | Int newUsed = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j]; |
---|
1222 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] = prev; |
---|
1223 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] = prevUsed; |
---|
1224 | prevUsed = newUsed; |
---|
1225 | prev = newPrev; |
---|
1226 | } |
---|
1227 | newRefs++; |
---|
1228 | } |
---|
1229 | } |
---|
1230 | if( newRefs >= numPrefRefs ) |
---|
1231 | { |
---|
1232 | break; |
---|
1233 | } |
---|
1234 | } |
---|
1235 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics = newRefs; |
---|
1236 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC = curPOC; |
---|
1237 | if( m_extraRPSs[viewId] == 0 ) |
---|
1238 | { |
---|
1239 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 0; |
---|
1240 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = 0; |
---|
1241 | } |
---|
1242 | else |
---|
1243 | { |
---|
1244 | Int rIdx = m_iGOPSize + m_extraRPSs[viewId] - 1; |
---|
1245 | Int refPOC = m_GOPListsMvc[viewId][rIdx].m_POC; |
---|
1246 | Int refPics = m_GOPListsMvc[viewId][rIdx].m_numRefPics; |
---|
1247 | Int newIdc = 0; |
---|
1248 | for( Int i = 0; i <= refPics; i++ ) |
---|
1249 | { |
---|
1250 | Int deltaPOC = ((i != refPics)? m_GOPListsMvc[viewId][rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0 |
---|
1251 | Int absPOCref = refPOC + deltaPOC; |
---|
1252 | Int refIdc = 0; |
---|
1253 | for( Int j = 0; j < m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics; j++ ) |
---|
1254 | { |
---|
1255 | if( (absPOCref - curPOC) == m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] ) |
---|
1256 | { |
---|
1257 | if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] ) |
---|
1258 | { |
---|
1259 | refIdc = 1; |
---|
1260 | } |
---|
1261 | else |
---|
1262 | { |
---|
1263 | refIdc = 2; |
---|
1264 | } |
---|
1265 | } |
---|
1266 | } |
---|
1267 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_refIdc[newIdc] = refIdc; |
---|
1268 | newIdc++; |
---|
1269 | } |
---|
1270 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 1; |
---|
1271 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = newIdc; |
---|
1272 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRPS = refPOC - m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC; |
---|
1273 | m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRIdxMinus1 = 0; |
---|
1274 | } |
---|
1275 | curGOP = m_iGOPSize + m_extraRPSs[viewId]; |
---|
1276 | m_extraRPSs[viewId]++; |
---|
1277 | } |
---|
1278 | numRefs = 0; |
---|
1279 | for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ ) |
---|
1280 | { |
---|
1281 | Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i]; |
---|
1282 | if( absPOC >= 0 ) |
---|
1283 | { |
---|
1284 | refList[numRefs] = absPOC; |
---|
1285 | numRefs++; |
---|
1286 | } |
---|
1287 | } |
---|
1288 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1289 | if(m_maxNumberOfReferencePictures<numRefs) |
---|
1290 | { |
---|
1291 | m_maxNumberOfReferencePictures=numRefs; |
---|
1292 | } |
---|
1293 | #endif |
---|
1294 | refList[numRefs] = curPOC; |
---|
1295 | numRefs++; |
---|
1296 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1297 | Int nonDisplayed=0; |
---|
1298 | for(Int i=0; i<numRefs; i++) |
---|
1299 | { |
---|
1300 | if(refList[i]==lastDisp+1) |
---|
1301 | { |
---|
1302 | lastDisp=refList[i]; |
---|
1303 | i=0; |
---|
1304 | } |
---|
1305 | } |
---|
1306 | for(Int i=0; i<numRefs; i++) |
---|
1307 | { |
---|
1308 | if(refList[i]>lastDisp) |
---|
1309 | { |
---|
1310 | nonDisplayed++; |
---|
1311 | } |
---|
1312 | } |
---|
1313 | if(nonDisplayed>numReorderFramesRequired) |
---|
1314 | { |
---|
1315 | numReorderFramesRequired=nonDisplayed; |
---|
1316 | } |
---|
1317 | #endif |
---|
1318 | } |
---|
1319 | checkGOP++; |
---|
1320 | } |
---|
1321 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1322 | if (m_numReorderFrames == -1) |
---|
1323 | { |
---|
1324 | m_numReorderFrames = numReorderFramesRequired; |
---|
1325 | } |
---|
1326 | #endif |
---|
1327 | xConfirmPara( errorGOP, "Invalid GOP structure given" ); |
---|
1328 | #if H0566_TLA |
---|
1329 | m_maxTempLayer[viewId] = 1; |
---|
1330 | #endif |
---|
1331 | for( Int i = 0; i < m_iGOPSize; i++ ) |
---|
1332 | { |
---|
1333 | #if H0566_TLA |
---|
1334 | if( m_GOPListsMvc[viewId][i].m_temporalId >= m_maxTempLayer[viewId] ) |
---|
1335 | { |
---|
1336 | m_maxTempLayer[viewId] = m_GOPListsMvc[viewId][i].m_temporalId + 1; |
---|
1337 | } |
---|
1338 | #endif |
---|
1339 | xConfirmPara( m_GOPListsMvc[viewId][i].m_sliceType != 'B' && m_GOPListsMvc[viewId][i].m_sliceType != 'P', "Slice type must be equal to B or P" ); |
---|
1340 | } |
---|
1341 | |
---|
1342 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1343 | for( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
1344 | { |
---|
1345 | m_numReorderPics[viewId][i] = 0; |
---|
1346 | m_maxDecPicBuffering[viewId][i] = 0; |
---|
1347 | } |
---|
1348 | for( Int i = 0; i < m_iGOPSize; i++ ) |
---|
1349 | { |
---|
1350 | if( m_GOPListsMvc[viewId][i].m_numRefPics > m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] ) |
---|
1351 | { |
---|
1352 | m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = m_GOPListsMvc[viewId][i].m_numRefPics; |
---|
1353 | } |
---|
1354 | Int highestDecodingNumberWithLowerPOC = 0; |
---|
1355 | for( Int j = 0; j < m_iGOPSize; j++ ) |
---|
1356 | { |
---|
1357 | if( m_GOPListsMvc[viewId][j].m_POC <= m_GOPListsMvc[viewId][i].m_POC ) |
---|
1358 | { |
---|
1359 | highestDecodingNumberWithLowerPOC = j; |
---|
1360 | } |
---|
1361 | } |
---|
1362 | Int numReorder = 0; |
---|
1363 | for( Int j = 0; j < highestDecodingNumberWithLowerPOC; j++ ) |
---|
1364 | { |
---|
1365 | if( m_GOPListsMvc[viewId][j].m_temporalId <= m_GOPListsMvc[viewId][i].m_temporalId && |
---|
1366 | m_GOPListsMvc[viewId][j].m_POC > m_GOPListsMvc[viewId][i].m_POC ) |
---|
1367 | { |
---|
1368 | numReorder++; |
---|
1369 | } |
---|
1370 | } |
---|
1371 | if( numReorder > m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] ) |
---|
1372 | { |
---|
1373 | m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = numReorder; |
---|
1374 | } |
---|
1375 | } |
---|
1376 | for( Int i = 0; i < MAX_TLAYER-1; i++ ) |
---|
1377 | { |
---|
1378 | // a lower layer can not have higher value of m_numReorderPics than a higher layer |
---|
1379 | if( m_numReorderPics[viewId][i+1] < m_numReorderPics[viewId][i] ) |
---|
1380 | { |
---|
1381 | m_numReorderPics[viewId][i+1] = m_numReorderPics[viewId][i]; |
---|
1382 | } |
---|
1383 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive |
---|
1384 | if( m_numReorderPics[viewId][i] > m_maxDecPicBuffering[viewId][i] ) |
---|
1385 | { |
---|
1386 | m_maxDecPicBuffering[viewId][i] = m_numReorderPics[viewId][i]; |
---|
1387 | } |
---|
1388 | // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer |
---|
1389 | if( m_maxDecPicBuffering[viewId][i+1] < m_maxDecPicBuffering[viewId][i] ) |
---|
1390 | { |
---|
1391 | m_maxDecPicBuffering[viewId][i+1] = m_maxDecPicBuffering[viewId][i]; |
---|
1392 | } |
---|
1393 | } |
---|
1394 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive |
---|
1395 | if( m_numReorderPics[viewId][MAX_TLAYER-1] > m_maxDecPicBuffering[viewId][MAX_TLAYER-1] ) |
---|
1396 | { |
---|
1397 | m_maxDecPicBuffering[viewId][MAX_TLAYER-1] = m_numReorderPics[viewId][MAX_TLAYER-1]; |
---|
1398 | } |
---|
1399 | #endif |
---|
1400 | |
---|
1401 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1402 | xConfirmPara( m_bUseLComb == false && m_numReorderPics[viewId][MAX_TLAYER-1] != 0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" ); // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1. |
---|
1403 | #else |
---|
1404 | xConfirmPara( m_bUseLComb==false && m_numReorderFrames!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" ); // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1. |
---|
1405 | xConfirmPara( m_numReorderFrames < numReorderFramesRequired, "For the used GOP the encoder requires more pictures for reordering than specified in MaxNumberOfReorderPictures" ); |
---|
1406 | #endif |
---|
1407 | } |
---|
1408 | } |
---|
1409 | #undef xConfirmPara |
---|
1410 | if( check_failed ) |
---|
1411 | { |
---|
1412 | exit(EXIT_FAILURE); |
---|
1413 | } |
---|
1414 | } |
---|
1415 | |
---|
1416 | template <class T> |
---|
1417 | Void |
---|
1418 | TAppEncCfg::xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid ) |
---|
1419 | { |
---|
1420 | Int iFirstInv = (Int)rcVec.size(); |
---|
1421 | for( Int iIdx = 0; iIdx < (Int)rcVec.size(); iIdx++ ) |
---|
1422 | { |
---|
1423 | if( rcVec[ iIdx ] == rcInvalid ) |
---|
1424 | { |
---|
1425 | iFirstInv = iIdx; |
---|
1426 | break; |
---|
1427 | } |
---|
1428 | } |
---|
1429 | while( (Int)rcVec.size() > iFirstInv ) |
---|
1430 | { |
---|
1431 | rcVec.pop_back(); |
---|
1432 | } |
---|
1433 | } |
---|
1434 | |
---|
1435 | Void |
---|
1436 | TAppEncCfg::xCleanUpVectors() |
---|
1437 | { |
---|
1438 | xCleanUpVector( m_pchInputFileList, (char*)0 ); |
---|
1439 | xCleanUpVector( m_pchDepthInputFileList, (char*)0 ); |
---|
1440 | xCleanUpVector( m_pchReconFileList, (char*)0 ); |
---|
1441 | xCleanUpVector( m_pchDepthReconFileList, (char*)0 ); |
---|
1442 | } |
---|
1443 | |
---|
1444 | /** \todo use of global variables should be removed later |
---|
1445 | */ |
---|
1446 | Void TAppEncCfg::xSetGlobal() |
---|
1447 | { |
---|
1448 | // set max CU width & height |
---|
1449 | g_uiMaxCUWidth = m_uiMaxCUWidth; |
---|
1450 | g_uiMaxCUHeight = m_uiMaxCUHeight; |
---|
1451 | |
---|
1452 | // compute actual CU depth with respect to config depth and max transform size |
---|
1453 | g_uiAddCUDepth = 0; |
---|
1454 | while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth ) ) ) g_uiAddCUDepth++; |
---|
1455 | |
---|
1456 | m_uiMaxCUDepth += g_uiAddCUDepth; |
---|
1457 | g_uiAddCUDepth++; |
---|
1458 | g_uiMaxCUDepth = m_uiMaxCUDepth; |
---|
1459 | |
---|
1460 | // set internal bit-depth and constants |
---|
1461 | #if FULL_NBIT |
---|
1462 | g_uiBitDepth = m_uiInternalBitDepth; |
---|
1463 | g_uiBitIncrement = 0; |
---|
1464 | #else |
---|
1465 | g_uiBitDepth = 8; |
---|
1466 | g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth; |
---|
1467 | #endif |
---|
1468 | |
---|
1469 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1470 | g_iDeltaDCsQuantOffset = g_uiBitIncrement - 2; |
---|
1471 | #endif |
---|
1472 | |
---|
1473 | g_uiBASE_MAX = ((1<<(g_uiBitDepth))-1); |
---|
1474 | |
---|
1475 | #if IBDI_NOCLIP_RANGE |
---|
1476 | g_uiIBDI_MAX = g_uiBASE_MAX << g_uiBitIncrement; |
---|
1477 | #else |
---|
1478 | g_uiIBDI_MAX = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1); |
---|
1479 | #endif |
---|
1480 | |
---|
1481 | if (m_uiOutputBitDepth == 0) |
---|
1482 | { |
---|
1483 | m_uiOutputBitDepth = m_uiInternalBitDepth; |
---|
1484 | } |
---|
1485 | |
---|
1486 | g_uiPCMBitDepthLuma = m_uiPCMBitDepthLuma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth); |
---|
1487 | g_uiPCMBitDepthChroma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth); |
---|
1488 | } |
---|
1489 | |
---|
1490 | Void TAppEncCfg::xPrintParameter() |
---|
1491 | { |
---|
1492 | printf("\n"); |
---|
1493 | for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++) |
---|
1494 | { |
---|
1495 | printf("Texture Input File %i : %s\n", iCounter, m_pchInputFileList[iCounter]); |
---|
1496 | } |
---|
1497 | if( m_bUsingDepthMaps ) |
---|
1498 | { |
---|
1499 | for( Int iCounter = 0; iCounter < m_iNumberOfViews; iCounter++) |
---|
1500 | { |
---|
1501 | printf("Depth Input File %i : %s\n", iCounter, m_pchDepthInputFileList[iCounter]); |
---|
1502 | } |
---|
1503 | } |
---|
1504 | printf("Bitstream File : %s\n", m_pchBitstreamFile ); |
---|
1505 | for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++) |
---|
1506 | { |
---|
1507 | printf("Texture Reconstruction File %i : %s\n", iCounter, m_pchReconFileList[iCounter]); |
---|
1508 | } |
---|
1509 | if( m_bUsingDepthMaps ) |
---|
1510 | { |
---|
1511 | for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++) |
---|
1512 | { |
---|
1513 | printf("Depth Reconstruction File %i : %s\n", iCounter, m_pchDepthReconFileList[iCounter]); |
---|
1514 | } |
---|
1515 | } |
---|
1516 | #if PIC_CROPPING |
---|
1517 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate ); |
---|
1518 | #else |
---|
1519 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_aiPad[0], m_iSourceHeight-m_aiPad[1], m_iFrameRate ); |
---|
1520 | #endif |
---|
1521 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
---|
1522 | printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded ); |
---|
1523 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
---|
1524 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
1525 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
---|
1526 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
---|
1527 | printf("Min PCM size : %d\n", 1 << m_uiPCMLog2MinSize); |
---|
1528 | printf("Motion search range : %d\n", m_iSearchRange ); |
---|
1529 | printf("Intra period : %d\n", m_iIntraPeriod ); |
---|
1530 | printf("Decoding refresh type : %d\n", m_iDecodingRefreshType ); |
---|
1531 | printf("QP Texture : %5.2f\n", m_adQP[0] ); |
---|
1532 | if( m_bUsingDepthMaps ) |
---|
1533 | { |
---|
1534 | printf("QP Depth : %5.2f\n", m_adQP[ m_adQP.size() < 2 ? 0 : 1] ); |
---|
1535 | } |
---|
1536 | printf("Max dQP signaling depth : %d\n", m_iMaxCuDQPDepth); |
---|
1537 | |
---|
1538 | printf("Chroma Qp Offset : %d\n", m_iChromaQpOffset ); |
---|
1539 | printf("Chroma Qp Offset 2nd : %d\n", m_iChromaQpOffset2nd); |
---|
1540 | |
---|
1541 | printf("QP adaptation : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) ); |
---|
1542 | printf("GOP size : %d\n", m_iGOPSize ); |
---|
1543 | printf("Internal bit depth : %d\n", m_uiInternalBitDepth ); |
---|
1544 | printf("PCM sample bit depth : %d\n", m_uiPCMBitDepthLuma ); |
---|
1545 | if((m_uiMaxCUWidth >> m_uiMaxCUDepth) == 4) |
---|
1546 | { |
---|
1547 | printf("DisableInter4x4 : %d\n", m_bDisInter4x4); |
---|
1548 | } |
---|
1549 | |
---|
1550 | printf("Loop Filter Disabled : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0, m_abLoopFilterDisable[1] ? 1 : 0 ); |
---|
1551 | printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision); |
---|
1552 | |
---|
1553 | #if HHI_VSO |
---|
1554 | printf("Force use of Lambda Scale : %d\n", m_bForceLambdaScaleVSO ); |
---|
1555 | |
---|
1556 | if ( m_bUseVSO ) |
---|
1557 | { |
---|
1558 | printf("VSO Lambda Scale : %5.2f\n", m_dLambdaScaleVSO ); |
---|
1559 | printf("VSO Mode : %d\n", m_uiVSOMode ); |
---|
1560 | printf("VSO Config : %s\n", m_pchVSOConfig ); |
---|
1561 | #if HHI_VSO_DIST_INT |
---|
1562 | printf("VSO Negative Distortion : %d\n", m_bAllowNegDist ? 1 : 0); |
---|
1563 | #endif |
---|
1564 | } |
---|
1565 | #endif |
---|
1566 | #if HHI_INTERVIEW_SKIP |
---|
1567 | printf("InterView Skip: : %d\n", m_bInterViewSkip ? 1:0 ); |
---|
1568 | printf("InterView Skip Lambda Scale : %f\n", m_dInterViewSkipLambdaScale ); |
---|
1569 | #endif |
---|
1570 | |
---|
1571 | printf("\n"); |
---|
1572 | |
---|
1573 | printf("TOOL CFG General: "); |
---|
1574 | #if LCU_SYNTAX_ALF |
---|
1575 | printf("ALFMNF:%d ", m_iALFMaxNumberFilters); |
---|
1576 | printf("ALFInSlice:%d ", m_bALFParamInSlice); |
---|
1577 | printf("ALFPicEnc:%d ", m_bALFPicBasedEncode); |
---|
1578 | #endif |
---|
1579 | printf("IBD:%d ", !!g_uiBitIncrement); |
---|
1580 | printf("HAD:%d ", m_bUseHADME ); |
---|
1581 | printf("SRD:%d ", m_bUseSBACRD ); |
---|
1582 | printf("SQP:%d ", m_uiDeltaQpRD ); |
---|
1583 | printf("ASR:%d ", m_bUseASR ); |
---|
1584 | #if !PIC_CROPPING |
---|
1585 | printf("PAD:%d ", m_bUsePAD ); |
---|
1586 | #endif |
---|
1587 | printf("LComb:%d ", m_bUseLComb ); |
---|
1588 | printf("LCMod:%d ", m_bLCMod ); |
---|
1589 | printf("FEN:%d ", m_bUseFastEnc ); |
---|
1590 | printf("ECU:%d ", m_bUseEarlyCU ); |
---|
1591 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
1592 | printf("FDM:%d ", m_useFastDecisionForMerge ); |
---|
1593 | #endif |
---|
1594 | printf("CFM:%d ", m_bUseCbfFastMode ); |
---|
1595 | printf("RQT:%d ", 1 ); |
---|
1596 | printf("LMC:%d ", m_bUseLMChroma ); |
---|
1597 | printf("Slice: G=%d M=%d ", m_iSliceGranularity, m_iSliceMode); |
---|
1598 | if (m_iSliceMode!=0) |
---|
1599 | { |
---|
1600 | printf("A=%d ", m_iSliceArgument); |
---|
1601 | } |
---|
1602 | printf("EntropySlice: M=%d ",m_iEntropySliceMode); |
---|
1603 | if (m_iEntropySliceMode!=0) |
---|
1604 | { |
---|
1605 | printf("A=%d ", m_iEntropySliceArgument); |
---|
1606 | } |
---|
1607 | printf("CIP:%d ", m_bUseConstrainedIntraPred); |
---|
1608 | #if BURST_IPCM |
---|
1609 | printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0); |
---|
1610 | #else |
---|
1611 | printf("PCM:%d ", ((1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0); |
---|
1612 | #endif |
---|
1613 | #if SAO_UNIT_INTERLEAVING |
---|
1614 | printf("SAOInterleaving:%d ", (m_saoInterleavingFlag)?(1):(0)); |
---|
1615 | #endif |
---|
1616 | #if LOSSLESS_CODING |
---|
1617 | printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 ); |
---|
1618 | #endif |
---|
1619 | printf("WPP:%d ", (Int)m_bUseWeightPred); |
---|
1620 | printf("WPB:%d ", m_uiBiPredIdc); |
---|
1621 | #if !REMOVE_TILE_DEPENDENCE |
---|
1622 | printf("TileBoundaryIndependence:%d ", m_iTileBoundaryIndependenceIdr ); |
---|
1623 | #endif |
---|
1624 | printf("TileLocationInSliceHdr:%d ", m_iTileLocationInSliceHeaderFlag); |
---|
1625 | printf("TileMarker:%d", m_iTileMarkerFlag); |
---|
1626 | if (m_iTileMarkerFlag) |
---|
1627 | { |
---|
1628 | printf("[%d] ", m_iMaxTileMarkerEntryPoints); |
---|
1629 | } |
---|
1630 | else |
---|
1631 | { |
---|
1632 | printf(" "); |
---|
1633 | } |
---|
1634 | printf(" WaveFrontSynchro:%d WaveFrontFlush:%d WaveFrontSubstreams:%d", |
---|
1635 | m_iWaveFrontSynchro, m_iWaveFrontFlush, m_iWaveFrontSubstreams); |
---|
1636 | printf(" ScalingList:%d ", m_useScalingListId ); |
---|
1637 | |
---|
1638 | printf("TMVP:%d ", m_enableTMVP ); |
---|
1639 | |
---|
1640 | #if ADAPTIVE_QP_SELECTION |
---|
1641 | printf("AQpS:%d", m_bUseAdaptQpSelect ); |
---|
1642 | #endif |
---|
1643 | |
---|
1644 | #if MULTIBITS_DATA_HIDING |
---|
1645 | printf(" SignBitHidingFlag:%d SignBitHidingThreshold:%d", m_signHideFlag, m_signHidingThreshold); |
---|
1646 | #endif |
---|
1647 | printf("\n"); |
---|
1648 | printf("TOOL CFG VIDEO : "); |
---|
1649 | printf("ALF:%d ", (m_abUseALF [0] ? 1 : 0) ); |
---|
1650 | printf("SAO:%d ", (m_abUseSAO [0] ? 1 : 0)); |
---|
1651 | printf("RDQ:%d ", (m_abUseRDOQ[0] ? 1 : 0) ); |
---|
1652 | printf("\n"); |
---|
1653 | |
---|
1654 | printf("TOOL CFG DEPTH : "); |
---|
1655 | printf("ALF:%d ", (m_abUseALF [1] ? 1 : 0)); |
---|
1656 | printf("SAO:%d ", (m_abUseSAO [1] ? 1 : 0)); |
---|
1657 | printf("RDQ:%d ", (m_abUseRDOQ[1] ? 1 : 0)); |
---|
1658 | #if HHI_VSO |
---|
1659 | printf("VSO:%d ", m_bUseVSO ); |
---|
1660 | #endif |
---|
1661 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1662 | printf("DMM:%d ", m_bUseDMM ); |
---|
1663 | #endif |
---|
1664 | #if HHI_MPI |
---|
1665 | printf("MVI:%d ", m_bUseMVI ? 1 : 0 ); |
---|
1666 | #endif |
---|
1667 | printf("\n\n"); |
---|
1668 | |
---|
1669 | fflush(stdout); |
---|
1670 | } |
---|
1671 | |
---|
1672 | Void TAppEncCfg::xPrintUsage() |
---|
1673 | { |
---|
1674 | printf( " <name> = ALF - adaptive loop filter\n"); |
---|
1675 | printf( " IBD - bit-depth increasement\n"); |
---|
1676 | printf( " GPB - generalized B instead of P in low-delay mode\n"); |
---|
1677 | printf( " HAD - hadamard ME for fractional-pel\n"); |
---|
1678 | printf( " SRD - SBAC based RD estimation\n"); |
---|
1679 | printf( " RDQ - RDOQ\n"); |
---|
1680 | printf( " LDC - low-delay mode\n"); |
---|
1681 | printf( " NRF - non-reference frame marking in last layer\n"); |
---|
1682 | printf( " BQP - hier-P style QP assignment in low-delay mode\n"); |
---|
1683 | printf( " PAD - automatic source padding of multiple of 16\n"); |
---|
1684 | printf( " ASR - adaptive motion search range\n"); |
---|
1685 | printf( " FEN - fast encoder setting\n"); |
---|
1686 | printf( " ECU - Early CU setting\n"); |
---|
1687 | printf( " CFM - Cbf fast mode setting\n"); |
---|
1688 | printf( " LMC - intra chroma prediction based on luma\n"); |
---|
1689 | printf( "\n" ); |
---|
1690 | printf( " Example 1) TAppEncoder.exe -c test.cfg -q 32 -g 8 -f 9 -s 64 -h 4\n"); |
---|
1691 | printf(" -> QP 32, hierarchical-B GOP 8, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n"); |
---|
1692 | printf( " Example 2) TAppEncoder.exe -c test.cfg -q 32 -g 4 -f 9 -s 64 -h 4 -1 LDC\n"); |
---|
1693 | printf(" -> QP 32, hierarchical-P GOP 4, 9 frames, 64x64-8x8 CU (~4x4 PU)\n\n"); |
---|
1694 | } |
---|
1695 | |
---|
1696 | Bool confirmPara(Bool bflag, const char* message) |
---|
1697 | { |
---|
1698 | if (!bflag) |
---|
1699 | return false; |
---|
1700 | |
---|
1701 | printf("Error: %s\n",message); |
---|
1702 | return true; |
---|
1703 | } |
---|
1704 | |
---|
1705 | /* helper function */ |
---|
1706 | /* for handling "-1/-0 FOO" */ |
---|
1707 | void translateOldStyleCmdline(const char* value, po::Options& opts, const std::string& arg) |
---|
1708 | { |
---|
1709 | const char* argv[] = {arg.c_str(), value}; |
---|
1710 | /* replace some short names with their long name varients */ |
---|
1711 | if (arg == "LDC") |
---|
1712 | { |
---|
1713 | argv[0] = "LowDelayCoding"; |
---|
1714 | } |
---|
1715 | else if (arg == "RDQ") |
---|
1716 | { |
---|
1717 | argv[0] = "RDOQ"; |
---|
1718 | } |
---|
1719 | else if (arg == "HAD") |
---|
1720 | { |
---|
1721 | argv[0] = "HadamardME"; |
---|
1722 | } |
---|
1723 | else if (arg == "SRD") |
---|
1724 | { |
---|
1725 | argv[0] = "SBACRD"; |
---|
1726 | } |
---|
1727 | else if (arg == "IBD") |
---|
1728 | { |
---|
1729 | argv[0] = "BitIncrement"; |
---|
1730 | } |
---|
1731 | /* issue a warning for change in FEN behaviour */ |
---|
1732 | if (arg == "FEN") |
---|
1733 | { |
---|
1734 | /* xxx todo */ |
---|
1735 | } |
---|
1736 | po::storePair(opts, argv[0], argv[1]); |
---|
1737 | } |
---|
1738 | |
---|
1739 | void doOldStyleCmdlineOn(po::Options& opts, const std::string& arg) |
---|
1740 | { |
---|
1741 | if (arg == "IBD") |
---|
1742 | { |
---|
1743 | translateOldStyleCmdline("4", opts, arg); |
---|
1744 | return; |
---|
1745 | } |
---|
1746 | translateOldStyleCmdline("1", opts, arg); |
---|
1747 | } |
---|
1748 | |
---|
1749 | void doOldStyleCmdlineOff(po::Options& opts, const std::string& arg) |
---|
1750 | { |
---|
1751 | translateOldStyleCmdline("0", opts, arg); |
---|
1752 | } |
---|
1753 | |
---|
1754 | Void TAppEncCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName) |
---|
1755 | { |
---|
1756 | size_t iInLength = strlen(pchInputFileName); |
---|
1757 | size_t iAppendLength = strlen(pchStringToAppend); |
---|
1758 | |
---|
1759 | rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1); |
---|
1760 | Char* pCDot = strrchr(pchInputFileName,'.'); |
---|
1761 | pCDot = pCDot ? pCDot : pchInputFileName + iInLength; |
---|
1762 | size_t iCharsToDot = pCDot - pchInputFileName ; |
---|
1763 | size_t iCharsToEnd = iInLength - iCharsToDot; |
---|
1764 | strncpy(rpchOutputFileName , pchInputFileName , iCharsToDot ); |
---|
1765 | strncpy(rpchOutputFileName+ iCharsToDot , pchStringToAppend , iAppendLength); |
---|
1766 | strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength , pchInputFileName+iCharsToDot, iCharsToEnd ); |
---|
1767 | rpchOutputFileName[iInLength+iAppendLength] = '\0'; |
---|
1768 | } |
---|
1769 | |
---|
1770 | //! \} |
---|