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 TEncGOP.cpp |
---|
35 | \brief GOP encoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <list> |
---|
39 | #include <algorithm> |
---|
40 | |
---|
41 | #include "TEncTop.h" |
---|
42 | #include "TEncGOP.h" |
---|
43 | #include "TEncAnalyze.h" |
---|
44 | #include "libmd5/MD5.h" |
---|
45 | #include "TLibCommon/SEI.h" |
---|
46 | #include "TLibCommon/NAL.h" |
---|
47 | #include "NALwrite.h" |
---|
48 | #include "../../App/TAppEncoder/TAppEncTop.h" |
---|
49 | |
---|
50 | #include <time.h> |
---|
51 | #include <math.h> |
---|
52 | |
---|
53 | using namespace std; |
---|
54 | |
---|
55 | //! \ingroup TLibEncoder |
---|
56 | //! \{ |
---|
57 | |
---|
58 | // ==================================================================================================================== |
---|
59 | // Constructor / destructor / initialization / destroy |
---|
60 | // ==================================================================================================================== |
---|
61 | |
---|
62 | TEncGOP::TEncGOP() |
---|
63 | { |
---|
64 | m_iLastIDR = 0; |
---|
65 | m_iGopSize = 0; |
---|
66 | m_iNumPicCoded = 0; //Niko |
---|
67 | m_bFirst = true; |
---|
68 | |
---|
69 | m_pcCfg = NULL; |
---|
70 | m_pcSliceEncoder = NULL; |
---|
71 | m_pcListPic = NULL; |
---|
72 | |
---|
73 | m_pcEntropyCoder = NULL; |
---|
74 | m_pcCavlcCoder = NULL; |
---|
75 | m_pcSbacCoder = NULL; |
---|
76 | m_pcBinCABAC = NULL; |
---|
77 | #if DEPTH_MAP_GENERATION |
---|
78 | m_pcDepthMapGenerator = NULL; |
---|
79 | #endif |
---|
80 | #if H3D_IVRP |
---|
81 | m_pcResidualGenerator = NULL; |
---|
82 | #endif |
---|
83 | |
---|
84 | m_bSeqFirst = true; |
---|
85 | |
---|
86 | m_bRefreshPending = 0; |
---|
87 | m_pocCRA = 0; |
---|
88 | |
---|
89 | return; |
---|
90 | } |
---|
91 | |
---|
92 | TEncGOP::~TEncGOP() |
---|
93 | { |
---|
94 | } |
---|
95 | |
---|
96 | /** Create list to contain pointers to LCU start addresses of slice. |
---|
97 | * \param iWidth, iHeight are picture width, height. iMaxCUWidth, iMaxCUHeight are LCU width, height. |
---|
98 | */ |
---|
99 | Void TEncGOP::create( Int iWidth, Int iHeight, UInt iMaxCUWidth, UInt iMaxCUHeight ) |
---|
100 | { |
---|
101 | UInt uiWidthInCU = ( iWidth %iMaxCUWidth ) ? iWidth /iMaxCUWidth + 1 : iWidth /iMaxCUWidth; |
---|
102 | UInt uiHeightInCU = ( iHeight%iMaxCUHeight ) ? iHeight/iMaxCUHeight + 1 : iHeight/iMaxCUHeight; |
---|
103 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
104 | m_uiStoredStartCUAddrForEncodingSlice = new UInt [uiNumCUsInFrame*(1<<(g_uiMaxCUDepth<<1))+1]; |
---|
105 | m_uiStoredStartCUAddrForEncodingEntropySlice = new UInt [uiNumCUsInFrame*(1<<(g_uiMaxCUDepth<<1))+1]; |
---|
106 | m_bLongtermTestPictureHasBeenCoded = 0; |
---|
107 | m_bLongtermTestPictureHasBeenCoded2 = 0; |
---|
108 | } |
---|
109 | |
---|
110 | Void TEncGOP::destroy() |
---|
111 | { |
---|
112 | delete [] m_uiStoredStartCUAddrForEncodingSlice; m_uiStoredStartCUAddrForEncodingSlice = NULL; |
---|
113 | delete [] m_uiStoredStartCUAddrForEncodingEntropySlice; m_uiStoredStartCUAddrForEncodingEntropySlice = NULL; |
---|
114 | } |
---|
115 | |
---|
116 | Void TEncGOP::init ( TEncTop* pcTEncTop ) |
---|
117 | { |
---|
118 | m_pcEncTop = pcTEncTop; |
---|
119 | m_pcCfg = pcTEncTop; |
---|
120 | m_pcSliceEncoder = pcTEncTop->getSliceEncoder(); |
---|
121 | m_pcListPic = pcTEncTop->getListPic(); |
---|
122 | |
---|
123 | m_pcEntropyCoder = pcTEncTop->getEntropyCoder(); |
---|
124 | m_pcCavlcCoder = pcTEncTop->getCavlcCoder(); |
---|
125 | m_pcSbacCoder = pcTEncTop->getSbacCoder(); |
---|
126 | m_pcBinCABAC = pcTEncTop->getBinCABAC(); |
---|
127 | m_pcLoopFilter = pcTEncTop->getLoopFilter(); |
---|
128 | m_pcBitCounter = pcTEncTop->getBitCounter(); |
---|
129 | |
---|
130 | #if DEPTH_MAP_GENERATION |
---|
131 | m_pcDepthMapGenerator = pcTEncTop->getDepthMapGenerator(); |
---|
132 | #endif |
---|
133 | #if H3D_IVRP |
---|
134 | m_pcResidualGenerator = pcTEncTop->getResidualGenerator(); |
---|
135 | #endif |
---|
136 | |
---|
137 | // Adaptive Loop filter |
---|
138 | m_pcAdaptiveLoopFilter = pcTEncTop->getAdaptiveLoopFilter(); |
---|
139 | //--Adaptive Loop filter |
---|
140 | m_pcSAO = pcTEncTop->getSAO(); |
---|
141 | m_pcRdCost = pcTEncTop->getRdCost(); |
---|
142 | } |
---|
143 | |
---|
144 | // ==================================================================================================================== |
---|
145 | // Public member functions |
---|
146 | // ==================================================================================================================== |
---|
147 | |
---|
148 | Void TEncGOP::initGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP) |
---|
149 | { |
---|
150 | xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut ); |
---|
151 | m_iNumPicCoded = 0; |
---|
152 | } |
---|
153 | |
---|
154 | Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid) |
---|
155 | { |
---|
156 | TComPic* pcPic; |
---|
157 | TComPicYuv* pcPicYuvRecOut; |
---|
158 | TComSlice* pcSlice; |
---|
159 | TComOutputBitstream *pcBitstreamRedirect; |
---|
160 | pcBitstreamRedirect = new TComOutputBitstream; |
---|
161 | AccessUnit::iterator itLocationToPushSliceHeaderNALU; // used to store location where NALU containing slice header is to be inserted |
---|
162 | UInt uiOneBitstreamPerSliceLength = 0; |
---|
163 | TEncSbac* pcSbacCoders = NULL; |
---|
164 | TComOutputBitstream* pcSubstreamsOut = NULL; |
---|
165 | |
---|
166 | { |
---|
167 | UInt uiColDir = 1; |
---|
168 | //-- For time output for each slice |
---|
169 | long iBeforeTime = clock(); |
---|
170 | |
---|
171 | //select uiColDir |
---|
172 | Int iCloseLeft=1, iCloseRight=-1; |
---|
173 | for(Int i = 0; i<m_pcCfg->getGOPEntry(iGOPid).m_numRefPics; i++) |
---|
174 | { |
---|
175 | Int iRef = m_pcCfg->getGOPEntry(iGOPid).m_referencePics[i]; |
---|
176 | if(iRef>0&&(iRef<iCloseRight||iCloseRight==-1)) |
---|
177 | { |
---|
178 | iCloseRight=iRef; |
---|
179 | } |
---|
180 | else if(iRef<0&&(iRef>iCloseLeft||iCloseLeft==1)) |
---|
181 | { |
---|
182 | iCloseLeft=iRef; |
---|
183 | } |
---|
184 | } |
---|
185 | if(iCloseRight>-1) |
---|
186 | { |
---|
187 | iCloseRight=iCloseRight+m_pcCfg->getGOPEntry(iGOPid).m_POC-1; |
---|
188 | } |
---|
189 | if(iCloseLeft<1) |
---|
190 | { |
---|
191 | iCloseLeft=iCloseLeft+m_pcCfg->getGOPEntry(iGOPid).m_POC-1; |
---|
192 | while(iCloseLeft<0) |
---|
193 | { |
---|
194 | iCloseLeft+=m_iGopSize; |
---|
195 | } |
---|
196 | } |
---|
197 | Int iLeftQP=0, iRightQP=0; |
---|
198 | for(Int i=0; i<m_iGopSize; i++) |
---|
199 | { |
---|
200 | if(m_pcCfg->getGOPEntry(i).m_POC==(iCloseLeft%m_iGopSize)+1) |
---|
201 | { |
---|
202 | iLeftQP= m_pcCfg->getGOPEntry(i).m_QPOffset; |
---|
203 | } |
---|
204 | if (m_pcCfg->getGOPEntry(i).m_POC==(iCloseRight%m_iGopSize)+1) |
---|
205 | { |
---|
206 | iRightQP=m_pcCfg->getGOPEntry(i).m_QPOffset; |
---|
207 | } |
---|
208 | } |
---|
209 | if(iCloseRight>-1&&iRightQP<iLeftQP) |
---|
210 | { |
---|
211 | uiColDir=0; |
---|
212 | } |
---|
213 | |
---|
214 | /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding |
---|
215 | UInt uiPOCCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC; |
---|
216 | Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; |
---|
217 | if(iPOCLast == 0) |
---|
218 | { |
---|
219 | uiPOCCurr=0; |
---|
220 | iTimeOffset = 1; |
---|
221 | } |
---|
222 | if(uiPOCCurr>=m_pcCfg->getFrameToBeEncoded()) |
---|
223 | { |
---|
224 | return; |
---|
225 | } |
---|
226 | if( getNalUnitTypeBaseViewMvc( uiPOCCurr ) == NAL_UNIT_CODED_SLICE_IDR ) |
---|
227 | { |
---|
228 | m_iLastIDR = uiPOCCurr; |
---|
229 | } |
---|
230 | |
---|
231 | /* start a new access unit: create an entry in the list of output |
---|
232 | * access units */ |
---|
233 | accessUnitsInGOP.push_back(AccessUnit()); |
---|
234 | AccessUnit& accessUnit = accessUnitsInGOP.back(); |
---|
235 | xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, uiPOCCurr ); |
---|
236 | |
---|
237 | // Slice data initialization |
---|
238 | pcPic->clearSliceBuffer(); |
---|
239 | assert(pcPic->getNumAllocatedSlice() == 1); |
---|
240 | m_pcSliceEncoder->setSliceIdx(0); |
---|
241 | pcPic->setCurrSliceIdx(0); |
---|
242 | |
---|
243 | std::vector<TComAPS>& vAPS = m_pcEncTop->getAPS(); |
---|
244 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
245 | #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 |
---|
246 | m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getEncTop()->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getIsDepth() ); |
---|
247 | #else |
---|
248 | m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getEncTop()->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); |
---|
249 | #endif |
---|
250 | #else |
---|
251 | m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); |
---|
252 | #endif |
---|
253 | pcSlice->setLastIDR(m_iLastIDR); |
---|
254 | pcSlice->setSliceIdx(0); |
---|
255 | pcSlice->setViewId( m_pcEncTop->getViewId() ); |
---|
256 | pcSlice->setIsDepth( m_pcEncTop->getIsDepth() ); |
---|
257 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
258 | pcSlice->setIVScalingFlag( m_pcEncTop->getUseIVS() ); |
---|
259 | #endif |
---|
260 | |
---|
261 | m_pcEncTop->getSPS()->setDisInter4x4(m_pcEncTop->getDisInter4x4()); |
---|
262 | pcSlice->setScalingList ( m_pcEncTop->getScalingList() ); |
---|
263 | if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) |
---|
264 | { |
---|
265 | m_pcEncTop->getTrQuant()->setFlatScalingList(); |
---|
266 | m_pcEncTop->getTrQuant()->setUseScalingList(false); |
---|
267 | } |
---|
268 | else if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_DEFAULT) |
---|
269 | { |
---|
270 | pcSlice->setDefaultScalingList (); |
---|
271 | pcSlice->getScalingList()->setScalingListPresentFlag(true); |
---|
272 | m_pcEncTop->getTrQuant()->setScalingList(pcSlice->getScalingList()); |
---|
273 | m_pcEncTop->getTrQuant()->setUseScalingList(true); |
---|
274 | } |
---|
275 | else if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_FILE_READ) |
---|
276 | { |
---|
277 | if(pcSlice->getScalingList()->xParseScalingList(m_pcCfg->getScalingListFile())) |
---|
278 | { |
---|
279 | pcSlice->setDefaultScalingList (); |
---|
280 | } |
---|
281 | pcSlice->getScalingList()->checkDcOfMatrix(); |
---|
282 | pcSlice->getScalingList()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList()); |
---|
283 | m_pcEncTop->getTrQuant()->setScalingList(pcSlice->getScalingList()); |
---|
284 | m_pcEncTop->getTrQuant()->setUseScalingList(true); |
---|
285 | } |
---|
286 | else |
---|
287 | { |
---|
288 | printf("error : ScalingList == %d no support\n",m_pcEncTop->getUseScalingListId()); |
---|
289 | assert(0); |
---|
290 | } |
---|
291 | |
---|
292 | #if HHI_INTERVIEW_SKIP |
---|
293 | if ( m_pcEncTop->getInterViewSkip() ) |
---|
294 | { |
---|
295 | m_pcEncTop->getEncTop()->getUsedPelsMap( pcPic->getViewId(), pcPic->getPOC(), pcPic->getUsedPelsMap() ); |
---|
296 | } |
---|
297 | #endif |
---|
298 | // Slice info. refinement |
---|
299 | if( pcSlice->getSliceType() == B_SLICE ) |
---|
300 | { |
---|
301 | #if QC_REM_IDV_B0046 |
---|
302 | if( m_pcCfg->getGOPEntry(pcSlice->getSPS()->getViewId() && ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA))? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); } |
---|
303 | #else |
---|
304 | if( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); } |
---|
305 | #endif |
---|
306 | } |
---|
307 | |
---|
308 | // Set the nal unit type |
---|
309 | pcSlice->setNalUnitType( getNalUnitType(uiPOCCurr) ); |
---|
310 | pcSlice->setNalUnitTypeBaseViewMvc( getNalUnitTypeBaseViewMvc(uiPOCCurr) ); |
---|
311 | |
---|
312 | // Do decoding refresh marking if any |
---|
313 | pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic); |
---|
314 | |
---|
315 | if ( !pcSlice->getPPS()->getEnableTMVPFlag() && pcPic->getTLayer() == 0 ) |
---|
316 | { |
---|
317 | pcSlice->decodingMarkingForNoTMVP( rcListPic, pcSlice->getPOC() ); |
---|
318 | } |
---|
319 | |
---|
320 | m_pcEncTop->selectReferencePictureSet(pcSlice, uiPOCCurr, iGOPid,rcListPic); |
---|
321 | pcSlice->getRPS()->setNumberOfLongtermPictures(0); |
---|
322 | |
---|
323 | if(pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) |
---|
324 | { |
---|
325 | pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS()); |
---|
326 | } |
---|
327 | pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS()); |
---|
328 | |
---|
329 | #if H0566_TLA_SET_FOR_SWITCHING_POINTS |
---|
330 | if(pcSlice->getTLayer() > 0) |
---|
331 | { |
---|
332 | if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic, pcSlice->getRPS())) |
---|
333 | { |
---|
334 | pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA); |
---|
335 | } |
---|
336 | } |
---|
337 | #endif |
---|
338 | |
---|
339 | #if !QC_REM_IDV_B0046 |
---|
340 | pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); |
---|
341 | pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); |
---|
342 | #else |
---|
343 | |
---|
344 | Bool bNalRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId()) ? 1: 0; |
---|
345 | pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); |
---|
346 | pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) ); |
---|
347 | #endif |
---|
348 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
349 | refPicListModification->setRefPicListModificationFlagL0( false ); |
---|
350 | refPicListModification->setRefPicListModificationFlagL1( false ); |
---|
351 | xSetRefPicListModificationsMvc( pcSlice, uiPOCCurr, iGOPid ); |
---|
352 | |
---|
353 | #if ADAPTIVE_QP_SELECTION |
---|
354 | pcSlice->setTrQuant( m_pcEncTop->getTrQuant() ); |
---|
355 | #endif |
---|
356 | // Set reference list |
---|
357 | TAppEncTop* tAppEncTop = m_pcEncTop->getEncTop(); |
---|
358 | assert( tAppEncTop != NULL ); |
---|
359 | |
---|
360 | |
---|
361 | #if FLEX_CODING_ORDER_M23723 |
---|
362 | TComPic * pcTexturePic; |
---|
363 | if(m_pcEncTop->getIsDepth() == 1) |
---|
364 | { |
---|
365 | TComPicYuv * recText; |
---|
366 | recText = tAppEncTop->getPicYuvFromView(m_pcEncTop->getViewId(), pcSlice->getPOC(), false ,true); |
---|
367 | if(recText == NULL) |
---|
368 | { |
---|
369 | pcSlice->setTexturePic(NULL); |
---|
370 | } |
---|
371 | else |
---|
372 | { |
---|
373 | pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL; |
---|
374 | pcSlice->setTexturePic( pcTexturePic ); |
---|
375 | } |
---|
376 | } |
---|
377 | else |
---|
378 | { |
---|
379 | pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL; |
---|
380 | assert( !m_pcEncTop->getIsDepth() || pcTexturePic != NULL ); |
---|
381 | pcSlice->setTexturePic( pcTexturePic ); |
---|
382 | } |
---|
383 | |
---|
384 | #else |
---|
385 | TComPic * const pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL; |
---|
386 | assert( !m_pcEncTop->getIsDepth() || pcTexturePic != NULL ); |
---|
387 | pcSlice->setTexturePic( pcTexturePic ); |
---|
388 | |
---|
389 | #endif |
---|
390 | std::vector<TComPic*> apcInterViewRefPics = tAppEncTop->getInterViewRefPics( m_pcEncTop->getViewId(), pcSlice->getPOC(), m_pcEncTop->getIsDepth(), pcSlice->getSPS() ); |
---|
391 | pcSlice->setRefPicListMvc( rcListPic, apcInterViewRefPics ); |
---|
392 | |
---|
393 | // Slice info. refinement |
---|
394 | if( pcSlice->getSliceType() == B_SLICE ) |
---|
395 | { |
---|
396 | #if !QC_REM_IDV_B0046 |
---|
397 | if( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); } |
---|
398 | #else |
---|
399 | Bool bRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId()) ? 1: 0; |
---|
400 | if( m_pcCfg->getGOPEntry( bRAP ? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); } |
---|
401 | #endif |
---|
402 | } |
---|
403 | |
---|
404 | if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb()) |
---|
405 | { |
---|
406 | pcSlice->setNumRefIdx(REF_PIC_LIST_C, 0); |
---|
407 | pcSlice->setRefPicListCombinationFlag(false); |
---|
408 | pcSlice->setRefPicListModificationFlagLC(false); |
---|
409 | } |
---|
410 | else |
---|
411 | { |
---|
412 | pcSlice->setRefPicListCombinationFlag(pcSlice->getSPS()->getUseLComb()); |
---|
413 | pcSlice->setRefPicListModificationFlagLC(pcSlice->getSPS()->getLCMod()); |
---|
414 | pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0)); |
---|
415 | } |
---|
416 | |
---|
417 | if (pcSlice->getSliceType() == B_SLICE) |
---|
418 | { |
---|
419 | pcSlice->setColDir(uiColDir); |
---|
420 | Bool bLowDelay = true; |
---|
421 | Int iCurrPOC = pcSlice->getPOC(); |
---|
422 | Int iRefIdx = 0; |
---|
423 | |
---|
424 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
425 | { |
---|
426 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
427 | { |
---|
428 | bLowDelay = false; |
---|
429 | } |
---|
430 | } |
---|
431 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
432 | { |
---|
433 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
434 | { |
---|
435 | bLowDelay = false; |
---|
436 | } |
---|
437 | } |
---|
438 | |
---|
439 | pcSlice->setCheckLDC(bLowDelay); |
---|
440 | } |
---|
441 | |
---|
442 | uiColDir = 1-uiColDir; |
---|
443 | |
---|
444 | //------------------------------------------------------------- |
---|
445 | pcSlice->setRefPOCnViewListsMvc(); |
---|
446 | |
---|
447 | pcSlice->setNoBackPredFlag( false ); |
---|
448 | if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag()) |
---|
449 | { |
---|
450 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
451 | { |
---|
452 | pcSlice->setNoBackPredFlag( true ); |
---|
453 | int i; |
---|
454 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
455 | { |
---|
456 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
457 | { |
---|
458 | pcSlice->setNoBackPredFlag( false ); |
---|
459 | break; |
---|
460 | } |
---|
461 | } |
---|
462 | } |
---|
463 | } |
---|
464 | |
---|
465 | if(pcSlice->getNoBackPredFlag()) |
---|
466 | { |
---|
467 | pcSlice->setNumRefIdx(REF_PIC_LIST_C, 0); |
---|
468 | } |
---|
469 | pcSlice->generateCombinedList(); |
---|
470 | |
---|
471 | #if HHI_VSO |
---|
472 | Bool bUseVSO = m_pcEncTop->getUseVSO(); |
---|
473 | m_pcRdCost->setUseVSO( bUseVSO ); |
---|
474 | #if SAIT_VSO_EST_A0033 |
---|
475 | m_pcRdCost->setUseEstimatedVSD( m_pcEncTop->getUseEstimatedVSD() ); |
---|
476 | #endif |
---|
477 | |
---|
478 | if ( bUseVSO ) |
---|
479 | { |
---|
480 | Int iVSOMode = m_pcEncTop->getVSOMode(); |
---|
481 | m_pcRdCost->setVSOMode( iVSOMode ); |
---|
482 | |
---|
483 | #if HHI_VSO_DIST_INT |
---|
484 | m_pcRdCost->setAllowNegDist( m_pcEncTop->getAllowNegDist() ); |
---|
485 | #endif |
---|
486 | |
---|
487 | |
---|
488 | #if SAIT_VSO_EST_A0033 |
---|
489 | #ifdef FLEX_CODING_ORDER_M23723 |
---|
490 | { |
---|
491 | Bool flagRec; |
---|
492 | flagRec = ((m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, true) == NULL) ? false: true); |
---|
493 | m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, flagRec ) ); |
---|
494 | m_pcRdCost->setDepthPicYuv ( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) ); |
---|
495 | } |
---|
496 | #else |
---|
497 | m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, true ) ); |
---|
498 | m_pcRdCost->setDepthPicYuv ( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) ); |
---|
499 | #endif |
---|
500 | #endif |
---|
501 | #if LGE_WVSO_A0119 |
---|
502 | Bool bUseWVSO = m_pcEncTop->getUseWVSO(); |
---|
503 | m_pcRdCost->setUseWVSO( bUseWVSO ); |
---|
504 | #endif |
---|
505 | |
---|
506 | } |
---|
507 | #endif |
---|
508 | /////////////////////////////////////////////////////////////////////////////////////////////////// Compress a slice |
---|
509 | // Slice compression |
---|
510 | if (m_pcCfg->getUseASR()) |
---|
511 | { |
---|
512 | m_pcSliceEncoder->setSearchRange(pcSlice); |
---|
513 | } |
---|
514 | |
---|
515 | Bool bGPBcheck=false; |
---|
516 | if ( pcSlice->getSliceType() == B_SLICE) |
---|
517 | { |
---|
518 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
519 | { |
---|
520 | bGPBcheck=true; |
---|
521 | int i; |
---|
522 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
523 | { |
---|
524 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
525 | { |
---|
526 | bGPBcheck=false; |
---|
527 | break; |
---|
528 | } |
---|
529 | } |
---|
530 | } |
---|
531 | } |
---|
532 | if(bGPBcheck) |
---|
533 | { |
---|
534 | pcSlice->setMvdL1ZeroFlag(true); |
---|
535 | } |
---|
536 | else |
---|
537 | { |
---|
538 | pcSlice->setMvdL1ZeroFlag(false); |
---|
539 | } |
---|
540 | pcPic->getSlice(pcSlice->getSliceIdx())->setMvdL1ZeroFlag(pcSlice->getMvdL1ZeroFlag()); |
---|
541 | |
---|
542 | UInt uiNumSlices = 1; |
---|
543 | |
---|
544 | UInt uiInternalAddress = pcPic->getNumPartInCU()-4; |
---|
545 | UInt uiExternalAddress = pcPic->getPicSym()->getNumberOfCUsInFrame()-1; |
---|
546 | UInt uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
547 | UInt uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
548 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
549 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
550 | while(uiPosX>=uiWidth||uiPosY>=uiHeight) |
---|
551 | { |
---|
552 | uiInternalAddress--; |
---|
553 | uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
554 | uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
555 | } |
---|
556 | uiInternalAddress++; |
---|
557 | if(uiInternalAddress==pcPic->getNumPartInCU()) |
---|
558 | { |
---|
559 | uiInternalAddress = 0; |
---|
560 | uiExternalAddress++; |
---|
561 | } |
---|
562 | UInt uiRealEndAddress = uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress; |
---|
563 | |
---|
564 | UInt uiCummulativeTileWidth; |
---|
565 | UInt uiCummulativeTileHeight; |
---|
566 | Int p, j; |
---|
567 | UInt uiEncCUAddr; |
---|
568 | |
---|
569 | |
---|
570 | if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 ) //derive the tile parameters from PPS |
---|
571 | { |
---|
572 | //set NumColumnsMinus1 and NumRowsMinus1 |
---|
573 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
574 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
575 | |
---|
576 | //create the TComTileArray |
---|
577 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
578 | |
---|
579 | if( pcSlice->getPPS()->getUniformSpacingIdr() == 1 ) |
---|
580 | { |
---|
581 | //set the width for each tile |
---|
582 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
583 | { |
---|
584 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
585 | { |
---|
586 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
587 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
588 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
589 | } |
---|
590 | } |
---|
591 | |
---|
592 | //set the height for each tile |
---|
593 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
594 | { |
---|
595 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
596 | { |
---|
597 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
598 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
599 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
600 | } |
---|
601 | } |
---|
602 | } |
---|
603 | else |
---|
604 | { |
---|
605 | //set the width for each tile |
---|
606 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
607 | { |
---|
608 | uiCummulativeTileWidth = 0; |
---|
609 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1(); p++) |
---|
610 | { |
---|
611 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->setTileWidth( pcSlice->getPPS()->getColumnWidth(p) ); |
---|
612 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(p); |
---|
613 | } |
---|
614 | pcPic->getPicSym()->getTComTile(j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
615 | } |
---|
616 | |
---|
617 | //set the height for each tile |
---|
618 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
619 | { |
---|
620 | uiCummulativeTileHeight = 0; |
---|
621 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1(); p++) |
---|
622 | { |
---|
623 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->setTileHeight( pcSlice->getPPS()->getRowHeight(p) ); |
---|
624 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(p); |
---|
625 | } |
---|
626 | pcPic->getPicSym()->getTComTile(p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
627 | } |
---|
628 | } |
---|
629 | } |
---|
630 | else //derive the tile parameters from SPS |
---|
631 | { |
---|
632 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
633 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getSPS()->getNumColumnsMinus1() ); |
---|
634 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getSPS()->getNumRowsMinus1() ); |
---|
635 | |
---|
636 | //create the TComTileArray |
---|
637 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
638 | |
---|
639 | if( pcSlice->getSPS()->getUniformSpacingIdr() == 1 ) |
---|
640 | { |
---|
641 | //set the width for each tile |
---|
642 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
643 | { |
---|
644 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
645 | { |
---|
646 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
647 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
648 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
649 | } |
---|
650 | } |
---|
651 | |
---|
652 | //set the height for each tile |
---|
653 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
654 | { |
---|
655 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
656 | { |
---|
657 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
658 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
659 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
660 | } |
---|
661 | } |
---|
662 | } |
---|
663 | |
---|
664 | else |
---|
665 | { |
---|
666 | //set the width for each tile |
---|
667 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
668 | { |
---|
669 | uiCummulativeTileWidth = 0; |
---|
670 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1(); p++) |
---|
671 | { |
---|
672 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->setTileWidth( pcSlice->getSPS()->getColumnWidth(p) ); |
---|
673 | uiCummulativeTileWidth += pcSlice->getSPS()->getColumnWidth(p); |
---|
674 | } |
---|
675 | pcPic->getPicSym()->getTComTile(j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
676 | } |
---|
677 | |
---|
678 | //set the height for each tile |
---|
679 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
680 | { |
---|
681 | uiCummulativeTileHeight = 0; |
---|
682 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1(); p++) |
---|
683 | { |
---|
684 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->setTileHeight( pcSlice->getSPS()->getRowHeight(p) ); |
---|
685 | uiCummulativeTileHeight += pcSlice->getSPS()->getRowHeight(p); |
---|
686 | } |
---|
687 | pcPic->getPicSym()->getTComTile(p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
688 | } |
---|
689 | } |
---|
690 | } |
---|
691 | |
---|
692 | //initialize each tile of the current picture |
---|
693 | pcPic->getPicSym()->xInitTiles(); |
---|
694 | |
---|
695 | // Allocate some coders, now we know how many tiles there are. |
---|
696 | Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); |
---|
697 | |
---|
698 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
699 | for(p=0, uiEncCUAddr=0; p<pcPic->getPicSym()->getNumberOfCUsInFrame(); p++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
700 | { |
---|
701 | pcPic->getPicSym()->setCUOrderMap(p, uiEncCUAddr); |
---|
702 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, p); |
---|
703 | } |
---|
704 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
705 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
706 | if (pcSlice->getPPS()->getEntropyCodingMode()) |
---|
707 | { |
---|
708 | // Allocate some coders, now we know how many tiles there are. |
---|
709 | m_pcEncTop->createWPPCoders(iNumSubstreams); |
---|
710 | pcSbacCoders = m_pcEncTop->getSbacCoders(); |
---|
711 | pcSubstreamsOut = new TComOutputBitstream[iNumSubstreams]; |
---|
712 | } |
---|
713 | |
---|
714 | UInt uiStartCUAddrSliceIdx = 0; // used to index "m_uiStoredStartCUAddrForEncodingSlice" containing locations of slice boundaries |
---|
715 | UInt uiStartCUAddrSlice = 0; // used to keep track of current slice's starting CU addr. |
---|
716 | pcSlice->setSliceCurStartCUAddr( uiStartCUAddrSlice ); // Setting "start CU addr" for current slice |
---|
717 | memset(m_uiStoredStartCUAddrForEncodingSlice, 0, sizeof(UInt) * (pcPic->getPicSym()->getNumberOfCUsInFrame()*pcPic->getNumPartInCU()+1)); |
---|
718 | |
---|
719 | UInt uiStartCUAddrEntropySliceIdx = 0; // used to index "m_uiStoredStartCUAddrForEntropyEncodingSlice" containing locations of slice boundaries |
---|
720 | UInt uiStartCUAddrEntropySlice = 0; // used to keep track of current Entropy slice's starting CU addr. |
---|
721 | pcSlice->setEntropySliceCurStartCUAddr( uiStartCUAddrEntropySlice ); // Setting "start CU addr" for current Entropy slice |
---|
722 | |
---|
723 | memset(m_uiStoredStartCUAddrForEncodingEntropySlice, 0, sizeof(UInt) * (pcPic->getPicSym()->getNumberOfCUsInFrame()*pcPic->getNumPartInCU()+1)); |
---|
724 | UInt uiNextCUAddr = 0; |
---|
725 | m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx++] = uiNextCUAddr; |
---|
726 | m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx++] = uiNextCUAddr; |
---|
727 | |
---|
728 | #if FCO_DVP_REFINE_C0132_C0170 |
---|
729 | pcPic->setDepthCoded(false); |
---|
730 | |
---|
731 | if(pcSlice->getViewId() != 0) |
---|
732 | { |
---|
733 | if(pcSlice->getSPS()->isDepth() == 0 ) |
---|
734 | { |
---|
735 | TComPic * recDepthMapBuffer; |
---|
736 | recDepthMapBuffer = m_pcEncTop->getEncTop()->getPicFromView( pcSlice->getViewId(), pcSlice->getPOC(), true ); |
---|
737 | pcSlice->getPic()->setRecDepthMap(recDepthMapBuffer); |
---|
738 | if(recDepthMapBuffer->getReconMark()) |
---|
739 | { |
---|
740 | pcPic->setDepthCoded(true); |
---|
741 | } |
---|
742 | } |
---|
743 | } |
---|
744 | #endif |
---|
745 | |
---|
746 | #if DEPTH_MAP_GENERATION |
---|
747 | // init view component and predict virtual depth map |
---|
748 | m_pcDepthMapGenerator->initViewComponent( pcPic ); |
---|
749 | #if !H3D_NBDV |
---|
750 | m_pcDepthMapGenerator->predictDepthMap ( pcPic ); |
---|
751 | #endif |
---|
752 | #endif |
---|
753 | #if H3D_IVMP |
---|
754 | m_pcDepthMapGenerator->covertOrgDepthMap( pcPic ); |
---|
755 | #endif |
---|
756 | #if H3D_IVRP |
---|
757 | m_pcResidualGenerator->initViewComponent( pcPic ); |
---|
758 | #endif |
---|
759 | |
---|
760 | #if H3D_NBDV |
---|
761 | if(pcSlice->getViewId() && pcSlice->getSPS()->getMultiviewMvPredMode()) |
---|
762 | { |
---|
763 | Int iColPoc = pcSlice->getRefPOC(RefPicList(pcSlice->getColDir()), pcSlice->getColRefIdx()); |
---|
764 | pcPic->setRapbCheck(pcPic->getDisCandRefPictures(iColPoc)); |
---|
765 | } |
---|
766 | #endif |
---|
767 | while(uiNextCUAddr<uiRealEndAddress) // determine slice boundaries |
---|
768 | { |
---|
769 | pcSlice->setNextSlice ( false ); |
---|
770 | pcSlice->setNextEntropySlice( false ); |
---|
771 | assert(pcPic->getNumAllocatedSlice() == uiStartCUAddrSliceIdx); |
---|
772 | m_pcSliceEncoder->precompressSlice( pcPic ); |
---|
773 | m_pcSliceEncoder->compressSlice ( pcPic ); |
---|
774 | |
---|
775 | Bool bNoBinBitConstraintViolated = (!pcSlice->isNextSlice() && !pcSlice->isNextEntropySlice()); |
---|
776 | if (pcSlice->isNextSlice() || (bNoBinBitConstraintViolated && m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)) |
---|
777 | { |
---|
778 | uiStartCUAddrSlice = pcSlice->getSliceCurEndCUAddr(); |
---|
779 | // Reconstruction slice |
---|
780 | m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx++] = uiStartCUAddrSlice; |
---|
781 | // Entropy slice |
---|
782 | if (uiStartCUAddrEntropySliceIdx>0 && m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx-1] != uiStartCUAddrSlice) |
---|
783 | { |
---|
784 | m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx++] = uiStartCUAddrSlice; |
---|
785 | } |
---|
786 | |
---|
787 | if (uiStartCUAddrSlice < uiRealEndAddress) |
---|
788 | { |
---|
789 | pcPic->allocateNewSlice(); |
---|
790 | pcPic->setCurrSliceIdx ( uiStartCUAddrSliceIdx-1 ); |
---|
791 | m_pcSliceEncoder->setSliceIdx ( uiStartCUAddrSliceIdx-1 ); |
---|
792 | pcSlice = pcPic->getSlice ( uiStartCUAddrSliceIdx-1 ); |
---|
793 | pcSlice->copySliceInfo ( pcPic->getSlice(0) ); |
---|
794 | pcSlice->setSliceIdx ( uiStartCUAddrSliceIdx-1 ); |
---|
795 | pcSlice->setSliceCurStartCUAddr ( uiStartCUAddrSlice ); |
---|
796 | pcSlice->setEntropySliceCurStartCUAddr ( uiStartCUAddrSlice ); |
---|
797 | pcSlice->setSliceBits(0); |
---|
798 | uiNumSlices ++; |
---|
799 | } |
---|
800 | } |
---|
801 | else if (pcSlice->isNextEntropySlice() || (bNoBinBitConstraintViolated && m_pcCfg->getEntropySliceMode()==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)) |
---|
802 | { |
---|
803 | uiStartCUAddrEntropySlice = pcSlice->getEntropySliceCurEndCUAddr(); |
---|
804 | m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx++] = uiStartCUAddrEntropySlice; |
---|
805 | pcSlice->setEntropySliceCurStartCUAddr( uiStartCUAddrEntropySlice ); |
---|
806 | } |
---|
807 | else |
---|
808 | { |
---|
809 | uiStartCUAddrSlice = pcSlice->getSliceCurEndCUAddr(); |
---|
810 | uiStartCUAddrEntropySlice = pcSlice->getEntropySliceCurEndCUAddr(); |
---|
811 | } |
---|
812 | |
---|
813 | uiNextCUAddr = (uiStartCUAddrSlice > uiStartCUAddrEntropySlice) ? uiStartCUAddrSlice : uiStartCUAddrEntropySlice; |
---|
814 | } |
---|
815 | m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx++] = pcSlice->getSliceCurEndCUAddr(); |
---|
816 | m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx++] = pcSlice->getSliceCurEndCUAddr(); |
---|
817 | |
---|
818 | pcSlice = pcPic->getSlice(0); |
---|
819 | |
---|
820 | #if H3D_IVRP |
---|
821 | // set residual picture |
---|
822 | m_pcResidualGenerator->setRecResidualPic( pcPic ); |
---|
823 | #endif |
---|
824 | #if DEPTH_MAP_GENERATION |
---|
825 | #if !H3D_NBDV |
---|
826 | // update virtual depth map |
---|
827 | m_pcDepthMapGenerator->updateDepthMap( pcPic ); |
---|
828 | #endif |
---|
829 | #endif |
---|
830 | |
---|
831 | //-- Loop filter |
---|
832 | Bool bLFCrossTileBoundary = (pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1)? |
---|
833 | (pcSlice->getPPS()->getLFCrossTileBoundaryFlag()):(pcSlice->getPPS()->getSPS()->getLFCrossTileBoundaryFlag()); |
---|
834 | m_pcLoopFilter->setCfg(pcSlice->getPPS()->getDeblockingFilterControlPresent(), pcSlice->getLoopFilterDisable(), pcSlice->getLoopFilterBetaOffset(), pcSlice->getLoopFilterTcOffset(), bLFCrossTileBoundary); |
---|
835 | m_pcLoopFilter->loopFilterPic( pcPic ); |
---|
836 | |
---|
837 | pcSlice = pcPic->getSlice(0); |
---|
838 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()) |
---|
839 | { |
---|
840 | Int sliceGranularity = pcSlice->getPPS()->getSliceGranularity(); |
---|
841 | pcPic->createNonDBFilterInfo(m_uiStoredStartCUAddrForEncodingSlice, uiNumSlices, sliceGranularity, pcSlice->getSPS()->getLFCrossSliceBoundaryFlag(),pcPic->getPicSym()->getNumTiles() ,bLFCrossTileBoundary); |
---|
842 | } |
---|
843 | |
---|
844 | |
---|
845 | pcSlice = pcPic->getSlice(0); |
---|
846 | |
---|
847 | if(pcSlice->getSPS()->getUseSAO()) |
---|
848 | { |
---|
849 | m_pcSAO->createPicSaoInfo(pcPic, uiNumSlices); |
---|
850 | } |
---|
851 | |
---|
852 | AlfParamSet* alfSliceParams = NULL; |
---|
853 | std::vector<AlfCUCtrlInfo>* alfCUCtrlParam = NULL; |
---|
854 | pcSlice = pcPic->getSlice(0); |
---|
855 | |
---|
856 | if(pcSlice->getSPS()->getUseALF()) |
---|
857 | { |
---|
858 | m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic, uiNumSlices, pcSlice->getSliceQp()); |
---|
859 | m_pcAdaptiveLoopFilter->initALFEnc(m_pcCfg->getALFParamInSlice(), m_pcCfg->getALFPicBasedEncode(), uiNumSlices, alfSliceParams, alfCUCtrlParam); |
---|
860 | } |
---|
861 | |
---|
862 | /////////////////////////////////////////////////////////////////////////////////////////////////// File writing |
---|
863 | // Set entropy coder |
---|
864 | m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); |
---|
865 | |
---|
866 | /* write various header sets. */ |
---|
867 | if ( m_bSeqFirst ) |
---|
868 | { |
---|
869 | #if QC_MVHEVC_B0046 |
---|
870 | if(!m_pcEncTop->getLayerId()) |
---|
871 | { |
---|
872 | #endif |
---|
873 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
874 | { |
---|
875 | OutputNALUnit nalu(NAL_UNIT_VPS, true, m_pcEncTop->getLayerId()); |
---|
876 | m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); |
---|
877 | m_pcEntropyCoder->encodeVPS(m_pcEncTop->getEncTop()->getVPS()); |
---|
878 | writeRBSPTrailingBits(nalu.m_Bitstream); |
---|
879 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
880 | } |
---|
881 | #endif |
---|
882 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
883 | OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getLayerId()); |
---|
884 | #else |
---|
885 | OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); |
---|
886 | #endif |
---|
887 | m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); |
---|
888 | pcSlice->getSPS()->setNumSubstreams( pcSlice->getPPS()->getNumSubstreams() ); |
---|
889 | #if HHI_MPI || H3D_QTL |
---|
890 | m_pcEntropyCoder->encodeSPS(pcSlice->getSPS(), m_pcEncTop->getIsDepth()); |
---|
891 | #else |
---|
892 | m_pcEntropyCoder->encodeSPS(pcSlice->getSPS()); |
---|
893 | #endif |
---|
894 | writeRBSPTrailingBits(nalu.m_Bitstream); |
---|
895 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
896 | |
---|
897 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
898 | #if QC_MVHEVC_B0046 |
---|
899 | nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getLayerId()); |
---|
900 | #else |
---|
901 | nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getLayerId()); |
---|
902 | #endif |
---|
903 | #else |
---|
904 | nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); |
---|
905 | #endif |
---|
906 | m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); |
---|
907 | m_pcEntropyCoder->encodePPS(pcSlice->getPPS()); |
---|
908 | writeRBSPTrailingBits(nalu.m_Bitstream); |
---|
909 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
910 | #if QC_MVHEVC_B0046 |
---|
911 | } |
---|
912 | #endif |
---|
913 | m_bSeqFirst = false; |
---|
914 | } |
---|
915 | |
---|
916 | /* use the main bitstream buffer for storing the marshalled picture */ |
---|
917 | m_pcEntropyCoder->setBitstream(NULL); |
---|
918 | |
---|
919 | uiStartCUAddrSliceIdx = 0; |
---|
920 | uiStartCUAddrSlice = 0; |
---|
921 | |
---|
922 | uiStartCUAddrEntropySliceIdx = 0; |
---|
923 | uiStartCUAddrEntropySlice = 0; |
---|
924 | uiNextCUAddr = 0; |
---|
925 | pcSlice = pcPic->getSlice(uiStartCUAddrSliceIdx); |
---|
926 | |
---|
927 | Int processingState = (pcSlice->getSPS()->getUseALF() || pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getScalingListFlag() || pcSlice->getSPS()->getUseDF())?(EXECUTE_INLOOPFILTER):(ENCODE_SLICE); |
---|
928 | |
---|
929 | static Int iCurrAPSIdx = 0; |
---|
930 | Int iCodedAPSIdx = 0; |
---|
931 | TComSlice* pcSliceForAPS = NULL; |
---|
932 | |
---|
933 | bool skippedSlice=false; |
---|
934 | while (uiNextCUAddr < uiRealEndAddress) // Iterate over all slices |
---|
935 | { |
---|
936 | switch(processingState) |
---|
937 | { |
---|
938 | case ENCODE_SLICE: |
---|
939 | { |
---|
940 | pcSlice->setNextSlice ( false ); |
---|
941 | pcSlice->setNextEntropySlice( false ); |
---|
942 | if (uiNextCUAddr == m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx]) |
---|
943 | { |
---|
944 | pcSlice = pcPic->getSlice(uiStartCUAddrSliceIdx); |
---|
945 | #if COLLOCATED_REF_IDX |
---|
946 | if(uiStartCUAddrSliceIdx > 0 && pcSlice->getSliceType()!= I_SLICE) |
---|
947 | { |
---|
948 | pcSlice->checkColRefIdx(uiStartCUAddrSliceIdx, pcPic); |
---|
949 | } |
---|
950 | #endif |
---|
951 | pcPic->setCurrSliceIdx(uiStartCUAddrSliceIdx); |
---|
952 | m_pcSliceEncoder->setSliceIdx(uiStartCUAddrSliceIdx); |
---|
953 | assert(uiStartCUAddrSliceIdx == pcSlice->getSliceIdx()); |
---|
954 | // Reconstruction slice |
---|
955 | pcSlice->setSliceCurStartCUAddr( uiNextCUAddr ); // to be used in encodeSlice() + context restriction |
---|
956 | pcSlice->setSliceCurEndCUAddr ( m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx+1 ] ); |
---|
957 | // Entropy slice |
---|
958 | pcSlice->setEntropySliceCurStartCUAddr( uiNextCUAddr ); // to be used in encodeSlice() + context restriction |
---|
959 | pcSlice->setEntropySliceCurEndCUAddr ( m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx+1 ] ); |
---|
960 | |
---|
961 | pcSlice->setNextSlice ( true ); |
---|
962 | |
---|
963 | uiStartCUAddrSliceIdx++; |
---|
964 | uiStartCUAddrEntropySliceIdx++; |
---|
965 | } |
---|
966 | else if (uiNextCUAddr == m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx]) |
---|
967 | { |
---|
968 | // Entropy slice |
---|
969 | pcSlice->setEntropySliceCurStartCUAddr( uiNextCUAddr ); // to be used in encodeSlice() + context restriction |
---|
970 | pcSlice->setEntropySliceCurEndCUAddr ( m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx+1 ] ); |
---|
971 | |
---|
972 | pcSlice->setNextEntropySlice( true ); |
---|
973 | |
---|
974 | uiStartCUAddrEntropySliceIdx++; |
---|
975 | } |
---|
976 | |
---|
977 | pcSlice->setRPS(pcPic->getSlice(0)->getRPS()); |
---|
978 | pcSlice->setRPSidx(pcPic->getSlice(0)->getRPSidx()); |
---|
979 | UInt uiDummyStartCUAddr; |
---|
980 | UInt uiDummyBoundingCUAddr; |
---|
981 | m_pcSliceEncoder->xDetermineStartAndBoundingCUAddr(uiDummyStartCUAddr,uiDummyBoundingCUAddr,pcPic,true); |
---|
982 | |
---|
983 | uiInternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getEntropySliceCurEndCUAddr()-1) % pcPic->getNumPartInCU(); |
---|
984 | uiExternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getEntropySliceCurEndCUAddr()-1) / pcPic->getNumPartInCU(); |
---|
985 | uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
986 | uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
987 | uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
988 | uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
989 | while(uiPosX>=uiWidth||uiPosY>=uiHeight) |
---|
990 | { |
---|
991 | uiInternalAddress--; |
---|
992 | uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
993 | uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
994 | } |
---|
995 | uiInternalAddress++; |
---|
996 | if(uiInternalAddress==pcPic->getNumPartInCU()) |
---|
997 | { |
---|
998 | uiInternalAddress = 0; |
---|
999 | uiExternalAddress = pcPic->getPicSym()->getCUOrderMap(pcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1); |
---|
1000 | } |
---|
1001 | UInt uiEndAddress = pcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress); |
---|
1002 | if(uiEndAddress<=pcSlice->getEntropySliceCurStartCUAddr()) { |
---|
1003 | UInt uiBoundingAddrSlice, uiBoundingAddrEntropySlice; |
---|
1004 | uiBoundingAddrSlice = m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx]; |
---|
1005 | uiBoundingAddrEntropySlice = m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx]; |
---|
1006 | uiNextCUAddr = min(uiBoundingAddrSlice, uiBoundingAddrEntropySlice); |
---|
1007 | if(pcSlice->isNextSlice()) |
---|
1008 | { |
---|
1009 | skippedSlice=true; |
---|
1010 | } |
---|
1011 | continue; |
---|
1012 | } |
---|
1013 | if(skippedSlice) |
---|
1014 | { |
---|
1015 | pcSlice->setNextSlice ( true ); |
---|
1016 | pcSlice->setNextEntropySlice( false ); |
---|
1017 | } |
---|
1018 | skippedSlice=false; |
---|
1019 | if (pcSlice->getPPS()->getEntropyCodingMode()) |
---|
1020 | { |
---|
1021 | pcSlice->allocSubstreamSizes( iNumSubstreams ); |
---|
1022 | for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) |
---|
1023 | pcSubstreamsOut[ui].clear(); |
---|
1024 | } |
---|
1025 | |
---|
1026 | m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); |
---|
1027 | m_pcEntropyCoder->resetEntropy (); |
---|
1028 | /* start slice NALunit */ |
---|
1029 | OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced(), |
---|
1030 | #if !VIDYO_VPS_INTEGRATION &!QC_MVHEVC_B0046 |
---|
1031 | m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() ); |
---|
1032 | #else |
---|
1033 | m_pcEncTop->getLayerId(), pcSlice->getTLayer() ); |
---|
1034 | #endif |
---|
1035 | |
---|
1036 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
1037 | if (!bEntropySlice) |
---|
1038 | { |
---|
1039 | uiOneBitstreamPerSliceLength = 0; // start of a new slice |
---|
1040 | } |
---|
1041 | |
---|
1042 | // used while writing slice header |
---|
1043 | Int iTransmitLWHeader = (m_pcCfg->getTileMarkerFlag()==0) ? 0 : 1; |
---|
1044 | pcSlice->setTileMarkerFlag ( iTransmitLWHeader ); |
---|
1045 | m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); |
---|
1046 | #if !CABAC_INIT_FLAG |
---|
1047 | pcSlice->setCABACinitIDC(pcSlice->getSliceType()); |
---|
1048 | #endif |
---|
1049 | |
---|
1050 | m_pcEntropyCoder->encodeSliceHeader(pcSlice); |
---|
1051 | |
---|
1052 | if(pcSlice->isNextSlice()) |
---|
1053 | { |
---|
1054 | if (pcSlice->getSPS()->getUseALF()) |
---|
1055 | { |
---|
1056 | if(pcSlice->getAlfEnabledFlag()) |
---|
1057 | { |
---|
1058 | |
---|
1059 | if( pcSlice->getSPS()->getUseALFCoefInSlice()) |
---|
1060 | { |
---|
1061 | Int iNumSUinLCU = 1<< (g_uiMaxCUDepth << 1); |
---|
1062 | Int firstLCUAddr = pcSlice->getSliceCurStartCUAddr() / iNumSUinLCU; |
---|
1063 | Bool isAcrossSlice = pcSlice->getSPS()->getLFCrossSliceBoundaryFlag(); |
---|
1064 | m_pcEntropyCoder->encodeAlfParam( &(alfSliceParams[pcSlice->getSliceIdx()]), false, firstLCUAddr, isAcrossSlice); |
---|
1065 | } |
---|
1066 | |
---|
1067 | if( !pcSlice->getSPS()->getUseALFCoefInSlice()) |
---|
1068 | { |
---|
1069 | AlfCUCtrlInfo& cAlfCUCtrlParam = (*alfCUCtrlParam)[pcSlice->getSliceIdx()]; |
---|
1070 | if(cAlfCUCtrlParam.cu_control_flag) |
---|
1071 | { |
---|
1072 | m_pcEntropyCoder->setAlfCtrl( true ); |
---|
1073 | m_pcEntropyCoder->setMaxAlfCtrlDepth(cAlfCUCtrlParam.alf_max_depth); |
---|
1074 | m_pcCavlcCoder->setAlfCtrl(true); |
---|
1075 | m_pcCavlcCoder->setMaxAlfCtrlDepth(cAlfCUCtrlParam.alf_max_depth); |
---|
1076 | } |
---|
1077 | else |
---|
1078 | { |
---|
1079 | m_pcEntropyCoder->setAlfCtrl(false); |
---|
1080 | } |
---|
1081 | m_pcEntropyCoder->encodeAlfCtrlParam(cAlfCUCtrlParam, m_pcAdaptiveLoopFilter->getNumCUsInPic()); |
---|
1082 | |
---|
1083 | } |
---|
1084 | } |
---|
1085 | } |
---|
1086 | } |
---|
1087 | m_pcEntropyCoder->encodeTileMarkerFlag(pcSlice); |
---|
1088 | |
---|
1089 | // is it needed? |
---|
1090 | { |
---|
1091 | if (!bEntropySlice) |
---|
1092 | { |
---|
1093 | pcBitstreamRedirect->writeAlignOne(); |
---|
1094 | } |
---|
1095 | else |
---|
1096 | { |
---|
1097 | // We've not completed our slice header info yet, do the alignment later. |
---|
1098 | } |
---|
1099 | m_pcSbacCoder->init( (TEncBinIf*)m_pcBinCABAC ); |
---|
1100 | m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice ); |
---|
1101 | m_pcEntropyCoder->resetEntropy (); |
---|
1102 | for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ ) |
---|
1103 | { |
---|
1104 | m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice ); |
---|
1105 | m_pcEntropyCoder->resetEntropy (); |
---|
1106 | } |
---|
1107 | } |
---|
1108 | |
---|
1109 | if(pcSlice->isNextSlice()) |
---|
1110 | { |
---|
1111 | // set entropy coder for writing |
---|
1112 | m_pcSbacCoder->init( (TEncBinIf*)m_pcBinCABAC ); |
---|
1113 | { |
---|
1114 | for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ ) |
---|
1115 | { |
---|
1116 | m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice ); |
---|
1117 | m_pcEntropyCoder->resetEntropy (); |
---|
1118 | } |
---|
1119 | pcSbacCoders[0].load(m_pcSbacCoder); |
---|
1120 | m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[0], pcSlice ); //ALF is written in substream #0 with CABAC coder #0 (see ALF param encoding below) |
---|
1121 | } |
---|
1122 | m_pcEntropyCoder->resetEntropy (); |
---|
1123 | // File writing |
---|
1124 | if (!bEntropySlice) |
---|
1125 | { |
---|
1126 | m_pcEntropyCoder->setBitstream(pcBitstreamRedirect); |
---|
1127 | } |
---|
1128 | else |
---|
1129 | { |
---|
1130 | m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); |
---|
1131 | } |
---|
1132 | // for now, override the TILES_DECODER setting in order to write substreams. |
---|
1133 | m_pcEntropyCoder->setBitstream ( &pcSubstreamsOut[0] ); |
---|
1134 | |
---|
1135 | } |
---|
1136 | pcSlice->setFinalized(true); |
---|
1137 | |
---|
1138 | m_pcSbacCoder->load( &pcSbacCoders[0] ); |
---|
1139 | |
---|
1140 | pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength ); |
---|
1141 | if (!bEntropySlice) |
---|
1142 | { |
---|
1143 | pcSlice->setTileLocationCount ( 0 ); |
---|
1144 | m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info. |
---|
1145 | } |
---|
1146 | else |
---|
1147 | { |
---|
1148 | m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info. |
---|
1149 | } |
---|
1150 | |
---|
1151 | { |
---|
1152 | // Construct the final bitstream by flushing and concatenating substreams. |
---|
1153 | // The final bitstream is either nalu.m_Bitstream or pcBitstreamRedirect; |
---|
1154 | UInt* puiSubstreamSizes = pcSlice->getSubstreamSizes(); |
---|
1155 | UInt uiTotalCodedSize = 0; // for padding calcs. |
---|
1156 | UInt uiNumSubstreamsPerTile = iNumSubstreams; |
---|
1157 | if (iNumSubstreams > 1) |
---|
1158 | { |
---|
1159 | uiNumSubstreamsPerTile /= pcPic->getPicSym()->getNumTiles(); |
---|
1160 | } |
---|
1161 | for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) |
---|
1162 | { |
---|
1163 | // Flush all substreams -- this includes empty ones. |
---|
1164 | // Terminating bit and flush. |
---|
1165 | m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice ); |
---|
1166 | m_pcEntropyCoder->setBitstream ( &pcSubstreamsOut[ui] ); |
---|
1167 | m_pcEntropyCoder->encodeTerminatingBit( 1 ); |
---|
1168 | m_pcEntropyCoder->encodeSliceFinish(); |
---|
1169 | pcSubstreamsOut[ui].write( 1, 1 ); // stop bit. |
---|
1170 | pcSubstreamsOut[ui].writeAlignZero(); |
---|
1171 | // Byte alignment is necessary between tiles when tiles are independent. |
---|
1172 | uiTotalCodedSize += pcSubstreamsOut[ui].getNumberOfWrittenBits(); |
---|
1173 | |
---|
1174 | { |
---|
1175 | Bool bNextSubstreamInNewTile = ((ui+1) < iNumSubstreams) |
---|
1176 | && ((ui+1)%uiNumSubstreamsPerTile == 0); |
---|
1177 | if (bNextSubstreamInNewTile) |
---|
1178 | { |
---|
1179 | // byte align. |
---|
1180 | while (uiTotalCodedSize&0x7) |
---|
1181 | { |
---|
1182 | pcSubstreamsOut[ui].write(0, 1); |
---|
1183 | uiTotalCodedSize++; |
---|
1184 | } |
---|
1185 | } |
---|
1186 | Bool bRecordOffsetNext = m_pcCfg->getTileLocationInSliceHeaderFlag() |
---|
1187 | && bNextSubstreamInNewTile; |
---|
1188 | if (bRecordOffsetNext) |
---|
1189 | pcSlice->setTileLocation(ui/uiNumSubstreamsPerTile, pcSlice->getTileOffstForMultES()+(uiTotalCodedSize>>3)); |
---|
1190 | } |
---|
1191 | if (ui+1 < pcSlice->getPPS()->getNumSubstreams()) |
---|
1192 | puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits(); |
---|
1193 | } |
---|
1194 | // Complete the slice header info. |
---|
1195 | m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); |
---|
1196 | m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); |
---|
1197 | if (m_pcCfg->getTileLocationInSliceHeaderFlag()==0) |
---|
1198 | { |
---|
1199 | pcSlice->setTileLocationCount( 0 ); |
---|
1200 | } |
---|
1201 | m_pcEntropyCoder->encodeTilesWPPEntryPoint( pcSlice ); |
---|
1202 | // Substreams... |
---|
1203 | TComOutputBitstream *pcOut = pcBitstreamRedirect; |
---|
1204 | // xWriteTileLocation will perform byte-alignment... |
---|
1205 | { |
---|
1206 | if (bEntropySlice) |
---|
1207 | { |
---|
1208 | // In these cases, padding is necessary here. |
---|
1209 | pcOut = &nalu.m_Bitstream; |
---|
1210 | pcOut->writeAlignOne(); |
---|
1211 | } |
---|
1212 | } |
---|
1213 | UInt uiAccumulatedLength = 0; |
---|
1214 | for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams(); ui++ ) |
---|
1215 | { |
---|
1216 | pcOut->addSubstream(&pcSubstreamsOut[ui]); |
---|
1217 | |
---|
1218 | // Update tile marker location information |
---|
1219 | for (Int uiMrkIdx = 0; uiMrkIdx < pcSubstreamsOut[ui].getTileMarkerLocationCount(); uiMrkIdx++) |
---|
1220 | { |
---|
1221 | UInt uiBottom = pcOut->getTileMarkerLocationCount(); |
---|
1222 | pcOut->setTileMarkerLocation ( uiBottom, uiAccumulatedLength + pcSubstreamsOut[ui].getTileMarkerLocation( uiMrkIdx ) ); |
---|
1223 | pcOut->setTileMarkerLocationCount ( uiBottom + 1 ); |
---|
1224 | } |
---|
1225 | uiAccumulatedLength = (pcOut->getNumberOfWrittenBits() >> 3); |
---|
1226 | } |
---|
1227 | } |
---|
1228 | |
---|
1229 | UInt uiBoundingAddrSlice, uiBoundingAddrEntropySlice; |
---|
1230 | uiBoundingAddrSlice = m_uiStoredStartCUAddrForEncodingSlice[uiStartCUAddrSliceIdx]; |
---|
1231 | uiBoundingAddrEntropySlice = m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx]; |
---|
1232 | uiNextCUAddr = min(uiBoundingAddrSlice, uiBoundingAddrEntropySlice); |
---|
1233 | // If current NALU is the first NALU of slice (containing slice header) and more NALUs exist (due to multiple entropy slices) then buffer it. |
---|
1234 | // If current NALU is the last NALU of slice and a NALU was buffered, then (a) Write current NALU (b) Update an write buffered NALU at approproate location in NALU list. |
---|
1235 | Bool bNALUAlignedWrittenToList = false; // used to ensure current NALU is not written more than once to the NALU list. |
---|
1236 | xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice); |
---|
1237 | writeRBSPTrailingBits(nalu.m_Bitstream); |
---|
1238 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
1239 | bNALUAlignedWrittenToList = true; |
---|
1240 | uiOneBitstreamPerSliceLength += nalu.m_Bitstream.getNumberOfWrittenBits(); // length of bitstream after byte-alignment |
---|
1241 | |
---|
1242 | if (!bNALUAlignedWrittenToList) |
---|
1243 | { |
---|
1244 | { |
---|
1245 | nalu.m_Bitstream.writeAlignZero(); |
---|
1246 | } |
---|
1247 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
1248 | uiOneBitstreamPerSliceLength += nalu.m_Bitstream.getNumberOfWrittenBits() + 24; // length of bitstream after byte-alignment + 3 byte startcode 0x000001 |
---|
1249 | } |
---|
1250 | |
---|
1251 | |
---|
1252 | processingState = ENCODE_SLICE; |
---|
1253 | } |
---|
1254 | break; |
---|
1255 | case EXECUTE_INLOOPFILTER: |
---|
1256 | { |
---|
1257 | TComAPS cAPS; |
---|
1258 | allocAPS(&cAPS, pcSlice->getSPS()); |
---|
1259 | cAPS.setSaoInterleavingFlag(m_pcCfg->getSaoInterleavingFlag()); |
---|
1260 | // set entropy coder for RD |
---|
1261 | m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice ); |
---|
1262 | |
---|
1263 | if ( pcSlice->getSPS()->getUseSAO() ) |
---|
1264 | { |
---|
1265 | m_pcEntropyCoder->resetEntropy(); |
---|
1266 | m_pcEntropyCoder->setBitstream( m_pcBitCounter ); |
---|
1267 | m_pcSAO->startSaoEnc(pcPic, m_pcEntropyCoder, m_pcEncTop->getRDSbacCoder(), NULL); |
---|
1268 | SAOParam& cSaoParam = *(cAPS.getSaoParam()); |
---|
1269 | |
---|
1270 | #if SAO_CHROMA_LAMBDA |
---|
1271 | m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma()); |
---|
1272 | #else |
---|
1273 | #if ALF_CHROMA_LAMBDA |
---|
1274 | m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambdaLuma()); |
---|
1275 | #else |
---|
1276 | m_pcSAO->SAOProcess(&cSaoParam, pcPic->getSlice(0)->getLambda()); |
---|
1277 | #endif |
---|
1278 | #endif |
---|
1279 | m_pcSAO->endSaoEnc(); |
---|
1280 | |
---|
1281 | m_pcAdaptiveLoopFilter->PCMLFDisableProcess(pcPic); |
---|
1282 | } |
---|
1283 | |
---|
1284 | // adaptive loop filter |
---|
1285 | if ( pcSlice->getSPS()->getUseALF()) |
---|
1286 | { |
---|
1287 | m_pcEntropyCoder->resetEntropy (); |
---|
1288 | m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); |
---|
1289 | m_pcAdaptiveLoopFilter->startALFEnc(pcPic, m_pcEntropyCoder ); |
---|
1290 | AlfParamSet* pAlfEncParam = (pcSlice->getSPS()->getUseALFCoefInSlice())?( alfSliceParams ):( cAPS.getAlfParam()); |
---|
1291 | #if ALF_CHROMA_LAMBDA |
---|
1292 | #if HHI_INTERVIEW_SKIP |
---|
1293 | m_pcAdaptiveLoopFilter->ALFProcess(pAlfEncParam, alfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma(), m_pcEncTop->getInterViewSkip() ); |
---|
1294 | #else |
---|
1295 | m_pcAdaptiveLoopFilter->ALFProcess(pAlfEncParam, alfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma() ); |
---|
1296 | #endif |
---|
1297 | #else |
---|
1298 | #if SAO_CHROMA_LAMBDA |
---|
1299 | #if HHI_INTERVIEW_SKIP |
---|
1300 | m_pcAdaptiveLoopFilter->ALFProcess(pAlfEncParam, alfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma(), m_pcEncTop->getInterViewSkip()); |
---|
1301 | #else |
---|
1302 | m_pcAdaptiveLoopFilter->ALFProcess(pAlfEncParam, alfCUCtrlParam, pcPic->getSlice(0)->getLambdaLuma()); |
---|
1303 | #endif |
---|
1304 | #else |
---|
1305 | #if HHI_INTERVIEW_SKIP |
---|
1306 | m_pcAdaptiveLoopFilter->ALFProcess(pAlfEncParam, alfCUCtrlParam, pcPic->getSlice(0)->getLambda(), m_pcEncTop->getInterViewSkip() ); |
---|
1307 | #else |
---|
1308 | m_pcAdaptiveLoopFilter->ALFProcess(pAlfEncParam, alfCUCtrlParam, pcPic->getSlice(0)->getLambda()); |
---|
1309 | #endif |
---|
1310 | #endif |
---|
1311 | #endif |
---|
1312 | |
---|
1313 | m_pcAdaptiveLoopFilter->endALFEnc(); |
---|
1314 | |
---|
1315 | m_pcAdaptiveLoopFilter->PCMLFDisableProcess(pcPic); |
---|
1316 | } |
---|
1317 | iCodedAPSIdx = iCurrAPSIdx; |
---|
1318 | pcSliceForAPS = pcSlice; |
---|
1319 | |
---|
1320 | assignNewAPS(cAPS, iCodedAPSIdx, vAPS, pcSliceForAPS); |
---|
1321 | iCurrAPSIdx = (iCurrAPSIdx +1)%MAX_NUM_SUPPORTED_APS; |
---|
1322 | processingState = ENCODE_APS; |
---|
1323 | |
---|
1324 | //set APS link to the slices |
---|
1325 | for(Int s=0; s< uiNumSlices; s++) |
---|
1326 | { |
---|
1327 | if (pcSlice->getSPS()->getUseALF()) |
---|
1328 | { |
---|
1329 | pcPic->getSlice(s)->setAlfEnabledFlag( (pcSlice->getSPS()->getUseALFCoefInSlice())?(alfSliceParams[s].isEnabled[ALF_Y]):(cAPS.getAlfEnabled()) ); |
---|
1330 | } |
---|
1331 | if (pcSlice->getSPS()->getUseSAO()) |
---|
1332 | { |
---|
1333 | pcPic->getSlice(s)->setSaoEnabledFlag((cAPS.getSaoParam()->bSaoFlag[0]==1)?true:false); |
---|
1334 | } |
---|
1335 | pcPic->getSlice(s)->setAPS(&(vAPS[iCodedAPSIdx])); |
---|
1336 | pcPic->getSlice(s)->setAPSId(iCodedAPSIdx); |
---|
1337 | } |
---|
1338 | } |
---|
1339 | break; |
---|
1340 | case ENCODE_APS: |
---|
1341 | { |
---|
1342 | #if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046 |
---|
1343 | OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getLayerId()); |
---|
1344 | #else |
---|
1345 | OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); |
---|
1346 | #endif |
---|
1347 | encodeAPS(&(vAPS[iCodedAPSIdx]), nalu.m_Bitstream, pcSliceForAPS); |
---|
1348 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
1349 | |
---|
1350 | processingState = ENCODE_SLICE; |
---|
1351 | } |
---|
1352 | break; |
---|
1353 | default: |
---|
1354 | { |
---|
1355 | printf("Not a supported encoding state\n"); |
---|
1356 | assert(0); |
---|
1357 | exit(-1); |
---|
1358 | } |
---|
1359 | } |
---|
1360 | } // end iteration over slices |
---|
1361 | |
---|
1362 | |
---|
1363 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()) |
---|
1364 | { |
---|
1365 | if(pcSlice->getSPS()->getUseSAO()) |
---|
1366 | { |
---|
1367 | m_pcSAO->destroyPicSaoInfo(); |
---|
1368 | } |
---|
1369 | |
---|
1370 | if(pcSlice->getSPS()->getUseALF()) |
---|
1371 | { |
---|
1372 | m_pcAdaptiveLoopFilter->uninitALFEnc(alfSliceParams, alfCUCtrlParam); |
---|
1373 | m_pcAdaptiveLoopFilter->destroyPicAlfInfo(); |
---|
1374 | } |
---|
1375 | |
---|
1376 | pcPic->destroyNonDBFilterInfo(); |
---|
1377 | } |
---|
1378 | |
---|
1379 | #if HHI_INTERVIEW_SKIP |
---|
1380 | if (pcPic->getUsedPelsMap()) |
---|
1381 | pcPic->removeUsedPelsMapBuffer() ; |
---|
1382 | #endif |
---|
1383 | #if H3D_IVMP |
---|
1384 | pcPic->removeOrgDepthMapBuffer(); |
---|
1385 | #endif |
---|
1386 | |
---|
1387 | // pcPic->compressMotion(); |
---|
1388 | m_pocLastCoded = pcPic->getPOC(); |
---|
1389 | |
---|
1390 | //-- For time output for each slice |
---|
1391 | Double dEncTime = (double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; |
---|
1392 | |
---|
1393 | const char* digestStr = NULL; |
---|
1394 | if (m_pcCfg->getPictureDigestEnabled()) |
---|
1395 | { |
---|
1396 | /* calculate MD5sum for entire reconstructed picture */ |
---|
1397 | SEIpictureDigest sei_recon_picture_digest; |
---|
1398 | sei_recon_picture_digest.method = SEIpictureDigest::MD5; |
---|
1399 | calcMD5(*pcPic->getPicYuvRec(), sei_recon_picture_digest.digest); |
---|
1400 | digestStr = digestToString(sei_recon_picture_digest.digest); |
---|
1401 | |
---|
1402 | #if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046 |
---|
1403 | OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getLayerId()); |
---|
1404 | #else |
---|
1405 | OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth()); |
---|
1406 | #endif |
---|
1407 | |
---|
1408 | /* write the SEI messages */ |
---|
1409 | m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); |
---|
1410 | m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); |
---|
1411 | m_pcEntropyCoder->encodeSEI(sei_recon_picture_digest); |
---|
1412 | writeRBSPTrailingBits(nalu.m_Bitstream); |
---|
1413 | |
---|
1414 | /* insert the SEI message NALUnit before any Slice NALUnits */ |
---|
1415 | AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice)); |
---|
1416 | accessUnit.insert(it, new NALUnitEBSP(nalu)); |
---|
1417 | } |
---|
1418 | |
---|
1419 | xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime ); |
---|
1420 | if (digestStr) |
---|
1421 | printf(" [MD5:%s]", digestStr); |
---|
1422 | |
---|
1423 | #if FIXED_ROUNDING_FRAME_MEMORY |
---|
1424 | /* TODO: this should happen after copyToPic(pcPicYuvRecOut) */ |
---|
1425 | pcPic->getPicYuvRec()->xFixedRoundingPic(); |
---|
1426 | #endif |
---|
1427 | pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut); |
---|
1428 | |
---|
1429 | pcPic->setReconMark ( true ); |
---|
1430 | |
---|
1431 | pcPic->setUsedForTMVP ( true ); |
---|
1432 | |
---|
1433 | m_bFirst = false; |
---|
1434 | m_iNumPicCoded++; |
---|
1435 | |
---|
1436 | /* logging: insert a newline at end of picture period */ |
---|
1437 | printf("\n"); |
---|
1438 | fflush(stdout); |
---|
1439 | } |
---|
1440 | |
---|
1441 | delete[] pcSubstreamsOut; |
---|
1442 | delete pcBitstreamRedirect; |
---|
1443 | |
---|
1444 | } |
---|
1445 | |
---|
1446 | /** Memory allocation for APS |
---|
1447 | * \param [out] pAPS APS pointer |
---|
1448 | * \param [in] pSPS SPS pointer |
---|
1449 | */ |
---|
1450 | Void TEncGOP::allocAPS (TComAPS* pAPS, TComSPS* pSPS) |
---|
1451 | { |
---|
1452 | if(pSPS->getUseSAO()) |
---|
1453 | { |
---|
1454 | pAPS->createSaoParam(); |
---|
1455 | m_pcSAO->allocSaoParam(pAPS->getSaoParam()); |
---|
1456 | } |
---|
1457 | if(pSPS->getUseALF()) |
---|
1458 | { |
---|
1459 | pAPS->createAlfParam(); |
---|
1460 | //alf Enabled flag in APS is false after pAPS->createAlfParam(); |
---|
1461 | if(!pSPS->getUseALFCoefInSlice()) |
---|
1462 | { |
---|
1463 | pAPS->getAlfParam()->create(m_pcAdaptiveLoopFilter->getNumLCUInPicWidth(), m_pcAdaptiveLoopFilter->getNumLCUInPicHeight(), m_pcAdaptiveLoopFilter->getNumCUsInPic()); |
---|
1464 | pAPS->getAlfParam()->createALFParam(); |
---|
1465 | } |
---|
1466 | } |
---|
1467 | } |
---|
1468 | |
---|
1469 | /** Memory deallocation for APS |
---|
1470 | * \param [out] pAPS APS pointer |
---|
1471 | * \param [in] pSPS SPS pointer |
---|
1472 | */ |
---|
1473 | Void TEncGOP::freeAPS (TComAPS* pAPS, TComSPS* pSPS) |
---|
1474 | { |
---|
1475 | if(pSPS->getUseSAO()) |
---|
1476 | { |
---|
1477 | if(pAPS->getSaoParam() != NULL) |
---|
1478 | { |
---|
1479 | m_pcSAO->freeSaoParam(pAPS->getSaoParam()); |
---|
1480 | pAPS->destroySaoParam(); |
---|
1481 | |
---|
1482 | } |
---|
1483 | } |
---|
1484 | if(pSPS->getUseALF()) |
---|
1485 | { |
---|
1486 | if(pAPS->getAlfParam() != NULL) |
---|
1487 | { |
---|
1488 | if(!pSPS->getUseALFCoefInSlice()) |
---|
1489 | { |
---|
1490 | pAPS->getAlfParam()->releaseALFParam(); |
---|
1491 | } |
---|
1492 | pAPS->destroyAlfParam(); |
---|
1493 | } |
---|
1494 | } |
---|
1495 | } |
---|
1496 | |
---|
1497 | /** Assign APS object into APS container according to APS ID |
---|
1498 | * \param [in] cAPS APS object |
---|
1499 | * \param [in] apsID APS ID |
---|
1500 | * \param [in,out] vAPS APS container |
---|
1501 | * \param [in] pcSlice pointer to slice |
---|
1502 | */ |
---|
1503 | Void TEncGOP::assignNewAPS(TComAPS& cAPS, Int apsID, std::vector<TComAPS>& vAPS, TComSlice* pcSlice) |
---|
1504 | { |
---|
1505 | |
---|
1506 | cAPS.setAPSID(apsID); |
---|
1507 | if(pcSlice->getPOC() == 0) |
---|
1508 | { |
---|
1509 | cAPS.setScalingListEnabled(pcSlice->getSPS()->getScalingListFlag()); |
---|
1510 | } |
---|
1511 | else |
---|
1512 | { |
---|
1513 | cAPS.setScalingListEnabled(false); |
---|
1514 | } |
---|
1515 | |
---|
1516 | cAPS.setSaoEnabled(pcSlice->getSPS()->getUseSAO() ? (cAPS.getSaoParam()->bSaoFlag[0] ):(false)); |
---|
1517 | cAPS.setAlfEnabled(pcSlice->getSPS()->getUseALF() ? (cAPS.getAlfParam()->isEnabled[0]):(false)); |
---|
1518 | cAPS.setLoopFilterOffsetInAPS(m_pcCfg->getLoopFilterOffsetInAPS()); |
---|
1519 | cAPS.setLoopFilterDisable(m_pcCfg->getLoopFilterDisable()); |
---|
1520 | cAPS.setLoopFilterBetaOffset(m_pcCfg->getLoopFilterBetaOffset()); |
---|
1521 | cAPS.setLoopFilterTcOffset(m_pcCfg->getLoopFilterTcOffset()); |
---|
1522 | |
---|
1523 | //assign new APS into APS container |
---|
1524 | Int apsBufSize= (Int)vAPS.size(); |
---|
1525 | |
---|
1526 | if(apsID >= apsBufSize) |
---|
1527 | { |
---|
1528 | vAPS.resize(apsID +1); |
---|
1529 | } |
---|
1530 | |
---|
1531 | freeAPS(&(vAPS[apsID]), pcSlice->getSPS()); |
---|
1532 | vAPS[apsID] = cAPS; |
---|
1533 | } |
---|
1534 | |
---|
1535 | |
---|
1536 | /** encode APS syntax elements |
---|
1537 | * \param [in] pcAPS APS pointer |
---|
1538 | * \param [in, out] APSbs bitstream |
---|
1539 | * \param [in] pointer to slice (just used for entropy coder initialization) |
---|
1540 | */ |
---|
1541 | Void TEncGOP::encodeAPS(TComAPS* pcAPS, TComOutputBitstream& APSbs, TComSlice* pcSlice) |
---|
1542 | { |
---|
1543 | m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder, pcSlice); |
---|
1544 | m_pcEntropyCoder->resetEntropy (); |
---|
1545 | m_pcEntropyCoder->setBitstream(&APSbs); |
---|
1546 | |
---|
1547 | m_pcEntropyCoder->encodeAPSInitInfo(pcAPS); |
---|
1548 | if(pcAPS->getScalingListEnabled()) |
---|
1549 | { |
---|
1550 | m_pcEntropyCoder->encodeScalingList( pcSlice->getScalingList() ); |
---|
1551 | } |
---|
1552 | if(pcAPS->getLoopFilterOffsetInAPS()) |
---|
1553 | { |
---|
1554 | m_pcEntropyCoder->encodeDFParams(pcAPS); |
---|
1555 | } |
---|
1556 | m_pcEntropyCoder->encodeSaoParam(pcAPS); |
---|
1557 | m_pcEntropyCoder->encodeAPSAlfFlag( pcAPS->getAlfEnabled()?1:0); |
---|
1558 | if(pcAPS->getAlfEnabled()) |
---|
1559 | { |
---|
1560 | m_pcEntropyCoder->encodeAlfParam(pcAPS->getAlfParam()); |
---|
1561 | } |
---|
1562 | |
---|
1563 | m_pcEntropyCoder->encodeApsExtensionFlag(); |
---|
1564 | //neither SAO and ALF is enabled |
---|
1565 | writeRBSPTrailingBits(APSbs); |
---|
1566 | } |
---|
1567 | |
---|
1568 | Void TEncGOP::preLoopFilterPicAll( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ) |
---|
1569 | { |
---|
1570 | TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
1571 | Bool bCalcDist = false; |
---|
1572 | m_pcLoopFilter->setCfg(pcSlice->getPPS()->getDeblockingFilterControlPresent(), pcSlice->getLoopFilterDisable(), m_pcCfg->getLoopFilterBetaOffset(), m_pcCfg->getLoopFilterTcOffset(), m_pcCfg->getLFCrossTileBoundaryFlag()); |
---|
1573 | m_pcLoopFilter->loopFilterPic( pcPic ); |
---|
1574 | |
---|
1575 | m_pcEntropyCoder->setEntropyCoder ( m_pcEncTop->getRDGoOnSbacCoder(), pcSlice ); |
---|
1576 | m_pcEntropyCoder->resetEntropy (); |
---|
1577 | m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); |
---|
1578 | pcSlice = pcPic->getSlice(0); |
---|
1579 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()) |
---|
1580 | { |
---|
1581 | pcPic->createNonDBFilterInfo(); |
---|
1582 | } |
---|
1583 | |
---|
1584 | // Adaptive Loop filter |
---|
1585 | if( pcSlice->getSPS()->getUseALF() ) |
---|
1586 | { |
---|
1587 | m_pcAdaptiveLoopFilter->createPicAlfInfo(pcPic); |
---|
1588 | |
---|
1589 | AlfParamSet* alfParamSet; |
---|
1590 | std::vector<AlfCUCtrlInfo>* alfCUCtrlParam = NULL; |
---|
1591 | alfParamSet= new AlfParamSet; |
---|
1592 | alfParamSet->create( m_pcAdaptiveLoopFilter->getNumLCUInPicWidth(), m_pcAdaptiveLoopFilter->getNumLCUInPicHeight(), m_pcAdaptiveLoopFilter->getNumCUsInPic()); |
---|
1593 | alfParamSet->createALFParam(); |
---|
1594 | m_pcAdaptiveLoopFilter->initALFEnc(false, true, 1, alfParamSet, alfCUCtrlParam); |
---|
1595 | m_pcAdaptiveLoopFilter->startALFEnc(pcPic, m_pcEntropyCoder); |
---|
1596 | |
---|
1597 | |
---|
1598 | |
---|
1599 | #if ALF_CHROMA_LAMBDA |
---|
1600 | #if HHI_INTERVIEW_SKIP |
---|
1601 | m_pcAdaptiveLoopFilter->ALFProcess(alfParamSet, NULL, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma(), m_pcEncTop->getInterViewSkip() ); |
---|
1602 | #else |
---|
1603 | m_pcAdaptiveLoopFilter->ALFProcess(alfParamSet, NULL, pcPic->getSlice(0)->getLambdaLuma(), pcPic->getSlice(0)->getLambdaChroma() ); |
---|
1604 | #endif |
---|
1605 | #else |
---|
1606 | #if SAO_CHROMA_LAMBDA |
---|
1607 | m_pcAdaptiveLoopFilter->ALFProcess(alfParamSet, NULL, pcPic->getSlice(0)->getLambdaLuma(), m_pcEncTop->getInterViewSkip()); |
---|
1608 | #if HHI_INTERVIEW_SKIP |
---|
1609 | #else |
---|
1610 | m_pcAdaptiveLoopFilter->ALFProcess(alfParamSet, NULL, pcPic->getSlice(0)->getLambdaLuma()); |
---|
1611 | #endif |
---|
1612 | #else |
---|
1613 | #if HHI_INTERVIEW_SKIP |
---|
1614 | m_pcAdaptiveLoopFilter->ALFProcess(alfParamSet, NULL, pcPic->getSlice(0)->getLambda(), m_pcEncTop->getInterViewSkip()); |
---|
1615 | #else |
---|
1616 | m_pcAdaptiveLoopFilter->ALFProcess(alfParamSet, NULL, pcPic->getSlice(0)->getLambda()); |
---|
1617 | #endif |
---|
1618 | #endif |
---|
1619 | #endif |
---|
1620 | |
---|
1621 | m_pcAdaptiveLoopFilter->endALFEnc(); |
---|
1622 | |
---|
1623 | alfParamSet->releaseALFParam(); |
---|
1624 | delete alfParamSet; |
---|
1625 | delete alfCUCtrlParam; |
---|
1626 | m_pcAdaptiveLoopFilter->PCMLFDisableProcess(pcPic); |
---|
1627 | m_pcAdaptiveLoopFilter->destroyPicAlfInfo(); |
---|
1628 | } |
---|
1629 | if( pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()) |
---|
1630 | { |
---|
1631 | pcPic->destroyNonDBFilterInfo(); |
---|
1632 | } |
---|
1633 | |
---|
1634 | m_pcEntropyCoder->resetEntropy (); |
---|
1635 | ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
1636 | |
---|
1637 | if (!bCalcDist) |
---|
1638 | ruiDist = xFindDistortionFrame(pcPic->getPicYuvOrg(), pcPic->getPicYuvRec()); |
---|
1639 | } |
---|
1640 | |
---|
1641 | // ==================================================================================================================== |
---|
1642 | // Protected member functions |
---|
1643 | // ==================================================================================================================== |
---|
1644 | |
---|
1645 | Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ) |
---|
1646 | { |
---|
1647 | assert( iNumPicRcvd > 0 ); |
---|
1648 | // Exception for the first frame |
---|
1649 | if ( iPOCLast == 0 ) |
---|
1650 | { |
---|
1651 | m_iGopSize = 1; |
---|
1652 | } |
---|
1653 | else |
---|
1654 | m_iGopSize = m_pcCfg->getGOPSize(); |
---|
1655 | |
---|
1656 | assert (m_iGopSize > 0); |
---|
1657 | |
---|
1658 | return; |
---|
1659 | } |
---|
1660 | |
---|
1661 | Void TEncGOP::xGetBuffer( TComList<TComPic*>& rcListPic, |
---|
1662 | TComList<TComPicYuv*>& rcListPicYuvRecOut, |
---|
1663 | Int iNumPicRcvd, |
---|
1664 | Int iTimeOffset, |
---|
1665 | TComPic*& rpcPic, |
---|
1666 | TComPicYuv*& rpcPicYuvRecOut, |
---|
1667 | UInt uiPOCCurr ) |
---|
1668 | { |
---|
1669 | Int i; |
---|
1670 | // Rec. output |
---|
1671 | TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end(); |
---|
1672 | for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ ) |
---|
1673 | { |
---|
1674 | iterPicYuvRec--; |
---|
1675 | } |
---|
1676 | |
---|
1677 | rpcPicYuvRecOut = *(iterPicYuvRec); |
---|
1678 | |
---|
1679 | // Current pic. |
---|
1680 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1681 | while (iterPic != rcListPic.end()) |
---|
1682 | { |
---|
1683 | rpcPic = *(iterPic); |
---|
1684 | rpcPic->setCurrSliceIdx(0); |
---|
1685 | if (rpcPic->getPOC() == (Int)uiPOCCurr) |
---|
1686 | { |
---|
1687 | break; |
---|
1688 | } |
---|
1689 | iterPic++; |
---|
1690 | } |
---|
1691 | |
---|
1692 | assert (rpcPic->getPOC() == (Int)uiPOCCurr); |
---|
1693 | |
---|
1694 | return; |
---|
1695 | } |
---|
1696 | |
---|
1697 | UInt64 TEncGOP::xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1) |
---|
1698 | { |
---|
1699 | Int x, y; |
---|
1700 | Pel* pSrc0 = pcPic0 ->getLumaAddr(); |
---|
1701 | Pel* pSrc1 = pcPic1 ->getLumaAddr(); |
---|
1702 | #if IBDI_DISTORTION |
---|
1703 | Int iShift = g_uiBitIncrement; |
---|
1704 | Int iOffset = 1<<(g_uiBitIncrement-1); |
---|
1705 | #else |
---|
1706 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1707 | #endif |
---|
1708 | Int iTemp; |
---|
1709 | |
---|
1710 | Int iStride = pcPic0->getStride(); |
---|
1711 | Int iWidth = pcPic0->getWidth(); |
---|
1712 | Int iHeight = pcPic0->getHeight(); |
---|
1713 | |
---|
1714 | UInt64 uiTotalDiff = 0; |
---|
1715 | |
---|
1716 | for( y = 0; y < iHeight; y++ ) |
---|
1717 | { |
---|
1718 | for( x = 0; x < iWidth; x++ ) |
---|
1719 | { |
---|
1720 | #if IBDI_DISTORTION |
---|
1721 | iTemp = ((pSrc0[x]+iOffset)>>iShift) - ((pSrc1[x]+iOffset)>>iShift); uiTotalDiff += iTemp * iTemp; |
---|
1722 | #else |
---|
1723 | iTemp = pSrc0[x] - pSrc1[x]; uiTotalDiff += (iTemp*iTemp) >> uiShift; |
---|
1724 | #endif |
---|
1725 | } |
---|
1726 | pSrc0 += iStride; |
---|
1727 | pSrc1 += iStride; |
---|
1728 | } |
---|
1729 | |
---|
1730 | iHeight >>= 1; |
---|
1731 | iWidth >>= 1; |
---|
1732 | iStride >>= 1; |
---|
1733 | |
---|
1734 | pSrc0 = pcPic0->getCbAddr(); |
---|
1735 | pSrc1 = pcPic1->getCbAddr(); |
---|
1736 | |
---|
1737 | for( y = 0; y < iHeight; y++ ) |
---|
1738 | { |
---|
1739 | for( x = 0; x < iWidth; x++ ) |
---|
1740 | { |
---|
1741 | #if IBDI_DISTORTION |
---|
1742 | iTemp = ((pSrc0[x]+iOffset)>>iShift) - ((pSrc1[x]+iOffset)>>iShift); uiTotalDiff += iTemp * iTemp; |
---|
1743 | #else |
---|
1744 | iTemp = pSrc0[x] - pSrc1[x]; uiTotalDiff += (iTemp*iTemp) >> uiShift; |
---|
1745 | #endif |
---|
1746 | } |
---|
1747 | pSrc0 += iStride; |
---|
1748 | pSrc1 += iStride; |
---|
1749 | } |
---|
1750 | |
---|
1751 | pSrc0 = pcPic0->getCrAddr(); |
---|
1752 | pSrc1 = pcPic1->getCrAddr(); |
---|
1753 | |
---|
1754 | for( y = 0; y < iHeight; y++ ) |
---|
1755 | { |
---|
1756 | for( x = 0; x < iWidth; x++ ) |
---|
1757 | { |
---|
1758 | #if IBDI_DISTORTION |
---|
1759 | iTemp = ((pSrc0[x]+iOffset)>>iShift) - ((pSrc1[x]+iOffset)>>iShift); uiTotalDiff += iTemp * iTemp; |
---|
1760 | #else |
---|
1761 | iTemp = pSrc0[x] - pSrc1[x]; uiTotalDiff += (iTemp*iTemp) >> uiShift; |
---|
1762 | #endif |
---|
1763 | } |
---|
1764 | pSrc0 += iStride; |
---|
1765 | pSrc1 += iStride; |
---|
1766 | } |
---|
1767 | |
---|
1768 | return uiTotalDiff; |
---|
1769 | } |
---|
1770 | |
---|
1771 | #if VERBOSE_RATE |
---|
1772 | static const char* nalUnitTypeToString(NalUnitType type) |
---|
1773 | { |
---|
1774 | switch (type) |
---|
1775 | { |
---|
1776 | case NAL_UNIT_CODED_SLICE: return "SLICE"; |
---|
1777 | #if !QC_REM_IDV_B0046 |
---|
1778 | case NAL_UNIT_CODED_SLICE_IDV: return "IDV"; |
---|
1779 | #endif |
---|
1780 | case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; |
---|
1781 | case NAL_UNIT_CODED_SLICE_TLA: return "TLA"; |
---|
1782 | case NAL_UNIT_CODED_SLICE_IDR: return "IDR"; |
---|
1783 | case NAL_UNIT_SEI: return "SEI"; |
---|
1784 | case NAL_UNIT_SPS: return "SPS"; |
---|
1785 | case NAL_UNIT_PPS: return "PPS"; |
---|
1786 | case NAL_UNIT_FILLER_DATA: return "FILLER"; |
---|
1787 | default: return "UNK"; |
---|
1788 | } |
---|
1789 | } |
---|
1790 | #endif |
---|
1791 | |
---|
1792 | Void TEncGOP::xCalculateAddPSNR( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit& accessUnit, Double dEncTime ) |
---|
1793 | { |
---|
1794 | Int x, y; |
---|
1795 | UInt64 uiSSDY = 0; |
---|
1796 | UInt64 uiSSDU = 0; |
---|
1797 | UInt64 uiSSDV = 0; |
---|
1798 | |
---|
1799 | Double dYPSNR = 0.0; |
---|
1800 | Double dUPSNR = 0.0; |
---|
1801 | Double dVPSNR = 0.0; |
---|
1802 | |
---|
1803 | //===== calculate PSNR ===== |
---|
1804 | Pel* pOrg = pcPic ->getPicYuvOrg()->getLumaAddr(); |
---|
1805 | Pel* pRec = pcPicD->getLumaAddr(); |
---|
1806 | Int iStride = pcPicD->getStride(); |
---|
1807 | |
---|
1808 | Int iWidth; |
---|
1809 | Int iHeight; |
---|
1810 | |
---|
1811 | iWidth = pcPicD->getWidth () - m_pcEncTop->getPad(0); |
---|
1812 | iHeight = pcPicD->getHeight() - m_pcEncTop->getPad(1); |
---|
1813 | |
---|
1814 | Int iSize = iWidth*iHeight; |
---|
1815 | |
---|
1816 | for( y = 0; y < iHeight; y++ ) |
---|
1817 | { |
---|
1818 | for( x = 0; x < iWidth; x++ ) |
---|
1819 | { |
---|
1820 | Int iDiff = (Int)( pOrg[x] - pRec[x] ); |
---|
1821 | uiSSDY += iDiff * iDiff; |
---|
1822 | } |
---|
1823 | pOrg += iStride; |
---|
1824 | pRec += iStride; |
---|
1825 | } |
---|
1826 | |
---|
1827 | #if HHI_VSO |
---|
1828 | #if HHI_VSO_SYNTH_DIST_OUT |
---|
1829 | if ( m_pcRdCost->getUseRenModel() ) |
---|
1830 | { |
---|
1831 | unsigned int maxval = 255 * (1<<(g_uiBitDepth + g_uiBitIncrement -8)); |
---|
1832 | Double fRefValueY = (double) maxval * maxval * iSize; |
---|
1833 | Double fRefValueC = fRefValueY / 4.0; |
---|
1834 | TRenModel* pcRenModel = m_pcEncTop->getEncTop()->getRenModel(); |
---|
1835 | Int64 iDistVSOY, iDistVSOU, iDistVSOV; |
---|
1836 | pcRenModel->getTotalSSE( iDistVSOY, iDistVSOU, iDistVSOV ); |
---|
1837 | dYPSNR = ( iDistVSOY ? 10.0 * log10( fRefValueY / (Double) iDistVSOY ) : 99.99 ); |
---|
1838 | dUPSNR = ( iDistVSOU ? 10.0 * log10( fRefValueC / (Double) iDistVSOU ) : 99.99 ); |
---|
1839 | dVPSNR = ( iDistVSOV ? 10.0 * log10( fRefValueC / (Double) iDistVSOV ) : 99.99 ); |
---|
1840 | } |
---|
1841 | else |
---|
1842 | #endif |
---|
1843 | #endif |
---|
1844 | { |
---|
1845 | iHeight >>= 1; |
---|
1846 | iWidth >>= 1; |
---|
1847 | iStride >>= 1; |
---|
1848 | pOrg = pcPic ->getPicYuvOrg()->getCbAddr(); |
---|
1849 | pRec = pcPicD->getCbAddr(); |
---|
1850 | |
---|
1851 | for( y = 0; y < iHeight; y++ ) |
---|
1852 | { |
---|
1853 | for( x = 0; x < iWidth; x++ ) |
---|
1854 | { |
---|
1855 | Int iDiff = (Int)( pOrg[x] - pRec[x] ); |
---|
1856 | uiSSDU += iDiff * iDiff; |
---|
1857 | } |
---|
1858 | pOrg += iStride; |
---|
1859 | pRec += iStride; |
---|
1860 | } |
---|
1861 | |
---|
1862 | pOrg = pcPic ->getPicYuvOrg()->getCrAddr(); |
---|
1863 | pRec = pcPicD->getCrAddr(); |
---|
1864 | |
---|
1865 | for( y = 0; y < iHeight; y++ ) |
---|
1866 | { |
---|
1867 | for( x = 0; x < iWidth; x++ ) |
---|
1868 | { |
---|
1869 | Int iDiff = (Int)( pOrg[x] - pRec[x] ); |
---|
1870 | uiSSDV += iDiff * iDiff; |
---|
1871 | } |
---|
1872 | pOrg += iStride; |
---|
1873 | pRec += iStride; |
---|
1874 | } |
---|
1875 | |
---|
1876 | unsigned int maxval = 255 * (1<<(g_uiBitDepth + g_uiBitIncrement -8)); |
---|
1877 | Double fRefValueY = (double) maxval * maxval * iSize; |
---|
1878 | Double fRefValueC = fRefValueY / 4.0; |
---|
1879 | dYPSNR = ( uiSSDY ? 10.0 * log10( fRefValueY / (Double)uiSSDY ) : 99.99 ); |
---|
1880 | dUPSNR = ( uiSSDU ? 10.0 * log10( fRefValueC / (Double)uiSSDU ) : 99.99 ); |
---|
1881 | dVPSNR = ( uiSSDV ? 10.0 * log10( fRefValueC / (Double)uiSSDV ) : 99.99 ); |
---|
1882 | } |
---|
1883 | /* calculate the size of the access unit, excluding: |
---|
1884 | * - any AnnexB contributions (start_code_prefix, zero_byte, etc.,) |
---|
1885 | * - SEI NAL units |
---|
1886 | */ |
---|
1887 | unsigned numRBSPBytes = 0; |
---|
1888 | for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++) |
---|
1889 | { |
---|
1890 | unsigned numRBSPBytes_nal = unsigned((*it)->m_nalUnitData.str().size()); |
---|
1891 | #if VERBOSE_RATE |
---|
1892 | printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal); |
---|
1893 | #endif |
---|
1894 | if ((*it)->m_nalUnitType != NAL_UNIT_SEI) |
---|
1895 | numRBSPBytes += numRBSPBytes_nal; |
---|
1896 | } |
---|
1897 | |
---|
1898 | unsigned uibits = numRBSPBytes * 8; |
---|
1899 | m_vRVM_RP.push_back( uibits ); |
---|
1900 | |
---|
1901 | //===== add PSNR ===== |
---|
1902 | m_pcEncTop->getAnalyzeAll()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); |
---|
1903 | TComSlice* pcSlice = pcPic->getSlice(0); |
---|
1904 | if (pcSlice->isIntra()) |
---|
1905 | { |
---|
1906 | m_pcEncTop->getAnalyzeI()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); |
---|
1907 | } |
---|
1908 | if (pcSlice->isInterP()) |
---|
1909 | { |
---|
1910 | m_pcEncTop->getAnalyzeP()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); |
---|
1911 | } |
---|
1912 | if (pcSlice->isInterB()) |
---|
1913 | { |
---|
1914 | m_pcEncTop->getAnalyzeB()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); |
---|
1915 | } |
---|
1916 | |
---|
1917 | Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B'); |
---|
1918 | if (!pcSlice->isReferenced()) c += 32; |
---|
1919 | |
---|
1920 | #if ADAPTIVE_QP_SELECTION |
---|
1921 | printf("%s View %3d POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits", |
---|
1922 | pcSlice->getIsDepth() ? "Depth " : "Texture", |
---|
1923 | pcSlice->getViewId(), |
---|
1924 | pcSlice->getPOC(), |
---|
1925 | pcSlice->getTLayer(), |
---|
1926 | c, |
---|
1927 | pcSlice->getSliceQpBase(), |
---|
1928 | pcSlice->getSliceQp(), |
---|
1929 | uibits ); |
---|
1930 | #else |
---|
1931 | printf("%s View %3d POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits", |
---|
1932 | pcSlice->getIsDepth() ? "Depth " : "Texture", |
---|
1933 | pcSlice->getViewId(), |
---|
1934 | pcSlice->getPOC()-pcSlice->getLastIDR(), |
---|
1935 | pcSlice->getTLayer(), |
---|
1936 | c, |
---|
1937 | pcSlice->getSliceQp(), |
---|
1938 | uibits ); |
---|
1939 | #endif |
---|
1940 | |
---|
1941 | printf(" [Y %6.4lf dB U %6.4lf dB V %6.4lf dB]", dYPSNR, dUPSNR, dVPSNR ); |
---|
1942 | printf(" [ET %5.0f ]", dEncTime ); |
---|
1943 | |
---|
1944 | for (Int iRefList = 0; iRefList < 2; iRefList++) |
---|
1945 | { |
---|
1946 | printf(" [L%d ", iRefList); |
---|
1947 | for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++) |
---|
1948 | { |
---|
1949 | if( pcSlice->getViewId() != pcSlice->getRefViewId( RefPicList(iRefList), iRefIndex ) ) |
---|
1950 | { |
---|
1951 | printf( "V%d ", pcSlice->getRefViewId( RefPicList(iRefList), iRefIndex ) ); |
---|
1952 | } |
---|
1953 | else |
---|
1954 | { |
---|
1955 | printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR()); |
---|
1956 | } |
---|
1957 | } |
---|
1958 | printf("]"); |
---|
1959 | } |
---|
1960 | if(pcSlice->getNumRefIdx(REF_PIC_LIST_C)>0 && !pcSlice->getNoBackPredFlag()) |
---|
1961 | { |
---|
1962 | printf(" [LC "); |
---|
1963 | for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(REF_PIC_LIST_C); iRefIndex++) |
---|
1964 | { |
---|
1965 | if( pcSlice->getViewId() != pcSlice->getRefViewId( (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIndex), pcSlice->getRefIdxFromIdxOfLC(iRefIndex) ) ) |
---|
1966 | { |
---|
1967 | printf( "V%d ", pcSlice->getRefViewId( (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIndex), pcSlice->getRefIdxFromIdxOfLC(iRefIndex) ) ); |
---|
1968 | } |
---|
1969 | else |
---|
1970 | { |
---|
1971 | printf ("%d ", pcSlice->getRefPOC((RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIndex), pcSlice->getRefIdxFromIdxOfLC(iRefIndex))-pcSlice->getLastIDR()); |
---|
1972 | } |
---|
1973 | } |
---|
1974 | printf("]"); |
---|
1975 | } |
---|
1976 | } |
---|
1977 | |
---|
1978 | /** Function for deciding the nal_unit_type. |
---|
1979 | * \param uiPOCCurr POC of the current picture |
---|
1980 | * \returns the nal_unit type of the picture |
---|
1981 | * This function checks the configuration and returns the appropriate nal_unit_type for the picture. |
---|
1982 | */ |
---|
1983 | NalUnitType TEncGOP::getNalUnitType(UInt uiPOCCurr) |
---|
1984 | { |
---|
1985 | Bool bInterViewOnlySlice = ( m_pcCfg->getGOPEntry(MAX_GOP).m_POC == 0 && (m_pcCfg->getGOPEntry(MAX_GOP).m_sliceType == 'P' || m_pcCfg->getGOPEntry(MAX_GOP).m_sliceType == 'B') ); |
---|
1986 | |
---|
1987 | if (uiPOCCurr == 0) |
---|
1988 | { |
---|
1989 | if( bInterViewOnlySlice ) |
---|
1990 | { |
---|
1991 | #if !QC_REM_IDV_B0046 |
---|
1992 | return NAL_UNIT_CODED_SLICE_IDV; |
---|
1993 | #else |
---|
1994 | return NAL_UNIT_CODED_SLICE_IDR; |
---|
1995 | #endif |
---|
1996 | } |
---|
1997 | else |
---|
1998 | { |
---|
1999 | return NAL_UNIT_CODED_SLICE_IDR; |
---|
2000 | } |
---|
2001 | } |
---|
2002 | if (uiPOCCurr % m_pcCfg->getIntraPeriod() == 0) |
---|
2003 | { |
---|
2004 | if (m_pcCfg->getDecodingRefreshType() == 1) |
---|
2005 | { |
---|
2006 | if( bInterViewOnlySlice ) |
---|
2007 | { |
---|
2008 | #if !QC_REM_IDV_B0046 |
---|
2009 | return NAL_UNIT_CODED_SLICE_IDV; |
---|
2010 | #else |
---|
2011 | return NAL_UNIT_CODED_SLICE_CRA; |
---|
2012 | #endif |
---|
2013 | } |
---|
2014 | else |
---|
2015 | { |
---|
2016 | return NAL_UNIT_CODED_SLICE_CRA; |
---|
2017 | } |
---|
2018 | } |
---|
2019 | else if (m_pcCfg->getDecodingRefreshType() == 2) |
---|
2020 | { |
---|
2021 | if( bInterViewOnlySlice ) |
---|
2022 | { |
---|
2023 | #if !QC_REM_IDV_B0046 |
---|
2024 | return NAL_UNIT_CODED_SLICE_IDV; |
---|
2025 | #else |
---|
2026 | return NAL_UNIT_CODED_SLICE_IDR; |
---|
2027 | #endif |
---|
2028 | } |
---|
2029 | else |
---|
2030 | { |
---|
2031 | return NAL_UNIT_CODED_SLICE_IDR; |
---|
2032 | } |
---|
2033 | } |
---|
2034 | } |
---|
2035 | return NAL_UNIT_CODED_SLICE; |
---|
2036 | } |
---|
2037 | |
---|
2038 | NalUnitType TEncGOP::getNalUnitTypeBaseViewMvc(UInt uiPOCCurr) |
---|
2039 | { |
---|
2040 | if( uiPOCCurr == 0 ) |
---|
2041 | { |
---|
2042 | return NAL_UNIT_CODED_SLICE_IDR; |
---|
2043 | } |
---|
2044 | if( uiPOCCurr % m_pcCfg->getIntraPeriod() == 0 ) |
---|
2045 | { |
---|
2046 | if( m_pcCfg->getDecodingRefreshType() == 1 ) |
---|
2047 | { |
---|
2048 | return NAL_UNIT_CODED_SLICE_CRA; |
---|
2049 | } |
---|
2050 | else if( m_pcCfg->getDecodingRefreshType() == 2 ) |
---|
2051 | { |
---|
2052 | return NAL_UNIT_CODED_SLICE_IDR; |
---|
2053 | } |
---|
2054 | } |
---|
2055 | return NAL_UNIT_CODED_SLICE; |
---|
2056 | } |
---|
2057 | |
---|
2058 | Double TEncGOP::xCalculateRVM() |
---|
2059 | { |
---|
2060 | Double dRVM = 0; |
---|
2061 | |
---|
2062 | if( m_pcCfg->getGOPSize() == 1 && m_pcCfg->getIntraPeriod() != 1 && m_pcCfg->getFrameToBeEncoded() > RVM_VCEGAM10_M * 2 ) |
---|
2063 | { |
---|
2064 | // calculate RVM only for lowdelay configurations |
---|
2065 | std::vector<Double> vRL , vB; |
---|
2066 | size_t N = m_vRVM_RP.size(); |
---|
2067 | vRL.resize( N ); |
---|
2068 | vB.resize( N ); |
---|
2069 | |
---|
2070 | Int i; |
---|
2071 | Double dRavg = 0 , dBavg = 0; |
---|
2072 | vB[RVM_VCEGAM10_M] = 0; |
---|
2073 | for( i = RVM_VCEGAM10_M + 1 ; i < N - RVM_VCEGAM10_M + 1 ; i++ ) |
---|
2074 | { |
---|
2075 | vRL[i] = 0; |
---|
2076 | for( Int j = i - RVM_VCEGAM10_M ; j <= i + RVM_VCEGAM10_M - 1 ; j++ ) |
---|
2077 | vRL[i] += m_vRVM_RP[j]; |
---|
2078 | vRL[i] /= ( 2 * RVM_VCEGAM10_M ); |
---|
2079 | vB[i] = vB[i-1] + m_vRVM_RP[i] - vRL[i]; |
---|
2080 | dRavg += m_vRVM_RP[i]; |
---|
2081 | dBavg += vB[i]; |
---|
2082 | } |
---|
2083 | |
---|
2084 | dRavg /= ( N - 2 * RVM_VCEGAM10_M ); |
---|
2085 | dBavg /= ( N - 2 * RVM_VCEGAM10_M ); |
---|
2086 | |
---|
2087 | double dSigamB = 0; |
---|
2088 | for( i = RVM_VCEGAM10_M + 1 ; i < N - RVM_VCEGAM10_M + 1 ; i++ ) |
---|
2089 | { |
---|
2090 | Double tmp = vB[i] - dBavg; |
---|
2091 | dSigamB += tmp * tmp; |
---|
2092 | } |
---|
2093 | dSigamB = sqrt( dSigamB / ( N - 2 * RVM_VCEGAM10_M ) ); |
---|
2094 | |
---|
2095 | double f = sqrt( 12.0 * ( RVM_VCEGAM10_M - 1 ) / ( RVM_VCEGAM10_M + 1 ) ); |
---|
2096 | |
---|
2097 | dRVM = dSigamB / dRavg * f; |
---|
2098 | } |
---|
2099 | |
---|
2100 | return( dRVM ); |
---|
2101 | } |
---|
2102 | |
---|
2103 | /** Determine the difference between consecutive tile sizes (in bytes) and writes it to bistream rNalu [slice header] |
---|
2104 | * \param rpcBitstreamRedirect contains the bitstream to be concatenated to rNalu. rpcBitstreamRedirect contains slice payload. rpcSlice contains tile location information. |
---|
2105 | * \returns Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call. |
---|
2106 | */ |
---|
2107 | Void TEncGOP::xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice) |
---|
2108 | { |
---|
2109 | { |
---|
2110 | } |
---|
2111 | |
---|
2112 | // Byte-align |
---|
2113 | rNalu.m_Bitstream.writeAlignOne(); |
---|
2114 | |
---|
2115 | // Update tile marker locations |
---|
2116 | TComOutputBitstream *pcOut = &rNalu.m_Bitstream; |
---|
2117 | UInt uiAccumulatedLength = pcOut->getNumberOfWrittenBits() >> 3; |
---|
2118 | for (Int uiMrkIdx = 0; uiMrkIdx < rpcBitstreamRedirect->getTileMarkerLocationCount(); uiMrkIdx++) |
---|
2119 | { |
---|
2120 | UInt uiBottom = pcOut->getTileMarkerLocationCount(); |
---|
2121 | pcOut->setTileMarkerLocation ( uiBottom, uiAccumulatedLength + rpcBitstreamRedirect->getTileMarkerLocation( uiMrkIdx ) ); |
---|
2122 | pcOut->setTileMarkerLocationCount ( uiBottom + 1 ); |
---|
2123 | } |
---|
2124 | |
---|
2125 | // Perform bitstream concatenation |
---|
2126 | if (rpcBitstreamRedirect->getNumberOfWrittenBits() > 0) |
---|
2127 | { |
---|
2128 | UInt uiBitCount = rpcBitstreamRedirect->getNumberOfWrittenBits(); |
---|
2129 | if (rpcBitstreamRedirect->getByteStreamLength()>0) |
---|
2130 | { |
---|
2131 | UChar *pucStart = reinterpret_cast<UChar*>(rpcBitstreamRedirect->getByteStream()); |
---|
2132 | UInt uiWriteByteCount = 0; |
---|
2133 | while (uiWriteByteCount < (uiBitCount >> 3) ) |
---|
2134 | { |
---|
2135 | UInt uiBits = (*pucStart); |
---|
2136 | rNalu.m_Bitstream.write(uiBits, 8); |
---|
2137 | pucStart++; |
---|
2138 | uiWriteByteCount++; |
---|
2139 | } |
---|
2140 | } |
---|
2141 | UInt uiBitsHeld = (uiBitCount & 0x07); |
---|
2142 | for (UInt uiIdx=0; uiIdx < uiBitsHeld; uiIdx++) |
---|
2143 | { |
---|
2144 | rNalu.m_Bitstream.write((rpcBitstreamRedirect->getHeldBits() & (1 << (7-uiIdx))) >> (7-uiIdx), 1); |
---|
2145 | } |
---|
2146 | } |
---|
2147 | |
---|
2148 | m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream); |
---|
2149 | |
---|
2150 | delete rpcBitstreamRedirect; |
---|
2151 | rpcBitstreamRedirect = new TComOutputBitstream; |
---|
2152 | } |
---|
2153 | |
---|
2154 | Void TEncGOP::xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid ) |
---|
2155 | { |
---|
2156 | if( pcSlice->getSliceType() == I_SLICE || !(pcSlice->getSPS()->getListsModificationPresentFlag()) || pcSlice->getSPS()->getNumberOfUsableInterViewRefs() == 0 ) |
---|
2157 | { |
---|
2158 | return; |
---|
2159 | } |
---|
2160 | |
---|
2161 | // analyze inter-view modifications |
---|
2162 | #if !QC_REM_IDV_B0046 |
---|
2163 | GOPEntryMvc gem = m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ); |
---|
2164 | #else |
---|
2165 | Bool bRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA)) && (pcSlice->getSPS()->getViewId()) ? 1:0; |
---|
2166 | GOPEntryMvc gem = m_pcCfg->getGOPEntry( bRAP ? MAX_GOP : iGOPid ); |
---|
2167 | #endif |
---|
2168 | Int numL0Modifications = 0; |
---|
2169 | Int numL1Modifications = 0; |
---|
2170 | for( Int k = 0; k < gem.m_numInterViewRefPics; k++ ) |
---|
2171 | { |
---|
2172 | if( gem.m_interViewRefPosL0[k] > 0 ) { numL0Modifications++; } |
---|
2173 | if( gem.m_interViewRefPosL1[k] > 0 ) { numL1Modifications++; } |
---|
2174 | } |
---|
2175 | |
---|
2176 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
2177 | Int maxRefListSize = pcSlice->getNumPocTotalCurrMvc(); |
---|
2178 | Int numTemporalRefs = pcSlice->getNumPocTotalCurr(); |
---|
2179 | |
---|
2180 | // set L0 inter-view modifications |
---|
2181 | if( (maxRefListSize > 1) && (numL0Modifications > 0) ) |
---|
2182 | { |
---|
2183 | refPicListModification->setRefPicListModificationFlagL0( true ); |
---|
2184 | Int tempListEntryL0[16]; |
---|
2185 | for( Int k = 0; k < 16; k++ ) { tempListEntryL0[k] = -1; } |
---|
2186 | |
---|
2187 | Bool hasModification = false; |
---|
2188 | for( Int k = 0; k < gem.m_numInterViewRefPics; k++ ) |
---|
2189 | { |
---|
2190 | if( gem.m_interViewRefPosL0[k] > 0 ) |
---|
2191 | { |
---|
2192 | for( Int l = 0; l < pcSlice->getSPS()->getNumberOfUsableInterViewRefs(); l++ ) |
---|
2193 | { |
---|
2194 | if( gem.m_interViewRefs[k] == pcSlice->getSPS()->getUsableInterViewRef( l ) && (gem.m_interViewRefPosL0[k] - 1) != (numTemporalRefs + l) ) |
---|
2195 | { |
---|
2196 | tempListEntryL0[gem.m_interViewRefPosL0[k]-1] = numTemporalRefs + l; |
---|
2197 | hasModification = true; |
---|
2198 | } |
---|
2199 | } |
---|
2200 | } |
---|
2201 | } |
---|
2202 | |
---|
2203 | if( hasModification ) |
---|
2204 | { |
---|
2205 | Int temporalRefIdx = 0; |
---|
2206 | for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++ ) |
---|
2207 | { |
---|
2208 | if( tempListEntryL0[i] >= 0 ) |
---|
2209 | { |
---|
2210 | refPicListModification->setRefPicSetIdxL0( i, tempListEntryL0[i] ); |
---|
2211 | } |
---|
2212 | else |
---|
2213 | { |
---|
2214 | refPicListModification->setRefPicSetIdxL0( i, temporalRefIdx ); |
---|
2215 | temporalRefIdx++; |
---|
2216 | } |
---|
2217 | } |
---|
2218 | } |
---|
2219 | else |
---|
2220 | { |
---|
2221 | refPicListModification->setRefPicListModificationFlagL0( false ); |
---|
2222 | } |
---|
2223 | } |
---|
2224 | |
---|
2225 | // set L1 inter-view modifications |
---|
2226 | if( (maxRefListSize > 1) && (numL1Modifications > 0) ) |
---|
2227 | { |
---|
2228 | refPicListModification->setRefPicListModificationFlagL1( true ); |
---|
2229 | Int tempListEntryL1[16]; |
---|
2230 | for( Int k = 0; k < 16; k++ ) { tempListEntryL1[k] = -1; } |
---|
2231 | |
---|
2232 | Bool hasModification = false; |
---|
2233 | for( Int k = 0; k < gem.m_numInterViewRefPics; k++ ) |
---|
2234 | { |
---|
2235 | if( gem.m_interViewRefPosL1[k] > 0 ) |
---|
2236 | { |
---|
2237 | for( Int l = 0; l < pcSlice->getSPS()->getNumberOfUsableInterViewRefs(); l++ ) |
---|
2238 | { |
---|
2239 | if( gem.m_interViewRefs[k] == pcSlice->getSPS()->getUsableInterViewRef( l ) && (gem.m_interViewRefPosL1[k] - 1) != (numTemporalRefs + l) ) |
---|
2240 | { |
---|
2241 | tempListEntryL1[gem.m_interViewRefPosL1[k]-1] = numTemporalRefs + l; |
---|
2242 | hasModification = true; |
---|
2243 | } |
---|
2244 | } |
---|
2245 | } |
---|
2246 | } |
---|
2247 | |
---|
2248 | if( hasModification ) |
---|
2249 | { |
---|
2250 | Int temporalRefIdx = 0; |
---|
2251 | for( Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++ ) |
---|
2252 | { |
---|
2253 | if( tempListEntryL1[i] >= 0 ) |
---|
2254 | { |
---|
2255 | refPicListModification->setRefPicSetIdxL1( i, tempListEntryL1[i] ); |
---|
2256 | } |
---|
2257 | else |
---|
2258 | { |
---|
2259 | refPicListModification->setRefPicSetIdxL1( i, temporalRefIdx ); |
---|
2260 | temporalRefIdx++; |
---|
2261 | } |
---|
2262 | } |
---|
2263 | } |
---|
2264 | else |
---|
2265 | { |
---|
2266 | refPicListModification->setRefPicListModificationFlagL1( false ); |
---|
2267 | } |
---|
2268 | } |
---|
2269 | |
---|
2270 | return; |
---|
2271 | } |
---|
2272 | //! \} |
---|