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-2014, 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 TEncTop.cpp |
---|
35 | \brief encoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TLibCommon/CommonDef.h" |
---|
39 | #include "TEncTop.h" |
---|
40 | #include "TEncPic.h" |
---|
41 | #include "TLibCommon/TComChromaFormat.h" |
---|
42 | #if FAST_BIT_EST |
---|
43 | #include "TLibCommon/ContextModel.h" |
---|
44 | #endif |
---|
45 | |
---|
46 | //! \ingroup TLibEncoder |
---|
47 | //! \{ |
---|
48 | #if SVC_EXTENSION |
---|
49 | Int TEncTop::m_iSPSIdCnt = 0; |
---|
50 | Int TEncTop::m_iPPSIdCnt = 0; |
---|
51 | TComVPS TEncCfg::m_cVPS; |
---|
52 | #endif |
---|
53 | |
---|
54 | // ==================================================================================================================== |
---|
55 | // Constructor / destructor / create / destroy |
---|
56 | // ==================================================================================================================== |
---|
57 | |
---|
58 | TEncTop::TEncTop() |
---|
59 | { |
---|
60 | m_iPOCLast = -1; |
---|
61 | m_iNumPicRcvd = 0; |
---|
62 | m_uiNumAllPicCoded = 0; |
---|
63 | m_pppcRDSbacCoder = NULL; |
---|
64 | m_pppcBinCoderCABAC = NULL; |
---|
65 | m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC ); |
---|
66 | #if ENC_DEC_TRACE |
---|
67 | if (g_hTrace == NULL) |
---|
68 | { |
---|
69 | g_hTrace = fopen( "TraceEnc.txt", "wb" ); |
---|
70 | } |
---|
71 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
72 | g_nSymbolCounter = 0; |
---|
73 | #endif |
---|
74 | |
---|
75 | m_iMaxRefPicNum = 0; |
---|
76 | |
---|
77 | #if FAST_BIT_EST |
---|
78 | ContextModel::buildNextStateTable(); |
---|
79 | #endif |
---|
80 | |
---|
81 | #if SVC_EXTENSION |
---|
82 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
83 | #if REF_IDX_MFM |
---|
84 | m_bMFMEnabledFlag = false; |
---|
85 | #endif |
---|
86 | m_numScaledRefLayerOffsets = 0; |
---|
87 | #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER |
---|
88 | m_pocAdjustmentValue = 0; |
---|
89 | #endif |
---|
90 | #if NO_CLRAS_OUTPUT_FLAG |
---|
91 | m_noClrasOutputFlag = false; |
---|
92 | m_layerInitializedFlag = false; |
---|
93 | m_firstPicInLayerDecodedFlag = false; |
---|
94 | m_noOutputOfPriorPicsFlags = false; |
---|
95 | #endif |
---|
96 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
97 | m_pocDecrementedInDPBFlag = false; |
---|
98 | #endif |
---|
99 | #endif //SVC_EXTENSION |
---|
100 | } |
---|
101 | |
---|
102 | TEncTop::~TEncTop() |
---|
103 | { |
---|
104 | #if ENC_DEC_TRACE |
---|
105 | if (g_hTrace != stdout) |
---|
106 | { |
---|
107 | fclose( g_hTrace ); |
---|
108 | } |
---|
109 | #endif |
---|
110 | } |
---|
111 | |
---|
112 | Void TEncTop::create () |
---|
113 | { |
---|
114 | #if !SVC_EXTENSION |
---|
115 | // initialize global variables |
---|
116 | initROM(); |
---|
117 | #endif |
---|
118 | |
---|
119 | // create processing unit classes |
---|
120 | #if SVC_EXTENSION |
---|
121 | m_cGOPEncoder. create( m_layerId ); |
---|
122 | #else |
---|
123 | m_cGOPEncoder. create( ); |
---|
124 | #endif |
---|
125 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
126 | m_cCuEncoder. create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, m_chromaFormatIDC ); |
---|
127 | if (m_bUseSAO) |
---|
128 | { |
---|
129 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_saoOffsetBitShift[CHANNEL_TYPE_LUMA], m_saoOffsetBitShift[CHANNEL_TYPE_CHROMA] ); |
---|
130 | #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK |
---|
131 | m_cEncSAO.createEncData(getSaoCtuBoundary()); |
---|
132 | #else |
---|
133 | m_cEncSAO.createEncData(); |
---|
134 | #endif |
---|
135 | } |
---|
136 | #if ADAPTIVE_QP_SELECTION |
---|
137 | if (m_bUseAdaptQpSelect) |
---|
138 | { |
---|
139 | m_cTrQuant.initSliceQpDelta(); |
---|
140 | } |
---|
141 | #endif |
---|
142 | |
---|
143 | m_cLoopFilter.create( g_uiMaxCUDepth ); |
---|
144 | |
---|
145 | if ( m_RCEnableRateControl ) |
---|
146 | { |
---|
147 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
---|
148 | g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); |
---|
149 | } |
---|
150 | |
---|
151 | m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
152 | #if FAST_BIT_EST |
---|
153 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1]; |
---|
154 | #else |
---|
155 | m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
156 | #endif |
---|
157 | |
---|
158 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
159 | { |
---|
160 | m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; |
---|
161 | #if FAST_BIT_EST |
---|
162 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; |
---|
163 | #else |
---|
164 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; |
---|
165 | #endif |
---|
166 | |
---|
167 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
168 | { |
---|
169 | m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; |
---|
170 | #if FAST_BIT_EST |
---|
171 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; |
---|
172 | #else |
---|
173 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; |
---|
174 | #endif |
---|
175 | m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | #if LAYER_CTB |
---|
180 | memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) ); |
---|
181 | memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) ); |
---|
182 | memcpy(g_auiLayerRasterToPelX[m_layerId], g_auiRasterToPelX, sizeof( g_auiRasterToPelX ) ); |
---|
183 | memcpy(g_auiLayerRasterToPelY[m_layerId], g_auiRasterToPelY, sizeof( g_auiRasterToPelY ) ); |
---|
184 | #endif |
---|
185 | } |
---|
186 | |
---|
187 | Void TEncTop::destroy () |
---|
188 | { |
---|
189 | // destroy processing unit classes |
---|
190 | m_cGOPEncoder. destroy(); |
---|
191 | m_cSliceEncoder. destroy(); |
---|
192 | m_cCuEncoder. destroy(); |
---|
193 | if (m_cSPS.getUseSAO()) |
---|
194 | { |
---|
195 | m_cEncSAO.destroyEncData(); |
---|
196 | m_cEncSAO.destroy(); |
---|
197 | } |
---|
198 | m_cLoopFilter. destroy(); |
---|
199 | m_cRateCtrl. destroy(); |
---|
200 | Int iDepth; |
---|
201 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
202 | { |
---|
203 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
204 | { |
---|
205 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
---|
206 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
---|
207 | } |
---|
208 | } |
---|
209 | |
---|
210 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
211 | { |
---|
212 | delete [] m_pppcRDSbacCoder[iDepth]; |
---|
213 | delete [] m_pppcBinCoderCABAC[iDepth]; |
---|
214 | } |
---|
215 | |
---|
216 | delete [] m_pppcRDSbacCoder; |
---|
217 | delete [] m_pppcBinCoderCABAC; |
---|
218 | |
---|
219 | #if SVC_EXTENSION |
---|
220 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
221 | { |
---|
222 | if(m_cIlpPic[i]) |
---|
223 | { |
---|
224 | m_cIlpPic[i]->destroy(); |
---|
225 | delete m_cIlpPic[i]; |
---|
226 | m_cIlpPic[i] = NULL; |
---|
227 | } |
---|
228 | } |
---|
229 | #else |
---|
230 | // destroy ROM |
---|
231 | destroyROM(); |
---|
232 | #endif |
---|
233 | return; |
---|
234 | } |
---|
235 | |
---|
236 | Void TEncTop::init(Bool isFieldCoding) |
---|
237 | { |
---|
238 | // initialize SPS |
---|
239 | xInitSPS(); |
---|
240 | |
---|
241 | // set the VPS profile information |
---|
242 | *m_cVPS.getPTL() = *m_cSPS.getPTL(); |
---|
243 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
244 | m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( true ); |
---|
245 | #else |
---|
246 | m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false ); |
---|
247 | #endif |
---|
248 | m_cRdCost.setCostMode(m_costMode); |
---|
249 | |
---|
250 | // initialize PPS |
---|
251 | m_cPPS.setSPS(&m_cSPS); |
---|
252 | xInitPPS(); |
---|
253 | xInitRPS(isFieldCoding); |
---|
254 | |
---|
255 | xInitPPSforTiles(); |
---|
256 | |
---|
257 | // initialize processing unit classes |
---|
258 | m_cGOPEncoder. init( this ); |
---|
259 | m_cSliceEncoder.init( this ); |
---|
260 | m_cCuEncoder. init( this ); |
---|
261 | |
---|
262 | // initialize transform & quantization class |
---|
263 | m_pcCavlcCoder = getCavlcCoder(); |
---|
264 | |
---|
265 | m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize, |
---|
266 | m_useRDOQ, |
---|
267 | m_useRDOQTS, |
---|
268 | true |
---|
269 | ,m_useTransformSkipFast |
---|
270 | #if ADAPTIVE_QP_SELECTION |
---|
271 | ,m_bUseAdaptQpSelect |
---|
272 | #endif |
---|
273 | ); |
---|
274 | |
---|
275 | // initialize encoder search class |
---|
276 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
277 | |
---|
278 | m_iMaxRefPicNum = 0; |
---|
279 | #if SVC_EXTENSION |
---|
280 | m_iSPSIdCnt ++; |
---|
281 | m_iPPSIdCnt ++; |
---|
282 | xInitILRP(); |
---|
283 | #endif |
---|
284 | } |
---|
285 | |
---|
286 | // ==================================================================================================================== |
---|
287 | // Public member functions |
---|
288 | // ==================================================================================================================== |
---|
289 | |
---|
290 | Void TEncTop::deletePicBuffer() |
---|
291 | { |
---|
292 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
293 | Int iSize = Int( m_cListPic.size() ); |
---|
294 | |
---|
295 | for ( Int i = 0; i < iSize; i++ ) |
---|
296 | { |
---|
297 | TComPic* pcPic = *(iterPic++); |
---|
298 | |
---|
299 | pcPic->destroy(); |
---|
300 | delete pcPic; |
---|
301 | pcPic = NULL; |
---|
302 | } |
---|
303 | } |
---|
304 | |
---|
305 | /** |
---|
306 | - Application has picture buffer list with size of GOP + 1 |
---|
307 | - Picture buffer list acts like as ring buffer |
---|
308 | - End of the list has the latest picture |
---|
309 | . |
---|
310 | \param flush cause encoder to encode a partial GOP |
---|
311 | \param pcPicYuvOrg original YUV picture |
---|
312 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
---|
313 | \retval rcListBitstreamOut list of output bitstreams |
---|
314 | \retval iNumEncoded number of encoded pictures |
---|
315 | */ |
---|
316 | #if SVC_EXTENSION |
---|
317 | Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ) |
---|
318 | { |
---|
319 | // compress GOP |
---|
320 | #if !RC_SHVC_HARMONIZATION |
---|
321 | if ( m_RCEnableRateControl ) |
---|
322 | { |
---|
323 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
324 | } |
---|
325 | #endif |
---|
326 | |
---|
327 | // compress GOP |
---|
328 | m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE); |
---|
329 | |
---|
330 | #if !RC_SHVC_HARMONIZATION |
---|
331 | if ( m_RCEnableRateControl ) |
---|
332 | { |
---|
333 | m_cRateCtrl.destroyRCGOP(); |
---|
334 | } |
---|
335 | #endif |
---|
336 | |
---|
337 | m_uiNumAllPicCoded ++; |
---|
338 | } |
---|
339 | |
---|
340 | Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg ) |
---|
341 | { |
---|
342 | if (pcPicYuvOrg != NULL) |
---|
343 | { |
---|
344 | // get original YUV |
---|
345 | TComPic* pcPicCurr = NULL; |
---|
346 | xGetNewPicBuffer( pcPicCurr ); |
---|
347 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
348 | pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() ); |
---|
349 | |
---|
350 | // compute image characteristics |
---|
351 | if ( getUseAdaptiveQP() ) |
---|
352 | { |
---|
353 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | #else |
---|
358 | Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ) |
---|
359 | { |
---|
360 | if (pcPicYuvOrg != NULL) |
---|
361 | { |
---|
362 | // get original YUV |
---|
363 | TComPic* pcPicCurr = NULL; |
---|
364 | |
---|
365 | xGetNewPicBuffer( pcPicCurr ); |
---|
366 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
367 | pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() ); |
---|
368 | |
---|
369 | // compute image characteristics |
---|
370 | if ( getUseAdaptiveQP() ) |
---|
371 | { |
---|
372 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | if ((m_iNumPicRcvd == 0) || (!flush && (m_iPOCLast != 0) && (m_iNumPicRcvd != m_iGOPSize) && (m_iGOPSize != 0))) |
---|
377 | { |
---|
378 | iNumEncoded = 0; |
---|
379 | return; |
---|
380 | } |
---|
381 | |
---|
382 | if ( m_RCEnableRateControl ) |
---|
383 | { |
---|
384 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
385 | } |
---|
386 | |
---|
387 | // compress GOP |
---|
388 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE); |
---|
389 | |
---|
390 | if ( m_RCEnableRateControl ) |
---|
391 | { |
---|
392 | m_cRateCtrl.destroyRCGOP(); |
---|
393 | } |
---|
394 | |
---|
395 | iNumEncoded = m_iNumPicRcvd; |
---|
396 | m_iNumPicRcvd = 0; |
---|
397 | m_uiNumAllPicCoded += iNumEncoded; |
---|
398 | } |
---|
399 | #endif |
---|
400 | |
---|
401 | /**------------------------------------------------ |
---|
402 | Separate interlaced frame into two fields |
---|
403 | -------------------------------------------------**/ |
---|
404 | Void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) |
---|
405 | { |
---|
406 | if (!isTop) |
---|
407 | { |
---|
408 | org += stride; |
---|
409 | } |
---|
410 | for (Int y = 0; y < height>>1; y++) |
---|
411 | { |
---|
412 | for (Int x = 0; x < width; x++) |
---|
413 | { |
---|
414 | dstField[x] = org[x]; |
---|
415 | } |
---|
416 | |
---|
417 | dstField += stride; |
---|
418 | org += stride*2; |
---|
419 | } |
---|
420 | |
---|
421 | } |
---|
422 | |
---|
423 | #if SVC_EXTENSION |
---|
424 | Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, Bool isTff ) |
---|
425 | { |
---|
426 | for (Int fieldNum=0; fieldNum<2; fieldNum++) |
---|
427 | { |
---|
428 | if (pcPicYuvOrg) |
---|
429 | { |
---|
430 | /* -- field initialization -- */ |
---|
431 | const Bool isTopField=isTff==(fieldNum==0); |
---|
432 | |
---|
433 | TComPic *pcField; |
---|
434 | xGetNewPicBuffer( pcField ); |
---|
435 | pcField->setReconMark (false); // where is this normally? |
---|
436 | |
---|
437 | pcField->getSlice(0)->setPOC( m_iPOCLast ); // superfluous? |
---|
438 | pcField->getPicYuvRec()->setBorderExtension(false);// where is this normally? |
---|
439 | |
---|
440 | pcField->setTopField(isTopField); // interlaced requirement |
---|
441 | |
---|
442 | for (UInt componentIndex = 0; componentIndex < pcPicYuvOrg->getNumberValidComponents(); componentIndex++) |
---|
443 | { |
---|
444 | const ComponentID component = ComponentID(componentIndex); |
---|
445 | const UInt stride = pcPicYuvOrg->getStride(component); |
---|
446 | |
---|
447 | separateFields((pcPicYuvOrg->getBuf(component) + pcPicYuvOrg->getMarginX(component) + (pcPicYuvOrg->getMarginY(component) * stride)), |
---|
448 | pcField->getPicYuvOrg()->getAddr(component), |
---|
449 | pcPicYuvOrg->getStride(component), |
---|
450 | pcPicYuvOrg->getWidth(component), |
---|
451 | pcPicYuvOrg->getHeight(component), |
---|
452 | isTopField); |
---|
453 | |
---|
454 | separateFields((pcPicYuvTrueOrg->getBuf(component) + pcPicYuvTrueOrg->getMarginX(component) + (pcPicYuvTrueOrg->getMarginY(component) * stride)), |
---|
455 | pcField->getPicYuvTrueOrg()->getAddr(component), |
---|
456 | pcPicYuvTrueOrg->getStride(component), |
---|
457 | pcPicYuvTrueOrg->getWidth(component), |
---|
458 | pcPicYuvTrueOrg->getHeight(component), |
---|
459 | isTopField); |
---|
460 | } |
---|
461 | |
---|
462 | // compute image characteristics |
---|
463 | if ( getUseAdaptiveQP() ) |
---|
464 | { |
---|
465 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcField ) ); |
---|
466 | } |
---|
467 | } |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ) |
---|
472 | { |
---|
473 | for (Int fieldNum=0; fieldNum<2; fieldNum++) |
---|
474 | { |
---|
475 | if (pcPicYuvOrg) |
---|
476 | { |
---|
477 | if (fieldNum==1) // where is this normally? |
---|
478 | { |
---|
479 | TComPicYuv* rpcPicYuvRec; |
---|
480 | |
---|
481 | // org. buffer |
---|
482 | if ( rcListPicYuvRecOut.size() >= (UInt)m_iGOPSize+1 ) // need to maintain field 0 in list of RecOuts while processing field 1. Hence +1 on m_iGOPSize. |
---|
483 | { |
---|
484 | rpcPicYuvRec = rcListPicYuvRecOut.popFront(); |
---|
485 | } |
---|
486 | else |
---|
487 | { |
---|
488 | rpcPicYuvRec = new TComPicYuv; |
---|
489 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); |
---|
490 | } |
---|
491 | rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | // compress GOP |
---|
496 | m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE); |
---|
497 | } |
---|
498 | |
---|
499 | m_uiNumAllPicCoded ++; |
---|
500 | } |
---|
501 | #else |
---|
502 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) |
---|
503 | { |
---|
504 | iNumEncoded = 0; |
---|
505 | |
---|
506 | for (Int fieldNum=0; fieldNum<2; fieldNum++) |
---|
507 | { |
---|
508 | if (pcPicYuvOrg) |
---|
509 | { |
---|
510 | |
---|
511 | /* -- field initialization -- */ |
---|
512 | const Bool isTopField=isTff==(fieldNum==0); |
---|
513 | |
---|
514 | TComPic *pcField; |
---|
515 | xGetNewPicBuffer( pcField ); |
---|
516 | pcField->setReconMark (false); // where is this normally? |
---|
517 | |
---|
518 | if (fieldNum==1) // where is this normally? |
---|
519 | { |
---|
520 | TComPicYuv* rpcPicYuvRec; |
---|
521 | |
---|
522 | // org. buffer |
---|
523 | if ( rcListPicYuvRecOut.size() >= (UInt)m_iGOPSize+1 ) // need to maintain field 0 in list of RecOuts while processing field 1. Hence +1 on m_iGOPSize. |
---|
524 | { |
---|
525 | rpcPicYuvRec = rcListPicYuvRecOut.popFront(); |
---|
526 | } |
---|
527 | else |
---|
528 | { |
---|
529 | rpcPicYuvRec = new TComPicYuv; |
---|
530 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); |
---|
531 | } |
---|
532 | rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); |
---|
533 | } |
---|
534 | |
---|
535 | pcField->getSlice(0)->setPOC( m_iPOCLast ); // superfluous? |
---|
536 | pcField->getPicYuvRec()->setBorderExtension(false);// where is this normally? |
---|
537 | |
---|
538 | pcField->setTopField(isTopField); // interlaced requirement |
---|
539 | |
---|
540 | for (UInt componentIndex = 0; componentIndex < pcPicYuvOrg->getNumberValidComponents(); componentIndex++) |
---|
541 | { |
---|
542 | const ComponentID component = ComponentID(componentIndex); |
---|
543 | const UInt stride = pcPicYuvOrg->getStride(component); |
---|
544 | |
---|
545 | separateFields((pcPicYuvOrg->getBuf(component) + pcPicYuvOrg->getMarginX(component) + (pcPicYuvOrg->getMarginY(component) * stride)), |
---|
546 | pcField->getPicYuvOrg()->getAddr(component), |
---|
547 | pcPicYuvOrg->getStride(component), |
---|
548 | pcPicYuvOrg->getWidth(component), |
---|
549 | pcPicYuvOrg->getHeight(component), |
---|
550 | isTopField); |
---|
551 | |
---|
552 | separateFields((pcPicYuvTrueOrg->getBuf(component) + pcPicYuvTrueOrg->getMarginX(component) + (pcPicYuvTrueOrg->getMarginY(component) * stride)), |
---|
553 | pcField->getPicYuvTrueOrg()->getAddr(component), |
---|
554 | pcPicYuvTrueOrg->getStride(component), |
---|
555 | pcPicYuvTrueOrg->getWidth(component), |
---|
556 | pcPicYuvTrueOrg->getHeight(component), |
---|
557 | isTopField); |
---|
558 | } |
---|
559 | |
---|
560 | // compute image characteristics |
---|
561 | if ( getUseAdaptiveQP() ) |
---|
562 | { |
---|
563 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcField ) ); |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|
567 | if ( m_iNumPicRcvd && ((flush&&fieldNum==1) || (m_iPOCLast/2)==0 || m_iNumPicRcvd==m_iGOPSize ) ) |
---|
568 | { |
---|
569 | // compress GOP |
---|
570 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff, snrCSC, m_printFrameMSE); |
---|
571 | |
---|
572 | iNumEncoded += m_iNumPicRcvd; |
---|
573 | m_uiNumAllPicCoded += m_iNumPicRcvd; |
---|
574 | m_iNumPicRcvd = 0; |
---|
575 | } |
---|
576 | } |
---|
577 | } |
---|
578 | #endif |
---|
579 | |
---|
580 | // ==================================================================================================================== |
---|
581 | // Protected member functions |
---|
582 | // ==================================================================================================================== |
---|
583 | |
---|
584 | /** |
---|
585 | - Application has picture buffer list with size of GOP + 1 |
---|
586 | - Picture buffer list acts like as ring buffer |
---|
587 | - End of the list has the latest picture |
---|
588 | . |
---|
589 | \retval rpcPic obtained picture buffer |
---|
590 | */ |
---|
591 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) |
---|
592 | { |
---|
593 | TComSlice::sortPicList(m_cListPic); |
---|
594 | |
---|
595 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
596 | { |
---|
597 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
598 | Int iSize = Int( m_cListPic.size() ); |
---|
599 | for ( Int i = 0; i < iSize; i++ ) |
---|
600 | { |
---|
601 | rpcPic = *(iterPic++); |
---|
602 | if(rpcPic->getSlice(0)->isReferenced() == false) |
---|
603 | { |
---|
604 | break; |
---|
605 | } |
---|
606 | } |
---|
607 | } |
---|
608 | else |
---|
609 | { |
---|
610 | if ( getUseAdaptiveQP() ) |
---|
611 | { |
---|
612 | TEncPic* pcEPic = new TEncPic; |
---|
613 | |
---|
614 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
615 | if(m_layerId > 0) |
---|
616 | { |
---|
617 | for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) |
---|
618 | { |
---|
619 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
620 | #if O0098_SCALED_REF_LAYER_ID |
---|
621 | const Window scalEL = getPPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
622 | #else |
---|
623 | const Window scalEL = getPPS()->getScaledRefLayerWindow(i); |
---|
624 | #endif |
---|
625 | #else |
---|
626 | #if O0098_SCALED_REF_LAYER_ID |
---|
627 | const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
628 | #else |
---|
629 | const Window scalEL = getSPS()->getScaledRefLayerWindow(i); |
---|
630 | #endif |
---|
631 | #endif |
---|
632 | #if REF_REGION_OFFSET |
---|
633 | const Window altRL = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
634 | #if RESAMPLING_FIX |
---|
635 | Bool equalOffsets = scalEL.hasEqualOffset(altRL); |
---|
636 | #if R0209_GENERIC_PHASE |
---|
637 | Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
638 | #endif |
---|
639 | #else |
---|
640 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 |
---|
641 | && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0); |
---|
642 | #endif |
---|
643 | #else |
---|
644 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
645 | #endif |
---|
646 | |
---|
647 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
648 | TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); |
---|
649 | #else |
---|
650 | TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); |
---|
651 | #endif |
---|
652 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
653 | UInt refLayerId = m_cVPS.getRefLayerId(m_layerId, i); |
---|
654 | Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] ); |
---|
655 | |
---|
656 | #if REF_IDX_MFM |
---|
657 | if( m_iSourceWidth == pcEncTopBase->getSourceWidth() && m_iSourceHeight == pcEncTopBase->getSourceHeight() && equalOffsets && zeroPhase ) |
---|
658 | { |
---|
659 | pcEPic->setEqualPictureSizeAndOffsetFlag( i, true ); |
---|
660 | } |
---|
661 | |
---|
662 | if( !pcEPic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths |
---|
663 | #else |
---|
664 | if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths |
---|
665 | #if REF_REGION_OFFSET && RESAMPLING_FIX |
---|
666 | || !equalOffsets |
---|
667 | #if R0209_GENERIC_PHASE |
---|
668 | || !zeroPhase |
---|
669 | #endif |
---|
670 | #else |
---|
671 | || !zeroOffsets |
---|
672 | #endif |
---|
673 | #endif |
---|
674 | #if Q0048_CGS_3D_ASYMLUT |
---|
675 | || m_cPPS.getCGSFlag() > 0 |
---|
676 | #endif |
---|
677 | #if LAYER_CTB |
---|
678 | || pcEncTopBase->getSPS()->getMaxCUWidth() != m_cSPS.getMaxCUWidth() || pcEncTopBase->getSPS()->getMaxCUHeight() != m_cSPS.getMaxCUHeight() || pcEncTopBase->getSPS()->getMaxCUDepth() != m_cSPS.getMaxCUDepth() |
---|
679 | #endif |
---|
680 | ) |
---|
681 | #else |
---|
682 | if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() |
---|
683 | #if REF_REGION_OFFSET && RESAMPLING_FIX |
---|
684 | || !equalOffsets |
---|
685 | #if R0209_GENERIC_PHASE |
---|
686 | || !zeroPhase |
---|
687 | #endif |
---|
688 | #else |
---|
689 | || !zeroOffsets |
---|
690 | #endif |
---|
691 | ) |
---|
692 | #endif |
---|
693 | { |
---|
694 | pcEPic->setSpatialEnhLayerFlag( i, true ); |
---|
695 | |
---|
696 | //only for scalable extension |
---|
697 | assert( m_cVPS.getScalabilityMask( SCALABILITY_ID ) == true ); |
---|
698 | } |
---|
699 | } |
---|
700 | } |
---|
701 | #endif |
---|
702 | |
---|
703 | #if SVC_EXTENSION |
---|
704 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 , |
---|
705 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
706 | #else //SVC_EXTENSION |
---|
707 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1, m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics); |
---|
708 | #endif //SVC_EXTENSION |
---|
709 | rpcPic = pcEPic; |
---|
710 | } |
---|
711 | else |
---|
712 | { |
---|
713 | rpcPic = new TComPic; |
---|
714 | |
---|
715 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
716 | if(m_layerId > 0) |
---|
717 | { |
---|
718 | for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) |
---|
719 | { |
---|
720 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
721 | #if O0098_SCALED_REF_LAYER_ID |
---|
722 | const Window scalEL = getPPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
723 | #else |
---|
724 | const Window scalEL = getPPS()->getScaledRefLayerWindow(i); |
---|
725 | #endif |
---|
726 | #else |
---|
727 | #if O0098_SCALED_REF_LAYER_ID |
---|
728 | const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
729 | #else |
---|
730 | const Window scalEL = getSPS()->getScaledRefLayerWindow(i); |
---|
731 | #endif |
---|
732 | #endif |
---|
733 | #if REF_REGION_OFFSET |
---|
734 | const Window altRL = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
735 | #if RESAMPLING_FIX |
---|
736 | Bool equalOffsets = scalEL.hasEqualOffset(altRL); |
---|
737 | #if R0209_GENERIC_PHASE |
---|
738 | Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i)); |
---|
739 | #endif |
---|
740 | #else |
---|
741 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 |
---|
742 | && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0); |
---|
743 | #endif |
---|
744 | #else |
---|
745 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
746 | #endif |
---|
747 | |
---|
748 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
749 | TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); |
---|
750 | #else |
---|
751 | TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); |
---|
752 | #endif |
---|
753 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
754 | UInt refLayerId = m_cVPS.getRefLayerId(m_layerId, i); |
---|
755 | Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] ); |
---|
756 | |
---|
757 | if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths |
---|
758 | #if REF_REGION_OFFSET && RESAMPLING_FIX |
---|
759 | || !equalOffsets |
---|
760 | #if R0209_GENERIC_PHASE |
---|
761 | || !zeroPhase |
---|
762 | #endif |
---|
763 | #else |
---|
764 | || !zeroOffsets |
---|
765 | #endif |
---|
766 | #if Q0048_CGS_3D_ASYMLUT |
---|
767 | || m_cPPS.getCGSFlag() > 0 |
---|
768 | #endif |
---|
769 | #if LAYER_CTB |
---|
770 | || pcEncTopBase->getSPS()->getMaxCUWidth() != m_cSPS.getMaxCUWidth() || pcEncTopBase->getSPS()->getMaxCUHeight() != m_cSPS.getMaxCUHeight() || pcEncTopBase->getSPS()->getMaxCUDepth() != m_cSPS.getMaxCUDepth() |
---|
771 | #endif |
---|
772 | ) |
---|
773 | #else |
---|
774 | if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() |
---|
775 | #if REF_REGION_OFFSET && RESAMPLING_FIX |
---|
776 | || !equalOffsets |
---|
777 | #if R0209_GENERIC_PHASE |
---|
778 | || !zeroPhase |
---|
779 | #endif |
---|
780 | #else |
---|
781 | || !zeroOffsets |
---|
782 | #endif |
---|
783 | ) |
---|
784 | #endif |
---|
785 | { |
---|
786 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
---|
787 | |
---|
788 | //only for scalable extension |
---|
789 | assert( m_cVPS.getScalabilityMask( SCALABILITY_ID ) == true ); |
---|
790 | } |
---|
791 | } |
---|
792 | } |
---|
793 | #endif |
---|
794 | |
---|
795 | #if SVC_EXTENSION |
---|
796 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
797 | m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS); |
---|
798 | #else //SVC_EXTENSION |
---|
799 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, false ); |
---|
800 | #endif //SVC_EXTENSION |
---|
801 | } |
---|
802 | |
---|
803 | m_cListPic.pushBack( rpcPic ); |
---|
804 | } |
---|
805 | rpcPic->setReconMark (false); |
---|
806 | |
---|
807 | m_iPOCLast++; |
---|
808 | m_iNumPicRcvd++; |
---|
809 | |
---|
810 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
---|
811 | // mark it should be extended |
---|
812 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
813 | } |
---|
814 | |
---|
815 | Void TEncTop::xInitSPS() |
---|
816 | { |
---|
817 | #if SVC_EXTENSION |
---|
818 | m_cSPS.setExtensionFlag( m_layerId > 0 ? true : false ); |
---|
819 | #if R0042_PROFILE_INDICATION |
---|
820 | m_cSPS.setNumDirectRefLayers(m_numAddLayerSets); |
---|
821 | #endif |
---|
822 | #if Q0078_ADD_LAYER_SETS |
---|
823 | if( !m_numDirectRefLayers && m_numAddLayerSets ) |
---|
824 | { |
---|
825 | m_cSPS.setLayerId(0); // layer ID 0 for independent layers |
---|
826 | } |
---|
827 | else |
---|
828 | { |
---|
829 | m_cSPS.setLayerId(m_layerId); |
---|
830 | } |
---|
831 | #else |
---|
832 | m_cSPS.setLayerId(m_layerId); |
---|
833 | #endif |
---|
834 | #if !MOVE_SCALED_OFFSET_TO_PPS |
---|
835 | m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets); |
---|
836 | for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++) |
---|
837 | { |
---|
838 | #if O0098_SCALED_REF_LAYER_ID |
---|
839 | m_cSPS.setScaledRefLayerId(i, m_scaledRefLayerId[i]); |
---|
840 | #endif |
---|
841 | m_cSPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i]; |
---|
842 | #if P0312_VERT_PHASE_ADJ |
---|
843 | m_cSPS.setVertPhasePositionEnableFlag( m_scaledRefLayerId[i], m_scaledRefLayerWindow[i].getVertPhasePositionEnableFlag() ); |
---|
844 | #endif |
---|
845 | } |
---|
846 | #endif |
---|
847 | #endif //SVC_EXTENSION |
---|
848 | ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL(); |
---|
849 | profileTierLevel.setLevelIdc(m_level); |
---|
850 | profileTierLevel.setTierFlag(m_levelTier); |
---|
851 | profileTierLevel.setProfileIdc(m_profile); |
---|
852 | profileTierLevel.setProfileCompatibilityFlag(m_profile, 1); |
---|
853 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
854 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
855 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
856 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
857 | profileTierLevel.setBitDepthConstraint(m_bitDepthConstraintValue); |
---|
858 | profileTierLevel.setChromaFormatConstraint(m_chromaFormatConstraintValue); |
---|
859 | profileTierLevel.setIntraConstraintFlag(m_intraConstraintFlag); |
---|
860 | profileTierLevel.setLowerBitRateConstraintFlag(m_lowerBitRateConstraintFlag); |
---|
861 | |
---|
862 | if ((m_profile == Profile::MAIN10) && (g_bitDepth[CHANNEL_TYPE_LUMA] == 8) && (g_bitDepth[CHANNEL_TYPE_CHROMA] == 8)) |
---|
863 | { |
---|
864 | /* The above constraint is equal to Profile::MAIN */ |
---|
865 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1); |
---|
866 | } |
---|
867 | if (m_profile == Profile::MAIN) |
---|
868 | { |
---|
869 | /* A Profile::MAIN10 decoder can always decode Profile::MAIN */ |
---|
870 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1); |
---|
871 | } |
---|
872 | /* XXX: should Main be marked as compatible with still picture? */ |
---|
873 | /* XXX: may be a good idea to refactor the above into a function |
---|
874 | * that chooses the actual compatibility based upon options */ |
---|
875 | |
---|
876 | m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); |
---|
877 | m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); |
---|
878 | m_cSPS.setConformanceWindow ( m_conformanceWindow ); |
---|
879 | m_cSPS.setMaxCUWidth ( g_uiMaxCUWidth ); |
---|
880 | m_cSPS.setMaxCUHeight ( g_uiMaxCUHeight ); |
---|
881 | m_cSPS.setMaxCUDepth ( g_uiMaxCUDepth ); |
---|
882 | m_cSPS.setChromaFormatIdc( m_chromaFormatIDC); |
---|
883 | |
---|
884 | Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth ); |
---|
885 | Int log2MinCUSize = 0; |
---|
886 | while(minCUSize > 1) |
---|
887 | { |
---|
888 | minCUSize >>= 1; |
---|
889 | log2MinCUSize++; |
---|
890 | } |
---|
891 | |
---|
892 | m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize); |
---|
893 | m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth-getMaxCUDepthOffset(m_cSPS.getChromaFormatIdc(), m_cSPS.getQuadtreeTULog2MinSize())); |
---|
894 | #if SVC_EXTENSION |
---|
895 | m_cSPS.setSPSId ( m_iSPSIdCnt ); |
---|
896 | #endif |
---|
897 | |
---|
898 | m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
---|
899 | m_cSPS.setUsePCM ( m_usePCM ); |
---|
900 | m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
---|
901 | |
---|
902 | m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
---|
903 | m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
---|
904 | m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
---|
905 | m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
---|
906 | |
---|
907 | m_cSPS.setTMVPFlagsPresent(false); |
---|
908 | |
---|
909 | m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
910 | |
---|
911 | Int i; |
---|
912 | |
---|
913 | for (i = 0; i < g_uiMaxCUDepth-g_uiAddCUDepth; i++ ) |
---|
914 | { |
---|
915 | m_cSPS.setAMPAcc( i, m_useAMP ); |
---|
916 | //m_cSPS.setAMPAcc( i, 1 ); |
---|
917 | } |
---|
918 | |
---|
919 | m_cSPS.setUseAMP ( m_useAMP ); |
---|
920 | |
---|
921 | for (i = g_uiMaxCUDepth-g_uiAddCUDepth; i < g_uiMaxCUDepth; i++ ) |
---|
922 | { |
---|
923 | m_cSPS.setAMPAcc(i, 0); |
---|
924 | } |
---|
925 | |
---|
926 | |
---|
927 | for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) |
---|
928 | { |
---|
929 | #if REPN_FORMAT_IN_VPS |
---|
930 | m_cSPS.setBitDepth (ChannelType(channelType), m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVps(ChannelType(channelType)) ); |
---|
931 | m_cSPS.setQpBDOffset (ChannelType(channelType), (6 * (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVps(ChannelType(channelType)) - 8))); |
---|
932 | #else |
---|
933 | m_cSPS.setBitDepth (ChannelType(channelType), g_bitDepth[channelType] ); |
---|
934 | m_cSPS.setQpBDOffset (ChannelType(channelType), (6 * (g_bitDepth[channelType] - 8))); |
---|
935 | #endif |
---|
936 | m_cSPS.setPCMBitDepth (ChannelType(channelType), g_PCMBitDepth[channelType] ); |
---|
937 | } |
---|
938 | |
---|
939 | m_cSPS.setUseExtendedPrecision(m_useExtendedPrecision); |
---|
940 | m_cSPS.setUseHighPrecisionPredictionWeighting(m_useHighPrecisionPredictionWeighting); |
---|
941 | |
---|
942 | m_cSPS.setUseSAO( m_bUseSAO ); |
---|
943 | m_cSPS.setUseResidualRotation(m_useResidualRotation); |
---|
944 | m_cSPS.setUseSingleSignificanceMapContext(m_useSingleSignificanceMapContext); |
---|
945 | m_cSPS.setUseGolombRiceParameterAdaptation(m_useGolombRiceParameterAdaptation); |
---|
946 | m_cSPS.setAlignCABACBeforeBypass(m_alignCABACBeforeBypass); |
---|
947 | |
---|
948 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
949 | { |
---|
950 | m_cSPS.setUseResidualDPCM(RDPCMSignallingMode(signallingModeIndex), m_useResidualDPCM[signallingModeIndex]); |
---|
951 | } |
---|
952 | |
---|
953 | m_cSPS.setMaxTLayers( m_maxTempLayer ); |
---|
954 | m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); |
---|
955 | |
---|
956 | for ( i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ ) |
---|
957 | { |
---|
958 | m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
---|
959 | m_cSPS.setNumReorderPics(m_numReorderPics[i], i); |
---|
960 | } |
---|
961 | |
---|
962 | m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
---|
963 | m_cSPS.setDisableIntraReferenceSmoothing( m_disableIntraReferenceSmoothing ); |
---|
964 | m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 ); |
---|
965 | m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
966 | m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); |
---|
967 | |
---|
968 | if (m_cSPS.getVuiParametersPresentFlag()) |
---|
969 | { |
---|
970 | TComVUI* pcVUI = m_cSPS.getVuiParameters(); |
---|
971 | pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag()); |
---|
972 | pcVUI->setAspectRatioIdc(getAspectRatioIdc()); |
---|
973 | pcVUI->setSarWidth(getSarWidth()); |
---|
974 | pcVUI->setSarHeight(getSarHeight()); |
---|
975 | pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag()); |
---|
976 | pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag()); |
---|
977 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag()); |
---|
978 | pcVUI->setVideoFormat(getVideoFormat()); |
---|
979 | pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag()); |
---|
980 | pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag()); |
---|
981 | pcVUI->setColourPrimaries(getColourPrimaries()); |
---|
982 | pcVUI->setTransferCharacteristics(getTransferCharacteristics()); |
---|
983 | pcVUI->setMatrixCoefficients(getMatrixCoefficients()); |
---|
984 | pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag()); |
---|
985 | pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField()); |
---|
986 | pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField()); |
---|
987 | pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag()); |
---|
988 | pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow()); |
---|
989 | pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag()); |
---|
990 | pcVUI->setFieldSeqFlag(false); |
---|
991 | pcVUI->setHrdParametersPresentFlag(false); |
---|
992 | pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); |
---|
993 | pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); |
---|
994 | pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag()); |
---|
995 | pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag()); |
---|
996 | pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag()); |
---|
997 | pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc()); |
---|
998 | pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom()); |
---|
999 | pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom()); |
---|
1000 | pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal()); |
---|
1001 | pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical()); |
---|
1002 | } |
---|
1003 | } |
---|
1004 | |
---|
1005 | Void TEncTop::xInitPPS() |
---|
1006 | { |
---|
1007 | m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
---|
1008 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
---|
1009 | |
---|
1010 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
1011 | { |
---|
1012 | bUseDQP = true; |
---|
1013 | } |
---|
1014 | |
---|
1015 | if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING) bUseDQP=false; |
---|
1016 | |
---|
1017 | if(bUseDQP) |
---|
1018 | { |
---|
1019 | m_cPPS.setUseDQP(true); |
---|
1020 | m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
---|
1021 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
1022 | } |
---|
1023 | else |
---|
1024 | { |
---|
1025 | m_cPPS.setUseDQP(false); |
---|
1026 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
1027 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
1028 | } |
---|
1029 | |
---|
1030 | if ( m_maxCUChromaQpAdjustmentDepth >= 0 ) |
---|
1031 | { |
---|
1032 | m_cPPS.setMaxCuChromaQpAdjDepth(m_maxCUChromaQpAdjustmentDepth); |
---|
1033 | m_cPPS.setChromaQpAdjTableAt(1, 6, 6); |
---|
1034 | /* todo, insert table entries from command line (NB, 0 should not be touched) */ |
---|
1035 | } |
---|
1036 | else |
---|
1037 | { |
---|
1038 | m_cPPS.setMaxCuChromaQpAdjDepth(0); |
---|
1039 | m_cPPS.clearChromaQpAdjTable(); |
---|
1040 | } |
---|
1041 | |
---|
1042 | if ( m_RCEnableRateControl ) |
---|
1043 | { |
---|
1044 | m_cPPS.setUseDQP(true); |
---|
1045 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
1046 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
1047 | } |
---|
1048 | |
---|
1049 | m_cPPS.setMinCuChromaQpAdjSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuChromaQpAdjDepth()) ); |
---|
1050 | |
---|
1051 | m_cPPS.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset ); |
---|
1052 | m_cPPS.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); |
---|
1053 | |
---|
1054 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams); |
---|
1055 | m_cPPS.setEntropyCodingSyncEnabledFlag( m_iWaveFrontSynchro > 0 ); |
---|
1056 | m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); |
---|
1057 | m_cPPS.setUseWP( m_useWeightedPred ); |
---|
1058 | m_cPPS.setWPBiPred( m_useWeightedBiPred ); |
---|
1059 | m_cPPS.setUseCrossComponentPrediction(m_useCrossComponentPrediction); |
---|
1060 | m_cPPS.setSaoOffsetBitShift(CHANNEL_TYPE_LUMA, m_saoOffsetBitShift[CHANNEL_TYPE_LUMA ]); |
---|
1061 | m_cPPS.setSaoOffsetBitShift(CHANNEL_TYPE_CHROMA, m_saoOffsetBitShift[CHANNEL_TYPE_CHROMA]); |
---|
1062 | m_cPPS.setOutputFlagPresentFlag( false ); |
---|
1063 | m_cPPS.setSignHideFlag(getSignHideFlag()); |
---|
1064 | if ( getDeblockingFilterMetric() ) |
---|
1065 | { |
---|
1066 | m_cPPS.setDeblockingFilterControlPresentFlag (true); |
---|
1067 | m_cPPS.setDeblockingFilterOverrideEnabledFlag(true); |
---|
1068 | m_cPPS.setPicDisableDeblockingFilterFlag(false); |
---|
1069 | m_cPPS.setDeblockingFilterBetaOffsetDiv2(0); |
---|
1070 | m_cPPS.setDeblockingFilterTcOffsetDiv2(0); |
---|
1071 | } |
---|
1072 | else |
---|
1073 | { |
---|
1074 | m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent ); |
---|
1075 | } |
---|
1076 | m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); |
---|
1077 | m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
---|
1078 | m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
1079 | |
---|
1080 | Int histogram[MAX_NUM_REF + 1]; |
---|
1081 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
1082 | { |
---|
1083 | histogram[i]=0; |
---|
1084 | } |
---|
1085 | for( Int i = 0; i < getGOPSize(); i++) |
---|
1086 | { |
---|
1087 | assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF); |
---|
1088 | histogram[getGOPEntry(i).m_numRefPicsActive]++; |
---|
1089 | } |
---|
1090 | |
---|
1091 | Int maxHist=-1; |
---|
1092 | Int bestPos=0; |
---|
1093 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
1094 | { |
---|
1095 | if(histogram[i]>maxHist) |
---|
1096 | { |
---|
1097 | maxHist=histogram[i]; |
---|
1098 | bestPos=i; |
---|
1099 | } |
---|
1100 | } |
---|
1101 | assert(bestPos <= 15); |
---|
1102 | m_cPPS.setNumRefIdxL0DefaultActive(bestPos); |
---|
1103 | m_cPPS.setNumRefIdxL1DefaultActive(bestPos); |
---|
1104 | m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag()); |
---|
1105 | m_cPPS.setUseTransformSkip( m_useTransformSkip ); |
---|
1106 | m_cPPS.setTransformSkipLog2MaxSize( m_transformSkipLog2MaxSize ); |
---|
1107 | |
---|
1108 | if (m_sliceSegmentMode != NO_SLICES) |
---|
1109 | { |
---|
1110 | m_cPPS.setDependentSliceSegmentsEnabledFlag( true ); |
---|
1111 | } |
---|
1112 | |
---|
1113 | #if SVC_EXTENSION |
---|
1114 | #if SCALINGLIST_INFERRING |
---|
1115 | m_cPPS.setLayerId( m_layerId ); |
---|
1116 | #endif |
---|
1117 | |
---|
1118 | #if Q0078_ADD_LAYER_SETS |
---|
1119 | if( !m_numDirectRefLayers && m_numAddLayerSets ) |
---|
1120 | { |
---|
1121 | m_cPPS.setLayerId(0); // layer ID 0 for independent layers |
---|
1122 | } |
---|
1123 | #endif |
---|
1124 | |
---|
1125 | if( m_layerId > 0 ) |
---|
1126 | { |
---|
1127 | m_cPPS.setListsModificationPresentFlag(true); |
---|
1128 | m_cPPS.setExtensionFlag(true); |
---|
1129 | } |
---|
1130 | else |
---|
1131 | { |
---|
1132 | m_cPPS.setListsModificationPresentFlag(false); |
---|
1133 | m_cPPS.setExtensionFlag(false); |
---|
1134 | } |
---|
1135 | |
---|
1136 | m_cPPS.setPPSId( m_iPPSIdCnt ); |
---|
1137 | m_cPPS.setSPSId( m_iSPSIdCnt ); |
---|
1138 | #if POC_RESET_FLAG |
---|
1139 | m_cPPS.setNumExtraSliceHeaderBits( 2 ); |
---|
1140 | #endif |
---|
1141 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
1142 | if (m_crossLayerBLAFlag) |
---|
1143 | { |
---|
1144 | m_cPPS.setNumExtraSliceHeaderBits( 3 ); |
---|
1145 | } |
---|
1146 | #endif |
---|
1147 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
1148 | m_cPPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets); |
---|
1149 | for(Int i = 0; i < m_cPPS.getNumScaledRefLayerOffsets(); i++) |
---|
1150 | { |
---|
1151 | #if O0098_SCALED_REF_LAYER_ID |
---|
1152 | m_cPPS.setScaledRefLayerId(i, m_scaledRefLayerId[i]); |
---|
1153 | #endif |
---|
1154 | m_cPPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i]; |
---|
1155 | #if REF_REGION_OFFSET |
---|
1156 | m_cPPS.getRefLayerWindow(i) = m_refLayerWindow[i]; |
---|
1157 | m_cPPS.setScaledRefLayerOffsetPresentFlag( m_scaledRefLayerId[i], m_scaledRefLayerOffsetPresentFlag[i] ); |
---|
1158 | m_cPPS.setRefRegionOffsetPresentFlag( m_scaledRefLayerId[i], m_refRegionOffsetPresentFlag[i] ); |
---|
1159 | #endif |
---|
1160 | #if R0209_GENERIC_PHASE |
---|
1161 | m_cPPS.setResamplePhaseSetPresentFlag( m_scaledRefLayerId[i], m_resamplePhaseSetPresentFlag[i] ); |
---|
1162 | m_cPPS.setPhaseHorLuma( m_scaledRefLayerId[i], m_phaseHorLuma[i] ); |
---|
1163 | m_cPPS.setPhaseVerLuma( m_scaledRefLayerId[i], m_phaseVerLuma[i] ); |
---|
1164 | m_cPPS.setPhaseHorChroma( m_scaledRefLayerId[i], m_phaseHorChroma[i] ); |
---|
1165 | m_cPPS.setPhaseVerChroma( m_scaledRefLayerId[i], m_phaseVerChroma[i] ); |
---|
1166 | #endif |
---|
1167 | #if P0312_VERT_PHASE_ADJ |
---|
1168 | m_cPPS.setVertPhasePositionEnableFlag( m_scaledRefLayerId[i], m_scaledRefLayerWindow[i].getVertPhasePositionEnableFlag() ); |
---|
1169 | #endif |
---|
1170 | } |
---|
1171 | #endif |
---|
1172 | #if Q0048_CGS_3D_ASYMLUT |
---|
1173 | m_cPPS.setCGSFlag( m_nCGSFlag ); |
---|
1174 | #endif |
---|
1175 | #if POC_RESET_IDC_ENCODER |
---|
1176 | m_cPPS.setPocResetInfoPresentFlag( true ); |
---|
1177 | m_cPPS.setExtensionFlag( true ); |
---|
1178 | m_cPPS.setSliceHeaderExtensionPresentFlag( true ); |
---|
1179 | #endif |
---|
1180 | #endif //SVC_EXTENSION |
---|
1181 | } |
---|
1182 | |
---|
1183 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
---|
1184 | Void TEncTop::xInitRPS(Bool isFieldCoding) |
---|
1185 | { |
---|
1186 | TComReferencePictureSet* rps; |
---|
1187 | |
---|
1188 | m_cSPS.createRPSList(getGOPSize() + m_extraRPSs + 1); |
---|
1189 | TComRPSList* rpsList = m_cSPS.getRPSList(); |
---|
1190 | |
---|
1191 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
---|
1192 | { |
---|
1193 | GOPEntry ge = getGOPEntry(i); |
---|
1194 | rps = rpsList->getReferencePictureSet(i); |
---|
1195 | rps->setNumberOfPictures(ge.m_numRefPics); |
---|
1196 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
1197 | Int numNeg = 0; |
---|
1198 | Int numPos = 0; |
---|
1199 | for( Int j = 0; j < ge.m_numRefPics; j++) |
---|
1200 | { |
---|
1201 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
---|
1202 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
---|
1203 | if(ge.m_referencePics[j]>0) |
---|
1204 | { |
---|
1205 | numPos++; |
---|
1206 | } |
---|
1207 | else |
---|
1208 | { |
---|
1209 | numNeg++; |
---|
1210 | } |
---|
1211 | } |
---|
1212 | rps->setNumberOfNegativePictures(numNeg); |
---|
1213 | rps->setNumberOfPositivePictures(numPos); |
---|
1214 | |
---|
1215 | // handle inter RPS intialization from the config file. |
---|
1216 | #if AUTO_INTER_RPS |
---|
1217 | rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0); // not very clean, converting anything > 0 to true. |
---|
1218 | rps->setDeltaRIdxMinus1(0); // index to the Reference RPS is always the previous one. |
---|
1219 | TComReferencePictureSet* RPSRef = rpsList->getReferencePictureSet(i-1); // get the reference RPS |
---|
1220 | |
---|
1221 | if (ge.m_interRPSPrediction == 2) // Automatic generation of the inter RPS idc based on the RIdx provided. |
---|
1222 | { |
---|
1223 | Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC; // the ref POC - current POC |
---|
1224 | Int numRefDeltaPOC = RPSRef->getNumberOfPictures(); |
---|
1225 | |
---|
1226 | rps->setDeltaRPS(deltaRPS); // set delta RPS |
---|
1227 | rps->setNumRefIdc(numRefDeltaPOC+1); // set the numRefIdc to the number of pictures in the reference RPS + 1. |
---|
1228 | Int count=0; |
---|
1229 | for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS. |
---|
1230 | { |
---|
1231 | Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0; // if it is the last decoded picture, set RefDeltaPOC = 0 |
---|
1232 | rps->setRefIdc(j, 0); |
---|
1233 | for (Int k = 0; k < rps->getNumberOfPictures(); k++ ) // cycle through pics in current RPS. |
---|
1234 | { |
---|
1235 | if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS)) // if the current RPS has a same picture as the reference RPS. |
---|
1236 | { |
---|
1237 | rps->setRefIdc(j, (rps->getUsed(k)?1:2)); |
---|
1238 | count++; |
---|
1239 | break; |
---|
1240 | } |
---|
1241 | } |
---|
1242 | } |
---|
1243 | if (count != rps->getNumberOfPictures()) |
---|
1244 | { |
---|
1245 | printf("Warning: Unable fully predict all delta POCs using the reference RPS index given in the config file. Setting Inter RPS to false for this RPS.\n"); |
---|
1246 | rps->setInterRPSPrediction(0); |
---|
1247 | } |
---|
1248 | } |
---|
1249 | else if (ge.m_interRPSPrediction == 1) // inter RPS idc based on the RefIdc values provided in config file. |
---|
1250 | { |
---|
1251 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
1252 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
1253 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1254 | { |
---|
1255 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
1256 | } |
---|
1257 | #if WRITE_BACK |
---|
1258 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
1259 | // computed from the RefIdc. A warning is printed if they are not identical. |
---|
1260 | numNeg = 0; |
---|
1261 | numPos = 0; |
---|
1262 | TComReferencePictureSet RPSTemp; // temporary variable |
---|
1263 | |
---|
1264 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1265 | { |
---|
1266 | if (ge.m_refIdc[j]) |
---|
1267 | { |
---|
1268 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
1269 | RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
1270 | RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
1271 | if (deltaPOC<0) |
---|
1272 | { |
---|
1273 | numNeg++; |
---|
1274 | } |
---|
1275 | else |
---|
1276 | { |
---|
1277 | numPos++; |
---|
1278 | } |
---|
1279 | } |
---|
1280 | } |
---|
1281 | if (numNeg != rps->getNumberOfNegativePictures()) |
---|
1282 | { |
---|
1283 | printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
1284 | rps->setNumberOfNegativePictures(numNeg); |
---|
1285 | rps->setNumberOfPictures(numNeg+numPos); |
---|
1286 | } |
---|
1287 | if (numPos != rps->getNumberOfPositivePictures()) |
---|
1288 | { |
---|
1289 | printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
1290 | rps->setNumberOfPositivePictures(numPos); |
---|
1291 | rps->setNumberOfPictures(numNeg+numPos); |
---|
1292 | } |
---|
1293 | RPSTemp.setNumberOfPictures(numNeg+numPos); |
---|
1294 | RPSTemp.setNumberOfNegativePictures(numNeg); |
---|
1295 | RPSTemp.sortDeltaPOC(); // sort the created delta POC before comparing |
---|
1296 | // check if Delta POC and Used are the same |
---|
1297 | // print warning if they are not. |
---|
1298 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1299 | { |
---|
1300 | if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j)) |
---|
1301 | { |
---|
1302 | printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n"); |
---|
1303 | rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j)); |
---|
1304 | } |
---|
1305 | if (RPSTemp.getUsed(j) != rps->getUsed(j)) |
---|
1306 | { |
---|
1307 | printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
1308 | rps->setUsed(j,RPSTemp.getUsed(j)); |
---|
1309 | } |
---|
1310 | } |
---|
1311 | #endif |
---|
1312 | } |
---|
1313 | #else |
---|
1314 | rps->setInterRPSPrediction(ge.m_interRPSPrediction); |
---|
1315 | if (ge.m_interRPSPrediction) |
---|
1316 | { |
---|
1317 | rps->setDeltaRIdxMinus1(0); |
---|
1318 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
1319 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
1320 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1321 | { |
---|
1322 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
1323 | } |
---|
1324 | #if WRITE_BACK |
---|
1325 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
1326 | // computed from the RefIdc. This is not necessary if both are identical. Currently there is no check to see if they are identical. |
---|
1327 | numNeg = 0; |
---|
1328 | numPos = 0; |
---|
1329 | TComReferencePictureSet* RPSRef = m_RPSList.getReferencePictureSet(i-1); |
---|
1330 | |
---|
1331 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1332 | { |
---|
1333 | if (ge.m_refIdc[j]) |
---|
1334 | { |
---|
1335 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
1336 | rps->setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
1337 | rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
1338 | if (deltaPOC<0) |
---|
1339 | { |
---|
1340 | numNeg++; |
---|
1341 | } |
---|
1342 | else |
---|
1343 | { |
---|
1344 | numPos++; |
---|
1345 | } |
---|
1346 | } |
---|
1347 | } |
---|
1348 | rps->setNumberOfNegativePictures(numNeg); |
---|
1349 | rps->setNumberOfPositivePictures(numPos); |
---|
1350 | rps->sortDeltaPOC(); |
---|
1351 | #endif |
---|
1352 | } |
---|
1353 | #endif //INTER_RPS_AUTO |
---|
1354 | } |
---|
1355 | //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file. |
---|
1356 | //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. |
---|
1357 | if (isFieldCoding) |
---|
1358 | { |
---|
1359 | rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); |
---|
1360 | rps->setNumberOfPictures(1); |
---|
1361 | rps->setNumberOfNegativePictures(1); |
---|
1362 | rps->setNumberOfPositivePictures(0); |
---|
1363 | rps->setNumberOfLongtermPictures(0); |
---|
1364 | rps->setDeltaPOC(0,-1); |
---|
1365 | rps->setPOC(0,0); |
---|
1366 | rps->setUsed(0,true); |
---|
1367 | rps->setInterRPSPrediction(false); |
---|
1368 | rps->setDeltaRIdxMinus1(0); |
---|
1369 | rps->setDeltaRPS(0); |
---|
1370 | rps->setNumRefIdc(0); |
---|
1371 | } |
---|
1372 | } |
---|
1373 | |
---|
1374 | // This is a function that |
---|
1375 | // determines what Reference Picture Set to use |
---|
1376 | // for a specific slice (with POC = POCCurr) |
---|
1377 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
1378 | { |
---|
1379 | slice->setRPSidx(GOPid); |
---|
1380 | |
---|
1381 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
1382 | { |
---|
1383 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
1384 | { |
---|
1385 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
1386 | if(POCIndex == 0) |
---|
1387 | { |
---|
1388 | POCIndex = m_uiIntraPeriod; |
---|
1389 | } |
---|
1390 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
1391 | { |
---|
1392 | slice->setRPSidx(extraNum); |
---|
1393 | } |
---|
1394 | } |
---|
1395 | else |
---|
1396 | { |
---|
1397 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
1398 | { |
---|
1399 | slice->setRPSidx(extraNum); |
---|
1400 | } |
---|
1401 | } |
---|
1402 | } |
---|
1403 | |
---|
1404 | if(POCCurr == 1 && slice->getPic()->isField()) |
---|
1405 | { |
---|
1406 | slice->setRPSidx(m_iGOPSize+m_extraRPSs); |
---|
1407 | } |
---|
1408 | |
---|
1409 | slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
---|
1410 | slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); |
---|
1411 | } |
---|
1412 | |
---|
1413 | Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
1414 | { |
---|
1415 | Int rpsIdx = GOPid; |
---|
1416 | |
---|
1417 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
1418 | { |
---|
1419 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
1420 | { |
---|
1421 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
1422 | if(POCIndex == 0) |
---|
1423 | { |
---|
1424 | POCIndex = m_uiIntraPeriod; |
---|
1425 | } |
---|
1426 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
1427 | { |
---|
1428 | rpsIdx = extraNum; |
---|
1429 | } |
---|
1430 | } |
---|
1431 | else |
---|
1432 | { |
---|
1433 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
1434 | { |
---|
1435 | rpsIdx = extraNum; |
---|
1436 | } |
---|
1437 | } |
---|
1438 | } |
---|
1439 | |
---|
1440 | return rpsIdx; |
---|
1441 | } |
---|
1442 | |
---|
1443 | Void TEncTop::xInitPPSforTiles() |
---|
1444 | { |
---|
1445 | m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag ); |
---|
1446 | m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
1447 | m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 ); |
---|
1448 | if( !m_tileUniformSpacingFlag ) |
---|
1449 | { |
---|
1450 | m_cPPS.setTileColumnWidth( m_tileColumnWidth ); |
---|
1451 | m_cPPS.setTileRowHeight( m_tileRowHeight ); |
---|
1452 | } |
---|
1453 | m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); |
---|
1454 | |
---|
1455 | // # substreams is "per tile" when tiles are independent. |
---|
1456 | if (m_iWaveFrontSynchro ) |
---|
1457 | { |
---|
1458 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)); |
---|
1459 | } |
---|
1460 | else |
---|
1461 | { |
---|
1462 | m_cPPS.setNumSubstreams((m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1)); |
---|
1463 | } |
---|
1464 | } |
---|
1465 | |
---|
1466 | Void TEncCfg::xCheckGSParameters() |
---|
1467 | { |
---|
1468 | Int iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth; |
---|
1469 | Int iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight; |
---|
1470 | UInt uiCummulativeColumnWidth = 0; |
---|
1471 | UInt uiCummulativeRowHeight = 0; |
---|
1472 | |
---|
1473 | //check the column relative parameters |
---|
1474 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
---|
1475 | { |
---|
1476 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
---|
1477 | exit( EXIT_FAILURE ); |
---|
1478 | } |
---|
1479 | |
---|
1480 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
---|
1481 | { |
---|
1482 | printf( "The current picture can not have so many columns.\n" ); |
---|
1483 | exit( EXIT_FAILURE ); |
---|
1484 | } |
---|
1485 | |
---|
1486 | if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag ) |
---|
1487 | { |
---|
1488 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
---|
1489 | { |
---|
1490 | uiCummulativeColumnWidth += m_tileColumnWidth[i]; |
---|
1491 | } |
---|
1492 | |
---|
1493 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
---|
1494 | { |
---|
1495 | printf( "The width of the column is too large.\n" ); |
---|
1496 | exit( EXIT_FAILURE ); |
---|
1497 | } |
---|
1498 | } |
---|
1499 | |
---|
1500 | //check the row relative parameters |
---|
1501 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
---|
1502 | { |
---|
1503 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
---|
1504 | exit( EXIT_FAILURE ); |
---|
1505 | } |
---|
1506 | |
---|
1507 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
---|
1508 | { |
---|
1509 | printf( "The current picture can not have so many rows.\n" ); |
---|
1510 | exit( EXIT_FAILURE ); |
---|
1511 | } |
---|
1512 | |
---|
1513 | if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag ) |
---|
1514 | { |
---|
1515 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
---|
1516 | uiCummulativeRowHeight += m_tileRowHeight[i]; |
---|
1517 | |
---|
1518 | if( uiCummulativeRowHeight >= iHeightInCU ) |
---|
1519 | { |
---|
1520 | printf( "The height of the row is too large.\n" ); |
---|
1521 | exit( EXIT_FAILURE ); |
---|
1522 | } |
---|
1523 | } |
---|
1524 | } |
---|
1525 | |
---|
1526 | #if SVC_EXTENSION |
---|
1527 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1528 | TEncTop* TEncTop::getRefLayerEnc( UInt refLayerIdc ) |
---|
1529 | { |
---|
1530 | if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 ) |
---|
1531 | { |
---|
1532 | return (TEncTop *)getLayerEnc( 0 ); |
---|
1533 | } |
---|
1534 | |
---|
1535 | return (TEncTop *)getLayerEnc( m_cVPS.getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
1536 | } |
---|
1537 | #endif |
---|
1538 | |
---|
1539 | #if !REPN_FORMAT_IN_VPS |
---|
1540 | Void TEncTop::xInitILRP() |
---|
1541 | { |
---|
1542 | if(m_layerId>0) |
---|
1543 | { |
---|
1544 | g_bitDepthY = m_cSPS.getBitDepthY(); |
---|
1545 | g_bitDepthC = m_cSPS.getBitDepthC(); |
---|
1546 | g_uiMaxCUWidth = m_cSPS.getMaxCUWidth(); |
---|
1547 | g_uiMaxCUHeight = m_cSPS.getMaxCUHeight(); |
---|
1548 | g_uiMaxCUDepth = m_cSPS.getMaxCUDepth(); |
---|
1549 | g_uiAddCUDepth = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() ); |
---|
1550 | |
---|
1551 | Int numReorderPics[MAX_TLAYER]; |
---|
1552 | Window &conformanceWindow = m_cSPS.getConformanceWindow(); |
---|
1553 | Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
1554 | |
---|
1555 | if (m_cIlpPic[0] == NULL) |
---|
1556 | { |
---|
1557 | for (Int j=0; j < m_numLayer; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
1558 | { |
---|
1559 | m_cIlpPic[j] = new TComPic; |
---|
1560 | #if AUXILIARY_PICTURES |
---|
1561 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
1562 | #else |
---|
1563 | m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
1564 | #endif |
---|
1565 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
1566 | { |
---|
1567 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
1568 | } |
---|
1569 | } |
---|
1570 | } |
---|
1571 | } |
---|
1572 | } |
---|
1573 | #else |
---|
1574 | Void TEncTop::xInitILRP() |
---|
1575 | { |
---|
1576 | #if O0096_REP_FORMAT_INDEX |
---|
1577 | RepFormat *repFormat = m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cSPS.getUpdateRepFormatFlag() ? m_cSPS.getUpdateRepFormatIndex() : m_layerId ) ); |
---|
1578 | #else |
---|
1579 | RepFormat *repFormat = m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) ); |
---|
1580 | #endif |
---|
1581 | Int bitDepthY,bitDepthC,picWidth,picHeight; |
---|
1582 | |
---|
1583 | #if O0096_REP_FORMAT_INDEX |
---|
1584 | bitDepthY = repFormat->getBitDepthVpsLuma(); |
---|
1585 | bitDepthC = repFormat->getBitDepthVpsChroma(); |
---|
1586 | picWidth = repFormat->getPicWidthVpsInLumaSamples(); |
---|
1587 | picHeight = repFormat->getPicHeightVpsInLumaSamples(); |
---|
1588 | #else |
---|
1589 | if( m_cSPS.getUpdateRepFormatFlag() ) |
---|
1590 | { |
---|
1591 | bitDepthY = m_cSPS.getBitDepthY(); |
---|
1592 | bitDepthC = m_cSPS.getBitDepthC(); |
---|
1593 | picWidth = m_cSPS.getPicWidthInLumaSamples(); |
---|
1594 | picHeight = m_cSPS.getPicHeightInLumaSamples(); |
---|
1595 | } |
---|
1596 | else |
---|
1597 | { |
---|
1598 | bitDepthY = repFormat->getBitDepthVpsLuma(); |
---|
1599 | bitDepthC = repFormat->getBitDepthVpsChroma(); |
---|
1600 | picWidth = repFormat->getPicWidthVpsInLumaSamples(); |
---|
1601 | picHeight = repFormat->getPicHeightVpsInLumaSamples(); |
---|
1602 | } |
---|
1603 | #endif |
---|
1604 | |
---|
1605 | if(m_layerId > 0) |
---|
1606 | { |
---|
1607 | g_bitDepth[CHANNEL_TYPE_LUMA] = bitDepthY; |
---|
1608 | g_bitDepth[CHANNEL_TYPE_CHROMA] = bitDepthC; |
---|
1609 | g_uiMaxCUWidth = m_cSPS.getMaxCUWidth(); |
---|
1610 | g_uiMaxCUHeight = m_cSPS.getMaxCUHeight(); |
---|
1611 | g_uiMaxCUDepth = m_cSPS.getMaxCUDepth(); |
---|
1612 | g_uiAddCUDepth = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() ); |
---|
1613 | |
---|
1614 | Int numReorderPics[MAX_TLAYER]; |
---|
1615 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
1616 | Window &conformanceWindow = repFormat->getConformanceWindowVps(); |
---|
1617 | #else |
---|
1618 | Window &conformanceWindow = m_cSPS.getConformanceWindow(); |
---|
1619 | #endif |
---|
1620 | Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
1621 | |
---|
1622 | if (m_cIlpPic[0] == NULL) |
---|
1623 | { |
---|
1624 | for (Int j=0; j < m_numDirectRefLayers; j++) |
---|
1625 | { |
---|
1626 | m_cIlpPic[j] = new TComPic; |
---|
1627 | #if AUXILIARY_PICTURES |
---|
1628 | m_cIlpPic[j]->create(picWidth, picHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
1629 | #else |
---|
1630 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); |
---|
1631 | #endif |
---|
1632 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++) |
---|
1633 | { |
---|
1634 | m_cIlpPic[j]->getPicSym()->getCtu(i)->initCtu(m_cIlpPic[j], i); |
---|
1635 | } |
---|
1636 | } |
---|
1637 | } |
---|
1638 | } |
---|
1639 | } |
---|
1640 | #endif |
---|
1641 | |
---|
1642 | #if O0098_SCALED_REF_LAYER_ID |
---|
1643 | Window& TEncTop::getScaledRefLayerWindowForLayer(Int layerId) |
---|
1644 | { |
---|
1645 | static Window win; |
---|
1646 | |
---|
1647 | for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) |
---|
1648 | { |
---|
1649 | if (layerId == m_scaledRefLayerId[i]) |
---|
1650 | { |
---|
1651 | return m_scaledRefLayerWindow[i]; |
---|
1652 | } |
---|
1653 | } |
---|
1654 | |
---|
1655 | win.resetWindow(); // scaled reference layer offsets are inferred to be zero when not present |
---|
1656 | return win; |
---|
1657 | } |
---|
1658 | #if REF_REGION_OFFSET |
---|
1659 | Window& TEncTop::getRefLayerWindowForLayer(Int layerId) |
---|
1660 | { |
---|
1661 | static Window win; |
---|
1662 | |
---|
1663 | for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) |
---|
1664 | { |
---|
1665 | if (layerId == m_refLayerId[i]) |
---|
1666 | { |
---|
1667 | return m_refLayerWindow[i]; |
---|
1668 | } |
---|
1669 | } |
---|
1670 | |
---|
1671 | win.resetWindow(); // reference offsets are inferred to be zero when not present |
---|
1672 | return win; |
---|
1673 | } |
---|
1674 | #endif |
---|
1675 | #endif |
---|
1676 | #endif //SVC_EXTENSION |
---|
1677 | //! \} |
---|