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 TEncCu.cpp |
---|
35 | \brief Coding Unit (CU) encoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <stdio.h> |
---|
39 | #include "TEncTop.h" |
---|
40 | #include "TEncCu.h" |
---|
41 | #include "TEncAnalyze.h" |
---|
42 | |
---|
43 | #include <cmath> |
---|
44 | #include <algorithm> |
---|
45 | using namespace std; |
---|
46 | |
---|
47 | //! \ingroup TLibEncoder |
---|
48 | //! \{ |
---|
49 | |
---|
50 | // ==================================================================================================================== |
---|
51 | // Constructor / destructor / create / destroy |
---|
52 | // ==================================================================================================================== |
---|
53 | |
---|
54 | /** |
---|
55 | \param uiTotalDepth total number of allowable depth |
---|
56 | \param uiMaxWidth largest CU width |
---|
57 | \param uiMaxHeight largest CU height |
---|
58 | */ |
---|
59 | Void TEncCu::create(UChar uhTotalDepth, UInt uiMaxWidth, UInt uiMaxHeight) |
---|
60 | { |
---|
61 | Int i; |
---|
62 | |
---|
63 | m_uhTotalDepth = uhTotalDepth + 1; |
---|
64 | m_ppcBestCU = new TComDataCU*[m_uhTotalDepth-1]; |
---|
65 | m_ppcTempCU = new TComDataCU*[m_uhTotalDepth-1]; |
---|
66 | |
---|
67 | m_ppcPredYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
68 | m_ppcResiYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
69 | m_ppcRecoYuvBest = new TComYuv*[m_uhTotalDepth-1]; |
---|
70 | m_ppcPredYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
71 | m_ppcResiYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
72 | m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1]; |
---|
73 | m_ppcOrigYuv = new TComYuv*[m_uhTotalDepth-1]; |
---|
74 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
75 | m_ppcResPredTmp = new TComYuv*[m_uhTotalDepth-1]; |
---|
76 | #endif |
---|
77 | |
---|
78 | #if HHI_MPI |
---|
79 | m_puhDepthSaved = new UChar[1ll<<( ( m_uhTotalDepth - 1 )<<1 )]; |
---|
80 | m_puhWidthSaved = new UChar[1ll<<( ( m_uhTotalDepth - 1 )<<1 )]; |
---|
81 | m_puhHeightSaved = new UChar[1ll<<( ( m_uhTotalDepth - 1 )<<1 )]; |
---|
82 | #endif |
---|
83 | |
---|
84 | UInt uiNumPartitions; |
---|
85 | for( i=0 ; i<m_uhTotalDepth-1 ; i++) |
---|
86 | { |
---|
87 | uiNumPartitions = 1<<( ( m_uhTotalDepth - i - 1 )<<1 ); |
---|
88 | UInt uiWidth = uiMaxWidth >> i; |
---|
89 | UInt uiHeight = uiMaxHeight >> i; |
---|
90 | |
---|
91 | m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); |
---|
92 | m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) ); |
---|
93 | |
---|
94 | m_ppcPredYuvBest[i] = new TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight); |
---|
95 | m_ppcResiYuvBest[i] = new TComYuv; m_ppcResiYuvBest[i]->create(uiWidth, uiHeight); |
---|
96 | m_ppcRecoYuvBest[i] = new TComYuv; m_ppcRecoYuvBest[i]->create(uiWidth, uiHeight); |
---|
97 | |
---|
98 | m_ppcPredYuvTemp[i] = new TComYuv; m_ppcPredYuvTemp[i]->create(uiWidth, uiHeight); |
---|
99 | m_ppcResiYuvTemp[i] = new TComYuv; m_ppcResiYuvTemp[i]->create(uiWidth, uiHeight); |
---|
100 | m_ppcRecoYuvTemp[i] = new TComYuv; m_ppcRecoYuvTemp[i]->create(uiWidth, uiHeight); |
---|
101 | |
---|
102 | m_ppcOrigYuv [i] = new TComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight); |
---|
103 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
104 | m_ppcResPredTmp [i] = new TComYuv; m_ppcResPredTmp [i]->create(uiWidth, uiHeight); |
---|
105 | #endif |
---|
106 | } |
---|
107 | |
---|
108 | m_bEncodeDQP = false; |
---|
109 | #if BURST_IPCM |
---|
110 | m_checkBurstIPCMFlag = false; |
---|
111 | #endif |
---|
112 | |
---|
113 | // initialize partition order. |
---|
114 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
115 | initZscanToRaster( m_uhTotalDepth, 1, 0, piTmp); |
---|
116 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
117 | |
---|
118 | // initialize conversion matrix from partition index to pel |
---|
119 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
120 | initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uhTotalDepth ); |
---|
121 | } |
---|
122 | |
---|
123 | Void TEncCu::destroy() |
---|
124 | { |
---|
125 | Int i; |
---|
126 | |
---|
127 | #if HHI_MPI |
---|
128 | delete[] m_puhDepthSaved; m_puhDepthSaved = NULL; |
---|
129 | delete[] m_puhWidthSaved; m_puhWidthSaved = NULL; |
---|
130 | delete[] m_puhHeightSaved; m_puhHeightSaved = NULL; |
---|
131 | #endif |
---|
132 | for( i=0 ; i<m_uhTotalDepth-1 ; i++) |
---|
133 | { |
---|
134 | if(m_ppcBestCU[i]) |
---|
135 | { |
---|
136 | m_ppcBestCU[i]->destroy(); delete m_ppcBestCU[i]; m_ppcBestCU[i] = NULL; |
---|
137 | } |
---|
138 | if(m_ppcTempCU[i]) |
---|
139 | { |
---|
140 | m_ppcTempCU[i]->destroy(); delete m_ppcTempCU[i]; m_ppcTempCU[i] = NULL; |
---|
141 | } |
---|
142 | if(m_ppcPredYuvBest[i]) |
---|
143 | { |
---|
144 | m_ppcPredYuvBest[i]->destroy(); delete m_ppcPredYuvBest[i]; m_ppcPredYuvBest[i] = NULL; |
---|
145 | } |
---|
146 | if(m_ppcResiYuvBest[i]) |
---|
147 | { |
---|
148 | m_ppcResiYuvBest[i]->destroy(); delete m_ppcResiYuvBest[i]; m_ppcResiYuvBest[i] = NULL; |
---|
149 | } |
---|
150 | if(m_ppcRecoYuvBest[i]) |
---|
151 | { |
---|
152 | m_ppcRecoYuvBest[i]->destroy(); delete m_ppcRecoYuvBest[i]; m_ppcRecoYuvBest[i] = NULL; |
---|
153 | } |
---|
154 | if(m_ppcPredYuvTemp[i]) |
---|
155 | { |
---|
156 | m_ppcPredYuvTemp[i]->destroy(); delete m_ppcPredYuvTemp[i]; m_ppcPredYuvTemp[i] = NULL; |
---|
157 | } |
---|
158 | if(m_ppcResiYuvTemp[i]) |
---|
159 | { |
---|
160 | m_ppcResiYuvTemp[i]->destroy(); delete m_ppcResiYuvTemp[i]; m_ppcResiYuvTemp[i] = NULL; |
---|
161 | } |
---|
162 | if(m_ppcRecoYuvTemp[i]) |
---|
163 | { |
---|
164 | m_ppcRecoYuvTemp[i]->destroy(); delete m_ppcRecoYuvTemp[i]; m_ppcRecoYuvTemp[i] = NULL; |
---|
165 | } |
---|
166 | if(m_ppcOrigYuv[i]) |
---|
167 | { |
---|
168 | m_ppcOrigYuv[i]->destroy(); delete m_ppcOrigYuv[i]; m_ppcOrigYuv[i] = NULL; |
---|
169 | } |
---|
170 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
171 | if(m_ppcResPredTmp[i]) |
---|
172 | { |
---|
173 | m_ppcResPredTmp [i]->destroy(); delete m_ppcResPredTmp[i]; m_ppcResPredTmp[i] = NULL; |
---|
174 | } |
---|
175 | #endif |
---|
176 | } |
---|
177 | if(m_ppcBestCU) |
---|
178 | { |
---|
179 | delete [] m_ppcBestCU; |
---|
180 | m_ppcBestCU = NULL; |
---|
181 | } |
---|
182 | if(m_ppcTempCU) |
---|
183 | { |
---|
184 | delete [] m_ppcTempCU; |
---|
185 | m_ppcTempCU = NULL; |
---|
186 | } |
---|
187 | |
---|
188 | if(m_ppcPredYuvBest) |
---|
189 | { |
---|
190 | delete [] m_ppcPredYuvBest; |
---|
191 | m_ppcPredYuvBest = NULL; |
---|
192 | } |
---|
193 | if(m_ppcResiYuvBest) |
---|
194 | { |
---|
195 | delete [] m_ppcResiYuvBest; |
---|
196 | m_ppcResiYuvBest = NULL; |
---|
197 | } |
---|
198 | if(m_ppcRecoYuvBest) |
---|
199 | { |
---|
200 | delete [] m_ppcRecoYuvBest; |
---|
201 | m_ppcRecoYuvBest = NULL; |
---|
202 | } |
---|
203 | if(m_ppcPredYuvTemp) |
---|
204 | { |
---|
205 | delete [] m_ppcPredYuvTemp; |
---|
206 | m_ppcPredYuvTemp = NULL; |
---|
207 | } |
---|
208 | if(m_ppcResiYuvTemp) |
---|
209 | { |
---|
210 | delete [] m_ppcResiYuvTemp; |
---|
211 | m_ppcResiYuvTemp = NULL; |
---|
212 | } |
---|
213 | if(m_ppcRecoYuvTemp) |
---|
214 | { |
---|
215 | delete [] m_ppcRecoYuvTemp; |
---|
216 | m_ppcRecoYuvTemp = NULL; |
---|
217 | } |
---|
218 | if(m_ppcOrigYuv) |
---|
219 | { |
---|
220 | delete [] m_ppcOrigYuv; |
---|
221 | m_ppcOrigYuv = NULL; |
---|
222 | } |
---|
223 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
224 | if(m_ppcResPredTmp) |
---|
225 | { |
---|
226 | delete [] m_ppcResPredTmp; |
---|
227 | m_ppcResPredTmp = NULL; |
---|
228 | } |
---|
229 | #endif |
---|
230 | } |
---|
231 | |
---|
232 | /** \param pcEncTop pointer of encoder class |
---|
233 | */ |
---|
234 | Void TEncCu::init( TEncTop* pcEncTop ) |
---|
235 | { |
---|
236 | m_pcEncCfg = pcEncTop; |
---|
237 | m_pcPredSearch = pcEncTop->getPredSearch(); |
---|
238 | m_pcTrQuant = pcEncTop->getTrQuant(); |
---|
239 | m_pcBitCounter = pcEncTop->getBitCounter(); |
---|
240 | m_pcRdCost = pcEncTop->getRdCost(); |
---|
241 | |
---|
242 | m_pcEntropyCoder = pcEncTop->getEntropyCoder(); |
---|
243 | m_pcCavlcCoder = pcEncTop->getCavlcCoder(); |
---|
244 | m_pcSbacCoder = pcEncTop->getSbacCoder(); |
---|
245 | m_pcBinCABAC = pcEncTop->getBinCABAC(); |
---|
246 | |
---|
247 | m_pppcRDSbacCoder = pcEncTop->getRDSbacCoder(); |
---|
248 | m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder(); |
---|
249 | |
---|
250 | m_bUseSBACRD = pcEncTop->getUseSBACRD(); |
---|
251 | } |
---|
252 | |
---|
253 | // ==================================================================================================================== |
---|
254 | // Public member functions |
---|
255 | // ==================================================================================================================== |
---|
256 | |
---|
257 | /** \param rpcCU pointer of CU data class |
---|
258 | */ |
---|
259 | Void TEncCu::compressCU( TComDataCU*& rpcCU ) |
---|
260 | { |
---|
261 | // initialize CU data |
---|
262 | m_ppcBestCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); |
---|
263 | m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); |
---|
264 | |
---|
265 | // analysis of CU |
---|
266 | xCompressCU( m_ppcBestCU[0], m_ppcTempCU[0], 0 ); |
---|
267 | |
---|
268 | #if ADAPTIVE_QP_SELECTION |
---|
269 | if( m_pcEncCfg->getUseAdaptQpSelect() ) |
---|
270 | { |
---|
271 | if(rpcCU->getSlice()->getSliceType()!=I_SLICE) //IIII |
---|
272 | { |
---|
273 | xLcuCollectARLStats( rpcCU); |
---|
274 | } |
---|
275 | } |
---|
276 | #endif |
---|
277 | } |
---|
278 | /** \param pcCU pointer of CU data class, bForceTerminate when set to true terminates slice (default is false). |
---|
279 | */ |
---|
280 | Void TEncCu::encodeCU ( TComDataCU* pcCU, Bool bForceTerminate ) |
---|
281 | { |
---|
282 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
283 | { |
---|
284 | setdQPFlag(true); |
---|
285 | } |
---|
286 | |
---|
287 | #if BURST_IPCM |
---|
288 | TComPic* pcPic = pcCU->getPic(); |
---|
289 | Bool checkBurstIPCMFlag = (pcPic->getSlice(0)->getSPS()->getUsePCM())? true : false; |
---|
290 | |
---|
291 | setCheckBurstIPCMFlag( checkBurstIPCMFlag ); |
---|
292 | |
---|
293 | pcCU->setNumSucIPCM(0); |
---|
294 | pcCU->setLastCUSucIPCMFlag(false); |
---|
295 | #endif |
---|
296 | |
---|
297 | // Encode CU data |
---|
298 | xEncodeCU( pcCU, 0, 0 ); |
---|
299 | |
---|
300 | #if OL_FLUSH |
---|
301 | bool bTerminateSlice = bForceTerminate; |
---|
302 | UInt uiCUAddr = pcCU->getAddr(); |
---|
303 | /* If at the end of an LCU line but not at the end of a substream, perform CABAC flush */ |
---|
304 | #if WPP_SIMPLIFICATION |
---|
305 | if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) |
---|
306 | #else |
---|
307 | if (!bTerminateSlice && pcCU->getSlice()->getPPS()->getCabacIstateReset()) |
---|
308 | #endif |
---|
309 | { |
---|
310 | Int iNumSubstreams = pcCU->getSlice()->getPPS()->getNumSubstreams(); |
---|
311 | UInt uiWidthInLCUs = pcCU->getPic()->getPicSym()->getFrameWidthInCU(); |
---|
312 | UInt uiCol = uiCUAddr % uiWidthInLCUs; |
---|
313 | UInt uiLin = uiCUAddr / uiWidthInLCUs; |
---|
314 | #if !REMOVE_TILE_DEPENDENCE |
---|
315 | Int iBreakDep = pcCU->getPic()->getPicSym()->getTileBoundaryIndependenceIdr(); |
---|
316 | #endif |
---|
317 | UInt uiTileStartLCU = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); |
---|
318 | UInt uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; |
---|
319 | UInt uiTileLCUY = uiTileStartLCU / uiWidthInLCUs; |
---|
320 | UInt uiTileWidth = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getTileWidth(); |
---|
321 | UInt uiTileHeight = pcCU->getPic()->getPicSym()->getTComTile(pcCU->getPic()->getPicSym()->getTileIdxMap(uiCUAddr))->getTileHeight(); |
---|
322 | Int iNumSubstreamsPerTile = iNumSubstreams; |
---|
323 | #if !REMOVE_TILE_DEPENDENCE |
---|
324 | #if WPP_SIMPLIFICATION |
---|
325 | if (iBreakDep && pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) |
---|
326 | #else |
---|
327 | if (iBreakDep && pcCU->getSlice()->getPPS()->getEntropyCodingSynchro()) |
---|
328 | #endif |
---|
329 | iNumSubstreamsPerTile /= pcCU->getPic()->getPicSym()->getNumTiles(); |
---|
330 | if ((iBreakDep && (uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight)) |
---|
331 | || (!iBreakDep && (uiCol == uiWidthInLCUs-1) && (uiLin+iNumSubstreams < pcCU->getPic()->getFrameHeightInCU()))) |
---|
332 | { |
---|
333 | m_pcEntropyCoder->encodeFlush(); |
---|
334 | } |
---|
335 | #else |
---|
336 | #if WPP_SIMPLIFICATION |
---|
337 | if (pcCU->getSlice()->getPPS()->getNumSubstreams() > 1) |
---|
338 | #else |
---|
339 | if (pcCU->getSlice()->getPPS()->getEntropyCodingSynchro()) |
---|
340 | #endif |
---|
341 | { |
---|
342 | iNumSubstreamsPerTile /= pcCU->getPic()->getPicSym()->getNumTiles(); |
---|
343 | } |
---|
344 | if ((uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight)) |
---|
345 | { |
---|
346 | m_pcEntropyCoder->encodeFlush(); |
---|
347 | } |
---|
348 | #endif |
---|
349 | } |
---|
350 | #endif // OL_FLUSH |
---|
351 | } |
---|
352 | |
---|
353 | // ==================================================================================================================== |
---|
354 | // Protected member functions |
---|
355 | // ==================================================================================================================== |
---|
356 | /** Derive small set of test modes for AMP encoder speed-up |
---|
357 | *\param rpcBestCU |
---|
358 | *\param eParentPartSize |
---|
359 | *\param bTestAMP_Hor |
---|
360 | *\param bTestAMP_Ver |
---|
361 | *\param bTestMergeAMP_Hor |
---|
362 | *\param bTestMergeAMP_Ver |
---|
363 | *\returns Void |
---|
364 | */ |
---|
365 | #if AMP_ENC_SPEEDUP |
---|
366 | #if AMP_MRG |
---|
367 | Void TEncCu::deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver) |
---|
368 | #else |
---|
369 | Void TEncCu::deriveTestModeAMP (TComDataCU *&rpcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver) |
---|
370 | #endif |
---|
371 | { |
---|
372 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN ) |
---|
373 | { |
---|
374 | bTestAMP_Hor = true; |
---|
375 | } |
---|
376 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
377 | { |
---|
378 | bTestAMP_Ver = true; |
---|
379 | } |
---|
380 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->getMergeFlag(0) == false && rpcBestCU->isSkipped(0) == false ) |
---|
381 | { |
---|
382 | bTestAMP_Hor = true; |
---|
383 | bTestAMP_Ver = true; |
---|
384 | } |
---|
385 | |
---|
386 | #if AMP_MRG |
---|
387 | //! Utilizing the partition size of parent PU |
---|
388 | if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) |
---|
389 | { |
---|
390 | bTestMergeAMP_Hor = true; |
---|
391 | bTestMergeAMP_Ver = true; |
---|
392 | } |
---|
393 | |
---|
394 | if ( eParentPartSize == SIZE_NONE ) //! if parent is intra |
---|
395 | { |
---|
396 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2NxN ) |
---|
397 | { |
---|
398 | bTestMergeAMP_Hor = true; |
---|
399 | } |
---|
400 | else if ( rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
401 | { |
---|
402 | bTestMergeAMP_Ver = true; |
---|
403 | } |
---|
404 | } |
---|
405 | |
---|
406 | if ( rpcBestCU->getPartitionSize(0) == SIZE_2Nx2N && rpcBestCU->isSkipped(0) == false ) |
---|
407 | { |
---|
408 | bTestMergeAMP_Hor = true; |
---|
409 | bTestMergeAMP_Ver = true; |
---|
410 | } |
---|
411 | |
---|
412 | if ( rpcBestCU->getWidth(0) == 64 ) |
---|
413 | { |
---|
414 | bTestAMP_Hor = false; |
---|
415 | bTestAMP_Ver = false; |
---|
416 | } |
---|
417 | #else |
---|
418 | //! Utilizing the partition size of parent PU |
---|
419 | if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N ) |
---|
420 | { |
---|
421 | bTestAMP_Hor = true; |
---|
422 | bTestAMP_Ver = true; |
---|
423 | } |
---|
424 | |
---|
425 | if ( eParentPartSize == SIZE_2Nx2N ) |
---|
426 | { |
---|
427 | bTestAMP_Hor = false; |
---|
428 | bTestAMP_Ver = false; |
---|
429 | } |
---|
430 | #endif |
---|
431 | } |
---|
432 | #endif |
---|
433 | |
---|
434 | // ==================================================================================================================== |
---|
435 | // Protected member functions |
---|
436 | // ==================================================================================================================== |
---|
437 | /** Compress a CU block recursively with enabling sub-LCU-level delta QP |
---|
438 | *\param rpcBestCU |
---|
439 | *\param rpcTempCU |
---|
440 | *\param uiDepth |
---|
441 | *\returns Void |
---|
442 | * |
---|
443 | *- for loop of QP value to compress the current CU with all possible QP |
---|
444 | */ |
---|
445 | #if AMP_ENC_SPEEDUP |
---|
446 | Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth, PartSize eParentPartSize ) |
---|
447 | #else |
---|
448 | Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ) |
---|
449 | #endif |
---|
450 | { |
---|
451 | TComPic* pcPic = rpcBestCU->getPic(); |
---|
452 | |
---|
453 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
454 | TComSPS *sps = pcPic->getSlice(0)->getSPS(); |
---|
455 | TComPic *pcTexture = rpcBestCU->getSlice()->getTexturePic(); |
---|
456 | |
---|
457 | Bool depthMapDetect = (pcTexture != NULL); |
---|
458 | Bool bIntraSliceDetect = (rpcBestCU->getSlice()->getSliceType() == I_SLICE); |
---|
459 | |
---|
460 | Bool bTry2NxN = true; |
---|
461 | Bool bTryNx2N = true; |
---|
462 | #endif |
---|
463 | |
---|
464 | // get Original YUV data from picture |
---|
465 | m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); |
---|
466 | |
---|
467 | // variables for fast encoder decision |
---|
468 | Bool bEarlySkip = false; |
---|
469 | Bool bTrySplit = true; |
---|
470 | Double fRD_Skip = MAX_DOUBLE; |
---|
471 | |
---|
472 | // variable for Early CU determination |
---|
473 | Bool bSubBranch = true; |
---|
474 | |
---|
475 | // variable for Cbf fast mode PU decision |
---|
476 | Bool doNotBlockPu = true; |
---|
477 | |
---|
478 | Bool bTrySplitDQP = true; |
---|
479 | |
---|
480 | static Double afCost [ MAX_CU_DEPTH ]; |
---|
481 | static Int aiNum [ MAX_CU_DEPTH ]; |
---|
482 | |
---|
483 | if ( rpcBestCU->getAddr() == 0 ) |
---|
484 | { |
---|
485 | ::memset( afCost, 0, sizeof( afCost ) ); |
---|
486 | ::memset( aiNum, 0, sizeof( aiNum ) ); |
---|
487 | } |
---|
488 | |
---|
489 | Bool bBoundary = false; |
---|
490 | UInt uiLPelX = rpcBestCU->getCUPelX(); |
---|
491 | UInt uiRPelX = uiLPelX + rpcBestCU->getWidth(0) - 1; |
---|
492 | UInt uiTPelY = rpcBestCU->getCUPelY(); |
---|
493 | UInt uiBPelY = uiTPelY + rpcBestCU->getHeight(0) - 1; |
---|
494 | |
---|
495 | #if LGE_ILLUCOMP_B0045 |
---|
496 | Bool bICEnabled = (!rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewId()); |
---|
497 | |
---|
498 | bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC(); |
---|
499 | #endif |
---|
500 | |
---|
501 | #if HHI_INTERVIEW_SKIP |
---|
502 | Bool bFullyRenderedSec = true ; |
---|
503 | if( m_pcEncCfg->getInterViewSkip() ) |
---|
504 | { |
---|
505 | Pel* pUsedSamples ; |
---|
506 | UInt uiStride ; |
---|
507 | pUsedSamples = pcPic->getUsedPelsMap()->getLumaAddr( rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); |
---|
508 | uiStride = pcPic->getUsedPelsMap()->getStride(); |
---|
509 | |
---|
510 | for ( Int y=0; y<m_ppcOrigYuv[uiDepth]->getHeight(); y++) |
---|
511 | { |
---|
512 | for ( Int x=0; x<m_ppcOrigYuv[uiDepth]->getWidth(); x++) |
---|
513 | { |
---|
514 | if( pUsedSamples[x] !=0 ) |
---|
515 | { |
---|
516 | bFullyRenderedSec = false ; |
---|
517 | break ; |
---|
518 | } |
---|
519 | } |
---|
520 | if ( !bFullyRenderedSec ) |
---|
521 | { |
---|
522 | break; |
---|
523 | } |
---|
524 | pUsedSamples += uiStride ; |
---|
525 | } |
---|
526 | } |
---|
527 | else |
---|
528 | { |
---|
529 | bFullyRenderedSec = false ; |
---|
530 | } |
---|
531 | |
---|
532 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
533 | if( bFullyRenderedSec ) |
---|
534 | { |
---|
535 | m_pcRdCost->setLambdaScale( m_pcEncCfg->getInterViewSkipLambdaScale() ); |
---|
536 | } |
---|
537 | else |
---|
538 | { |
---|
539 | m_pcRdCost->setLambdaScale( 1 ); |
---|
540 | } |
---|
541 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
542 | #endif |
---|
543 | |
---|
544 | #endif |
---|
545 | Int iBaseQP = xComputeQP( rpcBestCU, uiDepth ); |
---|
546 | Int iMinQP; |
---|
547 | Int iMaxQP; |
---|
548 | #if LOSSLESS_CODING |
---|
549 | Bool isAddLowestQP = false; |
---|
550 | #if H0736_AVC_STYLE_QP_RANGE |
---|
551 | Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
552 | #else |
---|
553 | Int lowestQP = 0; |
---|
554 | #endif |
---|
555 | #endif |
---|
556 | |
---|
557 | if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
558 | { |
---|
559 | Int idQP = m_pcEncCfg->getMaxDeltaQP(); |
---|
560 | #if H0736_AVC_STYLE_QP_RANGE |
---|
561 | iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); |
---|
562 | iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); |
---|
563 | #if LOSSLESS_CODING |
---|
564 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
565 | { |
---|
566 | isAddLowestQP = true; |
---|
567 | iMinQP = iMinQP - 1; |
---|
568 | |
---|
569 | } |
---|
570 | #endif |
---|
571 | #else |
---|
572 | iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP ); |
---|
573 | iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP ); |
---|
574 | #if LOSSLESS_CODING |
---|
575 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
576 | { |
---|
577 | isAddLowestQP = true; |
---|
578 | iMinQP = iMinQP - 1; |
---|
579 | } |
---|
580 | #endif |
---|
581 | #endif |
---|
582 | } |
---|
583 | else |
---|
584 | { |
---|
585 | iMinQP = rpcTempCU->getQP(0); |
---|
586 | iMaxQP = rpcTempCU->getQP(0); |
---|
587 | } |
---|
588 | |
---|
589 | // If slice start or slice end is within this cu... |
---|
590 | TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); |
---|
591 | Bool bSliceStart = pcSlice->getEntropySliceCurStartCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getEntropySliceCurStartCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart(); |
---|
592 | Bool bSliceEnd = (pcSlice->getEntropySliceCurEndCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getEntropySliceCurEndCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart()); |
---|
593 | Bool bInsidePicture = ( uiRPelX < rpcBestCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < rpcBestCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
594 | // We need to split, so don't try these modes. |
---|
595 | if(!bSliceEnd && !bSliceStart && bInsidePicture ) |
---|
596 | { |
---|
597 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
598 | { |
---|
599 | #if LOSSLESS_CODING |
---|
600 | if (isAddLowestQP && (iQP == iMinQP)) |
---|
601 | { |
---|
602 | iQP = lowestQP; |
---|
603 | } |
---|
604 | #endif |
---|
605 | // variables for fast encoder decision |
---|
606 | bEarlySkip = false; |
---|
607 | bTrySplit = true; |
---|
608 | fRD_Skip = MAX_DOUBLE; |
---|
609 | |
---|
610 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
611 | |
---|
612 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
613 | //logic for setting bTrySplit using the partition information that is stored of the texture colocated CU |
---|
614 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) |
---|
615 | { |
---|
616 | TComDataCU* pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() ); //Corresponding texture LCU |
---|
617 | UInt uiCUIdx = rpcBestCU->getZorderIdxInCU(); |
---|
618 | assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); //Depth cannot be more partitionned than the texture. |
---|
619 | if (pcTextureCU->getDepth(uiCUIdx) > uiDepth || pcTextureCU->getPartitionSize(uiCUIdx) == SIZE_NxN) //Texture was split. |
---|
620 | { |
---|
621 | bTrySplit = true; |
---|
622 | bTryNx2N = true; |
---|
623 | bTry2NxN = true; |
---|
624 | } |
---|
625 | else |
---|
626 | { |
---|
627 | bTrySplit = false; |
---|
628 | bTryNx2N = false; |
---|
629 | bTry2NxN = false; |
---|
630 | } |
---|
631 | } |
---|
632 | #endif |
---|
633 | |
---|
634 | // do inter modes, SKIP and 2Nx2N |
---|
635 | if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
636 | { |
---|
637 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
638 | #if MTK_MDIVRP_C0138 |
---|
639 | Bool bResPredAvailable = false; |
---|
640 | UInt uiResPrdId = 0; |
---|
641 | #else |
---|
642 | // check availability of residual prediction |
---|
643 | Bool bResPredAvailable = false; |
---|
644 | Bool bResPredAllowed = (!rpcBestCU->getSlice()->getSPS()->isDepth () ); |
---|
645 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getViewId () ); |
---|
646 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
647 | if( bResPredAllowed ) |
---|
648 | { |
---|
649 | bResPredAvailable = rpcBestCU->getResidualSamples( 0, |
---|
650 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
651 | true , |
---|
652 | #endif |
---|
653 | m_ppcResPredTmp[uiDepth] ); |
---|
654 | } |
---|
655 | |
---|
656 | for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ ) |
---|
657 | #endif |
---|
658 | { |
---|
659 | Bool bResPredFlag = ( uiResPrdId > 0 ); |
---|
660 | #if LGE_ILLUCOMP_B0045 |
---|
661 | for(UInt uiICId = 0; uiICId < (bICEnabled ? 2 : 1); uiICId++) |
---|
662 | { |
---|
663 | Bool bICFlag = (uiICId ? true : false); |
---|
664 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); |
---|
665 | #endif |
---|
666 | #endif |
---|
667 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
668 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
669 | #endif |
---|
670 | // SKIP |
---|
671 | #if HHI_INTERVIEW_SKIP |
---|
672 | xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, bFullyRenderedSec ); |
---|
673 | #else |
---|
674 | xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU ); |
---|
675 | #endif |
---|
676 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
677 | |
---|
678 | // fast encoder decision for early skip |
---|
679 | if ( m_pcEncCfg->getUseFastEnc() ) |
---|
680 | { |
---|
681 | Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; |
---|
682 | if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] ) |
---|
683 | { |
---|
684 | bEarlySkip = true; |
---|
685 | bTrySplit = false; |
---|
686 | } |
---|
687 | } |
---|
688 | #if LGE_ILLUCOMP_B0045_ENCSIMP |
---|
689 | if(bICFlag && rpcBestCU->getMergeFlag(0) && !rpcBestCU->getICFlag(0)) |
---|
690 | { |
---|
691 | bICEnabled = false; |
---|
692 | break; |
---|
693 | } |
---|
694 | #endif |
---|
695 | // 2Nx2N, NxN |
---|
696 | if ( !bEarlySkip ) |
---|
697 | { |
---|
698 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
699 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
700 | #endif |
---|
701 | #if HHI_INTERVIEW_SKIP |
---|
702 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFullyRenderedSec ); |
---|
703 | |
---|
704 | #else |
---|
705 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
706 | #endif |
---|
707 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
708 | if(m_pcEncCfg->getUseCbfFastMode()) |
---|
709 | { |
---|
710 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
711 | } |
---|
712 | } |
---|
713 | #if LGE_ILLUCOMP_B0045 |
---|
714 | } |
---|
715 | #endif |
---|
716 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
717 | } // uiResPrdId |
---|
718 | #endif |
---|
719 | } // != I_SLICE |
---|
720 | |
---|
721 | #if LGE_ILLUCOMP_B0045_ENCSIMP |
---|
722 | bICEnabled = rpcBestCU->getICFlag(0); |
---|
723 | #endif |
---|
724 | |
---|
725 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
726 | if(depthMapDetect && !bIntraSliceDetect && sps->getUseQTLPC()) |
---|
727 | { |
---|
728 | bTrySplitDQP = bTrySplit; |
---|
729 | } |
---|
730 | else |
---|
731 | { |
---|
732 | #endif |
---|
733 | if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
734 | { |
---|
735 | if(iQP == iBaseQP) |
---|
736 | { |
---|
737 | bTrySplitDQP = bTrySplit; |
---|
738 | } |
---|
739 | } |
---|
740 | else |
---|
741 | { |
---|
742 | bTrySplitDQP = bTrySplit; |
---|
743 | } |
---|
744 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
745 | } |
---|
746 | #endif |
---|
747 | |
---|
748 | #if LOSSLESS_CODING |
---|
749 | if (isAddLowestQP && (iQP == lowestQP)) |
---|
750 | { |
---|
751 | iQP = iMinQP; |
---|
752 | } |
---|
753 | #endif |
---|
754 | } // end for iMinQP to iMaxQP |
---|
755 | |
---|
756 | |
---|
757 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
758 | { |
---|
759 | #if LOSSLESS_CODING |
---|
760 | if (isAddLowestQP && (iQP == iMinQP)) |
---|
761 | { |
---|
762 | iQP = lowestQP; |
---|
763 | } |
---|
764 | #endif |
---|
765 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
766 | |
---|
767 | // do inter modes, NxN, 2NxN, and Nx2N |
---|
768 | if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
769 | { |
---|
770 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
771 | #if MTK_MDIVRP_C0138 |
---|
772 | Bool bResPredAvailable = false; |
---|
773 | UInt uiResPrdId = 0; |
---|
774 | #else |
---|
775 | // check availability of residual prediction |
---|
776 | Bool bResPredAvailable = false; |
---|
777 | Bool bResPredAllowed = (!rpcBestCU->getSlice()->getSPS()->isDepth () ); |
---|
778 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getViewId () ); |
---|
779 | bResPredAllowed = bResPredAllowed && ( rpcBestCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
780 | if( bResPredAllowed ) |
---|
781 | { |
---|
782 | bResPredAvailable = rpcBestCU->getResidualSamples( 0, |
---|
783 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
784 | true, |
---|
785 | #endif |
---|
786 | m_ppcResPredTmp[uiDepth] ); |
---|
787 | } |
---|
788 | |
---|
789 | for( UInt uiResPrdId = 0; uiResPrdId < ( bResPredAvailable ? 2 : 1 ); uiResPrdId++ ) |
---|
790 | #endif |
---|
791 | { |
---|
792 | Bool bResPredFlag = ( uiResPrdId > 0 ); |
---|
793 | #if LGE_ILLUCOMP_B0045 |
---|
794 | for(UInt uiICId = 0; uiICId < (bICEnabled ? 2 : 1); uiICId++) |
---|
795 | { |
---|
796 | Bool bICFlag = (uiICId ? true : false); |
---|
797 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); |
---|
798 | #endif |
---|
799 | #endif |
---|
800 | // 2Nx2N, NxN |
---|
801 | if ( !bEarlySkip ) |
---|
802 | { |
---|
803 | |
---|
804 | if(!( rpcBestCU->getSlice()->getSPS()->getDisInter4x4() && (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) |
---|
805 | { |
---|
806 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) |
---|
807 | { |
---|
808 | #if OL_QTLIMIT_PREDCODING_B0068 //try InterNxN |
---|
809 | if(bTrySplit) |
---|
810 | { |
---|
811 | #endif |
---|
812 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
813 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
814 | #endif |
---|
815 | #if HHI_INTERVIEW_SKIP |
---|
816 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFullyRenderedSec ); |
---|
817 | #else |
---|
818 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
819 | #endif |
---|
820 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
821 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
822 | } |
---|
823 | #endif |
---|
824 | } |
---|
825 | } |
---|
826 | } |
---|
827 | |
---|
828 | { // 2NxN, Nx2N |
---|
829 | #if OL_QTLIMIT_PREDCODING_B0068 //try Nx2N |
---|
830 | if(bTryNx2N) |
---|
831 | { |
---|
832 | #endif |
---|
833 | if(doNotBlockPu) |
---|
834 | { |
---|
835 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
836 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
837 | #endif |
---|
838 | #if HHI_INTERVIEW_SKIP |
---|
839 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFullyRenderedSec ); |
---|
840 | #else |
---|
841 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N ); |
---|
842 | #endif |
---|
843 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
844 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_Nx2N ) |
---|
845 | { |
---|
846 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
847 | } |
---|
848 | } |
---|
849 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
850 | } |
---|
851 | #endif |
---|
852 | |
---|
853 | #if OL_QTLIMIT_PREDCODING_B0068 //try 2NxN |
---|
854 | if(bTry2NxN) |
---|
855 | { |
---|
856 | #endif |
---|
857 | if(doNotBlockPu) |
---|
858 | { |
---|
859 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
860 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
861 | #endif |
---|
862 | #if HHI_INTERVIEW_SKIP |
---|
863 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxN, bFullyRenderedSec ); |
---|
864 | #else |
---|
865 | xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN ); |
---|
866 | #endif |
---|
867 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
868 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxN) |
---|
869 | { |
---|
870 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
871 | } |
---|
872 | } |
---|
873 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
874 | } |
---|
875 | #endif |
---|
876 | } |
---|
877 | |
---|
878 | #if 1 |
---|
879 | //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N) |
---|
880 | if( pcPic->getSlice(0)->getSPS()->getAMPAcc(uiDepth) ) |
---|
881 | { |
---|
882 | #if AMP_ENC_SPEEDUP |
---|
883 | Bool bTestAMP_Hor = false, bTestAMP_Ver = false; |
---|
884 | |
---|
885 | #if AMP_MRG |
---|
886 | Bool bTestMergeAMP_Hor = false, bTestMergeAMP_Ver = false; |
---|
887 | |
---|
888 | deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver, bTestMergeAMP_Hor, bTestMergeAMP_Ver); |
---|
889 | #else |
---|
890 | deriveTestModeAMP (rpcBestCU, eParentPartSize, bTestAMP_Hor, bTestAMP_Ver); |
---|
891 | #endif |
---|
892 | |
---|
893 | //! Do horizontal AMP |
---|
894 | if ( bTestAMP_Hor ) |
---|
895 | { |
---|
896 | #if OL_QTLIMIT_PREDCODING_B0068 //try 2NxnU & 2NxnD |
---|
897 | if(bTry2NxN) |
---|
898 | { |
---|
899 | #endif |
---|
900 | if(doNotBlockPu) |
---|
901 | { |
---|
902 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
903 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
904 | #endif |
---|
905 | #if HHI_INTERVIEW_SKIP |
---|
906 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec ); |
---|
907 | #else |
---|
908 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); |
---|
909 | #endif |
---|
910 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
911 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
912 | { |
---|
913 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
914 | } |
---|
915 | } |
---|
916 | if(doNotBlockPu) |
---|
917 | { |
---|
918 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
919 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
920 | #endif |
---|
921 | #if HHI_INTERVIEW_SKIP |
---|
922 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec ); |
---|
923 | #else |
---|
924 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); |
---|
925 | #endif |
---|
926 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
927 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
928 | { |
---|
929 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
930 | } |
---|
931 | } |
---|
932 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
933 | } |
---|
934 | #endif |
---|
935 | } |
---|
936 | #if AMP_MRG |
---|
937 | else if ( bTestMergeAMP_Hor ) |
---|
938 | { |
---|
939 | #if OL_QTLIMIT_PREDCODING_B0068 //try 2NxnU & 2NxnD Merge |
---|
940 | if(bTry2NxN) |
---|
941 | { |
---|
942 | #endif |
---|
943 | if(doNotBlockPu) |
---|
944 | { |
---|
945 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
946 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
947 | #endif |
---|
948 | #if HHI_INTERVIEW_SKIP |
---|
949 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec, true ); |
---|
950 | #else |
---|
951 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, true ); |
---|
952 | #endif |
---|
953 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
954 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnU ) |
---|
955 | { |
---|
956 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
957 | } |
---|
958 | } |
---|
959 | if(doNotBlockPu) |
---|
960 | { |
---|
961 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
962 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
963 | #endif |
---|
964 | #if HHI_INTERVIEW_SKIP |
---|
965 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec, true ); |
---|
966 | #else |
---|
967 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, true ); |
---|
968 | #endif |
---|
969 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
970 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_2NxnD ) |
---|
971 | { |
---|
972 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
973 | } |
---|
974 | } |
---|
975 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
976 | } |
---|
977 | #endif |
---|
978 | } |
---|
979 | #endif |
---|
980 | |
---|
981 | //! Do horizontal AMP |
---|
982 | if ( bTestAMP_Ver ) |
---|
983 | { |
---|
984 | #if OL_QTLIMIT_PREDCODING_B0068 //try nLx2N & nRx2N |
---|
985 | if(bTryNx2N) |
---|
986 | { |
---|
987 | #endif |
---|
988 | if(doNotBlockPu) |
---|
989 | { |
---|
990 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
991 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
992 | #endif |
---|
993 | #if HHI_INTERVIEW_SKIP |
---|
994 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec ); |
---|
995 | #else |
---|
996 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); |
---|
997 | #endif |
---|
998 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
999 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
1000 | { |
---|
1001 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
1002 | } |
---|
1003 | } |
---|
1004 | if(doNotBlockPu) |
---|
1005 | { |
---|
1006 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1007 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
1008 | #endif |
---|
1009 | #if HHI_INTERVIEW_SKIP |
---|
1010 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec ); |
---|
1011 | #else |
---|
1012 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); |
---|
1013 | #endif |
---|
1014 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1015 | } |
---|
1016 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
1017 | } |
---|
1018 | #endif |
---|
1019 | } |
---|
1020 | #if AMP_MRG |
---|
1021 | else if ( bTestMergeAMP_Ver ) |
---|
1022 | { |
---|
1023 | #if OL_QTLIMIT_PREDCODING_B0068 //try nLx2N & nRx2N (Merge) |
---|
1024 | if(bTryNx2N) |
---|
1025 | { |
---|
1026 | #endif |
---|
1027 | if(doNotBlockPu) |
---|
1028 | { |
---|
1029 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1030 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
1031 | #endif |
---|
1032 | #if HHI_INTERVIEW_SKIP |
---|
1033 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec, true ); |
---|
1034 | #else |
---|
1035 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, true ); |
---|
1036 | #endif |
---|
1037 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1038 | if(m_pcEncCfg->getUseCbfFastMode() && rpcBestCU->getPartitionSize(0) == SIZE_nLx2N ) |
---|
1039 | { |
---|
1040 | doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; |
---|
1041 | } |
---|
1042 | } |
---|
1043 | if(doNotBlockPu) |
---|
1044 | { |
---|
1045 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1046 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
1047 | #endif |
---|
1048 | #if HHI_INTERVIEW_SKIP |
---|
1049 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec, true ); |
---|
1050 | #else |
---|
1051 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, true ); |
---|
1052 | #endif |
---|
1053 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1054 | } |
---|
1055 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
1056 | } |
---|
1057 | #endif |
---|
1058 | } |
---|
1059 | #endif |
---|
1060 | |
---|
1061 | #else |
---|
1062 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1063 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
1064 | #endif |
---|
1065 | #if HHI_INTERVIEW_SKIP |
---|
1066 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFullyRenderedSec ); |
---|
1067 | #else |
---|
1068 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU ); |
---|
1069 | #endif |
---|
1070 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1071 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1072 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
1073 | #endif |
---|
1074 | #if HHI_INTERVIEW_SKIP |
---|
1075 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFullyRenderedSec ); |
---|
1076 | #else |
---|
1077 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD ); |
---|
1078 | #endif |
---|
1079 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1080 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1081 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
1082 | #endif |
---|
1083 | #if HHI_INTERVIEW_SKIP |
---|
1084 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFullyRenderedSec ); |
---|
1085 | #else |
---|
1086 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N ); |
---|
1087 | #endif |
---|
1088 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1089 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1090 | rpcTempCU->setResPredIndicator( bResPredAvailable, bResPredFlag ); |
---|
1091 | #endif |
---|
1092 | #if HHI_INTERVIEW_SKIP |
---|
1093 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFullyRenderedSec ); |
---|
1094 | #else |
---|
1095 | xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N ); |
---|
1096 | #endif |
---|
1097 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1098 | |
---|
1099 | #endif |
---|
1100 | } //! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N) |
---|
1101 | #endif |
---|
1102 | #if LGE_ILLUCOMP_B0045 |
---|
1103 | } |
---|
1104 | #endif |
---|
1105 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1106 | } // uiResPrdId |
---|
1107 | #endif |
---|
1108 | } // != I_SLICE |
---|
1109 | |
---|
1110 | // initialize PCM flag |
---|
1111 | rpcTempCU->setIPCMFlag( 0, false); |
---|
1112 | rpcTempCU->setIPCMFlagSubParts ( false, 0, uiDepth); //SUB_LCU_DQP |
---|
1113 | |
---|
1114 | // do normal intra modes |
---|
1115 | if ( !bEarlySkip ) |
---|
1116 | { |
---|
1117 | // speedup for inter frames |
---|
1118 | #if HHI_INTERVIEW_SKIP |
---|
1119 | if( ( rpcBestCU->getSlice()->getSliceType() == I_SLICE || |
---|
1120 | rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || |
---|
1121 | rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || |
---|
1122 | rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) && !bFullyRenderedSec ) // avoid very complex intra if it is unlikely |
---|
1123 | #else |
---|
1124 | if( rpcBestCU->getSlice()->getSliceType() == I_SLICE || |
---|
1125 | rpcBestCU->getCbf( 0, TEXT_LUMA ) != 0 || |
---|
1126 | rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0 || |
---|
1127 | rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0 ) // avoid very complex intra if it is unlikely |
---|
1128 | #endif |
---|
1129 | { |
---|
1130 | #if LGE_ILLUCOMP_B0045 |
---|
1131 | rpcTempCU->setICFlagSubParts(false, 0, 0, uiDepth); |
---|
1132 | #endif |
---|
1133 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); |
---|
1134 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1135 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
1136 | { |
---|
1137 | #if OL_QTLIMIT_PREDCODING_B0068 //Try IntraNxN |
---|
1138 | if(bTrySplit) |
---|
1139 | { |
---|
1140 | #endif |
---|
1141 | if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) ) |
---|
1142 | { |
---|
1143 | #if LGE_ILLUCOMP_B0045 |
---|
1144 | rpcTempCU->setICFlagSubParts(false, 0, 0, uiDepth); |
---|
1145 | #endif |
---|
1146 | xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN ); |
---|
1147 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1148 | } |
---|
1149 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
1150 | } |
---|
1151 | #endif |
---|
1152 | } |
---|
1153 | } |
---|
1154 | } |
---|
1155 | |
---|
1156 | // test PCM |
---|
1157 | if(pcPic->getSlice(0)->getSPS()->getUsePCM() |
---|
1158 | && rpcTempCU->getWidth(0) <= (1<<pcPic->getSlice(0)->getSPS()->getPCMLog2MaxSize()) |
---|
1159 | && rpcTempCU->getWidth(0) >= (1<<pcPic->getSlice(0)->getSPS()->getPCMLog2MinSize()) ) |
---|
1160 | { |
---|
1161 | UInt uiRawBits = (g_uiBitDepth * rpcBestCU->getWidth(0) * rpcBestCU->getHeight(0) * 3 / 2); |
---|
1162 | UInt uiBestBits = rpcBestCU->getTotalBits(); |
---|
1163 | #if HHI_VSO |
---|
1164 | Double dRDCostTemp = m_pcRdCost->getUseVSO() ? m_pcRdCost->calcRdCostVSO(uiRawBits, 0) : m_pcRdCost->calcRdCost(uiRawBits, 0); |
---|
1165 | if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > dRDCostTemp )) |
---|
1166 | #else |
---|
1167 | if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > m_pcRdCost->calcRdCost(uiRawBits, 0))) |
---|
1168 | #endif |
---|
1169 | { |
---|
1170 | #if LGE_ILLUCOMP_B0045 |
---|
1171 | rpcTempCU->setICFlagSubParts(false, 0, 0, uiDepth); |
---|
1172 | #endif |
---|
1173 | xCheckIntraPCM (rpcBestCU, rpcTempCU); |
---|
1174 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1175 | } |
---|
1176 | } |
---|
1177 | #if HHI_MPI |
---|
1178 | if( rpcBestCU->getSlice()->getSPS()->getUseMVI() && rpcBestCU->getSlice()->getSliceType() != I_SLICE ) |
---|
1179 | { |
---|
1180 | xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, false, false ); |
---|
1181 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1182 | xCheckRDCostMvInheritance( rpcBestCU, rpcTempCU, uiDepth, true, false ); |
---|
1183 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1184 | } |
---|
1185 | #endif |
---|
1186 | #if LOSSLESS_CODING |
---|
1187 | if (isAddLowestQP && (iQP == lowestQP)) |
---|
1188 | { |
---|
1189 | iQP = iMinQP; |
---|
1190 | } |
---|
1191 | #endif |
---|
1192 | } |
---|
1193 | |
---|
1194 | m_pcEntropyCoder->resetBits(); |
---|
1195 | m_pcEntropyCoder->encodeSplitFlag( rpcBestCU, 0, uiDepth, true ); |
---|
1196 | rpcBestCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits |
---|
1197 | if(m_pcEncCfg->getUseSBACRD()) |
---|
1198 | { |
---|
1199 | rpcBestCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
1200 | } |
---|
1201 | |
---|
1202 | #if HHI_VSO |
---|
1203 | if ( m_pcRdCost->getUseVSO() ) |
---|
1204 | { |
---|
1205 | rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); |
---|
1206 | } |
---|
1207 | else |
---|
1208 | #endif |
---|
1209 | { |
---|
1210 | rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); |
---|
1211 | } |
---|
1212 | |
---|
1213 | // accumulate statistics for early skip |
---|
1214 | if ( m_pcEncCfg->getUseFastEnc() ) |
---|
1215 | { |
---|
1216 | if ( rpcBestCU->isSkipped(0) ) |
---|
1217 | { |
---|
1218 | Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; |
---|
1219 | afCost[ iIdx ] += rpcBestCU->getTotalCost(); |
---|
1220 | aiNum [ iIdx ] ++; |
---|
1221 | } |
---|
1222 | } |
---|
1223 | |
---|
1224 | // Early CU determination |
---|
1225 | if( m_pcEncCfg->getUseEarlyCU() && ((*rpcBestCU->getPredictionMode()) == 0) ) |
---|
1226 | { |
---|
1227 | bSubBranch = false; |
---|
1228 | } |
---|
1229 | else |
---|
1230 | { |
---|
1231 | bSubBranch = true; |
---|
1232 | } |
---|
1233 | #if HHI_INTERVIEW_SKIP |
---|
1234 | rpcBestCU->setRenderableSubParts(bFullyRenderedSec,0,rpcBestCU->getDepth( 0 )) ; |
---|
1235 | #endif |
---|
1236 | } |
---|
1237 | else if(!(bSliceEnd && bInsidePicture)) |
---|
1238 | { |
---|
1239 | bBoundary = true; |
---|
1240 | } |
---|
1241 | |
---|
1242 | #if LOSSLESS_CODING |
---|
1243 | // copy orginal YUV samples to PCM buffer |
---|
1244 | if( rpcBestCU->isLosslessCoded(0) && (rpcBestCU->getIPCMFlag(0) == false)) |
---|
1245 | { |
---|
1246 | xFillPCMBuffer(rpcBestCU, m_ppcOrigYuv[uiDepth]); |
---|
1247 | } |
---|
1248 | #endif |
---|
1249 | if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
1250 | { |
---|
1251 | Int idQP = m_pcEncCfg->getMaxDeltaQP(); |
---|
1252 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1253 | iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); |
---|
1254 | iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); |
---|
1255 | #if LOSSLESS_CODING |
---|
1256 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
1257 | { |
---|
1258 | isAddLowestQP = true; |
---|
1259 | iMinQP = iMinQP - 1; |
---|
1260 | } |
---|
1261 | #endif |
---|
1262 | #else |
---|
1263 | iMinQP = Clip3( MIN_QP, MAX_QP, iBaseQP-idQP ); |
---|
1264 | iMaxQP = Clip3( MIN_QP, MAX_QP, iBaseQP+idQP ); |
---|
1265 | #if LOSSLESS_CODING |
---|
1266 | if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) |
---|
1267 | { |
---|
1268 | isAddLowestQP = true; |
---|
1269 | iMinQP = iMinQP - 1; |
---|
1270 | } |
---|
1271 | #endif |
---|
1272 | #endif |
---|
1273 | } |
---|
1274 | else if( (g_uiMaxCUWidth>>uiDepth) > rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
1275 | { |
---|
1276 | iMinQP = iBaseQP; |
---|
1277 | iMaxQP = iBaseQP; |
---|
1278 | } |
---|
1279 | else |
---|
1280 | { |
---|
1281 | Int iStartQP; |
---|
1282 | if( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(rpcTempCU->getZorderIdxInCU()) == pcSlice->getEntropySliceCurStartCUAddr()) |
---|
1283 | { |
---|
1284 | iStartQP = rpcTempCU->getQP(0); |
---|
1285 | } |
---|
1286 | else |
---|
1287 | { |
---|
1288 | UInt uiCurSliceStartPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
1289 | iStartQP = rpcTempCU->getQP(uiCurSliceStartPartIdx); |
---|
1290 | } |
---|
1291 | iMinQP = iStartQP; |
---|
1292 | iMaxQP = iStartQP; |
---|
1293 | } |
---|
1294 | |
---|
1295 | for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++) |
---|
1296 | { |
---|
1297 | #if LOSSLESS_CODING |
---|
1298 | if (isAddLowestQP && (iQP == iMinQP)) |
---|
1299 | { |
---|
1300 | iQP = lowestQP; |
---|
1301 | } |
---|
1302 | #endif |
---|
1303 | rpcTempCU->initEstData( uiDepth, iQP ); |
---|
1304 | |
---|
1305 | // further split |
---|
1306 | if( bSubBranch && bTrySplitDQP && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
1307 | { |
---|
1308 | #if HHI_VSO |
---|
1309 | // reset Model |
---|
1310 | if( m_pcRdCost->getUseRenModel() ) |
---|
1311 | { |
---|
1312 | UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth ( ); |
---|
1313 | UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight( ); |
---|
1314 | Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr( 0 ); |
---|
1315 | UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride(); |
---|
1316 | m_pcRdCost->setRenModelData( m_ppcBestCU[uiDepth], 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
1317 | } |
---|
1318 | #endif |
---|
1319 | UChar uhNextDepth = uiDepth+1; |
---|
1320 | TComDataCU* pcSubBestPartCU = m_ppcBestCU[uhNextDepth]; |
---|
1321 | TComDataCU* pcSubTempPartCU = m_ppcTempCU[uhNextDepth]; |
---|
1322 | |
---|
1323 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
1324 | { |
---|
1325 | pcSubBestPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
1326 | pcSubTempPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
1327 | |
---|
1328 | Bool bInSlice = pcSubBestPartCU->getSCUAddr()+pcSubBestPartCU->getTotalNumPart()>pcSlice->getEntropySliceCurStartCUAddr()&&pcSubBestPartCU->getSCUAddr()<pcSlice->getEntropySliceCurEndCUAddr(); |
---|
1329 | if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
1330 | { |
---|
1331 | if( m_bUseSBACRD ) |
---|
1332 | { |
---|
1333 | if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer |
---|
1334 | { |
---|
1335 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); |
---|
1336 | } |
---|
1337 | else |
---|
1338 | { |
---|
1339 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); |
---|
1340 | } |
---|
1341 | } |
---|
1342 | |
---|
1343 | #if AMP_ENC_SPEEDUP |
---|
1344 | if ( rpcBestCU->isIntra(0) ) |
---|
1345 | { |
---|
1346 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, SIZE_NONE ); |
---|
1347 | } |
---|
1348 | else |
---|
1349 | { |
---|
1350 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, rpcBestCU->getPartitionSize(0) ); |
---|
1351 | } |
---|
1352 | #else |
---|
1353 | xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth ); |
---|
1354 | #endif |
---|
1355 | |
---|
1356 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); // Keep best part data to current temporary data. |
---|
1357 | xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth ); |
---|
1358 | |
---|
1359 | #if HHI_VSO |
---|
1360 | #endif |
---|
1361 | } |
---|
1362 | else if (bInSlice) |
---|
1363 | { |
---|
1364 | pcSubBestPartCU->copyToPic( uhNextDepth ); |
---|
1365 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); |
---|
1366 | } |
---|
1367 | } |
---|
1368 | |
---|
1369 | if( !bBoundary ) |
---|
1370 | { |
---|
1371 | m_pcEntropyCoder->resetBits(); |
---|
1372 | m_pcEntropyCoder->encodeSplitFlag( rpcTempCU, 0, uiDepth, true ); |
---|
1373 | |
---|
1374 | rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // split bits |
---|
1375 | if(m_pcEncCfg->getUseSBACRD()) |
---|
1376 | { |
---|
1377 | rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
1378 | } |
---|
1379 | } |
---|
1380 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
1381 | if( bFullyRenderedSec ) |
---|
1382 | { |
---|
1383 | m_pcRdCost->setLambdaScale( m_pcEncCfg->getInterViewSkipLambdaScale() ); |
---|
1384 | } |
---|
1385 | else |
---|
1386 | { |
---|
1387 | m_pcRdCost->setLambdaScale( 1 ); |
---|
1388 | } |
---|
1389 | #endif |
---|
1390 | |
---|
1391 | #if HHI_VSO |
---|
1392 | if ( m_pcRdCost->getUseVSO() ) |
---|
1393 | { |
---|
1394 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
1395 | } |
---|
1396 | else |
---|
1397 | #endif |
---|
1398 | { |
---|
1399 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
1400 | } |
---|
1401 | |
---|
1402 | if( (g_uiMaxCUWidth>>uiDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() && rpcTempCU->getSlice()->getPPS()->getUseDQP()) |
---|
1403 | { |
---|
1404 | Bool bHasRedisual = false; |
---|
1405 | for( UInt uiBlkIdx = 0; uiBlkIdx < rpcTempCU->getTotalNumPart(); uiBlkIdx ++) |
---|
1406 | { |
---|
1407 | if( ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(uiBlkIdx+rpcTempCU->getZorderIdxInCU()) == rpcTempCU->getSlice()->getEntropySliceCurStartCUAddr() ) && |
---|
1408 | ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) ) |
---|
1409 | { |
---|
1410 | bHasRedisual = true; |
---|
1411 | break; |
---|
1412 | } |
---|
1413 | } |
---|
1414 | |
---|
1415 | UInt uiTargetPartIdx; |
---|
1416 | if ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(rpcTempCU->getZorderIdxInCU()) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
1417 | { |
---|
1418 | uiTargetPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
1419 | } |
---|
1420 | else |
---|
1421 | { |
---|
1422 | uiTargetPartIdx = 0; |
---|
1423 | } |
---|
1424 | if ( bHasRedisual ) |
---|
1425 | { |
---|
1426 | #if !RDO_WITHOUT_DQP_BITS |
---|
1427 | m_pcEntropyCoder->resetBits(); |
---|
1428 | m_pcEntropyCoder->encodeQP( rpcTempCU, uiTargetPartIdx, false ); |
---|
1429 | rpcTempCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits |
---|
1430 | if(m_pcEncCfg->getUseSBACRD()) |
---|
1431 | { |
---|
1432 | rpcTempCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
1433 | } |
---|
1434 | #if HHI_VSO |
---|
1435 | if ( m_pcRdCost->getUseLambdaScaleVSO()) |
---|
1436 | { |
---|
1437 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
1438 | } |
---|
1439 | else |
---|
1440 | #endif |
---|
1441 | { |
---|
1442 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
1443 | } |
---|
1444 | #endif |
---|
1445 | } |
---|
1446 | else |
---|
1447 | { |
---|
1448 | #if LOSSLESS_CODING |
---|
1449 | if (((rpcTempCU->getQP(uiTargetPartIdx) != rpcTempCU->getRefQP(uiTargetPartIdx)) ) && (rpcTempCU->getSlice()->getSPS()->getUseLossless())) |
---|
1450 | { |
---|
1451 | rpcTempCU->getTotalCost() = MAX_DOUBLE; |
---|
1452 | } |
---|
1453 | #endif |
---|
1454 | rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx ), 0, uiDepth ); // set QP to default QP |
---|
1455 | } |
---|
1456 | } |
---|
1457 | |
---|
1458 | if( m_bUseSBACRD ) |
---|
1459 | { |
---|
1460 | m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
1461 | } |
---|
1462 | Bool bEntropyLimit=false; |
---|
1463 | Bool bSliceLimit=false; |
---|
1464 | bSliceLimit=rpcBestCU->getSlice()->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&(rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getSliceArgument()<<3); |
---|
1465 | if(rpcBestCU->getSlice()->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&m_pcEncCfg->getUseSBACRD()) |
---|
1466 | { |
---|
1467 | if(rpcBestCU->getTotalBins()>rpcBestCU->getSlice()->getEntropySliceArgument()) |
---|
1468 | { |
---|
1469 | bEntropyLimit=true; |
---|
1470 | } |
---|
1471 | } |
---|
1472 | else if(rpcBestCU->getSlice()->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE) |
---|
1473 | { |
---|
1474 | if(rpcBestCU->getTotalBits()>rpcBestCU->getSlice()->getEntropySliceArgument()) |
---|
1475 | { |
---|
1476 | bEntropyLimit=true; |
---|
1477 | } |
---|
1478 | } |
---|
1479 | if(rpcBestCU->getDepth(0)>=rpcBestCU->getSlice()->getPPS()->getSliceGranularity()) |
---|
1480 | { |
---|
1481 | bSliceLimit=false; |
---|
1482 | bEntropyLimit=false; |
---|
1483 | } |
---|
1484 | if(bSliceLimit||bEntropyLimit) |
---|
1485 | { |
---|
1486 | rpcBestCU->getTotalCost()=rpcTempCU->getTotalCost()+1; |
---|
1487 | } |
---|
1488 | xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth); // RD compare current larger prediction |
---|
1489 | } // with sub partitioned prediction. |
---|
1490 | #if LOSSLESS_CODING |
---|
1491 | if (isAddLowestQP && (iQP == lowestQP)) |
---|
1492 | { |
---|
1493 | iQP = iMinQP; |
---|
1494 | } |
---|
1495 | #endif |
---|
1496 | } // SPLIT- QP Loop |
---|
1497 | |
---|
1498 | #if HHI_VSO |
---|
1499 | if( m_pcRdCost->getUseRenModel() ) |
---|
1500 | { |
---|
1501 | UInt uiWidth = m_ppcRecoYuvBest[uiDepth]->getWidth ( ); |
---|
1502 | UInt uiHeight = m_ppcRecoYuvBest[uiDepth]->getHeight ( ); |
---|
1503 | Pel* piSrc = m_ppcRecoYuvBest[uiDepth]->getLumaAddr( 0 ); |
---|
1504 | UInt uiSrcStride = m_ppcRecoYuvBest[uiDepth]->getStride ( ); |
---|
1505 | m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
1506 | } |
---|
1507 | #endif |
---|
1508 | |
---|
1509 | rpcBestCU->copyToPic(uiDepth); // Copy Best data to Picture for next partition prediction. |
---|
1510 | |
---|
1511 | xCopyYuv2Pic( rpcBestCU->getPic(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU(), uiDepth, uiDepth, rpcBestCU, uiLPelX, uiTPelY ); // Copy Yuv data to picture Yuv |
---|
1512 | if( bBoundary ||(bSliceEnd && bInsidePicture)) |
---|
1513 | { |
---|
1514 | return; |
---|
1515 | } |
---|
1516 | |
---|
1517 | // Assert if Best prediction mode is NONE |
---|
1518 | // Selected mode's RD-cost must be not MAX_DOUBLE. |
---|
1519 | assert( rpcBestCU->getPartitionSize ( 0 ) != SIZE_NONE ); |
---|
1520 | assert( rpcBestCU->getPredictionMode( 0 ) != MODE_NONE ); |
---|
1521 | assert( rpcBestCU->getTotalCost ( ) != MAX_DOUBLE ); |
---|
1522 | } |
---|
1523 | |
---|
1524 | /** finish encoding a cu and handle end-of-slice conditions |
---|
1525 | * \param pcCU |
---|
1526 | * \param uiAbsPartIdx |
---|
1527 | * \param uiDepth |
---|
1528 | * \returns Void |
---|
1529 | */ |
---|
1530 | Void TEncCu::finishCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1531 | { |
---|
1532 | TComPic* pcPic = pcCU->getPic(); |
---|
1533 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
1534 | |
---|
1535 | //Calculate end address |
---|
1536 | UInt uiCUAddr = pcCU->getSCUAddr()+uiAbsPartIdx; |
---|
1537 | |
---|
1538 | UInt uiInternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getEntropySliceCurEndCUAddr()-1) % pcPic->getNumPartInCU(); |
---|
1539 | UInt uiExternalAddress = pcPic->getPicSym()->getPicSCUAddr(pcSlice->getEntropySliceCurEndCUAddr()-1) / pcPic->getNumPartInCU(); |
---|
1540 | UInt uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
1541 | UInt uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
1542 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
1543 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
1544 | while(uiPosX>=uiWidth||uiPosY>=uiHeight) |
---|
1545 | { |
---|
1546 | uiInternalAddress--; |
---|
1547 | uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
1548 | uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; |
---|
1549 | } |
---|
1550 | uiInternalAddress++; |
---|
1551 | if(uiInternalAddress==pcCU->getPic()->getNumPartInCU()) |
---|
1552 | { |
---|
1553 | uiInternalAddress = 0; |
---|
1554 | uiExternalAddress = pcPic->getPicSym()->getCUOrderMap(pcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1); |
---|
1555 | } |
---|
1556 | UInt uiRealEndAddress = pcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress); |
---|
1557 | |
---|
1558 | // Encode slice finish |
---|
1559 | Bool bTerminateSlice = false; |
---|
1560 | if (uiCUAddr+(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1)) == uiRealEndAddress) |
---|
1561 | { |
---|
1562 | bTerminateSlice = true; |
---|
1563 | } |
---|
1564 | UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity()); |
---|
1565 | uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1566 | uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1567 | Bool granularityBoundary=((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
1568 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight)); |
---|
1569 | |
---|
1570 | #if BURST_IPCM |
---|
1571 | if(granularityBoundary && (!(pcCU->getIPCMFlag(uiAbsPartIdx) && ( pcCU->getNumSucIPCM() > 1 )))) |
---|
1572 | #else |
---|
1573 | if(granularityBoundary) |
---|
1574 | #endif |
---|
1575 | { |
---|
1576 | // The 1-terminating bit is added to all streams, so don't add it here when it's 1. |
---|
1577 | if (!bTerminateSlice) |
---|
1578 | m_pcEntropyCoder->encodeTerminatingBit( bTerminateSlice ? 1 : 0 ); |
---|
1579 | } |
---|
1580 | |
---|
1581 | Int numberOfWrittenBits = 0; |
---|
1582 | if (m_pcBitCounter) |
---|
1583 | { |
---|
1584 | numberOfWrittenBits = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
1585 | } |
---|
1586 | |
---|
1587 | // Calculate slice end IF this CU puts us over slice bit size. |
---|
1588 | unsigned iGranularitySize = pcCU->getPic()->getNumPartInCU()>>(pcSlice->getPPS()->getSliceGranularity()<<1); |
---|
1589 | int iGranularityEnd = ((pcCU->getSCUAddr()+uiAbsPartIdx)/iGranularitySize)*iGranularitySize; |
---|
1590 | if(iGranularityEnd<=pcSlice->getEntropySliceCurStartCUAddr()) |
---|
1591 | { |
---|
1592 | iGranularityEnd+=max(iGranularitySize,(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1))); |
---|
1593 | } |
---|
1594 | // Set slice end parameter |
---|
1595 | if(pcSlice->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+numberOfWrittenBits>pcSlice->getSliceArgument()<<3) |
---|
1596 | { |
---|
1597 | pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); |
---|
1598 | pcSlice->setSliceCurEndCUAddr(iGranularityEnd); |
---|
1599 | return; |
---|
1600 | } |
---|
1601 | // Set entropy slice end parameter |
---|
1602 | if(m_pcEncCfg->getUseSBACRD()) |
---|
1603 | { |
---|
1604 | TEncBinCABAC *pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); |
---|
1605 | UInt uiBinsCoded = pppcRDSbacCoder->getBinsCoded(); |
---|
1606 | if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+uiBinsCoded>pcSlice->getEntropySliceArgument()) |
---|
1607 | { |
---|
1608 | pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); |
---|
1609 | return; |
---|
1610 | } |
---|
1611 | } |
---|
1612 | else |
---|
1613 | { |
---|
1614 | if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+numberOfWrittenBits>pcSlice->getEntropySliceArgument()) |
---|
1615 | { |
---|
1616 | pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); |
---|
1617 | return; |
---|
1618 | } |
---|
1619 | } |
---|
1620 | if(granularityBoundary) |
---|
1621 | { |
---|
1622 | pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + numberOfWrittenBits) ); |
---|
1623 | if(m_pcEncCfg->getUseSBACRD()) |
---|
1624 | { |
---|
1625 | TEncBinCABAC *pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); |
---|
1626 | pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+pppcRDSbacCoder->getBinsCoded()); |
---|
1627 | pppcRDSbacCoder->setBinsCoded( 0 ); |
---|
1628 | } |
---|
1629 | else |
---|
1630 | { |
---|
1631 | pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+numberOfWrittenBits); |
---|
1632 | } |
---|
1633 | if (m_pcBitCounter) |
---|
1634 | { |
---|
1635 | m_pcEntropyCoder->resetBits(); |
---|
1636 | } |
---|
1637 | } |
---|
1638 | } |
---|
1639 | |
---|
1640 | /** Compute QP for each CU |
---|
1641 | * \param pcCU Target CU |
---|
1642 | * \param uiDepth CU depth |
---|
1643 | * \returns quantization parameter |
---|
1644 | */ |
---|
1645 | Int TEncCu::xComputeQP( TComDataCU* pcCU, UInt uiDepth ) |
---|
1646 | { |
---|
1647 | Int iBaseQp = pcCU->getSlice()->getSliceQp(); |
---|
1648 | Int iQpOffset = 0; |
---|
1649 | if ( m_pcEncCfg->getUseAdaptiveQP() ) |
---|
1650 | { |
---|
1651 | TEncPic* pcEPic = dynamic_cast<TEncPic*>( pcCU->getPic() ); |
---|
1652 | UInt uiAQDepth = min( uiDepth, pcEPic->getMaxAQDepth()-1 ); |
---|
1653 | TEncPicQPAdaptationLayer* pcAQLayer = pcEPic->getAQLayer( uiAQDepth ); |
---|
1654 | UInt uiAQUPosX = pcCU->getCUPelX() / pcAQLayer->getAQPartWidth(); |
---|
1655 | UInt uiAQUPosY = pcCU->getCUPelY() / pcAQLayer->getAQPartHeight(); |
---|
1656 | UInt uiAQUStride = pcAQLayer->getAQPartStride(); |
---|
1657 | TEncQPAdaptationUnit* acAQU = pcAQLayer->getQPAdaptationUnit(); |
---|
1658 | |
---|
1659 | Double dMaxQScale = pow(2.0, m_pcEncCfg->getQPAdaptationRange()/6.0); |
---|
1660 | Double dAvgAct = pcAQLayer->getAvgActivity(); |
---|
1661 | Double dCUAct = acAQU[uiAQUPosY * uiAQUStride + uiAQUPosX].getActivity(); |
---|
1662 | Double dNormAct = (dMaxQScale*dCUAct + dAvgAct) / (dCUAct + dMaxQScale*dAvgAct); |
---|
1663 | Double dQpOffset = log(dNormAct) / log(2.0) * 6.0; |
---|
1664 | iQpOffset = Int(floor( dQpOffset + 0.49999 )); |
---|
1665 | } |
---|
1666 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1667 | return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset ); |
---|
1668 | #else |
---|
1669 | return Clip3( MIN_QP, MAX_QP, iBaseQp+iQpOffset ); |
---|
1670 | #endif |
---|
1671 | } |
---|
1672 | |
---|
1673 | /** encode a CU block recursively |
---|
1674 | * \param pcCU |
---|
1675 | * \param uiAbsPartIdx |
---|
1676 | * \param uiDepth |
---|
1677 | * \returns Void |
---|
1678 | */ |
---|
1679 | Void TEncCu::xEncodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1680 | { |
---|
1681 | TComPic* pcPic = pcCU->getPic(); |
---|
1682 | |
---|
1683 | Bool bBoundary = false; |
---|
1684 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1685 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
1686 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1687 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
1688 | |
---|
1689 | #if BURST_IPCM |
---|
1690 | if( getCheckBurstIPCMFlag() ) |
---|
1691 | { |
---|
1692 | pcCU->setLastCUSucIPCMFlag( checkLastCUSucIPCM( pcCU, uiAbsPartIdx )); |
---|
1693 | pcCU->setNumSucIPCM( countNumSucIPCM ( pcCU, uiAbsPartIdx ) ); |
---|
1694 | } |
---|
1695 | #endif |
---|
1696 | |
---|
1697 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
1698 | // If slice start is within this cu... |
---|
1699 | Bool bSliceStart = pcSlice->getEntropySliceCurStartCUAddr() > pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
1700 | pcSlice->getEntropySliceCurStartCUAddr() < pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcPic->getNumPartInCU() >> (uiDepth<<1) ); |
---|
1701 | // We need to split, so don't try these modes. |
---|
1702 | if(!bSliceStart&&( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
1703 | { |
---|
1704 | #if HHI_MPI |
---|
1705 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
1706 | { |
---|
1707 | #endif |
---|
1708 | |
---|
1709 | m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1710 | |
---|
1711 | #if HHI_MPI |
---|
1712 | } |
---|
1713 | #endif |
---|
1714 | } |
---|
1715 | else |
---|
1716 | { |
---|
1717 | bBoundary = true; |
---|
1718 | } |
---|
1719 | |
---|
1720 | #if HHI_MPI |
---|
1721 | if( uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
1722 | { |
---|
1723 | xSaveDepthWidthHeight( pcCU ); |
---|
1724 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
1725 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
1726 | |
---|
1727 | if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
1728 | { |
---|
1729 | m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1730 | } |
---|
1731 | |
---|
1732 | if( !pcCU->getSlice()->isIntra() ) |
---|
1733 | { |
---|
1734 | m_pcEntropyCoder->encodeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
1735 | } |
---|
1736 | |
---|
1737 | if( pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
1738 | { |
---|
1739 | m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 ); |
---|
1740 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
1741 | xRestoreDepthWidthHeight( pcCU ); |
---|
1742 | return; |
---|
1743 | } |
---|
1744 | |
---|
1745 | m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx ); |
---|
1746 | |
---|
1747 | m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1748 | |
---|
1749 | // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
1750 | m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); |
---|
1751 | xRestoreDepthWidthHeight( pcCU ); |
---|
1752 | } |
---|
1753 | #endif |
---|
1754 | |
---|
1755 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < (g_uiMaxCUDepth-g_uiAddCUDepth) ) ) || bBoundary ) |
---|
1756 | { |
---|
1757 | UInt uiQNumParts = ( pcPic->getNumPartInCU() >> (uiDepth<<1) )>>2; |
---|
1758 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
1759 | { |
---|
1760 | setdQPFlag(true); |
---|
1761 | } |
---|
1762 | #if BURST_IPCM |
---|
1763 | pcCU->setNumSucIPCM(0); |
---|
1764 | pcCU->setLastCUSucIPCMFlag(false); |
---|
1765 | #endif |
---|
1766 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) |
---|
1767 | { |
---|
1768 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1769 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
1770 | Bool bInSlice = pcCU->getSCUAddr()+uiAbsPartIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurEndCUAddr(); |
---|
1771 | if(bInSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
1772 | { |
---|
1773 | xEncodeCU( pcCU, uiAbsPartIdx, uiDepth+1 ); |
---|
1774 | } |
---|
1775 | } |
---|
1776 | return; |
---|
1777 | } |
---|
1778 | |
---|
1779 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
1780 | { |
---|
1781 | setdQPFlag(true); |
---|
1782 | } |
---|
1783 | #if HHI_MPI |
---|
1784 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
1785 | { |
---|
1786 | #endif |
---|
1787 | if( !pcCU->getSlice()->isIntra() ) |
---|
1788 | { |
---|
1789 | m_pcEntropyCoder->encodeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
1790 | } |
---|
1791 | #if HHI_MPI |
---|
1792 | } |
---|
1793 | #endif |
---|
1794 | |
---|
1795 | if( pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
1796 | { |
---|
1797 | m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx, 0 ); |
---|
1798 | #if LGE_ILLUCOMP_B0045 |
---|
1799 | m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); |
---|
1800 | #endif |
---|
1801 | #if HHI_INTER_VIEW_RESIDUAL_PRED && !MTK_MDIVRP_C0138 |
---|
1802 | m_pcEntropyCoder->encodeResPredFlag( pcCU, uiAbsPartIdx, 0 ); |
---|
1803 | #endif |
---|
1804 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
1805 | return; |
---|
1806 | } |
---|
1807 | #if HHI_MPI |
---|
1808 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
1809 | { |
---|
1810 | #endif |
---|
1811 | m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx ); |
---|
1812 | |
---|
1813 | m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1814 | |
---|
1815 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
1816 | { |
---|
1817 | m_pcEntropyCoder->encodeIPCMInfo( pcCU, uiAbsPartIdx ); |
---|
1818 | |
---|
1819 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
1820 | { |
---|
1821 | // Encode slice finish |
---|
1822 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
1823 | return; |
---|
1824 | } |
---|
1825 | } |
---|
1826 | |
---|
1827 | // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
1828 | m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx ); |
---|
1829 | #if LGE_ILLUCOMP_B0045 |
---|
1830 | m_pcEntropyCoder->encodeICFlag ( pcCU, uiAbsPartIdx ); |
---|
1831 | #endif |
---|
1832 | #if HHI_INTER_VIEW_RESIDUAL_PRED && !MTK_MDIVRP_C0138 |
---|
1833 | if( !pcCU->isIntra( uiAbsPartIdx ) ) |
---|
1834 | { |
---|
1835 | m_pcEntropyCoder->encodeResPredFlag( pcCU, uiAbsPartIdx, 0 ); |
---|
1836 | } |
---|
1837 | #endif |
---|
1838 | #if HHI_MPI |
---|
1839 | } |
---|
1840 | #endif |
---|
1841 | |
---|
1842 | // Encode Coefficients |
---|
1843 | Bool bCodeDQP = getdQPFlag(); |
---|
1844 | m_pcEntropyCoder->encodeCoeff( pcCU, uiAbsPartIdx, uiDepth, pcCU->getWidth (uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), bCodeDQP ); |
---|
1845 | setdQPFlag( bCodeDQP ); |
---|
1846 | |
---|
1847 | // --- write terminating bit --- |
---|
1848 | finishCU(pcCU,uiAbsPartIdx,uiDepth); |
---|
1849 | } |
---|
1850 | |
---|
1851 | /** check RD costs for a CU block encoded with merge |
---|
1852 | * \param rpcBestCU |
---|
1853 | * \param rpcTempCU |
---|
1854 | * \returns Void |
---|
1855 | */ |
---|
1856 | #if HHI_INTERVIEW_SKIP |
---|
1857 | Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bSkipRes ) |
---|
1858 | #else |
---|
1859 | Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) |
---|
1860 | #endif |
---|
1861 | { |
---|
1862 | assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); |
---|
1863 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1864 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
1865 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
1866 | #else |
---|
1867 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
1868 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
1869 | #endif |
---|
1870 | Int numValidMergeCand = 0; |
---|
1871 | |
---|
1872 | #if HHI_INTER_VIEW_RESIDUAL_PRED && !MTK_MDIVRP_C0138 |
---|
1873 | Bool bResPrdAvail = rpcTempCU->getResPredAvail( 0 ); |
---|
1874 | Bool bResPrdFlag = rpcTempCU->getResPredFlag ( 0 ); |
---|
1875 | #endif |
---|
1876 | #if LGE_ILLUCOMP_B0045 |
---|
1877 | Bool bICFlag = rpcTempCU->getICFlag(0); |
---|
1878 | #endif |
---|
1879 | |
---|
1880 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1881 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui ) |
---|
1882 | #else |
---|
1883 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
1884 | #endif |
---|
1885 | { |
---|
1886 | uhInterDirNeighbours[ui] = 0; |
---|
1887 | } |
---|
1888 | UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
1889 | |
---|
1890 | #if HHI_VSO |
---|
1891 | if( m_pcRdCost->getUseRenModel() ) |
---|
1892 | { |
---|
1893 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
1894 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
1895 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
1896 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
1897 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
1898 | } |
---|
1899 | #endif |
---|
1900 | |
---|
1901 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level |
---|
1902 | #if MERL_VSP_C0152 |
---|
1903 | Int iVSPIndexTrue[3] = {-1, -1, -1}; |
---|
1904 | rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue ); |
---|
1905 | #else |
---|
1906 | rpcTempCU->getInterMergeCandidates( 0, 0, uhDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
1907 | #endif |
---|
1908 | #if MTK_MDIVRP_C0138 |
---|
1909 | Bool bResPredAvail = rpcTempCU->getResPredAvail(0); |
---|
1910 | #endif |
---|
1911 | |
---|
1912 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
1913 | Bool bestIsSkip = false; |
---|
1914 | #endif |
---|
1915 | |
---|
1916 | for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) |
---|
1917 | { |
---|
1918 | { |
---|
1919 | TComYuv* pcPredYuvTemp = NULL; |
---|
1920 | #if LOSSLESS_CODING |
---|
1921 | UInt iteration; |
---|
1922 | if ( rpcTempCU->isLosslessCoded(0)) |
---|
1923 | { |
---|
1924 | iteration = 1; |
---|
1925 | } |
---|
1926 | else |
---|
1927 | { |
---|
1928 | iteration = 2; |
---|
1929 | } |
---|
1930 | |
---|
1931 | #if HHI_INTERVIEW_SKIP |
---|
1932 | for( UInt uiNoResidual = (bSkipRes ? 1:0); uiNoResidual < iteration; ++uiNoResidual ) |
---|
1933 | #else |
---|
1934 | for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual ) |
---|
1935 | #endif |
---|
1936 | #else |
---|
1937 | #if HHI_INTERVIEW_SKIP |
---|
1938 | for( UInt uiNoResidual = (bSkipRes ? 1:0); uiNoResidual < 2; ++uiNoResidual ) |
---|
1939 | #else |
---|
1940 | for( UInt uiNoResidual = 0; uiNoResidual < 2; ++uiNoResidual ) |
---|
1941 | #endif |
---|
1942 | #endif |
---|
1943 | { |
---|
1944 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
1945 | if( !(bestIsSkip && uiNoResidual == 0) ) |
---|
1946 | { |
---|
1947 | #endif |
---|
1948 | // set MC parameters |
---|
1949 | rpcTempCU->setPredModeSubParts( MODE_SKIP, 0, uhDepth ); // interprets depth relative to LCU level |
---|
1950 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level |
---|
1951 | rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
1952 | rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
1953 | #if MERL_VSP_C0152 |
---|
1954 | { |
---|
1955 | Int iVSPIdx = 0; |
---|
1956 | Int numVSPIdx; |
---|
1957 | numVSPIdx = 3; |
---|
1958 | for (Int i = 0; i < numVSPIdx; i++) |
---|
1959 | { |
---|
1960 | if (iVSPIndexTrue[i] == uiMergeCand) |
---|
1961 | { |
---|
1962 | iVSPIdx = i+1; |
---|
1963 | break; |
---|
1964 | } |
---|
1965 | } |
---|
1966 | rpcTempCU->setVSPIndexSubParts( iVSPIdx, 0, 0, uhDepth ); |
---|
1967 | } |
---|
1968 | #endif |
---|
1969 | rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level |
---|
1970 | rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
1971 | rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level |
---|
1972 | |
---|
1973 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1974 | #if MTK_MDIVRP_C0138 |
---|
1975 | rpcTempCU->setResPredAvailSubParts(bResPredAvail, 0, 0, uhDepth); |
---|
1976 | #else |
---|
1977 | rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth ); |
---|
1978 | rpcTempCU->setResPredFlagSubParts ( bResPrdFlag, 0, 0, uhDepth ); |
---|
1979 | #endif |
---|
1980 | #endif |
---|
1981 | #if LGE_ILLUCOMP_B0045 |
---|
1982 | rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uhDepth); |
---|
1983 | #endif |
---|
1984 | |
---|
1985 | // do MC |
---|
1986 | #if HHI_INTERVIEW_SKIP |
---|
1987 | if ( (uiNoResidual == 0) || bSkipRes ) |
---|
1988 | #else |
---|
1989 | if ( uiNoResidual == 0 ) |
---|
1990 | #endif |
---|
1991 | { |
---|
1992 | #if MERL_VSP_C0152 |
---|
1993 | m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() ); |
---|
1994 | #else |
---|
1995 | m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); |
---|
1996 | #endif |
---|
1997 | #if MTK_MDIVRP_C0138 |
---|
1998 | if (uiMergeCand == 0 && rpcTempCU->getResPredAvail(0)) |
---|
1999 | { |
---|
2000 | m_pcPredSearch->residualPrediction(rpcTempCU, m_ppcPredYuvTemp[uhDepth], m_ppcResPredTmp [uhDepth]); |
---|
2001 | } |
---|
2002 | #endif |
---|
2003 | // save pred adress |
---|
2004 | pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth]; |
---|
2005 | |
---|
2006 | } |
---|
2007 | else |
---|
2008 | { |
---|
2009 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
2010 | if( bestIsSkip) |
---|
2011 | { |
---|
2012 | #if MERL_VSP_C0152 |
---|
2013 | m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() ); |
---|
2014 | #else |
---|
2015 | m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); |
---|
2016 | #endif |
---|
2017 | #if MTK_MDIVRP_C0138 |
---|
2018 | if (uiMergeCand == 0 && rpcTempCU->getResPredAvail(0)) |
---|
2019 | { |
---|
2020 | m_pcPredSearch->residualPrediction(rpcTempCU, m_ppcPredYuvTemp[uhDepth], m_ppcResPredTmp [uhDepth]); |
---|
2021 | } |
---|
2022 | #endif |
---|
2023 | // save pred adress |
---|
2024 | pcPredYuvTemp = m_ppcPredYuvTemp[uhDepth]; |
---|
2025 | } |
---|
2026 | else |
---|
2027 | { |
---|
2028 | #endif |
---|
2029 | if ( pcPredYuvTemp != m_ppcPredYuvTemp[uhDepth]) |
---|
2030 | { |
---|
2031 | //adress changes take best (old temp) |
---|
2032 | pcPredYuvTemp = m_ppcPredYuvBest[uhDepth]; |
---|
2033 | } |
---|
2034 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
2035 | } |
---|
2036 | #endif |
---|
2037 | } |
---|
2038 | #if HHI_VSO |
---|
2039 | if( m_pcRdCost->getUseRenModel() ) |
---|
2040 | { //Reset |
---|
2041 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); |
---|
2042 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); |
---|
2043 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr (); |
---|
2044 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); |
---|
2045 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
2046 | } |
---|
2047 | #endif |
---|
2048 | // estimate residual and encode everything |
---|
2049 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
2050 | m_ppcOrigYuv [uhDepth], |
---|
2051 | pcPredYuvTemp, |
---|
2052 | m_ppcResiYuvTemp[uhDepth], |
---|
2053 | m_ppcResiYuvBest[uhDepth], |
---|
2054 | m_ppcRecoYuvTemp[uhDepth], |
---|
2055 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2056 | m_ppcResPredTmp [uhDepth], |
---|
2057 | #endif |
---|
2058 | (uiNoResidual? true:false) ); |
---|
2059 | Bool bQtRootCbf = rpcTempCU->getQtRootCbf(0) == 1; |
---|
2060 | |
---|
2061 | #if H0736_AVC_STYLE_QP_RANGE |
---|
2062 | Int orgQP = rpcTempCU->getQP( 0 ); |
---|
2063 | xCheckDQP( rpcTempCU ); |
---|
2064 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
2065 | rpcTempCU->initEstData( uhDepth, orgQP ); |
---|
2066 | #else |
---|
2067 | UInt uiOrgQP = rpcTempCU->getQP( 0 ); |
---|
2068 | xCheckDQP( rpcTempCU ); |
---|
2069 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
2070 | rpcTempCU->initEstData( uhDepth, uiOrgQP ); |
---|
2071 | #endif |
---|
2072 | |
---|
2073 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
2074 | if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) |
---|
2075 | { |
---|
2076 | bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; |
---|
2077 | } |
---|
2078 | #endif |
---|
2079 | |
---|
2080 | if (!bQtRootCbf) |
---|
2081 | break; |
---|
2082 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
2083 | } |
---|
2084 | #endif |
---|
2085 | } |
---|
2086 | } |
---|
2087 | } |
---|
2088 | } |
---|
2089 | |
---|
2090 | #if AMP_MRG |
---|
2091 | #if HHI_INTERVIEW_SKIP |
---|
2092 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bSkipRes, Bool bUseMRG) |
---|
2093 | #else |
---|
2094 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG) |
---|
2095 | #endif |
---|
2096 | #else |
---|
2097 | #if HHI_INTERVIEW_SKIP |
---|
2098 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bSkipRes) |
---|
2099 | #else |
---|
2100 | Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize ) |
---|
2101 | #endif |
---|
2102 | #endif |
---|
2103 | { |
---|
2104 | UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
2105 | |
---|
2106 | #if HHI_VSO |
---|
2107 | if( m_pcRdCost->getUseRenModel() ) |
---|
2108 | { |
---|
2109 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth ( ); |
---|
2110 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight( ); |
---|
2111 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr( ); |
---|
2112 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride(); |
---|
2113 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
2114 | } |
---|
2115 | #endif |
---|
2116 | |
---|
2117 | rpcTempCU->setDepthSubParts( uhDepth, 0 ); |
---|
2118 | |
---|
2119 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2120 | Bool bResPrdAvail = rpcTempCU->getResPredAvail( 0 ); |
---|
2121 | Bool bResPrdFlag = rpcTempCU->getResPredFlag ( 0 ); |
---|
2122 | #endif |
---|
2123 | |
---|
2124 | rpcTempCU->setPartSizeSubParts ( ePartSize, 0, uhDepth ); |
---|
2125 | |
---|
2126 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2127 | rpcTempCU->setResPredAvailSubParts( bResPrdAvail, 0, 0, uhDepth ); |
---|
2128 | rpcTempCU->setResPredFlagSubParts ( bResPrdFlag, 0, 0, uhDepth ); |
---|
2129 | #endif |
---|
2130 | rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); |
---|
2131 | |
---|
2132 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2133 | #if !LG_RESTRICTEDRESPRED_M24766 |
---|
2134 | if( rpcTempCU->getResPredFlag( 0 ) ) |
---|
2135 | { // subtract residual prediction from original in motion search |
---|
2136 | m_ppcOrigYuv[uhDepth]->add( m_ppcResPredTmp [uhDepth], rpcTempCU->getWidth( 0 ), rpcTempCU->getHeight( 0 ), true ); |
---|
2137 | } |
---|
2138 | #endif |
---|
2139 | #endif |
---|
2140 | |
---|
2141 | #if AMP_MRG |
---|
2142 | rpcTempCU->setMergeAMP (true); |
---|
2143 | #if HHI_INTERVIEW_SKIP |
---|
2144 | #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 |
---|
2145 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcResPredTmp[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG); |
---|
2146 | #else |
---|
2147 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes, bUseMRG ); |
---|
2148 | #endif |
---|
2149 | #else |
---|
2150 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG ); |
---|
2151 | #endif |
---|
2152 | #else |
---|
2153 | #if HHI_INTERVIEW_SKIP |
---|
2154 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bSkipRes ); |
---|
2155 | #else |
---|
2156 | m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] ); |
---|
2157 | #endif |
---|
2158 | #endif |
---|
2159 | |
---|
2160 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2161 | #if !LG_RESTRICTEDRESPRED_M24766 |
---|
2162 | if( rpcTempCU->getResPredFlag( 0 ) ) |
---|
2163 | { // add residual prediction to original again |
---|
2164 | m_ppcOrigYuv[uhDepth]->add( m_ppcResPredTmp [uhDepth], rpcTempCU->getWidth( 0 ), rpcTempCU->getHeight( 0 ) ); |
---|
2165 | } |
---|
2166 | #endif |
---|
2167 | #endif |
---|
2168 | |
---|
2169 | #if AMP_MRG |
---|
2170 | if ( !rpcTempCU->getMergeAMP() ) |
---|
2171 | { |
---|
2172 | return; |
---|
2173 | } |
---|
2174 | #endif |
---|
2175 | |
---|
2176 | #if HHI_INTERVIEW_SKIP |
---|
2177 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
2178 | m_ppcOrigYuv[uhDepth], |
---|
2179 | m_ppcPredYuvTemp[uhDepth], |
---|
2180 | m_ppcResiYuvTemp[uhDepth], |
---|
2181 | m_ppcResiYuvBest[uhDepth], |
---|
2182 | m_ppcRecoYuvTemp[uhDepth], |
---|
2183 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2184 | m_ppcResPredTmp [uhDepth], |
---|
2185 | #endif |
---|
2186 | bSkipRes ); |
---|
2187 | #else |
---|
2188 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
2189 | m_ppcOrigYuv[uhDepth], |
---|
2190 | m_ppcPredYuvTemp[uhDepth], |
---|
2191 | m_ppcResiYuvTemp[uhDepth], |
---|
2192 | m_ppcResiYuvBest[uhDepth], |
---|
2193 | m_ppcRecoYuvTemp[uhDepth], |
---|
2194 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2195 | m_ppcResPredTmp [uhDepth], |
---|
2196 | #endif |
---|
2197 | false ); |
---|
2198 | #endif |
---|
2199 | #if HHI_VSO |
---|
2200 | if( m_pcRdCost->getUseLambdaScaleVSO() ) |
---|
2201 | { |
---|
2202 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2203 | } |
---|
2204 | else |
---|
2205 | #endif |
---|
2206 | { |
---|
2207 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2208 | } |
---|
2209 | |
---|
2210 | xCheckDQP( rpcTempCU ); |
---|
2211 | xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); |
---|
2212 | } |
---|
2213 | |
---|
2214 | Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize ) |
---|
2215 | { |
---|
2216 | UInt uiDepth = rpcTempCU->getDepth( 0 ); |
---|
2217 | |
---|
2218 | #if HHI_VSO |
---|
2219 | if( m_pcRdCost->getUseRenModel() ) |
---|
2220 | { |
---|
2221 | UInt uiWidth = m_ppcOrigYuv[uiDepth]->getWidth (); |
---|
2222 | UInt uiHeight = m_ppcOrigYuv[uiDepth]->getHeight (); |
---|
2223 | Pel* piSrc = m_ppcOrigYuv[uiDepth]->getLumaAddr(); |
---|
2224 | UInt uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride (); |
---|
2225 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
2226 | } |
---|
2227 | #endif |
---|
2228 | |
---|
2229 | rpcTempCU->setPartSizeSubParts( eSize, 0, uiDepth ); |
---|
2230 | rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); |
---|
2231 | |
---|
2232 | Bool bSeparateLumaChroma = true; // choose estimation mode |
---|
2233 | Dist uiPreCalcDistC = 0; |
---|
2234 | if( !bSeparateLumaChroma ) |
---|
2235 | { |
---|
2236 | m_pcPredSearch->preestChromaPredMode( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth] ); |
---|
2237 | } |
---|
2238 | m_pcPredSearch ->estIntraPredQT ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, bSeparateLumaChroma ); |
---|
2239 | |
---|
2240 | m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() ); |
---|
2241 | |
---|
2242 | #if RWTH_SDC_DLT_B0036 |
---|
2243 | if( !rpcTempCU->getSDCFlag( 0 ) ) |
---|
2244 | #endif |
---|
2245 | m_pcPredSearch ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC ); |
---|
2246 | |
---|
2247 | m_pcEntropyCoder->resetBits(); |
---|
2248 | m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); |
---|
2249 | m_pcEntropyCoder->encodePredMode( rpcTempCU, 0, true ); |
---|
2250 | m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true ); |
---|
2251 | m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0, true ); |
---|
2252 | m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true ); |
---|
2253 | |
---|
2254 | // Encode Coefficients |
---|
2255 | Bool bCodeDQP = getdQPFlag(); |
---|
2256 | m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP ); |
---|
2257 | setdQPFlag( bCodeDQP ); |
---|
2258 | |
---|
2259 | if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
2260 | |
---|
2261 | rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
2262 | if(m_pcEncCfg->getUseSBACRD()) |
---|
2263 | { |
---|
2264 | rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
2265 | } |
---|
2266 | #if HHI_VSO |
---|
2267 | if( m_pcRdCost->getUseLambdaScaleVSO()) |
---|
2268 | { |
---|
2269 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2270 | } |
---|
2271 | else |
---|
2272 | #endif |
---|
2273 | { |
---|
2274 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2275 | } |
---|
2276 | |
---|
2277 | xCheckDQP( rpcTempCU ); |
---|
2278 | xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth); |
---|
2279 | } |
---|
2280 | |
---|
2281 | /** Check R-D costs for a CU with PCM mode. |
---|
2282 | * \param rpcBestCU pointer to best mode CU data structure |
---|
2283 | * \param rpcTempCU pointer to testing mode CU data structure |
---|
2284 | * \returns Void |
---|
2285 | * |
---|
2286 | * \note Current PCM implementation encodes sample values in a lossless way. The distortion of PCM mode CUs are zero. PCM mode is selected if the best mode yields bits greater than that of PCM mode. |
---|
2287 | */ |
---|
2288 | Void TEncCu::xCheckIntraPCM( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) |
---|
2289 | { |
---|
2290 | UInt uiDepth = rpcTempCU->getDepth( 0 ); |
---|
2291 | |
---|
2292 | rpcTempCU->setIPCMFlag(0, true); |
---|
2293 | rpcTempCU->setIPCMFlagSubParts (true, 0, rpcTempCU->getDepth(0)); |
---|
2294 | rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
2295 | rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth ); |
---|
2296 | |
---|
2297 | m_pcPredSearch->IPCMSearch( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth]); |
---|
2298 | |
---|
2299 | if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]); |
---|
2300 | |
---|
2301 | m_pcEntropyCoder->resetBits(); |
---|
2302 | m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0, true ); |
---|
2303 | m_pcEntropyCoder->encodePredMode ( rpcTempCU, 0, true ); |
---|
2304 | m_pcEntropyCoder->encodePartSize ( rpcTempCU, 0, uiDepth, true ); |
---|
2305 | m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true ); |
---|
2306 | |
---|
2307 | if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]); |
---|
2308 | |
---|
2309 | rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
2310 | if(m_pcEncCfg->getUseSBACRD()) |
---|
2311 | { |
---|
2312 | rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
2313 | } |
---|
2314 | #if HHI_VSO |
---|
2315 | if ( m_pcRdCost->getUseVSO() ) |
---|
2316 | { |
---|
2317 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2318 | } |
---|
2319 | else |
---|
2320 | #endif |
---|
2321 | { |
---|
2322 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2323 | } |
---|
2324 | |
---|
2325 | xCheckDQP( rpcTempCU ); |
---|
2326 | xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth ); |
---|
2327 | } |
---|
2328 | |
---|
2329 | // check whether current try is the best |
---|
2330 | Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ) |
---|
2331 | { |
---|
2332 | if( rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost() ) |
---|
2333 | { |
---|
2334 | TComYuv* pcYuv; |
---|
2335 | UChar uhDepth = rpcBestCU->getDepth(0); |
---|
2336 | |
---|
2337 | // Change Information data |
---|
2338 | TComDataCU* pcCU = rpcBestCU; |
---|
2339 | rpcBestCU = rpcTempCU; |
---|
2340 | rpcTempCU = pcCU; |
---|
2341 | |
---|
2342 | // Change Prediction data |
---|
2343 | pcYuv = m_ppcPredYuvBest[uhDepth]; |
---|
2344 | m_ppcPredYuvBest[uhDepth] = m_ppcPredYuvTemp[uhDepth]; |
---|
2345 | m_ppcPredYuvTemp[uhDepth] = pcYuv; |
---|
2346 | |
---|
2347 | // Change Reconstruction data |
---|
2348 | pcYuv = m_ppcRecoYuvBest[uhDepth]; |
---|
2349 | m_ppcRecoYuvBest[uhDepth] = m_ppcRecoYuvTemp[uhDepth]; |
---|
2350 | m_ppcRecoYuvTemp[uhDepth] = pcYuv; |
---|
2351 | |
---|
2352 | pcYuv = NULL; |
---|
2353 | pcCU = NULL; |
---|
2354 | |
---|
2355 | if( m_bUseSBACRD ) // store temp best CI for next CU coding |
---|
2356 | m_pppcRDSbacCoder[uhDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uhDepth][CI_NEXT_BEST]); |
---|
2357 | } |
---|
2358 | } |
---|
2359 | |
---|
2360 | /** check whether current try is the best with identifying the depth of current try |
---|
2361 | * \param rpcBestCU |
---|
2362 | * \param rpcTempCU |
---|
2363 | * \returns Void |
---|
2364 | */ |
---|
2365 | Void TEncCu::xCheckBestMode( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt uiDepth ) |
---|
2366 | { |
---|
2367 | if( rpcTempCU->getTotalCost() < rpcBestCU->getTotalCost() ) |
---|
2368 | { |
---|
2369 | TComYuv* pcYuv; |
---|
2370 | // Change Information data |
---|
2371 | TComDataCU* pcCU = rpcBestCU; |
---|
2372 | rpcBestCU = rpcTempCU; |
---|
2373 | rpcTempCU = pcCU; |
---|
2374 | |
---|
2375 | // Change Prediction data |
---|
2376 | pcYuv = m_ppcPredYuvBest[uiDepth]; |
---|
2377 | m_ppcPredYuvBest[uiDepth] = m_ppcPredYuvTemp[uiDepth]; |
---|
2378 | m_ppcPredYuvTemp[uiDepth] = pcYuv; |
---|
2379 | |
---|
2380 | // Change Reconstruction data |
---|
2381 | pcYuv = m_ppcRecoYuvBest[uiDepth]; |
---|
2382 | m_ppcRecoYuvBest[uiDepth] = m_ppcRecoYuvTemp[uiDepth]; |
---|
2383 | m_ppcRecoYuvTemp[uiDepth] = pcYuv; |
---|
2384 | |
---|
2385 | pcYuv = NULL; |
---|
2386 | pcCU = NULL; |
---|
2387 | |
---|
2388 | if( m_bUseSBACRD ) // store temp best CI for next CU coding |
---|
2389 | m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]->store(m_pppcRDSbacCoder[uiDepth][CI_NEXT_BEST]); |
---|
2390 | } |
---|
2391 | } |
---|
2392 | |
---|
2393 | Void TEncCu::xCheckDQP( TComDataCU* pcCU ) |
---|
2394 | { |
---|
2395 | UInt uiDepth = pcCU->getDepth( 0 ); |
---|
2396 | |
---|
2397 | if( pcCU->getSlice()->getPPS()->getUseDQP() && (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
2398 | { |
---|
2399 | if ( pcCU->getCbf( 0, TEXT_LUMA, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_U, 0 ) || pcCU->getCbf( 0, TEXT_CHROMA_V, 0 ) ) |
---|
2400 | { |
---|
2401 | #if !RDO_WITHOUT_DQP_BITS |
---|
2402 | m_pcEntropyCoder->resetBits(); |
---|
2403 | m_pcEntropyCoder->encodeQP( pcCU, 0, false ); |
---|
2404 | pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); // dQP bits |
---|
2405 | if(m_pcEncCfg->getUseSBACRD()) |
---|
2406 | { |
---|
2407 | pcCU->getTotalBins() += ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded(); |
---|
2408 | } |
---|
2409 | |
---|
2410 | // GT: Change here?? |
---|
2411 | #if HHI_VSO |
---|
2412 | if ( m_pcRdCost->getUseVSO() ) |
---|
2413 | { |
---|
2414 | pcCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); |
---|
2415 | } |
---|
2416 | else |
---|
2417 | #endif |
---|
2418 | { |
---|
2419 | pcCU->getTotalCost() = m_pcRdCost->calcRdCost( pcCU->getTotalBits(), pcCU->getTotalDistortion() ); |
---|
2420 | } |
---|
2421 | #endif |
---|
2422 | } |
---|
2423 | else |
---|
2424 | { |
---|
2425 | #if LOSSLESS_CODING |
---|
2426 | if (( ( pcCU->getRefQP( 0 ) != pcCU->getQP( 0 )) ) && (pcCU->getSlice()->getSPS()->getUseLossless())) |
---|
2427 | { |
---|
2428 | pcCU->getTotalCost() = MAX_DOUBLE; |
---|
2429 | } |
---|
2430 | #endif |
---|
2431 | pcCU->setQPSubParts( pcCU->getRefQP( 0 ), 0, uiDepth ); // set QP to default QP |
---|
2432 | } |
---|
2433 | } |
---|
2434 | } |
---|
2435 | |
---|
2436 | #if BURST_IPCM |
---|
2437 | /** Check whether the last CU shares the same root as the current CU and is IPCM or not. |
---|
2438 | * \param pcCU |
---|
2439 | * \param uiCurAbsPartIdx |
---|
2440 | * \returns Bool |
---|
2441 | */ |
---|
2442 | Bool TEncCu::checkLastCUSucIPCM( TComDataCU* pcCU, UInt uiCurAbsPartIdx ) |
---|
2443 | { |
---|
2444 | Bool lastCUSucIPCMFlag = false; |
---|
2445 | |
---|
2446 | UInt curDepth = pcCU->getDepth(uiCurAbsPartIdx); |
---|
2447 | UInt shift = ((pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx())->getSPS()->getMaxCUDepth() - curDepth)<<1); |
---|
2448 | UInt startPartUnitIdx = ((uiCurAbsPartIdx&(0x03<<shift))>>shift); |
---|
2449 | |
---|
2450 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
2451 | if( pcSlice->getEntropySliceCurStartCUAddr() == ( pcCU->getSCUAddr() + uiCurAbsPartIdx ) ) |
---|
2452 | { |
---|
2453 | return false; |
---|
2454 | } |
---|
2455 | |
---|
2456 | if(curDepth > 0 && startPartUnitIdx > 0) |
---|
2457 | { |
---|
2458 | Int lastValidPartIdx = pcCU->getLastValidPartIdx((Int) uiCurAbsPartIdx ); |
---|
2459 | |
---|
2460 | if( lastValidPartIdx >= 0 ) |
---|
2461 | { |
---|
2462 | if(( pcCU->getSliceStartCU( uiCurAbsPartIdx ) == pcCU->getSliceStartCU( (UInt) lastValidPartIdx )) |
---|
2463 | && |
---|
2464 | ( pcCU->getDepth( uiCurAbsPartIdx ) == pcCU->getDepth( (UInt) lastValidPartIdx )) |
---|
2465 | && |
---|
2466 | pcCU->getIPCMFlag( (UInt) lastValidPartIdx ) ) |
---|
2467 | { |
---|
2468 | lastCUSucIPCMFlag = true; |
---|
2469 | } |
---|
2470 | } |
---|
2471 | } |
---|
2472 | |
---|
2473 | return lastCUSucIPCMFlag; |
---|
2474 | } |
---|
2475 | |
---|
2476 | /** Count the number of successive IPCM CUs sharing the same root. |
---|
2477 | * \param pcCU |
---|
2478 | * \param uiCurAbsPartIdx |
---|
2479 | * \returns Int |
---|
2480 | */ |
---|
2481 | Int TEncCu::countNumSucIPCM ( TComDataCU* pcCU, UInt uiCurAbsPartIdx ) |
---|
2482 | { |
---|
2483 | Int numSucIPCM = 0; |
---|
2484 | UInt CurDepth = pcCU->getDepth(uiCurAbsPartIdx); |
---|
2485 | |
---|
2486 | if( pcCU->getIPCMFlag(uiCurAbsPartIdx) ) |
---|
2487 | { |
---|
2488 | if(CurDepth == 0) |
---|
2489 | { |
---|
2490 | numSucIPCM = 1; |
---|
2491 | } |
---|
2492 | else |
---|
2493 | { |
---|
2494 | TComPic* pcPic = pcCU->getPic(); |
---|
2495 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
2496 | UInt qNumParts = ( pcPic->getNumPartInCU() >> ((CurDepth-1)<<1) )>>2; |
---|
2497 | |
---|
2498 | Bool continueFlag = true; |
---|
2499 | UInt absPartIdx = uiCurAbsPartIdx; |
---|
2500 | UInt shift = ((pcSlice->getSPS()->getMaxCUDepth() - CurDepth)<<1); |
---|
2501 | UInt startPartUnitIdx = ((uiCurAbsPartIdx&(0x03<<shift))>>shift); |
---|
2502 | |
---|
2503 | for ( UInt partUnitIdx = startPartUnitIdx; partUnitIdx < 4 && continueFlag; partUnitIdx++, absPartIdx+=qNumParts ) |
---|
2504 | { |
---|
2505 | UInt lPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; |
---|
2506 | UInt tPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; |
---|
2507 | Bool inSliceFlag = ( pcCU->getSCUAddr()+absPartIdx+qNumParts>pcSlice->getEntropySliceCurStartCUAddr() ) && ( pcCU->getSCUAddr()+absPartIdx < pcSlice->getEntropySliceCurEndCUAddr()); |
---|
2508 | |
---|
2509 | if( inSliceFlag && ( lPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( tPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
2510 | { |
---|
2511 | UInt uiDepth = pcCU->getDepth(absPartIdx); |
---|
2512 | |
---|
2513 | if( ( CurDepth == uiDepth) && pcCU->getIPCMFlag( absPartIdx ) ) |
---|
2514 | { |
---|
2515 | numSucIPCM++; |
---|
2516 | } |
---|
2517 | else |
---|
2518 | { |
---|
2519 | continueFlag = false; |
---|
2520 | } |
---|
2521 | } |
---|
2522 | } |
---|
2523 | } |
---|
2524 | } |
---|
2525 | |
---|
2526 | return numSucIPCM; |
---|
2527 | } |
---|
2528 | #endif |
---|
2529 | |
---|
2530 | Void TEncCu::xCopyAMVPInfo (AMVPInfo* pSrc, AMVPInfo* pDst) |
---|
2531 | { |
---|
2532 | pDst->iN = pSrc->iN; |
---|
2533 | for (Int i = 0; i < pSrc->iN; i++) |
---|
2534 | { |
---|
2535 | pDst->m_acMvCand[i] = pSrc->m_acMvCand[i]; |
---|
2536 | } |
---|
2537 | } |
---|
2538 | Void TEncCu::xCopyYuv2Pic(TComPic* rpcPic, UInt uiCUAddr, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSrcDepth, TComDataCU* pcCU, UInt uiLPelX, UInt uiTPelY ) |
---|
2539 | { |
---|
2540 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
2541 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
2542 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
2543 | Bool bSliceStart = pcSlice->getEntropySliceCurStartCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
2544 | pcSlice->getEntropySliceCurStartCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); |
---|
2545 | Bool bSliceEnd = pcSlice->getEntropySliceCurEndCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && |
---|
2546 | pcSlice->getEntropySliceCurEndCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); |
---|
2547 | if(!bSliceEnd && !bSliceStart && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
2548 | { |
---|
2549 | UInt uiAbsPartIdxInRaster = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
2550 | UInt uiSrcBlkWidth = rpcPic->getNumPartInWidth() >> (uiSrcDepth); |
---|
2551 | UInt uiBlkWidth = rpcPic->getNumPartInWidth() >> (uiDepth); |
---|
2552 | UInt uiPartIdxX = ( ( uiAbsPartIdxInRaster % rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; |
---|
2553 | UInt uiPartIdxY = ( ( uiAbsPartIdxInRaster / rpcPic->getNumPartInWidth() ) % uiSrcBlkWidth) / uiBlkWidth; |
---|
2554 | UInt uiPartIdx = uiPartIdxY * ( uiSrcBlkWidth / uiBlkWidth ) + uiPartIdxX; |
---|
2555 | m_ppcRecoYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvRec (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx); |
---|
2556 | } |
---|
2557 | else |
---|
2558 | { |
---|
2559 | UInt uiQNumParts = ( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) )>>2; |
---|
2560 | |
---|
2561 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx+=uiQNumParts ) |
---|
2562 | { |
---|
2563 | UInt uiSubCULPelX = uiLPelX + ( g_uiMaxCUWidth >>(uiDepth+1) )*( uiPartUnitIdx & 1 ); |
---|
2564 | UInt uiSubCUTPelY = uiTPelY + ( g_uiMaxCUHeight>>(uiDepth+1) )*( uiPartUnitIdx >> 1 ); |
---|
2565 | |
---|
2566 | Bool bInSlice = rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+uiQNumParts > pcSlice->getEntropySliceCurStartCUAddr() && |
---|
2567 | rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx < pcSlice->getEntropySliceCurEndCUAddr(); |
---|
2568 | if(bInSlice&&( uiSubCULPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiSubCUTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
2569 | { |
---|
2570 | xCopyYuv2Pic( rpcPic, uiCUAddr, uiAbsPartIdx, uiDepth+1, uiSrcDepth, pcCU, uiSubCULPelX, uiSubCUTPelY ); // Copy Yuv data to picture Yuv |
---|
2571 | } |
---|
2572 | } |
---|
2573 | } |
---|
2574 | } |
---|
2575 | |
---|
2576 | Void TEncCu::xCopyYuv2Tmp( UInt uiPartUnitIdx, UInt uiNextDepth ) |
---|
2577 | { |
---|
2578 | UInt uiCurrDepth = uiNextDepth - 1; |
---|
2579 | m_ppcRecoYuvBest[uiNextDepth]->copyToPartYuv( m_ppcRecoYuvTemp[uiCurrDepth], uiPartUnitIdx ); |
---|
2580 | } |
---|
2581 | |
---|
2582 | #if LOSSLESS_CODING |
---|
2583 | /** Function for filling the PCM buffer of a CU using its original sample array |
---|
2584 | * \param pcCU pointer to current CU |
---|
2585 | * \param pcOrgYuv pointer to original sample array |
---|
2586 | * \returns Void |
---|
2587 | */ |
---|
2588 | Void TEncCu::xFillPCMBuffer ( TComDataCU*& pCU, TComYuv* pOrgYuv ) |
---|
2589 | { |
---|
2590 | |
---|
2591 | UInt width = pCU->getWidth(0); |
---|
2592 | UInt height = pCU->getHeight(0); |
---|
2593 | |
---|
2594 | Pel* pSrcY = pOrgYuv->getLumaAddr(0, width); |
---|
2595 | Pel* pDstY = pCU->getPCMSampleY(); |
---|
2596 | UInt srcStride = pOrgYuv->getStride(); |
---|
2597 | |
---|
2598 | for(Int y = 0; y < height; y++ ) |
---|
2599 | { |
---|
2600 | for(Int x = 0; x < width; x++ ) |
---|
2601 | { |
---|
2602 | pDstY[x] = pSrcY[x]; |
---|
2603 | } |
---|
2604 | pDstY += width; |
---|
2605 | pSrcY += srcStride; |
---|
2606 | } |
---|
2607 | |
---|
2608 | Pel* pSrcCb = pOrgYuv->getCbAddr(); |
---|
2609 | Pel* pSrcCr = pOrgYuv->getCrAddr();; |
---|
2610 | |
---|
2611 | Pel* pDstCb = pCU->getPCMSampleCb(); |
---|
2612 | Pel* pDstCr = pCU->getPCMSampleCr();; |
---|
2613 | |
---|
2614 | UInt srcStrideC = pOrgYuv->getCStride(); |
---|
2615 | UInt heightC = height >> 1; |
---|
2616 | UInt widthC = width >> 1; |
---|
2617 | |
---|
2618 | for(Int y = 0; y < heightC; y++ ) |
---|
2619 | { |
---|
2620 | for(Int x = 0; x < widthC; x++ ) |
---|
2621 | { |
---|
2622 | pDstCb[x] = pSrcCb[x]; |
---|
2623 | pDstCr[x] = pSrcCr[x]; |
---|
2624 | } |
---|
2625 | pDstCb += widthC; |
---|
2626 | pDstCr += widthC; |
---|
2627 | pSrcCb += srcStrideC; |
---|
2628 | pSrcCr += srcStrideC; |
---|
2629 | } |
---|
2630 | } |
---|
2631 | #endif |
---|
2632 | |
---|
2633 | #if ADAPTIVE_QP_SELECTION |
---|
2634 | /** Collect ARL statistics from one block |
---|
2635 | */ |
---|
2636 | Int TEncCu::xTuCollectARLStats(TCoeff* rpcCoeff, Int* rpcArlCoeff, Int NumCoeffInCU, Double* cSum, UInt* numSamples ) |
---|
2637 | { |
---|
2638 | for( Int n = 0; n < NumCoeffInCU; n++ ) |
---|
2639 | { |
---|
2640 | Int u = abs( rpcCoeff[ n ] ); |
---|
2641 | Int absc = rpcArlCoeff[ n ]; |
---|
2642 | |
---|
2643 | if( u != 0 ) |
---|
2644 | { |
---|
2645 | if( u < LEVEL_RANGE ) |
---|
2646 | { |
---|
2647 | cSum[ u ] += ( Double )absc; |
---|
2648 | numSamples[ u ]++; |
---|
2649 | } |
---|
2650 | else |
---|
2651 | { |
---|
2652 | cSum[ LEVEL_RANGE ] += ( Double )absc - ( Double )( u << ARL_C_PRECISION ); |
---|
2653 | numSamples[ LEVEL_RANGE ]++; |
---|
2654 | } |
---|
2655 | } |
---|
2656 | } |
---|
2657 | |
---|
2658 | return 0; |
---|
2659 | } |
---|
2660 | |
---|
2661 | /** Collect ARL statistics from one LCU |
---|
2662 | * \param pcCU |
---|
2663 | */ |
---|
2664 | Void TEncCu::xLcuCollectARLStats(TComDataCU* rpcCU ) |
---|
2665 | { |
---|
2666 | Double cSum[ LEVEL_RANGE + 1 ]; //: the sum of DCT coefficients corresponding to datatype and quantization output |
---|
2667 | UInt numSamples[ LEVEL_RANGE + 1 ]; //: the number of coefficients corresponding to datatype and quantization output |
---|
2668 | |
---|
2669 | TCoeff* pCoeffY = rpcCU->getCoeffY(); |
---|
2670 | Int* pArlCoeffY = rpcCU->getArlCoeffY(); |
---|
2671 | |
---|
2672 | UInt uiMinCUWidth = g_uiMaxCUWidth >> g_uiMaxCUDepth; |
---|
2673 | UInt uiMinNumCoeffInCU = 1 << uiMinCUWidth; |
---|
2674 | |
---|
2675 | memset( cSum, 0, sizeof( Double )*(LEVEL_RANGE+1) ); |
---|
2676 | memset( numSamples, 0, sizeof( UInt )*(LEVEL_RANGE+1) ); |
---|
2677 | |
---|
2678 | // Collect stats to cSum[][] and numSamples[][] |
---|
2679 | for(Int i = 0; i < rpcCU->getTotalNumPart(); i ++ ) |
---|
2680 | { |
---|
2681 | UInt uiTrIdx = rpcCU->getTransformIdx(i); |
---|
2682 | |
---|
2683 | if(rpcCU->getPredictionMode(i) == MODE_INTER) |
---|
2684 | if( rpcCU->getCbf( i, TEXT_LUMA, uiTrIdx ) ) |
---|
2685 | { |
---|
2686 | xTuCollectARLStats(pCoeffY, pArlCoeffY, uiMinNumCoeffInCU, cSum, numSamples); |
---|
2687 | }//Note that only InterY is processed. QP rounding is based on InterY data only. |
---|
2688 | |
---|
2689 | pCoeffY += uiMinNumCoeffInCU; |
---|
2690 | pArlCoeffY += uiMinNumCoeffInCU; |
---|
2691 | } |
---|
2692 | |
---|
2693 | for(Int u=1; u<LEVEL_RANGE;u++) |
---|
2694 | { |
---|
2695 | m_pcTrQuant->getSliceSumC()[u] += cSum[ u ] ; |
---|
2696 | m_pcTrQuant->getSliceNSamples()[u] += numSamples[ u ] ; |
---|
2697 | } |
---|
2698 | m_pcTrQuant->getSliceSumC()[LEVEL_RANGE] += cSum[ LEVEL_RANGE ] ; |
---|
2699 | m_pcTrQuant->getSliceNSamples()[LEVEL_RANGE] += numSamples[ LEVEL_RANGE ] ; |
---|
2700 | } |
---|
2701 | #endif |
---|
2702 | |
---|
2703 | #if HHI_MPI |
---|
2704 | Void TEncCu::xCheckRDCostMvInheritance( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UChar uhTextureModeDepth, Bool bSkipResidual, Bool bRecursiveCall ) |
---|
2705 | { |
---|
2706 | assert( rpcTempCU->getSlice()->getIsDepth() ); |
---|
2707 | TComDataCU *pcTextureCU = rpcTempCU->getSlice()->getTexturePic()->getCU( rpcTempCU->getAddr() ); |
---|
2708 | |
---|
2709 | const UChar uhDepth = rpcTempCU->getDepth( 0 ); |
---|
2710 | const Int iQP = rpcTempCU->getQP( 0 ); |
---|
2711 | assert( bRecursiveCall == ( uhDepth != uhTextureModeDepth ) ); |
---|
2712 | |
---|
2713 | #if !MTK_UNCONSTRAINED_MVI_B0083 |
---|
2714 | if( uhDepth == uhTextureModeDepth ) |
---|
2715 | { |
---|
2716 | for( UInt ui = 0; ui < rpcTempCU->getTotalNumPart(); ui++ ) |
---|
2717 | { |
---|
2718 | if( pcTextureCU->isIntra( rpcTempCU->getZorderIdxInCU() + ui ) ) |
---|
2719 | { |
---|
2720 | return; |
---|
2721 | } |
---|
2722 | } |
---|
2723 | } |
---|
2724 | #endif |
---|
2725 | |
---|
2726 | #if HHI_VSO |
---|
2727 | if( m_pcRdCost->getUseRenModel() && !bRecursiveCall) |
---|
2728 | { |
---|
2729 | UInt uiWidth = m_ppcOrigYuv[uhDepth]->getWidth (); |
---|
2730 | UInt uiHeight = m_ppcOrigYuv[uhDepth]->getHeight (); |
---|
2731 | Pel* piSrc = m_ppcOrigYuv[uhDepth]->getLumaAddr(); |
---|
2732 | UInt uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride (); |
---|
2733 | m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
2734 | } |
---|
2735 | #endif |
---|
2736 | |
---|
2737 | Bool bSplit = uhDepth < pcTextureCU->getDepth( rpcTempCU->getZorderIdxInCU() ); |
---|
2738 | if( bSplit ) |
---|
2739 | { |
---|
2740 | const UChar uhNextDepth = uhDepth+1; |
---|
2741 | TComDataCU* pcSubBestPartCU = m_ppcBestCU[uhNextDepth]; |
---|
2742 | TComDataCU* pcSubTempPartCU = m_ppcTempCU[uhNextDepth]; |
---|
2743 | |
---|
2744 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
2745 | { |
---|
2746 | pcSubBestPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
2747 | pcSubTempPartCU->initSubCU( rpcTempCU, uiPartUnitIdx, uhNextDepth, iQP ); // clear sub partition datas or init. |
---|
2748 | |
---|
2749 | TComSlice * pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); |
---|
2750 | Bool bInSlice = pcSubBestPartCU->getSCUAddr()+pcSubBestPartCU->getTotalNumPart()>pcSlice->getEntropySliceCurStartCUAddr()&&pcSubBestPartCU->getSCUAddr()<pcSlice->getEntropySliceCurEndCUAddr(); |
---|
2751 | if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
2752 | { |
---|
2753 | if( m_bUseSBACRD ) |
---|
2754 | { |
---|
2755 | if ( 0 == uiPartUnitIdx) //initialize RD with previous depth buffer |
---|
2756 | { |
---|
2757 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhDepth][CI_CURR_BEST]); |
---|
2758 | } |
---|
2759 | else |
---|
2760 | { |
---|
2761 | m_pppcRDSbacCoder[uhNextDepth][CI_CURR_BEST]->load(m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]); |
---|
2762 | } |
---|
2763 | } |
---|
2764 | |
---|
2765 | xCheckRDCostMvInheritance( pcSubBestPartCU, pcSubTempPartCU, uhTextureModeDepth, bSkipResidual, true ); |
---|
2766 | |
---|
2767 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); // Keep best part data to current temporary data. |
---|
2768 | xCopyYuv2Tmp( pcSubBestPartCU->getTotalNumPart()*uiPartUnitIdx, uhNextDepth ); |
---|
2769 | } |
---|
2770 | else if (bInSlice) |
---|
2771 | { |
---|
2772 | pcSubBestPartCU->copyToPic( uhNextDepth ); |
---|
2773 | rpcTempCU->copyPartFrom( pcSubBestPartCU, uiPartUnitIdx, uhNextDepth ); |
---|
2774 | } |
---|
2775 | } |
---|
2776 | |
---|
2777 | if( uhDepth == uhTextureModeDepth ) |
---|
2778 | { |
---|
2779 | xAddMVISignallingBits( rpcTempCU ); |
---|
2780 | } |
---|
2781 | |
---|
2782 | // DQP stuff |
---|
2783 | { |
---|
2784 | if( (g_uiMaxCUWidth>>uhDepth) == rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() && rpcTempCU->getSlice()->getPPS()->getUseDQP()) |
---|
2785 | { |
---|
2786 | TComPic *pcPic = rpcTempCU->getPic(); |
---|
2787 | TComSlice *pcSlice = rpcTempCU->getPic()->getSlice(rpcTempCU->getPic()->getCurrSliceIdx()); |
---|
2788 | Bool bHasRedisual = false; |
---|
2789 | for( UInt uiBlkIdx = 0; uiBlkIdx < rpcTempCU->getTotalNumPart(); uiBlkIdx ++) |
---|
2790 | { |
---|
2791 | if( ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(uiBlkIdx+rpcTempCU->getZorderIdxInCU()) == rpcTempCU->getSlice()->getEntropySliceCurStartCUAddr() ) && |
---|
2792 | ( rpcTempCU->getCbf( uiBlkIdx, TEXT_LUMA ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_U ) || rpcTempCU->getCbf( uiBlkIdx, TEXT_CHROMA_V ) ) ) |
---|
2793 | { |
---|
2794 | bHasRedisual = true; |
---|
2795 | break; |
---|
2796 | } |
---|
2797 | } |
---|
2798 | |
---|
2799 | UInt uiTargetPartIdx; |
---|
2800 | if ( pcPic->getCU( rpcTempCU->getAddr() )->getEntropySliceStartCU(rpcTempCU->getZorderIdxInCU()) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
2801 | { |
---|
2802 | uiTargetPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU() - rpcTempCU->getZorderIdxInCU(); |
---|
2803 | } |
---|
2804 | else |
---|
2805 | { |
---|
2806 | uiTargetPartIdx = 0; |
---|
2807 | } |
---|
2808 | if ( ! bHasRedisual ) |
---|
2809 | { |
---|
2810 | #if LOSSLESS_CODING |
---|
2811 | if (((rpcTempCU->getQP(uiTargetPartIdx) != rpcTempCU->getRefQP(uiTargetPartIdx)) ) && (rpcTempCU->getSlice()->getSPS()->getUseLossless())) |
---|
2812 | { |
---|
2813 | rpcTempCU->getTotalCost() = MAX_DOUBLE; |
---|
2814 | } |
---|
2815 | #endif |
---|
2816 | rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( uiTargetPartIdx ), 0, uhDepth ); // set QP to default QP |
---|
2817 | } |
---|
2818 | } |
---|
2819 | } |
---|
2820 | |
---|
2821 | if( m_bUseSBACRD ) |
---|
2822 | { |
---|
2823 | m_pppcRDSbacCoder[uhNextDepth][CI_NEXT_BEST]->store(m_pppcRDSbacCoder[uhDepth][CI_TEMP_BEST]); |
---|
2824 | } |
---|
2825 | } |
---|
2826 | else |
---|
2827 | { |
---|
2828 | rpcTempCU->setTextureModeDepthSubParts( uhTextureModeDepth, 0, uhDepth ); |
---|
2829 | rpcTempCU->copyTextureMotionDataFrom( pcTextureCU, uhDepth, rpcTempCU->getZorderIdxInCU() ); |
---|
2830 | #if FIX_MPI_B0065 |
---|
2831 | UInt uiAbsPartIdx = rpcTempCU->getZorderIdxInCU(); |
---|
2832 | if( rpcTempCU->getDepth(0) > pcTextureCU->getDepth(uiAbsPartIdx)) |
---|
2833 | { |
---|
2834 | rpcTempCU->setPartSizeSubParts( SIZE_NxN, 0, uhDepth ); |
---|
2835 | } |
---|
2836 | else |
---|
2837 | { |
---|
2838 | PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx); |
---|
2839 | rpcTempCU->setPartSizeSubParts( partSize, 0, uhDepth ); |
---|
2840 | } |
---|
2841 | #else |
---|
2842 | rpcTempCU->setPartSizeSubParts( SIZE_NxN, 0, uhDepth ); |
---|
2843 | #endif |
---|
2844 | for( UInt ui = 0; ui < rpcTempCU->getTotalNumPart(); ui++ ) |
---|
2845 | { |
---|
2846 | assert( rpcTempCU->getInterDir( ui ) != 0 ); |
---|
2847 | assert( rpcTempCU->getPredictionMode( ui ) != MODE_NONE ); |
---|
2848 | #if MERL_VSP_C0152 |
---|
2849 | Int vspIdx = pcTextureCU->getVSPIndex( rpcTempCU->getZorderIdxInCU() + ui); |
---|
2850 | rpcTempCU->setVSPIndex( ui , vspIdx); |
---|
2851 | #endif |
---|
2852 | } |
---|
2853 | |
---|
2854 | rpcTempCU->setPredModeSubParts( bSkipResidual ? MODE_SKIP : MODE_INTER, 0, uhDepth ); |
---|
2855 | #if MERL_VSP_C0152 |
---|
2856 | m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth], rpcTempCU->getZorderIdxInCU() ); |
---|
2857 | #else |
---|
2858 | m_pcPredSearch->motionCompensation( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); |
---|
2859 | #endif |
---|
2860 | // get Original YUV data from picture |
---|
2861 | m_ppcOrigYuv[uhDepth]->copyFromPicYuv( rpcBestCU->getPic()->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); |
---|
2862 | m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, |
---|
2863 | m_ppcOrigYuv[uhDepth], |
---|
2864 | m_ppcPredYuvTemp[uhDepth], |
---|
2865 | m_ppcResiYuvTemp[uhDepth], |
---|
2866 | m_ppcResiYuvBest[uhDepth], |
---|
2867 | m_ppcRecoYuvTemp[uhDepth], |
---|
2868 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2869 | m_ppcResPredTmp [uhDepth], |
---|
2870 | #endif |
---|
2871 | bSkipResidual ); |
---|
2872 | |
---|
2873 | if( uhDepth == uhTextureModeDepth ) |
---|
2874 | { |
---|
2875 | xAddMVISignallingBits( rpcTempCU ); |
---|
2876 | } |
---|
2877 | xCheckDQP( rpcTempCU ); |
---|
2878 | } |
---|
2879 | |
---|
2880 | #if HHI_VSO |
---|
2881 | if( m_pcRdCost->getUseLambdaScaleVSO() ) |
---|
2882 | { |
---|
2883 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2884 | } |
---|
2885 | else |
---|
2886 | #endif |
---|
2887 | { |
---|
2888 | rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); |
---|
2889 | } |
---|
2890 | |
---|
2891 | if( rpcTempCU->getPredictionMode( 0 ) == MODE_SKIP && uhDepth == uhTextureModeDepth ) |
---|
2892 | { |
---|
2893 | if( rpcTempCU->getSlice()->getPPS()->getUseDQP() && (g_uiMaxCUWidth>>uhDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) |
---|
2894 | rpcTempCU->setQPSubParts( rpcTempCU->getRefQP( 0 ), 0, uhDepth ); // set QP to default QP |
---|
2895 | } |
---|
2896 | xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth ); |
---|
2897 | rpcBestCU->copyToPic(uhDepth); // Copy Best data to Picture for next partition prediction. |
---|
2898 | |
---|
2899 | #if HHI_VSO |
---|
2900 | if( !bSplit && bRecursiveCall && m_pcRdCost->getUseRenModel() ) |
---|
2901 | { |
---|
2902 | UInt uiWidth = m_ppcRecoYuvBest[uhDepth]->getWidth ( ); |
---|
2903 | UInt uiHeight = m_ppcRecoYuvBest[uhDepth]->getHeight ( ); |
---|
2904 | UInt uiSrcStride = m_ppcRecoYuvBest[uhDepth]->getStride ( ); |
---|
2905 | Pel* piSrc = m_ppcRecoYuvBest[uhDepth]->getLumaAddr( 0 ); |
---|
2906 | m_pcRdCost->setRenModelData( rpcBestCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight ); |
---|
2907 | } |
---|
2908 | #endif |
---|
2909 | } |
---|
2910 | |
---|
2911 | Void TEncCu::xAddMVISignallingBits( TComDataCU* pcCU ) |
---|
2912 | { |
---|
2913 | const UChar uhDepth = pcCU->getTextureModeDepth( 0 ); |
---|
2914 | m_pcEntropyCoder->resetBits(); |
---|
2915 | xSaveDepthWidthHeight( pcCU ); |
---|
2916 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uhDepth, g_uiMaxCUHeight>>uhDepth, 0, uhDepth ); |
---|
2917 | pcCU->setDepthSubParts( uhDepth, 0 ); |
---|
2918 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); |
---|
2919 | pcCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); |
---|
2920 | pcCU->setMergeIndexSubParts( HHI_MPI_MERGE_POS, 0, 0, uhDepth ); |
---|
2921 | |
---|
2922 | // check for skip mode |
---|
2923 | { |
---|
2924 | Bool bAllZero = true; |
---|
2925 | for( UInt ui = 0; ui < pcCU->getTotalNumPart(); ui++ ) |
---|
2926 | { |
---|
2927 | if( pcCU->getCbf( ui, TEXT_LUMA ) || pcCU->getCbf( ui, TEXT_CHROMA_U ) || pcCU->getCbf( ui, TEXT_CHROMA_V ) ) |
---|
2928 | { |
---|
2929 | bAllZero = false; |
---|
2930 | break; |
---|
2931 | } |
---|
2932 | } |
---|
2933 | if( bAllZero ) |
---|
2934 | pcCU->setPredModeSubParts( MODE_SKIP, 0, uhDepth ); |
---|
2935 | } |
---|
2936 | |
---|
2937 | |
---|
2938 | m_pcEntropyCoder->encodeSplitFlag( pcCU, 0, uhDepth, true ); |
---|
2939 | m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true ); |
---|
2940 | |
---|
2941 | if( pcCU->isSkipped( 0 ) ) |
---|
2942 | { |
---|
2943 | m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, 0, true ); |
---|
2944 | #if LGE_ILLUCOMP_B0045 |
---|
2945 | m_pcEntropyCoder->encodeICFlag( pcCU, 0, true ); |
---|
2946 | #endif |
---|
2947 | } |
---|
2948 | else |
---|
2949 | { |
---|
2950 | m_pcEntropyCoder->encodePredMode( pcCU, 0, true ); |
---|
2951 | m_pcEntropyCoder->encodePartSize( pcCU, 0, uhDepth, true ); |
---|
2952 | // prediction Info ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
2953 | m_pcEntropyCoder->encodePredInfo( pcCU, 0, true ); |
---|
2954 | #if LGE_ILLUCOMP_B0045 |
---|
2955 | m_pcEntropyCoder->encodeICFlag( pcCU, 0, true ); |
---|
2956 | #endif |
---|
2957 | } |
---|
2958 | xRestoreDepthWidthHeight( pcCU ); |
---|
2959 | |
---|
2960 | pcCU->getTotalBits() += m_pcEntropyCoder->getNumberOfWrittenBits(); |
---|
2961 | } |
---|
2962 | |
---|
2963 | Void TEncCu::xSaveDepthWidthHeight( TComDataCU* pcCU ) |
---|
2964 | { |
---|
2965 | const Int iSizeInUchar = sizeof( UChar ) * pcCU->getTotalNumPart(); |
---|
2966 | memcpy( m_puhDepthSaved, pcCU->getDepth(), iSizeInUchar ); |
---|
2967 | memcpy( m_puhWidthSaved, pcCU->getWidth(), iSizeInUchar ); |
---|
2968 | memcpy( m_puhHeightSaved, pcCU->getHeight(), iSizeInUchar ); |
---|
2969 | } |
---|
2970 | |
---|
2971 | Void TEncCu::xRestoreDepthWidthHeight( TComDataCU* pcCU ) |
---|
2972 | { |
---|
2973 | const Int iSizeInUchar = sizeof( UChar ) * pcCU->getTotalNumPart(); |
---|
2974 | memcpy( pcCU->getDepth(), m_puhDepthSaved, iSizeInUchar ); |
---|
2975 | memcpy( pcCU->getWidth(), m_puhWidthSaved, iSizeInUchar ); |
---|
2976 | memcpy( pcCU->getHeight(), m_puhHeightSaved, iSizeInUchar ); |
---|
2977 | } |
---|
2978 | #endif |
---|
2979 | |
---|
2980 | //! \} |
---|