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-2011, 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 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 | |
---|
35 | |
---|
36 | /** \file TComDataCU.cpp |
---|
37 | \brief CU data structure |
---|
38 | \todo not all entities are documented |
---|
39 | */ |
---|
40 | |
---|
41 | #include "TComDataCU.h" |
---|
42 | #include "TComPic.h" |
---|
43 | #include "TComDepthMapGenerator.h" |
---|
44 | #include "TComResidualGenerator.h" |
---|
45 | |
---|
46 | // ==================================================================================================================== |
---|
47 | // Constructor / destructor / create / destroy |
---|
48 | // ==================================================================================================================== |
---|
49 | |
---|
50 | TComDataCU::TComDataCU() |
---|
51 | { |
---|
52 | m_pcPic = NULL; |
---|
53 | m_pcSlice = NULL; |
---|
54 | m_puhDepth = NULL; |
---|
55 | #if HHI_MPI |
---|
56 | m_piTextureModeDepth = NULL; |
---|
57 | #endif |
---|
58 | |
---|
59 | m_pePartSize = NULL; |
---|
60 | m_pePredMode = NULL; |
---|
61 | m_puiAlfCtrlFlag = NULL; |
---|
62 | m_puiTmpAlfCtrlFlag = NULL; |
---|
63 | m_puhWidth = NULL; |
---|
64 | m_puhHeight = NULL; |
---|
65 | m_phQP = NULL; |
---|
66 | m_pbMergeFlag = NULL; |
---|
67 | m_puhMergeIndex = NULL; |
---|
68 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
69 | m_pbResPredAvailable = NULL; |
---|
70 | m_pbResPredFlag = NULL; |
---|
71 | #endif |
---|
72 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
73 | { |
---|
74 | m_apuhNeighbourCandIdx[ui] = NULL; |
---|
75 | } |
---|
76 | m_puhLumaIntraDir = NULL; |
---|
77 | m_puhChromaIntraDir = NULL; |
---|
78 | m_puhInterDir = NULL; |
---|
79 | m_puhTrIdx = NULL; |
---|
80 | m_puhCbf[0] = NULL; |
---|
81 | m_puhCbf[1] = NULL; |
---|
82 | m_puhCbf[2] = NULL; |
---|
83 | m_pcTrCoeffY = NULL; |
---|
84 | m_pcTrCoeffCb = NULL; |
---|
85 | m_pcTrCoeffCr = NULL; |
---|
86 | |
---|
87 | m_pcPattern = NULL; |
---|
88 | |
---|
89 | m_pcCUAboveLeft = NULL; |
---|
90 | m_pcCUAboveRight = NULL; |
---|
91 | m_pcCUAbove = NULL; |
---|
92 | m_pcCULeft = NULL; |
---|
93 | |
---|
94 | m_apcCUColocated[0] = NULL; |
---|
95 | m_apcCUColocated[1] = NULL; |
---|
96 | |
---|
97 | m_apiMVPIdx[0] = NULL; |
---|
98 | m_apiMVPIdx[1] = NULL; |
---|
99 | m_apiMVPNum[0] = NULL; |
---|
100 | m_apiMVPNum[1] = NULL; |
---|
101 | |
---|
102 | m_bDecSubCu = false; |
---|
103 | m_uiSliceStartCU = 0; |
---|
104 | m_uiEntropySliceStartCU = 0; |
---|
105 | |
---|
106 | #if SNY_DQP |
---|
107 | m_bdQP = false; |
---|
108 | #endif//SNY_DQP |
---|
109 | |
---|
110 | #if HHI_DMM_WEDGE_INTRA |
---|
111 | m_puiWedgeFullTabIdx = NULL; |
---|
112 | m_piWedgeFullDeltaDC1 = NULL; |
---|
113 | m_piWedgeFullDeltaDC2 = NULL; |
---|
114 | |
---|
115 | m_puiWedgePredDirTabIdx = NULL; |
---|
116 | m_piWedgePredDirDeltaDC1 = NULL; |
---|
117 | m_piWedgePredDirDeltaDC2 = NULL; |
---|
118 | m_piWedgePredDirDeltaEnd = NULL; |
---|
119 | #endif |
---|
120 | #if HHI_DMM_PRED_TEX |
---|
121 | m_puiWedgePredTexTabIdx = NULL; |
---|
122 | m_piWedgePredTexDeltaDC1 = NULL; |
---|
123 | m_piWedgePredTexDeltaDC2 = NULL; |
---|
124 | |
---|
125 | m_piContourPredTexDeltaDC1 = NULL; |
---|
126 | m_piContourPredTexDeltaDC2 = NULL; |
---|
127 | #endif |
---|
128 | } |
---|
129 | |
---|
130 | TComDataCU::~TComDataCU() |
---|
131 | { |
---|
132 | } |
---|
133 | |
---|
134 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu) |
---|
135 | { |
---|
136 | m_bDecSubCu = bDecSubCu; |
---|
137 | |
---|
138 | m_pcPic = NULL; |
---|
139 | m_pcSlice = NULL; |
---|
140 | m_uiNumPartition = uiNumPartition; |
---|
141 | |
---|
142 | if ( !bDecSubCu ) |
---|
143 | { |
---|
144 | m_phQP = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
145 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
146 | #if HHI_MPI |
---|
147 | m_piTextureModeDepth = (Int* )xMalloc(Int, uiNumPartition); |
---|
148 | #endif |
---|
149 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
150 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
151 | m_pePartSize = (PartSize* )xMalloc(PartSize, uiNumPartition); |
---|
152 | m_pePredMode = (PredMode* )xMalloc(PredMode, uiNumPartition); |
---|
153 | |
---|
154 | m_puiAlfCtrlFlag = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
155 | |
---|
156 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
157 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
158 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
159 | m_pbResPredAvailable = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
160 | m_pbResPredFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
161 | #endif |
---|
162 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
163 | { |
---|
164 | m_apuhNeighbourCandIdx[ ui ] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
165 | } |
---|
166 | |
---|
167 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
168 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
169 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
170 | |
---|
171 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
172 | |
---|
173 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
174 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
175 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
176 | |
---|
177 | m_apiMVPIdx[0] = (Int* )xMalloc(Int, uiNumPartition); |
---|
178 | m_apiMVPIdx[1] = (Int* )xMalloc(Int, uiNumPartition); |
---|
179 | m_apiMVPNum[0] = (Int* )xMalloc(Int, uiNumPartition); |
---|
180 | m_apiMVPNum[1] = (Int* )xMalloc(Int, uiNumPartition); |
---|
181 | |
---|
182 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
---|
183 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
184 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
185 | |
---|
186 | m_acCUMvField[0].create( uiNumPartition ); |
---|
187 | m_acCUMvField[1].create( uiNumPartition ); |
---|
188 | |
---|
189 | #if HHI_DMM_WEDGE_INTRA |
---|
190 | m_puiWedgeFullTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
191 | m_piWedgeFullDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
192 | m_piWedgeFullDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
193 | |
---|
194 | m_puiWedgePredDirTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
195 | m_piWedgePredDirDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
196 | m_piWedgePredDirDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
197 | m_piWedgePredDirDeltaEnd = (Int* )xMalloc(Int, uiNumPartition); |
---|
198 | #endif |
---|
199 | #if HHI_DMM_PRED_TEX |
---|
200 | m_puiWedgePredTexTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
---|
201 | m_piWedgePredTexDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
202 | m_piWedgePredTexDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
203 | |
---|
204 | m_piContourPredTexDeltaDC1 = (Int* )xMalloc(Int, uiNumPartition); |
---|
205 | m_piContourPredTexDeltaDC2 = (Int* )xMalloc(Int, uiNumPartition); |
---|
206 | #endif |
---|
207 | } |
---|
208 | else |
---|
209 | { |
---|
210 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
---|
211 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
---|
212 | } |
---|
213 | |
---|
214 | // create pattern memory |
---|
215 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
---|
216 | |
---|
217 | // create motion vector fields |
---|
218 | |
---|
219 | m_pcCUAboveLeft = NULL; |
---|
220 | m_pcCUAboveRight = NULL; |
---|
221 | m_pcCUAbove = NULL; |
---|
222 | m_pcCULeft = NULL; |
---|
223 | |
---|
224 | m_apcCUColocated[0] = NULL; |
---|
225 | m_apcCUColocated[1] = NULL; |
---|
226 | } |
---|
227 | |
---|
228 | Void TComDataCU::destroy() |
---|
229 | { |
---|
230 | m_pcPic = NULL; |
---|
231 | m_pcSlice = NULL; |
---|
232 | |
---|
233 | if ( m_pcPattern ) |
---|
234 | { |
---|
235 | xFree(m_pcPattern); |
---|
236 | m_pcPattern = NULL; |
---|
237 | } |
---|
238 | |
---|
239 | // encoder-side buffer free |
---|
240 | if ( !m_bDecSubCu ) |
---|
241 | { |
---|
242 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
---|
243 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
---|
244 | #if HHI_MPI |
---|
245 | if ( m_piTextureModeDepth ) { xFree(m_piTextureModeDepth); m_piTextureModeDepth= NULL; } |
---|
246 | #endif |
---|
247 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
---|
248 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
---|
249 | if ( m_pePartSize ) { xFree(m_pePartSize); m_pePartSize = NULL; } |
---|
250 | if ( m_pePredMode ) { xFree(m_pePredMode); m_pePredMode = NULL; } |
---|
251 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
---|
252 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
---|
253 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
---|
254 | if ( m_puiAlfCtrlFlag ) { xFree(m_puiAlfCtrlFlag); m_puiAlfCtrlFlag = NULL; } |
---|
255 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
---|
256 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
---|
257 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
---|
258 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
259 | if ( m_pbResPredAvailable ) { xFree(m_pbResPredAvailable); m_pbResPredAvailable= NULL; } |
---|
260 | if ( m_pbResPredFlag ) { xFree(m_pbResPredFlag); m_pbResPredFlag = NULL; } |
---|
261 | #endif |
---|
262 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
263 | { |
---|
264 | if( m_apuhNeighbourCandIdx[ ui ] ) { xFree(m_apuhNeighbourCandIdx[ ui ]); m_apuhNeighbourCandIdx[ ui ] = NULL; } |
---|
265 | } |
---|
266 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
---|
267 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
---|
268 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
---|
269 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
---|
270 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
---|
271 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
---|
272 | if ( m_apiMVPIdx[0] ) { xFree(m_apiMVPIdx[0]); m_apiMVPIdx[0] = NULL; } |
---|
273 | if ( m_apiMVPIdx[1] ) { xFree(m_apiMVPIdx[1]); m_apiMVPIdx[1] = NULL; } |
---|
274 | if ( m_apiMVPNum[0] ) { xFree(m_apiMVPNum[0]); m_apiMVPNum[0] = NULL; } |
---|
275 | if ( m_apiMVPNum[1] ) { xFree(m_apiMVPNum[1]); m_apiMVPNum[1] = NULL; } |
---|
276 | |
---|
277 | m_acCUMvField[0].destroy(); |
---|
278 | m_acCUMvField[1].destroy(); |
---|
279 | |
---|
280 | #if HHI_DMM_WEDGE_INTRA |
---|
281 | if ( m_puiWedgeFullTabIdx ) { xFree(m_puiWedgeFullTabIdx); m_puiWedgeFullTabIdx = NULL; } |
---|
282 | if ( m_piWedgeFullDeltaDC1 ) { xFree(m_piWedgeFullDeltaDC1); m_piWedgeFullDeltaDC1 = NULL; } |
---|
283 | if ( m_piWedgeFullDeltaDC2 ) { xFree(m_piWedgeFullDeltaDC2); m_piWedgeFullDeltaDC2 = NULL; } |
---|
284 | |
---|
285 | if ( m_puiWedgePredDirTabIdx ) { xFree(m_puiWedgePredDirTabIdx); m_puiWedgePredDirTabIdx = NULL; } |
---|
286 | if ( m_piWedgePredDirDeltaEnd ) { xFree(m_piWedgePredDirDeltaEnd); m_piWedgePredDirDeltaEnd = NULL; } |
---|
287 | if ( m_piWedgePredDirDeltaDC1 ) { xFree(m_piWedgePredDirDeltaDC1); m_piWedgePredDirDeltaDC1 = NULL; } |
---|
288 | if ( m_piWedgePredDirDeltaDC2 ) { xFree(m_piWedgePredDirDeltaDC2); m_piWedgePredDirDeltaDC2 = NULL; } |
---|
289 | #endif |
---|
290 | #if HHI_DMM_PRED_TEX |
---|
291 | if ( m_puiWedgePredTexTabIdx ) { xFree(m_puiWedgePredTexTabIdx); m_puiWedgePredTexTabIdx = NULL; } |
---|
292 | if ( m_piWedgePredTexDeltaDC1 ) { xFree(m_piWedgePredTexDeltaDC1); m_piWedgePredTexDeltaDC1 = NULL; } |
---|
293 | if ( m_piWedgePredTexDeltaDC2 ) { xFree(m_piWedgePredTexDeltaDC2); m_piWedgePredTexDeltaDC2 = NULL; } |
---|
294 | |
---|
295 | if ( m_piContourPredTexDeltaDC1 ) { xFree(m_piContourPredTexDeltaDC1); m_piContourPredTexDeltaDC1 = NULL; } |
---|
296 | if ( m_piContourPredTexDeltaDC2 ) { xFree(m_piContourPredTexDeltaDC2); m_piContourPredTexDeltaDC2 = NULL; } |
---|
297 | #endif |
---|
298 | } |
---|
299 | |
---|
300 | m_pcCUAboveLeft = NULL; |
---|
301 | m_pcCUAboveRight = NULL; |
---|
302 | m_pcCUAbove = NULL; |
---|
303 | m_pcCULeft = NULL; |
---|
304 | |
---|
305 | m_apcCUColocated[0] = NULL; |
---|
306 | m_apcCUColocated[1] = NULL; |
---|
307 | } |
---|
308 | |
---|
309 | // ==================================================================================================================== |
---|
310 | // Public member functions |
---|
311 | // ==================================================================================================================== |
---|
312 | |
---|
313 | // -------------------------------------------------------------------------------------------------------------------- |
---|
314 | // Initialization |
---|
315 | // -------------------------------------------------------------------------------------------------------------------- |
---|
316 | |
---|
317 | /** |
---|
318 | - initialize top-level CU |
---|
319 | - internal buffers are already created |
---|
320 | - set values before encoding a CU |
---|
321 | . |
---|
322 | \param pcPic picture (TComPic) class pointer |
---|
323 | \param iCUAddr CU address |
---|
324 | */ |
---|
325 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
---|
326 | { |
---|
327 | TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
328 | m_pcSlice = pcSlice; |
---|
329 | m_uiSliceStartCU = pcSlice->getSliceCurStartCUAddr(); |
---|
330 | m_uiEntropySliceStartCU = pcSlice->getEntropySliceCurStartCUAddr(); |
---|
331 | m_pcPic = pcPic; |
---|
332 | m_uiCUAddr = iCUAddr; |
---|
333 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
---|
334 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
---|
335 | m_uiAbsIdxInLCU = 0; |
---|
336 | |
---|
337 | m_dTotalCost = MAX_DOUBLE; |
---|
338 | m_uiTotalDistortion = 0; |
---|
339 | m_uiTotalBits = 0; |
---|
340 | m_uiNumPartition = pcPic->getNumPartInCU(); |
---|
341 | |
---|
342 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
343 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
344 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
345 | |
---|
346 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
347 | |
---|
348 | memset( m_phQP, pcSlice->getSliceQp(), iSizeInUchar ); |
---|
349 | memset( m_puiAlfCtrlFlag, 0, iSizeInUInt ); |
---|
350 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
351 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
352 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
353 | memset( m_pbResPredAvailable, 0, iSizeInBool ); |
---|
354 | memset( m_pbResPredFlag, 0, iSizeInBool ); |
---|
355 | #endif |
---|
356 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
357 | { |
---|
358 | memset( m_apuhNeighbourCandIdx[ ui ], 0, iSizeInUchar ); |
---|
359 | } |
---|
360 | memset( m_puhLumaIntraDir, 2, iSizeInUchar ); |
---|
361 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
362 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
363 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
364 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
365 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
366 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
367 | memset( m_puhDepth, 0, iSizeInUchar ); |
---|
368 | #if HHI_MPI |
---|
369 | memset( m_piTextureModeDepth,-1, iSizeInInt ); |
---|
370 | #endif |
---|
371 | |
---|
372 | UChar uhWidth = g_uiMaxCUWidth; |
---|
373 | UChar uhHeight = g_uiMaxCUHeight; |
---|
374 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
375 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
376 | |
---|
377 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
378 | { |
---|
379 | m_pePartSize[ui] = SIZE_NONE; |
---|
380 | m_pePredMode[ui] = MODE_NONE; |
---|
381 | |
---|
382 | m_apiMVPIdx[0][ui] = -1; |
---|
383 | m_apiMVPIdx[1][ui] = -1; |
---|
384 | m_apiMVPNum[0][ui] = -1; |
---|
385 | m_apiMVPNum[1][ui] = -1; |
---|
386 | } |
---|
387 | |
---|
388 | m_acCUMvField[0].clearMvField(); |
---|
389 | m_acCUMvField[1].clearMvField(); |
---|
390 | |
---|
391 | UInt uiTmp = m_puhWidth[0]*m_puhHeight[0]; |
---|
392 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
---|
393 | |
---|
394 | uiTmp >>= 2; |
---|
395 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
---|
396 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
---|
397 | |
---|
398 | // setting neighbor CU |
---|
399 | m_pcCULeft = NULL; |
---|
400 | m_pcCUAbove = NULL; |
---|
401 | m_pcCUAboveLeft = NULL; |
---|
402 | m_pcCUAboveRight = NULL; |
---|
403 | |
---|
404 | m_apcCUColocated[0] = NULL; |
---|
405 | m_apcCUColocated[1] = NULL; |
---|
406 | |
---|
407 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
---|
408 | if ( m_uiCUAddr % uiWidthInCU ) |
---|
409 | { |
---|
410 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
---|
411 | } |
---|
412 | |
---|
413 | if ( m_uiCUAddr / uiWidthInCU ) |
---|
414 | { |
---|
415 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
---|
416 | } |
---|
417 | |
---|
418 | if ( m_pcCULeft && m_pcCUAbove ) |
---|
419 | { |
---|
420 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
---|
421 | } |
---|
422 | |
---|
423 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
---|
424 | { |
---|
425 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
---|
426 | } |
---|
427 | |
---|
428 | if ( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
429 | { |
---|
430 | m_apcCUColocated[0] = pcSlice->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
---|
431 | } |
---|
432 | |
---|
433 | if ( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
434 | { |
---|
435 | m_apcCUColocated[1] = pcSlice->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
---|
436 | } |
---|
437 | |
---|
438 | #if HHI_DMM_WEDGE_INTRA |
---|
439 | memset( m_puiWedgeFullTabIdx, 0, iSizeInUInt ); |
---|
440 | memset( m_piWedgeFullDeltaDC1, 0, iSizeInInt ); |
---|
441 | memset( m_piWedgeFullDeltaDC2, 0, iSizeInInt ); |
---|
442 | |
---|
443 | memset( m_puiWedgePredDirTabIdx, 0, iSizeInUInt ); |
---|
444 | memset( m_piWedgePredDirDeltaDC1, 0, iSizeInInt ); |
---|
445 | memset( m_piWedgePredDirDeltaDC2, 0, iSizeInInt ); |
---|
446 | memset( m_piWedgePredDirDeltaEnd, 0, iSizeInInt ); |
---|
447 | #endif |
---|
448 | #if HHI_DMM_PRED_TEX |
---|
449 | memset( m_puiWedgePredTexTabIdx, 0, iSizeInUInt ); |
---|
450 | memset( m_piWedgePredTexDeltaDC1, 0, iSizeInInt ); |
---|
451 | memset( m_piWedgePredTexDeltaDC2, 0, iSizeInInt ); |
---|
452 | |
---|
453 | memset( m_piContourPredTexDeltaDC1, 0, iSizeInInt ); |
---|
454 | memset( m_piContourPredTexDeltaDC2, 0, iSizeInInt ); |
---|
455 | #endif |
---|
456 | } |
---|
457 | |
---|
458 | // initialize prediction data |
---|
459 | Void TComDataCU::initEstData() |
---|
460 | { |
---|
461 | m_dTotalCost = MAX_DOUBLE; |
---|
462 | m_uiTotalDistortion = 0; |
---|
463 | m_uiTotalBits = 0; |
---|
464 | |
---|
465 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
466 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
467 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
468 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
469 | memset( m_phQP, getSlice()->getSliceQp(), iSizeInUchar ); |
---|
470 | memset( m_puiAlfCtrlFlag, 0, iSizeInUInt ); |
---|
471 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
472 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
473 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
474 | memset( m_pbResPredAvailable, 0, iSizeInBool ); |
---|
475 | memset( m_pbResPredFlag, 0, iSizeInBool ); |
---|
476 | #endif |
---|
477 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
478 | { |
---|
479 | memset( m_apuhNeighbourCandIdx[ ui ], 0, iSizeInUchar ); |
---|
480 | } |
---|
481 | memset( m_puhLumaIntraDir, 2, iSizeInUchar ); |
---|
482 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
483 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
484 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
485 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
486 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
487 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
488 | |
---|
489 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
490 | { |
---|
491 | m_pePartSize[ui] = SIZE_NONE; |
---|
492 | m_pePredMode[ui] = MODE_NONE; |
---|
493 | |
---|
494 | m_apiMVPIdx[0][ui] = -1; |
---|
495 | m_apiMVPIdx[1][ui] = -1; |
---|
496 | m_apiMVPNum[0][ui] = -1; |
---|
497 | m_apiMVPNum[1][ui] = -1; |
---|
498 | } |
---|
499 | |
---|
500 | UInt uiTmp = m_puhWidth[0]*m_puhHeight[0]; |
---|
501 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
502 | |
---|
503 | uiTmp >>= 2; |
---|
504 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
505 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
506 | |
---|
507 | m_acCUMvField[0].clearMvField(); |
---|
508 | m_acCUMvField[1].clearMvField(); |
---|
509 | |
---|
510 | #if HHI_DMM_WEDGE_INTRA |
---|
511 | memset( m_puiWedgeFullTabIdx, 0, iSizeInUInt ); |
---|
512 | memset( m_piWedgeFullDeltaDC1, 0, iSizeInInt ); |
---|
513 | memset( m_piWedgeFullDeltaDC2, 0, iSizeInInt ); |
---|
514 | |
---|
515 | memset( m_puiWedgePredDirTabIdx, 0, iSizeInUInt ); |
---|
516 | memset( m_piWedgePredDirDeltaDC1, 0, iSizeInInt ); |
---|
517 | memset( m_piWedgePredDirDeltaDC2, 0, iSizeInInt ); |
---|
518 | memset( m_piWedgePredDirDeltaEnd, 0, iSizeInInt ); |
---|
519 | #endif |
---|
520 | #if HHI_DMM_PRED_TEX |
---|
521 | memset( m_puiWedgePredTexTabIdx, 0, iSizeInUInt ); |
---|
522 | memset( m_piWedgePredTexDeltaDC1, 0, iSizeInInt ); |
---|
523 | memset( m_piWedgePredTexDeltaDC2, 0, iSizeInInt ); |
---|
524 | |
---|
525 | memset( m_piContourPredTexDeltaDC1, 0, iSizeInInt ); |
---|
526 | memset( m_piContourPredTexDeltaDC2, 0, iSizeInInt ); |
---|
527 | #endif |
---|
528 | |
---|
529 | #if HHI_MPI |
---|
530 | memset( m_piTextureModeDepth, -1, iSizeInInt ); |
---|
531 | #endif |
---|
532 | } |
---|
533 | |
---|
534 | // initialize Sub partition |
---|
535 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
536 | { |
---|
537 | assert( uiPartUnitIdx<4 ); |
---|
538 | |
---|
539 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
540 | |
---|
541 | m_pcPic = pcCU->getPic(); |
---|
542 | m_pcSlice = pcCU->getSlice(); |
---|
543 | m_uiCUAddr = pcCU->getAddr(); |
---|
544 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
---|
545 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth >> uiDepth )*( uiPartUnitIdx & 1 ); |
---|
546 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight >> uiDepth )*( uiPartUnitIdx >> 1 ); |
---|
547 | |
---|
548 | m_dTotalCost = MAX_DOUBLE; |
---|
549 | m_uiTotalDistortion = 0; |
---|
550 | m_uiTotalBits = 0; |
---|
551 | |
---|
552 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
553 | |
---|
554 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
555 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
556 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
557 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
558 | |
---|
559 | memset( m_phQP, getSlice()->getSliceQp(), iSizeInUchar ); |
---|
560 | memset( m_puiAlfCtrlFlag, 0, iSizeInUInt ); |
---|
561 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
562 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
563 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
564 | memset( m_pbResPredAvailable, 0, iSizeInBool ); |
---|
565 | memset( m_pbResPredFlag, 0, iSizeInBool ); |
---|
566 | #endif |
---|
567 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
568 | { |
---|
569 | memset( m_apuhNeighbourCandIdx[ ui ], 0, iSizeInUchar ); |
---|
570 | } |
---|
571 | memset( m_puhLumaIntraDir, 2, iSizeInUchar ); |
---|
572 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
573 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
574 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
575 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
576 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
577 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
578 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
579 | #if HHI_MPI |
---|
580 | memset( m_piTextureModeDepth, -1, iSizeInInt ); |
---|
581 | #endif |
---|
582 | |
---|
583 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
584 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
585 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
586 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
587 | |
---|
588 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
589 | { |
---|
590 | m_pePartSize[ui] = SIZE_NONE; |
---|
591 | m_pePredMode[ui] = MODE_NONE; |
---|
592 | |
---|
593 | m_apiMVPIdx[0][ui] = -1; |
---|
594 | m_apiMVPIdx[1][ui] = -1; |
---|
595 | m_apiMVPNum[0][ui] = -1; |
---|
596 | m_apiMVPNum[1][ui] = -1; |
---|
597 | } |
---|
598 | |
---|
599 | UInt uiTmp = m_puhWidth[0]*m_puhHeight[0]; |
---|
600 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
601 | |
---|
602 | uiTmp >>= 2; |
---|
603 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
604 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
605 | |
---|
606 | m_pcCULeft = pcCU->getCULeft(); |
---|
607 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
608 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
609 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
610 | |
---|
611 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
612 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
613 | |
---|
614 | m_acCUMvField[0].clearMvField(); |
---|
615 | m_acCUMvField[1].clearMvField(); |
---|
616 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
617 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
618 | |
---|
619 | #if HHI_DMM_WEDGE_INTRA |
---|
620 | memset( m_puiWedgeFullTabIdx, 0, iSizeInUInt ); |
---|
621 | memset( m_piWedgeFullDeltaDC1, 0, iSizeInInt ); |
---|
622 | memset( m_piWedgeFullDeltaDC2, 0, iSizeInInt ); |
---|
623 | |
---|
624 | memset( m_puiWedgePredDirTabIdx, 0, iSizeInUInt ); |
---|
625 | memset( m_piWedgePredDirDeltaDC1, 0, iSizeInInt ); |
---|
626 | memset( m_piWedgePredDirDeltaDC2, 0, iSizeInInt ); |
---|
627 | memset( m_piWedgePredDirDeltaEnd, 0, iSizeInInt ); |
---|
628 | #endif |
---|
629 | #if HHI_DMM_PRED_TEX |
---|
630 | memset( m_puiWedgePredTexTabIdx, 0, iSizeInUInt ); |
---|
631 | memset( m_piWedgePredTexDeltaDC1, 0, iSizeInInt ); |
---|
632 | memset( m_piWedgePredTexDeltaDC2, 0, iSizeInInt ); |
---|
633 | |
---|
634 | memset( m_piContourPredTexDeltaDC1, 0, iSizeInInt ); |
---|
635 | memset( m_piContourPredTexDeltaDC2, 0, iSizeInInt ); |
---|
636 | #endif |
---|
637 | } |
---|
638 | |
---|
639 | // -------------------------------------------------------------------------------------------------------------------- |
---|
640 | // Copy |
---|
641 | // -------------------------------------------------------------------------------------------------------------------- |
---|
642 | |
---|
643 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
644 | { |
---|
645 | UInt uiPart = uiAbsPartIdx; |
---|
646 | |
---|
647 | m_pcPic = pcCU->getPic(); |
---|
648 | m_pcSlice = pcCU->getSlice(); |
---|
649 | m_uiCUAddr = pcCU->getAddr(); |
---|
650 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
651 | |
---|
652 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
653 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
654 | |
---|
655 | UInt uiWidth = g_uiMaxCUWidth >> uiDepth; |
---|
656 | UInt uiHeight = g_uiMaxCUHeight >> uiDepth; |
---|
657 | |
---|
658 | m_phQP=pcCU->getQP() + uiPart; |
---|
659 | m_pePartSize=pcCU->getPartitionSize() + uiPart; |
---|
660 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
661 | |
---|
662 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
663 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
664 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
665 | m_pbResPredAvailable = pcCU->getResPredAvail() + uiPart; |
---|
666 | m_pbResPredFlag = pcCU->getResPredFlag () + uiPart; |
---|
667 | #endif |
---|
668 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
669 | { |
---|
670 | m_apuhNeighbourCandIdx[ ui ] = pcCU->getNeighbourCandIdx( ui ) + uiPart; |
---|
671 | } |
---|
672 | |
---|
673 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
---|
674 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
---|
675 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
676 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
677 | |
---|
678 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
---|
679 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
---|
680 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
---|
681 | |
---|
682 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
683 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
684 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
685 | #if HHI_MPI |
---|
686 | m_piTextureModeDepth=pcCU->getTextureModeDepth()+ uiPart; |
---|
687 | #endif |
---|
688 | |
---|
689 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
---|
690 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
---|
691 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
---|
692 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
---|
693 | |
---|
694 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
695 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
696 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
697 | m_pcCULeft = pcCU->getCULeft(); |
---|
698 | |
---|
699 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
700 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
701 | |
---|
702 | UInt uiTmp = uiWidth*uiHeight; |
---|
703 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
704 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
705 | |
---|
706 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
---|
707 | |
---|
708 | m_pcTrCoeffY=pcCU->getCoeffY() + uiCoffOffset; |
---|
709 | |
---|
710 | uiTmp >>= 2; |
---|
711 | uiCoffOffset >>=2; |
---|
712 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
---|
713 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
---|
714 | |
---|
715 | m_acCUMvField[0].setMvPtr(pcCU->getCUMvField(REF_PIC_LIST_0)->getMv() + uiPart); |
---|
716 | m_acCUMvField[0].setMvdPtr(pcCU->getCUMvField(REF_PIC_LIST_0)->getMvd() + uiPart); |
---|
717 | m_acCUMvField[0].setRefIdxPtr(pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx() + uiPart); |
---|
718 | m_acCUMvField[1].setMvPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getMv() + uiPart); |
---|
719 | m_acCUMvField[1].setMvdPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getMvd() + uiPart); |
---|
720 | m_acCUMvField[1].setRefIdxPtr(pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx() + uiPart); |
---|
721 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
722 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
723 | |
---|
724 | #if HHI_DMM_WEDGE_INTRA |
---|
725 | m_puiWedgeFullTabIdx = pcCU->getWedgeFullTabIdx() + uiPart; |
---|
726 | m_piWedgeFullDeltaDC1 = pcCU->getWedgeFullDeltaDC1() + uiPart; |
---|
727 | m_piWedgeFullDeltaDC2 = pcCU->getWedgeFullDeltaDC2() + uiPart; |
---|
728 | |
---|
729 | m_puiWedgePredDirTabIdx = pcCU->getWedgePredDirTabIdx() + uiPart; |
---|
730 | m_piWedgePredDirDeltaDC1 = pcCU->getWedgePredDirDeltaDC1() + uiPart; |
---|
731 | m_piWedgePredDirDeltaDC2 = pcCU->getWedgePredDirDeltaDC2() + uiPart; |
---|
732 | m_piWedgePredDirDeltaEnd = pcCU->getWedgePredDirDeltaEnd() + uiPart; |
---|
733 | #endif |
---|
734 | #if HHI_DMM_PRED_TEX |
---|
735 | m_puiWedgePredTexTabIdx = pcCU->getWedgePredTexTabIdx() + uiPart; |
---|
736 | m_piWedgePredTexDeltaDC1 = pcCU->getWedgePredTexDeltaDC1() + uiPart; |
---|
737 | m_piWedgePredTexDeltaDC2 = pcCU->getWedgePredTexDeltaDC2() + uiPart; |
---|
738 | |
---|
739 | m_piContourPredTexDeltaDC1 = pcCU->getContourPredTexDeltaDC1() + uiPart; |
---|
740 | m_piContourPredTexDeltaDC2 = pcCU->getContourPredTexDeltaDC2() + uiPart; |
---|
741 | #endif |
---|
742 | } |
---|
743 | |
---|
744 | // Copy inter prediction info from the biggest CU |
---|
745 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
746 | { |
---|
747 | m_pcPic = pcCU->getPic(); |
---|
748 | m_pcSlice = pcCU->getSlice(); |
---|
749 | m_uiCUAddr = pcCU->getAddr(); |
---|
750 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
751 | |
---|
752 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
753 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
---|
754 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
---|
755 | |
---|
756 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
757 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
758 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
759 | m_pcCULeft = pcCU->getCULeft(); |
---|
760 | |
---|
761 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
762 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
763 | |
---|
764 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
765 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
766 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
767 | |
---|
768 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
769 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
770 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
771 | |
---|
772 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
773 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
774 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
775 | m_pbResPredAvailable = pcCU->getResPredAvail() + uiAbsPartIdx; |
---|
776 | m_pbResPredFlag = pcCU->getResPredFlag () + uiAbsPartIdx; |
---|
777 | #endif |
---|
778 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui ++ ) |
---|
779 | { |
---|
780 | m_apuhNeighbourCandIdx[ui] = pcCU->getNeighbourCandIdx( ui ) + uiAbsPartIdx; |
---|
781 | } |
---|
782 | |
---|
783 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
784 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
785 | |
---|
786 | m_acCUMvField[eRefPicList].setMvPtr(pcCU->getCUMvField(eRefPicList)->getMv() + uiAbsPartIdx); |
---|
787 | m_acCUMvField[eRefPicList].setMvdPtr(pcCU->getCUMvField(eRefPicList)->getMvd() + uiAbsPartIdx); |
---|
788 | m_acCUMvField[eRefPicList].setRefIdxPtr(pcCU->getCUMvField(eRefPicList)->getRefIdx() + uiAbsPartIdx); |
---|
789 | #if HHI_MPI |
---|
790 | m_piTextureModeDepth = pcCU->getTextureModeDepth() + uiAbsPartIdx; |
---|
791 | #endif |
---|
792 | |
---|
793 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
794 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
795 | } |
---|
796 | |
---|
797 | // Copy small CU to bigger CU. |
---|
798 | // One of quarter parts overwritten by predicted sub part. |
---|
799 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
800 | { |
---|
801 | assert( uiPartUnitIdx<4 ); |
---|
802 | |
---|
803 | m_dTotalCost += pcCU->getTotalCost(); |
---|
804 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
805 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
806 | |
---|
807 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
808 | |
---|
809 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
810 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
811 | Int iSizeInUInt = sizeof( UInt ) * uiNumPartition; |
---|
812 | Int iSizeInInt = sizeof( Int ) * uiNumPartition; |
---|
813 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
814 | |
---|
815 | memcpy( m_phQP + uiOffset, pcCU->getQP(), iSizeInUchar ); |
---|
816 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( PartSize ) * uiNumPartition ); |
---|
817 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( PredMode ) * uiNumPartition ); |
---|
818 | |
---|
819 | memcpy( m_puiAlfCtrlFlag + uiOffset, pcCU->getAlfCtrlFlag(), iSizeInUInt ); |
---|
820 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
821 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
822 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
823 | memcpy( m_pbResPredAvailable + uiOffset, pcCU->getResPredAvail(), iSizeInBool ); |
---|
824 | memcpy( m_pbResPredFlag + uiOffset, pcCU->getResPredFlag(), iSizeInBool ); |
---|
825 | #endif |
---|
826 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
827 | { |
---|
828 | memcpy( m_apuhNeighbourCandIdx[ ui ] + uiOffset, pcCU->getNeighbourCandIdx( ui ), iSizeInUchar ); |
---|
829 | } |
---|
830 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
---|
831 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
---|
832 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
833 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
834 | |
---|
835 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
---|
836 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
---|
837 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
---|
838 | |
---|
839 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
840 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
841 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
842 | |
---|
843 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInInt ); |
---|
844 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInInt ); |
---|
845 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInInt ); |
---|
846 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInInt ); |
---|
847 | |
---|
848 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
849 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
850 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
851 | m_pcCULeft = pcCU->getCULeft(); |
---|
852 | |
---|
853 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
854 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
855 | |
---|
856 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
857 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
858 | |
---|
859 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
---|
860 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
---|
861 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
---|
862 | |
---|
863 | uiTmp >>= 2; uiTmp2>>= 2; |
---|
864 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
---|
865 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
---|
866 | m_uiSliceStartCU = pcCU->getSliceStartCU(); |
---|
867 | m_uiEntropySliceStartCU = pcCU->getEntropySliceStartCU(); |
---|
868 | |
---|
869 | #if HHI_DMM_WEDGE_INTRA |
---|
870 | memcpy( m_puiWedgeFullTabIdx + uiOffset, pcCU->getWedgeFullTabIdx(), iSizeInUInt ); |
---|
871 | memcpy( m_piWedgeFullDeltaDC1 + uiOffset, pcCU->getWedgeFullDeltaDC1(), iSizeInInt ); |
---|
872 | memcpy( m_piWedgeFullDeltaDC2 + uiOffset, pcCU->getWedgeFullDeltaDC2(), iSizeInInt ); |
---|
873 | |
---|
874 | memcpy( m_puiWedgePredDirTabIdx + uiOffset, pcCU->getWedgePredDirTabIdx(), iSizeInUInt ); |
---|
875 | memcpy( m_piWedgePredDirDeltaDC1 + uiOffset, pcCU->getWedgePredDirDeltaDC1(), iSizeInInt ); |
---|
876 | memcpy( m_piWedgePredDirDeltaDC2 + uiOffset, pcCU->getWedgePredDirDeltaDC2(), iSizeInInt ); |
---|
877 | memcpy( m_piWedgePredDirDeltaEnd + uiOffset, pcCU->getWedgePredDirDeltaEnd(), iSizeInInt ); |
---|
878 | #endif |
---|
879 | #if HHI_DMM_PRED_TEX |
---|
880 | memcpy( m_puiWedgePredTexTabIdx + uiOffset, pcCU->getWedgePredTexTabIdx(), iSizeInUInt ); |
---|
881 | memcpy( m_piWedgePredTexDeltaDC1 + uiOffset, pcCU->getWedgePredTexDeltaDC1(), iSizeInInt ); |
---|
882 | memcpy( m_piWedgePredTexDeltaDC2 + uiOffset, pcCU->getWedgePredTexDeltaDC2(), iSizeInInt ); |
---|
883 | |
---|
884 | memcpy( m_piContourPredTexDeltaDC1 + uiOffset, pcCU->getContourPredTexDeltaDC1(), iSizeInInt ); |
---|
885 | memcpy( m_piContourPredTexDeltaDC2 + uiOffset, pcCU->getContourPredTexDeltaDC2(), iSizeInInt ); |
---|
886 | #endif |
---|
887 | |
---|
888 | #if HHI_MPI |
---|
889 | memcpy( m_piTextureModeDepth + uiOffset, pcCU->getTextureModeDepth(), iSizeInInt ); |
---|
890 | #endif |
---|
891 | } |
---|
892 | |
---|
893 | // Copy current predicted part to a CU in picture. |
---|
894 | // It is used to predict for next part |
---|
895 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
896 | { |
---|
897 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
898 | |
---|
899 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
900 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
901 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
902 | |
---|
903 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
904 | Int iSizeInUInt = sizeof( UInt ) * m_uiNumPartition; |
---|
905 | Int iSizeInInt = sizeof( Int ) * m_uiNumPartition; |
---|
906 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
907 | |
---|
908 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, iSizeInUchar ); |
---|
909 | |
---|
910 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( PartSize ) * m_uiNumPartition ); |
---|
911 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( PredMode ) * m_uiNumPartition ); |
---|
912 | |
---|
913 | memcpy( rpcCU->getAlfCtrlFlag() + m_uiAbsIdxInLCU, m_puiAlfCtrlFlag, iSizeInUInt ); |
---|
914 | |
---|
915 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
---|
916 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
---|
917 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
918 | memcpy( rpcCU->getResPredAvail() + m_uiAbsIdxInLCU, m_pbResPredAvailable, iSizeInBool ); |
---|
919 | memcpy( rpcCU->getResPredFlag() + m_uiAbsIdxInLCU, m_pbResPredFlag, iSizeInBool ); |
---|
920 | #endif |
---|
921 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
922 | { |
---|
923 | memcpy( rpcCU->getNeighbourCandIdx( ui ) + m_uiAbsIdxInLCU, m_apuhNeighbourCandIdx[ui], iSizeInUchar ); |
---|
924 | } |
---|
925 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
---|
926 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
---|
927 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
---|
928 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
---|
929 | |
---|
930 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
---|
931 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
---|
932 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
---|
933 | |
---|
934 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
---|
935 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
---|
936 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
---|
937 | |
---|
938 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInInt ); |
---|
939 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInInt ); |
---|
940 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInInt ); |
---|
941 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInInt ); |
---|
942 | |
---|
943 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
---|
944 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
---|
945 | |
---|
946 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
---|
947 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
948 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
949 | |
---|
950 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
951 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
952 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
953 | rpcCU->setSliceStartCU( m_uiSliceStartCU ); |
---|
954 | rpcCU->setEntropySliceStartCU( m_uiEntropySliceStartCU ); |
---|
955 | |
---|
956 | #if HHI_DMM_WEDGE_INTRA |
---|
957 | memcpy( rpcCU->getWedgeFullTabIdx() + m_uiAbsIdxInLCU, m_puiWedgeFullTabIdx, iSizeInUInt ); |
---|
958 | memcpy( rpcCU->getWedgeFullDeltaDC1() + m_uiAbsIdxInLCU, m_piWedgeFullDeltaDC1, iSizeInInt ); |
---|
959 | memcpy( rpcCU->getWedgeFullDeltaDC2() + m_uiAbsIdxInLCU, m_piWedgeFullDeltaDC2, iSizeInInt ); |
---|
960 | |
---|
961 | memcpy( rpcCU->getWedgePredDirTabIdx() + m_uiAbsIdxInLCU, m_puiWedgePredDirTabIdx, iSizeInUInt ); |
---|
962 | memcpy( rpcCU->getWedgePredDirDeltaDC1() + m_uiAbsIdxInLCU, m_piWedgePredDirDeltaDC1, iSizeInInt ); |
---|
963 | memcpy( rpcCU->getWedgePredDirDeltaDC2() + m_uiAbsIdxInLCU, m_piWedgePredDirDeltaDC2, iSizeInInt ); |
---|
964 | memcpy( rpcCU->getWedgePredDirDeltaEnd() + m_uiAbsIdxInLCU, m_piWedgePredDirDeltaEnd, iSizeInInt ); |
---|
965 | #endif |
---|
966 | #if HHI_DMM_PRED_TEX |
---|
967 | memcpy( rpcCU->getWedgePredTexTabIdx() + m_uiAbsIdxInLCU, m_puiWedgePredTexTabIdx, iSizeInUInt ); |
---|
968 | memcpy( rpcCU->getWedgePredTexDeltaDC1() + m_uiAbsIdxInLCU, m_piWedgePredTexDeltaDC1, iSizeInInt ); |
---|
969 | memcpy( rpcCU->getWedgePredTexDeltaDC2() + m_uiAbsIdxInLCU, m_piWedgePredTexDeltaDC2, iSizeInInt ); |
---|
970 | |
---|
971 | memcpy( rpcCU->getContourPredTexDeltaDC1() + m_uiAbsIdxInLCU, m_piContourPredTexDeltaDC1, iSizeInInt ); |
---|
972 | memcpy( rpcCU->getContourPredTexDeltaDC2() + m_uiAbsIdxInLCU, m_piContourPredTexDeltaDC2, iSizeInInt ); |
---|
973 | #endif |
---|
974 | |
---|
975 | #if HHI_MPI |
---|
976 | memcpy( rpcCU->getTextureModeDepth() + m_uiAbsIdxInLCU, m_piTextureModeDepth, iSizeInInt ); |
---|
977 | #endif |
---|
978 | } |
---|
979 | |
---|
980 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
---|
981 | { |
---|
982 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
983 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
---|
984 | |
---|
985 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
---|
986 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
---|
987 | |
---|
988 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
989 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
990 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
991 | |
---|
992 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
---|
993 | Int iSizeInUInt = sizeof( UInt ) * uiQNumPart; |
---|
994 | Int iSizeInInt = sizeof( Int ) * uiQNumPart; |
---|
995 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
---|
996 | |
---|
997 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, iSizeInUchar ); |
---|
998 | |
---|
999 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( PartSize ) * uiQNumPart ); |
---|
1000 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( PredMode ) * uiQNumPart ); |
---|
1001 | |
---|
1002 | memcpy( rpcCU->getAlfCtrlFlag() + uiPartOffset, m_puiAlfCtrlFlag, iSizeInUInt ); |
---|
1003 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
---|
1004 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
---|
1005 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1006 | memcpy( rpcCU->getResPredAvail() + uiPartOffset, m_pbResPredAvailable, iSizeInBool ); |
---|
1007 | memcpy( rpcCU->getResPredFlag() + uiPartOffset, m_pbResPredFlag, iSizeInBool ); |
---|
1008 | #endif |
---|
1009 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
1010 | { |
---|
1011 | memcpy( rpcCU->getNeighbourCandIdx( ui ) + uiPartOffset, m_apuhNeighbourCandIdx[ui], iSizeInUchar ); |
---|
1012 | } |
---|
1013 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
---|
1014 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
---|
1015 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
---|
1016 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
---|
1017 | |
---|
1018 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
---|
1019 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
---|
1020 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
---|
1021 | |
---|
1022 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
---|
1023 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
---|
1024 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
---|
1025 | |
---|
1026 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInInt ); |
---|
1027 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInInt ); |
---|
1028 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInInt ); |
---|
1029 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInInt ); |
---|
1030 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1031 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
1032 | |
---|
1033 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
---|
1034 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
1035 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
1036 | |
---|
1037 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
1038 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
1039 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
1040 | rpcCU->setSliceStartCU( m_uiSliceStartCU ); |
---|
1041 | rpcCU->setEntropySliceStartCU( m_uiEntropySliceStartCU ); |
---|
1042 | |
---|
1043 | #if HHI_DMM_WEDGE_INTRA |
---|
1044 | memcpy( rpcCU->getWedgeFullTabIdx() + uiPartOffset, m_puiWedgeFullTabIdx, iSizeInUInt ); |
---|
1045 | memcpy( rpcCU->getWedgeFullDeltaDC1() + uiPartOffset, m_piWedgeFullDeltaDC1, iSizeInInt ); |
---|
1046 | memcpy( rpcCU->getWedgeFullDeltaDC2() + uiPartOffset, m_piWedgeFullDeltaDC2, iSizeInInt ); |
---|
1047 | |
---|
1048 | memcpy( rpcCU->getWedgePredDirTabIdx() + uiPartOffset, m_puiWedgePredDirTabIdx, iSizeInUInt ); |
---|
1049 | memcpy( rpcCU->getWedgePredDirDeltaDC1() + uiPartOffset, m_piWedgePredDirDeltaDC1, iSizeInInt ); |
---|
1050 | memcpy( rpcCU->getWedgePredDirDeltaDC2() + uiPartOffset, m_piWedgePredDirDeltaDC2, iSizeInInt ); |
---|
1051 | memcpy( rpcCU->getWedgePredDirDeltaEnd() + uiPartOffset, m_piWedgePredDirDeltaEnd, iSizeInInt ); |
---|
1052 | #endif |
---|
1053 | #if HHI_DMM_PRED_TEX |
---|
1054 | memcpy( rpcCU->getWedgePredTexTabIdx() + uiPartOffset, m_puiWedgePredTexTabIdx, iSizeInUInt ); |
---|
1055 | memcpy( rpcCU->getWedgePredTexDeltaDC1() + uiPartOffset, m_piWedgePredTexDeltaDC1, iSizeInInt ); |
---|
1056 | memcpy( rpcCU->getWedgePredTexDeltaDC2() + uiPartOffset, m_piWedgePredTexDeltaDC2, iSizeInInt ); |
---|
1057 | |
---|
1058 | memcpy( rpcCU->getContourPredTexDeltaDC1() + uiPartOffset, m_piContourPredTexDeltaDC1, iSizeInInt ); |
---|
1059 | memcpy( rpcCU->getContourPredTexDeltaDC2() + uiPartOffset, m_piContourPredTexDeltaDC2, iSizeInInt ); |
---|
1060 | #endif |
---|
1061 | |
---|
1062 | #if HHI_MPI |
---|
1063 | memcpy( rpcCU->getTextureModeDepth() + uiPartOffset, m_piTextureModeDepth, iSizeInInt ); |
---|
1064 | #endif |
---|
1065 | } |
---|
1066 | |
---|
1067 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1068 | // Other public functions |
---|
1069 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1070 | |
---|
1071 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1072 | { |
---|
1073 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1074 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1075 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1076 | |
---|
1077 | if( uiAbsPartIdx % uiNumPartInCUWidth ) |
---|
1078 | { |
---|
1079 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1080 | if ( uiAbsPartIdx % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) |
---|
1081 | { |
---|
1082 | return m_pcPic->getCU( getAddr() ); |
---|
1083 | } |
---|
1084 | else |
---|
1085 | { |
---|
1086 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1087 | return this; |
---|
1088 | } |
---|
1089 | } |
---|
1090 | |
---|
1091 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
---|
1092 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1093 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1094 | { |
---|
1095 | return NULL; |
---|
1096 | } |
---|
1097 | return m_pcCULeft; |
---|
1098 | } |
---|
1099 | |
---|
1100 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1101 | { |
---|
1102 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1103 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1104 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1105 | |
---|
1106 | if( uiAbsPartIdx / uiNumPartInCUWidth ) |
---|
1107 | { |
---|
1108 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
---|
1109 | if ( uiAbsPartIdx / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) |
---|
1110 | { |
---|
1111 | return m_pcPic->getCU( getAddr() ); |
---|
1112 | } |
---|
1113 | else |
---|
1114 | { |
---|
1115 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1116 | return this; |
---|
1117 | } |
---|
1118 | } |
---|
1119 | |
---|
1120 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1121 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1122 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1123 | { |
---|
1124 | return NULL; |
---|
1125 | } |
---|
1126 | return m_pcCUAbove; |
---|
1127 | } |
---|
1128 | |
---|
1129 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1130 | { |
---|
1131 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1132 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
1133 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1134 | |
---|
1135 | if( uiAbsPartIdx % uiNumPartInCUWidth ) |
---|
1136 | { |
---|
1137 | if( uiAbsPartIdx / uiNumPartInCUWidth ) |
---|
1138 | { |
---|
1139 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
---|
1140 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) || ( uiAbsPartIdx / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) ) |
---|
1141 | { |
---|
1142 | return m_pcPic->getCU( getAddr() ); |
---|
1143 | } |
---|
1144 | else |
---|
1145 | { |
---|
1146 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1147 | return this; |
---|
1148 | } |
---|
1149 | } |
---|
1150 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
---|
1151 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1152 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1153 | { |
---|
1154 | return NULL; |
---|
1155 | } |
---|
1156 | return m_pcCUAbove; |
---|
1157 | } |
---|
1158 | |
---|
1159 | if( uiAbsPartIdx / uiNumPartInCUWidth ) |
---|
1160 | { |
---|
1161 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
1162 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1163 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1164 | { |
---|
1165 | return NULL; |
---|
1166 | } |
---|
1167 | return m_pcCULeft; |
---|
1168 | } |
---|
1169 | |
---|
1170 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
---|
1171 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || m_pcCUAboveLeft->getAddr() < m_uiSliceStartCU)) || |
---|
1172 | (bEnforceEntropySliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL|| m_pcCUAboveLeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1173 | { |
---|
1174 | return NULL; |
---|
1175 | } |
---|
1176 | return m_pcCUAboveLeft; |
---|
1177 | } |
---|
1178 | |
---|
1179 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1180 | { |
---|
1181 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1182 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
---|
1183 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1184 | |
---|
1185 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getWidth() ) |
---|
1186 | { |
---|
1187 | uiARPartUnitIdx = MAX_UINT; |
---|
1188 | return NULL; |
---|
1189 | } |
---|
1190 | |
---|
1191 | if ( uiAbsPartIdxRT % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) |
---|
1192 | { |
---|
1193 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1194 | { |
---|
1195 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1196 | { |
---|
1197 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1198 | if ( ( uiAbsPartIdxRT % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) || ( uiAbsPartIdxRT / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) ) |
---|
1199 | { |
---|
1200 | return m_pcPic->getCU( getAddr() ); |
---|
1201 | } |
---|
1202 | else |
---|
1203 | { |
---|
1204 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1205 | return this; |
---|
1206 | } |
---|
1207 | } |
---|
1208 | uiARPartUnitIdx = MAX_UINT; |
---|
1209 | return NULL; |
---|
1210 | } |
---|
1211 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1212 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1213 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1214 | { |
---|
1215 | return NULL; |
---|
1216 | } |
---|
1217 | return m_pcCUAbove; |
---|
1218 | } |
---|
1219 | |
---|
1220 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1221 | { |
---|
1222 | uiARPartUnitIdx = MAX_UINT; |
---|
1223 | return NULL; |
---|
1224 | } |
---|
1225 | |
---|
1226 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1227 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiSliceStartCU)) || |
---|
1228 | (bEnforceEntropySliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1229 | { |
---|
1230 | return NULL; |
---|
1231 | } |
---|
1232 | return m_pcCUAboveRight; |
---|
1233 | } |
---|
1234 | |
---|
1235 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1236 | { |
---|
1237 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1238 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
---|
1239 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1240 | |
---|
1241 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
1242 | { |
---|
1243 | uiBLPartUnitIdx = MAX_UINT; |
---|
1244 | return NULL; |
---|
1245 | } |
---|
1246 | |
---|
1247 | if ( uiAbsPartIdxLB / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) |
---|
1248 | { |
---|
1249 | if ( uiAbsPartIdxLB % uiNumPartInCUWidth ) |
---|
1250 | { |
---|
1251 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1252 | { |
---|
1253 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1254 | if ( ( (uiAbsPartIdxLB % uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB % uiNumPartInCUWidth) ) || ( (uiAbsPartIdxLB / uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB / uiNumPartInCUWidth) ) ) |
---|
1255 | { |
---|
1256 | return m_pcPic->getCU( getAddr() ); |
---|
1257 | } |
---|
1258 | else |
---|
1259 | { |
---|
1260 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1261 | return this; |
---|
1262 | } |
---|
1263 | } |
---|
1264 | uiBLPartUnitIdx = MAX_UINT; |
---|
1265 | return NULL; |
---|
1266 | } |
---|
1267 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1268 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1269 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1270 | { |
---|
1271 | return NULL; |
---|
1272 | } |
---|
1273 | return m_pcCULeft; |
---|
1274 | } |
---|
1275 | |
---|
1276 | uiBLPartUnitIdx = MAX_UINT; |
---|
1277 | return NULL; |
---|
1278 | } |
---|
1279 | |
---|
1280 | #if CONSTRAINED_INTRA_PRED |
---|
1281 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiPuHeight, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1282 | #else //CONSTRAINED_INTRA_PRED |
---|
1283 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiPuHeight, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1284 | #endif //CONSTRAINED_INTRA_PRED |
---|
1285 | { |
---|
1286 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1287 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
---|
1288 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1289 | |
---|
1290 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + uiPuHeight ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
1291 | { |
---|
1292 | uiBLPartUnitIdx = MAX_UINT; |
---|
1293 | return NULL; |
---|
1294 | } |
---|
1295 | |
---|
1296 | #if CONSTRAINED_INTRA_PRED |
---|
1297 | if ( uiAbsPartIdxLB / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - uiPartUnitOffset ) |
---|
1298 | #else |
---|
1299 | if ( uiAbsPartIdxLB / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) |
---|
1300 | #endif |
---|
1301 | { |
---|
1302 | if ( uiAbsPartIdxLB % uiNumPartInCUWidth ) |
---|
1303 | { |
---|
1304 | #if CONSTRAINED_INTRA_PRED |
---|
1305 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
---|
1306 | #else |
---|
1307 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
1308 | #endif |
---|
1309 | { |
---|
1310 | #if CONSTRAINED_INTRA_PRED |
---|
1311 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
---|
1312 | #else |
---|
1313 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
1314 | #endif |
---|
1315 | if ( ( (uiAbsPartIdxLB % uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB % uiNumPartInCUWidth) ) || ( (uiAbsPartIdxLB / uiNumPartInCUWidth) == (uiAbsZorderCUIdxLB / uiNumPartInCUWidth) ) ) |
---|
1316 | { |
---|
1317 | return m_pcPic->getCU( getAddr() ); |
---|
1318 | } |
---|
1319 | else |
---|
1320 | { |
---|
1321 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1322 | return this; |
---|
1323 | } |
---|
1324 | } |
---|
1325 | uiBLPartUnitIdx = MAX_UINT; |
---|
1326 | return NULL; |
---|
1327 | } |
---|
1328 | #if CONSTRAINED_INTRA_PRED |
---|
1329 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
---|
1330 | #else |
---|
1331 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
1332 | #endif |
---|
1333 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiSliceStartCU)) || |
---|
1334 | (bEnforceEntropySliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1335 | { |
---|
1336 | return NULL; |
---|
1337 | } |
---|
1338 | return m_pcCULeft; |
---|
1339 | } |
---|
1340 | |
---|
1341 | uiBLPartUnitIdx = MAX_UINT; |
---|
1342 | return NULL; |
---|
1343 | } |
---|
1344 | |
---|
1345 | #if CONSTRAINED_INTRA_PRED |
---|
1346 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiPuWidth, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1347 | #else //CONSTRAINED_INTRA_PRED |
---|
1348 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiPuWidth, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction, Bool bEnforceEntropySliceRestriction ) |
---|
1349 | #endif //CONSTRAINED_INTRA_PRED |
---|
1350 | { |
---|
1351 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
1352 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
1353 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
1354 | |
---|
1355 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + uiPuWidth ) >= m_pcSlice->getSPS()->getWidth() ) |
---|
1356 | { |
---|
1357 | uiARPartUnitIdx = MAX_UINT; |
---|
1358 | return NULL; |
---|
1359 | } |
---|
1360 | |
---|
1361 | #if CONSTRAINED_INTRA_PRED |
---|
1362 | if ( uiAbsPartIdxRT % uiNumPartInCUWidth < uiNumPartInCUWidth - uiPartUnitOffset ) |
---|
1363 | #else |
---|
1364 | if ( uiAbsPartIdxRT % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) |
---|
1365 | #endif |
---|
1366 | { |
---|
1367 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1368 | { |
---|
1369 | #if CONSTRAINED_INTRA_PRED |
---|
1370 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
---|
1371 | #else |
---|
1372 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
1373 | #endif |
---|
1374 | { |
---|
1375 | #if CONSTRAINED_INTRA_PRED |
---|
1376 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1377 | #else |
---|
1378 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
1379 | #endif |
---|
1380 | if ( ( uiAbsPartIdxRT % uiNumPartInCUWidth == uiAbsZorderCUIdx % uiNumPartInCUWidth ) || ( uiAbsPartIdxRT / uiNumPartInCUWidth == uiAbsZorderCUIdx / uiNumPartInCUWidth ) ) |
---|
1381 | { |
---|
1382 | return m_pcPic->getCU( getAddr() ); |
---|
1383 | } |
---|
1384 | else |
---|
1385 | { |
---|
1386 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
1387 | return this; |
---|
1388 | } |
---|
1389 | } |
---|
1390 | uiARPartUnitIdx = MAX_UINT; |
---|
1391 | return NULL; |
---|
1392 | } |
---|
1393 | #if CONSTRAINED_INTRA_PRED |
---|
1394 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
1395 | #else |
---|
1396 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
1397 | #endif |
---|
1398 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiSliceStartCU)) || |
---|
1399 | (bEnforceEntropySliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1400 | { |
---|
1401 | return NULL; |
---|
1402 | } |
---|
1403 | return m_pcCUAbove; |
---|
1404 | } |
---|
1405 | |
---|
1406 | if ( uiAbsPartIdxRT / uiNumPartInCUWidth ) |
---|
1407 | { |
---|
1408 | uiARPartUnitIdx = MAX_UINT; |
---|
1409 | return NULL; |
---|
1410 | } |
---|
1411 | |
---|
1412 | #if CONSTRAINED_INTRA_PRED |
---|
1413 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
---|
1414 | #else |
---|
1415 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
1416 | #endif |
---|
1417 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiSliceStartCU)) || |
---|
1418 | (bEnforceEntropySliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || m_pcCUAboveRight->getAddr() < m_uiEntropySliceStartCU)) ) |
---|
1419 | { |
---|
1420 | return NULL; |
---|
1421 | } |
---|
1422 | return m_pcCUAboveRight; |
---|
1423 | } |
---|
1424 | |
---|
1425 | #if HHI_DMM_WEDGE_INTRA |
---|
1426 | Void TComDataCU::setWedgeFullTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1427 | { |
---|
1428 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1429 | |
---|
1430 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1431 | { |
---|
1432 | m_puiWedgeFullTabIdx[uiAbsPartIdx+ui] = uiTIdx; |
---|
1433 | } |
---|
1434 | } |
---|
1435 | |
---|
1436 | Void TComDataCU::setWedgeFullDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1437 | { |
---|
1438 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1439 | |
---|
1440 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1441 | { |
---|
1442 | m_piWedgeFullDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1443 | } |
---|
1444 | } |
---|
1445 | |
---|
1446 | Void TComDataCU::setWedgeFullDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1447 | { |
---|
1448 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1449 | |
---|
1450 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1451 | { |
---|
1452 | m_piWedgeFullDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1453 | } |
---|
1454 | } |
---|
1455 | |
---|
1456 | Void TComDataCU::setWedgePredDirTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1457 | { |
---|
1458 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1459 | |
---|
1460 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1461 | { |
---|
1462 | m_puiWedgePredDirTabIdx[uiAbsPartIdx+ui] = uiTIdx; |
---|
1463 | } |
---|
1464 | } |
---|
1465 | |
---|
1466 | Void TComDataCU::setWedgePredDirDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1467 | { |
---|
1468 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1469 | |
---|
1470 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1471 | { |
---|
1472 | m_piWedgePredDirDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1473 | } |
---|
1474 | } |
---|
1475 | |
---|
1476 | Void TComDataCU::setWedgePredDirDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1477 | { |
---|
1478 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1479 | |
---|
1480 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1481 | { |
---|
1482 | m_piWedgePredDirDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1483 | } |
---|
1484 | } |
---|
1485 | |
---|
1486 | Void TComDataCU::setWedgePredDirDeltaEndSubParts( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1487 | { |
---|
1488 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1489 | |
---|
1490 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1491 | { |
---|
1492 | m_piWedgePredDirDeltaEnd[uiAbsPartIdx+ui] = iDelta; |
---|
1493 | } |
---|
1494 | } |
---|
1495 | #endif |
---|
1496 | #if HHI_DMM_PRED_TEX |
---|
1497 | Void TComDataCU::setWedgePredTexTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1498 | { |
---|
1499 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1500 | |
---|
1501 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1502 | { |
---|
1503 | m_puiWedgePredTexTabIdx[uiAbsPartIdx+ui] = uiTIdx; |
---|
1504 | } |
---|
1505 | } |
---|
1506 | |
---|
1507 | Void TComDataCU::setWedgePredTexDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1508 | { |
---|
1509 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1510 | |
---|
1511 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1512 | { |
---|
1513 | m_piWedgePredTexDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1514 | } |
---|
1515 | } |
---|
1516 | |
---|
1517 | Void TComDataCU::setWedgePredTexDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1518 | { |
---|
1519 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1520 | |
---|
1521 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1522 | { |
---|
1523 | m_piWedgePredTexDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1524 | } |
---|
1525 | } |
---|
1526 | |
---|
1527 | Void TComDataCU::setContourPredTexDeltaDC1SubParts( Int iDC1, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1528 | { |
---|
1529 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1530 | |
---|
1531 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1532 | { |
---|
1533 | m_piContourPredTexDeltaDC1[uiAbsPartIdx+ui] = iDC1; |
---|
1534 | } |
---|
1535 | } |
---|
1536 | |
---|
1537 | Void TComDataCU::setContourPredTexDeltaDC2SubParts( Int iDC2, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1538 | { |
---|
1539 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
1540 | |
---|
1541 | for ( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
1542 | { |
---|
1543 | m_piContourPredTexDeltaDC2[uiAbsPartIdx+ui] = iDC2; |
---|
1544 | } |
---|
1545 | } |
---|
1546 | #endif |
---|
1547 | |
---|
1548 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1549 | Int |
---|
1550 | TComDataCU::getPdmMergeCandidate( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv ) |
---|
1551 | { |
---|
1552 | TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator(); |
---|
1553 | ROFRS( pcDepthMapGenerator, 0 ); |
---|
1554 | return pcDepthMapGenerator->getPdmMergeCandidate( this, uiPartIdx, paiPdmRefIdx, pacPdmMv ); |
---|
1555 | } |
---|
1556 | |
---|
1557 | |
---|
1558 | Bool |
---|
1559 | TComDataCU::getPdmMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge ) |
---|
1560 | { |
---|
1561 | TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator(); |
---|
1562 | ROFRS( pcDepthMapGenerator, false ); |
---|
1563 | return pcDepthMapGenerator->getPdmMvPred( this, uiPartIdx, eRefPicList, iRefIdx, rcMv, bMerge ); |
---|
1564 | } |
---|
1565 | |
---|
1566 | |
---|
1567 | Bool |
---|
1568 | TComDataCU::getIViewOrgDepthMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv ) |
---|
1569 | { |
---|
1570 | TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator(); |
---|
1571 | ROFRS( pcDepthMapGenerator, false ); |
---|
1572 | return pcDepthMapGenerator->getIViewOrgDepthMvPred( this, uiPartIdx, eRefPicList, iRefIdx, rcMv ); |
---|
1573 | } |
---|
1574 | #endif |
---|
1575 | |
---|
1576 | |
---|
1577 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1578 | Bool |
---|
1579 | TComDataCU::getResidualSamples( UInt uiPartIdx, TComYuv* pcYuv ) |
---|
1580 | { |
---|
1581 | TComResidualGenerator* pcResidualGenerator = m_pcSlice->getSPS()->getResidualGenerator(); |
---|
1582 | ROFRS( pcResidualGenerator, false ); |
---|
1583 | return pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv ); |
---|
1584 | } |
---|
1585 | #endif |
---|
1586 | |
---|
1587 | |
---|
1588 | Int TComDataCU::getMostProbableIntraDirLuma( UInt uiAbsPartIdx ) |
---|
1589 | { |
---|
1590 | TComDataCU* pcTempCU; |
---|
1591 | UInt uiTempPartIdx; |
---|
1592 | Int iLeftIntraDir, iAboveIntraDir, iMostProbable; |
---|
1593 | |
---|
1594 | // Get intra direction of left PU |
---|
1595 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, false ); |
---|
1596 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1597 | #if ADD_PLANAR_MODE |
---|
1598 | mapPlanartoDC( iLeftIntraDir ); |
---|
1599 | #endif |
---|
1600 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1601 | mapDMMtoDC( iLeftIntraDir ); |
---|
1602 | #endif |
---|
1603 | |
---|
1604 | // Get intra direction of above PU |
---|
1605 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, false ); |
---|
1606 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1607 | #if ADD_PLANAR_MODE |
---|
1608 | mapPlanartoDC( iAboveIntraDir ); |
---|
1609 | #endif |
---|
1610 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1611 | mapDMMtoDC( iAboveIntraDir ); |
---|
1612 | #endif |
---|
1613 | |
---|
1614 | iMostProbable = Min( iLeftIntraDir, iAboveIntraDir ); |
---|
1615 | |
---|
1616 | // Mode conversion process for blocks with different number of available prediction directions |
---|
1617 | Int iIdx = getIntraSizeIdx(uiAbsPartIdx); |
---|
1618 | |
---|
1619 | if ( iMostProbable >= g_aucIntraModeNumAng[iIdx] ) |
---|
1620 | { |
---|
1621 | if ( g_aucIntraModeNumAng[iIdx] == 5 ) |
---|
1622 | iMostProbable = g_aucAngModeMapping[0][g_aucAngIntraModeOrder[iMostProbable]]; |
---|
1623 | if ( g_aucIntraModeNumAng[iIdx] == 3 ) |
---|
1624 | iMostProbable = g_aucAngModeMapping[3][g_aucAngIntraModeOrder[iMostProbable]]; |
---|
1625 | else |
---|
1626 | iMostProbable = g_aucAngModeMapping[1][g_aucAngIntraModeOrder[iMostProbable]]; |
---|
1627 | } |
---|
1628 | |
---|
1629 | return ( NOT_VALID == iMostProbable ) ? 2 : iMostProbable; |
---|
1630 | } |
---|
1631 | #if MTK_DCM_MPM |
---|
1632 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[] ) |
---|
1633 | { |
---|
1634 | TComDataCU* pcTempCU; |
---|
1635 | UInt uiTempPartIdx; |
---|
1636 | Int iLeftIntraDir, iAboveIntraDir; |
---|
1637 | Int uiPredNum = 0; |
---|
1638 | |
---|
1639 | // Get intra direction of left PU |
---|
1640 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1641 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : 2; |
---|
1642 | #if ADD_PLANAR_MODE |
---|
1643 | mapPlanartoDC( iLeftIntraDir ); |
---|
1644 | #endif |
---|
1645 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1646 | mapDMMtoDC( iLeftIntraDir ); |
---|
1647 | #endif |
---|
1648 | |
---|
1649 | // Get intra direction of above PU |
---|
1650 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1651 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : 2; |
---|
1652 | #if ADD_PLANAR_MODE |
---|
1653 | mapPlanartoDC( iAboveIntraDir ); |
---|
1654 | #endif |
---|
1655 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1656 | mapDMMtoDC( iAboveIntraDir ); |
---|
1657 | #endif |
---|
1658 | |
---|
1659 | Int iIdx = getIntraSizeIdx(uiAbsPartIdx); |
---|
1660 | |
---|
1661 | if ( iLeftIntraDir >= g_aucIntraModeNumAng[iIdx] ) |
---|
1662 | { |
---|
1663 | if ( g_aucIntraModeNumAng[iIdx] == 5 ) |
---|
1664 | { |
---|
1665 | iLeftIntraDir = g_aucAngModeMapping[0][g_aucAngIntraModeOrder[iLeftIntraDir]]; |
---|
1666 | } |
---|
1667 | if ( g_aucIntraModeNumAng[iIdx] == 3 ) |
---|
1668 | { |
---|
1669 | iLeftIntraDir = g_aucAngModeMapping[3][g_aucAngIntraModeOrder[iLeftIntraDir]]; |
---|
1670 | } |
---|
1671 | else |
---|
1672 | { |
---|
1673 | iLeftIntraDir = g_aucAngModeMapping[1][g_aucAngIntraModeOrder[iLeftIntraDir]]; |
---|
1674 | } |
---|
1675 | } |
---|
1676 | |
---|
1677 | |
---|
1678 | if ( iAboveIntraDir >= g_aucIntraModeNumAng[iIdx] ) |
---|
1679 | { |
---|
1680 | if ( g_aucIntraModeNumAng[iIdx] == 5 ) |
---|
1681 | { |
---|
1682 | iAboveIntraDir = g_aucAngModeMapping[0][g_aucAngIntraModeOrder[iAboveIntraDir]]; |
---|
1683 | } |
---|
1684 | if ( g_aucIntraModeNumAng[iIdx] == 3 ) |
---|
1685 | { |
---|
1686 | iAboveIntraDir = g_aucAngModeMapping[3][g_aucAngIntraModeOrder[iAboveIntraDir]]; |
---|
1687 | } |
---|
1688 | else |
---|
1689 | { |
---|
1690 | iAboveIntraDir = g_aucAngModeMapping[1][g_aucAngIntraModeOrder[iAboveIntraDir]]; |
---|
1691 | } |
---|
1692 | } |
---|
1693 | |
---|
1694 | if(iLeftIntraDir == iAboveIntraDir) |
---|
1695 | { |
---|
1696 | uiPredNum = 1; |
---|
1697 | uiIntraDirPred[0] = iLeftIntraDir ; |
---|
1698 | } |
---|
1699 | else |
---|
1700 | { |
---|
1701 | uiPredNum = 2; |
---|
1702 | uiIntraDirPred[0] = Min(iLeftIntraDir, iAboveIntraDir); |
---|
1703 | uiIntraDirPred[1] = Max(iLeftIntraDir, iAboveIntraDir); |
---|
1704 | } |
---|
1705 | |
---|
1706 | |
---|
1707 | return uiPredNum; |
---|
1708 | } |
---|
1709 | #endif |
---|
1710 | #if LCEC_INTRA_MODE |
---|
1711 | Int TComDataCU::getLeftIntraDirLuma( UInt uiAbsPartIdx ) |
---|
1712 | { |
---|
1713 | TComDataCU* pcTempCU; |
---|
1714 | UInt uiTempPartIdx; |
---|
1715 | Int iLeftIntraDir; |
---|
1716 | |
---|
1717 | // Get intra direction of left PU |
---|
1718 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1719 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1720 | #if ADD_PLANAR_MODE |
---|
1721 | mapPlanartoDC( iLeftIntraDir ); |
---|
1722 | #endif |
---|
1723 | |
---|
1724 | return iLeftIntraDir; |
---|
1725 | } |
---|
1726 | |
---|
1727 | Int TComDataCU::getAboveIntraDirLuma( UInt uiAbsPartIdx ) |
---|
1728 | { |
---|
1729 | TComDataCU* pcTempCU; |
---|
1730 | UInt uiTempPartIdx; |
---|
1731 | Int iAboveIntraDir; |
---|
1732 | |
---|
1733 | // Get intra direction of above PU |
---|
1734 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1735 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : 2 ) : NOT_VALID; |
---|
1736 | #if ADD_PLANAR_MODE |
---|
1737 | mapPlanartoDC( iAboveIntraDir ); |
---|
1738 | #endif |
---|
1739 | |
---|
1740 | return iAboveIntraDir; |
---|
1741 | } |
---|
1742 | #endif |
---|
1743 | |
---|
1744 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1745 | { |
---|
1746 | TComDataCU* pcTempCU; |
---|
1747 | UInt uiTempPartIdx; |
---|
1748 | UInt uiCtx; |
---|
1749 | // Get left split flag |
---|
1750 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1751 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1752 | |
---|
1753 | // Get above split flag |
---|
1754 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1755 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
1756 | |
---|
1757 | return uiCtx; |
---|
1758 | } |
---|
1759 | |
---|
1760 | UInt TComDataCU::getCtxIntraDirChroma( UInt uiAbsPartIdx ) |
---|
1761 | { |
---|
1762 | TComDataCU* pcTempCU; |
---|
1763 | UInt uiTempPartIdx; |
---|
1764 | UInt uiCtx; |
---|
1765 | |
---|
1766 | // Get intra direction of left PU |
---|
1767 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1768 | #if CHROMA_CODEWORD |
---|
1769 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) == 4 ) ? 1 : 0 ) : 0; |
---|
1770 | #else |
---|
1771 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) > 0 ) ? 1 : 0 ) : 0; |
---|
1772 | #endif |
---|
1773 | |
---|
1774 | // Get intra direction of above PU |
---|
1775 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1776 | #if CHROMA_CODEWORD |
---|
1777 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) == 4 ) ? 1 : 0 ) : 0; |
---|
1778 | #else |
---|
1779 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->isIntra( uiTempPartIdx ) && pcTempCU->getChromaIntraDir( uiTempPartIdx ) > 0 ) ? 1 : 0 ) : 0; |
---|
1780 | #endif |
---|
1781 | |
---|
1782 | return uiCtx; |
---|
1783 | } |
---|
1784 | |
---|
1785 | UInt TComDataCU::getCtxCbf( UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
1786 | { |
---|
1787 | TComDataCU* pcTempCU; |
---|
1788 | UInt uiTempPartIdx, uiTempTrDepth; |
---|
1789 | UInt uiErrRet = !isIntra(uiAbsPartIdx) ? 0 : 1; |
---|
1790 | UInt uiCtx = 0; |
---|
1791 | |
---|
1792 | // Get Cbf of left PU |
---|
1793 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1794 | if ( pcTempCU ) |
---|
1795 | { |
---|
1796 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1797 | uiCtx = pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth < uiTrDepth ? uiTempTrDepth : uiTrDepth ); |
---|
1798 | } |
---|
1799 | else |
---|
1800 | { |
---|
1801 | uiCtx = uiErrRet; |
---|
1802 | } |
---|
1803 | |
---|
1804 | // Get Cbf of above PU |
---|
1805 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1806 | if ( pcTempCU ) |
---|
1807 | { |
---|
1808 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1809 | uiCtx += pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth < uiTrDepth ? uiTempTrDepth : uiTrDepth ) << 1; |
---|
1810 | } |
---|
1811 | else |
---|
1812 | { |
---|
1813 | uiCtx += uiErrRet << 1; |
---|
1814 | } |
---|
1815 | |
---|
1816 | return uiCtx; |
---|
1817 | } |
---|
1818 | |
---|
1819 | UInt TComDataCU::getCtxQtCbf( UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
1820 | { |
---|
1821 | if( getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && eType != TEXT_LUMA ) |
---|
1822 | { |
---|
1823 | return uiTrDepth; |
---|
1824 | } |
---|
1825 | UInt uiCtx = 0; |
---|
1826 | const UInt uiDepth = getDepth( uiAbsPartIdx ); |
---|
1827 | const UInt uiLog2TrafoSize = g_aucConvertToBit[getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth - uiTrDepth; |
---|
1828 | |
---|
1829 | if( uiTrDepth == 0 || uiLog2TrafoSize == getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1830 | { |
---|
1831 | TComDataCU* pcTempCU; |
---|
1832 | UInt uiTempPartIdx, uiTempTrDepth; |
---|
1833 | |
---|
1834 | // Get Cbf of left PU |
---|
1835 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1836 | if ( pcTempCU ) |
---|
1837 | { |
---|
1838 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1839 | uiCtx = pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth ); |
---|
1840 | } |
---|
1841 | |
---|
1842 | // Get Cbf of above PU |
---|
1843 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1844 | if ( pcTempCU ) |
---|
1845 | { |
---|
1846 | uiTempTrDepth = pcTempCU->getTransformIdx( uiTempPartIdx ); |
---|
1847 | uiCtx += pcTempCU->getCbf( uiTempPartIdx, eType, uiTempTrDepth ) << 1; |
---|
1848 | } |
---|
1849 | uiCtx++; |
---|
1850 | } |
---|
1851 | return uiCtx; |
---|
1852 | } |
---|
1853 | |
---|
1854 | UInt TComDataCU::getCtxQtRootCbf( UInt uiAbsPartIdx ) |
---|
1855 | { |
---|
1856 | UInt uiCtx = 0; |
---|
1857 | TComDataCU* pcTempCU; |
---|
1858 | UInt uiTempPartIdx; |
---|
1859 | |
---|
1860 | // Get RootCbf of left PU |
---|
1861 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1862 | if ( pcTempCU ) |
---|
1863 | { |
---|
1864 | uiCtx = pcTempCU->getQtRootCbf( uiTempPartIdx ); |
---|
1865 | } |
---|
1866 | |
---|
1867 | // Get RootCbf of above PU |
---|
1868 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1869 | if ( pcTempCU ) |
---|
1870 | { |
---|
1871 | uiCtx += pcTempCU->getQtRootCbf( uiTempPartIdx ) << 1; |
---|
1872 | } |
---|
1873 | |
---|
1874 | return uiCtx; |
---|
1875 | } |
---|
1876 | |
---|
1877 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt uiIdx ) |
---|
1878 | { |
---|
1879 | #if HHI_RQT_DISABLE_SUB |
---|
1880 | return getQuadtreeTULog2RootSizeInCU(uiIdx); |
---|
1881 | #else |
---|
1882 | #if HHI_RQT_FORCE_SPLIT_ACC2_PU |
---|
1883 | UInt uiLog2MinTUSizeInCU = getQuadtreeTULog2RootSizeInCU(uiIdx); |
---|
1884 | #else |
---|
1885 | UInt uiLog2MinTUSizeInCU = g_aucConvertToBit[getWidth( uiIdx )] + 2; |
---|
1886 | |
---|
1887 | if ( getPredictionMode( uiIdx ) == MODE_INTRA && getPartitionSize( uiIdx ) == SIZE_NxN ) |
---|
1888 | { |
---|
1889 | uiLog2MinTUSizeInCU--; |
---|
1890 | } |
---|
1891 | #endif |
---|
1892 | |
---|
1893 | UInt uiQuadtreeTUMaxDepth = getPredictionMode( uiIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
1894 | if (uiLog2MinTUSizeInCU < m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + uiQuadtreeTUMaxDepth - 1) |
---|
1895 | { |
---|
1896 | uiLog2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
1897 | } |
---|
1898 | else |
---|
1899 | { |
---|
1900 | uiLog2MinTUSizeInCU -= uiQuadtreeTUMaxDepth - 1; |
---|
1901 | } |
---|
1902 | |
---|
1903 | if ( uiLog2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
1904 | { |
---|
1905 | uiLog2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1906 | } |
---|
1907 | return uiLog2MinTUSizeInCU; |
---|
1908 | #endif |
---|
1909 | } |
---|
1910 | |
---|
1911 | #if HHI_RQT_FORCE_SPLIT_ACC2_PU || HHI_RQT_DISABLE_SUB |
---|
1912 | UInt TComDataCU::getQuadtreeTULog2RootSizeInCU( UInt uiIdx ) |
---|
1913 | { |
---|
1914 | UInt uiLog2RootTUSizeInCU = g_aucConvertToBit[getWidth( uiIdx )] +2; |
---|
1915 | |
---|
1916 | #if !HHI_RQT_FORCE_SPLIT_NxN && !HHI_RQT_DISABLE_SUB |
---|
1917 | if ( getPredictionMode( uiIdx ) == MODE_INTRA && getPartitionSize( uiIdx ) == SIZE_NxN ) |
---|
1918 | { |
---|
1919 | uiLog2RootTUSizeInCU--; |
---|
1920 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1921 | } |
---|
1922 | #endif |
---|
1923 | |
---|
1924 | if (m_pePartSize[ uiIdx ] == SIZE_2Nx2N) |
---|
1925 | { |
---|
1926 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1927 | } |
---|
1928 | else if (m_pePartSize[ uiIdx ] >= SIZE_2NxN && m_pePartSize[ uiIdx ] <= SIZE_Nx2N) |
---|
1929 | { |
---|
1930 | #if HHI_RQT_FORCE_SPLIT_RECT || HHI_RQT_DISABLE_SUB |
---|
1931 | uiLog2RootTUSizeInCU--; |
---|
1932 | #endif |
---|
1933 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1934 | } |
---|
1935 | else if (m_pePartSize[ uiIdx ] == SIZE_NxN) |
---|
1936 | { |
---|
1937 | #if HHI_RQT_FORCE_SPLIT_NxN || HHI_RQT_DISABLE_SUB |
---|
1938 | uiLog2RootTUSizeInCU--; |
---|
1939 | #endif |
---|
1940 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1941 | } |
---|
1942 | |
---|
1943 | return (uiLog2RootTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() ? m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize() : uiLog2RootTUSizeInCU); |
---|
1944 | } |
---|
1945 | #endif |
---|
1946 | |
---|
1947 | UInt TComDataCU::getCtxAlfCtrlFlag( UInt uiAbsPartIdx ) |
---|
1948 | { |
---|
1949 | TComDataCU* pcTempCU; |
---|
1950 | UInt uiTempPartIdx; |
---|
1951 | UInt uiCtx = 0; |
---|
1952 | |
---|
1953 | // Get BCBP of left PU |
---|
1954 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1955 | uiCtx = ( pcTempCU ) ? pcTempCU->getAlfCtrlFlag( uiTempPartIdx ) : 0; |
---|
1956 | |
---|
1957 | // Get BCBP of above PU |
---|
1958 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1959 | uiCtx += ( pcTempCU ) ? pcTempCU->getAlfCtrlFlag( uiTempPartIdx ) : 0; |
---|
1960 | |
---|
1961 | return uiCtx; |
---|
1962 | } |
---|
1963 | |
---|
1964 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
1965 | { |
---|
1966 | TComDataCU* pcTempCU; |
---|
1967 | UInt uiTempPartIdx; |
---|
1968 | UInt uiCtx = 0; |
---|
1969 | |
---|
1970 | // Get BCBP of left PU |
---|
1971 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1972 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1973 | |
---|
1974 | // Get BCBP of above PU |
---|
1975 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1976 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
1977 | |
---|
1978 | return uiCtx; |
---|
1979 | } |
---|
1980 | |
---|
1981 | /** CABAC context derivation for merge flag |
---|
1982 | * \param uiAbsPartIdx |
---|
1983 | * \returns context offset |
---|
1984 | */ |
---|
1985 | UInt TComDataCU::getCtxMergeFlag( UInt uiAbsPartIdx ) |
---|
1986 | { |
---|
1987 | UInt uiCtx = 0; |
---|
1988 | #if CHANGE_MERGE_CONTEXT |
---|
1989 | TComDataCU* pcTempCU; |
---|
1990 | UInt uiTempPartIdx; |
---|
1991 | |
---|
1992 | // Get BCBP of left PU |
---|
1993 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1994 | uiCtx = ( pcTempCU ) ? pcTempCU->getMergeFlag( uiTempPartIdx ) : 0; |
---|
1995 | |
---|
1996 | // Get BCBP of above PU |
---|
1997 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
1998 | uiCtx += ( pcTempCU ) ? pcTempCU->getMergeFlag( uiTempPartIdx ) : 0; |
---|
1999 | #endif |
---|
2000 | return uiCtx; |
---|
2001 | } |
---|
2002 | |
---|
2003 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
2004 | { |
---|
2005 | TComDataCU* pcTempCU; |
---|
2006 | UInt uiTempPartIdx; |
---|
2007 | UInt uiCtx = 0; |
---|
2008 | |
---|
2009 | // Get BCBP of left PU |
---|
2010 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2011 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getInterDir( uiTempPartIdx ) % 3 ) ? 0 : 1 ) : 0; |
---|
2012 | |
---|
2013 | // Get BCBP of Above PU |
---|
2014 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2015 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getInterDir( uiTempPartIdx ) % 3 ) ? 0 : 1 ) : 0; |
---|
2016 | |
---|
2017 | return uiCtx; |
---|
2018 | } |
---|
2019 | |
---|
2020 | UInt TComDataCU::getCtxRefIdx( UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
2021 | { |
---|
2022 | TComDataCU* pcTempCU; |
---|
2023 | UInt uiTempPartIdx; |
---|
2024 | TComMvField cMvFieldTemp; |
---|
2025 | UInt uiCtx = 0; |
---|
2026 | |
---|
2027 | // Get BCBP of left PU |
---|
2028 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2029 | getMvField( pcTempCU, uiTempPartIdx, eRefPicList, cMvFieldTemp ); |
---|
2030 | uiCtx += cMvFieldTemp.getRefIdx() > 0 ? 1 : 0; |
---|
2031 | |
---|
2032 | // Get BCBP of Above PU |
---|
2033 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
2034 | getMvField( pcTempCU, uiTempPartIdx, eRefPicList, cMvFieldTemp ); |
---|
2035 | uiCtx += cMvFieldTemp.getRefIdx() > 0 ? 2 : 0; |
---|
2036 | |
---|
2037 | return uiCtx; |
---|
2038 | } |
---|
2039 | |
---|
2040 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2041 | { |
---|
2042 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2043 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2044 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2045 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2046 | } |
---|
2047 | |
---|
2048 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2049 | { |
---|
2050 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2051 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
2052 | } |
---|
2053 | |
---|
2054 | #if HHI_MRG_SKIP |
---|
2055 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
2056 | * \param uiCbf The value of the coded block flag to be set |
---|
2057 | * \param eTType |
---|
2058 | * \param uiAbsPartIdx |
---|
2059 | * \param uiPartIdx |
---|
2060 | * \param uiDepth |
---|
2061 | * \returns Void |
---|
2062 | */ |
---|
2063 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2064 | { |
---|
2065 | setSubPartUChar( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2066 | } |
---|
2067 | #endif |
---|
2068 | |
---|
2069 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
2070 | { |
---|
2071 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2072 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2073 | } |
---|
2074 | |
---|
2075 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
2076 | { |
---|
2077 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2078 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
2079 | } |
---|
2080 | |
---|
2081 | Void TComDataCU::setAlfCtrlFlagSubParts ( UInt uiFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2082 | { |
---|
2083 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2084 | |
---|
2085 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
2086 | { |
---|
2087 | m_puiAlfCtrlFlag[uiAbsPartIdx + ui] = uiFlag; |
---|
2088 | } |
---|
2089 | } |
---|
2090 | |
---|
2091 | Void TComDataCU::createTmpAlfCtrlFlag() |
---|
2092 | { |
---|
2093 | m_puiTmpAlfCtrlFlag = (UInt* )xMalloc(UInt, m_uiNumPartition); |
---|
2094 | } |
---|
2095 | |
---|
2096 | Void TComDataCU::destroyTmpAlfCtrlFlag() |
---|
2097 | { |
---|
2098 | if(m_puiTmpAlfCtrlFlag) |
---|
2099 | { |
---|
2100 | xFree(m_puiTmpAlfCtrlFlag); m_puiTmpAlfCtrlFlag = NULL; |
---|
2101 | } |
---|
2102 | } |
---|
2103 | |
---|
2104 | Void TComDataCU::copyAlfCtrlFlagToTmp() |
---|
2105 | { |
---|
2106 | memcpy( m_puiTmpAlfCtrlFlag, m_puiAlfCtrlFlag, sizeof(UInt)*m_uiNumPartition ); |
---|
2107 | } |
---|
2108 | |
---|
2109 | Void TComDataCU::copyAlfCtrlFlagFromTmp() |
---|
2110 | { |
---|
2111 | memcpy( m_puiAlfCtrlFlag, m_puiTmpAlfCtrlFlag, sizeof(UInt)*m_uiNumPartition ); |
---|
2112 | } |
---|
2113 | |
---|
2114 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2115 | { |
---|
2116 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2117 | |
---|
2118 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
2119 | { |
---|
2120 | m_pePartSize[uiAbsPartIdx + ui] = eMode; |
---|
2121 | } |
---|
2122 | } |
---|
2123 | |
---|
2124 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2125 | { |
---|
2126 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2127 | |
---|
2128 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
2129 | { |
---|
2130 | m_pePredMode[uiAbsPartIdx + ui] = eMode; |
---|
2131 | } |
---|
2132 | } |
---|
2133 | |
---|
2134 | Void TComDataCU::setQPSubParts( UInt uiQP, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2135 | { |
---|
2136 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2137 | |
---|
2138 | memset( m_phQP + uiAbsPartIdx, uiQP, sizeof(Char)*uiCurrPartNumb ); |
---|
2139 | } |
---|
2140 | |
---|
2141 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2142 | { |
---|
2143 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2144 | |
---|
2145 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2146 | } |
---|
2147 | |
---|
2148 | Void TComDataCU::setSubPartUChar( UInt uiParameter, UChar* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2149 | { |
---|
2150 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (uiCUDepth << 1)) >> 2; |
---|
2151 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2152 | { |
---|
2153 | case SIZE_2Nx2N: |
---|
2154 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ << 2 ); break; |
---|
2155 | case SIZE_2NxN: |
---|
2156 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ << 1 ); break; |
---|
2157 | case SIZE_Nx2N: |
---|
2158 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ ); |
---|
2159 | memset( puhBaseLCU + uiCUAddr + ( uiCurrPartNumQ << 1 ), uiParameter, sizeof(UChar)*uiCurrPartNumQ ); break; |
---|
2160 | case SIZE_NxN: |
---|
2161 | memset( puhBaseLCU + uiCUAddr, uiParameter, sizeof(UChar)*uiCurrPartNumQ ); break; |
---|
2162 | default: |
---|
2163 | assert( 0 ); |
---|
2164 | } |
---|
2165 | } |
---|
2166 | |
---|
2167 | Void TComDataCU::setSubPartBool( Bool bParameter, Bool* pbBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
2168 | { |
---|
2169 | UInt uiQuaterCUPartNum = (m_pcPic->getNumPartInCU() >> (uiCUDepth << 1)) >> 2; |
---|
2170 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
2171 | { |
---|
2172 | case SIZE_2Nx2N: |
---|
2173 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum << 2 ); break; |
---|
2174 | case SIZE_2NxN: |
---|
2175 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum << 1 ); break; |
---|
2176 | case SIZE_Nx2N: |
---|
2177 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum ); |
---|
2178 | memset( pbBaseLCU + uiCUAddr + ( uiQuaterCUPartNum << 1 ), bParameter, sizeof(Bool)*uiQuaterCUPartNum ); break; |
---|
2179 | case SIZE_NxN: |
---|
2180 | memset( pbBaseLCU + uiCUAddr, bParameter, sizeof(Bool)*uiQuaterCUPartNum ); break; |
---|
2181 | default: |
---|
2182 | assert( 0 ); |
---|
2183 | } |
---|
2184 | } |
---|
2185 | |
---|
2186 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2187 | { |
---|
2188 | setSubPartBool( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2189 | } |
---|
2190 | |
---|
2191 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2192 | { |
---|
2193 | setSubPartUChar( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2194 | } |
---|
2195 | |
---|
2196 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
2197 | Void TComDataCU::setResPredAvailSubParts( Bool bResPredAvailable, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2198 | { |
---|
2199 | setSubPartBool( bResPredAvailable, m_pbResPredAvailable, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2200 | } |
---|
2201 | |
---|
2202 | Void TComDataCU::setResPredFlagSubParts( Bool bResPredFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2203 | { |
---|
2204 | setSubPartBool( bResPredFlag, m_pbResPredFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2205 | } |
---|
2206 | #endif |
---|
2207 | |
---|
2208 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2209 | { |
---|
2210 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2211 | |
---|
2212 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
2213 | } |
---|
2214 | |
---|
2215 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2216 | { |
---|
2217 | setSubPartUChar( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
2218 | } |
---|
2219 | |
---|
2220 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2221 | { |
---|
2222 | UInt uiCurrPartNumQ = m_pcPic->getNumPartInCU() >> (uiDepth << 1) >> 2; |
---|
2223 | UInt i; |
---|
2224 | Int* pi; |
---|
2225 | switch ( m_pePartSize[ uiAbsPartIdx ] ) |
---|
2226 | { |
---|
2227 | case SIZE_2Nx2N: |
---|
2228 | { |
---|
2229 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2230 | for (i = 0; i < (uiCurrPartNumQ << 2); i++) |
---|
2231 | { |
---|
2232 | pi[i] = iMVPIdx; |
---|
2233 | } |
---|
2234 | } |
---|
2235 | break; |
---|
2236 | case SIZE_2NxN: |
---|
2237 | { |
---|
2238 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2239 | for (i = 0; i < (uiCurrPartNumQ << 1); i++) |
---|
2240 | { |
---|
2241 | pi[i] = iMVPIdx; |
---|
2242 | } |
---|
2243 | } |
---|
2244 | break; |
---|
2245 | case SIZE_Nx2N: |
---|
2246 | { |
---|
2247 | Int* pi2 = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx + ( uiCurrPartNumQ << 1 ); |
---|
2248 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2249 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2250 | { |
---|
2251 | pi [i] = iMVPIdx; |
---|
2252 | pi2[i] = iMVPIdx; |
---|
2253 | } |
---|
2254 | break; |
---|
2255 | } |
---|
2256 | case SIZE_NxN: |
---|
2257 | { |
---|
2258 | pi = m_apiMVPIdx[eRefPicList] + uiAbsPartIdx; |
---|
2259 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2260 | { |
---|
2261 | pi[i] = iMVPIdx; |
---|
2262 | } |
---|
2263 | break; |
---|
2264 | } |
---|
2265 | default: |
---|
2266 | assert( 0 ); |
---|
2267 | } |
---|
2268 | } |
---|
2269 | |
---|
2270 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
2271 | { |
---|
2272 | UInt uiCurrPartNumQ = m_pcPic->getNumPartInCU() >> (uiDepth << 1) >> 2; |
---|
2273 | UInt i; |
---|
2274 | Int* pi; |
---|
2275 | switch ( m_pePartSize[ uiAbsPartIdx ] ) |
---|
2276 | { |
---|
2277 | case SIZE_2Nx2N: |
---|
2278 | { |
---|
2279 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2280 | for (i = 0; i < (uiCurrPartNumQ << 2); i++) |
---|
2281 | { |
---|
2282 | pi[i] = iMVPNum; |
---|
2283 | } |
---|
2284 | } |
---|
2285 | break; |
---|
2286 | case SIZE_2NxN: |
---|
2287 | { |
---|
2288 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2289 | for (i = 0; i < (uiCurrPartNumQ << 1); i++) |
---|
2290 | { |
---|
2291 | pi[i] = iMVPNum; |
---|
2292 | } |
---|
2293 | } |
---|
2294 | break; |
---|
2295 | case SIZE_Nx2N: |
---|
2296 | { |
---|
2297 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2298 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2299 | { |
---|
2300 | pi[i] = iMVPNum; |
---|
2301 | } |
---|
2302 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx + ( uiCurrPartNumQ << 1 ); |
---|
2303 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2304 | { |
---|
2305 | pi[i] = iMVPNum; |
---|
2306 | } |
---|
2307 | } |
---|
2308 | break; |
---|
2309 | case SIZE_NxN: |
---|
2310 | { |
---|
2311 | pi = m_apiMVPNum[eRefPicList] + uiAbsPartIdx; |
---|
2312 | for (i = 0; i < uiCurrPartNumQ; i++) |
---|
2313 | { |
---|
2314 | pi[i] = iMVPNum; |
---|
2315 | } |
---|
2316 | } |
---|
2317 | break; |
---|
2318 | default: |
---|
2319 | assert( 0 ); |
---|
2320 | } |
---|
2321 | } |
---|
2322 | |
---|
2323 | |
---|
2324 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2325 | { |
---|
2326 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2327 | |
---|
2328 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
2329 | } |
---|
2330 | |
---|
2331 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2332 | { |
---|
2333 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
2334 | |
---|
2335 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
2336 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
2337 | } |
---|
2338 | |
---|
2339 | UChar TComDataCU::getNumPartInter() |
---|
2340 | { |
---|
2341 | UChar iNumPart = 0; |
---|
2342 | |
---|
2343 | switch ( m_pePartSize[0] ) |
---|
2344 | { |
---|
2345 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
2346 | case SIZE_2NxN: iNumPart = 2; break; |
---|
2347 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
2348 | case SIZE_NxN: iNumPart = 4; break; |
---|
2349 | default: assert (0); break; |
---|
2350 | } |
---|
2351 | |
---|
2352 | return iNumPart; |
---|
2353 | } |
---|
2354 | |
---|
2355 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
2356 | { |
---|
2357 | switch ( m_pePartSize[0] ) |
---|
2358 | { |
---|
2359 | case SIZE_2NxN: |
---|
2360 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2361 | break; |
---|
2362 | case SIZE_Nx2N: |
---|
2363 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
2364 | break; |
---|
2365 | case SIZE_NxN: |
---|
2366 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2367 | break; |
---|
2368 | default: |
---|
2369 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
2370 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
2371 | break; |
---|
2372 | } |
---|
2373 | } |
---|
2374 | |
---|
2375 | |
---|
2376 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
2377 | { |
---|
2378 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
2379 | { |
---|
2380 | TComMv cZeroMv; |
---|
2381 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
2382 | return; |
---|
2383 | } |
---|
2384 | |
---|
2385 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
2386 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
2387 | } |
---|
2388 | |
---|
2389 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2390 | { |
---|
2391 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2392 | UInt uiPUWidth = 0; |
---|
2393 | |
---|
2394 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2395 | { |
---|
2396 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2397 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
2398 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2399 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
2400 | default: |
---|
2401 | assert (0); |
---|
2402 | break; |
---|
2403 | } |
---|
2404 | |
---|
2405 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2406 | } |
---|
2407 | |
---|
2408 | Void TComDataCU::deriveLeftBottomIdxGeneral( PartSize eCUMode, UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2409 | { |
---|
2410 | UInt uiPUHeight = 0; |
---|
2411 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
2412 | { |
---|
2413 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2414 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2415 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
2416 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
2417 | default: |
---|
2418 | assert (0); |
---|
2419 | break; |
---|
2420 | } |
---|
2421 | |
---|
2422 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2423 | } |
---|
2424 | |
---|
2425 | Void TComDataCU::deriveLeftRightTopIdx ( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
2426 | { |
---|
2427 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
2428 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
2429 | |
---|
2430 | switch ( m_pePartSize[0] ) |
---|
2431 | { |
---|
2432 | case SIZE_2Nx2N: break; |
---|
2433 | case SIZE_2NxN: |
---|
2434 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2435 | break; |
---|
2436 | case SIZE_Nx2N: |
---|
2437 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
2438 | break; |
---|
2439 | case SIZE_NxN: |
---|
2440 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2441 | break; |
---|
2442 | default: |
---|
2443 | assert (0); |
---|
2444 | break; |
---|
2445 | } |
---|
2446 | |
---|
2447 | } |
---|
2448 | |
---|
2449 | Void TComDataCU::deriveLeftBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
2450 | { |
---|
2451 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
2452 | |
---|
2453 | switch ( m_pePartSize[0] ) |
---|
2454 | { |
---|
2455 | case SIZE_2Nx2N: |
---|
2456 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
2457 | break; |
---|
2458 | case SIZE_2NxN: |
---|
2459 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2460 | break; |
---|
2461 | case SIZE_Nx2N: |
---|
2462 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
2463 | break; |
---|
2464 | case SIZE_NxN: |
---|
2465 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
2466 | break; |
---|
2467 | default: |
---|
2468 | assert (0); |
---|
2469 | break; |
---|
2470 | } |
---|
2471 | } |
---|
2472 | |
---|
2473 | #if MTK_TMVP_H_MRG || MTK_TMVP_H_AMVP |
---|
2474 | /** Derives the partition index of neighbouring bottom right block |
---|
2475 | * \param in eCUMode |
---|
2476 | * \param in uiPartIdx |
---|
2477 | * \param out ruiPartIdx |
---|
2478 | * \returns Void |
---|
2479 | */ |
---|
2480 | Void TComDataCU::deriveRightBottomIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
2481 | { |
---|
2482 | ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; |
---|
2483 | |
---|
2484 | switch ( m_pePartSize[0] ) |
---|
2485 | { |
---|
2486 | case SIZE_2Nx2N: |
---|
2487 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
2488 | break; |
---|
2489 | case SIZE_2NxN: |
---|
2490 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
2491 | break; |
---|
2492 | case SIZE_Nx2N: |
---|
2493 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
2494 | break; |
---|
2495 | case SIZE_NxN: |
---|
2496 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
2497 | break; |
---|
2498 | default: |
---|
2499 | assert (0); |
---|
2500 | break; |
---|
2501 | } |
---|
2502 | } |
---|
2503 | #endif |
---|
2504 | |
---|
2505 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2506 | { |
---|
2507 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
2508 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
2509 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
2510 | } |
---|
2511 | |
---|
2512 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
2513 | { |
---|
2514 | UInt uiAbsIdx; |
---|
2515 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
2516 | |
---|
2517 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
2518 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
2519 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
2520 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
2521 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
2522 | } |
---|
2523 | |
---|
2524 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UInt uiCandInterDir, Int* paiCandRefIdx, TComMv* pacCandMv ) |
---|
2525 | { |
---|
2526 | AOT ( getInterDir( uiAbsPartIdx ) == 0 ); |
---|
2527 | ROTRS( getInterDir( uiAbsPartIdx ) == uiCandInterDir, false ); |
---|
2528 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2529 | { |
---|
2530 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2531 | { |
---|
2532 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != paiCandRefIdx[ uiRefListIdx ] || |
---|
2533 | getCUMvField( RefPicList( uiRefListIdx ) )->getMv ( uiAbsPartIdx ) != pacCandMv [ uiRefListIdx ] ) |
---|
2534 | { |
---|
2535 | return false; |
---|
2536 | } |
---|
2537 | } |
---|
2538 | } |
---|
2539 | return true; |
---|
2540 | } |
---|
2541 | |
---|
2542 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2543 | { |
---|
2544 | assert( getInterDir( uiAbsPartIdx ) != 0 ); |
---|
2545 | |
---|
2546 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
2547 | { |
---|
2548 | return false; |
---|
2549 | } |
---|
2550 | |
---|
2551 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
2552 | { |
---|
2553 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
2554 | { |
---|
2555 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
2556 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
2557 | { |
---|
2558 | return false; |
---|
2559 | } |
---|
2560 | } |
---|
2561 | } |
---|
2562 | |
---|
2563 | return true; |
---|
2564 | } |
---|
2565 | |
---|
2566 | Bool TComDataCU::avoidMergeCandidate( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, UInt uiCandInterDir, Int* paiCandRefIdx, TComMv* pacCandMv ) |
---|
2567 | { |
---|
2568 | // uiAbsPartIdx has to be the first index of the current PU |
---|
2569 | PartSize ePartSize = getPartitionSize( uiAbsPartIdx ); |
---|
2570 | |
---|
2571 | if ( ePartSize != SIZE_NxN && ePartSize != SIZE_2Nx2N ) |
---|
2572 | { |
---|
2573 | // we have exactly 2 PUs. Avoid imitating 2Nx2N. |
---|
2574 | if ( uiPUIdx == 1 ) |
---|
2575 | { |
---|
2576 | // we would merge the second PU |
---|
2577 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2578 | UInt uiAbsPartIdxOfFirstPU = uiAbsPartIdx - uiPUOffset; |
---|
2579 | if ( hasEqualMotion( uiAbsPartIdxOfFirstPU, uiCandInterDir, paiCandRefIdx, pacCandMv ) ) |
---|
2580 | { |
---|
2581 | // don't merge |
---|
2582 | return true; |
---|
2583 | } |
---|
2584 | } |
---|
2585 | } |
---|
2586 | if ( ePartSize == SIZE_NxN ) |
---|
2587 | { |
---|
2588 | if ( uiPUIdx == 3 ) |
---|
2589 | { |
---|
2590 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2591 | UInt uiPUOffsetIdx0 = uiAbsPartIdx - 3*uiPUOffset; |
---|
2592 | UInt uiPUOffsetIdx1 = uiAbsPartIdx - 2*uiPUOffset; |
---|
2593 | UInt uiPUOffsetIdx2 = uiAbsPartIdx - uiPUOffset; |
---|
2594 | |
---|
2595 | // avoid imitating 2Nx2N and Nx2N partitioning. |
---|
2596 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx2 ) && |
---|
2597 | hasEqualMotion( uiPUOffsetIdx1, uiCandInterDir, paiCandRefIdx, pacCandMv ) ) |
---|
2598 | { |
---|
2599 | // don't merge |
---|
2600 | return true; |
---|
2601 | } |
---|
2602 | |
---|
2603 | // avoid imitating 2NxN partitioning. |
---|
2604 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx1 ) && |
---|
2605 | hasEqualMotion( uiPUOffsetIdx2, uiCandInterDir, paiCandRefIdx, pacCandMv ) ) |
---|
2606 | { |
---|
2607 | // don't merge |
---|
2608 | return true; |
---|
2609 | } |
---|
2610 | } |
---|
2611 | } |
---|
2612 | return false; |
---|
2613 | } |
---|
2614 | |
---|
2615 | Bool TComDataCU::avoidMergeCandidate( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
2616 | { |
---|
2617 | // uiAbsPartIdx has to be the first index of the current PU |
---|
2618 | |
---|
2619 | if ( !pcCandCU ) |
---|
2620 | { |
---|
2621 | return true; |
---|
2622 | } |
---|
2623 | |
---|
2624 | PartSize ePartSize = getPartitionSize( uiAbsPartIdx ); |
---|
2625 | |
---|
2626 | if ( ePartSize != SIZE_NxN && ePartSize != SIZE_2Nx2N ) |
---|
2627 | { |
---|
2628 | // we have exactly 2 PUs. Avoid imitating 2Nx2N. |
---|
2629 | if ( uiPUIdx == 1 ) |
---|
2630 | { |
---|
2631 | // we would merge the second PU |
---|
2632 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2633 | UInt uiAbsPartIdxOfFirstPU = uiAbsPartIdx - uiPUOffset; |
---|
2634 | if ( hasEqualMotion( uiAbsPartIdxOfFirstPU, pcCandCU, uiCandAbsPartIdx ) ) |
---|
2635 | { |
---|
2636 | // don't merge |
---|
2637 | return true; |
---|
2638 | } |
---|
2639 | } |
---|
2640 | } |
---|
2641 | if ( ePartSize == SIZE_NxN ) |
---|
2642 | { |
---|
2643 | if ( uiPUIdx == 3 ) |
---|
2644 | { |
---|
2645 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
2646 | UInt uiPUOffsetIdx0 = uiAbsPartIdx - 3*uiPUOffset; |
---|
2647 | UInt uiPUOffsetIdx1 = uiAbsPartIdx - 2*uiPUOffset; |
---|
2648 | UInt uiPUOffsetIdx2 = uiAbsPartIdx - uiPUOffset; |
---|
2649 | |
---|
2650 | // avoid imitating 2Nx2N and Nx2N partitioning. |
---|
2651 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx2 ) && |
---|
2652 | hasEqualMotion( uiPUOffsetIdx1, pcCandCU, uiCandAbsPartIdx ) ) |
---|
2653 | { |
---|
2654 | // don't merge |
---|
2655 | return true; |
---|
2656 | } |
---|
2657 | |
---|
2658 | // avoid imitating 2NxN partitioning. |
---|
2659 | if ( hasEqualMotion( uiPUOffsetIdx0, this, uiPUOffsetIdx1 ) && |
---|
2660 | hasEqualMotion( uiPUOffsetIdx2, pcCandCU, uiCandAbsPartIdx ) ) |
---|
2661 | { |
---|
2662 | // don't merge |
---|
2663 | return true; |
---|
2664 | } |
---|
2665 | } |
---|
2666 | } |
---|
2667 | return false; |
---|
2668 | } |
---|
2669 | |
---|
2670 | /** Constructs a list of merging candidates |
---|
2671 | * \param uiAbsPartIdx |
---|
2672 | * \param uiPUIdx |
---|
2673 | * \param uiDepth |
---|
2674 | * \param pcMvFieldNeighbours |
---|
2675 | * \param puhInterDirNeighbours |
---|
2676 | * \param puiNeighbourCandIdx |
---|
2677 | * \returns Void |
---|
2678 | */ |
---|
2679 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, UInt* puiNeighbourCandIdx ) |
---|
2680 | { |
---|
2681 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
2682 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
2683 | Bool bNoPdmMerge = ( m_pcSlice->getSPS()->getViewId() == 0 || ( m_pcSlice->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) != PDM_USE_FOR_MERGE ); |
---|
2684 | UInt uiPdmMergePos = ( bNoPdmMerge ? 5 : PDM_MERGE_POS ); |
---|
2685 | UInt uiLeftAddr = ( uiPdmMergePos < 1 ? 1 : 0 ); |
---|
2686 | UInt uiAboveAddr = ( uiPdmMergePos < 2 ? 2 : 1 ); |
---|
2687 | UInt uiColocAddr = ( uiPdmMergePos < 3 ? 3 : 2 ); |
---|
2688 | UInt uiCorRTAddr = ( uiPdmMergePos < 4 ? 4 : 3 ); |
---|
2689 | UInt uiCorBLAddr = ( uiPdmMergePos < 5 ? 5 : 4 ); |
---|
2690 | UInt uiPdmAddr = uiPdmMergePos; |
---|
2691 | #else |
---|
2692 | UInt uiLeftAddr = 0; |
---|
2693 | UInt uiAboveAddr = 1; |
---|
2694 | UInt uiColocAddr = 2; |
---|
2695 | UInt uiCorRTAddr = 3; |
---|
2696 | UInt uiCorBLAddr = 4; |
---|
2697 | #endif |
---|
2698 | |
---|
2699 | bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
2700 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
2701 | { |
---|
2702 | abCandIsInter[ui] = false; |
---|
2703 | } |
---|
2704 | |
---|
2705 | //===== left ===== |
---|
2706 | UInt uiLeftPartIdx = 0; |
---|
2707 | TComDataCU* pcCULeft = 0; |
---|
2708 | pcCULeft = getPULeft( uiLeftPartIdx, uiAbsPartAddr ); |
---|
2709 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCULeft, uiLeftPartIdx ) ) |
---|
2710 | { |
---|
2711 | pcCULeft = NULL; |
---|
2712 | } |
---|
2713 | if( pcCULeft && !pcCULeft->isIntra( uiLeftPartIdx ) ) |
---|
2714 | { |
---|
2715 | abCandIsInter[uiLeftAddr] = true; |
---|
2716 | puiNeighbourCandIdx[uiLeftAddr] = uiLeftAddr+1; |
---|
2717 | } |
---|
2718 | if( abCandIsInter[uiLeftAddr] ) |
---|
2719 | { |
---|
2720 | // get Inter Dir |
---|
2721 | puhInterDirNeighbours[uiLeftAddr] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
2722 | // get Mv from Left |
---|
2723 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiLeftAddr<<1] ); |
---|
2724 | if ( getSlice()->isInterB() ) |
---|
2725 | { |
---|
2726 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(uiLeftAddr<<1)+1] ); |
---|
2727 | } |
---|
2728 | } |
---|
2729 | |
---|
2730 | |
---|
2731 | //===== top ===== |
---|
2732 | UInt uiAbovePartIdx = 0; |
---|
2733 | TComDataCU* pcCUAbove = 0; |
---|
2734 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiAbsPartAddr ); |
---|
2735 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCUAbove, uiAbovePartIdx ) ) |
---|
2736 | { |
---|
2737 | pcCUAbove = NULL; |
---|
2738 | } |
---|
2739 | if ( pcCUAbove && !pcCUAbove->isIntra( uiAbovePartIdx ) ) |
---|
2740 | { |
---|
2741 | abCandIsInter[uiAboveAddr] = true; |
---|
2742 | puiNeighbourCandIdx[uiAboveAddr] = uiAboveAddr+1; |
---|
2743 | } |
---|
2744 | if ( abCandIsInter[uiAboveAddr] ) |
---|
2745 | { |
---|
2746 | // get Inter Dir |
---|
2747 | puhInterDirNeighbours[uiAboveAddr] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
2748 | // get Mv from Above |
---|
2749 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiAboveAddr<<1] ); |
---|
2750 | if ( getSlice()->isInterB() ) |
---|
2751 | { |
---|
2752 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(uiAboveAddr<<1)+1] ); |
---|
2753 | } |
---|
2754 | } |
---|
2755 | |
---|
2756 | |
---|
2757 | //===== colocated ===== |
---|
2758 | #if MRG_NEIGH_COL |
---|
2759 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2760 | Int iRefIdxSkip[2] = {-1, -1}; |
---|
2761 | TComDataCU* pcTmpCU = NULL; |
---|
2762 | UInt uiIdxblk; |
---|
2763 | Int iRefIdxLeft[2] = {-1, -1}; |
---|
2764 | Int iRefIdxAbove[2] = {-1, -1}; |
---|
2765 | Int iRefIdxCor[2] = {-1, -1}; |
---|
2766 | |
---|
2767 | UInt uiPUIdxLT = 0; |
---|
2768 | UInt uiPUIdxRT = 0; |
---|
2769 | UInt uiPUIdxLB = 0; |
---|
2770 | PartSize cCurPS = m_pePartSize[uiAbsPartIdx]; |
---|
2771 | deriveLeftRightTopIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLT, uiPUIdxRT ); |
---|
2772 | deriveLeftBottomIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLB ); |
---|
2773 | |
---|
2774 | for (int i=0; i<2; i++) |
---|
2775 | { |
---|
2776 | RefPicList eRefPicList = ( i==1 ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2777 | |
---|
2778 | pcTmpCU = getPULeft(uiIdxblk, uiPUIdxLT); |
---|
2779 | iRefIdxLeft[i] = (pcTmpCU != NULL) ? pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdxblk) : -1; |
---|
2780 | pcTmpCU = getPUAbove(uiIdxblk, uiPUIdxLT); |
---|
2781 | iRefIdxAbove[i] = (pcTmpCU != NULL) ? pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdxblk) : -1; |
---|
2782 | pcTmpCU = getPUAboveRight( uiIdxblk, uiPUIdxRT ); |
---|
2783 | if (pcTmpCU == NULL) |
---|
2784 | { |
---|
2785 | pcTmpCU = getPUBelowLeft( uiIdxblk, uiPUIdxLB ); |
---|
2786 | } |
---|
2787 | if (pcTmpCU == NULL) |
---|
2788 | { |
---|
2789 | pcTmpCU = getPUAboveLeft( uiIdxblk, uiPUIdxLT ); |
---|
2790 | } |
---|
2791 | iRefIdxCor[i] = (pcTmpCU != NULL) ? pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdxblk) : -1; |
---|
2792 | |
---|
2793 | if (iRefIdxLeft[i] == iRefIdxAbove[i] && iRefIdxAbove[i] == iRefIdxCor[i]) |
---|
2794 | { |
---|
2795 | iRefIdxSkip[i] = (iRefIdxLeft[i] == -1) ? 0 : iRefIdxLeft[i]; |
---|
2796 | } |
---|
2797 | else if (iRefIdxLeft[i] == iRefIdxAbove[i]) |
---|
2798 | { |
---|
2799 | iRefIdxSkip[i] = (iRefIdxLeft[i] == -1) ? iRefIdxCor[i] : iRefIdxLeft[i]; |
---|
2800 | } |
---|
2801 | else if (iRefIdxAbove[i] == iRefIdxCor[i]) |
---|
2802 | { |
---|
2803 | iRefIdxSkip[i] = (iRefIdxAbove[i] == -1) ? iRefIdxLeft[i] : iRefIdxAbove[i]; |
---|
2804 | } |
---|
2805 | else if (iRefIdxLeft[i] == iRefIdxCor[i]) |
---|
2806 | { |
---|
2807 | iRefIdxSkip[i] = (iRefIdxLeft[i] == -1) ? iRefIdxAbove[i] : iRefIdxLeft[i]; |
---|
2808 | } |
---|
2809 | else if (iRefIdxLeft[i] == -1) |
---|
2810 | { |
---|
2811 | iRefIdxSkip[i] = min(iRefIdxAbove[i], iRefIdxCor[i]); |
---|
2812 | } |
---|
2813 | else if (iRefIdxAbove[i] == -1) |
---|
2814 | { |
---|
2815 | iRefIdxSkip[i] = min(iRefIdxLeft[i], iRefIdxCor[i]); |
---|
2816 | } |
---|
2817 | else if (iRefIdxCor[i] == -1) |
---|
2818 | { |
---|
2819 | iRefIdxSkip[i] = min(iRefIdxLeft[i], iRefIdxAbove[i]); |
---|
2820 | } |
---|
2821 | else |
---|
2822 | { |
---|
2823 | iRefIdxSkip[i] = min( min(iRefIdxLeft[i], iRefIdxAbove[i]), iRefIdxCor[i]); |
---|
2824 | } |
---|
2825 | } |
---|
2826 | #endif |
---|
2827 | #if MTK_TMVP_H_MRG |
---|
2828 | //>> MTK colocated-RightBottom |
---|
2829 | UInt uiPartIdxRB; |
---|
2830 | Int uiLCUIdx = getAddr(); |
---|
2831 | PartSize eCUMode = m_pePartSize[0]; |
---|
2832 | |
---|
2833 | deriveRightBottomIdx( eCUMode, uiPUIdx, uiPartIdxRB ); |
---|
2834 | |
---|
2835 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
2836 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
2837 | |
---|
2838 | TComMv cColMv; |
---|
2839 | Int iRefIdx; |
---|
2840 | |
---|
2841 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getWidth() ) // image boundary check |
---|
2842 | { |
---|
2843 | uiLCUIdx = -1; |
---|
2844 | } |
---|
2845 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
2846 | { |
---|
2847 | uiLCUIdx = -1; |
---|
2848 | } |
---|
2849 | else |
---|
2850 | { |
---|
2851 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
2852 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
2853 | { |
---|
2854 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
2855 | uiLCUIdx = getAddr(); |
---|
2856 | } |
---|
2857 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
2858 | { |
---|
2859 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
2860 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU(); |
---|
2861 | } |
---|
2862 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
2863 | { |
---|
2864 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
2865 | uiLCUIdx = getAddr() + 1; |
---|
2866 | } |
---|
2867 | else //is the right bottom corner of LCU |
---|
2868 | { |
---|
2869 | uiAbsPartAddr = 0; |
---|
2870 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU() + 1; |
---|
2871 | } |
---|
2872 | } |
---|
2873 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2874 | iRefIdx = iRefIdxSkip[0]; |
---|
2875 | #else |
---|
2876 | iRefIdx = 0; // scaled to 1st ref pic for List0/List1 |
---|
2877 | #endif |
---|
2878 | |
---|
2879 | #if FT_TCTR_MRG |
---|
2880 | Bool bExistMV = false; |
---|
2881 | UInt uiPartIdxCenter; |
---|
2882 | UInt uiCurLCUIdx = getAddr(); |
---|
2883 | xDeriveCenterIdx( eCUMode, uiPUIdx, uiPartIdxCenter ); |
---|
2884 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
2885 | if( bExistMV == false ) |
---|
2886 | { |
---|
2887 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2888 | } |
---|
2889 | if( bExistMV ) |
---|
2890 | #else |
---|
2891 | if (uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ) ) |
---|
2892 | #endif |
---|
2893 | { |
---|
2894 | abCandIsInter[uiColocAddr] = true; |
---|
2895 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2896 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cColMv, iRefIdx ); |
---|
2897 | #else |
---|
2898 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cColMv, 0 ); |
---|
2899 | #endif |
---|
2900 | puiNeighbourCandIdx[uiColocAddr] = uiColocAddr+1; |
---|
2901 | |
---|
2902 | if ( getSlice()->isInterB() ) |
---|
2903 | { |
---|
2904 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2905 | iRefIdx = iRefIdxSkip[1]; |
---|
2906 | #endif |
---|
2907 | #if FT_TCTR_MRG |
---|
2908 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
2909 | if( bExistMV == false ) |
---|
2910 | { |
---|
2911 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
2912 | } |
---|
2913 | if( bExistMV ) |
---|
2914 | #else |
---|
2915 | if (xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx) ) |
---|
2916 | #endif |
---|
2917 | { |
---|
2918 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2919 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cColMv, iRefIdx ); |
---|
2920 | #else |
---|
2921 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cColMv, 0 ); |
---|
2922 | #endif |
---|
2923 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
2924 | } |
---|
2925 | else |
---|
2926 | { |
---|
2927 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2928 | } |
---|
2929 | } |
---|
2930 | else |
---|
2931 | { |
---|
2932 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2933 | } |
---|
2934 | } |
---|
2935 | #else //MTK_TMVP_H_MRG |
---|
2936 | #if FT_TCTR_MRG |
---|
2937 | TComMv cMvTCenter[2]; |
---|
2938 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2939 | Int iRefIdx = iRefIdxSkip[0]; |
---|
2940 | if (xGetCenterCol( uiPUIdx, REF_PIC_LIST_0, iRefIdx, &cMvTCenter[0] )) |
---|
2941 | #else |
---|
2942 | if (xGetCenterCol( uiPUIdx, REF_PIC_LIST_0, 0, &cMvTCenter[0] )) |
---|
2943 | #endif |
---|
2944 | { |
---|
2945 | abCandIsInter[uiColocAddr] = true; |
---|
2946 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2947 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMvTCenter[0], iRefIdx ); |
---|
2948 | #else |
---|
2949 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMvTCenter[0], 0 ); |
---|
2950 | #endif |
---|
2951 | puiNeighbourCandIdx[uiColocAddr] = uiIdx; |
---|
2952 | |
---|
2953 | if ( getSlice()->isInterB() ) |
---|
2954 | { |
---|
2955 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2956 | if ( xGetCenterCol( uiPUIdx, REF_PIC_LIST_1, iRefIdx, &cMvTCenter[1] ) ) |
---|
2957 | #else |
---|
2958 | if ( xGetCenterCol( uiPUIdx, REF_PIC_LIST_1, 0, &cMvTCenter[1] ) ) |
---|
2959 | #endif |
---|
2960 | { |
---|
2961 | #if PANASONIC_MRG_TMVP_REFIDX |
---|
2962 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvTCenter[1], iRefIdx ); |
---|
2963 | #else |
---|
2964 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvTCenter[1], 0 ); |
---|
2965 | #endif |
---|
2966 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
2967 | } |
---|
2968 | else |
---|
2969 | { |
---|
2970 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2971 | } |
---|
2972 | } |
---|
2973 | else |
---|
2974 | { |
---|
2975 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
2976 | } |
---|
2977 | } |
---|
2978 | #else //FT_TCTR_MRG |
---|
2979 | UInt uiColDir = ( m_pcSlice->isInterB()? m_pcSlice->getColDir() : 0 ); |
---|
2980 | TComDataCU* pcCUColocated = getCUColocated( RefPicList( uiColDir ) ); |
---|
2981 | RefPicList eColRefPicList = ( m_pcSlice->isInterB()? RefPicList( 1-uiColDir ) : REF_PIC_LIST_0 ); |
---|
2982 | #if PANASONIC_MERGETEMPORALEXT |
---|
2983 | RefPicList eColRefPicList2 = (m_pcSlice->isInterB()? RefPicList(uiColDir) : REF_PIC_LIST_0); |
---|
2984 | #endif |
---|
2985 | if( pcCUColocated && !pcCUColocated->isIntra( uiAbsPartAddr ) && |
---|
2986 | pcCUColocated->getCUMvField( eColRefPicList )->getRefIdx( uiAbsPartAddr ) >= 0 ) |
---|
2987 | { |
---|
2988 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
2989 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC( eColRefPicList, pcCUColocated->getCUMvField( eColRefPicList )->getRefIdx( uiAbsPartAddr ) ); |
---|
2990 | TComMv cColMv = pcCUColocated->getCUMvField( eColRefPicList )->getMv( uiAbsPartAddr ); |
---|
2991 | |
---|
2992 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
2993 | Int iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_0, 0 )->getPOC(); |
---|
2994 | |
---|
2995 | TComMv cMv; |
---|
2996 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
2997 | |
---|
2998 | if( iScale == 1024 ) |
---|
2999 | { |
---|
3000 | cMv = cColMv; |
---|
3001 | } |
---|
3002 | else |
---|
3003 | { |
---|
3004 | cMv = cColMv.scaleMv( iScale ); |
---|
3005 | } |
---|
3006 | clipMv( cMv ); |
---|
3007 | abCandIsInter[uiColocAddr] = true; |
---|
3008 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMv, 0 ); |
---|
3009 | puiNeighbourCandIdx[uiColocAddr] = uiIdx; |
---|
3010 | if ( getSlice()->isInterB() ) |
---|
3011 | { |
---|
3012 | iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_1, 0 )->getPOC(); |
---|
3013 | TComMv cMvB; |
---|
3014 | iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
3015 | if( iScale == 1024 ) |
---|
3016 | { |
---|
3017 | cMvB = cColMv; |
---|
3018 | } |
---|
3019 | else |
---|
3020 | { |
---|
3021 | cMvB = cColMv.scaleMv( iScale ); |
---|
3022 | } |
---|
3023 | clipMv( cMvB ); |
---|
3024 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvB, 0 ); |
---|
3025 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
3026 | } |
---|
3027 | else |
---|
3028 | { |
---|
3029 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
3030 | } |
---|
3031 | } |
---|
3032 | #if PANASONIC_MERGETEMPORALEXT |
---|
3033 | else if( pcCUColocated && !pcCUColocated->isIntra( uiAbsPartAddr ) && |
---|
3034 | pcCUColocated->getCUMvField( eColRefPicList2 )->getRefIdx( uiAbsPartAddr ) >= 0 ) |
---|
3035 | { |
---|
3036 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
3037 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC( eColRefPicList2, pcCUColocated->getCUMvField( eColRefPicList2 )->getRefIdx( uiAbsPartAddr ) ); |
---|
3038 | TComMv cColMv = pcCUColocated->getCUMvField( eColRefPicList2 )->getMv( uiAbsPartAddr ); |
---|
3039 | |
---|
3040 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3041 | Int iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_0, 0 )->getPOC(); |
---|
3042 | |
---|
3043 | TComMv cMv; |
---|
3044 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
3045 | |
---|
3046 | if( iScale == 1024 ) |
---|
3047 | { |
---|
3048 | cMv = cColMv; |
---|
3049 | } |
---|
3050 | else |
---|
3051 | { |
---|
3052 | cMv = cColMv.scaleMv( iScale ); |
---|
3053 | } |
---|
3054 | clipMv( cMv ); |
---|
3055 | abCandIsInter[uiColocAddr] = true; |
---|
3056 | pcMvFieldNeighbours[uiColocAddr << 1].setMvField( cMv, 0 ); |
---|
3057 | puiNeighbourCandIdx[uiColocAddr] = uiIdx; |
---|
3058 | if ( getSlice()->isInterB() ) |
---|
3059 | { |
---|
3060 | iCurrRefPOC = m_pcSlice->getRefPic( REF_PIC_LIST_1, 0 )->getPOC(); |
---|
3061 | TComMv cMvB; |
---|
3062 | iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC ); |
---|
3063 | if( iScale == 1024 ) |
---|
3064 | { |
---|
3065 | cMvB = cColMv; |
---|
3066 | } |
---|
3067 | else |
---|
3068 | { |
---|
3069 | cMvB = cColMv.scaleMv( iScale ); |
---|
3070 | } |
---|
3071 | clipMv( cMvB ); |
---|
3072 | pcMvFieldNeighbours[ ( uiColocAddr << 1 ) + 1 ].setMvField( cMvB, 0 ); |
---|
3073 | puhInterDirNeighbours[uiColocAddr] = 3; |
---|
3074 | } |
---|
3075 | else |
---|
3076 | { |
---|
3077 | puhInterDirNeighbours[uiColocAddr] = 1; |
---|
3078 | } |
---|
3079 | } |
---|
3080 | #endif // PANASONIC_MERGETEMPORALEXT |
---|
3081 | #endif // FT_TCTR_MRG |
---|
3082 | #endif // MTK_TMVP_H_MRG |
---|
3083 | #endif // MRG_NEIGH_COL |
---|
3084 | |
---|
3085 | |
---|
3086 | //===== corners ===== |
---|
3087 | #if MRG_NEIGH_COL && PANASONIC_MRG_TMVP_REFIDX |
---|
3088 | uiPUIdxLT = 0; |
---|
3089 | uiPUIdxRT = 0; |
---|
3090 | uiPUIdxLB = 0; |
---|
3091 | cCurPS = m_pePartSize[uiAbsPartIdx]; |
---|
3092 | #else |
---|
3093 | UInt uiPUIdxLT = 0; |
---|
3094 | UInt uiPUIdxRT = 0; |
---|
3095 | UInt uiPUIdxLB = 0; |
---|
3096 | PartSize cCurPS = m_pePartSize[uiAbsPartIdx]; |
---|
3097 | #endif |
---|
3098 | |
---|
3099 | deriveLeftRightTopIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLT, uiPUIdxRT ); |
---|
3100 | deriveLeftBottomIdxGeneral( cCurPS, uiAbsPartIdx, uiPUIdx, uiPUIdxLB ); |
---|
3101 | |
---|
3102 | TComDataCU* pcCorner = 0; |
---|
3103 | UInt uiCornerIdx = 0; |
---|
3104 | |
---|
3105 | Bool bRTCornerCand = false; |
---|
3106 | Bool bLBCornerCand = false; |
---|
3107 | for( UInt uiIter = 0; uiIter < 2; uiIter++ ) |
---|
3108 | { |
---|
3109 | if( !bRTCornerCand ) |
---|
3110 | { |
---|
3111 | pcCorner = getPUAboveRight( uiCornerIdx, uiPUIdxRT ); |
---|
3112 | xCheckCornerCand( pcCorner, uiCornerIdx, uiIter, bRTCornerCand ); |
---|
3113 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCorner, uiCornerIdx ) ) |
---|
3114 | { |
---|
3115 | bRTCornerCand = false; |
---|
3116 | } |
---|
3117 | if( bRTCornerCand ) |
---|
3118 | { |
---|
3119 | abCandIsInter[uiCorRTAddr] = true; |
---|
3120 | puiNeighbourCandIdx[uiCorRTAddr] = uiCorRTAddr+1; |
---|
3121 | // get Inter Dir |
---|
3122 | puhInterDirNeighbours[uiCorRTAddr] = pcCorner->getInterDir( uiCornerIdx ); |
---|
3123 | // get Mv from Left |
---|
3124 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiCorRTAddr << 1] ); |
---|
3125 | if ( getSlice()->isInterB() ) |
---|
3126 | { |
---|
3127 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[( uiCorRTAddr << 1 ) + 1] ); |
---|
3128 | } |
---|
3129 | } |
---|
3130 | } |
---|
3131 | if( !bLBCornerCand ) |
---|
3132 | { |
---|
3133 | pcCorner = getPUBelowLeft( uiCornerIdx, uiPUIdxLB ); |
---|
3134 | xCheckCornerCand( pcCorner, uiCornerIdx, uiIter, bLBCornerCand ); |
---|
3135 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, pcCorner, uiCornerIdx ) ) |
---|
3136 | { |
---|
3137 | bLBCornerCand = false; |
---|
3138 | } |
---|
3139 | if( bLBCornerCand ) |
---|
3140 | { |
---|
3141 | uiCorBLAddr = 4; |
---|
3142 | abCandIsInter[uiCorBLAddr] = true; |
---|
3143 | puiNeighbourCandIdx[uiCorBLAddr] = uiCorBLAddr+1; |
---|
3144 | // get Inter Dir |
---|
3145 | puhInterDirNeighbours[uiCorBLAddr] = pcCorner->getInterDir( uiCornerIdx ); |
---|
3146 | // get Mv from Left |
---|
3147 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[uiCorBLAddr << 1] ); |
---|
3148 | if ( getSlice()->isInterB() ) |
---|
3149 | { |
---|
3150 | pcCorner->getMvField( pcCorner, uiCornerIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[( uiCorBLAddr << 1 ) + 1] ); |
---|
3151 | } |
---|
3152 | } |
---|
3153 | } |
---|
3154 | } |
---|
3155 | |
---|
3156 | |
---|
3157 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
3158 | //===== add merge with predicted depth maps ===== |
---|
3159 | TComMv acPdmMv [2]; |
---|
3160 | Int aiPdmRefIdx [2] = {-1,-1}; |
---|
3161 | Int iPdmInterDir = getPdmMergeCandidate( uiPUIdx, aiPdmRefIdx, acPdmMv ); |
---|
3162 | if( iPdmInterDir ) |
---|
3163 | { |
---|
3164 | if( avoidMergeCandidate( uiAbsPartIdx, uiPUIdx, uiDepth, iPdmInterDir, aiPdmRefIdx, acPdmMv ) ) |
---|
3165 | { |
---|
3166 | iPdmInterDir = 0; |
---|
3167 | } |
---|
3168 | } |
---|
3169 | if( iPdmInterDir ) |
---|
3170 | { |
---|
3171 | abCandIsInter [ uiPdmAddr ] = true; |
---|
3172 | puiNeighbourCandIdx [ uiPdmAddr ] = uiPdmAddr + 1; |
---|
3173 | puhInterDirNeighbours[ uiPdmAddr ] = iPdmInterDir; |
---|
3174 | if( ( iPdmInterDir & 1 ) == 1 ) |
---|
3175 | { |
---|
3176 | pcMvFieldNeighbours[ uiPdmAddr<<1 ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] ); |
---|
3177 | } |
---|
3178 | if( ( iPdmInterDir & 2 ) == 2 ) |
---|
3179 | { |
---|
3180 | pcMvFieldNeighbours[(uiPdmAddr<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] ); |
---|
3181 | } |
---|
3182 | } |
---|
3183 | #endif |
---|
3184 | |
---|
3185 | |
---|
3186 | //===== remove duplicates ===== |
---|
3187 | for( UInt uiOuter = 0; uiOuter < MRG_MAX_NUM_CANDS; uiOuter++ ) |
---|
3188 | { |
---|
3189 | if( abCandIsInter[ uiOuter ] && ( puiNeighbourCandIdx[uiOuter] == uiOuter + 1 ) ) |
---|
3190 | { |
---|
3191 | for( UInt uiIter = uiOuter + 1; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
3192 | { |
---|
3193 | if( abCandIsInter[ uiIter ] ) |
---|
3194 | { |
---|
3195 | UInt uiMvFieldNeighIdxCurr = uiOuter << 1; |
---|
3196 | UInt uiMvFieldNeighIdxComp = uiIter << 1; |
---|
3197 | if( getSlice()->isInterB() ) |
---|
3198 | { |
---|
3199 | if( puhInterDirNeighbours[ uiOuter ] == 3 ) |
---|
3200 | { |
---|
3201 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getRefIdx() && pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getRefIdx() && |
---|
3202 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getMv() && pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getMv() && |
---|
3203 | puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ) |
---|
3204 | { |
---|
3205 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3206 | abCandIsInter[ uiIter ] = false; |
---|
3207 | } |
---|
3208 | } |
---|
3209 | else if( puhInterDirNeighbours[ uiOuter ] == 2 ) |
---|
3210 | { |
---|
3211 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getRefIdx() && |
---|
3212 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr + 1 ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp + 1 ].getMv() && |
---|
3213 | puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ) |
---|
3214 | { |
---|
3215 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3216 | abCandIsInter[ uiIter ] = false; |
---|
3217 | } |
---|
3218 | } |
---|
3219 | else |
---|
3220 | { |
---|
3221 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getRefIdx() && |
---|
3222 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getMv() && |
---|
3223 | puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ) |
---|
3224 | { |
---|
3225 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3226 | abCandIsInter[ uiIter ] = false; |
---|
3227 | } |
---|
3228 | } |
---|
3229 | } |
---|
3230 | else |
---|
3231 | { |
---|
3232 | if( pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getRefIdx() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getRefIdx() && |
---|
3233 | pcMvFieldNeighbours[ uiMvFieldNeighIdxCurr ].getMv() == pcMvFieldNeighbours[ uiMvFieldNeighIdxComp ].getMv() ) |
---|
3234 | { |
---|
3235 | assert( puhInterDirNeighbours[ uiOuter ] == puhInterDirNeighbours[ uiIter ] ); |
---|
3236 | puiNeighbourCandIdx[ uiIter ] = puiNeighbourCandIdx[ uiOuter ]; |
---|
3237 | abCandIsInter[ uiIter ] = false; |
---|
3238 | } |
---|
3239 | } |
---|
3240 | } |
---|
3241 | } |
---|
3242 | } |
---|
3243 | } |
---|
3244 | #if AVOID_ZERO_MERGE_CANDIDATE |
---|
3245 | // if all merge candidate |
---|
3246 | int i; |
---|
3247 | for ( i=0; i<MRG_MAX_NUM_CANDS; i++ ) |
---|
3248 | { |
---|
3249 | if ( abCandIsInter[i] ) |
---|
3250 | { |
---|
3251 | break; |
---|
3252 | } |
---|
3253 | } |
---|
3254 | if ( i==MRG_MAX_NUM_CANDS ) // no merge candidate |
---|
3255 | { |
---|
3256 | abCandIsInter[0] = true; |
---|
3257 | puiNeighbourCandIdx[0] = 1; |
---|
3258 | puhInterDirNeighbours[0] = 1; |
---|
3259 | pcMvFieldNeighbours[0].setMvField( TComMv(0, 0), 0 ); |
---|
3260 | if ( getSlice()->isInterB() ) |
---|
3261 | { |
---|
3262 | puhInterDirNeighbours[0] = 3; |
---|
3263 | pcMvFieldNeighbours[1].setMvField( TComMv(0, 0), 0 ); |
---|
3264 | } |
---|
3265 | } |
---|
3266 | #endif |
---|
3267 | } |
---|
3268 | |
---|
3269 | Void TComDataCU::xCheckCornerCand( TComDataCU* pcCorner, UInt uiCornerPUIdx, UInt uiIter, Bool& rbValidCand ) |
---|
3270 | { |
---|
3271 | if( uiIter == 0 ) |
---|
3272 | { |
---|
3273 | if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) ) |
---|
3274 | { |
---|
3275 | rbValidCand = true; |
---|
3276 | if( getSlice()->isInterB() ) |
---|
3277 | { |
---|
3278 | if ( pcCorner->getInterDir( uiCornerPUIdx ) == 1 ) |
---|
3279 | { |
---|
3280 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3281 | { |
---|
3282 | rbValidCand = false; |
---|
3283 | } |
---|
3284 | } |
---|
3285 | else if ( pcCorner->getInterDir( uiCornerPUIdx ) == 2 ) |
---|
3286 | { |
---|
3287 | if( pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3288 | { |
---|
3289 | rbValidCand = false; |
---|
3290 | } |
---|
3291 | } |
---|
3292 | else |
---|
3293 | { |
---|
3294 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) != 0 || pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3295 | { |
---|
3296 | rbValidCand = false; |
---|
3297 | } |
---|
3298 | } |
---|
3299 | } |
---|
3300 | else if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) != 0 ) |
---|
3301 | { |
---|
3302 | rbValidCand = false; |
---|
3303 | } |
---|
3304 | } |
---|
3305 | } |
---|
3306 | else |
---|
3307 | { |
---|
3308 | if( pcCorner && !pcCorner->isIntra( uiCornerPUIdx ) ) |
---|
3309 | { |
---|
3310 | rbValidCand = true; |
---|
3311 | if( getSlice()->isInterB() ) |
---|
3312 | { |
---|
3313 | if ( pcCorner->getInterDir( uiCornerPUIdx ) == 1 ) |
---|
3314 | { |
---|
3315 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3316 | { |
---|
3317 | rbValidCand = false; |
---|
3318 | } |
---|
3319 | } |
---|
3320 | else if ( pcCorner->getInterDir( uiCornerPUIdx ) == 2 ) |
---|
3321 | { |
---|
3322 | if( pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3323 | { |
---|
3324 | rbValidCand = false; |
---|
3325 | } |
---|
3326 | } |
---|
3327 | else |
---|
3328 | { |
---|
3329 | if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) < 0 || pcCorner->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3330 | { |
---|
3331 | rbValidCand = false; |
---|
3332 | } |
---|
3333 | } |
---|
3334 | } |
---|
3335 | else if( pcCorner->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiCornerPUIdx ) < 0 ) |
---|
3336 | { |
---|
3337 | rbValidCand = false; |
---|
3338 | } |
---|
3339 | } |
---|
3340 | } |
---|
3341 | } |
---|
3342 | |
---|
3343 | Void TComDataCU::setNeighbourCandIdxSubParts( UInt uiCandIdx, UChar uhNumCands, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) |
---|
3344 | { |
---|
3345 | setSubPartUChar( uhNumCands, m_apuhNeighbourCandIdx[uiCandIdx], uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
3346 | } |
---|
3347 | |
---|
3348 | AMVP_MODE TComDataCU::getAMVPMode(UInt uiIdx) |
---|
3349 | { |
---|
3350 | return m_pcSlice->getSPS()->getAMVPMode(m_puhDepth[uiIdx]); |
---|
3351 | } |
---|
3352 | |
---|
3353 | /** Constructs a list of candidates for AMVP |
---|
3354 | * \param uiPartIdx |
---|
3355 | * \param uiPartAddr |
---|
3356 | * \param eRefPicList |
---|
3357 | * \param iRefIdx |
---|
3358 | * \param pInfo |
---|
3359 | * \param puiNeighbourCandIdx |
---|
3360 | * \returns Void |
---|
3361 | */ |
---|
3362 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
3363 | { |
---|
3364 | PartSize eCUMode = m_pePartSize[0]; |
---|
3365 | |
---|
3366 | TComMv cMvPred; |
---|
3367 | |
---|
3368 | pInfo->iN = 0; |
---|
3369 | #if !DCM_SIMPLIFIED_MVP |
---|
3370 | UInt uiIdx; |
---|
3371 | #endif |
---|
3372 | |
---|
3373 | if (iRefIdx < 0) |
---|
3374 | { |
---|
3375 | return; |
---|
3376 | } |
---|
3377 | |
---|
3378 | Int iLeftIdx = -1; |
---|
3379 | |
---|
3380 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
3381 | #if ( PDM_AMVP_POS == 0 ) |
---|
3382 | // get inter-view mv predictor (at position 0) |
---|
3383 | TComMv cPdmMvPred; |
---|
3384 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3385 | { |
---|
3386 | clipMv( cPdmMvPred ); |
---|
3387 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3388 | } |
---|
3389 | #endif |
---|
3390 | #endif |
---|
3391 | |
---|
3392 | #if !DCM_SIMPLIFIED_MVP |
---|
3393 | pInfo->m_acMvCand[pInfo->iN++] = cMvPred; //dummy mv |
---|
3394 | #endif |
---|
3395 | |
---|
3396 | //-- Get Spatial MV |
---|
3397 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
3398 | #if (DCM_SIMPLIFIED_MVP && !TI_AMVP_SMVP_SIMPLIFIED) || (!DCM_SIMPLIFIED_MVP) || MTK_TMVP_H_AMVP |
---|
3399 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
3400 | #endif |
---|
3401 | Bool bAdded = false; |
---|
3402 | #if !DCM_SIMPLIFIED_MVP |
---|
3403 | Int iLeftMvIdx = -1; |
---|
3404 | Int iAboveMvIdx = -1; |
---|
3405 | Int iCornerMvIdx = -1; |
---|
3406 | #endif |
---|
3407 | |
---|
3408 | deriveLeftRightTopIdx( eCUMode, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
3409 | deriveLeftBottomIdx( eCUMode, uiPartIdx, uiPartIdxLB ); |
---|
3410 | |
---|
3411 | #if DCM_SIMPLIFIED_MVP |
---|
3412 | // Left predictor search |
---|
3413 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3414 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3415 | if (!bAdded) |
---|
3416 | { |
---|
3417 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3418 | } |
---|
3419 | #else |
---|
3420 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxLB]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-= uiNumPartInCUWidth ) |
---|
3421 | { |
---|
3422 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_LEFT ); |
---|
3423 | } |
---|
3424 | #endif |
---|
3425 | |
---|
3426 | #if MTK_AMVP_SMVP_DERIVATION |
---|
3427 | if(!bAdded) |
---|
3428 | { |
---|
3429 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3430 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3431 | if (!bAdded) |
---|
3432 | { |
---|
3433 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
3434 | } |
---|
3435 | #else |
---|
3436 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxLB]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-= uiNumPartInCUWidth ) |
---|
3437 | { |
---|
3438 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_LEFT ); |
---|
3439 | } |
---|
3440 | #endif |
---|
3441 | } |
---|
3442 | #endif |
---|
3443 | if( bAdded ) |
---|
3444 | { |
---|
3445 | iLeftIdx = pInfo->iN - 1; |
---|
3446 | } |
---|
3447 | |
---|
3448 | |
---|
3449 | |
---|
3450 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
3451 | #if ( PDM_AMVP_POS == 1 ) |
---|
3452 | // get inter-view mv predictor (at position 1) |
---|
3453 | TComMv cPdmMvPred; |
---|
3454 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3455 | { |
---|
3456 | clipMv( cPdmMvPred ); |
---|
3457 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3458 | } |
---|
3459 | #endif |
---|
3460 | #endif |
---|
3461 | |
---|
3462 | |
---|
3463 | // Above predictor search |
---|
3464 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3465 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3466 | { |
---|
3467 | pInfo->iN--; //remove duplicate entries |
---|
3468 | bAdded = false; |
---|
3469 | } |
---|
3470 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3471 | if (!bAdded) |
---|
3472 | { |
---|
3473 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3474 | } |
---|
3475 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3476 | { |
---|
3477 | pInfo->iN--; //remove duplicate entries |
---|
3478 | bAdded = false; |
---|
3479 | } |
---|
3480 | #else |
---|
3481 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxRT]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-- ) |
---|
3482 | { |
---|
3483 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_ABOVE); |
---|
3484 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3485 | { |
---|
3486 | pInfo->iN--; //remove duplicate entries |
---|
3487 | bAdded = false; |
---|
3488 | } |
---|
3489 | } |
---|
3490 | #endif |
---|
3491 | if(!bAdded) |
---|
3492 | { |
---|
3493 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3494 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3495 | { |
---|
3496 | pInfo->iN--; //remove duplicate entries |
---|
3497 | } |
---|
3498 | } |
---|
3499 | #if MTK_AMVP_SMVP_DERIVATION |
---|
3500 | if(!bAdded) |
---|
3501 | { |
---|
3502 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3503 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3504 | { |
---|
3505 | pInfo->iN--; //remove duplicate entries |
---|
3506 | bAdded = false; |
---|
3507 | } |
---|
3508 | #if TI_AMVP_SMVP_SIMPLIFIED |
---|
3509 | if (!bAdded) |
---|
3510 | { |
---|
3511 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
3512 | } |
---|
3513 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3514 | { |
---|
3515 | pInfo->iN--; //remove duplicate entries |
---|
3516 | bAdded = false; |
---|
3517 | } |
---|
3518 | #else |
---|
3519 | for ( Int idx = (Int)g_auiZscanToRaster[uiPartIdxRT]; !bAdded && idx >= (Int)g_auiZscanToRaster[uiPartIdxLT]; idx-- ) |
---|
3520 | { |
---|
3521 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[idx], MD_ABOVE); |
---|
3522 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3523 | { |
---|
3524 | pInfo->iN--; //remove duplicate entries |
---|
3525 | bAdded = false; |
---|
3526 | } |
---|
3527 | } |
---|
3528 | #endif |
---|
3529 | if(!bAdded) |
---|
3530 | { |
---|
3531 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3532 | if (bAdded && iLeftIdx >= 0 && pInfo->m_acMvCand[iLeftIdx] == pInfo->m_acMvCand[pInfo->iN-1]) |
---|
3533 | { |
---|
3534 | pInfo->iN--; //remove duplicate entries |
---|
3535 | } |
---|
3536 | } |
---|
3537 | } |
---|
3538 | #endif |
---|
3539 | #else |
---|
3540 | //Left |
---|
3541 | for ( uiIdx = g_auiZscanToRaster[uiPartIdxLT]; uiIdx <= g_auiZscanToRaster[uiPartIdxLB]; uiIdx+= uiNumPartInCUWidth ) |
---|
3542 | { |
---|
3543 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[uiIdx], MD_LEFT ); |
---|
3544 | if (bAdded && iLeftMvIdx < 0) |
---|
3545 | { |
---|
3546 | iLeftMvIdx = pInfo->iN-1; |
---|
3547 | } |
---|
3548 | if (bAdded) break; |
---|
3549 | } |
---|
3550 | |
---|
3551 | bAdded = false; |
---|
3552 | //Above |
---|
3553 | for ( uiIdx = g_auiZscanToRaster[uiPartIdxLT]; uiIdx <= g_auiZscanToRaster[uiPartIdxRT]; uiIdx++ ) |
---|
3554 | { |
---|
3555 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, g_auiRasterToZscan[uiIdx], MD_ABOVE); |
---|
3556 | if (bAdded && iAboveMvIdx < 0) |
---|
3557 | { |
---|
3558 | iAboveMvIdx = pInfo->iN-1; |
---|
3559 | } |
---|
3560 | if (bAdded) break; |
---|
3561 | } |
---|
3562 | |
---|
3563 | bAdded = false; |
---|
3564 | //Above Right |
---|
3565 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
3566 | if (bAdded && iCornerMvIdx < 0) |
---|
3567 | { |
---|
3568 | iCornerMvIdx = pInfo->iN-1; |
---|
3569 | } |
---|
3570 | |
---|
3571 | //Below Left |
---|
3572 | if (!bAdded) |
---|
3573 | { |
---|
3574 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
3575 | } |
---|
3576 | if (bAdded && iCornerMvIdx < 0) |
---|
3577 | { |
---|
3578 | iCornerMvIdx = pInfo->iN-1; |
---|
3579 | } |
---|
3580 | |
---|
3581 | //Above Left |
---|
3582 | if (!bAdded) |
---|
3583 | { |
---|
3584 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
3585 | } |
---|
3586 | |
---|
3587 | if (bAdded && iCornerMvIdx < 0) |
---|
3588 | { |
---|
3589 | iCornerMvIdx = pInfo->iN-1; |
---|
3590 | } |
---|
3591 | |
---|
3592 | assert(iLeftMvIdx!=0 && iAboveMvIdx!=0 && iCornerMvIdx!=0); |
---|
3593 | |
---|
3594 | if (iLeftMvIdx < 0 && iAboveMvIdx < 0 && iCornerMvIdx < 0) |
---|
3595 | { |
---|
3596 | //done --> already zero Mv |
---|
3597 | } |
---|
3598 | else if ( (iLeftMvIdx > 0 && iAboveMvIdx > 0 && iCornerMvIdx > 0) || iLeftMvIdx*iAboveMvIdx*iCornerMvIdx < 0) |
---|
3599 | { |
---|
3600 | TComMv cLeftMv, cAboveMv, cCornerMv; |
---|
3601 | |
---|
3602 | if (iLeftMvIdx > 0) |
---|
3603 | { |
---|
3604 | cLeftMv = pInfo->m_acMvCand[iLeftMvIdx]; |
---|
3605 | } |
---|
3606 | if (iAboveMvIdx > 0) |
---|
3607 | { |
---|
3608 | cAboveMv = pInfo->m_acMvCand[iAboveMvIdx]; |
---|
3609 | } |
---|
3610 | if (iCornerMvIdx > 0) |
---|
3611 | { |
---|
3612 | cCornerMv = pInfo->m_acMvCand[iCornerMvIdx]; |
---|
3613 | } |
---|
3614 | pInfo->m_acMvCand[0].setHor ( Median (cLeftMv.getHor(), cAboveMv.getHor(), cCornerMv.getHor()) ); |
---|
3615 | pInfo->m_acMvCand[0].setVer ( Median (cLeftMv.getVer(), cAboveMv.getVer(), cCornerMv.getVer()) ); |
---|
3616 | } |
---|
3617 | else //only one is available among three candidates |
---|
3618 | { |
---|
3619 | if (iLeftMvIdx > 0) |
---|
3620 | { |
---|
3621 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iLeftMvIdx]; |
---|
3622 | } |
---|
3623 | else if (iAboveMvIdx > 0) |
---|
3624 | { |
---|
3625 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iAboveMvIdx]; |
---|
3626 | } |
---|
3627 | else if (iCornerMvIdx > 0) |
---|
3628 | { |
---|
3629 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iCornerMvIdx]; |
---|
3630 | } |
---|
3631 | else |
---|
3632 | { |
---|
3633 | assert(0); |
---|
3634 | } |
---|
3635 | } |
---|
3636 | |
---|
3637 | clipMv(pInfo->m_acMvCand[0]); |
---|
3638 | TComMv cTempMv; |
---|
3639 | if ( ( ( ((eCUMode == SIZE_2NxN)) && uiPartIdx == 1 ) || |
---|
3640 | ( ((eCUMode == SIZE_Nx2N)) && uiPartIdx == 0 ) ) |
---|
3641 | && iLeftMvIdx > 0 ) |
---|
3642 | { |
---|
3643 | cTempMv = pInfo->m_acMvCand[0]; |
---|
3644 | pInfo->m_acMvCand[0] = pInfo->m_acMvCand[iLeftMvIdx]; |
---|
3645 | pInfo->m_acMvCand[iLeftMvIdx] = cTempMv; |
---|
3646 | } |
---|
3647 | #endif |
---|
3648 | |
---|
3649 | if (getAMVPMode(uiPartAddr) == AM_NONE) //Should be optimized later for special cases |
---|
3650 | { |
---|
3651 | assert(pInfo->iN > 0); |
---|
3652 | pInfo->iN = 1; |
---|
3653 | return; |
---|
3654 | } |
---|
3655 | |
---|
3656 | |
---|
3657 | |
---|
3658 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
3659 | #if ( PDM_AMVP_POS == 2 ) |
---|
3660 | // get inter-view mv predictor (at position 2) |
---|
3661 | TComMv cPdmMvPred; |
---|
3662 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3663 | { |
---|
3664 | clipMv( cPdmMvPred ); |
---|
3665 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3666 | } |
---|
3667 | #endif |
---|
3668 | #endif |
---|
3669 | |
---|
3670 | // Get Temporal Motion Predictor |
---|
3671 | #if AMVP_NEIGH_COL |
---|
3672 | #if MTK_TMVP_H_AMVP |
---|
3673 | int iRefIdx_Col = iRefIdx; |
---|
3674 | TComMv cColMv; |
---|
3675 | UInt uiPartIdxRB; |
---|
3676 | UInt uiAbsPartIdx; |
---|
3677 | UInt uiAbsPartAddr; |
---|
3678 | int uiLCUIdx = getAddr(); |
---|
3679 | |
---|
3680 | deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB ); |
---|
3681 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
3682 | |
---|
3683 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
3684 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
3685 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getWidth() ) // image boundary check |
---|
3686 | { |
---|
3687 | uiLCUIdx = -1; |
---|
3688 | } |
---|
3689 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getHeight() ) |
---|
3690 | { |
---|
3691 | uiLCUIdx = -1; |
---|
3692 | } |
---|
3693 | else |
---|
3694 | { |
---|
3695 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
3696 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
3697 | { |
---|
3698 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
3699 | uiLCUIdx = getAddr(); |
---|
3700 | } |
---|
3701 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
3702 | { |
---|
3703 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
3704 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU(); |
---|
3705 | } |
---|
3706 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
3707 | { |
---|
3708 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
3709 | uiLCUIdx = getAddr() + 1; |
---|
3710 | } |
---|
3711 | else //is the right bottom corner of LCU |
---|
3712 | { |
---|
3713 | uiAbsPartAddr = 0; |
---|
3714 | uiLCUIdx = getAddr() + m_pcPic->getFrameWidthInCU() + 1; |
---|
3715 | } |
---|
3716 | } |
---|
3717 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) |
---|
3718 | { |
---|
3719 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3720 | } |
---|
3721 | #if FT_TCTR_AMVP |
---|
3722 | else |
---|
3723 | { |
---|
3724 | UInt uiPartIdxCenter; |
---|
3725 | UInt uiCurLCUIdx = getAddr(); |
---|
3726 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
3727 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col )) |
---|
3728 | { |
---|
3729 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
3730 | } |
---|
3731 | } |
---|
3732 | #endif |
---|
3733 | //---- co-located RightBottom Temporal Predictor ---// |
---|
3734 | |
---|
3735 | #else //MTK_TMVP_H_AMVP |
---|
3736 | #if FT_TCTR_AMVP |
---|
3737 | TComMv cMvTCenter; |
---|
3738 | if (xGetCenterCol( uiPartIdx, eRefPicList, iRefIdx, &cMvTCenter )) |
---|
3739 | { |
---|
3740 | for (int i = pInfo->iN-1; i >= 0; i--) |
---|
3741 | { |
---|
3742 | pInfo->m_acMvCand[i+1] = pInfo->m_acMvCand[i]; |
---|
3743 | } |
---|
3744 | pInfo->m_acMvCand[0] = cMvTCenter; |
---|
3745 | pInfo->iN++; |
---|
3746 | } |
---|
3747 | #else //FT_TCTR_AMVP |
---|
3748 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
3749 | |
---|
3750 | UInt uiColDir = (m_pcSlice->isInterB()? m_pcSlice->getColDir() : 0); |
---|
3751 | |
---|
3752 | TComDataCU* pcCUColocated = getCUColocated(RefPicList(uiColDir)); |
---|
3753 | |
---|
3754 | RefPicList eColRefPicList = (m_pcSlice->isInterB()? RefPicList(1-uiColDir) : REF_PIC_LIST_0); |
---|
3755 | #if PANASONIC_AMVPTEMPORALEXT |
---|
3756 | RefPicList eColRefPicList2 = (m_pcSlice->isInterB()? RefPicList(uiColDir) : REF_PIC_LIST_0); |
---|
3757 | #endif |
---|
3758 | |
---|
3759 | if ( pcCUColocated && !pcCUColocated->isIntra(uiAbsPartAddr) && |
---|
3760 | pcCUColocated->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr) >= 0 ) |
---|
3761 | { |
---|
3762 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
3763 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC(eColRefPicList, pcCUColocated->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr)); |
---|
3764 | TComMv cColMv = pcCUColocated->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
3765 | |
---|
3766 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3767 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
3768 | |
---|
3769 | TComMv cMv; |
---|
3770 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
3771 | |
---|
3772 | if (iScale == 1024) |
---|
3773 | { |
---|
3774 | cMv = cColMv; |
---|
3775 | } |
---|
3776 | else |
---|
3777 | { |
---|
3778 | cMv = cColMv.scaleMv( iScale ); |
---|
3779 | } |
---|
3780 | |
---|
3781 | clipMv(cMv); |
---|
3782 | |
---|
3783 | pInfo->m_acMvCand[pInfo->iN++] = cMv ; |
---|
3784 | } |
---|
3785 | #if PANASONIC_AMVPTEMPORALEXT |
---|
3786 | else if ( pcCUColocated && !pcCUColocated->isIntra(uiAbsPartAddr) && |
---|
3787 | pcCUColocated->getCUMvField(eColRefPicList2)->getRefIdx(uiAbsPartAddr) >= 0 ) |
---|
3788 | { |
---|
3789 | Int iColPOC = pcCUColocated->getSlice()->getPOC(); |
---|
3790 | Int iColRefPOC = pcCUColocated->getSlice()->getRefPOC(eColRefPicList2, pcCUColocated->getCUMvField(eColRefPicList2)->getRefIdx(uiAbsPartAddr)); |
---|
3791 | TComMv cColMv = pcCUColocated->getCUMvField(eColRefPicList2)->getMv(uiAbsPartAddr); |
---|
3792 | |
---|
3793 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
3794 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
3795 | |
---|
3796 | TComMv cMv; |
---|
3797 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
3798 | |
---|
3799 | if (iScale == 1024) |
---|
3800 | { |
---|
3801 | cMv = cColMv; |
---|
3802 | } |
---|
3803 | else |
---|
3804 | { |
---|
3805 | cMv = cColMv.scaleMv( iScale ); |
---|
3806 | } |
---|
3807 | |
---|
3808 | clipMv(cMv); |
---|
3809 | |
---|
3810 | pInfo->m_acMvCand[pInfo->iN++] = cMv ; |
---|
3811 | } |
---|
3812 | #endif // PANASONIC_AMVPTEMPORALEXT |
---|
3813 | #endif // FT_TCTR_AMVP |
---|
3814 | #endif // MTK_TMVP_H_AMVP |
---|
3815 | #endif // AMVP_NEIGH_COL |
---|
3816 | |
---|
3817 | |
---|
3818 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
3819 | #if ( PDM_AMVP_POS == 3 ) |
---|
3820 | // get inter-view mv predictor (at position 3) |
---|
3821 | TComMv cPdmMvPred; |
---|
3822 | if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) ) |
---|
3823 | { |
---|
3824 | clipMv( cPdmMvPred ); |
---|
3825 | pInfo->m_acMvCand[ pInfo->iN++ ] = cPdmMvPred; |
---|
3826 | } |
---|
3827 | #endif |
---|
3828 | #endif |
---|
3829 | |
---|
3830 | // Check No MV Candidate |
---|
3831 | xUniqueMVPCand( pInfo ); |
---|
3832 | return ; |
---|
3833 | } |
---|
3834 | |
---|
3835 | #if DCM_SIMPLIFIED_MVP==0 |
---|
3836 | Bool TComDataCU::clearMVPCand( TComMv cMvd, AMVPInfo* pInfo ) |
---|
3837 | { |
---|
3838 | // only works for multiple candidates |
---|
3839 | if (pInfo->iN <= 1) |
---|
3840 | { |
---|
3841 | return false; |
---|
3842 | } |
---|
3843 | |
---|
3844 | // only works for non-zero mvd case |
---|
3845 | if (cMvd.getHor() == 0 && cMvd.getVer() == 0) |
---|
3846 | { |
---|
3847 | return false; |
---|
3848 | } |
---|
3849 | |
---|
3850 | TComMv acMv[ AMVP_MAX_NUM_CANDS ]; |
---|
3851 | Int aiValid [ AMVP_MAX_NUM_CANDS ]; |
---|
3852 | |
---|
3853 | Int iNTmp, i, j; |
---|
3854 | |
---|
3855 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3856 | { |
---|
3857 | aiValid[i] = 1; |
---|
3858 | } |
---|
3859 | |
---|
3860 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3861 | { |
---|
3862 | TComMv cMvCand = pInfo->m_acMvCand[i] + cMvd; |
---|
3863 | |
---|
3864 | UInt uiBestBits = xGetMvdBits(cMvd); |
---|
3865 | for ( j=0; j<pInfo->iN; j++ ) |
---|
3866 | { |
---|
3867 | if (aiValid[j] && i!=j && xGetMvdBits(cMvCand-pInfo->m_acMvCand[j]) < uiBestBits) |
---|
3868 | { |
---|
3869 | aiValid[i] = 0; |
---|
3870 | } |
---|
3871 | } |
---|
3872 | } |
---|
3873 | |
---|
3874 | iNTmp = 0; |
---|
3875 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3876 | { |
---|
3877 | if (aiValid[i]) |
---|
3878 | iNTmp++; |
---|
3879 | } |
---|
3880 | |
---|
3881 | if (iNTmp == pInfo->iN) |
---|
3882 | { |
---|
3883 | return false; |
---|
3884 | } |
---|
3885 | |
---|
3886 | assert(iNTmp > 0); |
---|
3887 | |
---|
3888 | iNTmp = 0; |
---|
3889 | for ( i=0; i<pInfo->iN; i++ ) |
---|
3890 | { |
---|
3891 | if (aiValid[i]) |
---|
3892 | { |
---|
3893 | acMv[iNTmp++] = pInfo->m_acMvCand[i]; |
---|
3894 | } |
---|
3895 | } |
---|
3896 | |
---|
3897 | for ( i=0; i<iNTmp; i++ ) pInfo->m_acMvCand[i] = acMv[i]; |
---|
3898 | pInfo->iN = iNTmp; |
---|
3899 | |
---|
3900 | return true; |
---|
3901 | } |
---|
3902 | #endif |
---|
3903 | |
---|
3904 | Int TComDataCU::searchMVPIdx(TComMv cMv, AMVPInfo* pInfo) |
---|
3905 | { |
---|
3906 | for ( Int i=0; i<pInfo->iN; i++ ) |
---|
3907 | { |
---|
3908 | if (cMv == pInfo->m_acMvCand[i]) |
---|
3909 | return i; |
---|
3910 | } |
---|
3911 | |
---|
3912 | assert(0); |
---|
3913 | return -1; |
---|
3914 | } |
---|
3915 | |
---|
3916 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
3917 | { |
---|
3918 | Int iMvShift = 2; |
---|
3919 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
3920 | if( getSlice()->getSPS()->isDepth() ) |
---|
3921 | iMvShift = 0; |
---|
3922 | #endif |
---|
3923 | Int iHorMax = (m_pcSlice->getSPS()->getWidth() - m_uiCUPelX - 1 )<<iMvShift; |
---|
3924 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - (Int)m_uiCUPelX + 1 )<<iMvShift; |
---|
3925 | |
---|
3926 | Int iVerMax = (m_pcSlice->getSPS()->getHeight() - m_uiCUPelY - 1 )<<iMvShift; |
---|
3927 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - (Int)m_uiCUPelY + 1 )<<iMvShift; |
---|
3928 | |
---|
3929 | rcMv.setHor( Min (iHorMax, Max (iHorMin, rcMv.getHor())) ); |
---|
3930 | rcMv.setVer( Min (iVerMax, Max (iVerMin, rcMv.getVer())) ); |
---|
3931 | } |
---|
3932 | |
---|
3933 | |
---|
3934 | Void TComDataCU::convertTransIdx( UInt uiAbsPartIdx, UInt uiTrIdx, UInt& ruiLumaTrMode, UInt& ruiChromaTrMode ) |
---|
3935 | { |
---|
3936 | ruiLumaTrMode = uiTrIdx; |
---|
3937 | ruiChromaTrMode = uiTrIdx; |
---|
3938 | return; |
---|
3939 | } |
---|
3940 | |
---|
3941 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
3942 | { |
---|
3943 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
---|
3944 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
3945 | |
---|
3946 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
3947 | UInt uiCnt = 0; |
---|
3948 | while( uiWidth ) |
---|
3949 | { |
---|
3950 | uiCnt++; |
---|
3951 | uiWidth>>=1; |
---|
3952 | } |
---|
3953 | uiCnt-=2; |
---|
3954 | return uiCnt > 6 ? 6 : uiCnt; |
---|
3955 | } |
---|
3956 | |
---|
3957 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
3958 | { |
---|
3959 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
3960 | } |
---|
3961 | |
---|
3962 | /** Test if the current block is skipped or not |
---|
3963 | * \param uiPartIdx |
---|
3964 | * \returns Bool |
---|
3965 | */ |
---|
3966 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
3967 | { |
---|
3968 | if ( m_pcSlice->isIntra () ) |
---|
3969 | { |
---|
3970 | return false; |
---|
3971 | } |
---|
3972 | #if HHI_MRG_SKIP |
---|
3973 | return ( m_pePredMode[ uiPartIdx ] == MODE_SKIP && getMergeFlag( uiPartIdx ) && !getQtRootCbf( uiPartIdx ) ); |
---|
3974 | #else |
---|
3975 | if ( m_pcSlice->isInterP() ) |
---|
3976 | { |
---|
3977 | return ( ( m_pePredMode[ uiPartIdx ] == MODE_SKIP ) && ( ( m_puhCbf[0][uiPartIdx] & 0x1 ) + ( m_puhCbf[1][uiPartIdx] & 0x1 ) + ( m_puhCbf[2][uiPartIdx] & 0x1 ) == 0) ); |
---|
3978 | } |
---|
3979 | else //if ( m_pcSlice->isInterB() ) |
---|
3980 | { |
---|
3981 | return ( ( m_pePredMode[ uiPartIdx ] == MODE_SKIP ) && ( ( m_puhCbf[0][uiPartIdx] & 0x1 ) + ( m_puhCbf[1][uiPartIdx] & 0x1 ) + ( m_puhCbf[2][uiPartIdx] & 0x1 ) == 0) && (m_puhInterDir[uiPartIdx] == 3) ); |
---|
3982 | } |
---|
3983 | #endif |
---|
3984 | } |
---|
3985 | |
---|
3986 | // ==================================================================================================================== |
---|
3987 | // Protected member functions |
---|
3988 | // ==================================================================================================================== |
---|
3989 | |
---|
3990 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
3991 | { |
---|
3992 | TComDataCU* pcTmpCU = NULL; |
---|
3993 | UInt uiIdx; |
---|
3994 | switch( eDir ) |
---|
3995 | { |
---|
3996 | case MD_LEFT: |
---|
3997 | { |
---|
3998 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
3999 | break; |
---|
4000 | } |
---|
4001 | case MD_ABOVE: |
---|
4002 | { |
---|
4003 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
4004 | break; |
---|
4005 | } |
---|
4006 | case MD_ABOVE_RIGHT: |
---|
4007 | { |
---|
4008 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
4009 | break; |
---|
4010 | } |
---|
4011 | case MD_BELOW_LEFT: |
---|
4012 | { |
---|
4013 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
4014 | break; |
---|
4015 | } |
---|
4016 | case MD_ABOVE_LEFT: |
---|
4017 | { |
---|
4018 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
4019 | break; |
---|
4020 | } |
---|
4021 | default: |
---|
4022 | { |
---|
4023 | break; |
---|
4024 | } |
---|
4025 | } |
---|
4026 | |
---|
4027 | if ( pcTmpCU != NULL && m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
---|
4028 | { |
---|
4029 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
4030 | clipMv(cMvPred); |
---|
4031 | |
---|
4032 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
4033 | return true; |
---|
4034 | } |
---|
4035 | return false; |
---|
4036 | } |
---|
4037 | |
---|
4038 | Void TComDataCU::xUniqueMVPCand(AMVPInfo* pInfo) |
---|
4039 | { |
---|
4040 | if ( pInfo->iN == 0 ) |
---|
4041 | { |
---|
4042 | pInfo->m_acMvCand[ pInfo->iN++ ].setZero(); |
---|
4043 | return; |
---|
4044 | } |
---|
4045 | |
---|
4046 | TComMv acMv[ AMVP_MAX_NUM_CANDS ]; |
---|
4047 | Int iNTmp, i, j; |
---|
4048 | |
---|
4049 | // make it be unique |
---|
4050 | iNTmp = 0; |
---|
4051 | acMv[ iNTmp++ ] = pInfo->m_acMvCand[0]; |
---|
4052 | for ( i=1; i<pInfo->iN; i++ ) |
---|
4053 | { |
---|
4054 | // BugFix for 1603 |
---|
4055 | for ( j=iNTmp - 1; j>=0; j-- ) |
---|
4056 | { |
---|
4057 | if ( pInfo->m_acMvCand[i] == acMv[j] ) break; |
---|
4058 | } |
---|
4059 | if ( j<0 ) |
---|
4060 | { |
---|
4061 | acMv[ iNTmp++ ] = pInfo->m_acMvCand[i]; |
---|
4062 | } |
---|
4063 | } |
---|
4064 | for ( i=0; i<iNTmp; i++ ) pInfo->m_acMvCand[i] = acMv[i]; |
---|
4065 | pInfo->iN = iNTmp; |
---|
4066 | |
---|
4067 | return ; |
---|
4068 | } |
---|
4069 | |
---|
4070 | #if MTK_AMVP_SMVP_DERIVATION |
---|
4071 | /** |
---|
4072 | * \param pInfo |
---|
4073 | * \param eRefPicList |
---|
4074 | * \param iRefIdx |
---|
4075 | * \param uiPartUnitIdx |
---|
4076 | * \param eDir |
---|
4077 | * \returns Bool |
---|
4078 | */ |
---|
4079 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
4080 | { |
---|
4081 | TComDataCU* pcTmpCU = NULL; |
---|
4082 | UInt uiIdx; |
---|
4083 | switch( eDir ) |
---|
4084 | { |
---|
4085 | case MD_LEFT: |
---|
4086 | { |
---|
4087 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
4088 | break; |
---|
4089 | } |
---|
4090 | case MD_ABOVE: |
---|
4091 | { |
---|
4092 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
4093 | break; |
---|
4094 | } |
---|
4095 | case MD_ABOVE_RIGHT: |
---|
4096 | { |
---|
4097 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
4098 | break; |
---|
4099 | } |
---|
4100 | case MD_BELOW_LEFT: |
---|
4101 | { |
---|
4102 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
4103 | break; |
---|
4104 | } |
---|
4105 | case MD_ABOVE_LEFT: |
---|
4106 | { |
---|
4107 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
4108 | break; |
---|
4109 | } |
---|
4110 | default: |
---|
4111 | { |
---|
4112 | break; |
---|
4113 | } |
---|
4114 | } |
---|
4115 | |
---|
4116 | if ( pcTmpCU == NULL ) |
---|
4117 | return false; |
---|
4118 | |
---|
4119 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
4120 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
4121 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
4122 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
4123 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
4124 | |
---|
4125 | |
---|
4126 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
4127 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
4128 | Int iNeibPOC = iCurrPOC; |
---|
4129 | Int iNeibRefPOC; |
---|
4130 | |
---|
4131 | |
---|
4132 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
4133 | { |
---|
4134 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
4135 | if( pcTmpCU->getSlice()->getRefViewIdx( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewIdx( eRefPicList, iRefIdx ) ) |
---|
4136 | return false; |
---|
4137 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
4138 | { |
---|
4139 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
4140 | |
---|
4141 | clipMv(cMvPred); |
---|
4142 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
4143 | return true; |
---|
4144 | } |
---|
4145 | } |
---|
4146 | //--------------- V1 (END) ------------------// |
---|
4147 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
4148 | { |
---|
4149 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
4150 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
4151 | TComMv rcMv; |
---|
4152 | |
---|
4153 | if( pcTmpCU->getSlice()->getRefViewIdx( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewIdx( eRefPicList, iRefIdx ) ) |
---|
4154 | return false; |
---|
4155 | |
---|
4156 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
4157 | if ( iScale == 1024 ) |
---|
4158 | { |
---|
4159 | rcMv = cMvPred; |
---|
4160 | } |
---|
4161 | else |
---|
4162 | { |
---|
4163 | rcMv = cMvPred.scaleMv( iScale ); |
---|
4164 | } |
---|
4165 | |
---|
4166 | clipMv(rcMv); |
---|
4167 | |
---|
4168 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
4169 | return true; |
---|
4170 | } |
---|
4171 | //---------------------- V2(END) --------------------// |
---|
4172 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
4173 | { |
---|
4174 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
4175 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
4176 | TComMv rcMv; |
---|
4177 | |
---|
4178 | if( pcTmpCU->getSlice()->getRefViewIdx( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewIdx( eRefPicList, iRefIdx ) ) |
---|
4179 | return false; |
---|
4180 | |
---|
4181 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
4182 | if ( iScale == 1024 ) |
---|
4183 | { |
---|
4184 | rcMv = cMvPred; |
---|
4185 | } |
---|
4186 | else |
---|
4187 | { |
---|
4188 | rcMv = cMvPred.scaleMv( iScale ); |
---|
4189 | } |
---|
4190 | |
---|
4191 | clipMv(rcMv); |
---|
4192 | |
---|
4193 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
4194 | return true; |
---|
4195 | } |
---|
4196 | //---------------------- V3(END) --------------------// |
---|
4197 | return false; |
---|
4198 | } |
---|
4199 | #endif |
---|
4200 | |
---|
4201 | /** |
---|
4202 | * \param eRefPicList |
---|
4203 | * \param uiCUAddr |
---|
4204 | * \param uiPartUnitIdx |
---|
4205 | * \param riRefIdx |
---|
4206 | * \returns Bool |
---|
4207 | */ |
---|
4208 | #if MTK_TMVP_H_MRG || MTK_TMVP_H_AMVP |
---|
4209 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) |
---|
4210 | { |
---|
4211 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
4212 | |
---|
4213 | RefPicList eColRefPicList; |
---|
4214 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
4215 | #if SONY_COLPIC_AVAILABILITY |
---|
4216 | Int iColViewOrderIdx, iColRefViewOrderIdx, iCurrViewOrderIdx, iCurrRefViewOrderIdx; |
---|
4217 | #endif |
---|
4218 | TComMv cColMv; |
---|
4219 | |
---|
4220 | iCurrPOC = m_pcSlice->getPOC(); |
---|
4221 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
4222 | #if SONY_COLPIC_AVAILABILITY |
---|
4223 | iCurrViewOrderIdx = m_pcSlice->getViewOrderIdx(); |
---|
4224 | iCurrRefViewOrderIdx = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewOrderIdx(); |
---|
4225 | #endif |
---|
4226 | // use coldir. |
---|
4227 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0), 0); |
---|
4228 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
4229 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
4230 | #if SONY_COLPIC_AVAILABILITY |
---|
4231 | iColViewOrderIdx = pColCU->getSlice()->getViewOrderIdx(); |
---|
4232 | #endif |
---|
4233 | |
---|
4234 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
4235 | { |
---|
4236 | return false; |
---|
4237 | } |
---|
4238 | #if !SONY_COLPIC_AVAILABILITY |
---|
4239 | if( m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIdx() != m_pcSlice->getViewIdx() ) |
---|
4240 | return false; |
---|
4241 | #endif |
---|
4242 | |
---|
4243 | // Prefer a vector crossing us. Prefer shortest. |
---|
4244 | eColRefPicList = REF_PIC_LIST_0; |
---|
4245 | bool bFirstCrosses = false; |
---|
4246 | Int iFirstColDist = -1; |
---|
4247 | |
---|
4248 | for (Int l = 0; l < 2; l++) |
---|
4249 | { |
---|
4250 | bool bSaveIt = false; |
---|
4251 | int iColRefIdx = pColCU->getCUMvField(RefPicList(l))->getRefIdx(uiAbsPartAddr); |
---|
4252 | if (iColRefIdx < 0) |
---|
4253 | { |
---|
4254 | continue; |
---|
4255 | } |
---|
4256 | iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx); |
---|
4257 | #if SONY_COLPIC_AVAILABILITY |
---|
4258 | iColRefViewOrderIdx = pColCU->getSlice()->getRefPic(RefPicList(l), iColRefIdx)->getViewOrderIdx(); |
---|
4259 | bool bCrosses; |
---|
4260 | int iColDist; |
---|
4261 | if((iColPOC != iColRefPOC)&&(iCurrPOC != iCurrRefPOC)){ |
---|
4262 | iColDist = abs(iColRefPOC - iColPOC); |
---|
4263 | bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC; |
---|
4264 | }else if((iColPOC == iColRefPOC)&&(iCurrPOC == iCurrRefPOC)){ |
---|
4265 | iColDist = abs(iColRefViewOrderIdx - iColViewOrderIdx); |
---|
4266 | bCrosses = iColViewOrderIdx < iCurrViewOrderIdx ? iColRefViewOrderIdx > iCurrViewOrderIdx : iColRefViewOrderIdx < iCurrViewOrderIdx; |
---|
4267 | }else{ |
---|
4268 | continue; |
---|
4269 | } |
---|
4270 | #else |
---|
4271 | if( pColCU->getSlice()->getRefViewIdx(RefPicList(l), iColRefIdx) != pColCU->getSlice()->getViewIdx() ) |
---|
4272 | continue; |
---|
4273 | int iColDist = abs(iColRefPOC - iColPOC); |
---|
4274 | bool bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC; |
---|
4275 | #endif |
---|
4276 | |
---|
4277 | if (iFirstColDist < 0) |
---|
4278 | { |
---|
4279 | bSaveIt = true; |
---|
4280 | } |
---|
4281 | else if (bCrosses && !bFirstCrosses) |
---|
4282 | { |
---|
4283 | bSaveIt = true; |
---|
4284 | } |
---|
4285 | #if PANASONIC_AMVPTEMPORALMOD |
---|
4286 | else if (bCrosses == bFirstCrosses && l == eRefPicList) |
---|
4287 | #else |
---|
4288 | else if (bCrosses == bFirstCrosses && iColDist < iFirstColDist) |
---|
4289 | #endif |
---|
4290 | { |
---|
4291 | bSaveIt = true; |
---|
4292 | } |
---|
4293 | if (bSaveIt) |
---|
4294 | { |
---|
4295 | bFirstCrosses = bCrosses; |
---|
4296 | iFirstColDist = iColDist; |
---|
4297 | eColRefPicList = RefPicList(l); |
---|
4298 | } |
---|
4299 | } |
---|
4300 | if( iFirstColDist < 0 ) |
---|
4301 | return false; |
---|
4302 | // Scale the vector. |
---|
4303 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr)); |
---|
4304 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
4305 | #if SONY_COLPIC_AVAILABILITY |
---|
4306 | iColRefViewOrderIdx = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewOrderIdx(); |
---|
4307 | #endif |
---|
4308 | |
---|
4309 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
4310 | #if SONY_COLPIC_AVAILABILITY |
---|
4311 | iScale = 0; |
---|
4312 | iCurrRefViewOrderIdx = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewOrderIdx(); |
---|
4313 | if((iColPOC != iColRefPOC)&&(iCurrPOC != iCurrRefPOC)) |
---|
4314 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4315 | else if((iColPOC == iColRefPOC)&&(iCurrPOC == iCurrRefPOC)) |
---|
4316 | iScale = xGetDistScaleFactor(iCurrViewOrderIdx, iCurrRefViewOrderIdx, iColViewOrderIdx, iColRefViewOrderIdx); |
---|
4317 | #else |
---|
4318 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4319 | #endif |
---|
4320 | if (iScale == 1024) |
---|
4321 | { |
---|
4322 | rcMv = cColMv; |
---|
4323 | } |
---|
4324 | else |
---|
4325 | { |
---|
4326 | rcMv = cColMv.scaleMv( iScale ); |
---|
4327 | } |
---|
4328 | clipMv(rcMv); |
---|
4329 | return true; |
---|
4330 | } |
---|
4331 | #endif |
---|
4332 | |
---|
4333 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
4334 | { |
---|
4335 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
4336 | } |
---|
4337 | |
---|
4338 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
4339 | { |
---|
4340 | UInt uiLength = 1; |
---|
4341 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
4342 | |
---|
4343 | assert ( uiTemp ); |
---|
4344 | |
---|
4345 | while ( 1 != uiTemp ) |
---|
4346 | { |
---|
4347 | uiTemp >>= 1; |
---|
4348 | uiLength += 2; |
---|
4349 | } |
---|
4350 | |
---|
4351 | return uiLength; |
---|
4352 | } |
---|
4353 | |
---|
4354 | |
---|
4355 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
4356 | { |
---|
4357 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
4358 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
4359 | |
---|
4360 | if( iDiffPocD == iDiffPocB ) |
---|
4361 | { |
---|
4362 | return 1024; |
---|
4363 | } |
---|
4364 | else |
---|
4365 | { |
---|
4366 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
4367 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
4368 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
4369 | Int iScale = Clip3( -1024, 1023, (iTDB * iX + 32) >> 6 ); |
---|
4370 | return iScale; |
---|
4371 | } |
---|
4372 | } |
---|
4373 | |
---|
4374 | Void TComDataCU::xCalcCuCbf( UChar* puhCbf, UInt uiTrDepth, UInt uiCbfDepth, UInt uiCuDepth ) |
---|
4375 | { |
---|
4376 | if ( uiTrDepth == 0 ) |
---|
4377 | return; |
---|
4378 | |
---|
4379 | UInt ui, uiNumSig = 0; |
---|
4380 | |
---|
4381 | UInt uiNumPart = m_pcPic->getNumPartInCU() >> ( uiCuDepth << 1 ); |
---|
4382 | UInt uiQNumPart = uiNumPart >> 2; |
---|
4383 | |
---|
4384 | UInt uiCbfDepth1 = uiCbfDepth + 1; |
---|
4385 | if( uiNumPart == 1 ) |
---|
4386 | { |
---|
4387 | if ( ( puhCbf[0] >> uiCbfDepth1 ) & 0x1 ) |
---|
4388 | { |
---|
4389 | uiNumSig = 1; |
---|
4390 | } |
---|
4391 | puhCbf[0] |= uiNumSig << uiCbfDepth; |
---|
4392 | |
---|
4393 | return; |
---|
4394 | } |
---|
4395 | assert( uiQNumPart ); |
---|
4396 | |
---|
4397 | if ( uiCbfDepth < ( uiTrDepth - 1 ) ) |
---|
4398 | { |
---|
4399 | UChar* puhNextCbf = puhCbf; |
---|
4400 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); puhNextCbf += uiQNumPart; |
---|
4401 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); puhNextCbf += uiQNumPart; |
---|
4402 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); puhNextCbf += uiQNumPart; |
---|
4403 | xCalcCuCbf( puhNextCbf, uiTrDepth, uiCbfDepth1, uiCuDepth+1 ); |
---|
4404 | } |
---|
4405 | |
---|
4406 | for ( ui = 0; ui < uiNumPart; ui += uiQNumPart ) |
---|
4407 | { |
---|
4408 | if ( ( puhCbf[ui] >> uiCbfDepth1 ) & 0x1 ) |
---|
4409 | { |
---|
4410 | uiNumSig = 1; |
---|
4411 | break; |
---|
4412 | } |
---|
4413 | } |
---|
4414 | |
---|
4415 | uiNumSig <<= uiCbfDepth; |
---|
4416 | for ( ui = 0; ui < uiNumPart; ui++ ) |
---|
4417 | { |
---|
4418 | puhCbf[ui] |= uiNumSig; |
---|
4419 | } |
---|
4420 | } |
---|
4421 | |
---|
4422 | #if FT_TCTR_AMVP || FT_TCTR_MRG |
---|
4423 | /** |
---|
4424 | * \param eCUMode |
---|
4425 | * \param uiPartIdx |
---|
4426 | * \param ruiPartIdxCenter |
---|
4427 | * \returns Void |
---|
4428 | */ |
---|
4429 | Void TComDataCU::xDeriveCenterIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
4430 | { |
---|
4431 | UInt uiPartAddr; |
---|
4432 | Int iPartWidth; |
---|
4433 | Int iPartHeight; |
---|
4434 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
4435 | |
---|
4436 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
4437 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
4438 | + ( iPartHeight/m_pcPic->getMinCUHeight() -1 )/2*m_pcPic->getNumPartInWidth() |
---|
4439 | + ( iPartWidth/m_pcPic->getMinCUWidth() -1 )/2]; |
---|
4440 | } |
---|
4441 | |
---|
4442 | /** |
---|
4443 | * \param uiPartIdx |
---|
4444 | * \param eRefPicList |
---|
4445 | * \param iRefIdx |
---|
4446 | * \param pcMv |
---|
4447 | * \returns Bool |
---|
4448 | */ |
---|
4449 | Bool TComDataCU::xGetCenterCol( UInt uiPartIdx, RefPicList eRefPicList, int iRefIdx, TComMv *pcMv ) |
---|
4450 | { |
---|
4451 | PartSize eCUMode = m_pePartSize[0]; |
---|
4452 | |
---|
4453 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
4454 | |
---|
4455 | // use coldir. |
---|
4456 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0), 0); |
---|
4457 | TComDataCU *pColCU = pColPic->getCU( m_uiCUAddr ); |
---|
4458 | |
---|
4459 | Int iColPOC = pColCU->getSlice()->getPOC(); |
---|
4460 | UInt uiPartIdxCenter; |
---|
4461 | xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter ); |
---|
4462 | |
---|
4463 | if (pColCU->isIntra(uiPartIdxCenter)) |
---|
4464 | return false; |
---|
4465 | |
---|
4466 | if( m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getViewIdx() != m_pcSlice->getViewIdx() ) |
---|
4467 | return false; |
---|
4468 | |
---|
4469 | // Prefer a vector crossing us. Prefer shortest. |
---|
4470 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
---|
4471 | bool bFirstCrosses = false; |
---|
4472 | Int iFirstColDist = -1; |
---|
4473 | for (Int l = 0; l < 2; l++) |
---|
4474 | { |
---|
4475 | bool bSaveIt = false; |
---|
4476 | int iColRefIdx = pColCU->getCUMvField(RefPicList(l))->getRefIdx(uiPartIdxCenter); |
---|
4477 | if (iColRefIdx < 0) |
---|
4478 | continue; |
---|
4479 | int iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx); |
---|
4480 | if( pColCU->getSlice()->getRefViewIdx(RefPicList(l), iColRefIdx) != pColCU->getSlice()->getViewIdx() ) |
---|
4481 | continue; |
---|
4482 | int iColDist = abs(iColRefPOC - iColPOC); |
---|
4483 | bool bCrosses = iColPOC < iCurrPOC ? iColRefPOC > iCurrPOC : iColRefPOC < iCurrPOC; |
---|
4484 | if (iFirstColDist < 0) |
---|
4485 | bSaveIt = true; |
---|
4486 | else if (bCrosses && !bFirstCrosses) |
---|
4487 | bSaveIt = true; |
---|
4488 | #if PANASONIC_AMVPTEMPORALMOD |
---|
4489 | else if (bCrosses == bFirstCrosses && l == eRefPicList) |
---|
4490 | #else |
---|
4491 | else if (bCrosses == bFirstCrosses && iColDist < iFirstColDist) |
---|
4492 | #endif |
---|
4493 | bSaveIt = true; |
---|
4494 | |
---|
4495 | if (bSaveIt) |
---|
4496 | { |
---|
4497 | bFirstCrosses = bCrosses; |
---|
4498 | iFirstColDist = iColDist; |
---|
4499 | eColRefPicList = RefPicList(l); |
---|
4500 | } |
---|
4501 | } |
---|
4502 | if( iFirstColDist < 0 ) |
---|
4503 | return false; |
---|
4504 | |
---|
4505 | // Scale the vector. |
---|
4506 | Int iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartIdxCenter)); |
---|
4507 | TComMv cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartIdxCenter); |
---|
4508 | |
---|
4509 | Int iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, iRefIdx)->getPOC(); |
---|
4510 | Int iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
4511 | if (iScale == 1024) |
---|
4512 | { |
---|
4513 | pcMv[0] = cColMv; |
---|
4514 | } |
---|
4515 | else |
---|
4516 | { |
---|
4517 | pcMv[0] = cColMv.scaleMv( iScale ); |
---|
4518 | } |
---|
4519 | clipMv(pcMv[0]); |
---|
4520 | |
---|
4521 | return true; |
---|
4522 | } |
---|
4523 | #endif |
---|
4524 | |
---|
4525 | #if AMVP_BUFFERCOMPRESS |
---|
4526 | Void TComDataCU::compressMV() |
---|
4527 | { |
---|
4528 | m_acCUMvField[0].compress(m_pePredMode,m_puhInterDir); |
---|
4529 | m_acCUMvField[1].compress(m_pePredMode,m_puhInterDir); |
---|
4530 | } |
---|
4531 | #endif |
---|
4532 | |
---|
4533 | #if QC_MDCS |
---|
4534 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
4535 | { |
---|
4536 | static const UChar aucIntraLumaDirToScanIdx[MAX_CU_DEPTH][34] = |
---|
4537 | { |
---|
4538 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4539 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4540 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4541 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4542 | {1, 2, 0, 0, 1, 1, 0, 2, 2, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, }, |
---|
4543 | {1, 2, 0, 0, 1, 1, 0, 2, 2, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, }, |
---|
4544 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
---|
4545 | }; |
---|
4546 | static const UChar aucIntraChromaDirToScanIdx[MAX_CU_DEPTH][5] = |
---|
4547 | { |
---|
4548 | {0, 0, 0, 0, 0, }, |
---|
4549 | {0, 0, 0, 0, 0, }, |
---|
4550 | {0, 0, 0, 0, 0, }, |
---|
4551 | {0, 0, 0, 0, 0, }, |
---|
4552 | {0, 0, 0, 0, 0, }, |
---|
4553 | {1, 2, 0, 0, 0, }, |
---|
4554 | {1, 2, 0, 0, 0, }, |
---|
4555 | }; |
---|
4556 | |
---|
4557 | UInt uiCTXIdx; |
---|
4558 | UInt uiScanIdx; |
---|
4559 | UInt uiDirMode; |
---|
4560 | |
---|
4561 | if ( !bIsIntra ) |
---|
4562 | { |
---|
4563 | uiScanIdx = SCAN_ZIGZAG; |
---|
4564 | return uiScanIdx; |
---|
4565 | } |
---|
4566 | |
---|
4567 | switch(uiWidth) |
---|
4568 | { |
---|
4569 | case 2: uiCTXIdx = 6; break; |
---|
4570 | case 4: uiCTXIdx = 5; break; |
---|
4571 | case 8: uiCTXIdx = 4; break; |
---|
4572 | case 16: uiCTXIdx = 3; break; |
---|
4573 | case 32: uiCTXIdx = 2; break; |
---|
4574 | case 64: uiCTXIdx = 1; break; |
---|
4575 | default: uiCTXIdx = 0; break; |
---|
4576 | } |
---|
4577 | |
---|
4578 | if ( bIsLuma ) |
---|
4579 | { |
---|
4580 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
4581 | #if ADD_PLANAR_MODE |
---|
4582 | mapPlanartoDC( uiDirMode ); |
---|
4583 | #endif |
---|
4584 | uiScanIdx = aucIntraLumaDirToScanIdx[uiCTXIdx][uiDirMode]; |
---|
4585 | } |
---|
4586 | else |
---|
4587 | { |
---|
4588 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
4589 | #if ADD_PLANAR_MODE |
---|
4590 | mapPlanartoDC( uiDirMode ); |
---|
4591 | #endif |
---|
4592 | if (uiDirMode < 4) |
---|
4593 | { |
---|
4594 | uiScanIdx = (aucIntraChromaDirToScanIdx[uiCTXIdx][uiDirMode]); |
---|
4595 | } |
---|
4596 | else |
---|
4597 | { |
---|
4598 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
4599 | #if ADD_PLANAR_MODE |
---|
4600 | mapPlanartoDC( uiDirMode ); |
---|
4601 | #endif |
---|
4602 | uiScanIdx = aucIntraLumaDirToScanIdx[max<UInt>(uiCTXIdx-1,0)][uiDirMode]; |
---|
4603 | } |
---|
4604 | } |
---|
4605 | |
---|
4606 | return uiScanIdx; |
---|
4607 | } |
---|
4608 | #endif //QC_MDCS |
---|
4609 | |
---|
4610 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
4611 | Bool TComDataCU::isSuroundingRefIdxException ( UInt uiAbsPartIdx ) |
---|
4612 | { |
---|
4613 | if ( !getSlice()->isInterB() ) |
---|
4614 | return true; |
---|
4615 | |
---|
4616 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) <= 2 && getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) <= 2) |
---|
4617 | { |
---|
4618 | return false; |
---|
4619 | } |
---|
4620 | |
---|
4621 | TComDataCU* pcTempCU; |
---|
4622 | UInt uiTempPartIdx; |
---|
4623 | TComMvField cMvFieldTemp; |
---|
4624 | |
---|
4625 | if ( getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 0 ) // combined list case |
---|
4626 | { |
---|
4627 | // Left PU |
---|
4628 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4629 | if ( pcTempCU ) |
---|
4630 | { |
---|
4631 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4632 | { |
---|
4633 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4634 | return true; |
---|
4635 | } |
---|
4636 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4637 | { |
---|
4638 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4639 | return true; |
---|
4640 | } |
---|
4641 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4642 | { |
---|
4643 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4644 | return true; |
---|
4645 | |
---|
4646 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4647 | return true; |
---|
4648 | } |
---|
4649 | } |
---|
4650 | |
---|
4651 | // Above PU |
---|
4652 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4653 | if ( pcTempCU ) |
---|
4654 | { |
---|
4655 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4656 | { |
---|
4657 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4658 | return true; |
---|
4659 | } |
---|
4660 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4661 | { |
---|
4662 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4663 | return true; |
---|
4664 | } |
---|
4665 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4666 | { |
---|
4667 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4668 | return true; |
---|
4669 | |
---|
4670 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4671 | return true; |
---|
4672 | } |
---|
4673 | } |
---|
4674 | |
---|
4675 | // Above left PU |
---|
4676 | pcTempCU = getPUAboveLeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4677 | if ( pcTempCU ) |
---|
4678 | { |
---|
4679 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4680 | { |
---|
4681 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4682 | return true; |
---|
4683 | } |
---|
4684 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4685 | { |
---|
4686 | if ( pcTempCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx )) > 3 ) |
---|
4687 | return true; |
---|
4688 | } |
---|
4689 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4690 | { |
---|
4691 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4692 | return true; |
---|
4693 | |
---|
4694 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4695 | return true; |
---|
4696 | } |
---|
4697 | } |
---|
4698 | |
---|
4699 | return false; |
---|
4700 | } |
---|
4701 | |
---|
4702 | // not combined list case |
---|
4703 | // Left PU |
---|
4704 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4705 | if ( pcTempCU ) |
---|
4706 | { |
---|
4707 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4708 | { |
---|
4709 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4710 | return true; |
---|
4711 | } |
---|
4712 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4713 | { |
---|
4714 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4715 | return true; |
---|
4716 | } |
---|
4717 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4718 | { |
---|
4719 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4720 | return true; |
---|
4721 | |
---|
4722 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4723 | return true; |
---|
4724 | } |
---|
4725 | } |
---|
4726 | |
---|
4727 | // Above PU |
---|
4728 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4729 | if ( pcTempCU ) |
---|
4730 | { |
---|
4731 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4732 | { |
---|
4733 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4734 | return true; |
---|
4735 | } |
---|
4736 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4737 | { |
---|
4738 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4739 | return true; |
---|
4740 | } |
---|
4741 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4742 | { |
---|
4743 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4744 | return true; |
---|
4745 | |
---|
4746 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4747 | return true; |
---|
4748 | } |
---|
4749 | } |
---|
4750 | |
---|
4751 | // Above left PU |
---|
4752 | pcTempCU = getPUAboveLeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
4753 | if ( pcTempCU ) |
---|
4754 | { |
---|
4755 | if (pcTempCU->getInterDir(uiTempPartIdx) == 1 ) |
---|
4756 | { |
---|
4757 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4758 | return true; |
---|
4759 | } |
---|
4760 | else if (pcTempCU->getInterDir(uiTempPartIdx) == 2 ) |
---|
4761 | { |
---|
4762 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > MS_LCEC_UNI_EXCEPTION_THRES ) |
---|
4763 | return true; |
---|
4764 | } |
---|
4765 | else if ( pcTempCU->getInterDir(uiTempPartIdx) == 3 ) |
---|
4766 | { |
---|
4767 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4768 | return true; |
---|
4769 | |
---|
4770 | if ( pcTempCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiTempPartIdx ) > 1 ) |
---|
4771 | return true; |
---|
4772 | } |
---|
4773 | } |
---|
4774 | |
---|
4775 | return false; |
---|
4776 | } |
---|
4777 | #endif |
---|
4778 | |
---|
4779 | #if HHI_MPI |
---|
4780 | Void TComDataCU::setTextureModeDepthSubParts( Int iTextureModeDepth, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
4781 | { |
---|
4782 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
4783 | |
---|
4784 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
4785 | { |
---|
4786 | m_piTextureModeDepth[uiAbsPartIdx + ui] = iTextureModeDepth; |
---|
4787 | } |
---|
4788 | } |
---|
4789 | |
---|
4790 | Void TComDataCU::copyTextureMotionDataFrom( TComDataCU* pcCU, UInt uiDepth, UInt uiAbsPartIdxSrc, UInt uiAbsPartIdxDst ) |
---|
4791 | { |
---|
4792 | assert( getSlice()->getSPS()->isDepth() && ! pcCU->getSlice()->getSPS()->isDepth() ); |
---|
4793 | UInt uiNumPartition = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
4794 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
4795 | Int iSizeInInt = sizeof( Int ) * uiNumPartition; |
---|
4796 | |
---|
4797 | memcpy( m_pePredMode + uiAbsPartIdxDst, pcCU->getPredictionMode() + uiAbsPartIdxSrc, sizeof( PredMode ) * uiNumPartition ); |
---|
4798 | memcpy( m_puhInterDir + uiAbsPartIdxDst, pcCU->getInterDir() + uiAbsPartIdxSrc, iSizeInUchar ); |
---|
4799 | |
---|
4800 | memcpy( m_apiMVPIdx[0] + uiAbsPartIdxDst, pcCU->getMVPIdx(REF_PIC_LIST_0) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4801 | memcpy( m_apiMVPIdx[1] + uiAbsPartIdxDst, pcCU->getMVPIdx(REF_PIC_LIST_1) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4802 | memcpy( m_apiMVPNum[0] + uiAbsPartIdxDst, pcCU->getMVPNum(REF_PIC_LIST_0) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4803 | memcpy( m_apiMVPNum[1] + uiAbsPartIdxDst, pcCU->getMVPNum(REF_PIC_LIST_1) + uiAbsPartIdxSrc, iSizeInInt ); |
---|
4804 | |
---|
4805 | pcCU->getCUMvField( REF_PIC_LIST_0 )->copyTo( &m_acCUMvField[0], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition ); |
---|
4806 | pcCU->getCUMvField( REF_PIC_LIST_1 )->copyTo( &m_acCUMvField[1], -Int(uiAbsPartIdxSrc) + uiAbsPartIdxDst, uiAbsPartIdxSrc, uiNumPartition ); |
---|
4807 | #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC |
---|
4808 | for( UInt ui = 0; ui < uiNumPartition; ui++ ) |
---|
4809 | { |
---|
4810 | m_acCUMvField[0].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4811 | m_acCUMvField[0].getMv( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4812 | |
---|
4813 | m_acCUMvField[1].getMv( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4814 | m_acCUMvField[1].getMv( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4815 | |
---|
4816 | m_acCUMvField[0].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4817 | m_acCUMvField[0].getMvd( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4818 | |
---|
4819 | m_acCUMvField[1].getMvd( uiAbsPartIdxDst + ui ) += TComMv( 2, 2 ); |
---|
4820 | m_acCUMvField[1].getMvd( uiAbsPartIdxDst + ui ) >>= 2; |
---|
4821 | } |
---|
4822 | #endif |
---|
4823 | } |
---|
4824 | #endif |
---|
4825 | |
---|
4826 | Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) |
---|
4827 | { |
---|
4828 | riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); |
---|
4829 | riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); |
---|
4830 | } |
---|