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-2012, 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 "../../App/TAppEncoder/TAppEncTop.h" |
---|
42 | #if FAST_BIT_EST |
---|
43 | #include "TLibCommon/ContextModel.h" |
---|
44 | #endif |
---|
45 | |
---|
46 | //! \ingroup TLibEncoder |
---|
47 | //! \{ |
---|
48 | |
---|
49 | // ==================================================================================================================== |
---|
50 | // Constructor / destructor / create / destroy |
---|
51 | // ==================================================================================================================== |
---|
52 | |
---|
53 | TEncTop::TEncTop() |
---|
54 | { |
---|
55 | m_iPOCLast = -1; |
---|
56 | m_iNumPicRcvd = 0; |
---|
57 | m_uiNumAllPicCoded = 0; |
---|
58 | m_pppcRDSbacCoder = NULL; |
---|
59 | m_pppcBinCoderCABAC = NULL; |
---|
60 | m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC ); |
---|
61 | #if ENC_DEC_TRACE |
---|
62 | g_hTrace = fopen( "TraceEnc.txt", "wb" ); |
---|
63 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
64 | g_nSymbolCounter = 0; |
---|
65 | #endif |
---|
66 | |
---|
67 | m_iMaxRefPicNum = 0; |
---|
68 | |
---|
69 | #if FAST_BIT_EST |
---|
70 | ContextModel::buildNextStateTable(); |
---|
71 | #endif |
---|
72 | |
---|
73 | m_pcSbacCoders = NULL; |
---|
74 | m_pcBinCoderCABACs = NULL; |
---|
75 | m_ppppcRDSbacCoders = NULL; |
---|
76 | m_ppppcBinCodersCABAC = NULL; |
---|
77 | m_pcRDGoOnSbacCoders = NULL; |
---|
78 | m_pcRDGoOnBinCodersCABAC = NULL; |
---|
79 | m_pcBitCounters = NULL; |
---|
80 | m_pcRdCosts = NULL; |
---|
81 | } |
---|
82 | |
---|
83 | TEncTop::~TEncTop() |
---|
84 | { |
---|
85 | #if ENC_DEC_TRACE |
---|
86 | fclose( g_hTrace ); |
---|
87 | #endif |
---|
88 | } |
---|
89 | |
---|
90 | Void TEncTop::create () |
---|
91 | { |
---|
92 | // initialize global variables |
---|
93 | if( m_viewId == 0 && m_isDepth == false ) |
---|
94 | { |
---|
95 | initROM(); |
---|
96 | } |
---|
97 | |
---|
98 | |
---|
99 | // create processing unit classes |
---|
100 | m_cGOPEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
101 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
102 | m_cCuEncoder. create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
103 | if (m_bUseSAO) |
---|
104 | { |
---|
105 | m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag()); |
---|
106 | m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic()); |
---|
107 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
108 | m_cEncSAO.createEncBuffer(); |
---|
109 | } |
---|
110 | #if ADAPTIVE_QP_SELECTION |
---|
111 | if (m_bUseAdaptQpSelect) |
---|
112 | { |
---|
113 | m_cTrQuant.initSliceQpDelta(); |
---|
114 | } |
---|
115 | #endif |
---|
116 | m_cAdaptiveLoopFilter.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
117 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
118 | |
---|
119 | #if DEPTH_MAP_GENERATION |
---|
120 | m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); |
---|
121 | #endif |
---|
122 | #if H3D_IVRP |
---|
123 | m_cResidualGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement ); |
---|
124 | #endif |
---|
125 | |
---|
126 | if(m_bUseALF) |
---|
127 | { |
---|
128 | m_cAdaptiveLoopFilter.setAlfCoefInSlice(m_bALFParamInSlice); |
---|
129 | m_cAdaptiveLoopFilter.createAlfGlobalBuffers(); |
---|
130 | } |
---|
131 | |
---|
132 | if(m_bUseSAO || m_bUseALF) |
---|
133 | { |
---|
134 | m_vAPS.reserve(MAX_NUM_SUPPORTED_APS); |
---|
135 | } |
---|
136 | |
---|
137 | // if SBAC-based RD optimization is used |
---|
138 | if( m_bUseSBACRD ) |
---|
139 | { |
---|
140 | m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
141 | #if FAST_BIT_EST |
---|
142 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1]; |
---|
143 | #else |
---|
144 | m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
145 | #endif |
---|
146 | |
---|
147 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
148 | { |
---|
149 | m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; |
---|
150 | #if FAST_BIT_EST |
---|
151 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; |
---|
152 | #else |
---|
153 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; |
---|
154 | #endif |
---|
155 | |
---|
156 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
157 | { |
---|
158 | m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; |
---|
159 | #if FAST_BIT_EST |
---|
160 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; |
---|
161 | #else |
---|
162 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; |
---|
163 | #endif |
---|
164 | m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); |
---|
165 | } |
---|
166 | } |
---|
167 | } |
---|
168 | m_pcTAppEncTop = NULL; |
---|
169 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
170 | if( g_aacWedgeLists.empty() && m_bUseDMM ) |
---|
171 | { |
---|
172 | initWedgeLists(); |
---|
173 | } |
---|
174 | #endif |
---|
175 | } |
---|
176 | |
---|
177 | /** |
---|
178 | - Allocate coders required for wavefront for the nominated number of substreams. |
---|
179 | . |
---|
180 | \param iNumSubstreams Determines how much information to allocate. |
---|
181 | */ |
---|
182 | Void TEncTop::createWPPCoders(Int iNumSubstreams) |
---|
183 | { |
---|
184 | if (m_pcSbacCoders != NULL) |
---|
185 | return; // already generated. |
---|
186 | |
---|
187 | m_iNumSubstreams = iNumSubstreams; |
---|
188 | m_pcSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
189 | m_pcBinCoderCABACs = new TEncBinCABAC [iNumSubstreams]; |
---|
190 | m_pcRDGoOnSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
191 | m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC [iNumSubstreams]; |
---|
192 | m_pcBitCounters = new TComBitCounter [iNumSubstreams]; |
---|
193 | m_pcRdCosts = new TComRdCost [iNumSubstreams]; |
---|
194 | |
---|
195 | for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) |
---|
196 | { |
---|
197 | m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] ); |
---|
198 | m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] ); |
---|
199 | } |
---|
200 | if( m_bUseSBACRD ) |
---|
201 | { |
---|
202 | m_ppppcRDSbacCoders = new TEncSbac*** [iNumSubstreams]; |
---|
203 | m_ppppcBinCodersCABAC = new TEncBinCABAC***[iNumSubstreams]; |
---|
204 | for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) |
---|
205 | { |
---|
206 | m_ppppcRDSbacCoders[ui] = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
207 | m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
208 | |
---|
209 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
210 | { |
---|
211 | m_ppppcRDSbacCoders[ui][iDepth] = new TEncSbac* [CI_NUM]; |
---|
212 | m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM]; |
---|
213 | |
---|
214 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
215 | { |
---|
216 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx] = new TEncSbac; |
---|
217 | m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC; |
---|
218 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] ); |
---|
219 | } |
---|
220 | } |
---|
221 | } |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | Void TEncTop::destroy () |
---|
226 | { |
---|
227 | if(m_bUseALF) |
---|
228 | { |
---|
229 | m_cAdaptiveLoopFilter.destroyAlfGlobalBuffers(); |
---|
230 | } |
---|
231 | |
---|
232 | for(Int i=0; i< m_vAPS.size(); i++) |
---|
233 | { |
---|
234 | TComAPS& cAPS = m_vAPS[i]; |
---|
235 | m_cGOPEncoder.freeAPS(&cAPS, &m_cSPS); |
---|
236 | } |
---|
237 | |
---|
238 | // destroy processing unit classes |
---|
239 | m_cGOPEncoder. destroy(); |
---|
240 | m_cSliceEncoder. destroy(); |
---|
241 | m_cCuEncoder. destroy(); |
---|
242 | if (m_cSPS.getUseSAO()) |
---|
243 | { |
---|
244 | m_cEncSAO.destroy(); |
---|
245 | m_cEncSAO.destroyEncBuffer(); |
---|
246 | } |
---|
247 | m_cAdaptiveLoopFilter.destroy(); |
---|
248 | m_cLoopFilter. destroy(); |
---|
249 | |
---|
250 | #if DEPTH_MAP_GENERATION |
---|
251 | m_cDepthMapGenerator. destroy(); |
---|
252 | #endif |
---|
253 | #if H3D_IVRP |
---|
254 | m_cResidualGenerator. destroy(); |
---|
255 | #endif |
---|
256 | |
---|
257 | m_RPSList. destroy(); |
---|
258 | |
---|
259 | // SBAC RD |
---|
260 | if( m_bUseSBACRD ) |
---|
261 | { |
---|
262 | Int iDepth; |
---|
263 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
264 | { |
---|
265 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
266 | { |
---|
267 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
---|
268 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
---|
269 | } |
---|
270 | } |
---|
271 | |
---|
272 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
273 | { |
---|
274 | delete [] m_pppcRDSbacCoder[iDepth]; |
---|
275 | delete [] m_pppcBinCoderCABAC[iDepth]; |
---|
276 | } |
---|
277 | |
---|
278 | delete [] m_pppcRDSbacCoder; |
---|
279 | delete [] m_pppcBinCoderCABAC; |
---|
280 | |
---|
281 | for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ ) |
---|
282 | { |
---|
283 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
284 | { |
---|
285 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
286 | { |
---|
287 | delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; |
---|
288 | delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; |
---|
289 | } |
---|
290 | } |
---|
291 | |
---|
292 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
293 | { |
---|
294 | delete [] m_ppppcRDSbacCoders [ui][iDepth]; |
---|
295 | delete [] m_ppppcBinCodersCABAC[ui][iDepth]; |
---|
296 | } |
---|
297 | delete[] m_ppppcRDSbacCoders [ui]; |
---|
298 | delete[] m_ppppcBinCodersCABAC[ui]; |
---|
299 | } |
---|
300 | delete[] m_ppppcRDSbacCoders; |
---|
301 | delete[] m_ppppcBinCodersCABAC; |
---|
302 | } |
---|
303 | delete[] m_pcSbacCoders; |
---|
304 | delete[] m_pcBinCoderCABACs; |
---|
305 | delete[] m_pcRDGoOnSbacCoders; |
---|
306 | delete[] m_pcRDGoOnBinCodersCABAC; |
---|
307 | delete[] m_pcBitCounters; |
---|
308 | delete[] m_pcRdCosts; |
---|
309 | |
---|
310 | // destroy ROM |
---|
311 | if(m_viewId == 0 && m_isDepth == false) |
---|
312 | { |
---|
313 | destroyROM(); |
---|
314 | } |
---|
315 | |
---|
316 | return; |
---|
317 | } |
---|
318 | |
---|
319 | Void TEncTop::init( TAppEncTop* pcTAppEncTop ) |
---|
320 | { |
---|
321 | UInt *aTable4=NULL, *aTable8=NULL; |
---|
322 | UInt* aTableLastPosVlcIndex=NULL; |
---|
323 | // initialize SPS |
---|
324 | xInitSPS(); |
---|
325 | |
---|
326 | // initialize PPS |
---|
327 | m_cPPS.setSPS(&m_cSPS); |
---|
328 | m_cSPS.setRPSList(&m_RPSList); |
---|
329 | xInitPPS(); |
---|
330 | xInitRPS(); |
---|
331 | |
---|
332 | xInitSPSforInterViewRefs(); |
---|
333 | xInitPPSforTiles(); |
---|
334 | |
---|
335 | // initialize processing unit classes |
---|
336 | m_cGOPEncoder. init( this ); |
---|
337 | m_cSliceEncoder.init( this ); |
---|
338 | m_cCuEncoder. init( this ); |
---|
339 | |
---|
340 | m_pcTAppEncTop = pcTAppEncTop; |
---|
341 | |
---|
342 | #if DEPTH_MAP_GENERATION |
---|
343 | #if VIDYO_VPS_INTEGRATION |
---|
344 | m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getVPSAccess(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() ); |
---|
345 | #else |
---|
346 | m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() ); |
---|
347 | #endif |
---|
348 | #endif |
---|
349 | #if H3D_IVRP |
---|
350 | m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator ); |
---|
351 | #endif |
---|
352 | |
---|
353 | // initialize transform & quantization class |
---|
354 | m_pcCavlcCoder = getCavlcCoder(); |
---|
355 | |
---|
356 | m_cTrQuant.init( g_uiMaxCUWidth, g_uiMaxCUHeight, 1 << m_uiQuadtreeTULog2MaxSize, |
---|
357 | 0, |
---|
358 | aTable4, aTable8, |
---|
359 | aTableLastPosVlcIndex, m_bUseRDOQ, true |
---|
360 | #if ADAPTIVE_QP_SELECTION |
---|
361 | , m_bUseAdaptQpSelect |
---|
362 | #endif |
---|
363 | ); |
---|
364 | |
---|
365 | // initialize encoder search class |
---|
366 | #if DV_V_RESTRICTION_B0037 |
---|
367 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_bUseDisparitySearchRangeRestriction, m_iVerticalDisparitySearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
368 | #else |
---|
369 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
370 | #endif |
---|
371 | if(m_bUseALF) |
---|
372 | { |
---|
373 | m_cAdaptiveLoopFilter.setALFEncodePassReduction( m_iALFEncodePassReduction ); |
---|
374 | m_cAdaptiveLoopFilter.setALFMaxNumberFilters( m_iALFMaxNumberFilters ); |
---|
375 | m_cAdaptiveLoopFilter.initPicQuadTreePartition(m_bALFPicBasedEncode ); |
---|
376 | } |
---|
377 | |
---|
378 | m_iMaxRefPicNum = 0; |
---|
379 | } |
---|
380 | |
---|
381 | // ==================================================================================================================== |
---|
382 | // Public member functions |
---|
383 | // ==================================================================================================================== |
---|
384 | |
---|
385 | Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg, TComPicYuv* pcOrgPdmDepth ) |
---|
386 | { |
---|
387 | TComPic* pcPicCurr = NULL; |
---|
388 | |
---|
389 | // get original YUV |
---|
390 | xGetNewPicBuffer( pcPicCurr ); |
---|
391 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
392 | |
---|
393 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
394 | pcPicCurr->setViewOrderIdx(m_iViewOrderIdx); // will be changed to view_id |
---|
395 | #endif |
---|
396 | pcPicCurr->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset ); |
---|
397 | |
---|
398 | #if H3D_IVMP |
---|
399 | if( m_uiMultiviewMvRegMode ) |
---|
400 | { |
---|
401 | AOF( pcOrgPdmDepth ); |
---|
402 | AOF( pcPicCurr->getOrgDepthMap() ); |
---|
403 | pcOrgPdmDepth->copyToPic( pcPicCurr->getOrgDepthMap() ); |
---|
404 | } |
---|
405 | else |
---|
406 | { |
---|
407 | AOT( pcOrgPdmDepth ); |
---|
408 | AOT( pcPicCurr->getOrgDepthMap() ); |
---|
409 | } |
---|
410 | #endif |
---|
411 | |
---|
412 | #if DEPTH_MAP_GENERATION |
---|
413 | // add extra pic buffers |
---|
414 | Bool bNeedPrdDepthMapBuf = ( m_uiPredDepthMapGeneration > 0 ); |
---|
415 | if( bNeedPrdDepthMapBuf && !pcPicCurr->getPredDepthMap() ) |
---|
416 | { |
---|
417 | pcPicCurr->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); |
---|
418 | } |
---|
419 | #endif |
---|
420 | |
---|
421 | // compute image characteristics |
---|
422 | if ( getUseAdaptiveQP() ) |
---|
423 | { |
---|
424 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
425 | } |
---|
426 | } |
---|
427 | |
---|
428 | Void TEncTop::deletePicBuffer() |
---|
429 | { |
---|
430 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
431 | Int iSize = Int( m_cListPic.size() ); |
---|
432 | |
---|
433 | for ( Int i = 0; i < iSize; i++ ) |
---|
434 | { |
---|
435 | TComPic* pcPic = *(iterPic++); |
---|
436 | |
---|
437 | pcPic->destroy(); |
---|
438 | delete pcPic; |
---|
439 | pcPic = NULL; |
---|
440 | } |
---|
441 | } |
---|
442 | |
---|
443 | /** |
---|
444 | - Application has picture buffer list with size of GOP + 1 |
---|
445 | - Picture buffer list acts like as ring buffer |
---|
446 | - End of the list has the latest picture |
---|
447 | . |
---|
448 | \param bEos true if end-of-sequence is reached |
---|
449 | \param pcPicYuvOrg original YUV picture |
---|
450 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
---|
451 | \retval rcListBitstreamOut list of output bitstreams |
---|
452 | \retval iNumEncoded number of encoded pictures |
---|
453 | */ |
---|
454 | Void TEncTop::encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ) |
---|
455 | { |
---|
456 | |
---|
457 | if( gopId == 0) |
---|
458 | { |
---|
459 | m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); |
---|
460 | } |
---|
461 | |
---|
462 | { |
---|
463 | m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId ); |
---|
464 | } |
---|
465 | |
---|
466 | if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) |
---|
467 | { |
---|
468 | iNumEncoded = m_iNumPicRcvd; |
---|
469 | m_iNumPicRcvd = 0; |
---|
470 | m_uiNumAllPicCoded += iNumEncoded; |
---|
471 | } |
---|
472 | } |
---|
473 | |
---|
474 | |
---|
475 | #if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP |
---|
476 | Void |
---|
477 | TEncTop::deleteExtraPicBuffers( Int iPoc ) |
---|
478 | { |
---|
479 | TComPic* pcPic = 0; |
---|
480 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
481 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
482 | for( ; cIter != cEnd; cIter++ ) |
---|
483 | { |
---|
484 | if( (*cIter)->getPOC() == iPoc ) |
---|
485 | { |
---|
486 | pcPic = *cIter; |
---|
487 | break; |
---|
488 | } |
---|
489 | } |
---|
490 | AOF( pcPic ); |
---|
491 | if ( pcPic ) |
---|
492 | { |
---|
493 | #if H3D_IVMP |
---|
494 | pcPic->removeOrgDepthMapBuffer(); |
---|
495 | #endif |
---|
496 | #if H3D_IVRP |
---|
497 | pcPic->removeResidualBuffer (); |
---|
498 | #endif |
---|
499 | #if HHI_INTERVIEW_SKIP |
---|
500 | pcPic->removeUsedPelsMapBuffer(); |
---|
501 | #endif |
---|
502 | } |
---|
503 | } |
---|
504 | #endif |
---|
505 | |
---|
506 | Void |
---|
507 | TEncTop::compressMotion( Int iPoc ) |
---|
508 | { |
---|
509 | TComPic* pcPic = 0; |
---|
510 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
511 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
512 | for( ; cIter != cEnd; cIter++ ) |
---|
513 | { |
---|
514 | if( (*cIter)->getPOC() == iPoc ) |
---|
515 | { |
---|
516 | pcPic = *cIter; |
---|
517 | break; |
---|
518 | } |
---|
519 | } |
---|
520 | AOF( pcPic ); |
---|
521 | if ( pcPic ) |
---|
522 | { |
---|
523 | pcPic->compressMotion(); |
---|
524 | } |
---|
525 | } |
---|
526 | |
---|
527 | // ==================================================================================================================== |
---|
528 | // Protected member functions |
---|
529 | // ==================================================================================================================== |
---|
530 | |
---|
531 | /** |
---|
532 | - Application has picture buffer list with size of GOP + 1 |
---|
533 | - Picture buffer list acts like as ring buffer |
---|
534 | - End of the list has the latest picture |
---|
535 | . |
---|
536 | \retval rpcPic obtained picture buffer |
---|
537 | */ |
---|
538 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) |
---|
539 | { |
---|
540 | TComSlice::sortPicList(m_cListPic); |
---|
541 | |
---|
542 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
543 | { |
---|
544 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
545 | Int iSize = Int( m_cListPic.size() ); |
---|
546 | for ( Int i = 0; i < iSize; i++ ) |
---|
547 | { |
---|
548 | rpcPic = *(++iterPic); |
---|
549 | if(rpcPic->getSlice(0)->isReferenced() == false) |
---|
550 | break; |
---|
551 | } |
---|
552 | } |
---|
553 | else |
---|
554 | { |
---|
555 | if ( getUseAdaptiveQP() ) |
---|
556 | { |
---|
557 | TEncPic* pcEPic = new TEncPic; |
---|
558 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ); |
---|
559 | rpcPic = pcEPic; |
---|
560 | } |
---|
561 | else |
---|
562 | { |
---|
563 | rpcPic = new TComPic; |
---|
564 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
565 | } |
---|
566 | m_cListPic.pushBack( rpcPic ); |
---|
567 | } |
---|
568 | #if HHI_INTERVIEW_SKIP |
---|
569 | if( m_bInterViewSkip ) |
---|
570 | { |
---|
571 | rpcPic->addUsedPelsMapBuffer(); |
---|
572 | } |
---|
573 | #endif |
---|
574 | rpcPic->setReconMark (false); |
---|
575 | |
---|
576 | m_iPOCLast++; |
---|
577 | m_iNumPicRcvd++; |
---|
578 | |
---|
579 | #if H3D_IVMP |
---|
580 | if( m_uiMultiviewMvRegMode ) |
---|
581 | { |
---|
582 | rpcPic->addOrgDepthMapBuffer(); |
---|
583 | } |
---|
584 | #endif |
---|
585 | |
---|
586 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
---|
587 | // mark it should be extended |
---|
588 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
589 | rpcPic->getPicYuvOrg()->setBorderExtension(false); |
---|
590 | } |
---|
591 | |
---|
592 | Void TEncTop::xInitSPS() |
---|
593 | { |
---|
594 | m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); |
---|
595 | m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); |
---|
596 | m_cSPS.setPicCroppingFlag( m_croppingMode!= 0 ); |
---|
597 | if (m_croppingMode != 0) |
---|
598 | { |
---|
599 | m_cSPS.setPicCropLeftOffset( m_cropLeft ); |
---|
600 | m_cSPS.setPicCropRightOffset( m_cropRight ); |
---|
601 | m_cSPS.setPicCropTopOffset( m_cropTop ); |
---|
602 | m_cSPS.setPicCropBottomOffset( m_cropBottom ); |
---|
603 | } |
---|
604 | m_cSPS.setMaxCUWidth ( g_uiMaxCUWidth ); |
---|
605 | m_cSPS.setMaxCUHeight ( g_uiMaxCUHeight ); |
---|
606 | m_cSPS.setMaxCUDepth ( g_uiMaxCUDepth ); |
---|
607 | m_cSPS.setMinTrDepth ( 0 ); |
---|
608 | m_cSPS.setMaxTrDepth ( 1 ); |
---|
609 | |
---|
610 | m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
---|
611 | m_cSPS.setUsePCM ( m_usePCM ); |
---|
612 | m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
---|
613 | |
---|
614 | m_cSPS.setUseALF ( m_bUseALF ); |
---|
615 | if(m_bUseALF) |
---|
616 | { |
---|
617 | m_cSPS.setUseALFCoefInSlice(m_bALFParamInSlice); |
---|
618 | } |
---|
619 | |
---|
620 | #if RWTH_SDC_DLT_B0036 |
---|
621 | m_cSPS.setUseDLT ( m_bUseDLT ); |
---|
622 | #endif |
---|
623 | |
---|
624 | m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
---|
625 | m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
---|
626 | m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
---|
627 | m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
---|
628 | |
---|
629 | #if LOSSLESS_CODING |
---|
630 | m_cSPS.setUseLossless ( m_useLossless ); |
---|
631 | #endif |
---|
632 | m_cSPS.setUseLMChroma ( m_bUseLMChroma ); |
---|
633 | |
---|
634 | m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
635 | |
---|
636 | m_cSPS.setUseLComb ( m_bUseLComb ); |
---|
637 | m_cSPS.setLCMod ( m_bLCMod ); |
---|
638 | m_cSPS.setUseNSQT( m_useNSQT ); |
---|
639 | |
---|
640 | Int i; |
---|
641 | #if HHI_AMVP_OFF |
---|
642 | for ( i = 0; i < g_uiMaxCUDepth; i++ ) |
---|
643 | { |
---|
644 | m_cSPS.setAMVPMode( i, AM_NONE ); |
---|
645 | } |
---|
646 | #else |
---|
647 | for ( i = 0; i < g_uiMaxCUDepth; i++ ) |
---|
648 | { |
---|
649 | m_cSPS.setAMVPMode( i, AM_EXPL ); |
---|
650 | } |
---|
651 | #endif |
---|
652 | |
---|
653 | for (i = 0; i < g_uiMaxCUDepth-1; i++ ) |
---|
654 | { |
---|
655 | m_cSPS.setAMPAcc( i, m_useAMP ); |
---|
656 | //m_cSPS.setAMPAcc( i, 1 ); |
---|
657 | } |
---|
658 | |
---|
659 | m_cSPS.setUseAMP ( m_useAMP ); |
---|
660 | |
---|
661 | for (i = g_uiMaxCUDepth-1; i < g_uiMaxCUDepth; i++ ) |
---|
662 | { |
---|
663 | m_cSPS.setAMPAcc(i, 0); |
---|
664 | } |
---|
665 | |
---|
666 | m_cSPS.setBitDepth ( g_uiBitDepth ); |
---|
667 | m_cSPS.setBitIncrement( g_uiBitIncrement ); |
---|
668 | m_cSPS.setQpBDOffsetY ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); |
---|
669 | m_cSPS.setQpBDOffsetC ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); |
---|
670 | |
---|
671 | m_cSPS.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
672 | m_cSPS.setUseSAO( m_bUseSAO ); |
---|
673 | |
---|
674 | m_cSPS.setMaxTLayers( m_maxTempLayer ); |
---|
675 | m_cSPS.setTemporalIdNestingFlag( false ); |
---|
676 | for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ ) |
---|
677 | { |
---|
678 | m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
---|
679 | m_cSPS.setNumReorderPics(m_numReorderPics[i], i); |
---|
680 | } |
---|
681 | m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma); |
---|
682 | m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma); |
---|
683 | m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
---|
684 | |
---|
685 | m_cSPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
686 | m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); |
---|
687 | m_cSPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
688 | m_cSPS.setNumRowsMinus1( m_iNumRowsMinus1 ); |
---|
689 | if( m_iUniformSpacingIdr == 0 ) |
---|
690 | { |
---|
691 | m_cSPS.setColumnWidth( m_puiColumnWidth ); |
---|
692 | m_cSPS.setRowHeight( m_puiRowHeight ); |
---|
693 | } |
---|
694 | m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 ); |
---|
695 | m_cSPS.setUseDF( m_loopFilterOffsetInAPS ); |
---|
696 | |
---|
697 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
698 | m_cSPS.setUseDMM( m_bUseDMM ); |
---|
699 | #endif |
---|
700 | |
---|
701 | #if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723 |
---|
702 | m_cSPS.setUseDMM34( m_bUseDMM34 ); |
---|
703 | #endif |
---|
704 | |
---|
705 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
706 | m_cSPS.setUseQTLPC( m_bUseQTLPC ); |
---|
707 | #endif |
---|
708 | #if HHI_MPI |
---|
709 | m_cSPS.setUseMVI( m_bUseMVI ); |
---|
710 | #endif |
---|
711 | |
---|
712 | if( m_isDepth ) |
---|
713 | { |
---|
714 | #if FCO_FIX_SPS_CHANGE |
---|
715 | m_cSPS.initMultiviewSPSDepth ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset ); |
---|
716 | #else |
---|
717 | m_cSPS.initMultiviewSPSDepth ( m_viewId, m_iViewOrderIdx ); |
---|
718 | #endif |
---|
719 | |
---|
720 | #if DEPTH_MAP_GENERATION |
---|
721 | m_cSPS.setPredDepthMapGeneration( m_viewId, true ); |
---|
722 | #endif |
---|
723 | #if H3D_IVRP |
---|
724 | m_cSPS.setMultiviewResPredMode ( 0 ); |
---|
725 | #endif |
---|
726 | } |
---|
727 | else |
---|
728 | { |
---|
729 | #if QC_MVHEVC_B0046 |
---|
730 | m_cSPS.initMultiviewSPS ( m_viewId); |
---|
731 | #else |
---|
732 | m_cSPS.initMultiviewSPS ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset ); |
---|
733 | #endif |
---|
734 | if( m_viewId ) |
---|
735 | { |
---|
736 | #if DEPTH_MAP_GENERATION |
---|
737 | #if H3D_IVMP |
---|
738 | m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); |
---|
739 | #else |
---|
740 | m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, 0, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); |
---|
741 | #endif |
---|
742 | #endif |
---|
743 | #if H3D_IVRP |
---|
744 | m_cSPS.setMultiviewResPredMode ( m_uiMultiviewResPredMode ); |
---|
745 | #endif |
---|
746 | } |
---|
747 | else |
---|
748 | { |
---|
749 | #if DEPTH_MAP_GENERATION |
---|
750 | m_cSPS.setPredDepthMapGeneration( m_viewId, false ); |
---|
751 | #endif |
---|
752 | #if H3D_IVRP |
---|
753 | m_cSPS.setMultiviewResPredMode ( 0 ); |
---|
754 | #endif |
---|
755 | } |
---|
756 | } |
---|
757 | } |
---|
758 | |
---|
759 | Void TEncTop::xInitPPS() |
---|
760 | { |
---|
761 | m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
---|
762 | m_cPPS.setSliceGranularity(m_iSliceGranularity); |
---|
763 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
---|
764 | |
---|
765 | #if LOSSLESS_CODING |
---|
766 | Int lowestQP = - m_cSPS.getQpBDOffsetY(); |
---|
767 | |
---|
768 | if(getUseLossless()) |
---|
769 | { |
---|
770 | if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) ) |
---|
771 | { |
---|
772 | bUseDQP = false; |
---|
773 | } |
---|
774 | else |
---|
775 | { |
---|
776 | bUseDQP = true; |
---|
777 | } |
---|
778 | } |
---|
779 | else |
---|
780 | { |
---|
781 | if(bUseDQP == false) |
---|
782 | { |
---|
783 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
784 | { |
---|
785 | bUseDQP = true; |
---|
786 | } |
---|
787 | } |
---|
788 | } |
---|
789 | |
---|
790 | #else |
---|
791 | if(bUseDQP == false) |
---|
792 | { |
---|
793 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
794 | { |
---|
795 | bUseDQP = true; |
---|
796 | } |
---|
797 | } |
---|
798 | #endif |
---|
799 | |
---|
800 | if(bUseDQP) |
---|
801 | { |
---|
802 | m_cPPS.setUseDQP(true); |
---|
803 | m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
---|
804 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
805 | } |
---|
806 | else |
---|
807 | { |
---|
808 | m_cPPS.setUseDQP(false); |
---|
809 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
810 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
811 | } |
---|
812 | |
---|
813 | m_cPPS.setChromaQpOffset ( m_iChromaQpOffset ); |
---|
814 | m_cPPS.setChromaQpOffset2nd( m_iChromaQpOffset2nd ); |
---|
815 | |
---|
816 | m_cPPS.setEntropyCodingMode( 1 ); // In the PPS now, but also remains in slice header! |
---|
817 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams); |
---|
818 | m_cPPS.setUseWP( m_bUseWeightPred ); |
---|
819 | m_cPPS.setWPBiPredIdc( m_uiBiPredIdc ); |
---|
820 | m_cPPS.setEnableTMVPFlag( m_bEnableTMVP ); |
---|
821 | m_cPPS.setOutputFlagPresentFlag( false ); |
---|
822 | m_cPPS.setSignHideFlag(getSignHideFlag()); |
---|
823 | m_cPPS.setTSIG(getTSIG()); |
---|
824 | m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent ); |
---|
825 | m_cPPS.setLog2ParallelMergeLevelMinus2 (LOG2_PARALLEL_MERGE_LEVEL_MINUS2); |
---|
826 | #if CABAC_INIT_FLAG |
---|
827 | m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
---|
828 | #endif |
---|
829 | } |
---|
830 | |
---|
831 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
---|
832 | Void TEncTop::xInitRPS() |
---|
833 | { |
---|
834 | TComReferencePictureSet* rps; |
---|
835 | |
---|
836 | m_RPSList.create(getGOPSize()+m_extraRPSs); |
---|
837 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
---|
838 | { |
---|
839 | GOPEntryMvc ge = getGOPEntry(i); |
---|
840 | rps = m_RPSList.getReferencePictureSet(i); |
---|
841 | rps->setNumberOfPictures(ge.m_numRefPics); |
---|
842 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
843 | Int numNeg = 0; |
---|
844 | Int numPos = 0; |
---|
845 | for( Int j = 0; j < ge.m_numRefPics; j++) |
---|
846 | { |
---|
847 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
---|
848 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
---|
849 | if(ge.m_referencePics[j]>0) |
---|
850 | { |
---|
851 | numPos++; |
---|
852 | } |
---|
853 | else |
---|
854 | { |
---|
855 | numNeg++; |
---|
856 | } |
---|
857 | } |
---|
858 | rps->setNumberOfNegativePictures(numNeg); |
---|
859 | rps->setNumberOfPositivePictures(numPos); |
---|
860 | rps->setInterRPSPrediction(ge.m_interRPSPrediction); |
---|
861 | if (ge.m_interRPSPrediction) |
---|
862 | { |
---|
863 | rps->setDeltaRIdxMinus1(ge.m_deltaRIdxMinus1); |
---|
864 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
865 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
866 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
867 | { |
---|
868 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
869 | } |
---|
870 | #if WRITE_BACK |
---|
871 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
872 | // computed from the RefIdc. This is not necessary if both are identical. Currently there is no check to see if they are identical. |
---|
873 | numNeg = 0; |
---|
874 | numPos = 0; |
---|
875 | TComReferencePictureSet* RPSRef = m_RPSList.getReferencePictureSet(i-(ge.m_deltaRIdxMinus1+1)); |
---|
876 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
877 | { |
---|
878 | if (ge.m_refIdc[j]) |
---|
879 | { |
---|
880 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
881 | rps->setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
882 | rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
883 | if (deltaPOC<0) |
---|
884 | { |
---|
885 | numNeg++; |
---|
886 | } |
---|
887 | else |
---|
888 | { |
---|
889 | numPos++; |
---|
890 | } |
---|
891 | } |
---|
892 | } |
---|
893 | rps->setNumberOfNegativePictures(numNeg); |
---|
894 | rps->setNumberOfPositivePictures(numPos); |
---|
895 | rps->sortDeltaPOC(); |
---|
896 | #endif |
---|
897 | } |
---|
898 | } |
---|
899 | |
---|
900 | } |
---|
901 | |
---|
902 | // This is a function that |
---|
903 | // determines what Reference Picture Set to use |
---|
904 | // for a specific slice (with POC = POCCurr) |
---|
905 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic ) |
---|
906 | { |
---|
907 | #if QC_REM_IDV_B0046 |
---|
908 | if( (slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR ||slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && slice->getSPS()->getViewId() && POCCurr == 0 ) |
---|
909 | #else |
---|
910 | if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 ) |
---|
911 | #endif |
---|
912 | { |
---|
913 | TComReferencePictureSet* rps = slice->getLocalRPS(); |
---|
914 | rps->setNumberOfNegativePictures(0); |
---|
915 | rps->setNumberOfPositivePictures(0); |
---|
916 | rps->setNumberOfLongtermPictures(0); |
---|
917 | rps->setNumberOfPictures(0); |
---|
918 | slice->setRPS(rps); |
---|
919 | } |
---|
920 | else |
---|
921 | { |
---|
922 | slice->setRPSidx(GOPid); |
---|
923 | |
---|
924 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
925 | { |
---|
926 | if(m_uiIntraPeriod > 0) |
---|
927 | { |
---|
928 | if(POCCurr%m_uiIntraPeriod==m_GOPList[extraNum].m_POC) |
---|
929 | { |
---|
930 | slice->setRPSidx(extraNum); |
---|
931 | } |
---|
932 | } |
---|
933 | else |
---|
934 | { |
---|
935 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
936 | { |
---|
937 | slice->setRPSidx(extraNum); |
---|
938 | } |
---|
939 | } |
---|
940 | } |
---|
941 | |
---|
942 | slice->setRPS(getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
---|
943 | slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); |
---|
944 | } |
---|
945 | } |
---|
946 | |
---|
947 | Void TEncTop::xInitSPSforInterViewRefs() |
---|
948 | { |
---|
949 | // base view |
---|
950 | if( getGOPEntry( MAX_GOP ).m_POC == -1 ) |
---|
951 | { |
---|
952 | m_cSPS.setNumberOfUsableInterViewRefs( 0 ); |
---|
953 | m_cSPS.setListsModificationPresentFlag( false ); |
---|
954 | return; |
---|
955 | } |
---|
956 | |
---|
957 | Int numberUsableInterViewRefs = 0; |
---|
958 | for( Int i = 0; i < getGOPSize()+1 && numberUsableInterViewRefs < MAX_VIEW_NUM; i++ ) |
---|
959 | { |
---|
960 | GOPEntryMvc ge = ( i < getGOPSize() ) ? getGOPEntry( i ) : getGOPEntry( MAX_GOP ); |
---|
961 | for( Int j = 0; j < ge.m_numInterViewRefPics; j++ ) |
---|
962 | { |
---|
963 | // add ref view to list |
---|
964 | Bool onList = false; |
---|
965 | for( Int k = 0; k < numberUsableInterViewRefs; k++ ) |
---|
966 | { |
---|
967 | if( ge.m_interViewRefs[j] == m_cSPS.getUsableInterViewRef( k ) ) |
---|
968 | { |
---|
969 | onList = true; |
---|
970 | break; |
---|
971 | } |
---|
972 | } |
---|
973 | if( !onList ) |
---|
974 | { |
---|
975 | m_cSPS.setUsableInterViewRef( (UInt)numberUsableInterViewRefs, ge.m_interViewRefs[j] ); |
---|
976 | numberUsableInterViewRefs++; |
---|
977 | } |
---|
978 | } |
---|
979 | } |
---|
980 | m_cSPS.setNumberOfUsableInterViewRefs( numberUsableInterViewRefs ); |
---|
981 | |
---|
982 | // sort inter view refs |
---|
983 | for( Int j = 1; j < m_cSPS.getNumberOfUsableInterViewRefs(); j++ ) |
---|
984 | { |
---|
985 | Int deltaViewId = m_cSPS.getUsableInterViewRef( j ); |
---|
986 | for( Int k = j-1; k >= 0; k-- ) |
---|
987 | { |
---|
988 | Int temp = m_cSPS.getUsableInterViewRef( k ); |
---|
989 | if( deltaViewId > temp ) |
---|
990 | { |
---|
991 | m_cSPS.setUsableInterViewRef( k+1, temp ); |
---|
992 | m_cSPS.setUsableInterViewRef( k, deltaViewId ); |
---|
993 | } |
---|
994 | } |
---|
995 | } |
---|
996 | |
---|
997 | m_cSPS.setListsModificationPresentFlag( true ); |
---|
998 | } |
---|
999 | |
---|
1000 | Void TEncTop::xInitPPSforTiles() |
---|
1001 | { |
---|
1002 | m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent ); |
---|
1003 | m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); |
---|
1004 | m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
1005 | m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 ); |
---|
1006 | if( m_iUniformSpacingIdr == 0 ) |
---|
1007 | { |
---|
1008 | m_cPPS.setColumnWidth( m_puiColumnWidth ); |
---|
1009 | m_cPPS.setRowHeight( m_puiRowHeight ); |
---|
1010 | } |
---|
1011 | m_cPPS.setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag ); |
---|
1012 | m_cPPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
1013 | |
---|
1014 | // # substreams is "per tile" when tiles are independent. |
---|
1015 | if ( m_iWaveFrontSynchro ) |
---|
1016 | { |
---|
1017 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)); |
---|
1018 | } |
---|
1019 | } |
---|
1020 | |
---|
1021 | Void TEncCfg::xCheckGSParameters() |
---|
1022 | { |
---|
1023 | Int iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth; |
---|
1024 | Int iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight; |
---|
1025 | UInt uiCummulativeColumnWidth = 0; |
---|
1026 | UInt uiCummulativeRowHeight = 0; |
---|
1027 | |
---|
1028 | //check the column relative parameters |
---|
1029 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
---|
1030 | { |
---|
1031 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
---|
1032 | exit( EXIT_FAILURE ); |
---|
1033 | } |
---|
1034 | |
---|
1035 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
---|
1036 | { |
---|
1037 | printf( "The current picture can not have so many columns.\n" ); |
---|
1038 | exit( EXIT_FAILURE ); |
---|
1039 | } |
---|
1040 | |
---|
1041 | if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
1042 | { |
---|
1043 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
---|
1044 | uiCummulativeColumnWidth += m_puiColumnWidth[i]; |
---|
1045 | |
---|
1046 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
---|
1047 | { |
---|
1048 | printf( "The width of the column is too large.\n" ); |
---|
1049 | exit( EXIT_FAILURE ); |
---|
1050 | } |
---|
1051 | } |
---|
1052 | |
---|
1053 | //check the row relative parameters |
---|
1054 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
---|
1055 | { |
---|
1056 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
---|
1057 | exit( EXIT_FAILURE ); |
---|
1058 | } |
---|
1059 | |
---|
1060 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
---|
1061 | { |
---|
1062 | printf( "The current picture can not have so many rows.\n" ); |
---|
1063 | exit( EXIT_FAILURE ); |
---|
1064 | } |
---|
1065 | |
---|
1066 | if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
1067 | { |
---|
1068 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
---|
1069 | uiCummulativeRowHeight += m_puiRowHeight[i]; |
---|
1070 | |
---|
1071 | if( uiCummulativeRowHeight >= iHeightInCU ) |
---|
1072 | { |
---|
1073 | printf( "The height of the row is too large.\n" ); |
---|
1074 | exit( EXIT_FAILURE ); |
---|
1075 | } |
---|
1076 | } |
---|
1077 | } |
---|
1078 | |
---|
1079 | Void TEncTop::setTEncTopList(std::vector<TEncTop*>* pacTEncTopList ) |
---|
1080 | { |
---|
1081 | assert(m_viewId!=-1); // not to be set for single view coding |
---|
1082 | |
---|
1083 | m_pacTEncTopList=pacTEncTopList; |
---|
1084 | |
---|
1085 | } |
---|
1086 | |
---|
1087 | Void TEncTop::printOutSummary(UInt uiNumAllPicCoded) |
---|
1088 | { |
---|
1089 | assert (uiNumAllPicCoded == m_cAnalyzeAll.getNumPic()); |
---|
1090 | |
---|
1091 | //--CFG_KDY |
---|
1092 | m_cAnalyzeAll.setFrmRate( getFrameRate() ); |
---|
1093 | m_cAnalyzeI.setFrmRate( getFrameRate() ); |
---|
1094 | m_cAnalyzeP.setFrmRate( getFrameRate() ); |
---|
1095 | m_cAnalyzeB.setFrmRate( getFrameRate() ); |
---|
1096 | |
---|
1097 | //-- all |
---|
1098 | if(m_viewId==-1) |
---|
1099 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
1100 | else { |
---|
1101 | if ( m_isDepth ) |
---|
1102 | { |
---|
1103 | printf( "\n\nSUMMARY ---------------------------------------------- DEPTH %2d\n", m_viewId ); |
---|
1104 | } |
---|
1105 | else |
---|
1106 | { |
---|
1107 | printf( "\n\nSUMMARY ---------------------------------------------- VIDEO %2d\n", m_viewId ); |
---|
1108 | } |
---|
1109 | }; |
---|
1110 | m_cAnalyzeAll.printOut('a'); |
---|
1111 | |
---|
1112 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
1113 | m_cAnalyzeI.printOut('i'); |
---|
1114 | |
---|
1115 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
1116 | m_cAnalyzeP.printOut('p'); |
---|
1117 | |
---|
1118 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
1119 | m_cAnalyzeB.printOut('b'); |
---|
1120 | |
---|
1121 | // m_cAnalyzeAll.printSummaryOut(); |
---|
1122 | // m_cAnalyzeI.printSummary('I'); |
---|
1123 | // m_cAnalyzeP.printSummary('P'); |
---|
1124 | // m_cAnalyzeB.printSummary('B'); |
---|
1125 | } |
---|
1126 | |
---|
1127 | //! \} |
---|