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