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 | #include "TLibEncoder/TEncRateCtrl.h" |
---|
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 | // ==================================================================================================================== |
---|
57 | // Constructor / destructor / initialization / destroy |
---|
58 | // ==================================================================================================================== |
---|
59 | |
---|
60 | TAppEncCfg::TAppEncCfg() |
---|
61 | #if SVC_EXTENSION |
---|
62 | : m_pchBitstreamFile() |
---|
63 | , m_pchColumnWidth() |
---|
64 | , m_pchRowHeight() |
---|
65 | , m_scalingListFile() |
---|
66 | #if REF_IDX_FRAMEWORK |
---|
67 | , m_elRapSliceBEnabled(0) |
---|
68 | #endif |
---|
69 | #else |
---|
70 | : m_pchInputFile() |
---|
71 | , m_pchBitstreamFile() |
---|
72 | , m_pchReconFile() |
---|
73 | , m_pchdQPFile() |
---|
74 | , m_pchColumnWidth() |
---|
75 | , m_pchRowHeight() |
---|
76 | , m_scalingListFile() |
---|
77 | #endif |
---|
78 | { |
---|
79 | #if SVC_EXTENSION |
---|
80 | for(UInt layer=0; layer<MAX_LAYERS; layer++) |
---|
81 | { |
---|
82 | m_acLayerCfg[layer].setAppEncCfg(this); |
---|
83 | } |
---|
84 | #else |
---|
85 | m_aidQP = NULL; |
---|
86 | #endif |
---|
87 | } |
---|
88 | |
---|
89 | TAppEncCfg::~TAppEncCfg() |
---|
90 | { |
---|
91 | #if !SVC_EXTENSION |
---|
92 | if ( m_aidQP ) |
---|
93 | { |
---|
94 | delete[] m_aidQP; |
---|
95 | } |
---|
96 | free(m_pchInputFile); |
---|
97 | #endif |
---|
98 | free(m_pchBitstreamFile); |
---|
99 | #if !SVC_EXTENSION |
---|
100 | free(m_pchReconFile); |
---|
101 | free(m_pchdQPFile); |
---|
102 | #endif |
---|
103 | free(m_pchColumnWidth); |
---|
104 | free(m_pchRowHeight); |
---|
105 | free(m_scalingListFile); |
---|
106 | } |
---|
107 | |
---|
108 | Void TAppEncCfg::create() |
---|
109 | { |
---|
110 | } |
---|
111 | |
---|
112 | Void TAppEncCfg::destroy() |
---|
113 | { |
---|
114 | } |
---|
115 | |
---|
116 | std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry) //input |
---|
117 | { |
---|
118 | in>>entry.m_sliceType; |
---|
119 | in>>entry.m_POC; |
---|
120 | in>>entry.m_QPOffset; |
---|
121 | in>>entry.m_QPFactor; |
---|
122 | in>>entry.m_temporalId; |
---|
123 | in>>entry.m_numRefPicsActive; |
---|
124 | #if !TEMPORAL_LAYER_NON_REFERENCE |
---|
125 | in>>entry.m_refPic; |
---|
126 | #endif |
---|
127 | in>>entry.m_numRefPics; |
---|
128 | for ( Int i = 0; i < entry.m_numRefPics; i++ ) |
---|
129 | { |
---|
130 | in>>entry.m_referencePics[i]; |
---|
131 | } |
---|
132 | in>>entry.m_interRPSPrediction; |
---|
133 | #if AUTO_INTER_RPS |
---|
134 | if (entry.m_interRPSPrediction==1) |
---|
135 | { |
---|
136 | #if !J0234_INTER_RPS_SIMPL |
---|
137 | in>>entry.m_deltaRIdxMinus1; |
---|
138 | #endif |
---|
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 | else if (entry.m_interRPSPrediction==2) |
---|
147 | { |
---|
148 | #if !J0234_INTER_RPS_SIMPL |
---|
149 | in>>entry.m_deltaRIdxMinus1; |
---|
150 | #endif |
---|
151 | in>>entry.m_deltaRPS; |
---|
152 | } |
---|
153 | #else |
---|
154 | if (entry.m_interRPSPrediction) |
---|
155 | { |
---|
156 | #if !J0234_INTER_RPS_SIMPL |
---|
157 | in>>entry.m_deltaRIdxMinus1; |
---|
158 | #endif |
---|
159 | in>>entry.m_deltaRPS; |
---|
160 | in>>entry.m_numRefIdc; |
---|
161 | for ( Int i = 0; i < entry.m_numRefIdc; i++ ) |
---|
162 | { |
---|
163 | in>>entry.m_refIdc[i]; |
---|
164 | } |
---|
165 | } |
---|
166 | #endif |
---|
167 | return in; |
---|
168 | } |
---|
169 | |
---|
170 | #if SVC_EXTENSION |
---|
171 | void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path) |
---|
172 | { |
---|
173 | size_t pos = path.find_last_of("\\"); |
---|
174 | if(pos != std::string::npos) |
---|
175 | { |
---|
176 | filename.assign(path.begin() + pos + 1, path.end()); |
---|
177 | dir.assign(path.begin(), path.begin() + pos + 1); |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | pos = path.find_last_of("/"); |
---|
182 | if(pos != std::string::npos) |
---|
183 | { |
---|
184 | filename.assign(path.begin() + pos + 1, path.end()); |
---|
185 | dir.assign(path.begin(), path.begin() + pos + 1); |
---|
186 | } |
---|
187 | else |
---|
188 | { |
---|
189 | filename = path; |
---|
190 | dir.assign(""); |
---|
191 | } |
---|
192 | } |
---|
193 | } |
---|
194 | #endif |
---|
195 | |
---|
196 | // ==================================================================================================================== |
---|
197 | // Public member functions |
---|
198 | // ==================================================================================================================== |
---|
199 | |
---|
200 | /** \param argc number of arguments |
---|
201 | \param argv array of arguments |
---|
202 | \retval true when success |
---|
203 | */ |
---|
204 | Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] ) |
---|
205 | { |
---|
206 | bool do_help = false; |
---|
207 | |
---|
208 | #if SVC_EXTENSION |
---|
209 | string cfg_LayerCfgFile [MAX_LAYERS]; |
---|
210 | string cfg_BitstreamFile; |
---|
211 | string* cfg_InputFile [MAX_LAYERS]; |
---|
212 | string* cfg_ReconFile [MAX_LAYERS]; |
---|
213 | Double* cfg_fQP [MAX_LAYERS]; |
---|
214 | |
---|
215 | Int* cfg_SourceWidth [MAX_LAYERS]; |
---|
216 | Int* cfg_SourceHeight [MAX_LAYERS]; |
---|
217 | Int* cfg_FrameRate [MAX_LAYERS]; |
---|
218 | Int* cfg_IntraPeriod [MAX_LAYERS]; |
---|
219 | Int* cfg_CroppingMode [MAX_LAYERS]; |
---|
220 | for(UInt layer = 0; layer < MAX_LAYERS; layer++) |
---|
221 | { |
---|
222 | cfg_InputFile[layer] = &m_acLayerCfg[layer].m_cInputFile; |
---|
223 | cfg_ReconFile[layer] = &m_acLayerCfg[layer].m_cReconFile; |
---|
224 | cfg_fQP[layer] = &m_acLayerCfg[layer].m_fQP; |
---|
225 | cfg_SourceWidth[layer] = &m_acLayerCfg[layer].m_iSourceWidth; |
---|
226 | cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight; |
---|
227 | cfg_FrameRate[layer] = &m_acLayerCfg[layer].m_iFrameRate; |
---|
228 | cfg_IntraPeriod[layer] = &m_acLayerCfg[layer].m_iIntraPeriod; |
---|
229 | cfg_CroppingMode[layer] = &m_acLayerCfg[layer].m_croppingMode; |
---|
230 | } |
---|
231 | #if AVC_SYNTAX |
---|
232 | string cfg_BLSyntaxFile; |
---|
233 | #endif |
---|
234 | #else |
---|
235 | string cfg_InputFile; |
---|
236 | string cfg_BitstreamFile; |
---|
237 | string cfg_ReconFile; |
---|
238 | string cfg_dQPFile; |
---|
239 | #endif |
---|
240 | string cfg_ColumnWidth; |
---|
241 | string cfg_RowHeight; |
---|
242 | string cfg_ScalingListFile; |
---|
243 | po::Options opts; |
---|
244 | opts.addOptions() |
---|
245 | ("help", do_help, false, "this help text") |
---|
246 | ("c", po::parseConfigFile, "configuration file name") |
---|
247 | |
---|
248 | // File, I/O and source parameters |
---|
249 | #if SVC_EXTENSION |
---|
250 | ("InputFile%d,-i%d", cfg_InputFile, string(""), MAX_LAYERS, "original YUV input file name for layer %d") |
---|
251 | ("ReconFile%d,-o%d", cfg_ReconFile, string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d") |
---|
252 | ("LayerConfig%d,-lc%d", cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name") |
---|
253 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream output file name") |
---|
254 | ("SourceWidth%d,-wdt%d", cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d") |
---|
255 | ("SourceHeight%d,-hgt%d", cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d") |
---|
256 | ("FrameRate%d,-fr%d", cfg_FrameRate, 0, MAX_LAYERS, "Frame rate for layer %d") |
---|
257 | ("LambdaModifier%d,-LM%d", m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d") |
---|
258 | ("CroppingMode%d", cfg_CroppingMode,0, MAX_LAYERS, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping") |
---|
259 | ("InputBitDepth", m_uiInputBitDepth, 8u, "bit-depth of input file") |
---|
260 | ("BitDepth", m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth") |
---|
261 | ("OutputBitDepth", m_uiOutputBitDepth, 0u, "bit-depth of output file") |
---|
262 | ("InternalBitDepth", m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)") |
---|
263 | #if AVC_BASE |
---|
264 | ("InputBLFile,-ibl", *cfg_InputFile[0], string(""), "Base layer rec YUV input file name") |
---|
265 | #if AVC_SYNTAX |
---|
266 | ("InputBLSyntaxFile,-ibs", cfg_BLSyntaxFile, string(""), "Base layer syntax input file name") |
---|
267 | #endif |
---|
268 | #endif |
---|
269 | #if REF_IDX_FRAMEWORK |
---|
270 | ("EnableElRapB,-use-rap-b", m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture_") |
---|
271 | #endif |
---|
272 | #else |
---|
273 | ("InputFile,i", cfg_InputFile, string(""), "Original YUV input file name") |
---|
274 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "Bitstream output file name") |
---|
275 | ("ReconFile,o", cfg_ReconFile, string(""), "Reconstructed YUV output file name") |
---|
276 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
---|
277 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
---|
278 | ("InputBitDepth", m_uiInputBitDepth, 8u, "Bit-depth of input file") |
---|
279 | ("BitDepth", m_uiInputBitDepth, 8u, "Deprecated alias of InputBitDepth") |
---|
280 | ("OutputBitDepth", m_uiOutputBitDepth, 0u, "Bit-depth of output file") |
---|
281 | ("InternalBitDepth", m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)") |
---|
282 | ("CroppingMode", m_croppingMode, 0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping") |
---|
283 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "Horizontal source padding for cropping mode 2") |
---|
284 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "Vertical source padding for cropping mode 2") |
---|
285 | ("CropLeft", m_cropLeft, 0, "Left cropping for cropping mode 3") |
---|
286 | ("CropRight", m_cropRight, 0, "Right cropping for cropping mode 3") |
---|
287 | ("CropTop", m_cropTop, 0, "Top cropping for cropping mode 3") |
---|
288 | ("CropBottom", m_cropBottom, 0, "Bottom cropping for cropping mode 3") |
---|
289 | ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") |
---|
290 | #endif |
---|
291 | ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") |
---|
292 | ("FramesToBeEncoded,f", m_iFrameToBeEncoded, 0, "Number of frames to be encoded (default=all)") |
---|
293 | |
---|
294 | #if SVC_EXTENSION |
---|
295 | ("NumLayers", m_numLayers, 1, "Number of layers to code") |
---|
296 | #endif |
---|
297 | |
---|
298 | // Unit definition parameters |
---|
299 | ("MaxCUWidth", m_uiMaxCUWidth, 64u) |
---|
300 | ("MaxCUHeight", m_uiMaxCUHeight, 64u) |
---|
301 | // todo: remove defaults from MaxCUSize |
---|
302 | ("MaxCUSize,s", m_uiMaxCUWidth, 64u, "Maximum CU size") |
---|
303 | ("MaxCUSize,s", m_uiMaxCUHeight, 64u, "Maximum CU size") |
---|
304 | ("MaxPartitionDepth,h", m_uiMaxCUDepth, 4u, "CU depth") |
---|
305 | |
---|
306 | ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u, "Maximum TU size in logarithm base 2") |
---|
307 | ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u, "Minimum TU size in logarithm base 2") |
---|
308 | |
---|
309 | ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs") |
---|
310 | ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs") |
---|
311 | |
---|
312 | // Coding structure paramters |
---|
313 | #if SVC_EXTENSION |
---|
314 | ("IntraPeriod%d,-ip%d", cfg_IntraPeriod, -1, MAX_LAYERS, "intra period in frames for layer %d, (-1: only first frame)") |
---|
315 | #else |
---|
316 | ("IntraPeriod,-ip", m_iIntraPeriod, -1, "Intra period in frames, (-1: only first frame)") |
---|
317 | #endif |
---|
318 | ("DecodingRefreshType,-dr", m_iDecodingRefreshType, 0, "Intra refresh type (0:none 1:CRA 2:IDR)") |
---|
319 | ("GOPSize,g", m_iGOPSize, 1, "GOP size of temporal structure") |
---|
320 | ("ListCombination,-lc", m_bUseLComb, true, "Combined reference list for uni-prediction estimation in B-slices") |
---|
321 | // motion options |
---|
322 | ("FastSearch", m_iFastSearch, 1, "0:Full search 1:Diamond 2:PMVFAST") |
---|
323 | ("SearchRange,-sr", m_iSearchRange, 96, "Motion search range") |
---|
324 | ("BipredSearchRange", m_bipredSearchRange, 4, "Motion search range for bipred refinement") |
---|
325 | ("HadamardME", m_bUseHADME, true, "Hadamard ME for fractional-pel") |
---|
326 | ("ASR", m_bUseASR, false, "Adaptive motion search range") |
---|
327 | |
---|
328 | #if !SVC_EXTENSION |
---|
329 | // Mode decision parameters |
---|
330 | ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( double )1.0, "Lambda modifier for temporal layer 0") |
---|
331 | ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( double )1.0, "Lambda modifier for temporal layer 1") |
---|
332 | ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( double )1.0, "Lambda modifier for temporal layer 2") |
---|
333 | ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( double )1.0, "Lambda modifier for temporal layer 3") |
---|
334 | ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( double )1.0, "Lambda modifier for temporal layer 4") |
---|
335 | ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( double )1.0, "Lambda modifier for temporal layer 5") |
---|
336 | ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( double )1.0, "Lambda modifier for temporal layer 6") |
---|
337 | ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( double )1.0, "Lambda modifier for temporal layer 7") |
---|
338 | #endif |
---|
339 | |
---|
340 | /* Quantization parameters */ |
---|
341 | #if SVC_EXTENSION |
---|
342 | ("QP%d,-q%d", cfg_fQP, 30.0, MAX_LAYERS, "Qp value for layer %d, if value is float, QP is switched once during encoding") |
---|
343 | #else |
---|
344 | ("QP,q", m_fQP, 30.0, "Qp value, if value is float, QP is switched once during encoding") |
---|
345 | #endif |
---|
346 | ("DeltaQpRD,-dqr",m_uiDeltaQpRD, 0u, "max dQp offset for slice") |
---|
347 | ("MaxDeltaQP,d", m_iMaxDeltaQP, 0, "max dQp offset for block") |
---|
348 | ("MaxCuDQPDepth,-dqd", m_iMaxCuDQPDepth, 0, "max depth for a minimum CuDQP") |
---|
349 | |
---|
350 | ("CbQpOffset,-cbqpofs", m_cbQpOffset, 0, "Chroma Cb QP Offset") |
---|
351 | ("CrQpOffset,-crqpofs", m_crQpOffset, 0, "Chroma Cr QP Offset") |
---|
352 | |
---|
353 | #if ADAPTIVE_QP_SELECTION |
---|
354 | ("AdaptiveQpSelection,-aqps", m_bUseAdaptQpSelect, false, "AdaptiveQpSelection") |
---|
355 | #endif |
---|
356 | |
---|
357 | ("AdaptiveQP,-aq", m_bUseAdaptiveQP, false, "QP adaptation based on a psycho-visual model") |
---|
358 | ("MaxQPAdaptationRange,-aqr", m_iQPAdaptationRange, 6, "QP adaptation range") |
---|
359 | #if !SVC_EXTENSION |
---|
360 | ("dQPFile,m", cfg_dQPFile, string(""), "dQP file name") |
---|
361 | #endif |
---|
362 | ("RDOQ", m_bUseRDOQ, true ) |
---|
363 | |
---|
364 | // Entropy coding parameters |
---|
365 | ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation") |
---|
366 | |
---|
367 | // Deblocking filter parameters |
---|
368 | ("LoopFilterDisable", m_bLoopFilterDisable, false ) |
---|
369 | ("LoopFilterOffsetInPPS", m_loopFilterOffsetInPPS, false ) |
---|
370 | ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0 ) |
---|
371 | ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0 ) |
---|
372 | ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false ) |
---|
373 | |
---|
374 | // Coding tools |
---|
375 | #if !REMOVE_NSQT |
---|
376 | ("NSQT", m_enableNSQT, true, "Enable non-square transforms") |
---|
377 | #endif |
---|
378 | ("AMP", m_enableAMP, true, "Enable asymmetric motion partitions") |
---|
379 | #if !REMOVE_LMCHROMA |
---|
380 | ("LMChroma", m_bUseLMChroma, true, "Intra chroma prediction based on reconstructed luma") |
---|
381 | #endif |
---|
382 | ("TransformSkip", m_useTransformSkip, false, "Intra transform skipping") |
---|
383 | ("TransformSkipFast", m_useTransformSkipFast, false, "Fast intra transform skipping") |
---|
384 | #if !REMOVE_ALF |
---|
385 | ("ALF", m_bUseALF, true, "Enable Adaptive Loop Filter") |
---|
386 | #endif |
---|
387 | ("SAO", m_bUseSAO, true, "Enable Sample Adaptive Offset") |
---|
388 | ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "Max number of SAO offset per picture (Default: 2048)") |
---|
389 | #if SAO_LCU_BOUNDARY |
---|
390 | ("SAOLcuBoundary", m_saoLcuBoundary, false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas") |
---|
391 | #endif |
---|
392 | ("SAOLcuBasedOptimization", m_saoLcuBasedOptimization, true, "0: SAO picture-based optimization, 1: SAO LCU-based optimization ") |
---|
393 | #if !REMOVE_ALF |
---|
394 | ("ALFLowLatencyEncode", m_alfLowLatencyEncoding, false, "Low-latency ALF encoding, 0: picture latency (trained from current frame), 1: LCU latency(trained from previous frame)") |
---|
395 | #endif |
---|
396 | ("SliceMode", m_iSliceMode, 0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes") |
---|
397 | ("SliceArgument", m_iSliceArgument, 0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.") |
---|
398 | ("DependentSliceMode", m_iDependentSliceMode, 0, "0: Disable all dependent slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based dependent slices") |
---|
399 | ("DependentSliceArgument", m_iDependentSliceArgument,0, "if DependentSliceMode==1 SliceArgument represents max # of LCUs. if DependentSliceMode==2 DependentSliceArgument represents max # of bins.") |
---|
400 | #if DEPENDENT_SLICES |
---|
401 | #if TILES_WPP_ENTROPYSLICES_FLAGS |
---|
402 | ("EntropySliceEnabledFlag", m_entropySliceEnabledFlag, false, "Enable use of entropy slices instead of dependent slices." ) |
---|
403 | #else |
---|
404 | ("CabacIndependentFlag", m_bCabacIndependentFlag, false) |
---|
405 | #endif |
---|
406 | #endif |
---|
407 | #if !REMOVE_FGS |
---|
408 | ("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.") |
---|
409 | #endif |
---|
410 | ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true) |
---|
411 | |
---|
412 | ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction") |
---|
413 | ("PCMEnabledFlag", m_usePCM , false) |
---|
414 | ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u) |
---|
415 | ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u) |
---|
416 | |
---|
417 | ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true) |
---|
418 | ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false) |
---|
419 | ("LosslessCuEnabled", m_useLossless, false) |
---|
420 | ("weighted_pred_flag,-wpP", m_bUseWeightPred, false, "weighted prediction flag (P-Slices)") |
---|
421 | ("weighted_bipred_flag,-wpB", m_useWeightedBiPred, false, "weighted bipred flag (B-Slices)") |
---|
422 | ("Log2ParallelMergeLevel", m_log2ParallelMergeLevel, 2u, "Parallel merge estimation region") |
---|
423 | ("UniformSpacingIdc", m_iUniformSpacingIdr, 0, "Indicates if the column and row boundaries are distributed uniformly") |
---|
424 | ("NumTileColumnsMinus1", m_iNumColumnsMinus1, 0, "Number of columns in a picture minus 1") |
---|
425 | ("ColumnWidthArray", cfg_ColumnWidth, string(""), "Array containing ColumnWidth values in units of LCU") |
---|
426 | ("NumTileRowsMinus1", m_iNumRowsMinus1, 0, "Number of rows in a picture minus 1") |
---|
427 | ("RowHeightArray", cfg_RowHeight, string(""), "Array containing RowHeight values in units of LCU") |
---|
428 | ("LFCrossTileBoundaryFlag", m_bLFCrossTileBoundaryFlag, true, "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering") |
---|
429 | ("WaveFrontSynchro", m_iWaveFrontSynchro, 0, "0: no synchro; 1 synchro with TR; 2 TRR etc") |
---|
430 | ("ScalingList", m_useScalingListId, 0, "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile") |
---|
431 | ("ScalingListFile", cfg_ScalingListFile, string(""), "Scaling list file name") |
---|
432 | ("SignHideFlag,-SBH", m_signHideFlag, 1) |
---|
433 | ("MaxNumMergeCand", m_maxNumMergeCand, 5u, "Maximum number of merge candidates") |
---|
434 | |
---|
435 | /* Misc. */ |
---|
436 | ("SEIpictureDigest", m_decodePictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n" |
---|
437 | "\t3: checksum\n" |
---|
438 | "\t2: CRC\n" |
---|
439 | "\t1: use MD5\n" |
---|
440 | "\t0: disable") |
---|
441 | ("TMVPMode", m_TMVPModeId, 1, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only") |
---|
442 | ("FEN", m_bUseFastEnc, false, "fast encoder setting") |
---|
443 | ("ECU", m_bUseEarlyCU, false, "Early CU setting") |
---|
444 | ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") |
---|
445 | ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting") |
---|
446 | ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting") |
---|
447 | ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off") |
---|
448 | ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate") |
---|
449 | ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit") |
---|
450 | |
---|
451 | ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS") |
---|
452 | ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled") |
---|
453 | #if RECALCULATE_QP_ACCORDING_LAMBDA |
---|
454 | ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case") |
---|
455 | #endif |
---|
456 | #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE |
---|
457 | ("ActiveParameterSets", m_activeParameterSetsSEIEnabled, 0, "Control generation of active parameter sets SEI messages\n" |
---|
458 | "\t2: enable active parameter sets SEI message with active_sps_id\n" |
---|
459 | "\t1: enable active parameter sets SEI message without active_sps_id\n" |
---|
460 | "\t0: disable") |
---|
461 | #endif |
---|
462 | #if SUPPORT_FOR_VUI |
---|
463 | ("VuiParametersPresent,-vui", m_vuiParametersPresentFlag, false, "Enable generation of vui_parameters()") |
---|
464 | ("AspectRatioInfoPresent", m_aspectRatioInfoPresentFlag, false, "Signals whether aspect_ratio_idc is present") |
---|
465 | ("AspectRatioIdc", m_aspectRatioIdc, 0, "aspect_ratio_idc") |
---|
466 | ("SarWidth", m_sarWidth, 0, "horizontal size of the sample aspect ratio") |
---|
467 | ("SarHeight", m_sarHeight, 0, "vertical size of the sample aspect ratio") |
---|
468 | ("OverscanInfoPresent", m_overscanInfoPresentFlag, false, "Indicates whether cropped decoded pictures are suitable for display using overscan\n") |
---|
469 | ("OverscanAppropriate", m_overscanAppropriateFlag, false, "Indicates whether cropped decoded pictures are suitable for display using overscan\n") |
---|
470 | ("VideoSignalTypePresent", m_videoSignalTypePresentFlag, false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present") |
---|
471 | ("VideoFormat", m_videoFormat, 5, "Indicates representation of pictures") |
---|
472 | ("VideoFullRange", m_videoFullRangeFlag, false, "Indicates the black level and range of luma and chroma signals") |
---|
473 | ("ColourDescriptionPresent", m_colourDescriptionPresentFlag, false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present") |
---|
474 | ("ColourPrimaries", m_colourPrimaries, 2, "Indicates chromaticity coordinates of the source primaries") |
---|
475 | ("TransferCharateristics", m_transferCharacteristics, 2, "Indicates the opto-electronic transfer characteristics of the source") |
---|
476 | ("MatrixCoefficients", m_matrixCoefficients, 2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries") |
---|
477 | ("ChromaLocInfoPresent", m_chromaLocInfoPresentFlag, false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present") |
---|
478 | ("ChromaSampleLocTypeTopField", m_chromaSampleLocTypeTopField, 0, "Specifies the location of chroma samples for top field") |
---|
479 | ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField, 0, "Specifies the location of chroma samples for bottom field") |
---|
480 | ("NeutralChromaIndication", m_neutralChromaIndicationFlag, false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)") |
---|
481 | ("BitstreamRestriction", m_bitstreamRestrictionFlag, false, "Signals whether bitstream restriction parameters are present") |
---|
482 | ("TilesFixedStructure", m_tilesFixedStructureFlag, false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles") |
---|
483 | ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false, "Indicates that no samples outside the picture boundaries are used for inter prediction") |
---|
484 | ("MaxBytesPerPicDenom", m_maxBytesPerPicDenom, 2, "Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture") |
---|
485 | ("MaxBitsPerMinCuDenom", m_maxBitsPerMinCuDenom, 1, "Indicates an upper bound for the number of bits of coding_unit() data") |
---|
486 | ("Log2MaxMvLengthHorizontal", m_log2MaxMvLengthHorizontal, 15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units") |
---|
487 | ("Log2MaxMvLengthVertical", m_log2MaxMvLengthVertical, 15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units") |
---|
488 | #endif |
---|
489 | #if RECOVERY_POINT_SEI |
---|
490 | ("SEIRecoveryPoint", m_recoveryPointSEIEnabled, 0, "Control generation of recovery point SEI messages") |
---|
491 | #endif |
---|
492 | #if BUFFERING_PERIOD_AND_TIMING_SEI |
---|
493 | ("SEIBufferingPeriod", m_bufferingPeriodSEIEnabled, 0, "Control generation of buffering period SEI messages") |
---|
494 | ("SEIPictureTiming", m_pictureTimingSEIEnabled, 0, "Control generation of picture timing SEI messages") |
---|
495 | #endif |
---|
496 | ; |
---|
497 | |
---|
498 | for(Int i=1; i<MAX_GOP+1; i++) { |
---|
499 | std::ostringstream cOSS; |
---|
500 | cOSS<<"Frame"<<i; |
---|
501 | opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry()); |
---|
502 | } |
---|
503 | po::setDefaults(opts); |
---|
504 | const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv); |
---|
505 | |
---|
506 | for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++) |
---|
507 | { |
---|
508 | fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it); |
---|
509 | } |
---|
510 | |
---|
511 | if (argc == 1 || do_help) |
---|
512 | { |
---|
513 | /* argc == 1: no options have been specified */ |
---|
514 | po::doHelp(cout, opts); |
---|
515 | return false; |
---|
516 | } |
---|
517 | |
---|
518 | /* |
---|
519 | * Set any derived parameters |
---|
520 | */ |
---|
521 | /* convert std::string to c string for compatability */ |
---|
522 | #if SVC_EXTENSION |
---|
523 | m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
524 | #if AVC_SYNTAX |
---|
525 | m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str()); |
---|
526 | #endif |
---|
527 | #else |
---|
528 | m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str()); |
---|
529 | m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
530 | m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str()); |
---|
531 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
---|
532 | #endif |
---|
533 | |
---|
534 | m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str()); |
---|
535 | m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str()); |
---|
536 | m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str()); |
---|
537 | |
---|
538 | #if !SVC_EXTENSION |
---|
539 | // TODO:ChromaFmt assumes 4:2:0 below |
---|
540 | switch (m_croppingMode) |
---|
541 | { |
---|
542 | case 0: |
---|
543 | { |
---|
544 | // no cropping or padding |
---|
545 | m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0; |
---|
546 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
547 | break; |
---|
548 | } |
---|
549 | case 1: |
---|
550 | { |
---|
551 | // automatic padding to minimum CU size |
---|
552 | Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); |
---|
553 | if (m_iSourceWidth % minCuSize) |
---|
554 | { |
---|
555 | m_aiPad[0] = m_cropRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth; |
---|
556 | m_iSourceWidth += m_cropRight; |
---|
557 | } |
---|
558 | if (m_iSourceHeight % minCuSize) |
---|
559 | { |
---|
560 | m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; |
---|
561 | m_iSourceHeight += m_cropBottom; |
---|
562 | } |
---|
563 | if (m_aiPad[0] % TComSPS::getCropUnitX(CHROMA_420) != 0) |
---|
564 | { |
---|
565 | fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n"); |
---|
566 | exit(EXIT_FAILURE); |
---|
567 | } |
---|
568 | if (m_aiPad[1] % TComSPS::getCropUnitY(CHROMA_420) != 0) |
---|
569 | { |
---|
570 | fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n"); |
---|
571 | exit(EXIT_FAILURE); |
---|
572 | } |
---|
573 | break; |
---|
574 | } |
---|
575 | case 2: |
---|
576 | { |
---|
577 | //padding |
---|
578 | m_iSourceWidth += m_aiPad[0]; |
---|
579 | m_iSourceHeight += m_aiPad[1]; |
---|
580 | m_cropRight = m_aiPad[0]; |
---|
581 | m_cropBottom = m_aiPad[1]; |
---|
582 | break; |
---|
583 | } |
---|
584 | case 3: |
---|
585 | { |
---|
586 | // cropping |
---|
587 | if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0)) |
---|
588 | { |
---|
589 | fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n"); |
---|
590 | } |
---|
591 | if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0)) |
---|
592 | { |
---|
593 | fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n"); |
---|
594 | } |
---|
595 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
596 | break; |
---|
597 | } |
---|
598 | } |
---|
599 | |
---|
600 | // allocate slice-based dQP values |
---|
601 | m_aidQP = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ]; |
---|
602 | ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) ); |
---|
603 | |
---|
604 | // handling of floating-point QP values |
---|
605 | // if QP is not integer, sequence is split into two sections having QP and QP+1 |
---|
606 | m_iQP = (Int)( m_fQP ); |
---|
607 | if ( m_iQP < m_fQP ) |
---|
608 | { |
---|
609 | Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_fQP - m_iQP)*m_iFrameToBeEncoded + 0.5 ); |
---|
610 | |
---|
611 | iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize; |
---|
612 | for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ ) |
---|
613 | { |
---|
614 | m_aidQP[i] = 1; |
---|
615 | } |
---|
616 | } |
---|
617 | |
---|
618 | // reading external dQP description from file |
---|
619 | if ( m_pchdQPFile ) |
---|
620 | { |
---|
621 | FILE* fpt=fopen( m_pchdQPFile, "r" ); |
---|
622 | if ( fpt ) |
---|
623 | { |
---|
624 | Int iValue; |
---|
625 | Int iPOC = 0; |
---|
626 | while ( iPOC < m_iFrameToBeEncoded ) |
---|
627 | { |
---|
628 | if ( fscanf(fpt, "%d", &iValue ) == EOF ) break; |
---|
629 | m_aidQP[ iPOC ] = iValue; |
---|
630 | iPOC++; |
---|
631 | } |
---|
632 | fclose(fpt); |
---|
633 | } |
---|
634 | } |
---|
635 | m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; |
---|
636 | #endif |
---|
637 | // check validity of input parameters |
---|
638 | xCheckParameter(); |
---|
639 | |
---|
640 | // set global varibles |
---|
641 | xSetGlobal(); |
---|
642 | |
---|
643 | // print-out parameters |
---|
644 | xPrintParameter(); |
---|
645 | |
---|
646 | return true; |
---|
647 | } |
---|
648 | |
---|
649 | // ==================================================================================================================== |
---|
650 | // Private member functions |
---|
651 | // ==================================================================================================================== |
---|
652 | |
---|
653 | Bool confirmPara(Bool bflag, const char* message); |
---|
654 | |
---|
655 | Void TAppEncCfg::xCheckParameter() |
---|
656 | { |
---|
657 | if (!m_decodePictureHashSEIEnabled) |
---|
658 | { |
---|
659 | fprintf(stderr, "*************************************************************\n"); |
---|
660 | fprintf(stderr, "** WARNING: --SEIpictureDigest is now disabled by default. **\n"); |
---|
661 | fprintf(stderr, "** Automatic verification of decoded pictures by **\n"); |
---|
662 | fprintf(stderr, "** a decoder requires this option to be enabled. **\n"); |
---|
663 | fprintf(stderr, "*************************************************************\n"); |
---|
664 | } |
---|
665 | |
---|
666 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
667 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
668 | // check range of parameters |
---|
669 | xConfirmPara( m_uiInputBitDepth < 8, "InputBitDepth must be at least 8" ); |
---|
670 | #if !SVC_EXTENSION |
---|
671 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
---|
672 | #endif |
---|
673 | xConfirmPara( m_iFrameToBeEncoded <= 0, "Total Number Of Frames encoded must be more than 0" ); |
---|
674 | xConfirmPara( m_iGOPSize < 1 , "GOP Size must be greater or equal to 1" ); |
---|
675 | xConfirmPara( m_iGOPSize > 1 && m_iGOPSize % 2, "GOP Size must be a multiple of 2, if GOP Size is greater than 1" ); |
---|
676 | #if !SVC_EXTENSION |
---|
677 | xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" ); |
---|
678 | #endif |
---|
679 | xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2, "Decoding Refresh Type must be equal to 0, 1 or 2" ); |
---|
680 | #if !SVC_EXTENSION |
---|
681 | xConfirmPara( m_iQP < -6 * ((Int)m_uiInternalBitDepth - 8) || m_iQP > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
---|
682 | #endif |
---|
683 | xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13, "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)"); |
---|
684 | xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13, "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)"); |
---|
685 | xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2, "Fast Search Mode is not supported value (0:Full search 1:Diamond 2:PMVFAST)" ); |
---|
686 | xConfirmPara( m_iSearchRange < 0 , "Search Range must be more than 0" ); |
---|
687 | xConfirmPara( m_bipredSearchRange < 0 , "Search Range must be more than 0" ); |
---|
688 | xConfirmPara( m_iMaxDeltaQP > 7, "Absolute Delta QP exceeds supported range (0 to 7)" ); |
---|
689 | xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1, "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" ); |
---|
690 | |
---|
691 | xConfirmPara( m_cbQpOffset < -12, "Min. Chroma Cb QP Offset is -12" ); |
---|
692 | xConfirmPara( m_cbQpOffset > 12, "Max. Chroma Cb QP Offset is 12" ); |
---|
693 | xConfirmPara( m_crQpOffset < -12, "Min. Chroma Cr QP Offset is -12" ); |
---|
694 | xConfirmPara( m_crQpOffset > 12, "Max. Chroma Cr QP Offset is 12" ); |
---|
695 | |
---|
696 | xConfirmPara( m_iQPAdaptationRange <= 0, "QP Adaptation Range must be more than 0" ); |
---|
697 | #if !SVC_EXTENSION |
---|
698 | if (m_iDecodingRefreshType == 2) |
---|
699 | { |
---|
700 | xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize , "Intra period must be larger than GOP size for periodic IDR pictures"); |
---|
701 | } |
---|
702 | #endif |
---|
703 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
---|
704 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
---|
705 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
---|
706 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
---|
707 | #if !SVC_EXTENSION |
---|
708 | xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size"); |
---|
709 | xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size"); |
---|
710 | #endif |
---|
711 | |
---|
712 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
---|
713 | xConfirmPara( m_uiQuadtreeTULog2MinSize > 5, "QuadtreeTULog2MinSize must be 5 or smaller."); |
---|
714 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < 2, "QuadtreeTULog2MaxSize must be 2 or greater."); |
---|
715 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
---|
716 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
---|
717 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
718 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
719 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
---|
720 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
---|
721 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
---|
722 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthInter must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
723 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
---|
724 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" ); |
---|
725 | |
---|
726 | xConfirmPara( m_maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater."); |
---|
727 | xConfirmPara( m_maxNumMergeCand > 5, "MaxNumMergeCand must be 5 or smaller."); |
---|
728 | |
---|
729 | #if !SVC_EXTENSION |
---|
730 | #if ADAPTIVE_QP_SELECTION |
---|
731 | xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0, "AdaptiveQpSelection must be disabled when QP < 0."); |
---|
732 | xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ), "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0."); |
---|
733 | #endif |
---|
734 | #endif |
---|
735 | |
---|
736 | if( m_usePCM) |
---|
737 | { |
---|
738 | xConfirmPara( m_uiPCMLog2MinSize < 3, "PCMLog2MinSize must be 3 or greater."); |
---|
739 | xConfirmPara( m_uiPCMLog2MinSize > 5, "PCMLog2MinSize must be 5 or smaller."); |
---|
740 | xConfirmPara( m_pcmLog2MaxSize > 5, "PCMLog2MaxSize must be 5 or smaller."); |
---|
741 | xConfirmPara( m_pcmLog2MaxSize < m_uiPCMLog2MinSize, "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize."); |
---|
742 | } |
---|
743 | |
---|
744 | xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 3, "SliceMode exceeds supported range (0 to 3)" ); |
---|
745 | if (m_iSliceMode!=0) |
---|
746 | { |
---|
747 | xConfirmPara( m_iSliceArgument < 1 , "SliceArgument should be larger than or equal to 1" ); |
---|
748 | } |
---|
749 | #if !REMOVE_FGS |
---|
750 | if (m_iSliceMode==3) |
---|
751 | { |
---|
752 | xConfirmPara( m_iSliceGranularity > 0 , "When SliceMode == 3 is chosen, the SliceGranularity must be 0" ); |
---|
753 | } |
---|
754 | #endif |
---|
755 | xConfirmPara( m_iDependentSliceMode < 0 || m_iDependentSliceMode > 2, "DependentSliceMode exceeds supported range (0 to 2)" ); |
---|
756 | if (m_iDependentSliceMode!=0) |
---|
757 | { |
---|
758 | xConfirmPara( m_iDependentSliceArgument < 1 , "DependentSliceArgument should be larger than or equal to 1" ); |
---|
759 | } |
---|
760 | #if !REMOVE_FGS |
---|
761 | xConfirmPara( m_iSliceGranularity >= m_uiMaxCUDepth, "SliceGranularity must be smaller than maximum cu depth"); |
---|
762 | xConfirmPara( m_iSliceGranularity <0 || m_iSliceGranularity > 3, "SliceGranularity exceeds supported range (0 to 3)" ); |
---|
763 | xConfirmPara( m_iSliceGranularity > m_iMaxCuDQPDepth, "SliceGranularity must be smaller smaller than or equal to maximum dqp depth" ); |
---|
764 | #endif |
---|
765 | |
---|
766 | bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 ); |
---|
767 | #if !TILES_WPP_ENTROPYSLICES_FLAGS |
---|
768 | xConfirmPara( tileFlag && m_iDependentSliceMode, "Tile and Dependent Slice can not be applied together"); |
---|
769 | #endif |
---|
770 | xConfirmPara( tileFlag && m_iWaveFrontSynchro, "Tile and Wavefront can not be applied together"); |
---|
771 | #if !DEPENDENT_SLICES |
---|
772 | xConfirmPara( m_iWaveFrontSynchro && m_iDependentSliceMode, "Wavefront and Dependent Slice can not be applied together"); |
---|
773 | #endif |
---|
774 | #if DEPENDENT_SLICES |
---|
775 | #if TILES_WPP_ENTROPYSLICES_FLAGS |
---|
776 | xConfirmPara( m_iWaveFrontSynchro && m_entropySliceEnabledFlag, "WaveFrontSynchro and EntropySliceEnabledFlag can not be applied together"); |
---|
777 | #else |
---|
778 | xConfirmPara( m_iWaveFrontSynchro && m_bCabacIndependentFlag, "Wavefront and CabacIndependentFlag can not be applied together"); |
---|
779 | #endif |
---|
780 | #endif |
---|
781 | |
---|
782 | //TODO:ChromaFmt assumes 4:2:0 below |
---|
783 | #if !SVC_EXTENSION |
---|
784 | xConfirmPara( m_iSourceWidth % TComSPS::getCropUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); |
---|
785 | xConfirmPara( m_iSourceHeight % TComSPS::getCropUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); |
---|
786 | #endif |
---|
787 | |
---|
788 | #if !SVC_EXTENSION |
---|
789 | xConfirmPara( m_aiPad[0] % TComSPS::getCropUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling"); |
---|
790 | xConfirmPara( m_aiPad[1] % TComSPS::getCropUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling"); |
---|
791 | |
---|
792 | xConfirmPara( m_cropLeft % TComSPS::getCropUnitX(CHROMA_420) != 0, "Left cropping must be an integer multiple of the specified chroma subsampling"); |
---|
793 | xConfirmPara( m_cropRight % TComSPS::getCropUnitX(CHROMA_420) != 0, "Right cropping must be an integer multiple of the specified chroma subsampling"); |
---|
794 | xConfirmPara( m_cropTop % TComSPS::getCropUnitY(CHROMA_420) != 0, "Top cropping must be an integer multiple of the specified chroma subsampling"); |
---|
795 | xConfirmPara( m_cropBottom % TComSPS::getCropUnitY(CHROMA_420) != 0, "Bottom cropping must be an integer multiple of the specified chroma subsampling"); |
---|
796 | #endif |
---|
797 | |
---|
798 | #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV |
---|
799 | xConfirmPara( REF_IDX_ME_AROUND_ZEROMV && REF_IDX_ME_ZEROMV, "REF_IDX_ME_AROUND_ZEROMV and REF_IDX_ME_ZEROMV cannot be enabled simultaneously"); |
---|
800 | #endif |
---|
801 | // max CU width and height should be power of 2 |
---|
802 | UInt ui = m_uiMaxCUWidth; |
---|
803 | while(ui) |
---|
804 | { |
---|
805 | ui >>= 1; |
---|
806 | if( (ui & 1) == 1) |
---|
807 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
---|
808 | } |
---|
809 | ui = m_uiMaxCUHeight; |
---|
810 | while(ui) |
---|
811 | { |
---|
812 | ui >>= 1; |
---|
813 | if( (ui & 1) == 1) |
---|
814 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
---|
815 | } |
---|
816 | |
---|
817 | Bool verifiedGOP=false; |
---|
818 | Bool errorGOP=false; |
---|
819 | Int checkGOP=1; |
---|
820 | Int numRefs = 1; |
---|
821 | Int refList[MAX_NUM_REF_PICS+1]; |
---|
822 | refList[0]=0; |
---|
823 | Bool isOK[MAX_GOP]; |
---|
824 | for(Int i=0; i<MAX_GOP; i++) |
---|
825 | { |
---|
826 | isOK[i]=false; |
---|
827 | } |
---|
828 | Int numOK=0; |
---|
829 | #if !SVC_EXTENSION |
---|
830 | xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" ); |
---|
831 | #endif |
---|
832 | |
---|
833 | for(Int i=0; i<m_iGOPSize; i++) |
---|
834 | { |
---|
835 | if(m_GOPList[i].m_POC==m_iGOPSize) |
---|
836 | { |
---|
837 | xConfirmPara( m_GOPList[i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " ); |
---|
838 | } |
---|
839 | } |
---|
840 | |
---|
841 | m_extraRPSs=0; |
---|
842 | |
---|
843 | #if SVC_EXTENSION |
---|
844 | // verify layer configuration parameters |
---|
845 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
846 | { |
---|
847 | if(m_acLayerCfg[layer].xCheckParameter()) |
---|
848 | { |
---|
849 | printf("\nError: invalid configuration parameter found in layer %d \n", layer); |
---|
850 | check_failed = true; |
---|
851 | } |
---|
852 | } |
---|
853 | #endif |
---|
854 | |
---|
855 | //start looping through frames in coding order until we can verify that the GOP structure is correct. |
---|
856 | while(!verifiedGOP&&!errorGOP) |
---|
857 | { |
---|
858 | Int curGOP = (checkGOP-1)%m_iGOPSize; |
---|
859 | Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPList[curGOP].m_POC; |
---|
860 | if(m_GOPList[curGOP].m_POC<0) |
---|
861 | { |
---|
862 | printf("\nError: found fewer Reference Picture Sets than GOPSize\n"); |
---|
863 | errorGOP=true; |
---|
864 | } |
---|
865 | else |
---|
866 | { |
---|
867 | //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP. |
---|
868 | Bool beforeI = false; |
---|
869 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
870 | { |
---|
871 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
872 | if(absPOC < 0) |
---|
873 | { |
---|
874 | beforeI=true; |
---|
875 | } |
---|
876 | else |
---|
877 | { |
---|
878 | Bool found=false; |
---|
879 | for(Int j=0; j<numRefs; j++) |
---|
880 | { |
---|
881 | if(refList[j]==absPOC) |
---|
882 | { |
---|
883 | found=true; |
---|
884 | for(Int k=0; k<m_iGOPSize; k++) |
---|
885 | { |
---|
886 | if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize) |
---|
887 | { |
---|
888 | #if TEMPORAL_LAYER_NON_REFERENCE |
---|
889 | if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId) |
---|
890 | { |
---|
891 | m_GOPList[k].m_refPic = true; |
---|
892 | } |
---|
893 | #endif |
---|
894 | m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId; |
---|
895 | } |
---|
896 | } |
---|
897 | } |
---|
898 | } |
---|
899 | if(!found) |
---|
900 | { |
---|
901 | printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1); |
---|
902 | errorGOP=true; |
---|
903 | } |
---|
904 | } |
---|
905 | } |
---|
906 | if(!beforeI&&!errorGOP) |
---|
907 | { |
---|
908 | //all ref frames were present |
---|
909 | if(!isOK[curGOP]) |
---|
910 | { |
---|
911 | numOK++; |
---|
912 | isOK[curGOP]=true; |
---|
913 | if(numOK==m_iGOPSize) |
---|
914 | { |
---|
915 | verifiedGOP=true; |
---|
916 | } |
---|
917 | } |
---|
918 | } |
---|
919 | else |
---|
920 | { |
---|
921 | //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0) |
---|
922 | m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP]; |
---|
923 | Int newRefs=0; |
---|
924 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
925 | { |
---|
926 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
927 | if(absPOC>=0) |
---|
928 | { |
---|
929 | m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i]; |
---|
930 | m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i]; |
---|
931 | newRefs++; |
---|
932 | } |
---|
933 | } |
---|
934 | Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive; |
---|
935 | |
---|
936 | for(Int offset = -1; offset>-checkGOP; offset--) |
---|
937 | { |
---|
938 | //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0. |
---|
939 | Int offGOP = (checkGOP-1+offset)%m_iGOPSize; |
---|
940 | Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC; |
---|
941 | #if TEMPORAL_LAYER_NON_REFERENCE |
---|
942 | if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId) |
---|
943 | #else |
---|
944 | if(offPOC>=0&&m_GOPList[offGOP].m_refPic&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId) |
---|
945 | #endif |
---|
946 | { |
---|
947 | Bool newRef=false; |
---|
948 | for(Int i=0; i<numRefs; i++) |
---|
949 | { |
---|
950 | if(refList[i]==offPOC) |
---|
951 | { |
---|
952 | newRef=true; |
---|
953 | } |
---|
954 | } |
---|
955 | for(Int i=0; i<newRefs; i++) |
---|
956 | { |
---|
957 | if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC) |
---|
958 | { |
---|
959 | newRef=false; |
---|
960 | } |
---|
961 | } |
---|
962 | if(newRef) |
---|
963 | { |
---|
964 | Int insertPoint=newRefs; |
---|
965 | //this picture can be added, find appropriate place in list and insert it. |
---|
966 | #if TEMPORAL_LAYER_NON_REFERENCE |
---|
967 | if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId) |
---|
968 | { |
---|
969 | m_GOPList[offGOP].m_refPic = true; |
---|
970 | } |
---|
971 | #endif |
---|
972 | for(Int j=0; j<newRefs; j++) |
---|
973 | { |
---|
974 | if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0) |
---|
975 | { |
---|
976 | insertPoint = j; |
---|
977 | break; |
---|
978 | } |
---|
979 | } |
---|
980 | Int prev = offPOC-curPOC; |
---|
981 | Int prevUsed = m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId; |
---|
982 | for(Int j=insertPoint; j<newRefs+1; j++) |
---|
983 | { |
---|
984 | Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]; |
---|
985 | Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]; |
---|
986 | m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev; |
---|
987 | m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed; |
---|
988 | prevUsed=newUsed; |
---|
989 | prev=newPrev; |
---|
990 | } |
---|
991 | newRefs++; |
---|
992 | } |
---|
993 | } |
---|
994 | if(newRefs>=numPrefRefs) |
---|
995 | { |
---|
996 | break; |
---|
997 | } |
---|
998 | } |
---|
999 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs; |
---|
1000 | m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC; |
---|
1001 | if (m_extraRPSs == 0) |
---|
1002 | { |
---|
1003 | m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0; |
---|
1004 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0; |
---|
1005 | } |
---|
1006 | else |
---|
1007 | { |
---|
1008 | Int rIdx = m_iGOPSize + m_extraRPSs - 1; |
---|
1009 | Int refPOC = m_GOPList[rIdx].m_POC; |
---|
1010 | Int refPics = m_GOPList[rIdx].m_numRefPics; |
---|
1011 | Int newIdc=0; |
---|
1012 | for(Int i = 0; i<= refPics; i++) |
---|
1013 | { |
---|
1014 | Int deltaPOC = ((i != refPics)? m_GOPList[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0 |
---|
1015 | Int absPOCref = refPOC+deltaPOC; |
---|
1016 | Int refIdc = 0; |
---|
1017 | for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++) |
---|
1018 | { |
---|
1019 | if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]) |
---|
1020 | { |
---|
1021 | if (m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]) |
---|
1022 | { |
---|
1023 | refIdc = 1; |
---|
1024 | } |
---|
1025 | else |
---|
1026 | { |
---|
1027 | refIdc = 2; |
---|
1028 | } |
---|
1029 | } |
---|
1030 | } |
---|
1031 | m_GOPList[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc; |
---|
1032 | newIdc++; |
---|
1033 | } |
---|
1034 | m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1; |
---|
1035 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc; |
---|
1036 | m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC; |
---|
1037 | #if !J0234_INTER_RPS_SIMPL |
---|
1038 | m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRIdxMinus1 = 0; |
---|
1039 | #endif |
---|
1040 | } |
---|
1041 | curGOP=m_iGOPSize+m_extraRPSs; |
---|
1042 | m_extraRPSs++; |
---|
1043 | } |
---|
1044 | numRefs=0; |
---|
1045 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
1046 | { |
---|
1047 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
1048 | if(absPOC >= 0) |
---|
1049 | { |
---|
1050 | refList[numRefs]=absPOC; |
---|
1051 | numRefs++; |
---|
1052 | } |
---|
1053 | } |
---|
1054 | refList[numRefs]=curPOC; |
---|
1055 | numRefs++; |
---|
1056 | } |
---|
1057 | checkGOP++; |
---|
1058 | } |
---|
1059 | xConfirmPara(errorGOP,"Invalid GOP structure given"); |
---|
1060 | m_maxTempLayer = 1; |
---|
1061 | for(Int i=0; i<m_iGOPSize; i++) |
---|
1062 | { |
---|
1063 | if(m_GOPList[i].m_temporalId >= m_maxTempLayer) |
---|
1064 | { |
---|
1065 | m_maxTempLayer = m_GOPList[i].m_temporalId+1; |
---|
1066 | } |
---|
1067 | xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P', "Slice type must be equal to B or P"); |
---|
1068 | } |
---|
1069 | for(Int i=0; i<MAX_TLAYER; i++) |
---|
1070 | { |
---|
1071 | m_numReorderPics[i] = 0; |
---|
1072 | m_maxDecPicBuffering[i] = 0; |
---|
1073 | } |
---|
1074 | for(Int i=0; i<m_iGOPSize; i++) |
---|
1075 | { |
---|
1076 | if(m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId]) |
---|
1077 | { |
---|
1078 | m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics; |
---|
1079 | } |
---|
1080 | Int highestDecodingNumberWithLowerPOC = 0; |
---|
1081 | for(Int j=0; j<m_iGOPSize; j++) |
---|
1082 | { |
---|
1083 | if(m_GOPList[j].m_POC <= m_GOPList[i].m_POC) |
---|
1084 | { |
---|
1085 | highestDecodingNumberWithLowerPOC = j; |
---|
1086 | } |
---|
1087 | } |
---|
1088 | Int numReorder = 0; |
---|
1089 | for(Int j=0; j<highestDecodingNumberWithLowerPOC; j++) |
---|
1090 | { |
---|
1091 | if(m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId && |
---|
1092 | m_GOPList[j].m_POC > m_GOPList[i].m_POC) |
---|
1093 | { |
---|
1094 | numReorder++; |
---|
1095 | } |
---|
1096 | } |
---|
1097 | if(numReorder > m_numReorderPics[m_GOPList[i].m_temporalId]) |
---|
1098 | { |
---|
1099 | m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder; |
---|
1100 | } |
---|
1101 | } |
---|
1102 | for(Int i=0; i<MAX_TLAYER-1; i++) |
---|
1103 | { |
---|
1104 | // a lower layer can not have higher value of m_numReorderPics than a higher layer |
---|
1105 | if(m_numReorderPics[i+1] < m_numReorderPics[i]) |
---|
1106 | { |
---|
1107 | m_numReorderPics[i+1] = m_numReorderPics[i]; |
---|
1108 | } |
---|
1109 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive |
---|
1110 | if(m_numReorderPics[i] > m_maxDecPicBuffering[i]) |
---|
1111 | { |
---|
1112 | m_maxDecPicBuffering[i] = m_numReorderPics[i]; |
---|
1113 | } |
---|
1114 | // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer |
---|
1115 | if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i]) |
---|
1116 | { |
---|
1117 | m_maxDecPicBuffering[i+1] = m_maxDecPicBuffering[i]; |
---|
1118 | } |
---|
1119 | } |
---|
1120 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive |
---|
1121 | if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1]) |
---|
1122 | { |
---|
1123 | m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1]; |
---|
1124 | } |
---|
1125 | |
---|
1126 | xConfirmPara( m_bUseLComb==false && m_numReorderPics[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. |
---|
1127 | xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" ); |
---|
1128 | #if !SVC_EXTENSION |
---|
1129 | xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" ); |
---|
1130 | xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" ); |
---|
1131 | #endif |
---|
1132 | |
---|
1133 | xConfirmPara( m_decodePictureHashSEIEnabled<0 || m_decodePictureHashSEIEnabled>3, "this hash type is not correct!\n"); |
---|
1134 | |
---|
1135 | #if !SVC_EXTENSION |
---|
1136 | if(m_enableRateCtrl) |
---|
1137 | { |
---|
1138 | Int numLCUInWidth = (m_iSourceWidth / m_uiMaxCUWidth) + (( m_iSourceWidth % m_uiMaxCUWidth ) ? 1 : 0); |
---|
1139 | Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight)+ (( m_iSourceHeight % m_uiMaxCUHeight) ? 1 : 0); |
---|
1140 | Int numLCUInPic = numLCUInWidth * numLCUInHeight; |
---|
1141 | |
---|
1142 | xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" ); |
---|
1143 | |
---|
1144 | m_iMaxDeltaQP = MAX_DELTA_QP; |
---|
1145 | m_iMaxCuDQPDepth = MAX_CUDQP_DEPTH; |
---|
1146 | } |
---|
1147 | #endif |
---|
1148 | |
---|
1149 | xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0"); |
---|
1150 | |
---|
1151 | xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2"); |
---|
1152 | |
---|
1153 | #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE |
---|
1154 | xConfirmPara(m_activeParameterSetsSEIEnabled < 0 || m_activeParameterSetsSEIEnabled > 2, "ActiveParametersSEIEnabled exceeds supported range (0 to 2)"); |
---|
1155 | #endif |
---|
1156 | |
---|
1157 | #undef xConfirmPara |
---|
1158 | if (check_failed) |
---|
1159 | { |
---|
1160 | exit(EXIT_FAILURE); |
---|
1161 | } |
---|
1162 | } |
---|
1163 | |
---|
1164 | /** \todo use of global variables should be removed later |
---|
1165 | */ |
---|
1166 | Void TAppEncCfg::xSetGlobal() |
---|
1167 | { |
---|
1168 | // set max CU width & height |
---|
1169 | g_uiMaxCUWidth = m_uiMaxCUWidth; |
---|
1170 | g_uiMaxCUHeight = m_uiMaxCUHeight; |
---|
1171 | |
---|
1172 | // compute actual CU depth with respect to config depth and max transform size |
---|
1173 | g_uiAddCUDepth = 0; |
---|
1174 | while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth ) ) ) g_uiAddCUDepth++; |
---|
1175 | |
---|
1176 | m_uiMaxCUDepth += g_uiAddCUDepth; |
---|
1177 | g_uiAddCUDepth++; |
---|
1178 | g_uiMaxCUDepth = m_uiMaxCUDepth; |
---|
1179 | |
---|
1180 | // set internal bit-depth and constants |
---|
1181 | #if FULL_NBIT |
---|
1182 | g_uiBitDepth = m_uiInternalBitDepth; |
---|
1183 | g_uiBitIncrement = 0; |
---|
1184 | #else |
---|
1185 | g_uiBitDepth = 8; |
---|
1186 | g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth; |
---|
1187 | #endif |
---|
1188 | |
---|
1189 | g_uiBASE_MAX = ((1<<(g_uiBitDepth))-1); |
---|
1190 | |
---|
1191 | #if IBDI_NOCLIP_RANGE |
---|
1192 | g_uiIBDI_MAX = g_uiBASE_MAX << g_uiBitIncrement; |
---|
1193 | #else |
---|
1194 | g_uiIBDI_MAX = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1); |
---|
1195 | #endif |
---|
1196 | |
---|
1197 | if (m_uiOutputBitDepth == 0) |
---|
1198 | { |
---|
1199 | m_uiOutputBitDepth = m_uiInternalBitDepth; |
---|
1200 | } |
---|
1201 | |
---|
1202 | g_uiPCMBitDepthLuma = m_uiPCMBitDepthLuma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth); |
---|
1203 | g_uiPCMBitDepthChroma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth); |
---|
1204 | } |
---|
1205 | |
---|
1206 | Void TAppEncCfg::xPrintParameter() |
---|
1207 | { |
---|
1208 | printf("\n"); |
---|
1209 | #if SVC_EXTENSION |
---|
1210 | printf("Total number of layers : %d\n", m_numLayers ); |
---|
1211 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1212 | { |
---|
1213 | printf("=== Layer %d settings === \n", layer); |
---|
1214 | m_acLayerCfg[layer].xPrintParameter(); |
---|
1215 | printf("\n"); |
---|
1216 | } |
---|
1217 | printf("=== Common configuration settings === \n"); |
---|
1218 | printf("Bitstream File : %s\n", m_pchBitstreamFile ); |
---|
1219 | #else |
---|
1220 | printf("Input File : %s\n", m_pchInputFile ); |
---|
1221 | printf("Bitstream File : %s\n", m_pchBitstreamFile ); |
---|
1222 | printf("Reconstruction File : %s\n", m_pchReconFile ); |
---|
1223 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate ); |
---|
1224 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
---|
1225 | #endif |
---|
1226 | printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded ); |
---|
1227 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
---|
1228 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
1229 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
---|
1230 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
---|
1231 | printf("Min PCM size : %d\n", 1 << m_uiPCMLog2MinSize); |
---|
1232 | printf("Motion search range : %d\n", m_iSearchRange ); |
---|
1233 | #if !SVC_EXTENSION |
---|
1234 | printf("Intra period : %d\n", m_iIntraPeriod ); |
---|
1235 | #endif |
---|
1236 | printf("Decoding refresh type : %d\n", m_iDecodingRefreshType ); |
---|
1237 | #if !SVC_EXTENSION |
---|
1238 | printf("QP : %5.2f\n", m_fQP ); |
---|
1239 | #endif |
---|
1240 | printf("Max dQP signaling depth : %d\n", m_iMaxCuDQPDepth); |
---|
1241 | |
---|
1242 | printf("Cb QP Offset : %d\n", m_cbQpOffset ); |
---|
1243 | printf("Cr QP Offset : %d\n", m_crQpOffset); |
---|
1244 | |
---|
1245 | printf("QP adaptation : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) ); |
---|
1246 | printf("GOP size : %d\n", m_iGOPSize ); |
---|
1247 | printf("Internal bit depth : %d\n", m_uiInternalBitDepth ); |
---|
1248 | printf("PCM sample bit depth : %d\n", m_uiPCMBitDepthLuma ); |
---|
1249 | printf("RateControl : %d\n", m_enableRateCtrl); |
---|
1250 | if(m_enableRateCtrl) |
---|
1251 | { |
---|
1252 | printf("TargetBitrate : %d\n", m_targetBitrate); |
---|
1253 | printf("NumLCUInUnit : %d\n", m_numLCUInUnit); |
---|
1254 | } |
---|
1255 | printf("Max Num Merge Candidates : %d\n", m_maxNumMergeCand); |
---|
1256 | printf("\n"); |
---|
1257 | |
---|
1258 | printf("TOOL CFG: "); |
---|
1259 | #if !REMOVE_ALF |
---|
1260 | printf("ALF:%d ", m_bUseALF ); |
---|
1261 | printf("ALFLowLatencyEncode:%d ", m_alfLowLatencyEncoding?1:0); |
---|
1262 | #endif |
---|
1263 | printf("IBD:%d ", !!g_uiBitIncrement); |
---|
1264 | printf("HAD:%d ", m_bUseHADME ); |
---|
1265 | printf("SRD:%d ", m_bUseSBACRD ); |
---|
1266 | printf("RDQ:%d ", m_bUseRDOQ ); |
---|
1267 | printf("SQP:%d ", m_uiDeltaQpRD ); |
---|
1268 | printf("ASR:%d ", m_bUseASR ); |
---|
1269 | printf("LComb:%d ", m_bUseLComb ); |
---|
1270 | printf("FEN:%d ", m_bUseFastEnc ); |
---|
1271 | printf("ECU:%d ", m_bUseEarlyCU ); |
---|
1272 | printf("FDM:%d ", m_useFastDecisionForMerge ); |
---|
1273 | printf("CFM:%d ", m_bUseCbfFastMode ); |
---|
1274 | printf("ESD:%d ", m_useEarlySkipDetection ); |
---|
1275 | printf("RQT:%d ", 1 ); |
---|
1276 | #if !REMOVE_LMCHROMA |
---|
1277 | printf("LMC:%d ", m_bUseLMChroma ); |
---|
1278 | #endif |
---|
1279 | printf("TransformSkip:%d ", m_useTransformSkip ); |
---|
1280 | printf("TransformSkipFast:%d ", m_useTransformSkipFast ); |
---|
1281 | #if REMOVE_FGS |
---|
1282 | printf("Slice: M=%d ", m_iSliceMode); |
---|
1283 | #else |
---|
1284 | printf("Slice: G=%d M=%d ", m_iSliceGranularity, m_iSliceMode); |
---|
1285 | #endif |
---|
1286 | if (m_iSliceMode!=0) |
---|
1287 | { |
---|
1288 | printf("A=%d ", m_iSliceArgument); |
---|
1289 | } |
---|
1290 | printf("DependentSlice: M=%d ",m_iDependentSliceMode); |
---|
1291 | if (m_iDependentSliceMode!=0) |
---|
1292 | { |
---|
1293 | printf("A=%d ", m_iDependentSliceArgument); |
---|
1294 | } |
---|
1295 | printf("CIP:%d ", m_bUseConstrainedIntraPred); |
---|
1296 | printf("SAO:%d ", (m_bUseSAO)?(1):(0)); |
---|
1297 | printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0); |
---|
1298 | printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0)); |
---|
1299 | |
---|
1300 | printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 ); |
---|
1301 | printf("WPP:%d ", (Int)m_bUseWeightPred); |
---|
1302 | printf("WPB:%d ", (Int)m_useWeightedBiPred); |
---|
1303 | printf("PME:%d ", m_log2ParallelMergeLevel); |
---|
1304 | #if !SVC_EXTENSION |
---|
1305 | printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d", |
---|
1306 | m_iWaveFrontSynchro, m_iWaveFrontSubstreams); |
---|
1307 | #endif |
---|
1308 | printf(" ScalingList:%d ", m_useScalingListId ); |
---|
1309 | printf("TMVPMode:%d ", m_TMVPModeId ); |
---|
1310 | #if ADAPTIVE_QP_SELECTION |
---|
1311 | printf("AQpS:%d", m_bUseAdaptQpSelect ); |
---|
1312 | #endif |
---|
1313 | |
---|
1314 | printf(" SignBitHidingFlag:%d ", m_signHideFlag); |
---|
1315 | #if SVC_EXTENSION |
---|
1316 | #if RECALCULATE_QP_ACCORDING_LAMBDA |
---|
1317 | printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 ); |
---|
1318 | #endif |
---|
1319 | printf("AVC_BASE:%d ", AVC_BASE); |
---|
1320 | #if REF_IDX_FRAMEWORK |
---|
1321 | printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK); |
---|
1322 | printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled); |
---|
1323 | printf("REF_IDX_ME_AROUND_ZEROMV:%d ", REF_IDX_ME_AROUND_ZEROMV); |
---|
1324 | printf("REF_IDX_ME_ZEROMV: %d", REF_IDX_ME_ZEROMV); |
---|
1325 | #elif INTRA_BL |
---|
1326 | printf("INTRA_BL:%d ", INTRA_BL); |
---|
1327 | #if !AVC_BASE |
---|
1328 | printf("SVC_MVP:%d ", SVC_MVP ); |
---|
1329 | printf("SVC_BL_CAND_INTRA:%d", SVC_BL_CAND_INTRA ); |
---|
1330 | #endif |
---|
1331 | #endif |
---|
1332 | #else |
---|
1333 | #if RECALCULATE_QP_ACCORDING_LAMBDA |
---|
1334 | printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 ); |
---|
1335 | #endif |
---|
1336 | #endif |
---|
1337 | printf("\n\n"); |
---|
1338 | |
---|
1339 | fflush(stdout); |
---|
1340 | } |
---|
1341 | |
---|
1342 | Bool confirmPara(Bool bflag, const char* message) |
---|
1343 | { |
---|
1344 | if (!bflag) |
---|
1345 | return false; |
---|
1346 | |
---|
1347 | printf("Error: %s\n",message); |
---|
1348 | return true; |
---|
1349 | } |
---|
1350 | |
---|
1351 | //! \} |
---|