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-2016, 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 | #if NH_MV |
---|
46 | //#include "../../App/TAppEncoder/TAppEncTop.h" |
---|
47 | #endif |
---|
48 | |
---|
49 | //! \ingroup TLibEncoder |
---|
50 | //! \{ |
---|
51 | |
---|
52 | // ==================================================================================================================== |
---|
53 | // Constructor / destructor / create / destroy |
---|
54 | // ==================================================================================================================== |
---|
55 | |
---|
56 | TEncTop::TEncTop() |
---|
57 | { |
---|
58 | m_iPOCLast = -1; |
---|
59 | m_iNumPicRcvd = 0; |
---|
60 | m_uiNumAllPicCoded = 0; |
---|
61 | m_pppcRDSbacCoder = NULL; |
---|
62 | m_pppcBinCoderCABAC = NULL; |
---|
63 | m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC ); |
---|
64 | #if ENC_DEC_TRACE |
---|
65 | if (g_hTrace == NULL) |
---|
66 | { |
---|
67 | g_hTrace = fopen( "TraceEnc.txt", "wb" ); |
---|
68 | } |
---|
69 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
70 | g_nSymbolCounter = 0; |
---|
71 | #endif |
---|
72 | |
---|
73 | m_iMaxRefPicNum = 0; |
---|
74 | |
---|
75 | #if FAST_BIT_EST |
---|
76 | ContextModel::buildNextStateTable(); |
---|
77 | #endif |
---|
78 | #if NH_MV |
---|
79 | m_ivPicLists = NULL; |
---|
80 | #endif |
---|
81 | #if NH_3D_IC |
---|
82 | m_aICEnableCandidate = NULL; |
---|
83 | m_aICEnableNum = NULL; |
---|
84 | #endif |
---|
85 | #if NH_MV |
---|
86 | m_cCavlcCoder.setEncTop(this); |
---|
87 | #endif |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | TEncTop::~TEncTop() |
---|
92 | { |
---|
93 | #if NH_3D_FIX_LEAK |
---|
94 | #if NH_3D_IC |
---|
95 | if ( m_aICEnableCandidate != NULL ) |
---|
96 | { |
---|
97 | delete[] m_aICEnableCandidate; |
---|
98 | } |
---|
99 | |
---|
100 | if ( m_aICEnableNum != NULL ) |
---|
101 | { |
---|
102 | delete[] m_aICEnableNum; |
---|
103 | } |
---|
104 | #endif |
---|
105 | |
---|
106 | #endif |
---|
107 | #if ENC_DEC_TRACE |
---|
108 | if (g_hTrace != stdout) |
---|
109 | { |
---|
110 | fclose( g_hTrace ); |
---|
111 | } |
---|
112 | #endif |
---|
113 | } |
---|
114 | |
---|
115 | Void TEncTop::create () |
---|
116 | { |
---|
117 | #if !NH_MV |
---|
118 | // initialize global variables |
---|
119 | initROM(); |
---|
120 | #endif |
---|
121 | |
---|
122 | // create processing unit classes |
---|
123 | m_cGOPEncoder. create( ); |
---|
124 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth ); |
---|
125 | m_cCuEncoder. create( m_maxTotalCUDepth, m_maxCUWidth, m_maxCUHeight, m_chromaFormatIDC ); |
---|
126 | if (m_bUseSAO) |
---|
127 | { |
---|
128 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA], m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); |
---|
129 | m_cEncSAO.createEncData(getSaoCtuBoundary()); |
---|
130 | } |
---|
131 | #if ADAPTIVE_QP_SELECTION |
---|
132 | if (m_bUseAdaptQpSelect) |
---|
133 | { |
---|
134 | m_cTrQuant.initSliceQpDelta(); |
---|
135 | } |
---|
136 | #endif |
---|
137 | |
---|
138 | m_cLoopFilter.create( m_maxTotalCUDepth ); |
---|
139 | |
---|
140 | if ( m_RCEnableRateControl ) |
---|
141 | { |
---|
142 | #if KWU_RC_MADPRED_E0227 |
---|
143 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
---|
144 | g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() ); |
---|
145 | #else |
---|
146 | m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, (Int)( (Double)m_iFrameRate/m_temporalSubsampleRatio + 0.5), m_iGOPSize, m_iSourceWidth, m_iSourceHeight, |
---|
147 | m_maxCUWidth, m_maxCUHeight,m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); |
---|
148 | #endif |
---|
149 | } |
---|
150 | |
---|
151 | m_pppcRDSbacCoder = new TEncSbac** [m_maxTotalCUDepth+1]; |
---|
152 | #if FAST_BIT_EST |
---|
153 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [m_maxTotalCUDepth+1]; |
---|
154 | #else |
---|
155 | m_pppcBinCoderCABAC = new TEncBinCABAC** [m_maxTotalCUDepth+1]; |
---|
156 | #endif |
---|
157 | |
---|
158 | for ( Int iDepth = 0; iDepth < m_maxTotalCUDepth+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 | Void TEncTop::destroy () |
---|
181 | { |
---|
182 | // destroy processing unit classes |
---|
183 | m_cGOPEncoder. destroy(); |
---|
184 | m_cSliceEncoder. destroy(); |
---|
185 | m_cCuEncoder. destroy(); |
---|
186 | m_cEncSAO. destroyEncData(); |
---|
187 | m_cEncSAO. destroy(); |
---|
188 | m_cLoopFilter. destroy(); |
---|
189 | m_cRateCtrl. destroy(); |
---|
190 | m_cSearch. destroy(); |
---|
191 | Int iDepth; |
---|
192 | for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
---|
193 | { |
---|
194 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
195 | { |
---|
196 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
---|
197 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | for ( iDepth = 0; iDepth < m_maxTotalCUDepth+1; iDepth++ ) |
---|
202 | { |
---|
203 | delete [] m_pppcRDSbacCoder[iDepth]; |
---|
204 | delete [] m_pppcBinCoderCABAC[iDepth]; |
---|
205 | } |
---|
206 | |
---|
207 | delete [] m_pppcRDSbacCoder; |
---|
208 | delete [] m_pppcBinCoderCABAC; |
---|
209 | |
---|
210 | #if !NH_MV |
---|
211 | // destroy ROM |
---|
212 | destroyROM(); |
---|
213 | #endif |
---|
214 | |
---|
215 | return; |
---|
216 | } |
---|
217 | |
---|
218 | #if KWU_RC_MADPRED_E0227 |
---|
219 | Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding) |
---|
220 | #else |
---|
221 | Void TEncTop::init(Bool isFieldCoding) |
---|
222 | #endif |
---|
223 | { |
---|
224 | // initialize SPS |
---|
225 | #if H_3D |
---|
226 | // Assuming that all PPS indirectly refer to the same VPS via different SPS |
---|
227 | m_cSPS.setVPS(m_cVPS); |
---|
228 | #endif |
---|
229 | xInitSPS(); |
---|
230 | xInitVPS(); |
---|
231 | |
---|
232 | #if U0132_TARGET_BITS_SATURATION |
---|
233 | if (m_RCCpbSaturationEnabled) |
---|
234 | { |
---|
235 | m_cRateCtrl.initHrdParam(m_cSPS.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness); |
---|
236 | } |
---|
237 | #endif |
---|
238 | m_cRdCost.setCostMode(m_costMode); |
---|
239 | |
---|
240 | #if NH_MV |
---|
241 | // This seems to be incorrect, but irrelevant for the MV-HEVC |
---|
242 | *(m_cVPS->getPTL()) = *m_cSPS.getPTL(); |
---|
243 | m_cVPS->getTimingInfo()->setTimingInfoPresentFlag ( false ); |
---|
244 | #endif |
---|
245 | // initialize PPS |
---|
246 | xInitPPS(); |
---|
247 | xInitRPS(isFieldCoding); |
---|
248 | |
---|
249 | xInitPPSforTiles(); |
---|
250 | #if NH_3D_IC |
---|
251 | m_aICEnableCandidate = new Int[ 10 ]; |
---|
252 | m_aICEnableNum = new Int[ 10 ]; |
---|
253 | |
---|
254 | for(int i=0;i<10;i++) |
---|
255 | { |
---|
256 | m_aICEnableCandidate[i]=0; |
---|
257 | m_aICEnableNum[i]=0; |
---|
258 | } |
---|
259 | #endif |
---|
260 | |
---|
261 | // initialize processing unit classes |
---|
262 | m_cGOPEncoder. init( this ); |
---|
263 | m_cSliceEncoder.init( this ); |
---|
264 | m_cCuEncoder. init( this ); |
---|
265 | |
---|
266 | #if KWU_RC_MADPRED_E0227 |
---|
267 | m_pcTAppEncTop = pcTAppEncTop; |
---|
268 | #endif |
---|
269 | // initialize transform & quantization class |
---|
270 | m_pcCavlcCoder = getCavlcCoder(); |
---|
271 | |
---|
272 | m_cTrQuant.init( 1 << m_uiQuadtreeTULog2MaxSize, |
---|
273 | m_useRDOQ, |
---|
274 | m_useRDOQTS, |
---|
275 | #if T0196_SELECTIVE_RDOQ |
---|
276 | m_useSelectiveRDOQ, |
---|
277 | #endif |
---|
278 | true |
---|
279 | ,m_useTransformSkipFast |
---|
280 | #if ADAPTIVE_QP_SELECTION |
---|
281 | ,m_bUseAdaptQpSelect |
---|
282 | #endif |
---|
283 | ); |
---|
284 | |
---|
285 | // initialize encoder search class |
---|
286 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_motionEstimationSearchMethod, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
287 | |
---|
288 | m_iMaxRefPicNum = 0; |
---|
289 | |
---|
290 | xInitScalingLists(); |
---|
291 | } |
---|
292 | |
---|
293 | Void TEncTop::xInitScalingLists() |
---|
294 | { |
---|
295 | // Initialise scaling lists |
---|
296 | // The encoder will only use the SPS scaling lists. The PPS will never be marked present. |
---|
297 | const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] = |
---|
298 | { |
---|
299 | m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA), |
---|
300 | m_cSPS.getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA) |
---|
301 | }; |
---|
302 | if(getUseScalingListId() == SCALING_LIST_OFF) |
---|
303 | { |
---|
304 | getTrQuant()->setFlatScalingList(maxLog2TrDynamicRange, m_cSPS.getBitDepths()); |
---|
305 | getTrQuant()->setUseScalingList(false); |
---|
306 | m_cSPS.setScalingListPresentFlag(false); |
---|
307 | m_cPPS.setScalingListPresentFlag(false); |
---|
308 | } |
---|
309 | else if(getUseScalingListId() == SCALING_LIST_DEFAULT) |
---|
310 | { |
---|
311 | m_cSPS.getScalingList().setDefaultScalingList (); |
---|
312 | m_cSPS.setScalingListPresentFlag(false); |
---|
313 | m_cPPS.setScalingListPresentFlag(false); |
---|
314 | |
---|
315 | getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths()); |
---|
316 | getTrQuant()->setUseScalingList(true); |
---|
317 | } |
---|
318 | else if(getUseScalingListId() == SCALING_LIST_FILE_READ) |
---|
319 | { |
---|
320 | m_cSPS.getScalingList().setDefaultScalingList (); |
---|
321 | if(m_cSPS.getScalingList().xParseScalingList(getScalingListFileName())) |
---|
322 | { |
---|
323 | Bool bParsedScalingList=false; // Use of boolean so that assertion outputs useful string |
---|
324 | assert(bParsedScalingList); |
---|
325 | exit(1); |
---|
326 | } |
---|
327 | m_cSPS.getScalingList().checkDcOfMatrix(); |
---|
328 | m_cSPS.setScalingListPresentFlag(m_cSPS.getScalingList().checkDefaultScalingList()); |
---|
329 | m_cPPS.setScalingListPresentFlag(false); |
---|
330 | getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), maxLog2TrDynamicRange, m_cSPS.getBitDepths()); |
---|
331 | getTrQuant()->setUseScalingList(true); |
---|
332 | } |
---|
333 | else |
---|
334 | { |
---|
335 | printf("error : ScalingList == %d not supported\n",getUseScalingListId()); |
---|
336 | assert(0); |
---|
337 | } |
---|
338 | |
---|
339 | if (getUseScalingListId() != SCALING_LIST_OFF) |
---|
340 | { |
---|
341 | // Prepare delta's: |
---|
342 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
343 | { |
---|
344 | const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
345 | |
---|
346 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) |
---|
347 | { |
---|
348 | m_cSPS.getScalingList().checkPredMode( sizeId, listId ); |
---|
349 | } |
---|
350 | } |
---|
351 | } |
---|
352 | } |
---|
353 | |
---|
354 | // ==================================================================================================================== |
---|
355 | // Public member functions |
---|
356 | // ==================================================================================================================== |
---|
357 | |
---|
358 | #if NH_MV |
---|
359 | Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg ) |
---|
360 | { |
---|
361 | TComPic* pcPicCurr = NULL; |
---|
362 | |
---|
363 | // get original YUV |
---|
364 | xGetNewPicBuffer( pcPicCurr ); |
---|
365 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
366 | |
---|
367 | // compute image characteristics |
---|
368 | if ( getUseAdaptiveQP() ) |
---|
369 | { |
---|
370 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
371 | } |
---|
372 | pcPicCurr->setLayerId( getLayerId()); |
---|
373 | #if NH_3D |
---|
374 | pcPicCurr->setScaleOffset( m_cameraParameters->getCodedScale(), m_cameraParameters->getCodedOffset() ); |
---|
375 | #endif |
---|
376 | } |
---|
377 | #endif |
---|
378 | |
---|
379 | Void TEncTop::deletePicBuffer() |
---|
380 | { |
---|
381 | |
---|
382 | #if !NH_MV |
---|
383 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
384 | Int iSize = Int( m_cListPic.size() ); |
---|
385 | for ( Int i = 0; i < iSize; i++ ) |
---|
386 | { |
---|
387 | TComPic* pcPic = *(iterPic++); |
---|
388 | |
---|
389 | pcPic->destroy(); |
---|
390 | delete pcPic; |
---|
391 | pcPic = NULL; |
---|
392 | } |
---|
393 | #endif |
---|
394 | } |
---|
395 | |
---|
396 | /** |
---|
397 | - Application has picture buffer list with size of GOP + 1 |
---|
398 | - Picture buffer list acts like as ring buffer |
---|
399 | - End of the list has the latest picture |
---|
400 | . |
---|
401 | \param flush cause encoder to encode a partial GOP |
---|
402 | \param pcPicYuvOrg original YUV picture |
---|
403 | \param pcPicYuvTrueOrg |
---|
404 | \param snrCSC |
---|
405 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
---|
406 | \retval accessUnitsOut list of output access units |
---|
407 | \retval iNumEncoded number of encoded pictures |
---|
408 | */ |
---|
409 | #if NH_MV |
---|
410 | Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ) |
---|
411 | { |
---|
412 | #else |
---|
413 | Void TEncTop::encode( Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ) |
---|
414 | { |
---|
415 | #endif |
---|
416 | #if NH_3D |
---|
417 | TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() ); |
---|
418 | if( picLastCoded ) |
---|
419 | { |
---|
420 | picLastCoded->compressMotion(1); |
---|
421 | } |
---|
422 | #endif |
---|
423 | #if NH_MV |
---|
424 | if( gopId == 0) |
---|
425 | { |
---|
426 | m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb( getLayerId(), false )), rcListPicYuvRecOut, accessUnitsOut); |
---|
427 | #else |
---|
428 | if (pcPicYuvOrg != NULL) |
---|
429 | { |
---|
430 | // get original YUV |
---|
431 | TComPic* pcPicCurr = NULL; |
---|
432 | |
---|
433 | xGetNewPicBuffer( pcPicCurr ); |
---|
434 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
435 | pcPicYuvTrueOrg->copyToPic( pcPicCurr->getPicYuvTrueOrg() ); |
---|
436 | |
---|
437 | // compute image characteristics |
---|
438 | if ( getUseAdaptiveQP() ) |
---|
439 | { |
---|
440 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | if ((m_iNumPicRcvd == 0) || (!flush && (m_iPOCLast != 0) && (m_iNumPicRcvd != m_iGOPSize) && (m_iGOPSize != 0))) |
---|
445 | { |
---|
446 | iNumEncoded = 0; |
---|
447 | return; |
---|
448 | } |
---|
449 | #endif |
---|
450 | if ( m_RCEnableRateControl ) |
---|
451 | { |
---|
452 | m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); |
---|
453 | } |
---|
454 | #if NH_MV |
---|
455 | } |
---|
456 | m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, *(m_ivPicLists->getSubDpb(getLayerId(), false) ), rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE, gopId); |
---|
457 | |
---|
458 | if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) |
---|
459 | { |
---|
460 | #else |
---|
461 | // compress GOP |
---|
462 | m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false, snrCSC, m_printFrameMSE); |
---|
463 | #endif |
---|
464 | if ( m_RCEnableRateControl ) |
---|
465 | { |
---|
466 | m_cRateCtrl.destroyRCGOP(); |
---|
467 | } |
---|
468 | |
---|
469 | iNumEncoded = m_iNumPicRcvd; |
---|
470 | m_iNumPicRcvd = 0; |
---|
471 | m_uiNumAllPicCoded += iNumEncoded; |
---|
472 | #if NH_MV |
---|
473 | } |
---|
474 | #endif |
---|
475 | } |
---|
476 | |
---|
477 | /**------------------------------------------------ |
---|
478 | Separate interlaced frame into two fields |
---|
479 | -------------------------------------------------**/ |
---|
480 | Void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) |
---|
481 | { |
---|
482 | if (!isTop) |
---|
483 | { |
---|
484 | org += stride; |
---|
485 | } |
---|
486 | for (Int y = 0; y < height>>1; y++) |
---|
487 | { |
---|
488 | for (Int x = 0; x < width; x++) |
---|
489 | { |
---|
490 | dstField[x] = org[x]; |
---|
491 | } |
---|
492 | |
---|
493 | dstField += stride; |
---|
494 | org += stride*2; |
---|
495 | } |
---|
496 | |
---|
497 | } |
---|
498 | #if NH_MV |
---|
499 | Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, const InputColourSpaceConversion snrCSC, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff, Int gopId ) |
---|
500 | { |
---|
501 | assert( 0 ); // Field coding and multiview need to be further harmonized. |
---|
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, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, true); |
---|
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 | // Protected member functions |
---|
583 | // ==================================================================================================================== |
---|
584 | |
---|
585 | /** |
---|
586 | - Application has picture buffer list with size of GOP + 1 |
---|
587 | - Picture buffer list acts like as ring buffer |
---|
588 | - End of the list has the latest picture |
---|
589 | . |
---|
590 | \retval rpcPic obtained picture buffer |
---|
591 | */ |
---|
592 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) |
---|
593 | { |
---|
594 | // At this point, the SPS and PPS can be considered activated - they are copied to the new TComPic. |
---|
595 | |
---|
596 | #if NH_MV |
---|
597 | TComList<TComPic*>& cListPic = *(m_ivPicLists->getSubDpb(getLayerId(), false) ); |
---|
598 | TComSlice::sortPicList(cListPic); |
---|
599 | #else |
---|
600 | TComSlice::sortPicList(m_cListPic); |
---|
601 | #endif |
---|
602 | |
---|
603 | |
---|
604 | #if NH_MV |
---|
605 | if (cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
606 | { |
---|
607 | TComList<TComPic*>::iterator iterPic = cListPic.begin(); |
---|
608 | Int iSize = Int( cListPic.size() ); |
---|
609 | #else |
---|
610 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
611 | { |
---|
612 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
613 | Int iSize = Int( m_cListPic.size() ); |
---|
614 | #endif |
---|
615 | for ( Int i = 0; i < iSize; i++ ) |
---|
616 | { |
---|
617 | rpcPic = *(iterPic++); |
---|
618 | if(rpcPic->getSlice(0)->isReferenced() == false) |
---|
619 | { |
---|
620 | break; |
---|
621 | } |
---|
622 | } |
---|
623 | } |
---|
624 | else |
---|
625 | { |
---|
626 | if ( getUseAdaptiveQP() ) |
---|
627 | { |
---|
628 | TEncPic* pcEPic = new TEncPic; |
---|
629 | pcEPic->create( m_cSPS, m_cPPS, m_cPPS.getMaxCuDQPDepth()+1, false); |
---|
630 | rpcPic = pcEPic; |
---|
631 | } |
---|
632 | else |
---|
633 | { |
---|
634 | rpcPic = new TComPic; |
---|
635 | rpcPic->create( m_cSPS, m_cPPS, false ); |
---|
636 | } |
---|
637 | |
---|
638 | #if NH_MV |
---|
639 | cListPic.pushBack( rpcPic ); |
---|
640 | #else |
---|
641 | m_cListPic.pushBack( rpcPic ); |
---|
642 | #endif |
---|
643 | } |
---|
644 | rpcPic->setReconMark (false); |
---|
645 | |
---|
646 | m_iPOCLast++; |
---|
647 | m_iNumPicRcvd++; |
---|
648 | |
---|
649 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
---|
650 | // mark it should be extended |
---|
651 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
652 | #if NH_MV |
---|
653 | rpcPic->getPicYuvOrg()->setBorderExtension(false); |
---|
654 | #endif |
---|
655 | |
---|
656 | } |
---|
657 | |
---|
658 | Void TEncTop::xInitVPS() |
---|
659 | { |
---|
660 | // The SPS must have already been set up. |
---|
661 | // set the VPS profile information. |
---|
662 | #if NH_MV |
---|
663 | // Do initialization in TAppEncTop |
---|
664 | #else |
---|
665 | *m_cVPS.getPTL() = *m_cSPS.getPTL(); |
---|
666 | m_cVPS.setMaxOpSets(1); |
---|
667 | m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false ); |
---|
668 | m_cVPS.setNumHrdParameters( 0 ); |
---|
669 | |
---|
670 | m_cVPS.createHrdParamBuffer(); |
---|
671 | for( UInt i = 0; i < m_cVPS.getNumHrdParameters(); i ++ ) |
---|
672 | { |
---|
673 | m_cVPS.setHrdOpSetIdx( 0, i ); |
---|
674 | m_cVPS.setCprmsPresentFlag( false, i ); |
---|
675 | // Set up HrdParameters here. |
---|
676 | } |
---|
677 | #endif |
---|
678 | } |
---|
679 | |
---|
680 | Void TEncTop::xInitSPS() |
---|
681 | { |
---|
682 | #if NH_MV |
---|
683 | m_cSPS.setSPSId( getLayerIdInVps() ); |
---|
684 | m_cSPS.setLayerId( getLayerId() ); |
---|
685 | // Code below needs to be moved to VPS |
---|
686 | #endif |
---|
687 | ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL(); |
---|
688 | profileTierLevel.setLevelIdc(m_level); |
---|
689 | profileTierLevel.setTierFlag(m_levelTier); |
---|
690 | profileTierLevel.setProfileIdc(m_profile); |
---|
691 | profileTierLevel.setProfileCompatibilityFlag(m_profile, 1); |
---|
692 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
693 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
694 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
695 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
696 | profileTierLevel.setBitDepthConstraint(m_bitDepthConstraintValue); |
---|
697 | profileTierLevel.setChromaFormatConstraint(m_chromaFormatConstraintValue); |
---|
698 | profileTierLevel.setIntraConstraintFlag(m_intraConstraintFlag); |
---|
699 | profileTierLevel.setOnePictureOnlyConstraintFlag(m_onePictureOnlyConstraintFlag); |
---|
700 | profileTierLevel.setLowerBitRateConstraintFlag(m_lowerBitRateConstraintFlag); |
---|
701 | |
---|
702 | if ((m_profile == Profile::MAIN10) && (m_bitDepth[CHANNEL_TYPE_LUMA] == 8) && (m_bitDepth[CHANNEL_TYPE_CHROMA] == 8)) |
---|
703 | { |
---|
704 | /* The above constraint is equal to Profile::MAIN */ |
---|
705 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN, 1); |
---|
706 | } |
---|
707 | if (m_profile == Profile::MAIN) |
---|
708 | { |
---|
709 | /* A Profile::MAIN10 decoder can always decode Profile::MAIN */ |
---|
710 | profileTierLevel.setProfileCompatibilityFlag(Profile::MAIN10, 1); |
---|
711 | } |
---|
712 | /* XXX: should Main be marked as compatible with still picture? */ |
---|
713 | /* XXX: may be a good idea to refactor the above into a function |
---|
714 | * that chooses the actual compatibility based upon options */ |
---|
715 | #if NH_MV |
---|
716 | m_cSPS.setUpdateRepFormatFlag ( false ); |
---|
717 | Bool multiLayerExtensionFlag = ( getLayerId() > 0 ) && ( m_cVPS->getNumRefLayers( getLayerId() ) > 0 ); |
---|
718 | |
---|
719 | m_cSPS.setSpsExtOrMaxSubLayersMinus1( multiLayerExtensionFlag ? 7 : m_maxTempLayer - 1 ); |
---|
720 | if ( multiLayerExtensionFlag ) |
---|
721 | { |
---|
722 | m_cSPS.setSpsInferScalingListFlag ( true ); |
---|
723 | m_cSPS.setSpsScalingListRefLayerId( m_cVPS->getIdRefLayer( getLayerId(), 0 ) ); |
---|
724 | #if NH_MV |
---|
725 | if ( m_bUseDisparitySearchRangeRestriction ) |
---|
726 | { |
---|
727 | m_cSPS.setInterViewMvVertConstraintFlag ( true ) ; |
---|
728 | } |
---|
729 | #endif |
---|
730 | } |
---|
731 | m_cSPS.setSpsExtensionPresentFlag ( true ); |
---|
732 | m_cSPS.setSpsMultilayerExtensionFlag ( true ); |
---|
733 | #if NH_3D |
---|
734 | m_cSPS.setSps3dExtensionFlag ( true ); |
---|
735 | #endif |
---|
736 | #endif |
---|
737 | |
---|
738 | m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); |
---|
739 | m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); |
---|
740 | m_cSPS.setConformanceWindow ( m_conformanceWindow ); |
---|
741 | m_cSPS.setMaxCUWidth ( m_maxCUWidth ); |
---|
742 | m_cSPS.setMaxCUHeight ( m_maxCUHeight ); |
---|
743 | m_cSPS.setMaxTotalCUDepth ( m_maxTotalCUDepth ); |
---|
744 | #if NH_3D |
---|
745 | assert( !getIsDepth() || m_chromaFormatIDC == CHROMA_400 ); |
---|
746 | #endif |
---|
747 | m_cSPS.setChromaFormatIdc( m_chromaFormatIDC); |
---|
748 | m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize); |
---|
749 | |
---|
750 | Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getLog2DiffMaxMinCodingBlockSize() ); |
---|
751 | Int log2MinCUSize = 0; |
---|
752 | while(minCUSize > 1) |
---|
753 | { |
---|
754 | minCUSize >>= 1; |
---|
755 | log2MinCUSize++; |
---|
756 | } |
---|
757 | |
---|
758 | m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize); |
---|
759 | |
---|
760 | m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
---|
761 | m_cSPS.setUsePCM ( m_usePCM ); |
---|
762 | m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
---|
763 | |
---|
764 | m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
---|
765 | m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
---|
766 | m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
---|
767 | m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
---|
768 | |
---|
769 | m_cSPS.setTMVPFlagsPresent((getTMVPModeId() == 2 || getTMVPModeId() == 1)); |
---|
770 | |
---|
771 | m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
772 | |
---|
773 | m_cSPS.setUseAMP ( m_useAMP ); |
---|
774 | |
---|
775 | for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) |
---|
776 | { |
---|
777 | m_cSPS.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] ); |
---|
778 | #if O0043_BEST_EFFORT_DECODING |
---|
779 | m_cSPS.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] ); |
---|
780 | #endif |
---|
781 | m_cSPS.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8))); |
---|
782 | m_cSPS.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType] ); |
---|
783 | } |
---|
784 | #if NH_MV |
---|
785 | m_cSPS.inferRepFormat( m_cVPS, getLayerId(), true ); |
---|
786 | #endif |
---|
787 | m_cSPS.setUseSAO( m_bUseSAO ); |
---|
788 | |
---|
789 | m_cSPS.setMaxTLayers( m_maxTempLayer ); |
---|
790 | m_cSPS.setTemporalIdNestingFlag( ( m_maxTempLayer == 1 ) ? true : false ); |
---|
791 | |
---|
792 | for (Int i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ ) |
---|
793 | { |
---|
794 | m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
---|
795 | m_cSPS.setNumReorderPics(m_numReorderPics[i], i); |
---|
796 | } |
---|
797 | #if NH_MV |
---|
798 | for ( Int ols = 0; ols < m_cVPS->getNumOutputLayerSets(); ols++) |
---|
799 | { |
---|
800 | // Check MaxDecPicBuffering |
---|
801 | const std::vector<Int>& targetDecLayerIdList = m_cVPS->getTargetDecLayerIdList( m_cVPS->olsIdxToLsIdx( ols )); |
---|
802 | for( Int is = 0; is < targetDecLayerIdList.size(); is++ ) |
---|
803 | { |
---|
804 | if ( m_cVPS->getNecessaryLayerFlag( ols, is ) ) |
---|
805 | { |
---|
806 | m_cSPS.inferSpsMaxDecPicBufferingMinus1( m_cVPS, ols, targetDecLayerIdList[is], true ); |
---|
807 | } |
---|
808 | } |
---|
809 | } |
---|
810 | #endif |
---|
811 | |
---|
812 | |
---|
813 | m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
---|
814 | m_cSPS.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 ); |
---|
815 | m_cSPS.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
816 | m_cSPS.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); |
---|
817 | |
---|
818 | if (m_cSPS.getVuiParametersPresentFlag()) |
---|
819 | { |
---|
820 | TComVUI* pcVUI = m_cSPS.getVuiParameters(); |
---|
821 | pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag()); |
---|
822 | pcVUI->setAspectRatioIdc(getAspectRatioIdc()); |
---|
823 | pcVUI->setSarWidth(getSarWidth()); |
---|
824 | pcVUI->setSarHeight(getSarHeight()); |
---|
825 | pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag()); |
---|
826 | pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag()); |
---|
827 | #if NH_MV |
---|
828 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag() && getLayerId() == 0 ); |
---|
829 | #else |
---|
830 | pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag()); |
---|
831 | #endif |
---|
832 | pcVUI->setVideoFormat(getVideoFormat()); |
---|
833 | pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag()); |
---|
834 | pcVUI->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag()); |
---|
835 | pcVUI->setColourPrimaries(getColourPrimaries()); |
---|
836 | pcVUI->setTransferCharacteristics(getTransferCharacteristics()); |
---|
837 | pcVUI->setMatrixCoefficients(getMatrixCoefficients()); |
---|
838 | pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag()); |
---|
839 | pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField()); |
---|
840 | pcVUI->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField()); |
---|
841 | pcVUI->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag()); |
---|
842 | pcVUI->setDefaultDisplayWindow(getDefaultDisplayWindow()); |
---|
843 | pcVUI->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag()); |
---|
844 | pcVUI->setFieldSeqFlag(false); |
---|
845 | pcVUI->setHrdParametersPresentFlag(false); |
---|
846 | pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); |
---|
847 | pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); |
---|
848 | pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag()); |
---|
849 | pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag()); |
---|
850 | pcVUI->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag()); |
---|
851 | pcVUI->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc()); |
---|
852 | pcVUI->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom()); |
---|
853 | pcVUI->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom()); |
---|
854 | pcVUI->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal()); |
---|
855 | pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical()); |
---|
856 | } |
---|
857 | m_cSPS.setNumLongTermRefPicSPS(NUM_LONG_TERM_REF_PIC_SPS); |
---|
858 | assert (NUM_LONG_TERM_REF_PIC_SPS <= MAX_NUM_LONG_TERM_REF_PICS); |
---|
859 | for (Int k = 0; k < NUM_LONG_TERM_REF_PIC_SPS; k++) |
---|
860 | { |
---|
861 | m_cSPS.setLtRefPicPocLsbSps(k, 0); |
---|
862 | m_cSPS.setUsedByCurrPicLtSPSFlag(k, 0); |
---|
863 | } |
---|
864 | |
---|
865 | #if U0132_TARGET_BITS_SATURATION |
---|
866 | if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() || getCpbSaturationEnabled() ) |
---|
867 | #else |
---|
868 | if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) |
---|
869 | #endif |
---|
870 | { |
---|
871 | xInitHrdParameters(); |
---|
872 | } |
---|
873 | if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) |
---|
874 | { |
---|
875 | m_cSPS.getVuiParameters()->setHrdParametersPresentFlag( true ); |
---|
876 | } |
---|
877 | |
---|
878 | // Set up SPS range extension settings |
---|
879 | m_cSPS.getSpsRangeExtension().setTransformSkipRotationEnabledFlag(m_transformSkipRotationEnabledFlag); |
---|
880 | m_cSPS.getSpsRangeExtension().setTransformSkipContextEnabledFlag(m_transformSkipContextEnabledFlag); |
---|
881 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
882 | { |
---|
883 | m_cSPS.getSpsRangeExtension().setRdpcmEnabledFlag(RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); |
---|
884 | } |
---|
885 | m_cSPS.getSpsRangeExtension().setExtendedPrecisionProcessingFlag(m_extendedPrecisionProcessingFlag); |
---|
886 | m_cSPS.getSpsRangeExtension().setIntraSmoothingDisabledFlag( m_intraSmoothingDisabledFlag ); |
---|
887 | m_cSPS.getSpsRangeExtension().setHighPrecisionOffsetsEnabledFlag(m_highPrecisionOffsetsEnabledFlag); |
---|
888 | m_cSPS.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag); |
---|
889 | m_cSPS.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag); |
---|
890 | #if NH_MV |
---|
891 | m_cSPS.setSpsRangeExtensionsFlag( m_cSPS.getSpsRangeExtension().settingsDifferFromDefaults() ); |
---|
892 | #endif |
---|
893 | } |
---|
894 | #if U0132_TARGET_BITS_SATURATION |
---|
895 | // calculate scale value of bitrate and initial delay |
---|
896 | Int calcScale(Int x) |
---|
897 | { |
---|
898 | UInt iMask = 0xffffffff; |
---|
899 | Int ScaleValue = 32; |
---|
900 | |
---|
901 | while ((x&iMask) != 0) |
---|
902 | { |
---|
903 | ScaleValue--; |
---|
904 | iMask = (iMask >> 1); |
---|
905 | } |
---|
906 | |
---|
907 | return ScaleValue; |
---|
908 | } |
---|
909 | #endif |
---|
910 | Void TEncTop::xInitHrdParameters() |
---|
911 | { |
---|
912 | Bool useSubCpbParams = (getSliceMode() > 0) || (getSliceSegmentMode() > 0); |
---|
913 | Int bitRate = getTargetBitrate(); |
---|
914 | Bool isRandomAccess = getIntraPeriod() > 0; |
---|
915 | # if U0132_TARGET_BITS_SATURATION |
---|
916 | Int cpbSize = getCpbSize(); |
---|
917 | |
---|
918 | if( !getVuiParametersPresentFlag() && !getCpbSaturationEnabled() ) |
---|
919 | #else |
---|
920 | if( !getVuiParametersPresentFlag() ) |
---|
921 | #endif |
---|
922 | { |
---|
923 | return; |
---|
924 | } |
---|
925 | |
---|
926 | TComVUI *vui = m_cSPS.getVuiParameters(); |
---|
927 | TComHRD *hrd = vui->getHrdParameters(); |
---|
928 | |
---|
929 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
930 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
931 | switch( getFrameRate() ) |
---|
932 | { |
---|
933 | case 24: |
---|
934 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
935 | break; |
---|
936 | case 25: |
---|
937 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
938 | break; |
---|
939 | case 30: |
---|
940 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
941 | break; |
---|
942 | case 50: |
---|
943 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
944 | break; |
---|
945 | case 60: |
---|
946 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
947 | break; |
---|
948 | default: |
---|
949 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
950 | break; |
---|
951 | } |
---|
952 | |
---|
953 | if (getTemporalSubsampleRatio()>1) |
---|
954 | { |
---|
955 | UInt temporalSubsampleRatio = getTemporalSubsampleRatio(); |
---|
956 | if ( Double(timingInfo->getNumUnitsInTick()) * temporalSubsampleRatio > std::numeric_limits<UInt>::max() ) |
---|
957 | { |
---|
958 | timingInfo->setTimeScale( timingInfo->getTimeScale() / temporalSubsampleRatio ); |
---|
959 | } |
---|
960 | else |
---|
961 | { |
---|
962 | timingInfo->setNumUnitsInTick( timingInfo->getNumUnitsInTick() * temporalSubsampleRatio ); |
---|
963 | } |
---|
964 | } |
---|
965 | |
---|
966 | Bool rateCnt = ( bitRate > 0 ); |
---|
967 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
968 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
969 | |
---|
970 | hrd->setSubPicCpbParamsPresentFlag( useSubCpbParams ); |
---|
971 | |
---|
972 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
973 | { |
---|
974 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
975 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
976 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
977 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
978 | } |
---|
979 | else |
---|
980 | { |
---|
981 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
982 | } |
---|
983 | |
---|
984 | #if U0132_TARGET_BITS_SATURATION |
---|
985 | if (calcScale(bitRate) <= 6) |
---|
986 | { |
---|
987 | hrd->setBitRateScale(0); |
---|
988 | } |
---|
989 | else |
---|
990 | { |
---|
991 | hrd->setBitRateScale(calcScale(bitRate) - 6); |
---|
992 | } |
---|
993 | |
---|
994 | if (calcScale(cpbSize) <= 4) |
---|
995 | { |
---|
996 | hrd->setCpbSizeScale(0); |
---|
997 | } |
---|
998 | else |
---|
999 | { |
---|
1000 | hrd->setCpbSizeScale(calcScale(cpbSize) - 4); |
---|
1001 | } |
---|
1002 | #else |
---|
1003 | hrd->setBitRateScale( 4 ); // in units of 2^( 6 + 4 ) = 1,024 bps |
---|
1004 | hrd->setCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit |
---|
1005 | #endif |
---|
1006 | |
---|
1007 | hrd->setDuCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit |
---|
1008 | |
---|
1009 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
1010 | if( isRandomAccess ) |
---|
1011 | { |
---|
1012 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
1013 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
1014 | } |
---|
1015 | else |
---|
1016 | { |
---|
1017 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
1018 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
1019 | } |
---|
1020 | |
---|
1021 | // Note: parameters for all temporal layers are initialized with the same values |
---|
1022 | Int i, j; |
---|
1023 | UInt bitrateValue, cpbSizeValue; |
---|
1024 | UInt duCpbSizeValue; |
---|
1025 | UInt duBitRateValue = 0; |
---|
1026 | |
---|
1027 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
1028 | { |
---|
1029 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
1030 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
1031 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
1032 | hrd->setCpbCntMinus1( i, 0 ); |
---|
1033 | |
---|
1034 | //! \todo check for possible PTL violations |
---|
1035 | // BitRate[ i ] = ( bit_rate_value_minus1[ i ] + 1 ) * 2^( 6 + bit_rate_scale ) |
---|
1036 | bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) ); // bitRate is in bits, so it needs to be scaled down |
---|
1037 | // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) |
---|
1038 | #if U0132_TARGET_BITS_SATURATION |
---|
1039 | cpbSizeValue = cpbSize / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size |
---|
1040 | #else |
---|
1041 | cpbSizeValue = bitRate / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size |
---|
1042 | #endif |
---|
1043 | |
---|
1044 | |
---|
1045 | // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know |
---|
1046 | // in how many DUs the slice segment settings will result |
---|
1047 | duCpbSizeValue = bitrateValue; |
---|
1048 | duBitRateValue = cpbSizeValue; |
---|
1049 | |
---|
1050 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
1051 | { |
---|
1052 | hrd->setBitRateValueMinus1( i, j, 0, ( bitrateValue - 1 ) ); |
---|
1053 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
1054 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( duCpbSizeValue - 1 ) ); |
---|
1055 | hrd->setDuBitRateValueMinus1( i, j, 0, ( duBitRateValue - 1 ) ); |
---|
1056 | hrd->setCbrFlag( i, j, 0, false ); |
---|
1057 | |
---|
1058 | hrd->setBitRateValueMinus1( i, j, 1, ( bitrateValue - 1) ); |
---|
1059 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
1060 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( duCpbSizeValue - 1 ) ); |
---|
1061 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
1062 | hrd->setCbrFlag( i, j, 1, false ); |
---|
1063 | } |
---|
1064 | } |
---|
1065 | } |
---|
1066 | |
---|
1067 | |
---|
1068 | Void TEncTop::xInitPPS() |
---|
1069 | { |
---|
1070 | #if NH_MV |
---|
1071 | m_cPPS.setLayerId( getLayerId() ); |
---|
1072 | #if NH_3D |
---|
1073 | // Check if this condition is still correct |
---|
1074 | if( getVPS()->getNumRefListLayers( getLayerId() ) > 0 ) |
---|
1075 | #else |
---|
1076 | if( getVPS()->getNumDirectRefLayers( getLayerId() ) > 0 ) |
---|
1077 | #endif |
---|
1078 | { |
---|
1079 | m_cPPS.setListsModificationPresentFlag( true ); |
---|
1080 | } |
---|
1081 | m_cPPS.setPPSId( getLayerIdInVps() ); |
---|
1082 | m_cPPS.setSPSId( getLayerIdInVps() ); |
---|
1083 | m_cPPS.setPpsMultilayerExtensionFlag ( true ); |
---|
1084 | #if NH_3D |
---|
1085 | // Might be used for DLT |
---|
1086 | m_cPPS.setPps3dExtensionFlag ( getIsDepth() ); |
---|
1087 | #endif |
---|
1088 | #endif |
---|
1089 | |
---|
1090 | #if NH_3D_DLT |
---|
1091 | // create mapping from depth layer indexes to layer ids |
---|
1092 | Int j=0; |
---|
1093 | for( Int i=0; i<=getVPS()->getMaxLayersMinus1(); i++ ) |
---|
1094 | { |
---|
1095 | Int layerId = getVPS()->getLayerIdInNuh(i); |
---|
1096 | if( getVPS()->getDepthId(layerId) ) |
---|
1097 | m_cDLT.setDepthIdxToLayerId(j++, layerId); |
---|
1098 | } |
---|
1099 | m_cPPS.setDLT( m_cDLT ); |
---|
1100 | #endif |
---|
1101 | |
---|
1102 | m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
---|
1103 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
---|
1104 | |
---|
1105 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
1106 | { |
---|
1107 | bUseDQP = true; |
---|
1108 | } |
---|
1109 | |
---|
1110 | if (m_costMode==COST_SEQUENCE_LEVEL_LOSSLESS || m_costMode==COST_LOSSLESS_CODING) |
---|
1111 | { |
---|
1112 | bUseDQP=false; |
---|
1113 | } |
---|
1114 | |
---|
1115 | |
---|
1116 | if ( m_RCEnableRateControl ) |
---|
1117 | { |
---|
1118 | m_cPPS.setUseDQP(true); |
---|
1119 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
1120 | } |
---|
1121 | else if(bUseDQP) |
---|
1122 | { |
---|
1123 | m_cPPS.setUseDQP(true); |
---|
1124 | m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
---|
1125 | } |
---|
1126 | else |
---|
1127 | { |
---|
1128 | m_cPPS.setUseDQP(false); |
---|
1129 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
1130 | } |
---|
1131 | |
---|
1132 | if ( m_diffCuChromaQpOffsetDepth >= 0 ) |
---|
1133 | { |
---|
1134 | m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(m_diffCuChromaQpOffsetDepth); |
---|
1135 | m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList(); |
---|
1136 | m_cPPS.getPpsRangeExtension().setChromaQpOffsetListEntry(1, 6, 6); |
---|
1137 | /* todo, insert table entries from command line (NB, 0 should not be touched) */ |
---|
1138 | } |
---|
1139 | else |
---|
1140 | { |
---|
1141 | m_cPPS.getPpsRangeExtension().setDiffCuChromaQpOffsetDepth(0); |
---|
1142 | m_cPPS.getPpsRangeExtension().clearChromaQpOffsetList(); |
---|
1143 | } |
---|
1144 | m_cPPS.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag); |
---|
1145 | m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]); |
---|
1146 | m_cPPS.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]); |
---|
1147 | |
---|
1148 | m_cPPS.setQpOffset(COMPONENT_Cb, m_chromaCbQpOffset ); |
---|
1149 | m_cPPS.setQpOffset(COMPONENT_Cr, m_chromaCrQpOffset ); |
---|
1150 | #if W0038_CQP_ADJ |
---|
1151 | Bool bChromaDeltaQPEnabled = false; |
---|
1152 | { |
---|
1153 | bChromaDeltaQPEnabled = ( m_sliceChromaQpOffsetIntraOrPeriodic[0] || m_sliceChromaQpOffsetIntraOrPeriodic[1] ); |
---|
1154 | if( !bChromaDeltaQPEnabled ) |
---|
1155 | { |
---|
1156 | for( Int i=0; i<m_iGOPSize; i++ ) |
---|
1157 | { |
---|
1158 | if( m_GOPList[i].m_CbQPoffset || m_GOPList[i].m_CrQPoffset ) |
---|
1159 | { |
---|
1160 | bChromaDeltaQPEnabled = true; |
---|
1161 | break; |
---|
1162 | } |
---|
1163 | } |
---|
1164 | } |
---|
1165 | } |
---|
1166 | m_cPPS.setSliceChromaQpFlag(bChromaDeltaQPEnabled); |
---|
1167 | #endif |
---|
1168 | |
---|
1169 | m_cPPS.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag ); |
---|
1170 | m_cPPS.setTilesEnabledFlag( (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0) ); |
---|
1171 | m_cPPS.setUseWP( m_useWeightedPred ); |
---|
1172 | m_cPPS.setWPBiPred( m_useWeightedBiPred ); |
---|
1173 | m_cPPS.setOutputFlagPresentFlag( false ); |
---|
1174 | #if NH_MV |
---|
1175 | m_cPPS.setNumExtraSliceHeaderBits( 2 ); |
---|
1176 | #endif |
---|
1177 | m_cPPS.setSignHideFlag(getSignHideFlag()); |
---|
1178 | if ( getDeblockingFilterMetric() ) |
---|
1179 | { |
---|
1180 | m_cPPS.setDeblockingFilterOverrideEnabledFlag(true); |
---|
1181 | m_cPPS.setPicDisableDeblockingFilterFlag(false); |
---|
1182 | } |
---|
1183 | else |
---|
1184 | { |
---|
1185 | m_cPPS.setDeblockingFilterOverrideEnabledFlag( !getLoopFilterOffsetInPPS() ); |
---|
1186 | m_cPPS.setPicDisableDeblockingFilterFlag( getLoopFilterDisable() ); |
---|
1187 | } |
---|
1188 | |
---|
1189 | if (! m_cPPS.getPicDisableDeblockingFilterFlag()) |
---|
1190 | { |
---|
1191 | m_cPPS.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() ); |
---|
1192 | m_cPPS.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() ); |
---|
1193 | } |
---|
1194 | else |
---|
1195 | { |
---|
1196 | m_cPPS.setDeblockingFilterBetaOffsetDiv2(0); |
---|
1197 | m_cPPS.setDeblockingFilterTcOffsetDiv2(0); |
---|
1198 | } |
---|
1199 | |
---|
1200 | // deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values: |
---|
1201 | const Bool deblockingFilterControlPresentFlag = m_cPPS.getDeblockingFilterOverrideEnabledFlag() || |
---|
1202 | m_cPPS.getPicDisableDeblockingFilterFlag() || |
---|
1203 | m_cPPS.getDeblockingFilterBetaOffsetDiv2() != 0 || |
---|
1204 | m_cPPS.getDeblockingFilterTcOffsetDiv2() != 0; |
---|
1205 | |
---|
1206 | m_cPPS.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag); |
---|
1207 | |
---|
1208 | m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); |
---|
1209 | m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
---|
1210 | m_cPPS.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
1211 | |
---|
1212 | |
---|
1213 | Int histogram[MAX_NUM_REF + 1]; |
---|
1214 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
1215 | { |
---|
1216 | histogram[i]=0; |
---|
1217 | } |
---|
1218 | for( Int i = 0; i < getGOPSize(); i++) |
---|
1219 | { |
---|
1220 | assert(getGOPEntry(i).m_numRefPicsActive >= 0 && getGOPEntry(i).m_numRefPicsActive <= MAX_NUM_REF); |
---|
1221 | histogram[getGOPEntry(i).m_numRefPicsActive]++; |
---|
1222 | } |
---|
1223 | |
---|
1224 | Int maxHist=-1; |
---|
1225 | Int bestPos=0; |
---|
1226 | for( Int i = 0; i <= MAX_NUM_REF; i++ ) |
---|
1227 | { |
---|
1228 | if(histogram[i]>maxHist) |
---|
1229 | { |
---|
1230 | maxHist=histogram[i]; |
---|
1231 | bestPos=i; |
---|
1232 | } |
---|
1233 | } |
---|
1234 | assert(bestPos <= 15); |
---|
1235 | m_cPPS.setNumRefIdxL0DefaultActive(bestPos); |
---|
1236 | m_cPPS.setNumRefIdxL1DefaultActive(bestPos); |
---|
1237 | m_cPPS.setTransquantBypassEnableFlag(getTransquantBypassEnableFlag()); |
---|
1238 | m_cPPS.setUseTransformSkip( m_useTransformSkip ); |
---|
1239 | m_cPPS.getPpsRangeExtension().setLog2MaxTransformSkipBlockSize( m_log2MaxTransformSkipBlockSize ); |
---|
1240 | |
---|
1241 | if (m_sliceSegmentMode != NO_SLICES) |
---|
1242 | { |
---|
1243 | m_cPPS.setDependentSliceSegmentsEnabledFlag( true ); |
---|
1244 | } |
---|
1245 | } |
---|
1246 | |
---|
1247 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
---|
1248 | Void TEncTop::xInitRPS(Bool isFieldCoding) |
---|
1249 | { |
---|
1250 | TComReferencePictureSet* rps; |
---|
1251 | |
---|
1252 | m_cSPS.createRPSList(getGOPSize() + m_extraRPSs + 1); |
---|
1253 | TComRPSList* rpsList = m_cSPS.getRPSList(); |
---|
1254 | |
---|
1255 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
---|
1256 | { |
---|
1257 | GOPEntry ge = getGOPEntry(i); |
---|
1258 | rps = rpsList->getReferencePictureSet(i); |
---|
1259 | rps->setNumberOfPictures(ge.m_numRefPics); |
---|
1260 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
1261 | Int numNeg = 0; |
---|
1262 | Int numPos = 0; |
---|
1263 | for( Int j = 0; j < ge.m_numRefPics; j++) |
---|
1264 | { |
---|
1265 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
---|
1266 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
---|
1267 | if(ge.m_referencePics[j]>0) |
---|
1268 | { |
---|
1269 | numPos++; |
---|
1270 | } |
---|
1271 | else |
---|
1272 | { |
---|
1273 | numNeg++; |
---|
1274 | } |
---|
1275 | } |
---|
1276 | rps->setNumberOfNegativePictures(numNeg); |
---|
1277 | rps->setNumberOfPositivePictures(numPos); |
---|
1278 | |
---|
1279 | // handle inter RPS intialization from the config file. |
---|
1280 | rps->setInterRPSPrediction(ge.m_interRPSPrediction > 0); // not very clean, converting anything > 0 to true. |
---|
1281 | rps->setDeltaRIdxMinus1(0); // index to the Reference RPS is always the previous one. |
---|
1282 | TComReferencePictureSet* RPSRef = i>0 ? rpsList->getReferencePictureSet(i-1): NULL; // get the reference RPS |
---|
1283 | |
---|
1284 | if (ge.m_interRPSPrediction == 2) // Automatic generation of the inter RPS idc based on the RIdx provided. |
---|
1285 | { |
---|
1286 | assert (RPSRef!=NULL); |
---|
1287 | Int deltaRPS = getGOPEntry(i-1).m_POC - ge.m_POC; // the ref POC - current POC |
---|
1288 | Int numRefDeltaPOC = RPSRef->getNumberOfPictures(); |
---|
1289 | |
---|
1290 | rps->setDeltaRPS(deltaRPS); // set delta RPS |
---|
1291 | rps->setNumRefIdc(numRefDeltaPOC+1); // set the numRefIdc to the number of pictures in the reference RPS + 1. |
---|
1292 | Int count=0; |
---|
1293 | for (Int j = 0; j <= numRefDeltaPOC; j++ ) // cycle through pics in reference RPS. |
---|
1294 | { |
---|
1295 | Int RefDeltaPOC = (j<numRefDeltaPOC)? RPSRef->getDeltaPOC(j): 0; // if it is the last decoded picture, set RefDeltaPOC = 0 |
---|
1296 | rps->setRefIdc(j, 0); |
---|
1297 | for (Int k = 0; k < rps->getNumberOfPictures(); k++ ) // cycle through pics in current RPS. |
---|
1298 | { |
---|
1299 | if (rps->getDeltaPOC(k) == ( RefDeltaPOC + deltaRPS)) // if the current RPS has a same picture as the reference RPS. |
---|
1300 | { |
---|
1301 | rps->setRefIdc(j, (rps->getUsed(k)?1:2)); |
---|
1302 | count++; |
---|
1303 | break; |
---|
1304 | } |
---|
1305 | } |
---|
1306 | } |
---|
1307 | if (count != rps->getNumberOfPictures()) |
---|
1308 | { |
---|
1309 | 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"); |
---|
1310 | rps->setInterRPSPrediction(0); |
---|
1311 | } |
---|
1312 | } |
---|
1313 | else if (ge.m_interRPSPrediction == 1) // inter RPS idc based on the RefIdc values provided in config file. |
---|
1314 | { |
---|
1315 | assert (RPSRef!=NULL); |
---|
1316 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
1317 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
1318 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1319 | { |
---|
1320 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
1321 | } |
---|
1322 | // the following code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
1323 | // computed from the RefIdc. A warning is printed if they are not identical. |
---|
1324 | numNeg = 0; |
---|
1325 | numPos = 0; |
---|
1326 | TComReferencePictureSet RPSTemp; // temporary variable |
---|
1327 | |
---|
1328 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1329 | { |
---|
1330 | if (ge.m_refIdc[j]) |
---|
1331 | { |
---|
1332 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
1333 | RPSTemp.setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
1334 | RPSTemp.setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
1335 | if (deltaPOC<0) |
---|
1336 | { |
---|
1337 | numNeg++; |
---|
1338 | } |
---|
1339 | else |
---|
1340 | { |
---|
1341 | numPos++; |
---|
1342 | } |
---|
1343 | } |
---|
1344 | } |
---|
1345 | if (numNeg != rps->getNumberOfNegativePictures()) |
---|
1346 | { |
---|
1347 | printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
1348 | rps->setNumberOfNegativePictures(numNeg); |
---|
1349 | rps->setNumberOfPictures(numNeg+numPos); |
---|
1350 | } |
---|
1351 | if (numPos != rps->getNumberOfPositivePictures()) |
---|
1352 | { |
---|
1353 | printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
1354 | rps->setNumberOfPositivePictures(numPos); |
---|
1355 | rps->setNumberOfPictures(numNeg+numPos); |
---|
1356 | } |
---|
1357 | RPSTemp.setNumberOfPictures(numNeg+numPos); |
---|
1358 | RPSTemp.setNumberOfNegativePictures(numNeg); |
---|
1359 | RPSTemp.sortDeltaPOC(); // sort the created delta POC before comparing |
---|
1360 | // check if Delta POC and Used are the same |
---|
1361 | // print warning if they are not. |
---|
1362 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
1363 | { |
---|
1364 | if (RPSTemp.getDeltaPOC(j) != rps->getDeltaPOC(j)) |
---|
1365 | { |
---|
1366 | printf("Warning: delta POC is different between intra RPS and inter RPS specified in the config file.\n"); |
---|
1367 | rps->setDeltaPOC(j,RPSTemp.getDeltaPOC(j)); |
---|
1368 | } |
---|
1369 | if (RPSTemp.getUsed(j) != rps->getUsed(j)) |
---|
1370 | { |
---|
1371 | printf("Warning: Used by Current in RPS is different between intra and inter RPS specified in the config file.\n"); |
---|
1372 | rps->setUsed(j,RPSTemp.getUsed(j)); |
---|
1373 | } |
---|
1374 | } |
---|
1375 | } |
---|
1376 | } |
---|
1377 | //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. |
---|
1378 | //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. |
---|
1379 | if (isFieldCoding) |
---|
1380 | { |
---|
1381 | rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); |
---|
1382 | rps->setNumberOfPictures(1); |
---|
1383 | rps->setNumberOfNegativePictures(1); |
---|
1384 | rps->setNumberOfPositivePictures(0); |
---|
1385 | rps->setNumberOfLongtermPictures(0); |
---|
1386 | rps->setDeltaPOC(0,-1); |
---|
1387 | rps->setPOC(0,0); |
---|
1388 | rps->setUsed(0,true); |
---|
1389 | rps->setInterRPSPrediction(false); |
---|
1390 | rps->setDeltaRIdxMinus1(0); |
---|
1391 | rps->setDeltaRPS(0); |
---|
1392 | rps->setNumRefIdc(0); |
---|
1393 | } |
---|
1394 | } |
---|
1395 | |
---|
1396 | // This is a function that |
---|
1397 | // determines what Reference Picture Set to use |
---|
1398 | // for a specific slice (with POC = POCCurr) |
---|
1399 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ) |
---|
1400 | { |
---|
1401 | #if NH_MV |
---|
1402 | if( slice->getRapPicFlag() == true && getLayerId() > 0 && POCCurr == 0 ) |
---|
1403 | { |
---|
1404 | TComReferencePictureSet* rps = slice->getLocalRPS(); |
---|
1405 | rps->setNumberOfNegativePictures(0); |
---|
1406 | rps->setNumberOfPositivePictures(0); |
---|
1407 | rps->setNumberOfLongtermPictures(0); |
---|
1408 | rps->setNumberOfPictures(0); |
---|
1409 | slice->setRPS(rps); |
---|
1410 | } |
---|
1411 | else |
---|
1412 | { |
---|
1413 | #endif |
---|
1414 | slice->setRPSidx(GOPid); |
---|
1415 | |
---|
1416 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
1417 | { |
---|
1418 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
1419 | { |
---|
1420 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
1421 | if(POCIndex == 0) |
---|
1422 | { |
---|
1423 | POCIndex = m_uiIntraPeriod; |
---|
1424 | } |
---|
1425 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
1426 | { |
---|
1427 | slice->setRPSidx(extraNum); |
---|
1428 | } |
---|
1429 | } |
---|
1430 | else |
---|
1431 | { |
---|
1432 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
1433 | { |
---|
1434 | slice->setRPSidx(extraNum); |
---|
1435 | } |
---|
1436 | } |
---|
1437 | } |
---|
1438 | |
---|
1439 | if(POCCurr == 1 && slice->getPic()->isField()) |
---|
1440 | { |
---|
1441 | slice->setRPSidx(m_iGOPSize+m_extraRPSs); |
---|
1442 | } |
---|
1443 | |
---|
1444 | const TComReferencePictureSet *rps = (slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
---|
1445 | slice->setRPS(rps); |
---|
1446 | #if NH_MV |
---|
1447 | } |
---|
1448 | #endif |
---|
1449 | |
---|
1450 | } |
---|
1451 | |
---|
1452 | Int TEncTop::getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid ) |
---|
1453 | { |
---|
1454 | Int rpsIdx = GOPid; |
---|
1455 | |
---|
1456 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
1457 | { |
---|
1458 | if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0) |
---|
1459 | { |
---|
1460 | Int POCIndex = POCCurr%m_uiIntraPeriod; |
---|
1461 | if(POCIndex == 0) |
---|
1462 | { |
---|
1463 | POCIndex = m_uiIntraPeriod; |
---|
1464 | } |
---|
1465 | if(POCIndex == m_GOPList[extraNum].m_POC) |
---|
1466 | { |
---|
1467 | rpsIdx = extraNum; |
---|
1468 | } |
---|
1469 | } |
---|
1470 | else |
---|
1471 | { |
---|
1472 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
1473 | { |
---|
1474 | rpsIdx = extraNum; |
---|
1475 | } |
---|
1476 | } |
---|
1477 | } |
---|
1478 | |
---|
1479 | return rpsIdx; |
---|
1480 | } |
---|
1481 | |
---|
1482 | Void TEncTop::xInitPPSforTiles() |
---|
1483 | { |
---|
1484 | m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag ); |
---|
1485 | m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
1486 | m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 ); |
---|
1487 | if( !m_tileUniformSpacingFlag ) |
---|
1488 | { |
---|
1489 | m_cPPS.setTileColumnWidth( m_tileColumnWidth ); |
---|
1490 | m_cPPS.setTileRowHeight( m_tileRowHeight ); |
---|
1491 | } |
---|
1492 | m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); |
---|
1493 | |
---|
1494 | // # substreams is "per tile" when tiles are independent. |
---|
1495 | } |
---|
1496 | |
---|
1497 | Void TEncCfg::xCheckGSParameters() |
---|
1498 | { |
---|
1499 | Int iWidthInCU = ( m_iSourceWidth%m_maxCUWidth ) ? m_iSourceWidth/m_maxCUWidth + 1 : m_iSourceWidth/m_maxCUWidth; |
---|
1500 | Int iHeightInCU = ( m_iSourceHeight%m_maxCUHeight ) ? m_iSourceHeight/m_maxCUHeight + 1 : m_iSourceHeight/m_maxCUHeight; |
---|
1501 | UInt uiCummulativeColumnWidth = 0; |
---|
1502 | UInt uiCummulativeRowHeight = 0; |
---|
1503 | |
---|
1504 | //check the column relative parameters |
---|
1505 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
---|
1506 | { |
---|
1507 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
---|
1508 | exit( EXIT_FAILURE ); |
---|
1509 | } |
---|
1510 | |
---|
1511 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
---|
1512 | { |
---|
1513 | printf( "The current picture can not have so many columns.\n" ); |
---|
1514 | exit( EXIT_FAILURE ); |
---|
1515 | } |
---|
1516 | |
---|
1517 | if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag ) |
---|
1518 | { |
---|
1519 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
---|
1520 | { |
---|
1521 | uiCummulativeColumnWidth += m_tileColumnWidth[i]; |
---|
1522 | } |
---|
1523 | |
---|
1524 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
---|
1525 | { |
---|
1526 | printf( "The width of the column is too large.\n" ); |
---|
1527 | exit( EXIT_FAILURE ); |
---|
1528 | } |
---|
1529 | } |
---|
1530 | |
---|
1531 | //check the row relative parameters |
---|
1532 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
---|
1533 | { |
---|
1534 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
---|
1535 | exit( EXIT_FAILURE ); |
---|
1536 | } |
---|
1537 | |
---|
1538 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
---|
1539 | { |
---|
1540 | printf( "The current picture can not have so many rows.\n" ); |
---|
1541 | exit( EXIT_FAILURE ); |
---|
1542 | } |
---|
1543 | |
---|
1544 | if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag ) |
---|
1545 | { |
---|
1546 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
---|
1547 | { |
---|
1548 | uiCummulativeRowHeight += m_tileRowHeight[i]; |
---|
1549 | } |
---|
1550 | |
---|
1551 | if( uiCummulativeRowHeight >= iHeightInCU ) |
---|
1552 | { |
---|
1553 | printf( "The height of the row is too large.\n" ); |
---|
1554 | exit( EXIT_FAILURE ); |
---|
1555 | } |
---|
1556 | } |
---|
1557 | } |
---|
1558 | |
---|
1559 | #if NH_MV |
---|
1560 | Int TEncTop::getFrameId(Int iGOPid) |
---|
1561 | { |
---|
1562 | if(m_iPOCLast == 0) |
---|
1563 | { |
---|
1564 | return(0 ); |
---|
1565 | } |
---|
1566 | else |
---|
1567 | { |
---|
1568 | return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ; |
---|
1569 | } |
---|
1570 | } |
---|
1571 | |
---|
1572 | TComPic* TEncTop::getPic( Int poc ) |
---|
1573 | { |
---|
1574 | TComList<TComPic*>* listPic = getListPic(); |
---|
1575 | TComPic* pcPic = NULL; |
---|
1576 | for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++) |
---|
1577 | { |
---|
1578 | if( (*it)->getPOC() == poc ) |
---|
1579 | { |
---|
1580 | pcPic = *it ; |
---|
1581 | break ; |
---|
1582 | } |
---|
1583 | } |
---|
1584 | return pcPic; |
---|
1585 | } |
---|
1586 | |
---|
1587 | #endif |
---|
1588 | |
---|
1589 | #if NH_3D_VSO |
---|
1590 | Void TEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset, Int maxCuHeight ) |
---|
1591 | { |
---|
1592 | TRenModel* rendererModel = m_cRdCost.getRenModel(); |
---|
1593 | rendererModel->setupPart( iHorOffset, std::min( maxCuHeight, (Int) ( m_iSourceHeight - iHorOffset ) )) ; |
---|
1594 | |
---|
1595 | Int iEncViewSIdx = m_cameraParameters->getBaseId2SortedId()[ iEncViewIdx ]; |
---|
1596 | |
---|
1597 | // setup base views |
---|
1598 | Int iNumOfBV = m_renderModelParameters->getNumOfBaseViewsForView( iEncViewSIdx, iEncContent ); |
---|
1599 | |
---|
1600 | for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ ) |
---|
1601 | { |
---|
1602 | Int iBaseViewSIdx; |
---|
1603 | Int iVideoDistMode; |
---|
1604 | Int iDepthDistMode; |
---|
1605 | |
---|
1606 | m_renderModelParameters->getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode ); |
---|
1607 | |
---|
1608 | AOT( iVideoDistMode < 0 || iVideoDistMode > 2 ); |
---|
1609 | |
---|
1610 | Int iBaseViewIdx = m_cameraParameters->getBaseSortedId2Id()[ iBaseViewSIdx ]; |
---|
1611 | |
---|
1612 | Int auxId = getVPS()->getAuxId ( getLayerId() ); |
---|
1613 | Bool depthFlag = ( getVPS()->getDepthId( getLayerId() ) == 1 ); |
---|
1614 | |
---|
1615 | if( auxId == 0 && !depthFlag ) |
---|
1616 | { |
---|
1617 | // Defaults for texture layers |
---|
1618 | #if NH_3D |
---|
1619 | depthFlag = true; |
---|
1620 | auxId = 0; |
---|
1621 | #else |
---|
1622 | depthFlag = false; |
---|
1623 | auxId = 2; |
---|
1624 | #endif |
---|
1625 | } |
---|
1626 | |
---|
1627 | TComPicYuv* pcPicYuvVideoRec = m_ivPicLists->getPicYuv( iBaseViewIdx, false , 0 , iPoc, true ); |
---|
1628 | TComPicYuv* pcPicYuvDepthRec = m_ivPicLists->getPicYuv( iBaseViewIdx, depthFlag, auxId, iPoc, true ); |
---|
1629 | TComPicYuv* pcPicYuvVideoOrg = m_ivPicLists->getPicYuv( iBaseViewIdx, false, 0 , iPoc, false ); |
---|
1630 | TComPicYuv* pcPicYuvDepthOrg = m_ivPicLists->getPicYuv( iBaseViewIdx, depthFlag, auxId, iPoc, false ); |
---|
1631 | |
---|
1632 | TComPicYuv* pcPicYuvVideoRef = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg : NULL; |
---|
1633 | TComPicYuv* pcPicYuvDepthRef = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg : NULL; |
---|
1634 | |
---|
1635 | TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg : pcPicYuvVideoRec; |
---|
1636 | TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg : pcPicYuvDepthRec; |
---|
1637 | |
---|
1638 | AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) ); |
---|
1639 | AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) ); |
---|
1640 | AOT( pcPicYuvDepthTest == NULL ); |
---|
1641 | AOT( pcPicYuvVideoTest == NULL ); |
---|
1642 | |
---|
1643 | rendererModel->setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
---|
1644 | } |
---|
1645 | |
---|
1646 | rendererModel->setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
---|
1647 | // setup virtual views |
---|
1648 | Int iNumOfSV = m_renderModelParameters->getNumOfModelsForView( iEncViewSIdx, iEncContent ); |
---|
1649 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
1650 | { |
---|
1651 | Int iOrgRefBaseViewSIdx; |
---|
1652 | Int iLeftBaseViewSIdx; |
---|
1653 | Int iRightBaseViewSIdx; |
---|
1654 | Int iSynthViewRelNum; |
---|
1655 | Int iModelNum; |
---|
1656 | Int iBlendMode; |
---|
1657 | m_renderModelParameters->getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
1658 | |
---|
1659 | Int iLeftBaseViewIdx = -1; |
---|
1660 | Int iRightBaseViewIdx = -1; |
---|
1661 | |
---|
1662 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
1663 | Int** ppiShiftLUTLeft = NULL; |
---|
1664 | Int** ppiShiftLUTRight = NULL; |
---|
1665 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
1666 | Int** ppiBaseShiftLUTRight = NULL; |
---|
1667 | |
---|
1668 | |
---|
1669 | Int iDistToLeft = -1; |
---|
1670 | |
---|
1671 | Int iSynthViewIdx = m_cameraParameters->synthRelNum2Idx( iSynthViewRelNum ); |
---|
1672 | |
---|
1673 | if ( iLeftBaseViewSIdx != -1 ) |
---|
1674 | { |
---|
1675 | iLeftBaseViewIdx = m_cameraParameters->getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
1676 | ppiShiftLUTLeft = m_cameraParameters->getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
1677 | } |
---|
1678 | |
---|
1679 | if ( iRightBaseViewSIdx != -1 ) |
---|
1680 | { |
---|
1681 | iRightBaseViewIdx = m_cameraParameters->getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
1682 | ppiShiftLUTRight = m_cameraParameters->getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
1683 | } |
---|
1684 | |
---|
1685 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
1686 | { |
---|
1687 | iDistToLeft = m_cameraParameters->getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
1688 | ppiBaseShiftLUTLeft = m_cameraParameters->getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
1689 | ppiBaseShiftLUTRight = m_cameraParameters->getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
1690 | |
---|
1691 | } |
---|
1692 | |
---|
1693 | if ( iOrgRefBaseViewSIdx != -1 ) |
---|
1694 | { |
---|
1695 | pcPicYuvOrgRef = m_ivPicLists->getPicYuv( m_cameraParameters->getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , false, 0, iPoc, false ); |
---|
1696 | AOF ( pcPicYuvOrgRef ); |
---|
1697 | } |
---|
1698 | |
---|
1699 | rendererModel->setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef, iEncViewSIdx ); |
---|
1700 | } |
---|
1701 | } |
---|
1702 | #endif |
---|
1703 | |
---|
1704 | //! \} |
---|