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