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-2013, 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 | |
---|
45 | static istream& operator>>(istream &, Level::Name &); |
---|
46 | static istream& operator>>(istream &, Level::Tier &); |
---|
47 | static istream& operator>>(istream &, Profile::Name &); |
---|
48 | |
---|
49 | #include "TAppCommon/program_options_lite.h" |
---|
50 | #include "TLibEncoder/TEncRateCtrl.h" |
---|
51 | #ifdef WIN32 |
---|
52 | #define strdup _strdup |
---|
53 | #endif |
---|
54 | |
---|
55 | using namespace std; |
---|
56 | namespace po = df::program_options_lite; |
---|
57 | |
---|
58 | //! \ingroup TAppEncoder |
---|
59 | //! \{ |
---|
60 | |
---|
61 | // ==================================================================================================================== |
---|
62 | // Constructor / destructor / initialization / destroy |
---|
63 | // ==================================================================================================================== |
---|
64 | |
---|
65 | #if SVC_EXTENSION |
---|
66 | TAppEncCfg::TAppEncCfg() |
---|
67 | : m_pBitstreamFile() |
---|
68 | #if AVC_BASE |
---|
69 | , m_avcBaseLayerFlag(0) |
---|
70 | #endif |
---|
71 | #if N0120_MAX_TID_REF_CFG |
---|
72 | , m_maxTidRefPresentFlag(1) |
---|
73 | #endif |
---|
74 | , m_pColumnWidth() |
---|
75 | , m_pRowHeight() |
---|
76 | , m_scalingListFile() |
---|
77 | , m_elRapSliceBEnabled(0) |
---|
78 | { |
---|
79 | for(UInt layer=0; layer<MAX_LAYERS; layer++) |
---|
80 | { |
---|
81 | m_acLayerCfg[layer].setAppEncCfg(this); |
---|
82 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
83 | m_ilSampleOnlyPred[layer] = 0; |
---|
84 | #endif |
---|
85 | } |
---|
86 | memset( m_scalabilityMask, 0, sizeof(m_scalabilityMask) ); |
---|
87 | } |
---|
88 | #else |
---|
89 | TAppEncCfg::TAppEncCfg() |
---|
90 | : m_pchInputFile() |
---|
91 | , m_pchBitstreamFile() |
---|
92 | , m_pchReconFile() |
---|
93 | , m_pchdQPFile() |
---|
94 | , m_pColumnWidth() |
---|
95 | , m_pRowHeight() |
---|
96 | , m_scalingListFile() |
---|
97 | { |
---|
98 | m_aidQP = NULL; |
---|
99 | m_startOfCodedInterval = NULL; |
---|
100 | m_codedPivotValue = NULL; |
---|
101 | m_targetPivotValue = NULL; |
---|
102 | } |
---|
103 | #endif |
---|
104 | |
---|
105 | TAppEncCfg::~TAppEncCfg() |
---|
106 | { |
---|
107 | #if SVC_EXTENSION |
---|
108 | free(m_pBitstreamFile); |
---|
109 | #else |
---|
110 | free(m_pchBitstreamFile); |
---|
111 | if ( m_aidQP ) |
---|
112 | { |
---|
113 | delete[] m_aidQP; |
---|
114 | } |
---|
115 | if ( m_startOfCodedInterval ) |
---|
116 | { |
---|
117 | delete[] m_startOfCodedInterval; |
---|
118 | m_startOfCodedInterval = NULL; |
---|
119 | } |
---|
120 | if ( m_codedPivotValue ) |
---|
121 | { |
---|
122 | delete[] m_codedPivotValue; |
---|
123 | m_codedPivotValue = NULL; |
---|
124 | } |
---|
125 | if ( m_targetPivotValue ) |
---|
126 | { |
---|
127 | delete[] m_targetPivotValue; |
---|
128 | m_targetPivotValue = NULL; |
---|
129 | } |
---|
130 | free(m_pchInputFile); |
---|
131 | #endif |
---|
132 | #if !SVC_EXTENSION |
---|
133 | free(m_pchReconFile); |
---|
134 | free(m_pchdQPFile); |
---|
135 | #endif |
---|
136 | free(m_pColumnWidth); |
---|
137 | free(m_pRowHeight); |
---|
138 | free(m_scalingListFile); |
---|
139 | } |
---|
140 | |
---|
141 | Void TAppEncCfg::create() |
---|
142 | { |
---|
143 | } |
---|
144 | |
---|
145 | Void TAppEncCfg::destroy() |
---|
146 | { |
---|
147 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
148 | #if M0457_PREDICTION_INDICATIONS |
---|
149 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
150 | { |
---|
151 | if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 ) |
---|
152 | { |
---|
153 | delete [] m_acLayerCfg[layer].m_samplePredRefLayerIds; |
---|
154 | } |
---|
155 | } |
---|
156 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
157 | { |
---|
158 | if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 ) |
---|
159 | { |
---|
160 | delete [] m_acLayerCfg[layer].m_motionPredRefLayerIds; |
---|
161 | } |
---|
162 | } |
---|
163 | #else |
---|
164 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
165 | { |
---|
166 | if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 ) |
---|
167 | { |
---|
168 | delete [] m_acLayerCfg[layer].m_refLayerIds; |
---|
169 | } |
---|
170 | } |
---|
171 | #endif |
---|
172 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
173 | { |
---|
174 | if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 ) |
---|
175 | { |
---|
176 | delete [] m_acLayerCfg[layer].m_predLayerIds; |
---|
177 | } |
---|
178 | } |
---|
179 | #endif |
---|
180 | } |
---|
181 | |
---|
182 | std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry) //input |
---|
183 | { |
---|
184 | in>>entry.m_sliceType; |
---|
185 | in>>entry.m_POC; |
---|
186 | in>>entry.m_QPOffset; |
---|
187 | in>>entry.m_QPFactor; |
---|
188 | in>>entry.m_tcOffsetDiv2; |
---|
189 | in>>entry.m_betaOffsetDiv2; |
---|
190 | in>>entry.m_temporalId; |
---|
191 | in>>entry.m_numRefPicsActive; |
---|
192 | in>>entry.m_numRefPics; |
---|
193 | for ( Int i = 0; i < entry.m_numRefPics; i++ ) |
---|
194 | { |
---|
195 | in>>entry.m_referencePics[i]; |
---|
196 | } |
---|
197 | in>>entry.m_interRPSPrediction; |
---|
198 | #if AUTO_INTER_RPS |
---|
199 | if (entry.m_interRPSPrediction==1) |
---|
200 | { |
---|
201 | in>>entry.m_deltaRPS; |
---|
202 | in>>entry.m_numRefIdc; |
---|
203 | for ( Int i = 0; i < entry.m_numRefIdc; i++ ) |
---|
204 | { |
---|
205 | in>>entry.m_refIdc[i]; |
---|
206 | } |
---|
207 | } |
---|
208 | else if (entry.m_interRPSPrediction==2) |
---|
209 | { |
---|
210 | in>>entry.m_deltaRPS; |
---|
211 | } |
---|
212 | #else |
---|
213 | if (entry.m_interRPSPrediction) |
---|
214 | { |
---|
215 | in>>entry.m_deltaRPS; |
---|
216 | in>>entry.m_numRefIdc; |
---|
217 | for ( Int i = 0; i < entry.m_numRefIdc; i++ ) |
---|
218 | { |
---|
219 | in>>entry.m_refIdc[i]; |
---|
220 | } |
---|
221 | } |
---|
222 | #endif |
---|
223 | #if EXTERNAL_USEDBYCURR_N0082 |
---|
224 | if(entry.m_numRefPics>0){ |
---|
225 | in>>entry.m_UseExtusedByCurrPic; |
---|
226 | if(entry.m_UseExtusedByCurrPic) |
---|
227 | { |
---|
228 | for ( Int i = 0; i < entry.m_numRefPics; i++ ) |
---|
229 | { |
---|
230 | in>>entry.m_ExtusedByCurrPic[i]; |
---|
231 | } |
---|
232 | } |
---|
233 | } |
---|
234 | #endif |
---|
235 | return in; |
---|
236 | } |
---|
237 | |
---|
238 | #if SVC_EXTENSION |
---|
239 | void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path) |
---|
240 | { |
---|
241 | size_t pos = path.find_last_of("\\"); |
---|
242 | if(pos != std::string::npos) |
---|
243 | { |
---|
244 | filename.assign(path.begin() + pos + 1, path.end()); |
---|
245 | dir.assign(path.begin(), path.begin() + pos + 1); |
---|
246 | } |
---|
247 | else |
---|
248 | { |
---|
249 | pos = path.find_last_of("/"); |
---|
250 | if(pos != std::string::npos) |
---|
251 | { |
---|
252 | filename.assign(path.begin() + pos + 1, path.end()); |
---|
253 | dir.assign(path.begin(), path.begin() + pos + 1); |
---|
254 | } |
---|
255 | else |
---|
256 | { |
---|
257 | filename = path; |
---|
258 | dir.assign(""); |
---|
259 | } |
---|
260 | } |
---|
261 | } |
---|
262 | #endif |
---|
263 | |
---|
264 | static const struct MapStrToProfile { |
---|
265 | const Char* str; |
---|
266 | Profile::Name value; |
---|
267 | } strToProfile[] = { |
---|
268 | {"none", Profile::NONE}, |
---|
269 | {"main", Profile::MAIN}, |
---|
270 | {"main10", Profile::MAIN10}, |
---|
271 | {"main-still-picture", Profile::MAINSTILLPICTURE}, |
---|
272 | }; |
---|
273 | |
---|
274 | static const struct MapStrToTier { |
---|
275 | const Char* str; |
---|
276 | Level::Tier value; |
---|
277 | } strToTier[] = { |
---|
278 | {"main", Level::MAIN}, |
---|
279 | {"high", Level::HIGH}, |
---|
280 | }; |
---|
281 | |
---|
282 | static const struct MapStrToLevel { |
---|
283 | const Char* str; |
---|
284 | Level::Name value; |
---|
285 | } strToLevel[] = { |
---|
286 | {"none",Level::NONE}, |
---|
287 | {"1", Level::LEVEL1}, |
---|
288 | {"2", Level::LEVEL2}, |
---|
289 | {"2.1", Level::LEVEL2_1}, |
---|
290 | {"3", Level::LEVEL3}, |
---|
291 | {"3.1", Level::LEVEL3_1}, |
---|
292 | {"4", Level::LEVEL4}, |
---|
293 | {"4.1", Level::LEVEL4_1}, |
---|
294 | {"5", Level::LEVEL5}, |
---|
295 | {"5.1", Level::LEVEL5_1}, |
---|
296 | {"5.2", Level::LEVEL5_2}, |
---|
297 | {"6", Level::LEVEL6}, |
---|
298 | {"6.1", Level::LEVEL6_1}, |
---|
299 | {"6.2", Level::LEVEL6_2}, |
---|
300 | }; |
---|
301 | |
---|
302 | template<typename T, typename P> |
---|
303 | static istream& readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val) |
---|
304 | { |
---|
305 | string str; |
---|
306 | in >> str; |
---|
307 | |
---|
308 | for (Int i = 0; i < mapLen; i++) |
---|
309 | { |
---|
310 | if (str == map[i].str) |
---|
311 | { |
---|
312 | val = map[i].value; |
---|
313 | goto found; |
---|
314 | } |
---|
315 | } |
---|
316 | /* not found */ |
---|
317 | in.setstate(ios::failbit); |
---|
318 | found: |
---|
319 | return in; |
---|
320 | } |
---|
321 | |
---|
322 | static istream& operator>>(istream &in, Profile::Name &profile) |
---|
323 | { |
---|
324 | return readStrToEnum(strToProfile, sizeof(strToProfile)/sizeof(*strToProfile), in, profile); |
---|
325 | } |
---|
326 | |
---|
327 | static istream& operator>>(istream &in, Level::Tier &tier) |
---|
328 | { |
---|
329 | return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier); |
---|
330 | } |
---|
331 | |
---|
332 | static istream& operator>>(istream &in, Level::Name &level) |
---|
333 | { |
---|
334 | return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level); |
---|
335 | } |
---|
336 | |
---|
337 | // ==================================================================================================================== |
---|
338 | // Public member functions |
---|
339 | // ==================================================================================================================== |
---|
340 | |
---|
341 | /** \param argc number of arguments |
---|
342 | \param argv array of arguments |
---|
343 | \retval true when success |
---|
344 | */ |
---|
345 | Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] ) |
---|
346 | { |
---|
347 | Bool do_help = false; |
---|
348 | |
---|
349 | #if SVC_EXTENSION |
---|
350 | string cfg_LayerCfgFile [MAX_LAYERS]; |
---|
351 | string cfg_BitstreamFile; |
---|
352 | string* cfg_InputFile [MAX_LAYERS]; |
---|
353 | string* cfg_ReconFile [MAX_LAYERS]; |
---|
354 | Double* cfg_fQP [MAX_LAYERS]; |
---|
355 | |
---|
356 | #if REPN_FORMAT_IN_VPS |
---|
357 | Int* cfg_repFormatIdx [MAX_LAYERS]; |
---|
358 | #endif |
---|
359 | Int* cfg_SourceWidth [MAX_LAYERS]; |
---|
360 | Int* cfg_SourceHeight [MAX_LAYERS]; |
---|
361 | Int* cfg_FrameRate [MAX_LAYERS]; |
---|
362 | Int* cfg_IntraPeriod [MAX_LAYERS]; |
---|
363 | Int* cfg_conformanceMode [MAX_LAYERS]; |
---|
364 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
365 | #if M0457_PREDICTION_INDICATIONS |
---|
366 | Int* cfg_numSamplePredRefLayers [MAX_LAYERS]; |
---|
367 | string cfg_samplePredRefLayerIds [MAX_LAYERS]; |
---|
368 | string* cfg_samplePredRefLayerIdsPtr[MAX_LAYERS]; |
---|
369 | Int* cfg_numMotionPredRefLayers [MAX_LAYERS]; |
---|
370 | string cfg_motionPredRefLayerIds [MAX_LAYERS]; |
---|
371 | string* cfg_motionPredRefLayerIdsPtr[MAX_LAYERS]; |
---|
372 | #else |
---|
373 | Int* cfg_numDirectRefLayers [MAX_LAYERS]; |
---|
374 | string cfg_refLayerIds [MAX_LAYERS]; |
---|
375 | string* cfg_refLayerIdsPtr [MAX_LAYERS]; |
---|
376 | #endif |
---|
377 | Int* cfg_numActiveRefLayers [MAX_LAYERS]; |
---|
378 | string cfg_predLayerIds [MAX_LAYERS]; |
---|
379 | string* cfg_predLayerIdsPtr [MAX_LAYERS]; |
---|
380 | #endif |
---|
381 | #if SCALED_REF_LAYER_OFFSETS |
---|
382 | string cfg_scaledRefLayerLeftOffset [MAX_LAYERS]; |
---|
383 | string cfg_scaledRefLayerTopOffset [MAX_LAYERS]; |
---|
384 | string cfg_scaledRefLayerRightOffset [MAX_LAYERS]; |
---|
385 | string cfg_scaledRefLayerBottomOffset [MAX_LAYERS]; |
---|
386 | Int* cfg_numScaledRefLayerOffsets[MAX_LAYERS]; |
---|
387 | |
---|
388 | string* cfg_scaledRefLayerLeftOffsetPtr [MAX_LAYERS]; |
---|
389 | string* cfg_scaledRefLayerTopOffsetPtr [MAX_LAYERS]; |
---|
390 | string* cfg_scaledRefLayerRightOffsetPtr [MAX_LAYERS]; |
---|
391 | string* cfg_scaledRefLayerBottomOffsetPtr [MAX_LAYERS]; |
---|
392 | #endif |
---|
393 | #if RC_SHVC_HARMONIZATION |
---|
394 | Bool* cfg_RCEnableRateControl [MAX_LAYERS]; |
---|
395 | Int* cfg_RCTargetBitRate [MAX_LAYERS]; |
---|
396 | Bool* cfg_RCKeepHierarchicalBit[MAX_LAYERS]; |
---|
397 | Bool* cfg_RCLCULevelRC [MAX_LAYERS]; |
---|
398 | Bool* cfg_RCUseLCUSeparateModel[MAX_LAYERS]; |
---|
399 | Int* cfg_RCInitialQP [MAX_LAYERS]; |
---|
400 | Bool* cfg_RCForceIntraQP [MAX_LAYERS]; |
---|
401 | #endif |
---|
402 | #if N0120_MAX_TID_REF_CFG |
---|
403 | Int* cfg_maxTidIlRefPicsPlus1[MAX_LAYERS]; |
---|
404 | #endif |
---|
405 | for(UInt layer = 0; layer < MAX_LAYERS; layer++) |
---|
406 | { |
---|
407 | cfg_InputFile[layer] = &m_acLayerCfg[layer].m_cInputFile; |
---|
408 | cfg_ReconFile[layer] = &m_acLayerCfg[layer].m_cReconFile; |
---|
409 | cfg_fQP[layer] = &m_acLayerCfg[layer].m_fQP; |
---|
410 | #if REPN_FORMAT_IN_VPS |
---|
411 | cfg_repFormatIdx[layer] = &m_acLayerCfg[layer].m_repFormatIdx; |
---|
412 | #endif |
---|
413 | cfg_SourceWidth[layer] = &m_acLayerCfg[layer].m_iSourceWidth; |
---|
414 | cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight; |
---|
415 | cfg_FrameRate[layer] = &m_acLayerCfg[layer].m_iFrameRate; |
---|
416 | cfg_IntraPeriod[layer] = &m_acLayerCfg[layer].m_iIntraPeriod; |
---|
417 | cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode; |
---|
418 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
419 | #if M0457_PREDICTION_INDICATIONS |
---|
420 | cfg_numSamplePredRefLayers [layer] = &m_acLayerCfg[layer].m_numSamplePredRefLayers; |
---|
421 | cfg_samplePredRefLayerIdsPtr[layer] = &cfg_samplePredRefLayerIds[layer]; |
---|
422 | cfg_numMotionPredRefLayers [layer] = &m_acLayerCfg[layer].m_numMotionPredRefLayers; |
---|
423 | cfg_motionPredRefLayerIdsPtr[layer] = &cfg_motionPredRefLayerIds[layer]; |
---|
424 | #else |
---|
425 | cfg_numDirectRefLayers [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers; |
---|
426 | cfg_refLayerIdsPtr [layer] = &cfg_refLayerIds[layer]; |
---|
427 | #endif |
---|
428 | cfg_numActiveRefLayers [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers; |
---|
429 | cfg_predLayerIdsPtr [layer] = &cfg_predLayerIds[layer]; |
---|
430 | #endif |
---|
431 | #if SCALED_REF_LAYER_OFFSETS |
---|
432 | cfg_numScaledRefLayerOffsets [layer] = &m_acLayerCfg[layer].m_numScaledRefLayerOffsets; |
---|
433 | for(Int i = 0; i < MAX_LAYERS; i++) |
---|
434 | { |
---|
435 | cfg_scaledRefLayerLeftOffsetPtr [layer] = &cfg_scaledRefLayerLeftOffset[layer] ; |
---|
436 | cfg_scaledRefLayerTopOffsetPtr [layer] = &cfg_scaledRefLayerTopOffset[layer] ; |
---|
437 | cfg_scaledRefLayerRightOffsetPtr [layer] = &cfg_scaledRefLayerRightOffset[layer] ; |
---|
438 | cfg_scaledRefLayerBottomOffsetPtr[layer] = &cfg_scaledRefLayerBottomOffset[layer]; |
---|
439 | } |
---|
440 | #endif |
---|
441 | #if RC_SHVC_HARMONIZATION |
---|
442 | cfg_RCEnableRateControl[layer] = &m_acLayerCfg[layer].m_RCEnableRateControl; |
---|
443 | cfg_RCTargetBitRate[layer] = &m_acLayerCfg[layer].m_RCTargetBitrate; |
---|
444 | cfg_RCKeepHierarchicalBit[layer] = &m_acLayerCfg[layer].m_RCKeepHierarchicalBit; |
---|
445 | cfg_RCLCULevelRC[layer] = &m_acLayerCfg[layer].m_RCLCULevelRC; |
---|
446 | cfg_RCUseLCUSeparateModel[layer] = &m_acLayerCfg[layer].m_RCUseLCUSeparateModel; |
---|
447 | cfg_RCInitialQP[layer] = &m_acLayerCfg[layer].m_RCInitialQP; |
---|
448 | cfg_RCForceIntraQP[layer] = &m_acLayerCfg[layer].m_RCForceIntraQP; |
---|
449 | #endif |
---|
450 | #if N0120_MAX_TID_REF_CFG |
---|
451 | cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1; |
---|
452 | #endif |
---|
453 | } |
---|
454 | #if AVC_BASE |
---|
455 | string cfg_BLInputFile; |
---|
456 | #endif |
---|
457 | #if AVC_SYNTAX |
---|
458 | string cfg_BLSyntaxFile; |
---|
459 | #endif |
---|
460 | #else |
---|
461 | string cfg_InputFile; |
---|
462 | string cfg_BitstreamFile; |
---|
463 | string cfg_ReconFile; |
---|
464 | string cfg_dQPFile; |
---|
465 | #endif |
---|
466 | string cfg_ColumnWidth; |
---|
467 | string cfg_RowHeight; |
---|
468 | string cfg_ScalingListFile; |
---|
469 | string cfg_startOfCodedInterval; |
---|
470 | string cfg_codedPivotValue; |
---|
471 | string cfg_targetPivotValue; |
---|
472 | po::Options opts; |
---|
473 | opts.addOptions() |
---|
474 | ("help", do_help, false, "this help text") |
---|
475 | ("c", po::parseConfigFile, "configuration file name") |
---|
476 | |
---|
477 | // File, I/O and source parameters |
---|
478 | #if SVC_EXTENSION |
---|
479 | ("InputFile%d,-i%d", cfg_InputFile, string(""), MAX_LAYERS, "original YUV input file name for layer %d") |
---|
480 | ("ReconFile%d,-o%d", cfg_ReconFile, string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d") |
---|
481 | ("LayerConfig%d,-lc%d", cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name") |
---|
482 | ("SourceWidth%d,-wdt%d", cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d") |
---|
483 | ("SourceHeight%d,-hgt%d", cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d") |
---|
484 | ("FrameRate%d,-fr%d", cfg_FrameRate, 0, MAX_LAYERS, "Frame rate for layer %d") |
---|
485 | ("LambdaModifier%d,-LM%d", m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d") |
---|
486 | #if REPN_FORMAT_IN_VPS |
---|
487 | ("RepFormatIdx%d", cfg_repFormatIdx, -1, MAX_LAYERS, "Index to the representation format structure used from the VPS") |
---|
488 | #endif |
---|
489 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
490 | #if M0457_PREDICTION_INDICATIONS |
---|
491 | ("NumSamplePredRefLayers%d",cfg_numSamplePredRefLayers, -1, MAX_LAYERS, "Number of sample prediction reference layers") |
---|
492 | ("SamplePredRefLayerIds%d", cfg_samplePredRefLayerIdsPtr, string(""), MAX_LAYERS, "sample pred reference layer IDs") |
---|
493 | ("NumMotionPredRefLayers%d",cfg_numMotionPredRefLayers, -1, MAX_LAYERS, "Number of motion prediction reference layers") |
---|
494 | ("MotionPredRefLayerIds%d", cfg_motionPredRefLayerIdsPtr, string(""), MAX_LAYERS, "motion pred reference layer IDs") |
---|
495 | #else |
---|
496 | ("NumDirectRefLayers%d", cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers") |
---|
497 | ("RefLayerIds%d", cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs") |
---|
498 | #endif |
---|
499 | ("NumActiveRefLayers%d", cfg_numActiveRefLayers, -1, MAX_LAYERS, "Number of active reference layers") |
---|
500 | ("PredLayerIds%d", cfg_predLayerIdsPtr, string(""), MAX_LAYERS, "inter-layer prediction layer IDs") |
---|
501 | #endif |
---|
502 | ("NumLayers", m_numLayers, 1, "Number of layers to code") |
---|
503 | ("ConformanceMode%d", cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping") |
---|
504 | ("ScalabilityMask0", m_scalabilityMask[0], 0, "scalability_mask[0] (multiview)") |
---|
505 | ("ScalabilityMask1", m_scalabilityMask[1], 1, "scalability_mask[1] (scalable)" ) |
---|
506 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "Bitstream output file name") |
---|
507 | ("InputBitDepth", m_inputBitDepthY, 8, "Bit-depth of input file") |
---|
508 | ("OutputBitDepth", m_outputBitDepthY, 0, "Bit-depth of output file (default:InternalBitDepth)") |
---|
509 | ("InternalBitDepth", m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)" |
---|
510 | "If different to InputBitDepth, source data will be converted") |
---|
511 | ("InputBitDepthC", m_inputBitDepthC, 0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)") |
---|
512 | ("OutputBitDepthC", m_outputBitDepthC, 0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)") |
---|
513 | ("InternalBitDepthC", m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)") |
---|
514 | #if SCALED_REF_LAYER_OFFSETS |
---|
515 | ("NumScaledRefLayerOffsets%d", cfg_numScaledRefLayerOffsets, 0, MAX_LAYERS, "Number of scaled offset layer sets ") |
---|
516 | ("ScaledRefLayerLeftOffset%d", cfg_scaledRefLayerLeftOffsetPtr, string(""), MAX_LAYERS, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to" |
---|
517 | " top-left luma sample of the EL picture, in units of two luma samples") |
---|
518 | ("ScaledRefLayerTopOffset%d", cfg_scaledRefLayerTopOffsetPtr, string(""), MAX_LAYERS, "Vertical offset of top-left luma sample of scaled base layer picture with respect to" |
---|
519 | " top-left luma sample of the EL picture, in units of two luma samples") |
---|
520 | ("ScaledRefLayerRightOffset%d", cfg_scaledRefLayerRightOffsetPtr, string(""), MAX_LAYERS, "Horizontal offset of bottom-right luma sample of scaled base layer picture with respect to" |
---|
521 | " bottom-right luma sample of the EL picture, in units of two luma samples") |
---|
522 | ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to" |
---|
523 | " bottom-right luma sample of the EL picture, in units of two luma samples") |
---|
524 | #endif |
---|
525 | #if N0120_MAX_TID_REF_CFG |
---|
526 | ("MaxTidRefPresentFlag", m_maxTidRefPresentFlag, true, "max_tid_ref_present_flag (0: not present, 1: present(default)) " ) |
---|
527 | ("MaxTidIlRefPicsPlus1%d", cfg_maxTidIlRefPicsPlus1, 1, MAX_LAYERS, "allowed maximum temporal_id for inter-layer prediction") |
---|
528 | #endif |
---|
529 | #if AVC_BASE |
---|
530 | ("AvcBase,-avc", m_avcBaseLayerFlag, 0, "avc_base_layer_flag") |
---|
531 | ("InputBLFile,-ibl", cfg_BLInputFile, string(""), "Base layer rec YUV input file name") |
---|
532 | #if AVC_SYNTAX |
---|
533 | ("InputBLSyntaxFile,-ibs", cfg_BLSyntaxFile, string(""), "Base layer syntax input file name") |
---|
534 | #endif |
---|
535 | #endif |
---|
536 | ("EnableElRapB,-use-rap-b", m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)") |
---|
537 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
538 | ("IlSampleOnlyPred%d", m_ilSampleOnlyPred, 0, MAX_LAYERS, "Set inter_layer_sample_pred_only_flag for all slices") |
---|
539 | #endif |
---|
540 | #else |
---|
541 | ("InputFile,i", cfg_InputFile, string(""), "Original YUV input file name") |
---|
542 | ("BitstreamFile,b", cfg_BitstreamFile, string(""), "Bitstream output file name") |
---|
543 | ("ReconFile,o", cfg_ReconFile, string(""), "Reconstructed YUV output file name") |
---|
544 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
---|
545 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
---|
546 | ("InputBitDepth", m_inputBitDepthY, 8, "Bit-depth of input file") |
---|
547 | ("OutputBitDepth", m_outputBitDepthY, 0, "Bit-depth of output file (default:InternalBitDepth)") |
---|
548 | ("InternalBitDepth", m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)" |
---|
549 | "If different to InputBitDepth, source data will be converted") |
---|
550 | ("InputBitDepthC", m_inputBitDepthC, 0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)") |
---|
551 | ("OutputBitDepthC", m_outputBitDepthC, 0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)") |
---|
552 | ("InternalBitDepthC", m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)") |
---|
553 | ("ConformanceMode", m_conformanceMode, 0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance") |
---|
554 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "Horizontal source padding for conformance window mode 2") |
---|
555 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "Vertical source padding for conformance window mode 2") |
---|
556 | ("ConfLeft", m_confLeft, 0, "Left offset for window conformance mode 3") |
---|
557 | ("ConfRight", m_confRight, 0, "Right offset for window conformance mode 3") |
---|
558 | ("ConfTop", m_confTop, 0, "Top offset for window conformance mode 3") |
---|
559 | ("ConfBottom", m_confBottom, 0, "Bottom offset for window conformance mode 3") |
---|
560 | ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") |
---|
561 | #endif |
---|
562 | ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") |
---|
563 | ("FramesToBeEncoded,f", m_framesToBeEncoded, 0, "Number of frames to be encoded (default=all)") |
---|
564 | |
---|
565 | // Profile and level |
---|
566 | ("Profile", m_profile, Profile::NONE, "Profile to be used when encoding (Incomplete)") |
---|
567 | ("Level", m_level, Level::NONE, "Level limit to be used, eg 5.1 (Incomplete)") |
---|
568 | ("Tier", m_levelTier, Level::MAIN, "Tier to use for interpretation of --Level") |
---|
569 | |
---|
570 | ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive") |
---|
571 | ("InterlacedSource", m_interlacedSourceFlag, false, "Indicate that source is interlaced") |
---|
572 | ("NonPackedSource", m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing") |
---|
573 | ("FrameOnly", m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames") |
---|
574 | |
---|
575 | // Unit definition parameters |
---|
576 | ("MaxCUWidth", m_uiMaxCUWidth, 64u) |
---|
577 | ("MaxCUHeight", m_uiMaxCUHeight, 64u) |
---|
578 | // todo: remove defaults from MaxCUSize |
---|
579 | ("MaxCUSize,s", m_uiMaxCUWidth, 64u, "Maximum CU size") |
---|
580 | ("MaxCUSize,s", m_uiMaxCUHeight, 64u, "Maximum CU size") |
---|
581 | ("MaxPartitionDepth,h", m_uiMaxCUDepth, 4u, "CU depth") |
---|
582 | |
---|
583 | ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u, "Maximum TU size in logarithm base 2") |
---|
584 | ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u, "Minimum TU size in logarithm base 2") |
---|
585 | |
---|
586 | ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs") |
---|
587 | ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs") |
---|
588 | |
---|
589 | // Coding structure paramters |
---|
590 | #if SVC_EXTENSION |
---|
591 | ("IntraPeriod%d,-ip%d", cfg_IntraPeriod, -1, MAX_LAYERS, "intra period in frames for layer %d, (-1: only first frame)") |
---|
592 | #else |
---|
593 | ("IntraPeriod,-ip", m_iIntraPeriod, -1, "Intra period in frames, (-1: only first frame)") |
---|
594 | #endif |
---|
595 | ("DecodingRefreshType,-dr", m_iDecodingRefreshType, 0, "Intra refresh type (0:none 1:CRA 2:IDR)") |
---|
596 | ("GOPSize,g", m_iGOPSize, 1, "GOP size of temporal structure") |
---|
597 | // motion options |
---|
598 | ("FastSearch", m_iFastSearch, 1, "0:Full search 1:Diamond 2:PMVFAST") |
---|
599 | ("SearchRange,-sr", m_iSearchRange, 96, "Motion search range") |
---|
600 | ("BipredSearchRange", m_bipredSearchRange, 4, "Motion search range for bipred refinement") |
---|
601 | ("HadamardME", m_bUseHADME, true, "Hadamard ME for fractional-pel") |
---|
602 | ("ASR", m_bUseASR, false, "Adaptive motion search range") |
---|
603 | |
---|
604 | #if SVC_EXTENSION |
---|
605 | ("LambdaModifier%d,-LM%d", m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d") |
---|
606 | #else |
---|
607 | // Mode decision parameters |
---|
608 | ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0") |
---|
609 | ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( Double )1.0, "Lambda modifier for temporal layer 1") |
---|
610 | ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( Double )1.0, "Lambda modifier for temporal layer 2") |
---|
611 | ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( Double )1.0, "Lambda modifier for temporal layer 3") |
---|
612 | ("LambdaModifier4,-LM4", m_adLambdaModifier[ 4 ], ( Double )1.0, "Lambda modifier for temporal layer 4") |
---|
613 | ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( Double )1.0, "Lambda modifier for temporal layer 5") |
---|
614 | ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6") |
---|
615 | ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7") |
---|
616 | #endif |
---|
617 | |
---|
618 | /* Quantization parameters */ |
---|
619 | #if SVC_EXTENSION |
---|
620 | ("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") |
---|
621 | #else |
---|
622 | ("QP,q", m_fQP, 30.0, "Qp value, if value is float, QP is switched once during encoding") |
---|
623 | #endif |
---|
624 | ("DeltaQpRD,-dqr",m_uiDeltaQpRD, 0u, "max dQp offset for slice") |
---|
625 | ("MaxDeltaQP,d", m_iMaxDeltaQP, 0, "max dQp offset for block") |
---|
626 | ("MaxCuDQPDepth,-dqd", m_iMaxCuDQPDepth, 0, "max depth for a minimum CuDQP") |
---|
627 | |
---|
628 | ("CbQpOffset,-cbqpofs", m_cbQpOffset, 0, "Chroma Cb QP Offset") |
---|
629 | ("CrQpOffset,-crqpofs", m_crQpOffset, 0, "Chroma Cr QP Offset") |
---|
630 | |
---|
631 | #if ADAPTIVE_QP_SELECTION |
---|
632 | ("AdaptiveQpSelection,-aqps", m_bUseAdaptQpSelect, false, "AdaptiveQpSelection") |
---|
633 | #endif |
---|
634 | |
---|
635 | ("AdaptiveQP,-aq", m_bUseAdaptiveQP, false, "QP adaptation based on a psycho-visual model") |
---|
636 | ("MaxQPAdaptationRange,-aqr", m_iQPAdaptationRange, 6, "QP adaptation range") |
---|
637 | #if !SVC_EXTENSION |
---|
638 | ("dQPFile,m", cfg_dQPFile, string(""), "dQP file name") |
---|
639 | #endif |
---|
640 | ("RDOQ", m_useRDOQ, true ) |
---|
641 | ("RDOQTS", m_useRDOQTS, true ) |
---|
642 | ("RDpenalty", m_rdPenalty, 0, "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled 1:RD-penalty 2:maximum RD-penalty") |
---|
643 | // Entropy coding parameters |
---|
644 | ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation") |
---|
645 | |
---|
646 | // Deblocking filter parameters |
---|
647 | ("LoopFilterDisable", m_bLoopFilterDisable, false ) |
---|
648 | ("LoopFilterOffsetInPPS", m_loopFilterOffsetInPPS, false ) |
---|
649 | ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0 ) |
---|
650 | ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0 ) |
---|
651 | ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false ) |
---|
652 | ("DeblockingFilterMetric", m_DeblockingFilterMetric, false ) |
---|
653 | |
---|
654 | // Coding tools |
---|
655 | ("AMP", m_enableAMP, true, "Enable asymmetric motion partitions") |
---|
656 | ("TransformSkip", m_useTransformSkip, false, "Intra transform skipping") |
---|
657 | ("TransformSkipFast", m_useTransformSkipFast, false, "Fast intra transform skipping") |
---|
658 | ("SAO", m_bUseSAO, true, "Enable Sample Adaptive Offset") |
---|
659 | ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "Max number of SAO offset per picture (Default: 2048)") |
---|
660 | ("SAOLcuBoundary", m_saoLcuBoundary, false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas") |
---|
661 | ("SAOLcuBasedOptimization", m_saoLcuBasedOptimization, true, "0: SAO picture-based optimization, 1: SAO LCU-based optimization ") |
---|
662 | ("SliceMode", m_sliceMode, 0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice") |
---|
663 | ("SliceArgument", m_sliceArgument, 0, "Depending on SliceMode being:" |
---|
664 | "\t1: max number of CTUs per slice" |
---|
665 | "\t2: max number of bytes per slice" |
---|
666 | "\t3: max number of tiles per slice") |
---|
667 | ("SliceSegmentMode", m_sliceSegmentMode, 0, "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice") |
---|
668 | ("SliceSegmentArgument", m_sliceSegmentArgument, 0, "Depending on SliceSegmentMode being:" |
---|
669 | "\t1: max number of CTUs per slice segment" |
---|
670 | "\t2: max number of bytes per slice segment" |
---|
671 | "\t3: max number of tiles per slice segment") |
---|
672 | ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true) |
---|
673 | |
---|
674 | ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction") |
---|
675 | |
---|
676 | ("PCMEnabledFlag", m_usePCM, false) |
---|
677 | ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u) |
---|
678 | ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u) |
---|
679 | ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true) |
---|
680 | ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false) |
---|
681 | |
---|
682 | ("LosslessCuEnabled", m_useLossless, false) |
---|
683 | |
---|
684 | ("WeightedPredP,-wpP", m_useWeightedPred, false, "Use weighted prediction in P slices") |
---|
685 | ("WeightedPredB,-wpB", m_useWeightedBiPred, false, "Use weighted (bidirectional) prediction in B slices") |
---|
686 | ("Log2ParallelMergeLevel", m_log2ParallelMergeLevel, 2u, "Parallel merge estimation region") |
---|
687 | ("UniformSpacingIdc", m_iUniformSpacingIdr, 0, "Indicates if the column and row boundaries are distributed uniformly") |
---|
688 | ("NumTileColumnsMinus1", m_iNumColumnsMinus1, 0, "Number of columns in a picture minus 1") |
---|
689 | ("ColumnWidthArray", cfg_ColumnWidth, string(""), "Array containing ColumnWidth values in units of LCU") |
---|
690 | ("NumTileRowsMinus1", m_iNumRowsMinus1, 0, "Number of rows in a picture minus 1") |
---|
691 | ("RowHeightArray", cfg_RowHeight, string(""), "Array containing RowHeight values in units of LCU") |
---|
692 | ("LFCrossTileBoundaryFlag", m_bLFCrossTileBoundaryFlag, true, "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering") |
---|
693 | ("WaveFrontSynchro", m_iWaveFrontSynchro, 0, "0: no synchro; 1 synchro with TR; 2 TRR etc") |
---|
694 | ("ScalingList", m_useScalingListId, 0, "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile") |
---|
695 | ("ScalingListFile", cfg_ScalingListFile, string(""), "Scaling list file name") |
---|
696 | ("SignHideFlag,-SBH", m_signHideFlag, 1) |
---|
697 | ("MaxNumMergeCand", m_maxNumMergeCand, 5u, "Maximum number of merge candidates") |
---|
698 | |
---|
699 | /* Misc. */ |
---|
700 | ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 0, "Control generation of decode picture hash SEI messages\n" |
---|
701 | "\t3: checksum\n" |
---|
702 | "\t2: CRC\n" |
---|
703 | "\t1: use MD5\n" |
---|
704 | "\t0: disable") |
---|
705 | ("SEIpictureDigest", m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash") |
---|
706 | ("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") |
---|
707 | ("FEN", m_bUseFastEnc, false, "fast encoder setting") |
---|
708 | ("ECU", m_bUseEarlyCU, false, "Early CU setting") |
---|
709 | ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") |
---|
710 | ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting") |
---|
711 | ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting") |
---|
712 | #if FAST_INTRA_SHVC |
---|
713 | ("FIS", m_useFastIntraScalable, false, "Fast Intra Decision for Scalable HEVC") |
---|
714 | #endif |
---|
715 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
716 | #if RC_SHVC_HARMONIZATION |
---|
717 | ("RateControl%d", cfg_RCEnableRateControl, false, MAX_LAYERS, "Rate control: enable rate control for layer %d") |
---|
718 | ("TargetBitrate%d", cfg_RCTargetBitRate, 0, MAX_LAYERS, "Rate control: target bitrate for layer %d") |
---|
719 | ("KeepHierarchicalBit%d", cfg_RCKeepHierarchicalBit, false, MAX_LAYERS, "Rate control: keep hierarchical bit allocation for layer %d") |
---|
720 | ("LCULevelRateControl%d", cfg_RCLCULevelRC, true, MAX_LAYERS, "Rate control: LCU level RC") |
---|
721 | ("RCLCUSeparateModel%d", cfg_RCUseLCUSeparateModel, true, MAX_LAYERS, "Rate control: Use LCU level separate R-lambda model") |
---|
722 | ("InitialQP%d", cfg_RCInitialQP, 0, MAX_LAYERS, "Rate control: initial QP") |
---|
723 | ("RCForceIntraQP%d", cfg_RCForceIntraQP, false, MAX_LAYERS, "Rate control: force intra QP to be equal to initial QP") |
---|
724 | #else |
---|
725 | ( "RateControl", m_RCEnableRateControl, false, "Rate control: enable rate control" ) |
---|
726 | ( "TargetBitrate", m_RCTargetBitrate, 0, "Rate control: target bitrate" ) |
---|
727 | #if M0036_RC_IMPROVEMENT |
---|
728 | ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, 0, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" ) |
---|
729 | #else |
---|
730 | ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" ) |
---|
731 | #endif |
---|
732 | ( "LCULevelRateControl", m_RCLCULevelRC, true, "Rate control: true: LCU level RC; false: picture level RC" ) |
---|
733 | ( "RCLCUSeparateModel", m_RCUseLCUSeparateModel, true, "Rate control: use LCU level separate R-lambda model" ) |
---|
734 | ( "InitialQP", m_RCInitialQP, 0, "Rate control: initial QP" ) |
---|
735 | ( "RCForceIntraQP", m_RCForceIntraQP, false, "Rate control: force intra QP to be equal to initial QP" ) |
---|
736 | #endif |
---|
737 | #else |
---|
738 | ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off") |
---|
739 | ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate") |
---|
740 | ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit") |
---|
741 | #endif |
---|
742 | |
---|
743 | ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS") |
---|
744 | ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled") |
---|
745 | ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case") |
---|
746 | ("StrongIntraSmoothing,-sis", m_useStrongIntraSmoothing, true, "Enable strong intra smoothing for 32x32 blocks") |
---|
747 | ("SEIActiveParameterSets", m_activeParameterSetsSEIEnabled, 0, "Enable generation of active parameter sets SEI messages") |
---|
748 | ("VuiParametersPresent,-vui", m_vuiParametersPresentFlag, false, "Enable generation of vui_parameters()") |
---|
749 | ("AspectRatioInfoPresent", m_aspectRatioInfoPresentFlag, false, "Signals whether aspect_ratio_idc is present") |
---|
750 | ("AspectRatioIdc", m_aspectRatioIdc, 0, "aspect_ratio_idc") |
---|
751 | ("SarWidth", m_sarWidth, 0, "horizontal size of the sample aspect ratio") |
---|
752 | ("SarHeight", m_sarHeight, 0, "vertical size of the sample aspect ratio") |
---|
753 | ("OverscanInfoPresent", m_overscanInfoPresentFlag, false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n") |
---|
754 | ("OverscanAppropriate", m_overscanAppropriateFlag, false, "Indicates whether conformant decoded pictures are suitable for display using overscan\n") |
---|
755 | ("VideoSignalTypePresent", m_videoSignalTypePresentFlag, false, "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present") |
---|
756 | ("VideoFormat", m_videoFormat, 5, "Indicates representation of pictures") |
---|
757 | ("VideoFullRange", m_videoFullRangeFlag, false, "Indicates the black level and range of luma and chroma signals") |
---|
758 | ("ColourDescriptionPresent", m_colourDescriptionPresentFlag, false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present") |
---|
759 | ("ColourPrimaries", m_colourPrimaries, 2, "Indicates chromaticity coordinates of the source primaries") |
---|
760 | ("TransferCharateristics", m_transferCharacteristics, 2, "Indicates the opto-electronic transfer characteristics of the source") |
---|
761 | ("MatrixCoefficients", m_matrixCoefficients, 2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries") |
---|
762 | ("ChromaLocInfoPresent", m_chromaLocInfoPresentFlag, false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present") |
---|
763 | ("ChromaSampleLocTypeTopField", m_chromaSampleLocTypeTopField, 0, "Specifies the location of chroma samples for top field") |
---|
764 | ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField, 0, "Specifies the location of chroma samples for bottom field") |
---|
765 | ("NeutralChromaIndication", m_neutralChromaIndicationFlag, false, "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)") |
---|
766 | ("DefaultDisplayWindowFlag", m_defaultDisplayWindowFlag, false, "Indicates the presence of the Default Window parameters") |
---|
767 | ("DefDispWinLeftOffset", m_defDispWinLeftOffset, 0, "Specifies the left offset of the default display window from the conformance window") |
---|
768 | ("DefDispWinRightOffset", m_defDispWinRightOffset, 0, "Specifies the right offset of the default display window from the conformance window") |
---|
769 | ("DefDispWinTopOffset", m_defDispWinTopOffset, 0, "Specifies the top offset of the default display window from the conformance window") |
---|
770 | ("DefDispWinBottomOffset", m_defDispWinBottomOffset, 0, "Specifies the bottom offset of the default display window from the conformance window") |
---|
771 | ("FrameFieldInfoPresentFlag", m_frameFieldInfoPresentFlag, false, "Indicates that pic_struct and field coding related values are present in picture timing SEI messages") |
---|
772 | ("PocProportionalToTimingFlag", m_pocProportionalToTimingFlag, false, "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS") |
---|
773 | ("NumTicksPocDiffOneMinus1", m_numTicksPocDiffOneMinus1, 0, "Number of ticks minus 1 that for a POC difference of one") |
---|
774 | ("BitstreamRestriction", m_bitstreamRestrictionFlag, false, "Signals whether bitstream restriction parameters are present") |
---|
775 | ("TilesFixedStructure", m_tilesFixedStructureFlag, false, "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles") |
---|
776 | ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false, "Indicates that no samples outside the picture boundaries are used for inter prediction") |
---|
777 | ("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") |
---|
778 | ("MaxBitsPerMinCuDenom", m_maxBitsPerMinCuDenom, 1, "Indicates an upper bound for the number of bits of coding_unit() data") |
---|
779 | ("Log2MaxMvLengthHorizontal", m_log2MaxMvLengthHorizontal, 15, "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units") |
---|
780 | ("Log2MaxMvLengthVertical", m_log2MaxMvLengthVertical, 15, "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units") |
---|
781 | ("SEIRecoveryPoint", m_recoveryPointSEIEnabled, 0, "Control generation of recovery point SEI messages") |
---|
782 | ("SEIBufferingPeriod", m_bufferingPeriodSEIEnabled, 0, "Control generation of buffering period SEI messages") |
---|
783 | ("SEIPictureTiming", m_pictureTimingSEIEnabled, 0, "Control generation of picture timing SEI messages") |
---|
784 | ("SEIToneMappingInfo", m_toneMappingInfoSEIEnabled, false, "Control generation of Tone Mapping SEI messages") |
---|
785 | ("SEIToneMapId", m_toneMapId, 0, "Specifies Id of Tone Mapping SEI message for a given session") |
---|
786 | ("SEIToneMapCancelFlag", m_toneMapCancelFlag, false, "Indicates that Tone Mapping SEI message cancels the persistance or follows") |
---|
787 | ("SEIToneMapPersistenceFlag", m_toneMapPersistenceFlag, true, "Specifies the persistence of the Tone Mapping SEI message") |
---|
788 | ("SEIToneMapCodedDataBitDepth", m_toneMapCodedDataBitDepth, 8, "Specifies Coded Data BitDepth of Tone Mapping SEI messages") |
---|
789 | ("SEIToneMapTargetBitDepth", m_toneMapTargetBitDepth, 8, "Specifies Output BitDepth of Tome mapping function") |
---|
790 | ("SEIToneMapModelId", m_toneMapModelId, 0, "Specifies Model utilized for mapping coded data into target_bit_depth range\n" |
---|
791 | "\t0: linear mapping with clipping\n" |
---|
792 | "\t1: sigmoidal mapping\n" |
---|
793 | "\t2: user-defined table mapping\n" |
---|
794 | "\t3: piece-wise linear mapping\n" |
---|
795 | "\t4: luminance dynamic range information ") |
---|
796 | ("SEIToneMapMinValue", m_toneMapMinValue, 0, "Specifies the minimum value in mode 0") |
---|
797 | ("SEIToneMapMaxValue", m_toneMapMaxValue, 1023, "Specifies the maxmum value in mode 0") |
---|
798 | ("SEIToneMapSigmoidMidpoint", m_sigmoidMidpoint, 512, "Specifies the centre point in mode 1") |
---|
799 | ("SEIToneMapSigmoidWidth", m_sigmoidWidth, 960, "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1") |
---|
800 | ("SEIToneMapStartOfCodedInterval", cfg_startOfCodedInterval, string(""), "Array of user-defined mapping table") |
---|
801 | ("SEIToneMapNumPivots", m_numPivots, 0, "Specifies the number of pivot points in mode 3") |
---|
802 | ("SEIToneMapCodedPivotValue", cfg_codedPivotValue, string(""), "Array of pivot point") |
---|
803 | ("SEIToneMapTargetPivotValue", cfg_targetPivotValue, string(""), "Array of pivot point") |
---|
804 | ("SEIToneMapCameraIsoSpeedIdc", m_cameraIsoSpeedIdc, 0, "Indicates the camera ISO speed for daylight illumination") |
---|
805 | ("SEIToneMapCameraIsoSpeedValue", m_cameraIsoSpeedValue, 400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO") |
---|
806 | ("SEIToneMapExposureCompensationValueSignFlag", m_exposureCompensationValueSignFlag, 0, "Specifies the sign of ExposureCompensationValue") |
---|
807 | ("SEIToneMapExposureCompensationValueNumerator", m_exposureCompensationValueNumerator, 0, "Specifies the numerator of ExposureCompensationValue") |
---|
808 | ("SEIToneMapExposureCompensationValueDenomIdc", m_exposureCompensationValueDenomIdc, 2, "Specifies the denominator of ExposureCompensationValue") |
---|
809 | ("SEIToneMapRefScreenLuminanceWhite", m_refScreenLuminanceWhite, 350, "Specifies reference screen brightness setting in units of candela per square metre") |
---|
810 | ("SEIToneMapExtendedRangeWhiteLevel", m_extendedRangeWhiteLevel, 800, "Indicates the luminance dynamic range") |
---|
811 | ("SEIToneMapNominalBlackLevelLumaCodeValue", m_nominalBlackLevelLumaCodeValue, 16, "Specifies luma sample value of the nominal black level assigned decoded pictures") |
---|
812 | ("SEIToneMapNominalWhiteLevelLumaCodeValue", m_nominalWhiteLevelLumaCodeValue, 235, "Specifies luma sample value of the nominal white level assigned decoded pictures") |
---|
813 | ("SEIToneMapExtendedWhiteLevelLumaCodeValue", m_extendedWhiteLevelLumaCodeValue, 300, "Specifies luma sample value of the extended dynamic range assigned decoded pictures") |
---|
814 | ("SEIFramePacking", m_framePackingSEIEnabled, 0, "Control generation of frame packing SEI messages") |
---|
815 | ("SEIFramePackingType", m_framePackingSEIType, 0, "Define frame packing arrangement\n" |
---|
816 | "\t0: checkerboard - pixels alternatively represent either frames\n" |
---|
817 | "\t1: column alternation - frames are interlaced by column\n" |
---|
818 | "\t2: row alternation - frames are interlaced by row\n" |
---|
819 | "\t3: side by side - frames are displayed horizontally\n" |
---|
820 | "\t4: top bottom - frames are displayed vertically\n" |
---|
821 | "\t5: frame alternation - one frame is alternated with the other") |
---|
822 | ("SEIFramePackingId", m_framePackingSEIId, 0, "Id of frame packing SEI message for a given session") |
---|
823 | ("SEIFramePackingQuincunx", m_framePackingSEIQuincunx, 0, "Indicate the presence of a Quincunx type video frame") |
---|
824 | ("SEIFramePackingInterpretation", m_framePackingSEIInterpretation, 0, "Indicate the interpretation of the frame pair\n" |
---|
825 | "\t0: unspecified\n" |
---|
826 | "\t1: stereo pair, frame0 represents left view\n" |
---|
827 | "\t2: stereo pair, frame0 represents right view") |
---|
828 | ("SEIDisplayOrientation", m_displayOrientationSEIAngle, 0, "Control generation of display orientation SEI messages\n" |
---|
829 | "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n" |
---|
830 | "\t0: disable") |
---|
831 | ("SEITemporalLevel0Index", m_temporalLevel0IndexSEIEnabled, 0, "Control generation of temporal level 0 index SEI messages") |
---|
832 | ("SEIGradualDecodingRefreshInfo", m_gradualDecodingRefreshInfoEnabled, 0, "Control generation of gradual decoding refresh information SEI message") |
---|
833 | ("SEIDecodingUnitInfo", m_decodingUnitInfoSEIEnabled, 0, "Control generation of decoding unit information SEI message.") |
---|
834 | #if M0043_LAYERS_PRESENT_SEI |
---|
835 | ("SEILayersPresent", m_layersPresentSEIEnabled, 0, "Control generation of layers present SEI message") |
---|
836 | #endif |
---|
837 | ("SEISOPDescription", m_SOPDescriptionSEIEnabled, 0, "Control generation of SOP description SEI messages") |
---|
838 | ("SEIScalableNesting", m_scalableNestingSEIEnabled, 0, "Control generation of scalable nesting SEI messages") |
---|
839 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
840 | ("AdaptiveResolutionChange", m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)") |
---|
841 | #endif |
---|
842 | ; |
---|
843 | |
---|
844 | for(Int i=1; i<MAX_GOP+1; i++) { |
---|
845 | std::ostringstream cOSS; |
---|
846 | cOSS<<"Frame"<<i; |
---|
847 | opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry()); |
---|
848 | } |
---|
849 | #if FINAL_RPL_CHANGE_N0082 |
---|
850 | for(Int i=1; i<MAX_GOP+1; i++) { |
---|
851 | std::ostringstream cOSS; |
---|
852 | cOSS<<"FrameEL"<<i; |
---|
853 | opts.addOptions()(cOSS.str(), m_acLayerCfg[1].m_GOPListLayer[i-1], GOPEntry()); |
---|
854 | } |
---|
855 | #endif |
---|
856 | po::setDefaults(opts); |
---|
857 | const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv); |
---|
858 | |
---|
859 | for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++) |
---|
860 | { |
---|
861 | fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it); |
---|
862 | } |
---|
863 | |
---|
864 | if (argc == 1 || do_help) |
---|
865 | { |
---|
866 | /* argc == 1: no options have been specified */ |
---|
867 | po::doHelp(cout, opts); |
---|
868 | return false; |
---|
869 | } |
---|
870 | |
---|
871 | /* |
---|
872 | * Set any derived parameters |
---|
873 | */ |
---|
874 | /* convert std::string to c string for compatability */ |
---|
875 | #if SVC_EXTENSION |
---|
876 | #if AVC_BASE |
---|
877 | if( m_avcBaseLayerFlag ) |
---|
878 | { |
---|
879 | *cfg_InputFile[0] = cfg_BLInputFile; |
---|
880 | } |
---|
881 | #endif |
---|
882 | m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
883 | #if AVC_SYNTAX |
---|
884 | m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str()); |
---|
885 | #endif |
---|
886 | #else |
---|
887 | m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str()); |
---|
888 | m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); |
---|
889 | m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str()); |
---|
890 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
---|
891 | #endif |
---|
892 | |
---|
893 | Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str()); |
---|
894 | Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str()); |
---|
895 | if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 ) |
---|
896 | { |
---|
897 | char *columnWidth; |
---|
898 | int i=0; |
---|
899 | m_pColumnWidth = new UInt[m_iNumColumnsMinus1]; |
---|
900 | columnWidth = strtok(pColumnWidth, " ,-"); |
---|
901 | while(columnWidth!=NULL) |
---|
902 | { |
---|
903 | if( i>=m_iNumColumnsMinus1 ) |
---|
904 | { |
---|
905 | printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
906 | exit( EXIT_FAILURE ); |
---|
907 | } |
---|
908 | *( m_pColumnWidth + i ) = atoi( columnWidth ); |
---|
909 | columnWidth = strtok(NULL, " ,-"); |
---|
910 | i++; |
---|
911 | } |
---|
912 | if( i<m_iNumColumnsMinus1 ) |
---|
913 | { |
---|
914 | printf( "The width of some columns is not defined.\n" ); |
---|
915 | exit( EXIT_FAILURE ); |
---|
916 | } |
---|
917 | } |
---|
918 | else |
---|
919 | { |
---|
920 | m_pColumnWidth = NULL; |
---|
921 | } |
---|
922 | |
---|
923 | if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 ) |
---|
924 | { |
---|
925 | char *rowHeight; |
---|
926 | int i=0; |
---|
927 | m_pRowHeight = new UInt[m_iNumRowsMinus1]; |
---|
928 | rowHeight = strtok(pRowHeight, " ,-"); |
---|
929 | while(rowHeight!=NULL) |
---|
930 | { |
---|
931 | if( i>=m_iNumRowsMinus1 ) |
---|
932 | { |
---|
933 | printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" ); |
---|
934 | exit( EXIT_FAILURE ); |
---|
935 | } |
---|
936 | *( m_pRowHeight + i ) = atoi( rowHeight ); |
---|
937 | rowHeight = strtok(NULL, " ,-"); |
---|
938 | i++; |
---|
939 | } |
---|
940 | if( i<m_iNumRowsMinus1 ) |
---|
941 | { |
---|
942 | printf( "The height of some rows is not defined.\n" ); |
---|
943 | exit( EXIT_FAILURE ); |
---|
944 | } |
---|
945 | } |
---|
946 | else |
---|
947 | { |
---|
948 | m_pRowHeight = NULL; |
---|
949 | } |
---|
950 | #if SCALED_REF_LAYER_OFFSETS |
---|
951 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
952 | { |
---|
953 | // If number of scaled ref. layer offsets is non-zero, at least one of the offsets should be specified |
---|
954 | if(m_acLayerCfg[layer].m_numScaledRefLayerOffsets) |
---|
955 | { |
---|
956 | assert( strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(), "") || |
---|
957 | strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(), "") || |
---|
958 | strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(), "") || |
---|
959 | strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"") |
---|
960 | ); |
---|
961 | } |
---|
962 | |
---|
963 | Int *tempArray = NULL; // Contain the value |
---|
964 | // Left offset // |
---|
965 | if(strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(), "")) |
---|
966 | { |
---|
967 | cfgStringToArray( &tempArray, cfg_scaledRefLayerLeftOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "LeftOffset"); |
---|
968 | if(tempArray) |
---|
969 | { |
---|
970 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
971 | { |
---|
972 | m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i] = tempArray[i]; |
---|
973 | } |
---|
974 | delete [] tempArray; tempArray = NULL; |
---|
975 | } |
---|
976 | } |
---|
977 | |
---|
978 | // Top offset // |
---|
979 | if(strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(), "")) |
---|
980 | { |
---|
981 | cfgStringToArray( &tempArray, cfg_scaledRefLayerTopOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "TopOffset"); |
---|
982 | if(tempArray) |
---|
983 | { |
---|
984 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
985 | { |
---|
986 | m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i] = tempArray[i]; |
---|
987 | } |
---|
988 | delete [] tempArray; tempArray = NULL; |
---|
989 | } |
---|
990 | } |
---|
991 | |
---|
992 | // Right offset // |
---|
993 | if(strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(), "")) |
---|
994 | { |
---|
995 | cfgStringToArray( &tempArray, cfg_scaledRefLayerRightOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RightOffset"); |
---|
996 | if(tempArray) |
---|
997 | { |
---|
998 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
999 | { |
---|
1000 | m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i] = tempArray[i]; |
---|
1001 | } |
---|
1002 | delete [] tempArray; tempArray = NULL; |
---|
1003 | } |
---|
1004 | } |
---|
1005 | |
---|
1006 | // Bottom offset // |
---|
1007 | if(strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(), "")) |
---|
1008 | { |
---|
1009 | cfgStringToArray( &tempArray, cfg_scaledRefLayerBottomOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "BottomOffset"); |
---|
1010 | if(tempArray) |
---|
1011 | { |
---|
1012 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
1013 | { |
---|
1014 | m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i] = tempArray[i]; |
---|
1015 | } |
---|
1016 | delete [] tempArray; tempArray = NULL; |
---|
1017 | } |
---|
1018 | } |
---|
1019 | } |
---|
1020 | #endif |
---|
1021 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1022 | #if M0457_PREDICTION_INDICATIONS |
---|
1023 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
1024 | { |
---|
1025 | Char* pSamplePredRefLayerIds = cfg_samplePredRefLayerIds[layer].empty() ? NULL: strdup(cfg_samplePredRefLayerIds[layer].c_str()); |
---|
1026 | if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 ) |
---|
1027 | { |
---|
1028 | char *samplePredRefLayerId; |
---|
1029 | int i=0; |
---|
1030 | m_acLayerCfg[layer].m_samplePredRefLayerIds = new Int[m_acLayerCfg[layer].m_numSamplePredRefLayers]; |
---|
1031 | samplePredRefLayerId = strtok(pSamplePredRefLayerIds, " ,-"); |
---|
1032 | while(samplePredRefLayerId != NULL) |
---|
1033 | { |
---|
1034 | if( i >= m_acLayerCfg[layer].m_numSamplePredRefLayers ) |
---|
1035 | { |
---|
1036 | printf( "NumSamplePredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
1037 | exit( EXIT_FAILURE ); |
---|
1038 | } |
---|
1039 | *( m_acLayerCfg[layer].m_samplePredRefLayerIds + i ) = atoi( samplePredRefLayerId ); |
---|
1040 | samplePredRefLayerId = strtok(NULL, " ,-"); |
---|
1041 | i++; |
---|
1042 | } |
---|
1043 | if( i < m_acLayerCfg[layer].m_numSamplePredRefLayers ) |
---|
1044 | { |
---|
1045 | printf( "NumSamplePredRefLayers: The width of some columns is not defined.\n" ); |
---|
1046 | exit( EXIT_FAILURE ); |
---|
1047 | } |
---|
1048 | } |
---|
1049 | else |
---|
1050 | { |
---|
1051 | m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL; |
---|
1052 | } |
---|
1053 | } |
---|
1054 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
1055 | { |
---|
1056 | Char* pMotionPredRefLayerIds = cfg_motionPredRefLayerIds[layer].empty() ? NULL: strdup(cfg_motionPredRefLayerIds[layer].c_str()); |
---|
1057 | if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 ) |
---|
1058 | { |
---|
1059 | char *motionPredRefLayerId; |
---|
1060 | int i=0; |
---|
1061 | m_acLayerCfg[layer].m_motionPredRefLayerIds = new Int[m_acLayerCfg[layer].m_numMotionPredRefLayers]; |
---|
1062 | motionPredRefLayerId = strtok(pMotionPredRefLayerIds, " ,-"); |
---|
1063 | while(motionPredRefLayerId != NULL) |
---|
1064 | { |
---|
1065 | if( i >= m_acLayerCfg[layer].m_numMotionPredRefLayers ) |
---|
1066 | { |
---|
1067 | printf( "NumMotionPredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
1068 | exit( EXIT_FAILURE ); |
---|
1069 | } |
---|
1070 | *( m_acLayerCfg[layer].m_motionPredRefLayerIds + i ) = atoi( motionPredRefLayerId ); |
---|
1071 | motionPredRefLayerId = strtok(NULL, " ,-"); |
---|
1072 | i++; |
---|
1073 | } |
---|
1074 | if( i < m_acLayerCfg[layer].m_numMotionPredRefLayers ) |
---|
1075 | { |
---|
1076 | printf( "NumMotionPredRefLayers: The width of some columns is not defined.\n" ); |
---|
1077 | exit( EXIT_FAILURE ); |
---|
1078 | } |
---|
1079 | } |
---|
1080 | else |
---|
1081 | { |
---|
1082 | m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL; |
---|
1083 | } |
---|
1084 | } |
---|
1085 | #else |
---|
1086 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
1087 | { |
---|
1088 | Char* pRefLayerIds = cfg_refLayerIds[layer].empty() ? NULL: strdup(cfg_refLayerIds[layer].c_str()); |
---|
1089 | if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 ) |
---|
1090 | { |
---|
1091 | char *refLayerId; |
---|
1092 | int i=0; |
---|
1093 | m_acLayerCfg[layer].m_refLayerIds = new Int[m_acLayerCfg[layer].m_numDirectRefLayers]; |
---|
1094 | refLayerId = strtok(pRefLayerIds, " ,-"); |
---|
1095 | while(refLayerId != NULL) |
---|
1096 | { |
---|
1097 | if( i >= m_acLayerCfg[layer].m_numDirectRefLayers ) |
---|
1098 | { |
---|
1099 | printf( "NumDirectRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
1100 | exit( EXIT_FAILURE ); |
---|
1101 | } |
---|
1102 | *( m_acLayerCfg[layer].m_refLayerIds + i ) = atoi( refLayerId ); |
---|
1103 | refLayerId = strtok(NULL, " ,-"); |
---|
1104 | i++; |
---|
1105 | } |
---|
1106 | if( i < m_acLayerCfg[layer].m_numDirectRefLayers ) |
---|
1107 | { |
---|
1108 | printf( "NumDirectRefLayers: The width of some columns is not defined.\n" ); |
---|
1109 | exit( EXIT_FAILURE ); |
---|
1110 | } |
---|
1111 | } |
---|
1112 | else |
---|
1113 | { |
---|
1114 | m_acLayerCfg[layer].m_refLayerIds = NULL; |
---|
1115 | } |
---|
1116 | } |
---|
1117 | #endif |
---|
1118 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
1119 | { |
---|
1120 | Char* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str()); |
---|
1121 | if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 ) |
---|
1122 | { |
---|
1123 | char *refLayerId; |
---|
1124 | int i=0; |
---|
1125 | m_acLayerCfg[layer].m_predLayerIds = new Int[m_acLayerCfg[layer].m_numActiveRefLayers]; |
---|
1126 | refLayerId = strtok(pPredLayerIds, " ,-"); |
---|
1127 | while(refLayerId != NULL) |
---|
1128 | { |
---|
1129 | if( i >= m_acLayerCfg[layer].m_numActiveRefLayers ) |
---|
1130 | { |
---|
1131 | printf( "NumActiveRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" ); |
---|
1132 | exit( EXIT_FAILURE ); |
---|
1133 | } |
---|
1134 | *( m_acLayerCfg[layer].m_predLayerIds + i ) = atoi( refLayerId ); |
---|
1135 | refLayerId = strtok(NULL, " ,-"); |
---|
1136 | i++; |
---|
1137 | } |
---|
1138 | if( i < m_acLayerCfg[layer].m_numActiveRefLayers ) |
---|
1139 | { |
---|
1140 | printf( "NumActiveRefLayers: The width of some columns is not defined.\n" ); |
---|
1141 | exit( EXIT_FAILURE ); |
---|
1142 | } |
---|
1143 | } |
---|
1144 | else |
---|
1145 | { |
---|
1146 | m_acLayerCfg[layer].m_predLayerIds = NULL; |
---|
1147 | } |
---|
1148 | } |
---|
1149 | #endif |
---|
1150 | m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str()); |
---|
1151 | |
---|
1152 | #if REPN_FORMAT_IN_VPS_123 |
---|
1153 | for(Int layer = 0; layer < MAX_LAYERS; layer++) |
---|
1154 | { |
---|
1155 | m_acLayerCfg[layer].setSourceHeight( m_repFormatCfg[ m_acLayerCfg[layer].getRepFormatIdx() ].m_picHeightInLumaSamples); |
---|
1156 | m_acLayerCfg[layer].setSourceWidth ( m_repFormatCfg[ m_acLayerCfg[layer].getRepFormatIdx() ].m_picWidthInLumaSamples ); |
---|
1157 | } |
---|
1158 | #endif |
---|
1159 | /* rules for input, output and internal bitdepths as per help text */ |
---|
1160 | if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; } |
---|
1161 | if (!m_internalBitDepthC) { m_internalBitDepthC = m_internalBitDepthY; } |
---|
1162 | if (!m_inputBitDepthC) { m_inputBitDepthC = m_inputBitDepthY; } |
---|
1163 | if (!m_outputBitDepthY) { m_outputBitDepthY = m_internalBitDepthY; } |
---|
1164 | if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; } |
---|
1165 | |
---|
1166 | #if !SVC_EXTENSION |
---|
1167 | // TODO:ChromaFmt assumes 4:2:0 below |
---|
1168 | switch (m_conformanceMode) |
---|
1169 | { |
---|
1170 | case 0: |
---|
1171 | { |
---|
1172 | // no conformance or padding |
---|
1173 | m_confLeft = m_confRight = m_confTop = m_confBottom = 0; |
---|
1174 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
1175 | break; |
---|
1176 | } |
---|
1177 | case 1: |
---|
1178 | { |
---|
1179 | // automatic padding to minimum CU size |
---|
1180 | Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); |
---|
1181 | if (m_iSourceWidth % minCuSize) |
---|
1182 | { |
---|
1183 | m_aiPad[0] = m_confRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth; |
---|
1184 | m_iSourceWidth += m_confRight; |
---|
1185 | } |
---|
1186 | if (m_iSourceHeight % minCuSize) |
---|
1187 | { |
---|
1188 | m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; |
---|
1189 | m_iSourceHeight += m_confBottom; |
---|
1190 | } |
---|
1191 | if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0) |
---|
1192 | { |
---|
1193 | fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n"); |
---|
1194 | exit(EXIT_FAILURE); |
---|
1195 | } |
---|
1196 | if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0) |
---|
1197 | { |
---|
1198 | fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n"); |
---|
1199 | exit(EXIT_FAILURE); |
---|
1200 | } |
---|
1201 | break; |
---|
1202 | } |
---|
1203 | case 2: |
---|
1204 | { |
---|
1205 | //padding |
---|
1206 | m_iSourceWidth += m_aiPad[0]; |
---|
1207 | m_iSourceHeight += m_aiPad[1]; |
---|
1208 | m_confRight = m_aiPad[0]; |
---|
1209 | m_confBottom = m_aiPad[1]; |
---|
1210 | break; |
---|
1211 | } |
---|
1212 | case 3: |
---|
1213 | { |
---|
1214 | // conformance |
---|
1215 | if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0)) |
---|
1216 | { |
---|
1217 | fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n"); |
---|
1218 | } |
---|
1219 | if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0)) |
---|
1220 | { |
---|
1221 | fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n"); |
---|
1222 | } |
---|
1223 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
1224 | break; |
---|
1225 | } |
---|
1226 | } |
---|
1227 | |
---|
1228 | // allocate slice-based dQP values |
---|
1229 | m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ]; |
---|
1230 | ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) ); |
---|
1231 | |
---|
1232 | // handling of floating-point QP values |
---|
1233 | // if QP is not integer, sequence is split into two sections having QP and QP+1 |
---|
1234 | m_iQP = (Int)( m_fQP ); |
---|
1235 | if ( m_iQP < m_fQP ) |
---|
1236 | { |
---|
1237 | Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP - m_iQP)*m_framesToBeEncoded + 0.5 ); |
---|
1238 | |
---|
1239 | iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize; |
---|
1240 | for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ ) |
---|
1241 | { |
---|
1242 | m_aidQP[i] = 1; |
---|
1243 | } |
---|
1244 | } |
---|
1245 | |
---|
1246 | // reading external dQP description from file |
---|
1247 | if ( m_pchdQPFile ) |
---|
1248 | { |
---|
1249 | FILE* fpt=fopen( m_pchdQPFile, "r" ); |
---|
1250 | if ( fpt ) |
---|
1251 | { |
---|
1252 | Int iValue; |
---|
1253 | Int iPOC = 0; |
---|
1254 | while ( iPOC < m_framesToBeEncoded ) |
---|
1255 | { |
---|
1256 | if ( fscanf(fpt, "%d", &iValue ) == EOF ) break; |
---|
1257 | m_aidQP[ iPOC ] = iValue; |
---|
1258 | iPOC++; |
---|
1259 | } |
---|
1260 | fclose(fpt); |
---|
1261 | } |
---|
1262 | } |
---|
1263 | m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; |
---|
1264 | #endif |
---|
1265 | if( m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag ) |
---|
1266 | { |
---|
1267 | Char* pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL: strdup(cfg_startOfCodedInterval.c_str()); |
---|
1268 | Char* pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL: strdup(cfg_codedPivotValue.c_str()); |
---|
1269 | Char* pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL: strdup(cfg_targetPivotValue.c_str()); |
---|
1270 | if( m_toneMapModelId == 2 && pcStartOfCodedInterval ) |
---|
1271 | { |
---|
1272 | char *startOfCodedInterval; |
---|
1273 | UInt num = 1u<< m_toneMapTargetBitDepth; |
---|
1274 | m_startOfCodedInterval = new Int[num]; |
---|
1275 | ::memset( m_startOfCodedInterval, 0, sizeof(Int)*num ); |
---|
1276 | startOfCodedInterval = strtok(pcStartOfCodedInterval, " ."); |
---|
1277 | int i = 0; |
---|
1278 | while( startOfCodedInterval && ( i < num ) ) |
---|
1279 | { |
---|
1280 | m_startOfCodedInterval[i] = atoi( startOfCodedInterval ); |
---|
1281 | startOfCodedInterval = strtok(NULL, " ."); |
---|
1282 | i++; |
---|
1283 | } |
---|
1284 | } |
---|
1285 | else |
---|
1286 | { |
---|
1287 | m_startOfCodedInterval = NULL; |
---|
1288 | } |
---|
1289 | if( ( m_toneMapModelId == 3 ) && ( m_numPivots > 0 ) ) |
---|
1290 | { |
---|
1291 | if( pcCodedPivotValue && pcTargetPivotValue ) |
---|
1292 | { |
---|
1293 | char *codedPivotValue; |
---|
1294 | char *targetPivotValue; |
---|
1295 | m_codedPivotValue = new Int[m_numPivots]; |
---|
1296 | m_targetPivotValue = new Int[m_numPivots]; |
---|
1297 | ::memset( m_codedPivotValue, 0, sizeof(Int)*( m_numPivots ) ); |
---|
1298 | ::memset( m_targetPivotValue, 0, sizeof(Int)*( m_numPivots ) ); |
---|
1299 | codedPivotValue = strtok(pcCodedPivotValue, " ."); |
---|
1300 | int i=0; |
---|
1301 | while(codedPivotValue&&i<m_numPivots) |
---|
1302 | { |
---|
1303 | m_codedPivotValue[i] = atoi( codedPivotValue ); |
---|
1304 | codedPivotValue = strtok(NULL, " ."); |
---|
1305 | i++; |
---|
1306 | } |
---|
1307 | i=0; |
---|
1308 | targetPivotValue = strtok(pcTargetPivotValue, " ."); |
---|
1309 | while(targetPivotValue&&i<m_numPivots) |
---|
1310 | { |
---|
1311 | m_targetPivotValue[i]= atoi( targetPivotValue ); |
---|
1312 | targetPivotValue = strtok(NULL, " ."); |
---|
1313 | i++; |
---|
1314 | } |
---|
1315 | } |
---|
1316 | } |
---|
1317 | else |
---|
1318 | { |
---|
1319 | m_codedPivotValue = NULL; |
---|
1320 | m_targetPivotValue = NULL; |
---|
1321 | } |
---|
1322 | } |
---|
1323 | // check validity of input parameters |
---|
1324 | xCheckParameter(); |
---|
1325 | |
---|
1326 | // set global varibles |
---|
1327 | xSetGlobal(); |
---|
1328 | |
---|
1329 | // print-out parameters |
---|
1330 | xPrintParameter(); |
---|
1331 | |
---|
1332 | return true; |
---|
1333 | } |
---|
1334 | // ==================================================================================================================== |
---|
1335 | // Private member functions |
---|
1336 | // ==================================================================================================================== |
---|
1337 | |
---|
1338 | Bool confirmPara(Bool bflag, const Char* message); |
---|
1339 | |
---|
1340 | Void TAppEncCfg::xCheckParameter() |
---|
1341 | { |
---|
1342 | if (!m_decodedPictureHashSEIEnabled) |
---|
1343 | { |
---|
1344 | fprintf(stderr, "******************************************************************\n"); |
---|
1345 | fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n"); |
---|
1346 | fprintf(stderr, "** Automatic verification of decoded pictures by a **\n"); |
---|
1347 | fprintf(stderr, "** decoder requires this option to be enabled. **\n"); |
---|
1348 | fprintf(stderr, "******************************************************************\n"); |
---|
1349 | } |
---|
1350 | if( m_profile==Profile::NONE ) |
---|
1351 | { |
---|
1352 | fprintf(stderr, "***************************************************************************\n"); |
---|
1353 | fprintf(stderr, "** WARNING: For conforming bitstreams a valid Profile value must be set! **\n"); |
---|
1354 | fprintf(stderr, "***************************************************************************\n"); |
---|
1355 | } |
---|
1356 | if( m_level==Level::NONE ) |
---|
1357 | { |
---|
1358 | fprintf(stderr, "***************************************************************************\n"); |
---|
1359 | fprintf(stderr, "** WARNING: For conforming bitstreams a valid Level value must be set! **\n"); |
---|
1360 | fprintf(stderr, "***************************************************************************\n"); |
---|
1361 | } |
---|
1362 | |
---|
1363 | Bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
1364 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
1365 | // check range of parameters |
---|
1366 | xConfirmPara( m_inputBitDepthY < 8, "InputBitDepth must be at least 8" ); |
---|
1367 | xConfirmPara( m_inputBitDepthC < 8, "InputBitDepthC must be at least 8" ); |
---|
1368 | #if !SVC_EXTENSION |
---|
1369 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
---|
1370 | #endif |
---|
1371 | xConfirmPara( m_framesToBeEncoded <= 0, "Total Number Of Frames encoded must be more than 0" ); |
---|
1372 | xConfirmPara( m_iGOPSize < 1 , "GOP Size must be greater or equal to 1" ); |
---|
1373 | xConfirmPara( m_iGOPSize > 1 && m_iGOPSize % 2, "GOP Size must be a multiple of 2, if GOP Size is greater than 1" ); |
---|
1374 | #if !SVC_EXTENSION |
---|
1375 | xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" ); |
---|
1376 | #endif |
---|
1377 | xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2, "Decoding Refresh Type must be equal to 0, 1 or 2" ); |
---|
1378 | #if !SVC_EXTENSION |
---|
1379 | xConfirmPara( m_iQP < -6 * (m_internalBitDepthY - 8) || m_iQP > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
---|
1380 | #endif |
---|
1381 | xConfirmPara( m_loopFilterBetaOffsetDiv2 < -6 || m_loopFilterBetaOffsetDiv2 > 6, "Loop Filter Beta Offset div. 2 exceeds supported range (-6 to 6)"); |
---|
1382 | xConfirmPara( m_loopFilterTcOffsetDiv2 < -6 || m_loopFilterTcOffsetDiv2 > 6, "Loop Filter Tc Offset div. 2 exceeds supported range (-6 to 6)"); |
---|
1383 | xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2, "Fast Search Mode is not supported value (0:Full search 1:Diamond 2:PMVFAST)" ); |
---|
1384 | xConfirmPara( m_iSearchRange < 0 , "Search Range must be more than 0" ); |
---|
1385 | xConfirmPara( m_bipredSearchRange < 0 , "Search Range must be more than 0" ); |
---|
1386 | xConfirmPara( m_iMaxDeltaQP > 7, "Absolute Delta QP exceeds supported range (0 to 7)" ); |
---|
1387 | xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1, "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" ); |
---|
1388 | |
---|
1389 | xConfirmPara( m_cbQpOffset < -12, "Min. Chroma Cb QP Offset is -12" ); |
---|
1390 | xConfirmPara( m_cbQpOffset > 12, "Max. Chroma Cb QP Offset is 12" ); |
---|
1391 | xConfirmPara( m_crQpOffset < -12, "Min. Chroma Cr QP Offset is -12" ); |
---|
1392 | xConfirmPara( m_crQpOffset > 12, "Max. Chroma Cr QP Offset is 12" ); |
---|
1393 | |
---|
1394 | xConfirmPara( m_iQPAdaptationRange <= 0, "QP Adaptation Range must be more than 0" ); |
---|
1395 | #if !SVC_EXTENSION |
---|
1396 | if (m_iDecodingRefreshType == 2) |
---|
1397 | { |
---|
1398 | xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize , "Intra period must be larger than GOP size for periodic IDR pictures"); |
---|
1399 | } |
---|
1400 | #endif |
---|
1401 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
---|
1402 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
---|
1403 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
---|
1404 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
---|
1405 | #if !SVC_EXTENSION |
---|
1406 | xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size"); |
---|
1407 | xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size"); |
---|
1408 | #endif |
---|
1409 | |
---|
1410 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
---|
1411 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
---|
1412 | xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth, "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller."); |
---|
1413 | |
---|
1414 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
---|
1415 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
1416 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
1417 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
---|
1418 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
---|
1419 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
---|
1420 | xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthInter - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" ); |
---|
1421 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
---|
1422 | xConfirmPara( m_uiMaxCUWidth < ( 1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthIntra - 1) ), "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1" ); |
---|
1423 | |
---|
1424 | xConfirmPara( m_maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater."); |
---|
1425 | xConfirmPara( m_maxNumMergeCand > 5, "MaxNumMergeCand must be 5 or smaller."); |
---|
1426 | |
---|
1427 | #if !SVC_EXTENSION |
---|
1428 | #if ADAPTIVE_QP_SELECTION |
---|
1429 | xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0, "AdaptiveQpSelection must be disabled when QP < 0."); |
---|
1430 | xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ), "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0."); |
---|
1431 | #endif |
---|
1432 | #endif |
---|
1433 | |
---|
1434 | if( m_usePCM) |
---|
1435 | { |
---|
1436 | xConfirmPara( m_uiPCMLog2MinSize < 3, "PCMLog2MinSize must be 3 or greater."); |
---|
1437 | xConfirmPara( m_uiPCMLog2MinSize > 5, "PCMLog2MinSize must be 5 or smaller."); |
---|
1438 | xConfirmPara( m_pcmLog2MaxSize > 5, "PCMLog2MaxSize must be 5 or smaller."); |
---|
1439 | xConfirmPara( m_pcmLog2MaxSize < m_uiPCMLog2MinSize, "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize."); |
---|
1440 | } |
---|
1441 | |
---|
1442 | xConfirmPara( m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)" ); |
---|
1443 | if (m_sliceMode!=0) |
---|
1444 | { |
---|
1445 | xConfirmPara( m_sliceArgument < 1 , "SliceArgument should be larger than or equal to 1" ); |
---|
1446 | } |
---|
1447 | xConfirmPara( m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)" ); |
---|
1448 | if (m_sliceSegmentMode!=0) |
---|
1449 | { |
---|
1450 | xConfirmPara( m_sliceSegmentArgument < 1 , "SliceSegmentArgument should be larger than or equal to 1" ); |
---|
1451 | } |
---|
1452 | |
---|
1453 | Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 ); |
---|
1454 | xConfirmPara( tileFlag && m_iWaveFrontSynchro, "Tile and Wavefront can not be applied together"); |
---|
1455 | |
---|
1456 | //TODO:ChromaFmt assumes 4:2:0 below |
---|
1457 | #if !SVC_EXTENSION |
---|
1458 | xConfirmPara( m_iSourceWidth % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); |
---|
1459 | xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); |
---|
1460 | |
---|
1461 | xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling"); |
---|
1462 | xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling"); |
---|
1463 | |
---|
1464 | xConfirmPara( m_confLeft % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
1465 | xConfirmPara( m_confRight % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
1466 | xConfirmPara( m_confTop % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
1467 | xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
1468 | #endif |
---|
1469 | |
---|
1470 | // max CU width and height should be power of 2 |
---|
1471 | UInt ui = m_uiMaxCUWidth; |
---|
1472 | while(ui) |
---|
1473 | { |
---|
1474 | ui >>= 1; |
---|
1475 | if( (ui & 1) == 1) |
---|
1476 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
---|
1477 | } |
---|
1478 | ui = m_uiMaxCUHeight; |
---|
1479 | while(ui) |
---|
1480 | { |
---|
1481 | ui >>= 1; |
---|
1482 | if( (ui & 1) == 1) |
---|
1483 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
---|
1484 | } |
---|
1485 | |
---|
1486 | |
---|
1487 | /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure |
---|
1488 | * This permits the ability to omit a GOP structure specification */ |
---|
1489 | #if SVC_EXTENSION |
---|
1490 | for(UInt layer = 0; layer < MAX_LAYERS; layer++) |
---|
1491 | { |
---|
1492 | Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod; |
---|
1493 | #endif |
---|
1494 | if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) { |
---|
1495 | m_GOPList[0] = GOPEntry(); |
---|
1496 | m_GOPList[0].m_QPFactor = 1; |
---|
1497 | m_GOPList[0].m_betaOffsetDiv2 = 0; |
---|
1498 | m_GOPList[0].m_tcOffsetDiv2 = 0; |
---|
1499 | m_GOPList[0].m_POC = 1; |
---|
1500 | m_GOPList[0].m_numRefPicsActive = 4; |
---|
1501 | } |
---|
1502 | #if SVC_EXTENSION |
---|
1503 | } |
---|
1504 | #endif |
---|
1505 | |
---|
1506 | #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 |
---|
1507 | Bool verifiedGOP=false; |
---|
1508 | #endif |
---|
1509 | Bool errorGOP=false; |
---|
1510 | #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 |
---|
1511 | Int checkGOP=1; |
---|
1512 | Int numRefs = 1; |
---|
1513 | #endif |
---|
1514 | Int refList[MAX_NUM_REF_PICS+1]; |
---|
1515 | refList[0]=0; |
---|
1516 | Bool isOK[MAX_GOP]; |
---|
1517 | for(Int i=0; i<MAX_GOP; i++) |
---|
1518 | { |
---|
1519 | isOK[i]=false; |
---|
1520 | } |
---|
1521 | #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 |
---|
1522 | Int numOK=0; |
---|
1523 | #endif |
---|
1524 | #if !SVC_EXTENSION |
---|
1525 | xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" ); |
---|
1526 | #endif |
---|
1527 | |
---|
1528 | for(Int i=0; i<m_iGOPSize; i++) |
---|
1529 | { |
---|
1530 | if(m_GOPList[i].m_POC==m_iGOPSize) |
---|
1531 | { |
---|
1532 | xConfirmPara( m_GOPList[i].m_temporalId!=0 , "The last frame in each GOP must have temporal ID = 0 " ); |
---|
1533 | } |
---|
1534 | } |
---|
1535 | |
---|
1536 | #if SVC_EXTENSION |
---|
1537 | xConfirmPara( m_numLayers > MAX_LAYERS , "Number of layers in config file is greater than MAX_LAYERS" ); |
---|
1538 | m_numLayers = m_numLayers > MAX_LAYERS ? MAX_LAYERS : m_numLayers; |
---|
1539 | |
---|
1540 | // verify layer configuration parameters |
---|
1541 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1542 | { |
---|
1543 | if(m_acLayerCfg[layer].xCheckParameter()) |
---|
1544 | { |
---|
1545 | printf("\nError: invalid configuration parameter found in layer %d \n", layer); |
---|
1546 | check_failed = true; |
---|
1547 | } |
---|
1548 | } |
---|
1549 | |
---|
1550 | // verify layer configuration parameters |
---|
1551 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1552 | { |
---|
1553 | Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod; |
---|
1554 | #endif |
---|
1555 | if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) ) |
---|
1556 | { |
---|
1557 | for(Int i=0; i<m_iGOPSize; i++) |
---|
1558 | { |
---|
1559 | xConfirmPara( (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 || (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" ); |
---|
1560 | xConfirmPara( (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 || (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" ); |
---|
1561 | } |
---|
1562 | } |
---|
1563 | #if SVC_EXTENSION |
---|
1564 | } |
---|
1565 | #endif |
---|
1566 | #if FINAL_RPL_CHANGE_N0082 |
---|
1567 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1568 | { |
---|
1569 | if (m_acLayerCfg[layer].m_GOPListLayer[0].m_POC<0) |
---|
1570 | { |
---|
1571 | memcpy( m_acLayerCfg[layer].m_GOPListLayer, m_GOPList, sizeof(GOPEntry)*MAX_GOP ); |
---|
1572 | } |
---|
1573 | errorGOP = xconfirmExtraGOP( m_acLayerCfg[layer].m_GOPListLayer ); |
---|
1574 | xConfirmPara(errorGOP,"Invalid GOP structure given"); |
---|
1575 | } |
---|
1576 | #if TEMP_SCALABILITY_FIX |
---|
1577 | if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6 && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7 && |
---|
1578 | m_acLayerCfg[1].m_GOPListLayer[5].m_temporalId == 0 && m_acLayerCfg[1].m_GOPListLayer[7].m_temporalId == 0) |
---|
1579 | #else |
---|
1580 | //tentative for encoder |
---|
1581 | if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6 && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7 ) |
---|
1582 | #endif |
---|
1583 | { |
---|
1584 | //RA, POC5 |
---|
1585 | m_acLayerCfg[1].m_GOPListLayer[5].m_usedByCurrPic[2] = 0; |
---|
1586 | m_acLayerCfg[1].m_GOPListLayer[5].m_refIdc[2] = 0; |
---|
1587 | //RA, POC7 |
---|
1588 | m_acLayerCfg[1].m_GOPListLayer[7].m_usedByCurrPic[2] = 0; |
---|
1589 | m_acLayerCfg[1].m_GOPListLayer[7].m_refIdc[2] = 0; |
---|
1590 | } |
---|
1591 | #endif |
---|
1592 | #if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082 |
---|
1593 | m_extraRPSs=0; |
---|
1594 | //start looping through frames in coding order until we can verify that the GOP structure is correct. |
---|
1595 | while(!verifiedGOP&&!errorGOP) |
---|
1596 | { |
---|
1597 | Int curGOP = (checkGOP-1)%m_iGOPSize; |
---|
1598 | Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPList[curGOP].m_POC; |
---|
1599 | if(m_GOPList[curGOP].m_POC<0) |
---|
1600 | { |
---|
1601 | printf("\nError: found fewer Reference Picture Sets than GOPSize\n"); |
---|
1602 | errorGOP=true; |
---|
1603 | } |
---|
1604 | else |
---|
1605 | { |
---|
1606 | //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP. |
---|
1607 | Bool beforeI = false; |
---|
1608 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
1609 | { |
---|
1610 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
1611 | if(absPOC < 0) |
---|
1612 | { |
---|
1613 | beforeI=true; |
---|
1614 | } |
---|
1615 | else |
---|
1616 | { |
---|
1617 | Bool found=false; |
---|
1618 | for(Int j=0; j<numRefs; j++) |
---|
1619 | { |
---|
1620 | if(refList[j]==absPOC) |
---|
1621 | { |
---|
1622 | found=true; |
---|
1623 | for(Int k=0; k<m_iGOPSize; k++) |
---|
1624 | { |
---|
1625 | if(absPOC%m_iGOPSize == m_GOPList[k].m_POC%m_iGOPSize) |
---|
1626 | { |
---|
1627 | if(m_GOPList[k].m_temporalId==m_GOPList[curGOP].m_temporalId) |
---|
1628 | { |
---|
1629 | m_GOPList[k].m_refPic = true; |
---|
1630 | } |
---|
1631 | m_GOPList[curGOP].m_usedByCurrPic[i]=m_GOPList[k].m_temporalId<=m_GOPList[curGOP].m_temporalId; |
---|
1632 | } |
---|
1633 | } |
---|
1634 | } |
---|
1635 | } |
---|
1636 | if(!found) |
---|
1637 | { |
---|
1638 | printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1); |
---|
1639 | errorGOP=true; |
---|
1640 | } |
---|
1641 | } |
---|
1642 | } |
---|
1643 | if(!beforeI&&!errorGOP) |
---|
1644 | { |
---|
1645 | //all ref frames were present |
---|
1646 | if(!isOK[curGOP]) |
---|
1647 | { |
---|
1648 | numOK++; |
---|
1649 | isOK[curGOP]=true; |
---|
1650 | if(numOK==m_iGOPSize) |
---|
1651 | { |
---|
1652 | verifiedGOP=true; |
---|
1653 | } |
---|
1654 | } |
---|
1655 | } |
---|
1656 | else |
---|
1657 | { |
---|
1658 | //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0) |
---|
1659 | m_GOPList[m_iGOPSize+m_extraRPSs]=m_GOPList[curGOP]; |
---|
1660 | Int newRefs=0; |
---|
1661 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
1662 | { |
---|
1663 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
1664 | if(absPOC>=0) |
---|
1665 | { |
---|
1666 | m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=m_GOPList[curGOP].m_referencePics[i]; |
---|
1667 | m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=m_GOPList[curGOP].m_usedByCurrPic[i]; |
---|
1668 | newRefs++; |
---|
1669 | } |
---|
1670 | } |
---|
1671 | Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive; |
---|
1672 | |
---|
1673 | for(Int offset = -1; offset>-checkGOP; offset--) |
---|
1674 | { |
---|
1675 | //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0. |
---|
1676 | Int offGOP = (checkGOP-1+offset)%m_iGOPSize; |
---|
1677 | Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + m_GOPList[offGOP].m_POC; |
---|
1678 | if(offPOC>=0&&m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId) |
---|
1679 | { |
---|
1680 | Bool newRef=false; |
---|
1681 | for(Int i=0; i<numRefs; i++) |
---|
1682 | { |
---|
1683 | if(refList[i]==offPOC) |
---|
1684 | { |
---|
1685 | newRef=true; |
---|
1686 | } |
---|
1687 | } |
---|
1688 | for(Int i=0; i<newRefs; i++) |
---|
1689 | { |
---|
1690 | if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC) |
---|
1691 | { |
---|
1692 | newRef=false; |
---|
1693 | } |
---|
1694 | } |
---|
1695 | if(newRef) |
---|
1696 | { |
---|
1697 | Int insertPoint=newRefs; |
---|
1698 | //this picture can be added, find appropriate place in list and insert it. |
---|
1699 | if(m_GOPList[offGOP].m_temporalId==m_GOPList[curGOP].m_temporalId) |
---|
1700 | { |
---|
1701 | m_GOPList[offGOP].m_refPic = true; |
---|
1702 | } |
---|
1703 | for(Int j=0; j<newRefs; j++) |
---|
1704 | { |
---|
1705 | if(m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0) |
---|
1706 | { |
---|
1707 | insertPoint = j; |
---|
1708 | break; |
---|
1709 | } |
---|
1710 | } |
---|
1711 | Int prev = offPOC-curPOC; |
---|
1712 | Int prevUsed = m_GOPList[offGOP].m_temporalId<=m_GOPList[curGOP].m_temporalId; |
---|
1713 | for(Int j=insertPoint; j<newRefs+1; j++) |
---|
1714 | { |
---|
1715 | Int newPrev = m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]; |
---|
1716 | Int newUsed = m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]; |
---|
1717 | m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev; |
---|
1718 | m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed; |
---|
1719 | prevUsed=newUsed; |
---|
1720 | prev=newPrev; |
---|
1721 | } |
---|
1722 | newRefs++; |
---|
1723 | } |
---|
1724 | } |
---|
1725 | if(newRefs>=numPrefRefs) |
---|
1726 | { |
---|
1727 | break; |
---|
1728 | } |
---|
1729 | } |
---|
1730 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs; |
---|
1731 | m_GOPList[m_iGOPSize+m_extraRPSs].m_POC = curPOC; |
---|
1732 | if (m_extraRPSs == 0) |
---|
1733 | { |
---|
1734 | m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0; |
---|
1735 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0; |
---|
1736 | } |
---|
1737 | else |
---|
1738 | { |
---|
1739 | Int rIdx = m_iGOPSize + m_extraRPSs - 1; |
---|
1740 | Int refPOC = m_GOPList[rIdx].m_POC; |
---|
1741 | Int refPics = m_GOPList[rIdx].m_numRefPics; |
---|
1742 | Int newIdc=0; |
---|
1743 | for(Int i = 0; i<= refPics; i++) |
---|
1744 | { |
---|
1745 | Int deltaPOC = ((i != refPics)? m_GOPList[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0 |
---|
1746 | Int absPOCref = refPOC+deltaPOC; |
---|
1747 | Int refIdc = 0; |
---|
1748 | for (Int j = 0; j < m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefPics; j++) |
---|
1749 | { |
---|
1750 | if ( (absPOCref - curPOC) == m_GOPList[m_iGOPSize+m_extraRPSs].m_referencePics[j]) |
---|
1751 | { |
---|
1752 | if (m_GOPList[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]) |
---|
1753 | { |
---|
1754 | refIdc = 1; |
---|
1755 | } |
---|
1756 | else |
---|
1757 | { |
---|
1758 | refIdc = 2; |
---|
1759 | } |
---|
1760 | } |
---|
1761 | } |
---|
1762 | m_GOPList[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc; |
---|
1763 | newIdc++; |
---|
1764 | } |
---|
1765 | m_GOPList[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1; |
---|
1766 | m_GOPList[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc; |
---|
1767 | m_GOPList[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize+m_extraRPSs].m_POC; |
---|
1768 | } |
---|
1769 | curGOP=m_iGOPSize+m_extraRPSs; |
---|
1770 | m_extraRPSs++; |
---|
1771 | } |
---|
1772 | numRefs=0; |
---|
1773 | for(Int i = 0; i< m_GOPList[curGOP].m_numRefPics; i++) |
---|
1774 | { |
---|
1775 | Int absPOC = curPOC+m_GOPList[curGOP].m_referencePics[i]; |
---|
1776 | if(absPOC >= 0) |
---|
1777 | { |
---|
1778 | refList[numRefs]=absPOC; |
---|
1779 | numRefs++; |
---|
1780 | } |
---|
1781 | } |
---|
1782 | refList[numRefs]=curPOC; |
---|
1783 | numRefs++; |
---|
1784 | } |
---|
1785 | checkGOP++; |
---|
1786 | } |
---|
1787 | xConfirmPara(errorGOP,"Invalid GOP structure given"); |
---|
1788 | #endif |
---|
1789 | #if EXTERNAL_USEDBYCURR_N0082 |
---|
1790 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1791 | { |
---|
1792 | for (Int i=0; i< m_iGOPSize; i++){ |
---|
1793 | if (m_acLayerCfg[layer].m_GOPListLayer[i].m_UseExtusedByCurrPic == 1 ) |
---|
1794 | { |
---|
1795 | for(Int j=0; j<m_acLayerCfg[layer].m_GOPListLayer[i].m_numRefPics; j++ ) |
---|
1796 | { |
---|
1797 | m_acLayerCfg[layer].m_GOPListLayer[i].m_usedByCurrPic[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j]; |
---|
1798 | m_acLayerCfg[layer].m_GOPListLayer[i].m_refIdc[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j]; |
---|
1799 | } |
---|
1800 | } |
---|
1801 | } |
---|
1802 | } |
---|
1803 | #endif |
---|
1804 | m_maxTempLayer = 1; |
---|
1805 | for(Int i=0; i<m_iGOPSize; i++) |
---|
1806 | { |
---|
1807 | if(m_GOPList[i].m_temporalId >= m_maxTempLayer) |
---|
1808 | { |
---|
1809 | m_maxTempLayer = m_GOPList[i].m_temporalId+1; |
---|
1810 | } |
---|
1811 | xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P', "Slice type must be equal to B or P"); |
---|
1812 | } |
---|
1813 | for(Int i=0; i<MAX_TLAYER; i++) |
---|
1814 | { |
---|
1815 | m_numReorderPics[i] = 0; |
---|
1816 | m_maxDecPicBuffering[i] = 1; |
---|
1817 | } |
---|
1818 | for(Int i=0; i<m_iGOPSize; i++) |
---|
1819 | { |
---|
1820 | if(m_GOPList[i].m_numRefPics+1 > m_maxDecPicBuffering[m_GOPList[i].m_temporalId]) |
---|
1821 | { |
---|
1822 | m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1; |
---|
1823 | } |
---|
1824 | |
---|
1825 | Int highestDecodingNumberWithLowerPOC = 0; |
---|
1826 | for(Int j=0; j<m_iGOPSize; j++) |
---|
1827 | { |
---|
1828 | if(m_GOPList[j].m_POC <= m_GOPList[i].m_POC) |
---|
1829 | { |
---|
1830 | highestDecodingNumberWithLowerPOC = j; |
---|
1831 | } |
---|
1832 | } |
---|
1833 | Int numReorder = 0; |
---|
1834 | for(Int j=0; j<highestDecodingNumberWithLowerPOC; j++) |
---|
1835 | { |
---|
1836 | if(m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId && |
---|
1837 | m_GOPList[j].m_POC > m_GOPList[i].m_POC) |
---|
1838 | { |
---|
1839 | numReorder++; |
---|
1840 | } |
---|
1841 | } |
---|
1842 | if(numReorder > m_numReorderPics[m_GOPList[i].m_temporalId]) |
---|
1843 | { |
---|
1844 | m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder; |
---|
1845 | } |
---|
1846 | } |
---|
1847 | for(Int i=0; i<MAX_TLAYER-1; i++) |
---|
1848 | { |
---|
1849 | // a lower layer can not have higher value of m_numReorderPics than a higher layer |
---|
1850 | if(m_numReorderPics[i+1] < m_numReorderPics[i]) |
---|
1851 | { |
---|
1852 | m_numReorderPics[i+1] = m_numReorderPics[i]; |
---|
1853 | } |
---|
1854 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive |
---|
1855 | if(m_numReorderPics[i] > m_maxDecPicBuffering[i] - 1) |
---|
1856 | { |
---|
1857 | m_maxDecPicBuffering[i] = m_numReorderPics[i] + 1; |
---|
1858 | } |
---|
1859 | // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer |
---|
1860 | if(m_maxDecPicBuffering[i+1] < m_maxDecPicBuffering[i]) |
---|
1861 | { |
---|
1862 | m_maxDecPicBuffering[i+1] = m_maxDecPicBuffering[i]; |
---|
1863 | } |
---|
1864 | } |
---|
1865 | |
---|
1866 | |
---|
1867 | // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ] - 1, inclusive |
---|
1868 | if(m_numReorderPics[MAX_TLAYER-1] > m_maxDecPicBuffering[MAX_TLAYER-1] - 1) |
---|
1869 | { |
---|
1870 | m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1; |
---|
1871 | } |
---|
1872 | |
---|
1873 | #if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers |
---|
1874 | for(UInt layer = 0; layer < MAX_LAYERS; layer++) |
---|
1875 | { |
---|
1876 | Int m_iSourceWidth = m_acLayerCfg[layer].m_iSourceWidth; |
---|
1877 | Int m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight; |
---|
1878 | #endif |
---|
1879 | if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag) |
---|
1880 | { |
---|
1881 | Int PicSizeInSamplesY = m_iSourceWidth * m_iSourceHeight; |
---|
1882 | if(tileFlag) |
---|
1883 | { |
---|
1884 | Int maxTileWidth = 0; |
---|
1885 | Int maxTileHeight = 0; |
---|
1886 | Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth; |
---|
1887 | Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight; |
---|
1888 | if(m_iUniformSpacingIdr) |
---|
1889 | { |
---|
1890 | maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1)); |
---|
1891 | maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1)); |
---|
1892 | // if only the last tile-row is one treeblock higher than the others |
---|
1893 | // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others |
---|
1894 | if(!((heightInCU-1)%(m_iNumRowsMinus1+1))) |
---|
1895 | { |
---|
1896 | maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight); |
---|
1897 | } |
---|
1898 | // if only the last tile-column is one treeblock wider than the others |
---|
1899 | // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others |
---|
1900 | if(!((widthInCU-1)%(m_iNumColumnsMinus1+1))) |
---|
1901 | { |
---|
1902 | maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth); |
---|
1903 | } |
---|
1904 | } |
---|
1905 | else // not uniform spacing |
---|
1906 | { |
---|
1907 | if(m_iNumColumnsMinus1<1) |
---|
1908 | { |
---|
1909 | maxTileWidth = m_iSourceWidth; |
---|
1910 | } |
---|
1911 | else |
---|
1912 | { |
---|
1913 | Int accColumnWidth = 0; |
---|
1914 | for(Int col=0; col<(m_iNumColumnsMinus1); col++) |
---|
1915 | { |
---|
1916 | maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth; |
---|
1917 | accColumnWidth += m_pColumnWidth[col]; |
---|
1918 | } |
---|
1919 | maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth; |
---|
1920 | } |
---|
1921 | if(m_iNumRowsMinus1<1) |
---|
1922 | { |
---|
1923 | maxTileHeight = m_iSourceHeight; |
---|
1924 | } |
---|
1925 | else |
---|
1926 | { |
---|
1927 | Int accRowHeight = 0; |
---|
1928 | for(Int row=0; row<(m_iNumRowsMinus1); row++) |
---|
1929 | { |
---|
1930 | maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight; |
---|
1931 | accRowHeight += m_pRowHeight[row]; |
---|
1932 | } |
---|
1933 | maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight; |
---|
1934 | } |
---|
1935 | } |
---|
1936 | Int maxSizeInSamplesY = maxTileWidth*maxTileHeight; |
---|
1937 | m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/maxSizeInSamplesY-4; |
---|
1938 | } |
---|
1939 | else if(m_iWaveFrontSynchro) |
---|
1940 | { |
---|
1941 | m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4; |
---|
1942 | } |
---|
1943 | else if(m_sliceMode == 1) |
---|
1944 | { |
---|
1945 | m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/(m_sliceArgument*m_uiMaxCUWidth*m_uiMaxCUHeight)-4; |
---|
1946 | } |
---|
1947 | else |
---|
1948 | { |
---|
1949 | m_minSpatialSegmentationIdc = 0; |
---|
1950 | } |
---|
1951 | } |
---|
1952 | #if SVC_EXTENSION |
---|
1953 | } |
---|
1954 | #endif |
---|
1955 | xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" ); |
---|
1956 | #if !SVC_EXTENSION |
---|
1957 | xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" ); |
---|
1958 | xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" ); |
---|
1959 | #endif |
---|
1960 | |
---|
1961 | xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n"); |
---|
1962 | |
---|
1963 | if (m_toneMappingInfoSEIEnabled) |
---|
1964 | { |
---|
1965 | xConfirmPara( m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14 , "SEIToneMapCodedDataBitDepth must be in rage 8 to 14"); |
---|
1966 | xConfirmPara( m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255) , "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255"); |
---|
1967 | xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4"); |
---|
1968 | xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0"); |
---|
1969 | xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100"); |
---|
1970 | xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue"); |
---|
1971 | xConfirmPara( m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue, "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue"); |
---|
1972 | } |
---|
1973 | |
---|
1974 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
1975 | #if RC_SHVC_HARMONIZATION |
---|
1976 | for ( Int layer=0; layer<m_numLayers; layer++ ) |
---|
1977 | { |
---|
1978 | if ( m_acLayerCfg[layer].m_RCEnableRateControl ) |
---|
1979 | { |
---|
1980 | if ( m_acLayerCfg[layer].m_RCForceIntraQP ) |
---|
1981 | { |
---|
1982 | if ( m_acLayerCfg[layer].m_RCInitialQP == 0 ) |
---|
1983 | { |
---|
1984 | printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" ); |
---|
1985 | m_acLayerCfg[layer].m_RCForceIntraQP = false; |
---|
1986 | } |
---|
1987 | } |
---|
1988 | } |
---|
1989 | xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" ); |
---|
1990 | } |
---|
1991 | #else |
---|
1992 | if ( m_RCEnableRateControl ) |
---|
1993 | { |
---|
1994 | if ( m_RCForceIntraQP ) |
---|
1995 | { |
---|
1996 | if ( m_RCInitialQP == 0 ) |
---|
1997 | { |
---|
1998 | printf( "\nInitial QP for rate control is not specified. Reset not to use force intra QP!" ); |
---|
1999 | m_RCForceIntraQP = false; |
---|
2000 | } |
---|
2001 | } |
---|
2002 | xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" ); |
---|
2003 | } |
---|
2004 | #endif |
---|
2005 | #else |
---|
2006 | if(m_enableRateCtrl) |
---|
2007 | { |
---|
2008 | Int numLCUInWidth = (m_iSourceWidth / m_uiMaxCUWidth) + (( m_iSourceWidth % m_uiMaxCUWidth ) ? 1 : 0); |
---|
2009 | Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight)+ (( m_iSourceHeight % m_uiMaxCUHeight) ? 1 : 0); |
---|
2010 | Int numLCUInPic = numLCUInWidth * numLCUInHeight; |
---|
2011 | |
---|
2012 | xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" ); |
---|
2013 | |
---|
2014 | m_iMaxDeltaQP = MAX_DELTA_QP; |
---|
2015 | m_iMaxCuDQPDepth = MAX_CUDQP_DEPTH; |
---|
2016 | } |
---|
2017 | #endif |
---|
2018 | |
---|
2019 | xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0"); |
---|
2020 | |
---|
2021 | xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2"); |
---|
2022 | if (m_framePackingSEIEnabled) |
---|
2023 | { |
---|
2024 | xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5 , "SEIFramePackingType must be in rage 3 to 5"); |
---|
2025 | } |
---|
2026 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2027 | #if M0457_PREDICTION_INDICATIONS |
---|
2028 | xConfirmPara( (m_acLayerCfg[0].m_numSamplePredRefLayers != 0) && (m_acLayerCfg[0].m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" ); |
---|
2029 | // NOTE: m_numSamplePredRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
2030 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
2031 | { |
---|
2032 | xConfirmPara(m_acLayerCfg[layer].m_numSamplePredRefLayers > layer, "Cannot reference more layers than before current layer"); |
---|
2033 | for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++) |
---|
2034 | { |
---|
2035 | xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] > layer, "Cannot reference higher layers"); |
---|
2036 | xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] == layer, "Cannot reference the current layer itself"); |
---|
2037 | } |
---|
2038 | } |
---|
2039 | xConfirmPara( (m_acLayerCfg[0].m_numMotionPredRefLayers != 0) && (m_acLayerCfg[0].m_numMotionPredRefLayers != -1), "Layer 0 cannot have any reference layers" ); |
---|
2040 | // NOTE: m_numMotionPredRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
2041 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
2042 | { |
---|
2043 | xConfirmPara(m_acLayerCfg[layer].m_numMotionPredRefLayers > layer, "Cannot reference more layers than before current layer"); |
---|
2044 | for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++) |
---|
2045 | { |
---|
2046 | xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] > layer, "Cannot reference higher layers"); |
---|
2047 | xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] == layer, "Cannot reference the current layer itself"); |
---|
2048 | } |
---|
2049 | } |
---|
2050 | #else |
---|
2051 | xConfirmPara( (m_acLayerCfg[0].m_numDirectRefLayers != 0) && (m_acLayerCfg[0].m_numDirectRefLayers != -1), "Layer 0 cannot have any reference layers" ); |
---|
2052 | // NOTE: m_numDirectRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
2053 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
2054 | { |
---|
2055 | xConfirmPara(m_acLayerCfg[layer].m_numDirectRefLayers > layer, "Cannot reference more layers than before current layer"); |
---|
2056 | for(Int i = 0; i < m_acLayerCfg[layer].m_numDirectRefLayers; i++) |
---|
2057 | { |
---|
2058 | xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] > layer, "Cannot reference higher layers"); |
---|
2059 | xConfirmPara(m_acLayerCfg[layer].m_refLayerIds[i] == layer, "Cannot reference the current layer itself"); |
---|
2060 | } |
---|
2061 | } |
---|
2062 | #endif |
---|
2063 | xConfirmPara( (m_acLayerCfg[0].m_numActiveRefLayers != 0) && (m_acLayerCfg[0].m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" ); |
---|
2064 | // NOTE: m_numActiveRefLayers (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference |
---|
2065 | for(Int layer = 1; layer < MAX_LAYERS; layer++) |
---|
2066 | { |
---|
2067 | #if M0457_PREDICTION_INDICATIONS |
---|
2068 | Bool predEnabledFlag[MAX_LAYERS]; |
---|
2069 | for (Int refLayer = 0; refLayer < layer; refLayer++) |
---|
2070 | { |
---|
2071 | predEnabledFlag[refLayer] = false; |
---|
2072 | } |
---|
2073 | for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++) |
---|
2074 | { |
---|
2075 | predEnabledFlag[m_acLayerCfg[layer].m_samplePredRefLayerIds[i]] = true; |
---|
2076 | } |
---|
2077 | for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++) |
---|
2078 | { |
---|
2079 | predEnabledFlag[m_acLayerCfg[layer].m_motionPredRefLayerIds[i]] = true; |
---|
2080 | } |
---|
2081 | Int numDirectRefLayers = 0; |
---|
2082 | for (Int refLayer = 0; refLayer < layer; refLayer++) |
---|
2083 | { |
---|
2084 | if (predEnabledFlag[refLayer] == true) numDirectRefLayers++; |
---|
2085 | } |
---|
2086 | xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers"); |
---|
2087 | for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++) |
---|
2088 | { |
---|
2089 | xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] >= numDirectRefLayers, "Cannot reference higher layers"); |
---|
2090 | } |
---|
2091 | #else |
---|
2092 | xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers"); |
---|
2093 | for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++) |
---|
2094 | { |
---|
2095 | xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] >= m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference higher layers"); |
---|
2096 | } |
---|
2097 | #endif |
---|
2098 | } |
---|
2099 | #endif |
---|
2100 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2101 | if (m_adaptiveResolutionChange > 0) |
---|
2102 | { |
---|
2103 | xConfirmPara(m_numLayers != 2, "Adaptive resolution change works with 2 layers only"); |
---|
2104 | xConfirmPara(m_acLayerCfg[1].m_iIntraPeriod == 0 || (m_adaptiveResolutionChange % m_acLayerCfg[1].m_iIntraPeriod) != 0, "Adaptive resolution change must happen at enhancement layer RAP picture"); |
---|
2105 | } |
---|
2106 | #endif |
---|
2107 | #if N0120_MAX_TID_REF_CFG |
---|
2108 | for (UInt layer=0; layer < MAX_LAYERS-1; layer++) |
---|
2109 | { |
---|
2110 | xConfirmPara(m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 < 0 || m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7"); |
---|
2111 | } |
---|
2112 | #endif |
---|
2113 | #undef xConfirmPara |
---|
2114 | if (check_failed) |
---|
2115 | { |
---|
2116 | exit(EXIT_FAILURE); |
---|
2117 | } |
---|
2118 | } |
---|
2119 | |
---|
2120 | /** \todo use of global variables should be removed later |
---|
2121 | */ |
---|
2122 | Void TAppEncCfg::xSetGlobal() |
---|
2123 | { |
---|
2124 | // set max CU width & height |
---|
2125 | g_uiMaxCUWidth = m_uiMaxCUWidth; |
---|
2126 | g_uiMaxCUHeight = m_uiMaxCUHeight; |
---|
2127 | |
---|
2128 | // compute actual CU depth with respect to config depth and max transform size |
---|
2129 | g_uiAddCUDepth = 0; |
---|
2130 | while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth ) ) ) g_uiAddCUDepth++; |
---|
2131 | |
---|
2132 | m_uiMaxCUDepth += g_uiAddCUDepth; |
---|
2133 | g_uiAddCUDepth++; |
---|
2134 | g_uiMaxCUDepth = m_uiMaxCUDepth; |
---|
2135 | |
---|
2136 | // set internal bit-depth and constants |
---|
2137 | g_bitDepthY = m_internalBitDepthY; |
---|
2138 | g_bitDepthC = m_internalBitDepthC; |
---|
2139 | |
---|
2140 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY; |
---|
2141 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC; |
---|
2142 | } |
---|
2143 | |
---|
2144 | Void TAppEncCfg::xPrintParameter() |
---|
2145 | { |
---|
2146 | printf("\n"); |
---|
2147 | #if SVC_EXTENSION |
---|
2148 | printf("Total number of layers : %d\n", m_numLayers ); |
---|
2149 | printf("Multiview : %d\n", m_scalabilityMask[0] ); |
---|
2150 | printf("Scalable : %d\n", m_scalabilityMask[1] ); |
---|
2151 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2152 | printf("Adaptive Resolution Change : %d\n", m_adaptiveResolutionChange ); |
---|
2153 | #endif |
---|
2154 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2155 | { |
---|
2156 | printf("=== Layer %d settings === \n", layer); |
---|
2157 | #if AVC_SYNTAX |
---|
2158 | m_acLayerCfg[layer].xPrintParameter( layer ); |
---|
2159 | #else |
---|
2160 | m_acLayerCfg[layer].xPrintParameter(); |
---|
2161 | #endif |
---|
2162 | printf("\n"); |
---|
2163 | } |
---|
2164 | printf("=== Common configuration settings === \n"); |
---|
2165 | printf("Bitstream File : %s\n", m_pBitstreamFile ); |
---|
2166 | #else |
---|
2167 | printf("Input File : %s\n", m_pchInputFile ); |
---|
2168 | printf("Bitstream File : %s\n", m_pchBitstreamFile ); |
---|
2169 | printf("Reconstruction File : %s\n", m_pchReconFile ); |
---|
2170 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate ); |
---|
2171 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
---|
2172 | #endif |
---|
2173 | printf("Frame index : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded ); |
---|
2174 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
---|
2175 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
2176 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
---|
2177 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
---|
2178 | printf("Min PCM size : %d\n", 1 << m_uiPCMLog2MinSize); |
---|
2179 | printf("Motion search range : %d\n", m_iSearchRange ); |
---|
2180 | #if !SVC_EXTENSION |
---|
2181 | printf("Intra period : %d\n", m_iIntraPeriod ); |
---|
2182 | #endif |
---|
2183 | printf("Decoding refresh type : %d\n", m_iDecodingRefreshType ); |
---|
2184 | #if !SVC_EXTENSION |
---|
2185 | printf("QP : %5.2f\n", m_fQP ); |
---|
2186 | #endif |
---|
2187 | printf("Max dQP signaling depth : %d\n", m_iMaxCuDQPDepth); |
---|
2188 | |
---|
2189 | printf("Cb QP Offset : %d\n", m_cbQpOffset ); |
---|
2190 | printf("Cr QP Offset : %d\n", m_crQpOffset); |
---|
2191 | |
---|
2192 | printf("QP adaptation : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) ); |
---|
2193 | printf("GOP size : %d\n", m_iGOPSize ); |
---|
2194 | printf("Internal bit depth : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC ); |
---|
2195 | printf("PCM sample bit depth : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma ); |
---|
2196 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
2197 | #if !RC_SHVC_HARMONIZATION |
---|
2198 | printf("RateControl : %d\n", m_RCEnableRateControl ); |
---|
2199 | if(m_RCEnableRateControl) |
---|
2200 | { |
---|
2201 | printf("TargetBitrate : %d\n", m_RCTargetBitrate ); |
---|
2202 | printf("KeepHierarchicalBit : %d\n", m_RCKeepHierarchicalBit ); |
---|
2203 | printf("LCULevelRC : %d\n", m_RCLCULevelRC ); |
---|
2204 | printf("UseLCUSeparateModel : %d\n", m_RCUseLCUSeparateModel ); |
---|
2205 | printf("InitialQP : %d\n", m_RCInitialQP ); |
---|
2206 | printf("ForceIntraQP : %d\n", m_RCForceIntraQP ); |
---|
2207 | } |
---|
2208 | #endif |
---|
2209 | #else |
---|
2210 | printf("RateControl : %d\n", m_enableRateCtrl); |
---|
2211 | if(m_enableRateCtrl) |
---|
2212 | { |
---|
2213 | printf("TargetBitrate : %d\n", m_targetBitrate); |
---|
2214 | printf("NumLCUInUnit : %d\n", m_numLCUInUnit); |
---|
2215 | } |
---|
2216 | #endif |
---|
2217 | printf("Max Num Merge Candidates : %d\n", m_maxNumMergeCand); |
---|
2218 | printf("\n"); |
---|
2219 | |
---|
2220 | printf("TOOL CFG: "); |
---|
2221 | printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC); |
---|
2222 | printf("HAD:%d ", m_bUseHADME ); |
---|
2223 | printf("SRD:%d ", m_bUseSBACRD ); |
---|
2224 | printf("RDQ:%d ", m_useRDOQ ); |
---|
2225 | printf("RDQTS:%d ", m_useRDOQTS ); |
---|
2226 | printf("RDpenalty:%d ", m_rdPenalty ); |
---|
2227 | printf("SQP:%d ", m_uiDeltaQpRD ); |
---|
2228 | printf("ASR:%d ", m_bUseASR ); |
---|
2229 | printf("FEN:%d ", m_bUseFastEnc ); |
---|
2230 | printf("ECU:%d ", m_bUseEarlyCU ); |
---|
2231 | printf("FDM:%d ", m_useFastDecisionForMerge ); |
---|
2232 | printf("CFM:%d ", m_bUseCbfFastMode ); |
---|
2233 | printf("ESD:%d ", m_useEarlySkipDetection ); |
---|
2234 | #if FAST_INTRA_SHVC |
---|
2235 | printf("FIS:%d ", m_useFastIntraScalable ); |
---|
2236 | #endif |
---|
2237 | printf("RQT:%d ", 1 ); |
---|
2238 | printf("TransformSkip:%d ", m_useTransformSkip ); |
---|
2239 | printf("TransformSkipFast:%d ", m_useTransformSkipFast ); |
---|
2240 | printf("Slice: M=%d ", m_sliceMode); |
---|
2241 | if (m_sliceMode!=0) |
---|
2242 | { |
---|
2243 | printf("A=%d ", m_sliceArgument); |
---|
2244 | } |
---|
2245 | printf("SliceSegment: M=%d ",m_sliceSegmentMode); |
---|
2246 | if (m_sliceSegmentMode!=0) |
---|
2247 | { |
---|
2248 | printf("A=%d ", m_sliceSegmentArgument); |
---|
2249 | } |
---|
2250 | printf("CIP:%d ", m_bUseConstrainedIntraPred); |
---|
2251 | printf("SAO:%d ", (m_bUseSAO)?(1):(0)); |
---|
2252 | printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0); |
---|
2253 | printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0)); |
---|
2254 | |
---|
2255 | printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 ); |
---|
2256 | printf("WPP:%d ", (Int)m_useWeightedPred); |
---|
2257 | printf("WPB:%d ", (Int)m_useWeightedBiPred); |
---|
2258 | printf("PME:%d ", m_log2ParallelMergeLevel); |
---|
2259 | #if !SVC_EXTENSION |
---|
2260 | printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d", |
---|
2261 | m_iWaveFrontSynchro, m_iWaveFrontSubstreams); |
---|
2262 | #endif |
---|
2263 | printf(" ScalingList:%d ", m_useScalingListId ); |
---|
2264 | printf("TMVPMode:%d ", m_TMVPModeId ); |
---|
2265 | #if ADAPTIVE_QP_SELECTION |
---|
2266 | printf("AQpS:%d", m_bUseAdaptQpSelect ); |
---|
2267 | #endif |
---|
2268 | |
---|
2269 | printf(" SignBitHidingFlag:%d ", m_signHideFlag); |
---|
2270 | #if SVC_EXTENSION |
---|
2271 | printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 ); |
---|
2272 | #if AVC_BASE |
---|
2273 | printf("AvcBase:%d ", m_avcBaseLayerFlag ? 1 : 0); |
---|
2274 | #else |
---|
2275 | printf("AvcBase:%d ", 0); |
---|
2276 | #endif |
---|
2277 | printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled); |
---|
2278 | printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV); |
---|
2279 | printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE); |
---|
2280 | printf("REF_IDX_MFM: %d ", REF_IDX_MFM); |
---|
2281 | #else |
---|
2282 | printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 ); |
---|
2283 | #endif |
---|
2284 | printf("\n\n"); |
---|
2285 | |
---|
2286 | fflush(stdout); |
---|
2287 | } |
---|
2288 | |
---|
2289 | Bool confirmPara(Bool bflag, const Char* message) |
---|
2290 | { |
---|
2291 | if (!bflag) |
---|
2292 | return false; |
---|
2293 | |
---|
2294 | printf("Error: %s\n",message); |
---|
2295 | return true; |
---|
2296 | } |
---|
2297 | |
---|
2298 | #if SCALED_REF_LAYER_OFFSETS |
---|
2299 | Void TAppEncCfg::cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString) |
---|
2300 | { |
---|
2301 | Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str()); |
---|
2302 | if( numEntries > 0 ) |
---|
2303 | { |
---|
2304 | Char *arrayEntry; |
---|
2305 | Int i = 0; |
---|
2306 | *arr = new Int[numEntries]; |
---|
2307 | |
---|
2308 | arrayEntry = strtok( tempChar, " ,"); |
---|
2309 | while(arrayEntry != NULL) |
---|
2310 | { |
---|
2311 | if( i >= numEntries ) |
---|
2312 | { |
---|
2313 | printf( "%s: The number of entries specified is larger than the allowed number.\n", logString ); |
---|
2314 | exit( EXIT_FAILURE ); |
---|
2315 | } |
---|
2316 | *( *arr + i ) = atoi( arrayEntry ); |
---|
2317 | arrayEntry = strtok(NULL, " ,"); |
---|
2318 | i++; |
---|
2319 | } |
---|
2320 | if( i < numEntries ) |
---|
2321 | { |
---|
2322 | printf( "%s: Some entries are not specified.\n", logString ); |
---|
2323 | exit( EXIT_FAILURE ); |
---|
2324 | } |
---|
2325 | } |
---|
2326 | else |
---|
2327 | { |
---|
2328 | *arr = NULL; |
---|
2329 | } |
---|
2330 | } |
---|
2331 | #endif |
---|
2332 | |
---|
2333 | #if FINAL_RPL_CHANGE_N0082 |
---|
2334 | Bool TAppEncCfg::xconfirmExtraGOP (GOPEntry * ge) |
---|
2335 | { |
---|
2336 | Bool verifiedGOP=false; |
---|
2337 | Bool errorGOP=false; |
---|
2338 | Int checkGOP=1; |
---|
2339 | Int numRefs = 1; |
---|
2340 | Int refList[MAX_NUM_REF_PICS+1]; |
---|
2341 | refList[0]=0; |
---|
2342 | Bool isOK[MAX_GOP]; |
---|
2343 | for(Int i=0; i<MAX_GOP; i++) |
---|
2344 | { |
---|
2345 | isOK[i]=false; |
---|
2346 | } |
---|
2347 | Int numOK=0; |
---|
2348 | |
---|
2349 | m_extraRPSs=0; |
---|
2350 | //start looping through frames in coding order until we can verify that the GOP structure is correct. |
---|
2351 | while(!verifiedGOP&&!errorGOP) |
---|
2352 | { |
---|
2353 | Int curGOP = (checkGOP-1)%m_iGOPSize; |
---|
2354 | Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + ge[curGOP].m_POC; |
---|
2355 | if(ge[curGOP].m_POC<0) |
---|
2356 | { |
---|
2357 | printf("\nError: found fewer Reference Picture Sets than GOPSize\n"); |
---|
2358 | errorGOP=true; |
---|
2359 | } |
---|
2360 | else |
---|
2361 | { |
---|
2362 | //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP. |
---|
2363 | Bool beforeI = false; |
---|
2364 | for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) |
---|
2365 | { |
---|
2366 | Int absPOC = curPOC+ge[curGOP].m_referencePics[i]; |
---|
2367 | if(absPOC < 0) |
---|
2368 | { |
---|
2369 | beforeI=true; |
---|
2370 | } |
---|
2371 | else |
---|
2372 | { |
---|
2373 | Bool found=false; |
---|
2374 | for(Int j=0; j<numRefs; j++) |
---|
2375 | { |
---|
2376 | if(refList[j]==absPOC) |
---|
2377 | { |
---|
2378 | found=true; |
---|
2379 | for(Int k=0; k<m_iGOPSize; k++) |
---|
2380 | { |
---|
2381 | if(absPOC%m_iGOPSize == ge[k].m_POC%m_iGOPSize) |
---|
2382 | { |
---|
2383 | if(ge[k].m_temporalId==ge[curGOP].m_temporalId) |
---|
2384 | { |
---|
2385 | ge[k].m_refPic = true; |
---|
2386 | } |
---|
2387 | ge[curGOP].m_usedByCurrPic[i]=ge[k].m_temporalId<=ge[curGOP].m_temporalId; |
---|
2388 | } |
---|
2389 | } |
---|
2390 | } |
---|
2391 | } |
---|
2392 | if(!found) |
---|
2393 | { |
---|
2394 | printf("\nError: ref pic %d is not available for GOP frame %d\n",ge[curGOP].m_referencePics[i],curGOP+1); |
---|
2395 | errorGOP=true; |
---|
2396 | } |
---|
2397 | } |
---|
2398 | } |
---|
2399 | if(!beforeI&&!errorGOP) |
---|
2400 | { |
---|
2401 | //all ref frames were present |
---|
2402 | if(!isOK[curGOP]) |
---|
2403 | { |
---|
2404 | numOK++; |
---|
2405 | isOK[curGOP]=true; |
---|
2406 | if(numOK==m_iGOPSize) |
---|
2407 | { |
---|
2408 | verifiedGOP=true; |
---|
2409 | } |
---|
2410 | } |
---|
2411 | } |
---|
2412 | else |
---|
2413 | { |
---|
2414 | //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0) |
---|
2415 | ge[m_iGOPSize+m_extraRPSs]=ge[curGOP]; |
---|
2416 | Int newRefs=0; |
---|
2417 | for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) |
---|
2418 | { |
---|
2419 | Int absPOC = curPOC+ge[curGOP].m_referencePics[i]; |
---|
2420 | if(absPOC>=0) |
---|
2421 | { |
---|
2422 | ge[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=ge[curGOP].m_referencePics[i]; |
---|
2423 | ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=ge[curGOP].m_usedByCurrPic[i]; |
---|
2424 | newRefs++; |
---|
2425 | } |
---|
2426 | } |
---|
2427 | Int numPrefRefs = ge[curGOP].m_numRefPicsActive; |
---|
2428 | |
---|
2429 | for(Int offset = -1; offset>-checkGOP; offset--) |
---|
2430 | { |
---|
2431 | //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0. |
---|
2432 | Int offGOP = (checkGOP-1+offset)%m_iGOPSize; |
---|
2433 | Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + ge[offGOP].m_POC; |
---|
2434 | if(offPOC>=0&&ge[offGOP].m_temporalId<=ge[curGOP].m_temporalId) |
---|
2435 | { |
---|
2436 | Bool newRef=false; |
---|
2437 | for(Int i=0; i<numRefs; i++) |
---|
2438 | { |
---|
2439 | if(refList[i]==offPOC) |
---|
2440 | { |
---|
2441 | newRef=true; |
---|
2442 | } |
---|
2443 | } |
---|
2444 | for(Int i=0; i<newRefs; i++) |
---|
2445 | { |
---|
2446 | if(ge[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC) |
---|
2447 | { |
---|
2448 | newRef=false; |
---|
2449 | } |
---|
2450 | } |
---|
2451 | if(newRef) |
---|
2452 | { |
---|
2453 | Int insertPoint=newRefs; |
---|
2454 | //this picture can be added, find appropriate place in list and insert it. |
---|
2455 | if(ge[offGOP].m_temporalId==ge[curGOP].m_temporalId) |
---|
2456 | { |
---|
2457 | ge[offGOP].m_refPic = true; |
---|
2458 | } |
---|
2459 | for(Int j=0; j<newRefs; j++) |
---|
2460 | { |
---|
2461 | if(ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0) |
---|
2462 | { |
---|
2463 | insertPoint = j; |
---|
2464 | break; |
---|
2465 | } |
---|
2466 | } |
---|
2467 | Int prev = offPOC-curPOC; |
---|
2468 | Int prevUsed = ge[offGOP].m_temporalId<=ge[curGOP].m_temporalId; |
---|
2469 | for(Int j=insertPoint; j<newRefs+1; j++) |
---|
2470 | { |
---|
2471 | Int newPrev = ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]; |
---|
2472 | Int newUsed = ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]; |
---|
2473 | ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev; |
---|
2474 | ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed; |
---|
2475 | prevUsed=newUsed; |
---|
2476 | prev=newPrev; |
---|
2477 | } |
---|
2478 | newRefs++; |
---|
2479 | } |
---|
2480 | } |
---|
2481 | if(newRefs>=numPrefRefs) |
---|
2482 | { |
---|
2483 | break; |
---|
2484 | } |
---|
2485 | } |
---|
2486 | ge[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs; |
---|
2487 | ge[m_iGOPSize+m_extraRPSs].m_POC = curPOC; |
---|
2488 | if (m_extraRPSs == 0) |
---|
2489 | { |
---|
2490 | ge[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0; |
---|
2491 | ge[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0; |
---|
2492 | } |
---|
2493 | else |
---|
2494 | { |
---|
2495 | Int rIdx = m_iGOPSize + m_extraRPSs - 1; |
---|
2496 | Int refPOC = ge[rIdx].m_POC; |
---|
2497 | Int refPics = ge[rIdx].m_numRefPics; |
---|
2498 | Int newIdc=0; |
---|
2499 | for(Int i = 0; i<= refPics; i++) |
---|
2500 | { |
---|
2501 | Int deltaPOC = ((i != refPics)? ge[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0 |
---|
2502 | Int absPOCref = refPOC+deltaPOC; |
---|
2503 | Int refIdc = 0; |
---|
2504 | for (Int j = 0; j < ge[m_iGOPSize+m_extraRPSs].m_numRefPics; j++) |
---|
2505 | { |
---|
2506 | if ( (absPOCref - curPOC) == ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]) |
---|
2507 | { |
---|
2508 | if (ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]) |
---|
2509 | { |
---|
2510 | refIdc = 1; |
---|
2511 | } |
---|
2512 | else |
---|
2513 | { |
---|
2514 | refIdc = 2; |
---|
2515 | } |
---|
2516 | } |
---|
2517 | } |
---|
2518 | ge[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc; |
---|
2519 | newIdc++; |
---|
2520 | } |
---|
2521 | ge[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1; |
---|
2522 | ge[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc; |
---|
2523 | ge[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - ge[m_iGOPSize+m_extraRPSs].m_POC; |
---|
2524 | } |
---|
2525 | curGOP=m_iGOPSize+m_extraRPSs; |
---|
2526 | m_extraRPSs++; |
---|
2527 | } |
---|
2528 | numRefs=0; |
---|
2529 | for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) |
---|
2530 | { |
---|
2531 | Int absPOC = curPOC+ge[curGOP].m_referencePics[i]; |
---|
2532 | if(absPOC >= 0) |
---|
2533 | { |
---|
2534 | refList[numRefs]=absPOC; |
---|
2535 | numRefs++; |
---|
2536 | } |
---|
2537 | } |
---|
2538 | refList[numRefs]=curPOC; |
---|
2539 | numRefs++; |
---|
2540 | } |
---|
2541 | checkGOP++; |
---|
2542 | } |
---|
2543 | |
---|
2544 | return errorGOP; //update |
---|
2545 | } |
---|
2546 | #endif |
---|
2547 | //! \} |
---|