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