1 | /** \file TAppEncLayerCfg.cpp |
---|
2 | \brief Handle encoder configuration parameters |
---|
3 | */ |
---|
4 | |
---|
5 | #include <stdlib.h> |
---|
6 | #include <cassert> |
---|
7 | #include <cstring> |
---|
8 | #include <string> |
---|
9 | #include "TLibCommon/TComRom.h" |
---|
10 | #include "TAppEncCfg.h" |
---|
11 | #include "TAppEncLayerCfg.h" |
---|
12 | #include "TAppCommon/program_options_lite.h" |
---|
13 | |
---|
14 | #ifdef WIN32 |
---|
15 | #define strdup _strdup |
---|
16 | #endif |
---|
17 | |
---|
18 | using namespace std; |
---|
19 | namespace po = df::program_options_lite; |
---|
20 | |
---|
21 | //! \ingroup TAppEncoder |
---|
22 | //! \{ |
---|
23 | |
---|
24 | |
---|
25 | #if AUXILIARY_PICTURES |
---|
26 | static inline ChromaFormat numberToChromaFormat(const Int val) |
---|
27 | { |
---|
28 | switch (val) |
---|
29 | { |
---|
30 | case 400: return CHROMA_400; break; |
---|
31 | case 420: return CHROMA_420; break; |
---|
32 | case 422: return CHROMA_422; break; |
---|
33 | case 444: return CHROMA_444; break; |
---|
34 | default: return NUM_CHROMA_FORMAT; |
---|
35 | } |
---|
36 | } |
---|
37 | #endif |
---|
38 | |
---|
39 | // ==================================================================================================================== |
---|
40 | // Constructor / destructor / initialization / destroy |
---|
41 | // ==================================================================================================================== |
---|
42 | #if SVC_EXTENSION |
---|
43 | TAppEncLayerCfg::TAppEncLayerCfg() |
---|
44 | :m_cInputFile(string("")), |
---|
45 | m_cReconFile(string("")), |
---|
46 | m_conformanceMode( 0 ), |
---|
47 | m_aidQP(NULL) |
---|
48 | #if REPN_FORMAT_IN_VPS |
---|
49 | , m_repFormatIdx (-1) |
---|
50 | #endif |
---|
51 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
52 | , m_colourRemapSEIFileRoot(string("")) |
---|
53 | #endif |
---|
54 | { |
---|
55 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
56 | for( Int c=0 ; c<3 ; c++) |
---|
57 | { |
---|
58 | m_colourRemapSEIPreLutCodedValue[c] = NULL; |
---|
59 | m_colourRemapSEIPreLutTargetValue[c] = NULL; |
---|
60 | m_colourRemapSEIPostLutCodedValue[c] = NULL; |
---|
61 | m_colourRemapSEIPostLutTargetValue[c] = NULL; |
---|
62 | } |
---|
63 | #endif |
---|
64 | m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0; |
---|
65 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
66 | m_numRefLayerLocationOffsets = 0; |
---|
67 | ::memset(m_refLocationOffsetLayerId, 0, sizeof(m_refLocationOffsetLayerId)); |
---|
68 | ::memset(m_scaledRefLayerLeftOffset, 0, sizeof(m_scaledRefLayerLeftOffset)); |
---|
69 | ::memset(m_scaledRefLayerTopOffset, 0, sizeof(m_scaledRefLayerTopOffset)); |
---|
70 | ::memset(m_scaledRefLayerRightOffset, 0, sizeof(m_scaledRefLayerRightOffset)); |
---|
71 | ::memset(m_scaledRefLayerBottomOffset, 0, sizeof(m_scaledRefLayerBottomOffset)); |
---|
72 | ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag)); |
---|
73 | ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag)); |
---|
74 | ::memset(m_refRegionLeftOffset, 0, sizeof(m_refRegionLeftOffset)); |
---|
75 | ::memset(m_refRegionTopOffset, 0, sizeof(m_refRegionTopOffset)); |
---|
76 | ::memset(m_refRegionRightOffset, 0, sizeof(m_refRegionRightOffset)); |
---|
77 | ::memset(m_refRegionBottomOffset, 0, sizeof(m_refRegionBottomOffset)); |
---|
78 | ::memset(m_resamplePhaseSetPresentFlag, 0, sizeof(m_resamplePhaseSetPresentFlag)); |
---|
79 | ::memset(m_phaseHorLuma, 0, sizeof(m_phaseHorLuma)); |
---|
80 | ::memset(m_phaseVerLuma, 0, sizeof(m_phaseVerLuma)); |
---|
81 | ::memset(m_phaseHorChroma, 0, sizeof(m_phaseHorChroma)); |
---|
82 | ::memset(m_phaseVerChroma, 0, sizeof(m_phaseVerChroma)); |
---|
83 | } |
---|
84 | |
---|
85 | TAppEncLayerCfg::~TAppEncLayerCfg() |
---|
86 | { |
---|
87 | if ( m_aidQP ) |
---|
88 | { |
---|
89 | delete[] m_aidQP; |
---|
90 | } |
---|
91 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
92 | for( Int c=0 ; c<3 ; c++) |
---|
93 | { |
---|
94 | if ( m_colourRemapSEIPreLutCodedValue[c] ) |
---|
95 | { |
---|
96 | delete[] m_colourRemapSEIPreLutCodedValue[c]; |
---|
97 | } |
---|
98 | if ( m_colourRemapSEIPreLutTargetValue[c] ) |
---|
99 | { |
---|
100 | delete[] m_colourRemapSEIPreLutTargetValue[c]; |
---|
101 | } |
---|
102 | if ( m_colourRemapSEIPostLutCodedValue[c] ) |
---|
103 | { |
---|
104 | delete[] m_colourRemapSEIPostLutCodedValue[c]; |
---|
105 | } |
---|
106 | if ( m_colourRemapSEIPostLutTargetValue[c] ) |
---|
107 | { |
---|
108 | delete[] m_colourRemapSEIPostLutTargetValue[c]; |
---|
109 | } |
---|
110 | } |
---|
111 | #endif |
---|
112 | } |
---|
113 | |
---|
114 | Void TAppEncLayerCfg::create() |
---|
115 | { |
---|
116 | } |
---|
117 | |
---|
118 | Void TAppEncLayerCfg::destroy() |
---|
119 | { |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | // ==================================================================================================================== |
---|
124 | // Public member functions |
---|
125 | // ==================================================================================================================== |
---|
126 | |
---|
127 | /** \param argc number of arguments |
---|
128 | \param argv array of arguments |
---|
129 | \retval true when success |
---|
130 | */ |
---|
131 | bool TAppEncLayerCfg::parseCfg( const string& cfgFileName ) |
---|
132 | { |
---|
133 | string cfg_InputFile; |
---|
134 | string cfg_ReconFile; |
---|
135 | string cfg_dQPFile; |
---|
136 | #if AUXILIARY_PICTURES |
---|
137 | Int tmpInputChromaFormat; |
---|
138 | Int tmpChromaFormat; |
---|
139 | #endif |
---|
140 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
141 | string cfg_colourRemapSEIFileRoot; |
---|
142 | #endif |
---|
143 | |
---|
144 | po::Options opts; |
---|
145 | opts.addOptions() |
---|
146 | ("InputFile,i", cfg_InputFile, string(""), "original YUV input file name") |
---|
147 | #if AVC_BASE |
---|
148 | ("InputBLFile,-ibl", cfg_InputFile, string(""), "original YUV input file name") |
---|
149 | #endif |
---|
150 | ("ReconFile,o", cfg_ReconFile, string(""), "reconstructed YUV output file name") |
---|
151 | ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") |
---|
152 | ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") |
---|
153 | ("CroppingMode", m_conformanceMode, 0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping") |
---|
154 | #if AUXILIARY_PICTURES |
---|
155 | ("InputChromaFormat", tmpInputChromaFormat, 420, "InputChromaFormatIDC") |
---|
156 | ("ChromaFormatIDC", tmpChromaFormat, 420, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)") |
---|
157 | #endif |
---|
158 | ("ConfLeft", m_confWinLeft, 0, "Deprecated alias of ConfWinLeft") |
---|
159 | ("ConfRight", m_confWinRight, 0, "Deprecated alias of ConfWinRight") |
---|
160 | ("ConfTop", m_confWinTop, 0, "Deprecated alias of ConfWinTop") |
---|
161 | ("ConfBottom", m_confWinBottom, 0, "Deprecated alias of ConfWinBottom") |
---|
162 | ("ConfWinLeft", m_confWinLeft, 0, "Left offset for window conformance mode 3") |
---|
163 | ("ConfWinRight", m_confWinRight, 0, "Right offset for window conformance mode 3") |
---|
164 | ("ConfWinTop", m_confWinTop, 0, "Top offset for window conformance mode 3") |
---|
165 | ("ConfWinBottom", m_confWinBottom, 0, "Bottom offset for window conformance mode 3") |
---|
166 | ("HorizontalPadding,-pdx",m_aiPad[0], 0, "horizontal source padding for cropping mode 2") |
---|
167 | ("VerticalPadding,-pdy", m_aiPad[1], 0, "vertical source padding for cropping mode 2") |
---|
168 | ("IntraPeriod,-ip", m_iIntraPeriod, -1, "intra period in frames, (-1: only first frame)") |
---|
169 | ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") |
---|
170 | ("dQPFile,m", cfg_dQPFile, string(""), "dQP file name") |
---|
171 | ("QP,q", m_fQP, 30.0, "Qp value, if value is float, QP is switched once during encoding") |
---|
172 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
173 | ("SEIColourRemappingInfoFileRoot", cfg_colourRemapSEIFileRoot, string(""), "Colour Remapping Information SEI parameters file name") |
---|
174 | #endif |
---|
175 | ; |
---|
176 | |
---|
177 | po::setDefaults(opts); |
---|
178 | po::parseConfigFile(opts, cfgFileName); |
---|
179 | |
---|
180 | m_cInputFile = cfg_InputFile; |
---|
181 | m_cReconFile = cfg_ReconFile; |
---|
182 | m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); |
---|
183 | #if AUXILIARY_PICTURES |
---|
184 | m_InputChromaFormatIDC = numberToChromaFormat(tmpInputChromaFormat); |
---|
185 | m_chromaFormatIDC = ((tmpChromaFormat == 0) ? (m_InputChromaFormatIDC) : (numberToChromaFormat(tmpChromaFormat))); |
---|
186 | #endif |
---|
187 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
188 | m_colourRemapSEIFileRoot = cfg_colourRemapSEIFileRoot.empty() ? NULL : strdup(cfg_colourRemapSEIFileRoot.c_str()); |
---|
189 | #endif |
---|
190 | |
---|
191 | // reading external dQP description from file |
---|
192 | if ( m_pchdQPFile ) |
---|
193 | { |
---|
194 | FILE* fpt=fopen( m_pchdQPFile, "r" ); |
---|
195 | if ( fpt ) |
---|
196 | { |
---|
197 | Int iValue; |
---|
198 | Int iPOC = 0; |
---|
199 | while ( iPOC < m_cAppEncCfg->getNumFrameToBeEncoded() ) |
---|
200 | { |
---|
201 | if ( fscanf(fpt, "%d", &iValue ) == EOF ) break; |
---|
202 | m_aidQP[ iPOC ] = iValue; |
---|
203 | iPOC++; |
---|
204 | } |
---|
205 | fclose(fpt); |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | return true; |
---|
210 | } |
---|
211 | |
---|
212 | Void TAppEncLayerCfg::xPrintParameter() |
---|
213 | { |
---|
214 | printf("Input File : %s\n", m_cInputFile.c_str() ); |
---|
215 | printf("Reconstruction File : %s\n", m_cReconFile.c_str() ); |
---|
216 | #if REPN_FORMAT_IN_VPS |
---|
217 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - ( m_confWinLeft + m_confWinRight ) * TComSPS::getWinUnitX( m_chromaFormatIDC ), m_iSourceHeight - ( m_confWinTop + m_confWinBottom ) * TComSPS::getWinUnitY( m_chromaFormatIDC ), m_iFrameRate ); |
---|
218 | #else |
---|
219 | printf("Real Format : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate ); |
---|
220 | #endif |
---|
221 | printf("Internal Format : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate ); |
---|
222 | printf("PTL index : %d\n", m_layerPTLIdx ); |
---|
223 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
224 | printf("Input bit depth : (Y:%d, C:%d)\n", m_inputBitDepth[CHANNEL_TYPE_LUMA], m_inputBitDepth[CHANNEL_TYPE_CHROMA] ); |
---|
225 | printf("Internal bit depth : (Y:%d, C:%d)\n", m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA] ); |
---|
226 | printf("PCM sample bit depth : (Y:%d, C:%d)\n", m_cAppEncCfg->getPCMInputBitDepthFlag() ? m_inputBitDepth[CHANNEL_TYPE_LUMA] : m_internalBitDepth[CHANNEL_TYPE_LUMA], m_cAppEncCfg->getPCMInputBitDepthFlag() ? m_inputBitDepth[CHANNEL_TYPE_CHROMA] : m_internalBitDepth[CHANNEL_TYPE_CHROMA] ); |
---|
227 | #endif |
---|
228 | std::cout << "Input ChromaFormatIDC :"; |
---|
229 | |
---|
230 | switch (m_InputChromaFormatIDC) |
---|
231 | { |
---|
232 | case CHROMA_400: std::cout << " 4:0:0"; break; |
---|
233 | case CHROMA_420: std::cout << " 4:2:0"; break; |
---|
234 | case CHROMA_422: std::cout << " 4:2:2"; break; |
---|
235 | case CHROMA_444: std::cout << " 4:4:4"; break; |
---|
236 | default: |
---|
237 | std::cerr << "Invalid"; |
---|
238 | exit(1); |
---|
239 | } |
---|
240 | std::cout << std::endl; |
---|
241 | |
---|
242 | std::cout << "Output (internal) ChromaFormatIDC :"; |
---|
243 | switch (m_chromaFormatIDC) |
---|
244 | { |
---|
245 | case CHROMA_400: std::cout << " 4:0:0"; break; |
---|
246 | case CHROMA_420: std::cout << " 4:2:0"; break; |
---|
247 | case CHROMA_422: std::cout << " 4:2:2"; break; |
---|
248 | case CHROMA_444: std::cout << " 4:4:4"; break; |
---|
249 | default: |
---|
250 | std::cerr << "Invalid"; |
---|
251 | exit(1); |
---|
252 | } |
---|
253 | printf("\n"); |
---|
254 | #if LAYER_CTB |
---|
255 | printf("CU size / depth : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth ); |
---|
256 | printf("RQT trans. size (min / max) : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
257 | printf("Max RQT depth inter : %d\n", m_uiQuadtreeTUMaxDepthInter); |
---|
258 | printf("Max RQT depth intra : %d\n", m_uiQuadtreeTUMaxDepthIntra); |
---|
259 | #endif |
---|
260 | printf("QP : %5.2f\n", m_fQP ); |
---|
261 | printf("Intra period : %d\n", m_iIntraPeriod ); |
---|
262 | #if RC_SHVC_HARMONIZATION |
---|
263 | printf("RateControl : %d\n", m_RCEnableRateControl ); |
---|
264 | if(m_RCEnableRateControl) |
---|
265 | { |
---|
266 | printf("TargetBitrate : %d\n", m_RCTargetBitrate ); |
---|
267 | printf("KeepHierarchicalBit : %d\n", m_RCKeepHierarchicalBit ); |
---|
268 | printf("LCULevelRC : %d\n", m_RCLCULevelRC ); |
---|
269 | printf("UseLCUSeparateModel : %d\n", m_RCUseLCUSeparateModel ); |
---|
270 | printf("InitialQP : %d\n", m_RCInitialQP ); |
---|
271 | printf("ForceIntraQP : %d\n", m_RCForceIntraQP ); |
---|
272 | } |
---|
273 | #endif |
---|
274 | printf("WaveFrontSynchro : %d\n", m_waveFrontSynchro); |
---|
275 | printf("WaveFrontSubstreams : %d\n", m_iWaveFrontSubstreams); |
---|
276 | #if LAYER_CTB |
---|
277 | printf("PCM : %d ", (m_cAppEncCfg->getUsePCM() && (1<<m_cAppEncCfg->getPCMLog2MinSize()) <= m_uiMaxCUWidth)? 1 : 0); |
---|
278 | #endif |
---|
279 | } |
---|
280 | |
---|
281 | Bool confirmPara(Bool bflag, const char* message); |
---|
282 | |
---|
283 | Bool TAppEncLayerCfg::xCheckParameter( Bool isField ) |
---|
284 | { |
---|
285 | switch (m_conformanceMode) |
---|
286 | { |
---|
287 | case 0: |
---|
288 | { |
---|
289 | // no cropping or padding |
---|
290 | m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0; |
---|
291 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
292 | break; |
---|
293 | } |
---|
294 | case 1: |
---|
295 | { |
---|
296 | // conformance |
---|
297 | if ((m_confWinLeft != 0) || (m_confWinRight != 0) || (m_confWinTop != 0) || (m_confWinBottom != 0)) |
---|
298 | { |
---|
299 | fprintf(stderr, "Warning: Automatic padding enabled, but cropping parameters are set. Undesired size possible.\n"); |
---|
300 | } |
---|
301 | if ((m_aiPad[1] != 0) || (m_aiPad[0] != 0)) |
---|
302 | { |
---|
303 | fprintf(stderr, "Warning: Automatic padding enabled, but padding parameters are also set\n"); |
---|
304 | } |
---|
305 | |
---|
306 | // automatic padding to minimum CU size |
---|
307 | #if LAYER_CTB |
---|
308 | Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); |
---|
309 | #else |
---|
310 | Int minCuSize = m_cAppEncCfg->getMaxCUHeight() >> (m_cAppEncCfg->getMaxCUDepth() - 1); |
---|
311 | #endif |
---|
312 | if (m_iSourceWidth % minCuSize) |
---|
313 | { |
---|
314 | m_aiPad[0] = m_confWinRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth; |
---|
315 | m_iSourceWidth += m_confWinRight; |
---|
316 | #if REPN_FORMAT_IN_VPS |
---|
317 | m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC ); |
---|
318 | #endif |
---|
319 | } |
---|
320 | if (m_iSourceHeight % minCuSize) |
---|
321 | { |
---|
322 | m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; |
---|
323 | m_iSourceHeight += m_confWinBottom; |
---|
324 | if ( isField ) |
---|
325 | { |
---|
326 | m_iSourceHeightOrg += m_confWinBottom << 1; |
---|
327 | m_aiPad[1] = m_confWinBottom << 1; |
---|
328 | } |
---|
329 | #if REPN_FORMAT_IN_VPS |
---|
330 | m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC ); |
---|
331 | #endif |
---|
332 | } |
---|
333 | break; |
---|
334 | } |
---|
335 | case 2: |
---|
336 | { |
---|
337 | // conformance |
---|
338 | if ((m_confWinLeft != 0) || (m_confWinRight != 0) || (m_confWinTop != 0) || (m_confWinBottom != 0)) |
---|
339 | { |
---|
340 | fprintf(stderr, "Warning: Automatic padding enabled, but cropping parameters are set. Undesired size possible.\n"); |
---|
341 | } |
---|
342 | |
---|
343 | //padding |
---|
344 | m_iSourceWidth += m_aiPad[0]; |
---|
345 | m_iSourceHeight += m_aiPad[1]; |
---|
346 | m_confWinRight = m_aiPad[0]; |
---|
347 | m_confWinBottom = m_aiPad[1]; |
---|
348 | #if REPN_FORMAT_IN_VPS |
---|
349 | m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC ); |
---|
350 | m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC ); |
---|
351 | #endif |
---|
352 | break; |
---|
353 | } |
---|
354 | case 3: |
---|
355 | { |
---|
356 | // conformance |
---|
357 | if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0)) |
---|
358 | { |
---|
359 | fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n"); |
---|
360 | } |
---|
361 | if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0)) |
---|
362 | { |
---|
363 | fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n"); |
---|
364 | } |
---|
365 | m_aiPad[1] = m_aiPad[0] = 0; |
---|
366 | break; |
---|
367 | } |
---|
368 | } |
---|
369 | |
---|
370 | // allocate slice-based dQP values |
---|
371 | Int iFrameToBeEncoded = m_cAppEncCfg->getNumFrameToBeEncoded(); |
---|
372 | Int iGOPSize = m_cAppEncCfg->getGOPSize(); |
---|
373 | if( m_aidQP == NULL ) |
---|
374 | m_aidQP = new Int[iFrameToBeEncoded + iGOPSize + 1 ]; |
---|
375 | ::memset( m_aidQP, 0, sizeof(Int)*( iFrameToBeEncoded + iGOPSize + 1 ) ); |
---|
376 | |
---|
377 | // handling of floating-point QP values |
---|
378 | // if QP is not integer, sequence is split into two sections having QP and QP+1 |
---|
379 | m_iQP = (Int)( m_fQP ); |
---|
380 | if ( m_iQP < m_fQP ) |
---|
381 | { |
---|
382 | Int iSwitchPOC = (Int)( iFrameToBeEncoded - (m_fQP - m_iQP)*iFrameToBeEncoded + 0.5 ); |
---|
383 | |
---|
384 | |
---|
385 | iSwitchPOC = (Int)( (Double)iSwitchPOC / iGOPSize + 0.5 )*iGOPSize; |
---|
386 | for ( Int i=iSwitchPOC; i<iFrameToBeEncoded + iGOPSize + 1; i++ ) |
---|
387 | { |
---|
388 | m_aidQP[i] = 1; |
---|
389 | } |
---|
390 | } |
---|
391 | |
---|
392 | #if LAYER_CTB |
---|
393 | UInt maxCUWidth = m_uiMaxCUWidth; |
---|
394 | UInt maxCUHeight = m_uiMaxCUHeight; |
---|
395 | UInt maxCUDepth = m_uiMaxCUDepth; |
---|
396 | #else |
---|
397 | UInt maxCUWidth = m_cAppEncCfg->getMaxCUWidth(); |
---|
398 | UInt maxCUHeight = m_cAppEncCfg->getMaxCUHeight(); |
---|
399 | UInt maxCUDepth = m_cAppEncCfg->getMaxCUDepth(); |
---|
400 | #endif |
---|
401 | bool check_failed = false; /* abort if there is a fatal configuration problem */ |
---|
402 | #define xConfirmPara(a,b) check_failed |= confirmPara(a,b) |
---|
403 | // check range of parameters |
---|
404 | xConfirmPara( m_iFrameRate <= 0, "Frame rate must be more than 1" ); |
---|
405 | xConfirmPara( (m_iSourceWidth % (maxCUWidth >> (maxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size"); |
---|
406 | xConfirmPara( (m_iSourceHeight % (maxCUHeight >> (maxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size"); |
---|
407 | xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" ); |
---|
408 | if (m_cAppEncCfg->getDecodingRefreshType() == 2) |
---|
409 | { |
---|
410 | xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= iGOPSize , "Intra period must be larger than GOP size for periodic IDR pictures"); |
---|
411 | } |
---|
412 | |
---|
413 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
414 | xConfirmPara( m_iQP < -6 * (m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8) || m_iQP > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
---|
415 | #else |
---|
416 | xConfirmPara( m_iQP < -6 * ((Int)m_cAppEncCfg->getInternalBitDepthY() - 8) || m_iQP > 51, "QP exceeds supported range (-QpBDOffsety to 51)" ); |
---|
417 | #endif |
---|
418 | |
---|
419 | m_iWaveFrontSubstreams = m_waveFrontSynchro ? (m_iSourceHeight + maxCUHeight - 1) / maxCUHeight : 1; |
---|
420 | xConfirmPara( m_waveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" ); |
---|
421 | xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" ); |
---|
422 | xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_waveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" ); |
---|
423 | |
---|
424 | //chekc parameters |
---|
425 | xConfirmPara( m_iSourceWidth % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); |
---|
426 | xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); |
---|
427 | |
---|
428 | xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling"); |
---|
429 | xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling"); |
---|
430 | |
---|
431 | #if !REPN_FORMAT_IN_VPS |
---|
432 | xConfirmPara( m_confLeft % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
433 | xConfirmPara( m_confRight % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
434 | xConfirmPara( m_confTop % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
435 | xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling"); |
---|
436 | #endif |
---|
437 | |
---|
438 | #if LAYER_CTB |
---|
439 | xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); |
---|
440 | xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); |
---|
441 | xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); |
---|
442 | xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); |
---|
443 | xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater."); |
---|
444 | xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller."); |
---|
445 | xConfirmPara( (1<<m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth, "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller."); |
---|
446 | xConfirmPara( m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize, "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize."); |
---|
447 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUWidth >>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
448 | xConfirmPara( (1<<m_uiQuadtreeTULog2MinSize)>(m_uiMaxCUHeight>>(m_uiMaxCUDepth-1)), "QuadtreeTULog2MinSize must not be greater than minimum CU size" ); // HS |
---|
449 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUWidth >> m_uiMaxCUDepth ), "Minimum CU width must be greater than minimum transform size." ); |
---|
450 | xConfirmPara( ( 1 << m_uiQuadtreeTULog2MinSize ) > ( m_uiMaxCUHeight >> m_uiMaxCUDepth ), "Minimum CU height must be greater than minimum transform size." ); |
---|
451 | xConfirmPara( m_uiQuadtreeTUMaxDepthInter < 1, "QuadtreeTUMaxDepthInter must be greater than or equal to 1" ); |
---|
452 | 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" ); |
---|
453 | xConfirmPara( m_uiQuadtreeTUMaxDepthIntra < 1, "QuadtreeTUMaxDepthIntra must be greater than or equal to 1" ); |
---|
454 | 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" ); |
---|
455 | |
---|
456 | // max CU width and height should be power of 2 |
---|
457 | UInt ui = m_uiMaxCUWidth; |
---|
458 | while(ui) |
---|
459 | { |
---|
460 | ui >>= 1; |
---|
461 | if( (ui & 1) == 1) |
---|
462 | xConfirmPara( ui != 1 , "Width should be 2^n"); |
---|
463 | } |
---|
464 | ui = m_uiMaxCUHeight; |
---|
465 | while(ui) |
---|
466 | { |
---|
467 | ui >>= 1; |
---|
468 | if( (ui & 1) == 1) |
---|
469 | xConfirmPara( ui != 1 , "Height should be 2^n"); |
---|
470 | } |
---|
471 | #endif |
---|
472 | |
---|
473 | #undef xConfirmPara |
---|
474 | return check_failed; |
---|
475 | } |
---|
476 | |
---|
477 | #endif //SVC_EXTENSION |
---|
478 | |
---|
479 | |
---|
480 | //! \} |
---|