source: 3DVCSoftware/branches/HTM-6.0-dev0/source/Lib/TLibCommon/TComYuv.cpp @ 312

Last change on this file since 312 was 296, checked in by tech, 11 years ago

Reintegrated branch 5.1-dev0 rev. 295.

  • Property svn:eol-style set to native
File size: 31.8 KB
Line 
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
51TComYuv::TComYuv()
52{
53  m_apiBufY = NULL;
54  m_apiBufU = NULL;
55  m_apiBufV = NULL;
56}
57
58TComYuv::~TComYuv()
59{
60}
61
62Void 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
76Void 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
84Void 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
91Void 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
97Void 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
117Void 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
141Void TComYuv::copyFromPicYuv   ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx )
142{
143  copyFromPicLuma  ( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx );
144  copyFromPicChroma( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx );
145}
146
147Void 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
164Void 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
186Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx )
187{
188  copyToPartLuma  ( pcYuvDst, uiDstPartIdx );
189  copyToPartChroma( pcYuvDst, uiDstPartIdx );
190}
191
192Void 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
209Void 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
231Void TComYuv::copyPartToYuv( TComYuv* pcYuvDst, UInt uiSrcPartIdx )
232{
233  copyPartToLuma  ( pcYuvDst, uiSrcPartIdx );
234  copyPartToChroma( pcYuvDst, uiSrcPartIdx );
235}
236
237Void 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
258Void 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
285Void 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
291Void 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
298Void 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
323Void 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
344Void 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
371Void 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#if LG_RESTRICTEDRESPRED_M24766  && !MTK_MDIVRP_C0138
395Void
396TComYuv::add(Int *iPUResiPredShift, PartSize uhPartitionSize,  TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
397{
398  addLuma   (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth,    iHeight,    bSubtract );
399  addChroma (iPUResiPredShift, uhPartitionSize, pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract );
400}
401#else
402Void
403TComYuv::add( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
404{
405  addLuma   ( pcYuvAdd, iWidth,    iHeight,    bSubtract );
406  addChroma ( pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract );
407}
408#endif
409
410#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
411Void
412TComYuv::getPUXYOffset(PartSize uhPartitionSize, Int iWidth, Int iHeight, Int &iXOffset, Int &iYOffset)
413{
414  switch(uhPartitionSize)
415  {   
416  case SIZE_2NxN:
417    iXOffset = iWidth;      iYOffset = iHeight >> 1;   break;
418  case SIZE_2NxnU:
419    iXOffset = iWidth;      iYOffset = iHeight >> 2;   break;
420  case SIZE_2NxnD: 
421    iXOffset = iWidth;      iYOffset = (iHeight >> 1) + (iHeight >> 2);   break;
422  case SIZE_Nx2N:
423    iXOffset = iWidth >> 1; iYOffset = iHeight; break;
424  case SIZE_nLx2N:
425    iXOffset = iWidth >> 2; iYOffset = iHeight; break;
426  case SIZE_nRx2N:
427    iXOffset = (iWidth >> 1) + (iWidth >> 2); iYOffset = iHeight; break;
428  case SIZE_NxN:
429    iXOffset = iWidth >> 1; iYOffset = iHeight >> 1;  break;
430  default:
431    assert(uhPartitionSize == SIZE_2Nx2N);
432    iXOffset = iWidth;     iYOffset = iHeight;    break;
433  }
434}
435#endif
436
437#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
438Void
439TComYuv::addLuma(Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
440#else
441Void
442TComYuv::addLuma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
443#endif
444{
445  Int   iScale      = ( bSubtract ? -1 : 1 );
446  Int   iAddStride  = pcYuvAdd->getStride();
447  Int   iDstStride  = getStride();
448  Pel*  pAddSamples = pcYuvAdd->getLumaAddr();
449  Pel*  pDstSamples = getLumaAddr();
450
451#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
452  Int iXOffset, iYOffset;
453
454  getPUXYOffset(uhPartitionSize, iWidth, iHeight, iXOffset, iYOffset);
455
456  for( Int iY = 0; iY < iYOffset; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride )
457  {
458    if(iPUResiPredShift[0] >= 0)
459    {
460      for( Int iX = 0; iX < iXOffset; iX++ )
461      {
462        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[0]);
463      }
464    }
465
466    if(iPUResiPredShift[1] >= 0)
467    {
468      for( Int iX = iXOffset; iX < iWidth; iX++ )
469      {
470        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[1]);
471      }
472    }
473  }
474
475  for( Int iY = iYOffset; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride )
476  {
477    if(iPUResiPredShift[2] >= 0)
478    {
479      for( Int iX = 0; iX < iXOffset; iX++ )
480      {
481        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[2]);
482      }
483    }
484
485    if(iPUResiPredShift[3] >= 0)
486    {
487      for( Int iX = iXOffset; iX < iWidth; iX++ )
488      {
489        pDstSamples[iX] += iScale * (pAddSamples[iX] >> iPUResiPredShift[3]);
490      }
491    }
492  }
493#else
494  for( Int iY = 0; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride )
495  {
496    for( Int iX = 0; iX < iWidth; iX++ )
497    {
498      pDstSamples[iX] += iScale * pAddSamples[iX];
499    }
500  }
501#endif
502}
503
504#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
505Void
506TComYuv::addChroma(Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
507#else
508Void
509TComYuv::addChroma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract )
510#endif
511{
512  Int   iScale        = ( bSubtract ? -1 : 1 );
513  Int   iAddStride    = pcYuvAdd->getCStride();
514  Int   iDstStride    = getCStride();
515  Pel*  pAddSamplesCb = pcYuvAdd->getCbAddr();
516  Pel*  pAddSamplesCr = pcYuvAdd->getCrAddr();
517  Pel*  pDstSamplesCb = getCbAddr();
518  Pel*  pDstSamplesCr = getCrAddr();
519
520#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
521  Int iXOffset, iYOffset;
522 
523  getPUXYOffset(uhPartitionSize, iWidth, iHeight, iXOffset, iYOffset);
524
525  for( Int iY = 0; iY < iYOffset; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride,
526    pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
527  {
528    if(iPUResiPredShift[0] >= 0)
529    {
530      for( Int iX = 0; iX < iXOffset; iX++ )
531      {
532        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[0]);
533        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[0]);
534      }
535    }
536
537    if(iPUResiPredShift[1] >= 0)
538    {
539      for( Int iX = iXOffset; iX < iWidth; iX++ )
540      {
541        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[1]);
542        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[1]);
543      }
544    }
545  }
546
547  for( Int iY = iYOffset; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride,
548    pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
549  {
550    if(iPUResiPredShift[2] >= 0)
551    {
552      for( Int iX = 0; iX < iXOffset; iX++ )
553      {
554        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[2]);
555        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[2]);
556      }
557    }
558
559    if(iPUResiPredShift[3] >= 0)
560    {
561      for( Int iX = iXOffset; iX < iWidth; iX++ )
562      {
563        pDstSamplesCb[iX] += iScale * (pAddSamplesCb[iX] >> iPUResiPredShift[3]);
564        pDstSamplesCr[iX] += iScale * (pAddSamplesCr[iX] >> iPUResiPredShift[3]);
565      }
566    }
567  }
568#else
569  for( Int iY = 0; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride,
570                                       pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride  )
571  {
572    for( Int iX = 0; iX < iWidth; iX++ )
573    {
574      pDstSamplesCb[iX] += iScale * pAddSamplesCb[iX];
575      pDstSamplesCr[iX] += iScale * pAddSamplesCr[iX];
576    }
577  }
578#endif
579}
580
581Void
582TComYuv::clip( Int iWidth, Int iHeight )
583{
584  clipLuma   ( iWidth,    iHeight    );
585  clipChroma ( iWidth>>1, iHeight>>1 );
586}
587
588Void
589TComYuv::clipLuma( Int iWidth, Int iHeight )
590{
591  Int   iStride  = getStride();
592  Pel*  pSamples = getLumaAddr();
593  for( Int iY = 0; iY < iHeight; iY++, pSamples += iStride )
594  {
595    for( Int iX = 0; iX < iWidth; iX++ )
596    {
597      pSamples[iX] = xClip( pSamples[iX] );
598    }
599  }
600}
601
602Void
603TComYuv::clipChroma( Int iWidth, Int iHeight )
604{
605  Int   iStride    = getCStride();
606  Pel*  pSamplesCb = getCbAddr();
607  Pel*  pSamplesCr = getCrAddr();
608  for( Int iY = 0; iY < iHeight; iY++, pSamplesCb += iStride, pSamplesCr += iStride )
609  {
610    for( Int iX = 0; iX < iWidth; iX++ )
611    {
612      pSamplesCb[iX] = xClip( pSamplesCb[iX] );
613      pSamplesCr[iX] = xClip( pSamplesCr[iX] );
614    }
615  }
616}
617
618Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
619{
620  addClipLuma   ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize     );
621  addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1  );
622}
623
624Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
625{
626  Int x, y;
627 
628  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize );
629  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize );
630  Pel* pDst  = getLumaAddr( uiTrUnitIdx, uiPartSize );
631 
632  UInt iSrc0Stride = pcYuvSrc0->getStride();
633  UInt iSrc1Stride = pcYuvSrc1->getStride();
634  UInt iDstStride  = getStride();
635  for ( y = uiPartSize-1; y >= 0; y-- )
636  {
637    for ( x = uiPartSize-1; x >= 0; x-- )
638    {
639      pDst[x] = Clip( pSrc0[x] + pSrc1[x] );
640    }
641    pSrc0 += iSrc0Stride;
642    pSrc1 += iSrc1Stride;
643    pDst  += iDstStride;
644  }
645}
646
647Void TComYuv::addClipChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
648{
649  Int x, y;
650 
651  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize );
652  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize );
653  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize );
654  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize );
655  Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize );
656  Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize );
657 
658  UInt  iSrc0Stride = pcYuvSrc0->getCStride();
659  UInt  iSrc1Stride = pcYuvSrc1->getCStride();
660  UInt  iDstStride  = getCStride();
661  for ( y = uiPartSize-1; y >= 0; y-- )
662  {
663    for ( x = uiPartSize-1; x >= 0; x-- )
664    {
665      pDstU[x] = Clip( pSrcU0[x] + pSrcU1[x] );
666      pDstV[x] = Clip( pSrcV0[x] + pSrcV1[x] );
667    }
668   
669    pSrcU0 += iSrc0Stride;
670    pSrcU1 += iSrc1Stride;
671    pSrcV0 += iSrc0Stride;
672    pSrcV1 += iSrc1Stride;
673    pDstU  += iDstStride;
674    pDstV  += iDstStride;
675  }
676}
677
678#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
679Void TComYuv::subtract(Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
680{
681  subtractLuma  (iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize    );
682  subtractChroma(iPUResiPredShift, uhPartitionSize, pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize>>1 );
683}
684#else
685Void TComYuv::subtract( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
686{
687  subtractLuma  ( pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize    );
688  subtractChroma( pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize>>1 );
689}
690#endif
691
692#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
693Void TComYuv::subtractLuma(Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
694#else
695Void TComYuv::subtractLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
696#endif
697{
698  Int x, y;
699 
700  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize );
701  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize );
702  Pel* pDst  = getLumaAddr( uiTrUnitIdx, uiPartSize );
703 
704  Int  iSrc0Stride = pcYuvSrc0->getStride();
705  Int  iSrc1Stride = pcYuvSrc1->getStride();
706  Int  iDstStride  = getStride();
707
708#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
709  Int iXOffset, iYOffset;
710
711  getPUXYOffset(uhPartitionSize, uiPartSize, uiPartSize, iXOffset, iYOffset);
712
713#if FIX_LG_RESTRICTEDRESPRED_M24766
714  for ( y = 0; y < iYOffset; y++ )
715  {
716    if(iPUResiPredShift[0] >= 0)
717    {
718      for ( x = 0; x < iXOffset; x++ )
719      {
720        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[0]);
721      }
722    }
723
724    if(iPUResiPredShift[1] >= 0)
725    {
726      for ( x = iXOffset; x < uiPartSize; x++ )
727      {
728        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[1]);
729      }
730    }
731    pSrc0 += iSrc0Stride;
732    pSrc1 += iSrc1Stride;
733    pDst  += iDstStride;
734  }
735
736  for ( y = iYOffset; y < uiPartSize; y++ )
737  {
738    if(iPUResiPredShift[2] >= 0)
739    {
740      for ( x = 0; x < iXOffset; x++ )
741      {
742        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
743      }
744    }
745
746    if(iPUResiPredShift[3] >= 0)
747    {
748      for ( x = iXOffset; x < uiPartSize; x++ )
749      {
750        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
751      }
752    }
753    pSrc0 += iSrc0Stride;
754    pSrc1 += iSrc1Stride;
755    pDst  += iDstStride;
756  }
757#else
758  for ( y = uiPartSize-1; y >= iYOffset; y-- )
759  {
760    if(iPUResiPredShift[3] >= 0)
761    {
762      for ( x = uiPartSize-1; x >= iXOffset; x-- )
763      {
764        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
765      }
766    }
767
768    if(iPUResiPredShift[2] >= 0)
769    {
770      for ( x = iXOffset-1; x >= 0; x-- )
771      {
772        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
773      }
774    }
775    pSrc0 += iSrc0Stride;
776    pSrc1 += iSrc1Stride;
777    pDst  += iDstStride;
778  }
779
780  for ( y = iYOffset-1; y >= 0; y-- )
781  {
782    if(iPUResiPredShift[1] >= 0)
783    {
784      for ( x = uiPartSize-1; x >= iXOffset; x-- )
785      {
786        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[3]);
787      }
788    }
789
790    if(iPUResiPredShift[0] >= 0)
791    {
792      for ( x = iXOffset-1; x >= 0; x-- )
793      {
794        pDst[x] = pSrc0[x] - (pSrc1[x] >> iPUResiPredShift[2]);
795      }
796    }
797    pSrc0 += iSrc0Stride;
798    pSrc1 += iSrc1Stride;
799    pDst  += iDstStride;
800  }
801#endif
802#else
803  for ( y = uiPartSize-1; y >= 0; y-- )
804  {
805    for ( x = uiPartSize-1; x >= 0; x-- )
806    {
807      pDst[x] = pSrc0[x] - pSrc1[x];
808    }
809    pSrc0 += iSrc0Stride;
810    pSrc1 += iSrc1Stride;
811    pDst  += iDstStride;
812  }
813#endif
814}
815
816#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
817Void TComYuv::subtractChroma(Int *iPUResiPredShift, PartSize uhPartitionSize, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
818#else
819Void TComYuv::subtractChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
820#endif
821{
822  Int x, y;
823 
824  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize );
825  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize );
826  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize );
827  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize );
828  Pel* pDstU  = getCbAddr( uiTrUnitIdx, uiPartSize );
829  Pel* pDstV  = getCrAddr( uiTrUnitIdx, uiPartSize );
830 
831  Int  iSrc0Stride = pcYuvSrc0->getCStride();
832  Int  iSrc1Stride = pcYuvSrc1->getCStride();
833  Int  iDstStride  = getCStride();
834#if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138
835  Int iXOffset, iYOffset;
836 
837  getPUXYOffset(uhPartitionSize, uiPartSize, uiPartSize, iXOffset, iYOffset);
838
839#if FIX_LG_RESTRICTEDRESPRED_M24766
840  for ( y = 0; y < iYOffset; y++ )
841  {
842    if(iPUResiPredShift[0] >= 0)
843    {
844      for ( x = 0; x < iXOffset; x++ )
845      {
846        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[0]);
847        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[0]);
848      }
849    }
850
851    if(iPUResiPredShift[1] >= 0)
852    {
853      for ( x = iXOffset; x < uiPartSize; x++ )
854      {
855        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[1]);
856        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[1]);
857      }
858    }
859    pSrcU0 += iSrc0Stride;
860    pSrcU1 += iSrc1Stride;
861    pSrcV0 += iSrc0Stride;
862    pSrcV1 += iSrc1Stride;
863    pDstU  += iDstStride;
864    pDstV  += iDstStride;
865  }
866
867  for ( y = iYOffset; y < uiPartSize; y++ )
868  {
869    if(iPUResiPredShift[2] >= 0)
870    {
871      for ( x = 0; x < iXOffset; x++ )
872      {
873        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[2]);
874        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[2]);
875      }
876    }
877
878    if(iPUResiPredShift[3] >= 0)
879    {
880      for ( x = iXOffset; x < uiPartSize; x++ )
881      {
882        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[3]);
883        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[3]);
884      }
885    }
886    pSrcU0 += iSrc0Stride;
887    pSrcU1 += iSrc1Stride;
888    pSrcV0 += iSrc0Stride;
889    pSrcV1 += iSrc1Stride;
890    pDstU  += iDstStride;
891    pDstV  += iDstStride;
892  }
893#else
894  for ( y = uiPartSize-1; y >= iYOffset; y-- )
895  {
896    if(iPUResiPredShift[3] >= 0)
897    {
898      for ( x = uiPartSize-1; x >= iXOffset; x-- )
899      {
900        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[3]);
901        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[3]);
902      }
903    }
904
905    if(iPUResiPredShift[2] >= 0)
906    {
907      for ( x = iXOffset-1; x >= 0; x-- )
908      {
909        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[2]);
910        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[2]);
911      }
912    }
913    pSrcU0 += iSrc0Stride;
914    pSrcU1 += iSrc1Stride;
915    pSrcV0 += iSrc0Stride;
916    pSrcV1 += iSrc1Stride;
917    pDstU  += iDstStride;
918    pDstV  += iDstStride;
919  }
920
921  for ( y = iYOffset-1; y >= 0; y-- )
922  {
923    if(iPUResiPredShift[1] >= 0)
924    {
925      for ( x = uiPartSize-1; x >= iXOffset; x-- )
926      {
927        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[1]);
928        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[1]);
929      }
930    }
931
932    if(iPUResiPredShift[0] >= 0)
933    {
934      for ( x = iXOffset-1; x >= 0; x-- )
935      {
936        pDstU[x] = pSrcU0[x] - (pSrcU1[x]>>iPUResiPredShift[0]);
937        pDstV[x] = pSrcV0[x] - (pSrcV1[x]>>iPUResiPredShift[0]);
938      }
939    }
940    pSrcU0 += iSrc0Stride;
941    pSrcU1 += iSrc1Stride;
942    pSrcV0 += iSrc0Stride;
943    pSrcV1 += iSrc1Stride;
944    pDstU  += iDstStride;
945    pDstV  += iDstStride;
946  }
947#endif
948#else
949  for ( y = uiPartSize-1; y >= 0; y-- )
950  {
951    for ( x = uiPartSize-1; x >= 0; x-- )
952    {
953      pDstU[x] = pSrcU0[x] - pSrcU1[x];
954      pDstV[x] = pSrcV0[x] - pSrcV1[x];
955    }
956    pSrcU0 += iSrc0Stride;
957    pSrcU1 += iSrc1Stride;
958    pSrcV0 += iSrc0Stride;
959    pSrcV1 += iSrc1Stride;
960    pDstU  += iDstStride;
961    pDstV  += iDstStride;
962  }
963#endif
964}
965
966Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight )
967{
968  Int x, y;
969 
970  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
971  Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
972  Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
973 
974  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
975  Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
976  Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
977 
978  Pel* pDstY   = getLumaAddr( iPartUnitIdx );
979  Pel* pDstU   = getCbAddr  ( iPartUnitIdx );
980  Pel* pDstV   = getCrAddr  ( iPartUnitIdx );
981 
982  UInt  iSrc0Stride = pcYuvSrc0->getStride();
983  UInt  iSrc1Stride = pcYuvSrc1->getStride();
984  UInt  iDstStride  = getStride();
985  Int shiftNum = IF_INTERNAL_PREC + 1 - ( g_uiBitDepth + g_uiBitIncrement );
986  Int offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS;
987 
988  for ( y = 0; y < iHeight; y++ )
989  {
990    for ( x = 0; x < iWidth; x += 4 )
991    {
992      pDstY[ x + 0 ] = Clip( ( pSrcY0[ x + 0 ] + pSrcY1[ x + 0 ] + offset ) >> shiftNum );
993      pDstY[ x + 1 ] = Clip( ( pSrcY0[ x + 1 ] + pSrcY1[ x + 1 ] + offset ) >> shiftNum );
994      pDstY[ x + 2 ] = Clip( ( pSrcY0[ x + 2 ] + pSrcY1[ x + 2 ] + offset ) >> shiftNum );
995      pDstY[ x + 3 ] = Clip( ( pSrcY0[ x + 3 ] + pSrcY1[ x + 3 ] + offset ) >> shiftNum );
996    }
997    pSrcY0 += iSrc0Stride;
998    pSrcY1 += iSrc1Stride;
999    pDstY  += iDstStride;
1000  }
1001 
1002  iSrc0Stride = pcYuvSrc0->getCStride();
1003  iSrc1Stride = pcYuvSrc1->getCStride();
1004  iDstStride  = getCStride();
1005 
1006  iWidth  >>=1;
1007  iHeight >>=1;
1008 
1009  for ( y = iHeight-1; y >= 0; y-- )
1010  {
1011    for ( x = iWidth-1; x >= 0; )
1012    {
1013      // note: chroma min width is 2
1014      pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);
1015      pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--;
1016      pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);
1017      pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--;
1018    }
1019   
1020    pSrcU0 += iSrc0Stride;
1021    pSrcU1 += iSrc1Stride;
1022    pSrcV0 += iSrc0Stride;
1023    pSrcV1 += iSrc1Stride;
1024    pDstU  += iDstStride;
1025    pDstV  += iDstStride;
1026  }
1027}
1028
1029#if DEPTH_MAP_GENERATION
1030Void TComYuv::addAvgPdm( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY )
1031{
1032  Int x, y;
1033
1034  UInt uiBlkX  = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX;
1035  UInt uiBlkY  = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY;
1036  Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
1037  Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
1038  Pel* pDstY   = getLumaAddr() + uiBlkY * getStride() + uiBlkX;
1039
1040  UInt  iSrc0Stride = pcYuvSrc0->getStride();
1041  UInt  iSrc1Stride = pcYuvSrc1->getStride();
1042  UInt  iDstStride  = getStride();
1043
1044  for ( y = iHeight-1; y >= 0; y-- )
1045  {
1046    for ( x = iWidth-1; x >= 0; x-- )
1047    {
1048      pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1;
1049    }
1050    pSrcY0 += iSrc0Stride;
1051    pSrcY1 += iSrc1Stride;
1052    pDstY  += iDstStride;
1053  }
1054}
1055#endif
1056
1057Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight )
1058{
1059  Int x, y;
1060 
1061  Pel* pSrc  = pcYuvSrc->getLumaAddr(uiPartIdx);
1062  Pel* pSrcU = pcYuvSrc->getCbAddr(uiPartIdx);
1063  Pel* pSrcV = pcYuvSrc->getCrAddr(uiPartIdx);
1064 
1065  Pel* pDst  = getLumaAddr(uiPartIdx);
1066  Pel* pDstU = getCbAddr(uiPartIdx);
1067  Pel* pDstV = getCrAddr(uiPartIdx);
1068 
1069  Int  iSrcStride = pcYuvSrc->getStride();
1070  Int  iDstStride = getStride();
1071 
1072  for ( y = uiHeight-1; y >= 0; y-- )
1073  {
1074    for ( x = uiWidht-1; x >= 0; x-- )
1075    {
1076#if DISABLING_CLIP_FOR_BIPREDME
1077      pDst[x ] = (pDst[x ]<<1) - pSrc[x ] ;
1078#else
1079      pDst[x ] = Clip( (pDst[x ]<<1) - pSrc[x ] );
1080#endif
1081    }
1082    pSrc += iSrcStride;
1083    pDst += iDstStride;
1084  }
1085 
1086  iSrcStride = pcYuvSrc->getCStride();
1087  iDstStride = getCStride();
1088 
1089  uiHeight >>= 1;
1090  uiWidht  >>= 1;
1091 
1092  for ( y = uiHeight-1; y >= 0; y-- )
1093  {
1094    for ( x = uiWidht-1; x >= 0; x-- )
1095    {
1096#if DISABLING_CLIP_FOR_BIPREDME
1097      pDstU[x ] = (pDstU[x ]<<1) - pSrcU[x ] ;
1098      pDstV[x ] = (pDstV[x ]<<1) - pSrcV[x ] ;
1099#else
1100      pDstU[x ] = Clip( (pDstU[x ]<<1) - pSrcU[x ] );
1101      pDstV[x ] = Clip( (pDstV[x ]<<1) - pSrcV[x ] );
1102#endif
1103    }
1104    pSrcU += iSrcStride;
1105    pSrcV += iSrcStride;
1106    pDstU += iDstStride;
1107    pDstV += iDstStride;
1108  }
1109}
1110//! \}
Note: See TracBrowser for help on using the repository browser.