1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComYuv.cpp |
---|
35 | \brief general YUV buffer class |
---|
36 | \todo this should be merged with TComPicYuv |
---|
37 | */ |
---|
38 | |
---|
39 | #include <stdlib.h> |
---|
40 | #include <memory.h> |
---|
41 | #include <assert.h> |
---|
42 | #include <math.h> |
---|
43 | |
---|
44 | #include "CommonDef.h" |
---|
45 | #include "TComYuv.h" |
---|
46 | #include "TComInterpolationFilter.h" |
---|
47 | |
---|
48 | //! \ingroup TLibCommon |
---|
49 | //! \{ |
---|
50 | |
---|
51 | TComYuv::TComYuv() |
---|
52 | { |
---|
53 | m_apiBufY = NULL; |
---|
54 | m_apiBufU = NULL; |
---|
55 | m_apiBufV = NULL; |
---|
56 | } |
---|
57 | |
---|
58 | TComYuv::~TComYuv() |
---|
59 | { |
---|
60 | } |
---|
61 | |
---|
62 | Void TComYuv::create( UInt iWidth, UInt iHeight ) |
---|
63 | { |
---|
64 | // memory allocation |
---|
65 | m_apiBufY = (Pel*)xMalloc( Pel, iWidth*iHeight ); |
---|
66 | m_apiBufU = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 ); |
---|
67 | m_apiBufV = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 ); |
---|
68 | |
---|
69 | // set width and height |
---|
70 | m_iWidth = iWidth; |
---|
71 | m_iHeight = iHeight; |
---|
72 | m_iCWidth = iWidth >> 1; |
---|
73 | m_iCHeight = iHeight >> 1; |
---|
74 | } |
---|
75 | |
---|
76 | Void TComYuv::destroy() |
---|
77 | { |
---|
78 | // memory free |
---|
79 | xFree( m_apiBufY ); m_apiBufY = NULL; |
---|
80 | xFree( m_apiBufU ); m_apiBufU = NULL; |
---|
81 | xFree( m_apiBufV ); m_apiBufV = NULL; |
---|
82 | } |
---|
83 | |
---|
84 | Void TComYuv::clear() |
---|
85 | { |
---|
86 | ::memset( m_apiBufY, 0, ( m_iWidth * m_iHeight )*sizeof(Pel) ); |
---|
87 | ::memset( m_apiBufU, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) ); |
---|
88 | ::memset( m_apiBufV, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) ); |
---|
89 | } |
---|
90 | |
---|
91 | Void TComYuv::copyToPicYuv ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
92 | { |
---|
93 | copyToPicLuma ( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx ); |
---|
94 | copyToPicChroma( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx ); |
---|
95 | } |
---|
96 | |
---|
97 | Void TComYuv::copyToPicLuma ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
98 | { |
---|
99 | Int y, iWidth, iHeight; |
---|
100 | iWidth = m_iWidth >>uiPartDepth; |
---|
101 | iHeight = m_iHeight>>uiPartDepth; |
---|
102 | |
---|
103 | Pel* pSrc = getLumaAddr(uiPartIdx, iWidth); |
---|
104 | Pel* pDst = pcPicYuvDst->getLumaAddr ( iCuAddr, uiAbsZorderIdx ); |
---|
105 | |
---|
106 | UInt iSrcStride = getStride(); |
---|
107 | UInt iDstStride = pcPicYuvDst->getStride(); |
---|
108 | |
---|
109 | for ( y = iHeight; y != 0; y-- ) |
---|
110 | { |
---|
111 | ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth); |
---|
112 | pDst += iDstStride; |
---|
113 | pSrc += iSrcStride; |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | Void TComYuv::copyToPicChroma( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
118 | { |
---|
119 | Int y, iWidth, iHeight; |
---|
120 | iWidth = m_iCWidth >>uiPartDepth; |
---|
121 | iHeight = m_iCHeight>>uiPartDepth; |
---|
122 | |
---|
123 | Pel* pSrcU = getCbAddr(uiPartIdx, iWidth); |
---|
124 | Pel* pSrcV = getCrAddr(uiPartIdx, iWidth); |
---|
125 | Pel* pDstU = pcPicYuvDst->getCbAddr( iCuAddr, uiAbsZorderIdx ); |
---|
126 | Pel* pDstV = pcPicYuvDst->getCrAddr( iCuAddr, uiAbsZorderIdx ); |
---|
127 | |
---|
128 | UInt iSrcStride = getCStride(); |
---|
129 | UInt iDstStride = pcPicYuvDst->getCStride(); |
---|
130 | for ( y = iHeight; y != 0; y-- ) |
---|
131 | { |
---|
132 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(iWidth) ); |
---|
133 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(iWidth) ); |
---|
134 | pSrcU += iSrcStride; |
---|
135 | pSrcV += iSrcStride; |
---|
136 | pDstU += iDstStride; |
---|
137 | pDstV += iDstStride; |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | Void TComYuv::copyFromPicYuv ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
142 | { |
---|
143 | copyFromPicLuma ( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx ); |
---|
144 | copyFromPicChroma( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx ); |
---|
145 | } |
---|
146 | |
---|
147 | Void TComYuv::copyFromPicLuma ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
148 | { |
---|
149 | Int y; |
---|
150 | |
---|
151 | Pel* pDst = m_apiBufY; |
---|
152 | Pel* pSrc = pcPicYuvSrc->getLumaAddr ( iCuAddr, uiAbsZorderIdx ); |
---|
153 | |
---|
154 | UInt iDstStride = getStride(); |
---|
155 | UInt iSrcStride = pcPicYuvSrc->getStride(); |
---|
156 | for ( y = m_iHeight; y != 0; y-- ) |
---|
157 | { |
---|
158 | ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth); |
---|
159 | pDst += iDstStride; |
---|
160 | pSrc += iSrcStride; |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | Void TComYuv::copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
165 | { |
---|
166 | Int y; |
---|
167 | |
---|
168 | Pel* pDstU = m_apiBufU; |
---|
169 | Pel* pDstV = m_apiBufV; |
---|
170 | Pel* pSrcU = pcPicYuvSrc->getCbAddr( iCuAddr, uiAbsZorderIdx ); |
---|
171 | Pel* pSrcV = pcPicYuvSrc->getCrAddr( iCuAddr, uiAbsZorderIdx ); |
---|
172 | |
---|
173 | UInt iDstStride = getCStride(); |
---|
174 | UInt iSrcStride = pcPicYuvSrc->getCStride(); |
---|
175 | for ( y = m_iCHeight; y != 0; y-- ) |
---|
176 | { |
---|
177 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) ); |
---|
178 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) ); |
---|
179 | pSrcU += iSrcStride; |
---|
180 | pSrcV += iSrcStride; |
---|
181 | pDstU += iDstStride; |
---|
182 | pDstV += iDstStride; |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
187 | { |
---|
188 | copyToPartLuma ( pcYuvDst, uiDstPartIdx ); |
---|
189 | copyToPartChroma( pcYuvDst, uiDstPartIdx ); |
---|
190 | } |
---|
191 | |
---|
192 | Void TComYuv::copyToPartLuma( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
193 | { |
---|
194 | Int y; |
---|
195 | |
---|
196 | Pel* pSrc = m_apiBufY; |
---|
197 | Pel* pDst = pcYuvDst->getLumaAddr( uiDstPartIdx ); |
---|
198 | |
---|
199 | UInt iSrcStride = getStride(); |
---|
200 | UInt iDstStride = pcYuvDst->getStride(); |
---|
201 | for ( y = m_iHeight; y != 0; y-- ) |
---|
202 | { |
---|
203 | ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth); |
---|
204 | pDst += iDstStride; |
---|
205 | pSrc += iSrcStride; |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | Void TComYuv::copyToPartChroma( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
210 | { |
---|
211 | Int y; |
---|
212 | |
---|
213 | Pel* pSrcU = m_apiBufU; |
---|
214 | Pel* pSrcV = m_apiBufV; |
---|
215 | Pel* pDstU = pcYuvDst->getCbAddr( uiDstPartIdx ); |
---|
216 | Pel* pDstV = pcYuvDst->getCrAddr( uiDstPartIdx ); |
---|
217 | |
---|
218 | UInt iSrcStride = getCStride(); |
---|
219 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
220 | for ( y = m_iCHeight; y != 0; y-- ) |
---|
221 | { |
---|
222 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) ); |
---|
223 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) ); |
---|
224 | pSrcU += iSrcStride; |
---|
225 | pSrcV += iSrcStride; |
---|
226 | pDstU += iDstStride; |
---|
227 | pDstV += iDstStride; |
---|
228 | } |
---|
229 | } |
---|
230 | |
---|
231 | Void TComYuv::copyPartToYuv( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
232 | { |
---|
233 | copyPartToLuma ( pcYuvDst, uiSrcPartIdx ); |
---|
234 | copyPartToChroma( pcYuvDst, uiSrcPartIdx ); |
---|
235 | } |
---|
236 | |
---|
237 | Void TComYuv::copyPartToLuma( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
238 | { |
---|
239 | Int y; |
---|
240 | |
---|
241 | Pel* pSrc = getLumaAddr(uiSrcPartIdx); |
---|
242 | Pel* pDst = pcYuvDst->getLumaAddr( 0 ); |
---|
243 | |
---|
244 | UInt iSrcStride = getStride(); |
---|
245 | UInt iDstStride = pcYuvDst->getStride(); |
---|
246 | |
---|
247 | UInt uiHeight = pcYuvDst->getHeight(); |
---|
248 | UInt uiWidth = pcYuvDst->getWidth(); |
---|
249 | |
---|
250 | for ( y = uiHeight; y != 0; y-- ) |
---|
251 | { |
---|
252 | ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth); |
---|
253 | pDst += iDstStride; |
---|
254 | pSrc += iSrcStride; |
---|
255 | } |
---|
256 | } |
---|
257 | |
---|
258 | Void TComYuv::copyPartToChroma( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
259 | { |
---|
260 | Int y; |
---|
261 | |
---|
262 | Pel* pSrcU = getCbAddr( uiSrcPartIdx ); |
---|
263 | Pel* pSrcV = getCrAddr( uiSrcPartIdx ); |
---|
264 | Pel* pDstU = pcYuvDst->getCbAddr( 0 ); |
---|
265 | Pel* pDstV = pcYuvDst->getCrAddr( 0 ); |
---|
266 | |
---|
267 | UInt iSrcStride = getCStride(); |
---|
268 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
269 | |
---|
270 | UInt uiCHeight = pcYuvDst->getCHeight(); |
---|
271 | UInt uiCWidth = pcYuvDst->getCWidth(); |
---|
272 | |
---|
273 | for ( y = uiCHeight; y != 0; y-- ) |
---|
274 | { |
---|
275 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(uiCWidth) ); |
---|
276 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(uiCWidth) ); |
---|
277 | pSrcU += iSrcStride; |
---|
278 | pSrcV += iSrcStride; |
---|
279 | pDstU += iDstStride; |
---|
280 | pDstV += iDstStride; |
---|
281 | } |
---|
282 | } |
---|
283 | |
---|
284 | #if DEPTH_MAP_GENERATION |
---|
285 | Void TComYuv::copyPartToPartYuvPdm ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
286 | { |
---|
287 | copyPartToPartLumaPdm (pcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
288 | } |
---|
289 | #endif |
---|
290 | |
---|
291 | Void TComYuv::copyPartToPartYuv ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
292 | { |
---|
293 | copyPartToPartLuma (pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
294 | copyPartToPartChroma (pcYuvDst, uiPartIdx, iWidth>>1, iHeight>>1 ); |
---|
295 | } |
---|
296 | |
---|
297 | #if DEPTH_MAP_GENERATION |
---|
298 | Void TComYuv::copyPartToPartLumaPdm ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
299 | { |
---|
300 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpX; |
---|
301 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpY; |
---|
302 | Pel* pSrc = getLumaAddr(uiPartIdx); |
---|
303 | Pel* pDst = pcYuvDst->getLumaAddr() + uiBlkY * pcYuvDst->getStride() + uiBlkX; |
---|
304 | |
---|
305 | if( pSrc == pDst ) |
---|
306 | { |
---|
307 | //th not a good idea |
---|
308 | //th best would be to fix the caller |
---|
309 | return ; |
---|
310 | } |
---|
311 | |
---|
312 | UInt iSrcStride = getStride(); |
---|
313 | UInt iDstStride = pcYuvDst->getStride(); |
---|
314 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
315 | { |
---|
316 | ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) ); |
---|
317 | pSrc += iSrcStride; |
---|
318 | pDst += iDstStride; |
---|
319 | } |
---|
320 | } |
---|
321 | #endif |
---|
322 | |
---|
323 | Void TComYuv::copyPartToPartLuma ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
324 | { |
---|
325 | Pel* pSrc = getLumaAddr(uiPartIdx); |
---|
326 | Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx); |
---|
327 | if( pSrc == pDst ) |
---|
328 | { |
---|
329 | //th not a good idea |
---|
330 | //th best would be to fix the caller |
---|
331 | return ; |
---|
332 | } |
---|
333 | |
---|
334 | UInt iSrcStride = getStride(); |
---|
335 | UInt iDstStride = pcYuvDst->getStride(); |
---|
336 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
337 | { |
---|
338 | ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) ); |
---|
339 | pSrc += iSrcStride; |
---|
340 | pDst += iDstStride; |
---|
341 | } |
---|
342 | } |
---|
343 | |
---|
344 | Void TComYuv::copyPartToPartChroma( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
345 | { |
---|
346 | Pel* pSrcU = getCbAddr(uiPartIdx); |
---|
347 | Pel* pSrcV = getCrAddr(uiPartIdx); |
---|
348 | Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); |
---|
349 | Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); |
---|
350 | |
---|
351 | if( pSrcU == pDstU && pSrcV == pDstV) |
---|
352 | { |
---|
353 | //th not a good idea |
---|
354 | //th best would be to fix the caller |
---|
355 | return ; |
---|
356 | } |
---|
357 | |
---|
358 | UInt iSrcStride = getCStride(); |
---|
359 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
360 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
361 | { |
---|
362 | ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) ); |
---|
363 | ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) ); |
---|
364 | pSrcU += iSrcStride; |
---|
365 | pSrcV += iSrcStride; |
---|
366 | pDstU += iDstStride; |
---|
367 | pDstV += iDstStride; |
---|
368 | } |
---|
369 | } |
---|
370 | |
---|
371 | Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
372 | { |
---|
373 | Int x, y; |
---|
374 | |
---|
375 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx); |
---|
376 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx); |
---|
377 | Pel* pDst = getLumaAddr( uiTrUnitIdx); |
---|
378 | |
---|
379 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
380 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
381 | UInt iDstStride = getStride(); |
---|
382 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
383 | { |
---|
384 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
385 | { |
---|
386 | pDst[x] = Clip( pSrc0[x] + pSrc1[x] ); |
---|
387 | } |
---|
388 | pSrc0 += iSrc0Stride; |
---|
389 | pSrc1 += iSrc1Stride; |
---|
390 | pDst += iDstStride; |
---|
391 | } |
---|
392 | } |
---|
393 | |
---|
394 | Void |
---|
395 | TComYuv::add( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
396 | { |
---|
397 | addLuma ( pcYuvAdd, iWidth, iHeight, bSubtract ); |
---|
398 | addChroma ( pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract ); |
---|
399 | } |
---|
400 | |
---|
401 | |
---|
402 | Void |
---|
403 | TComYuv::addLuma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
404 | { |
---|
405 | Int iScale = ( bSubtract ? -1 : 1 ); |
---|
406 | Int iAddStride = pcYuvAdd->getStride(); |
---|
407 | Int iDstStride = getStride(); |
---|
408 | Pel* pAddSamples = pcYuvAdd->getLumaAddr(); |
---|
409 | Pel* pDstSamples = getLumaAddr(); |
---|
410 | |
---|
411 | for( Int iY = 0; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride ) |
---|
412 | { |
---|
413 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
414 | { |
---|
415 | pDstSamples[iX] += iScale * pAddSamples[iX]; |
---|
416 | } |
---|
417 | } |
---|
418 | } |
---|
419 | |
---|
420 | Void |
---|
421 | TComYuv::addChroma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
422 | { |
---|
423 | Int iScale = ( bSubtract ? -1 : 1 ); |
---|
424 | Int iAddStride = pcYuvAdd->getCStride(); |
---|
425 | Int iDstStride = getCStride(); |
---|
426 | Pel* pAddSamplesCb = pcYuvAdd->getCbAddr(); |
---|
427 | Pel* pAddSamplesCr = pcYuvAdd->getCrAddr(); |
---|
428 | Pel* pDstSamplesCb = getCbAddr(); |
---|
429 | Pel* pDstSamplesCr = getCrAddr(); |
---|
430 | |
---|
431 | for( Int iY = 0; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride, |
---|
432 | pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride ) |
---|
433 | { |
---|
434 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
435 | { |
---|
436 | pDstSamplesCb[iX] += iScale * pAddSamplesCb[iX]; |
---|
437 | pDstSamplesCr[iX] += iScale * pAddSamplesCr[iX]; |
---|
438 | } |
---|
439 | } |
---|
440 | } |
---|
441 | |
---|
442 | Void |
---|
443 | TComYuv::clip( Int iWidth, Int iHeight ) |
---|
444 | { |
---|
445 | clipLuma ( iWidth, iHeight ); |
---|
446 | clipChroma ( iWidth>>1, iHeight>>1 ); |
---|
447 | } |
---|
448 | |
---|
449 | Void |
---|
450 | TComYuv::clipLuma( Int iWidth, Int iHeight ) |
---|
451 | { |
---|
452 | Int iStride = getStride(); |
---|
453 | Pel* pSamples = getLumaAddr(); |
---|
454 | for( Int iY = 0; iY < iHeight; iY++, pSamples += iStride ) |
---|
455 | { |
---|
456 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
457 | { |
---|
458 | pSamples[iX] = xClip( pSamples[iX] ); |
---|
459 | } |
---|
460 | } |
---|
461 | } |
---|
462 | |
---|
463 | Void |
---|
464 | TComYuv::clipChroma( Int iWidth, Int iHeight ) |
---|
465 | { |
---|
466 | Int iStride = getCStride(); |
---|
467 | Pel* pSamplesCb = getCbAddr(); |
---|
468 | Pel* pSamplesCr = getCrAddr(); |
---|
469 | for( Int iY = 0; iY < iHeight; iY++, pSamplesCb += iStride, pSamplesCr += iStride ) |
---|
470 | { |
---|
471 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
472 | { |
---|
473 | pSamplesCb[iX] = xClip( pSamplesCb[iX] ); |
---|
474 | pSamplesCr[iX] = xClip( pSamplesCr[iX] ); |
---|
475 | } |
---|
476 | } |
---|
477 | } |
---|
478 | |
---|
479 | Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
480 | { |
---|
481 | addClipLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
482 | addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
483 | } |
---|
484 | |
---|
485 | Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
486 | { |
---|
487 | Int x, y; |
---|
488 | |
---|
489 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
490 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
491 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
492 | |
---|
493 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
494 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
495 | UInt iDstStride = getStride(); |
---|
496 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
497 | { |
---|
498 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
499 | { |
---|
500 | pDst[x] = Clip( pSrc0[x] + pSrc1[x] ); |
---|
501 | } |
---|
502 | pSrc0 += iSrc0Stride; |
---|
503 | pSrc1 += iSrc1Stride; |
---|
504 | pDst += iDstStride; |
---|
505 | } |
---|
506 | } |
---|
507 | |
---|
508 | Void TComYuv::addClipChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
509 | { |
---|
510 | Int x, y; |
---|
511 | |
---|
512 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
513 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
514 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
515 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
516 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
517 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
518 | |
---|
519 | UInt iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
520 | UInt iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
521 | UInt iDstStride = getCStride(); |
---|
522 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
523 | { |
---|
524 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
525 | { |
---|
526 | pDstU[x] = Clip( pSrcU0[x] + pSrcU1[x] ); |
---|
527 | pDstV[x] = Clip( pSrcV0[x] + pSrcV1[x] ); |
---|
528 | } |
---|
529 | |
---|
530 | pSrcU0 += iSrc0Stride; |
---|
531 | pSrcU1 += iSrc1Stride; |
---|
532 | pSrcV0 += iSrc0Stride; |
---|
533 | pSrcV1 += iSrc1Stride; |
---|
534 | pDstU += iDstStride; |
---|
535 | pDstV += iDstStride; |
---|
536 | } |
---|
537 | } |
---|
538 | |
---|
539 | Void TComYuv::subtract( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
540 | { |
---|
541 | subtractLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
542 | subtractChroma( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
543 | } |
---|
544 | |
---|
545 | Void TComYuv::subtractLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
546 | { |
---|
547 | Int x, y; |
---|
548 | |
---|
549 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
550 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
551 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
552 | |
---|
553 | Int iSrc0Stride = pcYuvSrc0->getStride(); |
---|
554 | Int iSrc1Stride = pcYuvSrc1->getStride(); |
---|
555 | Int iDstStride = getStride(); |
---|
556 | |
---|
557 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
558 | { |
---|
559 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
560 | { |
---|
561 | pDst[x] = pSrc0[x] - pSrc1[x]; |
---|
562 | } |
---|
563 | pSrc0 += iSrc0Stride; |
---|
564 | pSrc1 += iSrc1Stride; |
---|
565 | pDst += iDstStride; |
---|
566 | } |
---|
567 | } |
---|
568 | |
---|
569 | Void TComYuv::subtractChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
570 | { |
---|
571 | Int x, y; |
---|
572 | |
---|
573 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
574 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
575 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
576 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
577 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
578 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
579 | |
---|
580 | Int iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
581 | Int iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
582 | Int iDstStride = getCStride(); |
---|
583 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
584 | { |
---|
585 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
586 | { |
---|
587 | pDstU[x] = pSrcU0[x] - pSrcU1[x]; |
---|
588 | pDstV[x] = pSrcV0[x] - pSrcV1[x]; |
---|
589 | } |
---|
590 | pSrcU0 += iSrc0Stride; |
---|
591 | pSrcU1 += iSrc1Stride; |
---|
592 | pSrcV0 += iSrc0Stride; |
---|
593 | pSrcV1 += iSrc1Stride; |
---|
594 | pDstU += iDstStride; |
---|
595 | pDstV += iDstStride; |
---|
596 | } |
---|
597 | } |
---|
598 | |
---|
599 | Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight ) |
---|
600 | { |
---|
601 | Int x, y; |
---|
602 | |
---|
603 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
604 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
605 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
606 | |
---|
607 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
608 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
609 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
610 | |
---|
611 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
612 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
613 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
614 | |
---|
615 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
616 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
617 | UInt iDstStride = getStride(); |
---|
618 | Int shiftNum = IF_INTERNAL_PREC + 1 - ( g_uiBitDepth + g_uiBitIncrement ); |
---|
619 | Int offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS; |
---|
620 | |
---|
621 | for ( y = 0; y < iHeight; y++ ) |
---|
622 | { |
---|
623 | for ( x = 0; x < iWidth; x += 4 ) |
---|
624 | { |
---|
625 | pDstY[ x + 0 ] = Clip( ( pSrcY0[ x + 0 ] + pSrcY1[ x + 0 ] + offset ) >> shiftNum ); |
---|
626 | pDstY[ x + 1 ] = Clip( ( pSrcY0[ x + 1 ] + pSrcY1[ x + 1 ] + offset ) >> shiftNum ); |
---|
627 | pDstY[ x + 2 ] = Clip( ( pSrcY0[ x + 2 ] + pSrcY1[ x + 2 ] + offset ) >> shiftNum ); |
---|
628 | pDstY[ x + 3 ] = Clip( ( pSrcY0[ x + 3 ] + pSrcY1[ x + 3 ] + offset ) >> shiftNum ); |
---|
629 | } |
---|
630 | pSrcY0 += iSrc0Stride; |
---|
631 | pSrcY1 += iSrc1Stride; |
---|
632 | pDstY += iDstStride; |
---|
633 | } |
---|
634 | |
---|
635 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
636 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
637 | iDstStride = getCStride(); |
---|
638 | |
---|
639 | iWidth >>=1; |
---|
640 | iHeight >>=1; |
---|
641 | |
---|
642 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
643 | { |
---|
644 | for ( x = iWidth-1; x >= 0; ) |
---|
645 | { |
---|
646 | // note: chroma min width is 2 |
---|
647 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
648 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
649 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
650 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
651 | } |
---|
652 | |
---|
653 | pSrcU0 += iSrc0Stride; |
---|
654 | pSrcU1 += iSrc1Stride; |
---|
655 | pSrcV0 += iSrc0Stride; |
---|
656 | pSrcV1 += iSrc1Stride; |
---|
657 | pDstU += iDstStride; |
---|
658 | pDstV += iDstStride; |
---|
659 | } |
---|
660 | } |
---|
661 | |
---|
662 | #if DEPTH_MAP_GENERATION |
---|
663 | Void TComYuv::addAvgPdm( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
664 | { |
---|
665 | Int x, y; |
---|
666 | |
---|
667 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX; |
---|
668 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY; |
---|
669 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
670 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
671 | Pel* pDstY = getLumaAddr() + uiBlkY * getStride() + uiBlkX; |
---|
672 | |
---|
673 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
674 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
675 | UInt iDstStride = getStride(); |
---|
676 | |
---|
677 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
678 | { |
---|
679 | for ( x = iWidth-1; x >= 0; x-- ) |
---|
680 | { |
---|
681 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; |
---|
682 | } |
---|
683 | pSrcY0 += iSrc0Stride; |
---|
684 | pSrcY1 += iSrc1Stride; |
---|
685 | pDstY += iDstStride; |
---|
686 | } |
---|
687 | } |
---|
688 | #endif |
---|
689 | |
---|
690 | Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight ) |
---|
691 | { |
---|
692 | Int x, y; |
---|
693 | |
---|
694 | Pel* pSrc = pcYuvSrc->getLumaAddr(uiPartIdx); |
---|
695 | Pel* pSrcU = pcYuvSrc->getCbAddr(uiPartIdx); |
---|
696 | Pel* pSrcV = pcYuvSrc->getCrAddr(uiPartIdx); |
---|
697 | |
---|
698 | Pel* pDst = getLumaAddr(uiPartIdx); |
---|
699 | Pel* pDstU = getCbAddr(uiPartIdx); |
---|
700 | Pel* pDstV = getCrAddr(uiPartIdx); |
---|
701 | |
---|
702 | Int iSrcStride = pcYuvSrc->getStride(); |
---|
703 | Int iDstStride = getStride(); |
---|
704 | |
---|
705 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
706 | { |
---|
707 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
708 | { |
---|
709 | #if DISABLING_CLIP_FOR_BIPREDME |
---|
710 | pDst[x ] = (pDst[x ]<<1) - pSrc[x ] ; |
---|
711 | #else |
---|
712 | pDst[x ] = Clip( (pDst[x ]<<1) - pSrc[x ] ); |
---|
713 | #endif |
---|
714 | } |
---|
715 | pSrc += iSrcStride; |
---|
716 | pDst += iDstStride; |
---|
717 | } |
---|
718 | |
---|
719 | iSrcStride = pcYuvSrc->getCStride(); |
---|
720 | iDstStride = getCStride(); |
---|
721 | |
---|
722 | uiHeight >>= 1; |
---|
723 | uiWidht >>= 1; |
---|
724 | |
---|
725 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
726 | { |
---|
727 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
728 | { |
---|
729 | #if DISABLING_CLIP_FOR_BIPREDME |
---|
730 | pDstU[x ] = (pDstU[x ]<<1) - pSrcU[x ] ; |
---|
731 | pDstV[x ] = (pDstV[x ]<<1) - pSrcV[x ] ; |
---|
732 | #else |
---|
733 | pDstU[x ] = Clip( (pDstU[x ]<<1) - pSrcU[x ] ); |
---|
734 | pDstV[x ] = Clip( (pDstV[x ]<<1) - pSrcV[x ] ); |
---|
735 | #endif |
---|
736 | } |
---|
737 | pSrcU += iSrcStride; |
---|
738 | pSrcV += iSrcStride; |
---|
739 | pDstU += iDstStride; |
---|
740 | pDstV += iDstStride; |
---|
741 | } |
---|
742 | } |
---|
743 | #if QC_ARP_D0177 |
---|
744 | Void TComYuv::addARP(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip ) |
---|
745 | { |
---|
746 | addARPLuma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth , uiHeight , bClip ); |
---|
747 | addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip ); |
---|
748 | } |
---|
749 | |
---|
750 | Void TComYuv::addARPLuma(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip ) |
---|
751 | { |
---|
752 | Int x, y; |
---|
753 | |
---|
754 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx ); |
---|
755 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx ); |
---|
756 | Pel* pDst = getLumaAddr( uiAbsPartIdx ); |
---|
757 | |
---|
758 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
759 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
760 | UInt iDstStride = getStride(); |
---|
761 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
762 | { |
---|
763 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
764 | { |
---|
765 | pDst[x] = pSrc0[x] + pSrc1[x]; |
---|
766 | if( bClip ) |
---|
767 | pDst[x] = Clip( pDst[x] ); |
---|
768 | } |
---|
769 | pSrc0 += iSrc0Stride; |
---|
770 | pSrc1 += iSrc1Stride; |
---|
771 | pDst += iDstStride; |
---|
772 | } |
---|
773 | } |
---|
774 | |
---|
775 | Void TComYuv::addARPChroma(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip ) |
---|
776 | { |
---|
777 | Int x, y; |
---|
778 | |
---|
779 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx ); |
---|
780 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx ); |
---|
781 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx ); |
---|
782 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx ); |
---|
783 | Pel* pDstU = getCbAddr( uiAbsPartIdx ); |
---|
784 | Pel* pDstV = getCrAddr( uiAbsPartIdx ); |
---|
785 | |
---|
786 | UInt iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
787 | UInt iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
788 | UInt iDstStride = getCStride(); |
---|
789 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
790 | { |
---|
791 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
792 | { |
---|
793 | pDstU[x] = pSrcU0[x] + pSrcU1[x]; |
---|
794 | pDstV[x] = pSrcV0[x] + pSrcV1[x]; |
---|
795 | if( bClip ) |
---|
796 | { |
---|
797 | pDstU[x] = Clip( pDstU[x] ); |
---|
798 | pDstV[x] = Clip( pDstV[x] ); |
---|
799 | } |
---|
800 | } |
---|
801 | |
---|
802 | pSrcU0 += iSrc0Stride; |
---|
803 | pSrcU1 += iSrc1Stride; |
---|
804 | pSrcV0 += iSrc0Stride; |
---|
805 | pSrcV1 += iSrc1Stride; |
---|
806 | pDstU += iDstStride; |
---|
807 | pDstV += iDstStride; |
---|
808 | } |
---|
809 | } |
---|
810 | |
---|
811 | Void TComYuv::subtractARP(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight) |
---|
812 | { |
---|
813 | subtractARPLuma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth , uiHeight ); |
---|
814 | subtractARPChroma( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 ); |
---|
815 | } |
---|
816 | |
---|
817 | Void TComYuv::subtractARPLuma(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight) |
---|
818 | { |
---|
819 | Int x, y; |
---|
820 | |
---|
821 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx ); |
---|
822 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx ); |
---|
823 | Pel* pDst = getLumaAddr( uiAbsPartIdx ); |
---|
824 | |
---|
825 | Int iSrc0Stride = pcYuvSrc0->getStride(); |
---|
826 | Int iSrc1Stride = pcYuvSrc1->getStride(); |
---|
827 | Int iDstStride = getStride(); |
---|
828 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
829 | { |
---|
830 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
831 | { |
---|
832 | pDst[x] = pSrc0[x] - pSrc1[x]; |
---|
833 | } |
---|
834 | pSrc0 += iSrc0Stride; |
---|
835 | pSrc1 += iSrc1Stride; |
---|
836 | pDst += iDstStride; |
---|
837 | } |
---|
838 | } |
---|
839 | |
---|
840 | Void TComYuv::subtractARPChroma(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight) |
---|
841 | { |
---|
842 | Int x, y; |
---|
843 | |
---|
844 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx ); |
---|
845 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx ); |
---|
846 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx ); |
---|
847 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx ); |
---|
848 | Pel* pDstU = getCbAddr( uiAbsPartIdx ); |
---|
849 | Pel* pDstV = getCrAddr( uiAbsPartIdx ); |
---|
850 | |
---|
851 | Int iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
852 | Int iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
853 | Int iDstStride = getCStride(); |
---|
854 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
855 | { |
---|
856 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
857 | { |
---|
858 | pDstU[x] = pSrcU0[x] - pSrcU1[x]; |
---|
859 | pDstV[x] = pSrcV0[x] - pSrcV1[x]; |
---|
860 | } |
---|
861 | pSrcU0 += iSrc0Stride; |
---|
862 | pSrcU1 += iSrc1Stride; |
---|
863 | pSrcV0 += iSrc0Stride; |
---|
864 | pSrcV1 += iSrc1Stride; |
---|
865 | pDstU += iDstStride; |
---|
866 | pDstV += iDstStride; |
---|
867 | } |
---|
868 | } |
---|
869 | |
---|
870 | Void TComYuv::multiplyARP( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ) |
---|
871 | { |
---|
872 | multiplyARPLuma( uiAbsPartIdx , uiWidth , uiHeight , dW ); |
---|
873 | multiplyARPChroma( uiAbsPartIdx , uiWidth >> 1 , uiHeight >> 1 , dW ); |
---|
874 | } |
---|
875 | |
---|
876 | Void TComYuv::xxMultiplyLine( Pel * pSrcDst , UInt uiWidth , UChar dW ) |
---|
877 | { |
---|
878 | assert( dW == 2 ); |
---|
879 | for( UInt x = 0 ; x < uiWidth ; x++ ) |
---|
880 | pSrcDst[x] = pSrcDst[x] >> 1; |
---|
881 | } |
---|
882 | |
---|
883 | Void TComYuv::multiplyARPLuma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ) |
---|
884 | { |
---|
885 | Pel* pDst = getLumaAddr( uiAbsPartIdx ); |
---|
886 | Int iDstStride = getStride(); |
---|
887 | for ( Int y = uiHeight-1; y >= 0; y-- ) |
---|
888 | { |
---|
889 | xxMultiplyLine( pDst , uiWidth , dW ); |
---|
890 | pDst += iDstStride; |
---|
891 | } |
---|
892 | } |
---|
893 | |
---|
894 | Void TComYuv::multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ) |
---|
895 | { |
---|
896 | Pel* pDstU = getCbAddr( uiAbsPartIdx ); |
---|
897 | Pel* pDstV = getCrAddr( uiAbsPartIdx ); |
---|
898 | |
---|
899 | Int iDstStride = getCStride(); |
---|
900 | for ( Int y = uiHeight-1; y >= 0; y-- ) |
---|
901 | { |
---|
902 | xxMultiplyLine( pDstU , uiWidth , dW ); |
---|
903 | xxMultiplyLine( pDstV , uiWidth , dW ); |
---|
904 | pDstU += iDstStride; |
---|
905 | pDstV += iDstStride; |
---|
906 | } |
---|
907 | } |
---|
908 | #endif |
---|
909 | //! \} |
---|