source: 3DVCSoftware/trunk/source/Lib/TLibRenderer/TRenInterpFilter.h @ 1313

Last change on this file since 1313 was 1313, checked in by tech, 9 years ago

Merged 14.1-update-dev1@1312.

File size: 41.6 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-2015, 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 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     TRenInterpFilter.h
37    \brief    interpolation filter class (header), (From HM 3.0 TComPredFilter))
38*/
39
40#ifndef __TRENINTERPFILTER__
41#define __TRENINTERPFILTER__
42
43// Include files
44#include "TLibCommon/CommonDef.h"
45#include "assert.h"
46#if NH_3D
47
48// ====================================================================================================================
49// Constants
50// ====================================================================================================================
51
52// Local type definitions
53#define HAL_IDX   1
54#define QU0_IDX   0
55#define QU1_IDX   2
56
57// ====================================================================================================================
58// Class definition
59// ====================================================================================================================
60
61/// interpolation filter class
62template<UInt bitDepth>
63class TRenInterpFilter
64{
65public:
66  TRenInterpFilter();
67 
68  // DIF filter interface (for half & quarter)
69  __inline Void xCTI_FilterHalfHor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);
70  __inline Void xCTI_FilterHalfHor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);
71 
72  __inline Void xCTI_FilterQuarter0Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);
73  __inline Void xCTI_FilterQuarter0Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);
74 
75  __inline Void xCTI_FilterQuarter1Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);
76  __inline Void xCTI_FilterQuarter1Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst);
77 
78  __inline Void xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst, Int iDstStridePel, Pel*& rpiDstPel );
79  __inline Void xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst );
80  __inline Void xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst );
81 
82  __inline Void xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst );
83  __inline Void xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst );
84 
85  __inline Void xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst );
86  __inline Void xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst );
87 
88  __inline Void xCTI_Filter2DVerC (Pel* piSrc, Int iSrcStride,  Int iWidth, Int iHeight, Int iDstStride,  Int*& rpiDst, Int iMv);
89  __inline Void xCTI_Filter2DHorC (Int* piSrc, Int iSrcStride,  Int iWidth, Int iHeight, Int iDstStride,  Pel*& rpiDst, Int iMV);
90  __inline Void xCTI_Filter1DHorC (Pel* piSrc, Int iSrcStride,  Int iWidth, Int iHeight, Int iDstStride,  Pel*& rpiDst, Int iMV);
91  __inline Void xCTI_Filter1DVerC (Pel* piSrc, Int iSrcStride,  Int iWidth, Int iHeight, Int iDstStride,  Pel*& rpiDst, Int iMV);
92
93   __inline Int xCTI_Filter_VPS04_C_HAL( Pel* pSrc, Int iStride );
94   __inline Int xCTI_Filter_VIS04_C_HAL( Int* pSrc, Int iStride );
95   __inline Int xCTI_Filter_VP04_C_OCT0( Pel* pSrc, Int iStride );
96   __inline Int xCTI_Filter_VI04_C_OCT0( Int* pSrc, Int iStride );
97   __inline Int xCTI_Filter_VP04_C_QUA0( Pel* pSrc, Int iStride );
98   __inline Int xCTI_Filter_VI04_C_QUA0( Int* pSrc, Int iStride );
99   __inline Int xCTI_Filter_VP04_C_OCT1( Pel* pSrc, Int iStride );
100   __inline Int xCTI_Filter_VI04_C_OCT1( Int* pSrc, Int iStride );
101   __inline Int xCTI_Filter_VP04_C_OCT2( Pel* pSrc, Int iStride );
102   __inline Int xCTI_Filter_VI04_C_OCT2( Int* pSrc, Int iStride );
103   __inline Int xCTI_Filter_VP04_C_QUA1( Pel* pSrc, Int iStride );
104   __inline Int xCTI_Filter_VI04_C_QUA1( Int* pSrc, Int iStride );
105   __inline Int xCTI_Filter_VP04_C_OCT3( Pel* pSrc, Int iStride );
106   __inline Int xCTI_Filter_VI04_C_OCT3( Int* pSrc, Int iStride );
107private:
108  __inline Int xClipY( Pel x ) { return std::min<Pel>(Pel((1 << bitDepth)-1), std::max<Pel>( Pel(0), x)); } 
109  __inline Int xClipC( Pel x ) { return std::min<Pel>(Pel((1 << bitDepth)-1), std::max<Pel>( Pel(0), x)); }
110
111};
112
113
114// ------------------------------------------------------------------------------------------------
115// DCTIF filters
116// ------------------------------------------------------------------------------------------------
117template<UInt bitDepth>
118__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfHor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
119{
120  Pel*  piDst    = rpiDst;
121  Int   iSum;
122  Pel*  piSrcTmp;
123  Int iSrcStep2 = iSrcStep*2;
124  Int iSrcStep3 = iSrcStep*3;
125  Int iSrcStep4 = iSrcStep*4;
126  Int iSrcStep5 = iSrcStep*5;
127  Int iSrcStep6 = iSrcStep*6;
128  Int iSrcStep7 = iSrcStep*7;
129
130  Int iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;
131
132  for ( Int y = iHeight; y != 0; y-- )
133  {
134    piSrcTmp = &piSrc[ -3*iSrcStep ];
135    for ( Int x = 0; x < iWidth; x++ )
136    {
137      // { -1,4,-11,40,40,-11,4,-1   }
138      iTmp0 = piSrcTmp[        0]+piSrcTmp[iSrcStep7];
139      iTmp1 = piSrcTmp[iSrcStep]+piSrcTmp[iSrcStep6];
140      iTmp2 = piSrcTmp[iSrcStep2]+piSrcTmp[iSrcStep5];
141      iTmp3 = piSrcTmp[iSrcStep3]+piSrcTmp[iSrcStep4];
142
143      iTmpA = (iTmp3 << 2) - iTmp2;
144
145      iSum  = (   iTmp1          << 2 )
146            + (   iTmpA          << 3 )
147            + (   iTmpA          << 1 )
148            -    iTmp0 -  iTmp2;
149
150      piDst   [x * iDstStep] = xClipY( (iSum +  32) >>  6 );
151      piSrcTmp += iSrcStep;
152    }
153    piSrc += iSrcStride;
154    piDst += iDstStride;
155  }
156  return;
157}
158
159template<UInt bitDepth>
160__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfHor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
161{
162  Pel*  piDst    = rpiDst;
163  Int   iSum;
164  Int*  piSrcTmp;
165  Int iSrcStep2 = iSrcStep*2;
166  Int iSrcStep3 = iSrcStep*3;
167  Int iSrcStep4 = iSrcStep*4;
168  Int iSrcStep5 = iSrcStep*5;
169  Int iSrcStep6 = iSrcStep*6;
170  Int iSrcStep7 = iSrcStep*7;
171
172  Int iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;
173
174  for ( Int y = iHeight; y != 0; y-- )
175  {
176    piSrcTmp = &piSrc[ -3*iSrcStep ];
177    for ( Int x = 0; x < iWidth; x++ )
178    {
179      // { -1,4,-11,40,40,-11,4,-1   }
180      iTmp0 = piSrcTmp[        0]+piSrcTmp[iSrcStep7];
181      iTmp1 = piSrcTmp[iSrcStep ]+piSrcTmp[iSrcStep6];
182      iTmp2 = piSrcTmp[iSrcStep2]+piSrcTmp[iSrcStep5];
183      iTmp3 = piSrcTmp[iSrcStep3]+piSrcTmp[iSrcStep4];
184     
185      iTmpA = (iTmp3 << 2) - iTmp2;
186     
187      iSum  = (   iTmp1          << 2 )
188            + (   iTmpA          << 3 )
189            + (   iTmpA          << 1 )
190            -    iTmp0 -  iTmp2;
191     
192      piDst   [x * iDstStep] = xClipY( (iSum +  2048) >>  12 );
193      piSrcTmp += iSrcStep;
194    }
195    piSrc += iSrcStride;
196    piDst += iDstStride;
197  }
198  return;
199}
200
201template<UInt bitDepth>
202__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
203{ 
204  Pel*  piDst    = rpiDst;
205  Int   iSum;
206  Pel*  piSrcTmp;
207  Int iSrcStep2 = iSrcStep*2;
208  Int iSrcStep3 = iSrcStep*3;
209  Int iSrcStep4 = iSrcStep*4;
210  Int iSrcStep5 = iSrcStep*5;
211  Int iSrcStep6 = iSrcStep*6;
212  Int iSrcStep7 = iSrcStep*7;
213
214  Int  iTmp1, iTmp2;
215
216  for ( Int y = iHeight; y != 0; y-- )
217  {
218    piSrcTmp = &piSrc[ -3*iSrcStep ];
219    for ( Int x = 0; x < iWidth; x++ )
220    {
221      // {-1,   4,  -10,  57,   19,  -7,   3,   -1  },
222     
223      iTmp1 = piSrcTmp[iSrcStep3] + piSrcTmp[iSrcStep5];
224      iTmp2 = piSrcTmp[iSrcStep6] + piSrcTmp[iSrcStep4];
225     
226      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]
227             - ( ( piSrcTmp[iSrcStep2] - iTmp2 ) << 1 )
228             + (  piSrcTmp[iSrcStep]             << 2 )
229             - ( ( piSrcTmp[iSrcStep2] + iTmp1 ) << 3 )
230             + (   piSrcTmp[iSrcStep4]           << 4 );
231     
232      piDst   [x * iDstStep] = xClipY(( (iSum +  32) >>  6 )+ piSrcTmp[iSrcStep3]);
233      piSrcTmp += iSrcStep;
234    }
235    piSrc += iSrcStride;
236    piDst += iDstStride;
237  }
238  return;
239}
240
241template<UInt bitDepth>
242__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
243{
244  Pel*  piDst    = rpiDst;
245  Int   iSum;
246  Int*  piSrcTmp;
247  Int iSrcStep2 = iSrcStep*2;
248  Int iSrcStep3 = iSrcStep*3;
249  Int iSrcStep4 = iSrcStep*4;
250  Int iSrcStep5 = iSrcStep*5;
251  Int iSrcStep6 = iSrcStep*6;
252  Int iSrcStep7 = iSrcStep*7;
253
254  Int  iTmp1, iTmp2;
255
256  for ( Int y = iHeight; y != 0; y-- )
257  {
258    piSrcTmp = &piSrc[ -3*iSrcStep ];
259    for ( Int x = 0; x < iWidth; x++ )
260    {
261      // {-1,   4,  -10,  57,   19,  -7,   3,   -1  },
262   
263      iTmp1 = piSrcTmp[iSrcStep3] + piSrcTmp[iSrcStep5];
264      iTmp2 = piSrcTmp[iSrcStep6] + piSrcTmp[iSrcStep4];
265     
266      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]
267            - ( ( piSrcTmp[iSrcStep2] - iTmp2 ) << 1 )
268            + (  piSrcTmp[iSrcStep]             << 2 )
269            - ( ( piSrcTmp[iSrcStep2] + iTmp1 ) << 3 )
270            + (   piSrcTmp[iSrcStep4]           << 4 )
271            + (   piSrcTmp[iSrcStep3]           << 6 );
272     
273      piDst   [x * iDstStep] = xClipY( (iSum +  2048) >>  12 );
274      piSrcTmp += iSrcStep;
275    }
276    piSrc += iSrcStride;
277    piDst += iDstStride;
278  }
279  return;
280}
281
282template<UInt bitDepth>
283__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Hor(Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
284{
285  Pel*  piDst    = rpiDst;
286  Int   iSum;
287  Pel*  piSrcTmp;
288  Int iSrcStep2 = iSrcStep*2;
289  Int iSrcStep3 = iSrcStep*3;
290  Int iSrcStep4 = iSrcStep*4;
291  Int iSrcStep5 = iSrcStep*5;
292  Int iSrcStep6 = iSrcStep*6;
293  Int iSrcStep7 = iSrcStep*7;
294
295  Int  iTmp1, iTmp2;
296  for ( Int y = iHeight; y != 0; y-- )
297  {
298    piSrcTmp = &piSrc[ -3*iSrcStep ];
299    for ( Int x = 0; x < iWidth; x++ )
300    {
301      // {-1,   3,  -7,  19,   57,  -10,   4,   -1  },
302     
303      iTmp1 = piSrcTmp[iSrcStep4] + piSrcTmp[iSrcStep2];
304      iTmp2 = piSrcTmp[iSrcStep ] + piSrcTmp[iSrcStep3];
305     
306      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]
307            - ( ( piSrcTmp[iSrcStep5] - iTmp2 ) << 1 )
308            + (   piSrcTmp[iSrcStep6]           << 2 )
309            - ( ( piSrcTmp[iSrcStep5] + iTmp1 ) << 3 )
310            + (   piSrcTmp[iSrcStep3]           << 4 );
311     
312      piDst   [x * iDstStep] = xClipY( ((iSum +  32) >>  6) + piSrcTmp[iSrcStep4] );
313      piSrcTmp += iSrcStep;
314    }
315    piSrc += iSrcStride;
316    piDst += iDstStride;
317  }
318  return;
319}
320
321template<UInt bitDepth>
322__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Hor(Int* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
323{
324  Pel*  piDst    = rpiDst;
325  Int   iSum;
326  Int*  piSrcTmp;
327  Int iSrcStep2 = iSrcStep*2;
328  Int iSrcStep3 = iSrcStep*3;
329  Int iSrcStep4 = iSrcStep*4;
330  Int iSrcStep5 = iSrcStep*5;
331  Int iSrcStep6 = iSrcStep*6;
332  Int iSrcStep7 = iSrcStep*7;
333
334  Int  iTmp1, iTmp2;
335  for ( Int y = iHeight; y != 0; y-- )
336  {
337    piSrcTmp = &piSrc[ -3*iSrcStep ];
338    for ( Int x = 0; x < iWidth; x++ )
339    {
340      // {-1,   3,  -7,  19,   57,  -10,   4,   -1  },
341     
342      iTmp1 = piSrcTmp[iSrcStep4] + piSrcTmp[iSrcStep2];
343      iTmp2 = piSrcTmp[iSrcStep ] + piSrcTmp[iSrcStep3];
344     
345      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStep7]
346            - ( ( piSrcTmp[iSrcStep5] - iTmp2 ) << 1 )
347            + (   piSrcTmp[iSrcStep6]           << 2 )
348            - ( ( piSrcTmp[iSrcStep5] + iTmp1 ) << 3 )
349            + (   piSrcTmp[iSrcStep3]           << 4 )
350            + (   piSrcTmp[iSrcStep4]           << 6 );
351     
352      piDst   [x * iDstStep] = xClipY( (iSum +  2048) >>  12 );
353      piSrcTmp += iSrcStep;
354    }
355    piSrc += iSrcStride;
356    piDst += iDstStride;
357  }
358  return;
359}
360
361template<UInt bitDepth>
362__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst, Int iDstStridePel, Pel*& rpiDstPel )
363{
364  Int*  piDst = rpiDst;
365  Pel*  piDstPel = rpiDstPel;
366  Int   iSum;
367  Pel*  piSrcTmp;
368  Int iSrcStride2 = iSrcStride*2;
369  Int iSrcStride3 = iSrcStride*3;
370  Int iSrcStride4 = iSrcStride*4;
371  Int iSrcStride5 = iSrcStride*5;
372  Int iSrcStride6 = iSrcStride*6;
373  Int iSrcStride7 = iSrcStride*7;
374
375  Int  iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;
376  for ( Int y = iHeight; y != 0; y-- )
377  {
378    piSrcTmp = &piSrc[ -3*iSrcStride ];
379    for ( Int x = 0; x < iWidth; x++ )
380    {
381      // { -1,4,-11,40,40,-11,4,-1   }
382      iTmp0 = piSrcTmp[          0]+piSrcTmp[iSrcStride7];
383      iTmp1 = piSrcTmp[iSrcStride ]+piSrcTmp[iSrcStride6];
384      iTmp2 = piSrcTmp[iSrcStride2]+piSrcTmp[iSrcStride5];
385      iTmp3 = piSrcTmp[iSrcStride3]+piSrcTmp[iSrcStride4];
386     
387      iTmpA = (iTmp3 << 2) - iTmp2;
388     
389      iSum  = (   iTmp1          << 2 )
390            + (   iTmpA          << 3 )
391            + (   iTmpA          << 1 )
392            -    iTmp0 -  iTmp2;
393     
394      piDst[x * iDstStep]    = iSum;
395      piDstPel[x * iDstStep] = xClipY( (iSum +  32) >>  6 );
396      piSrcTmp += iSrcStep;
397    }
398    piSrc += iSrcStride;
399    piDst += iDstStride;
400    piDstPel += iDstStridePel;
401  }
402 return;
403}
404
405template<UInt bitDepth>
406__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst)
407{
408  Int*  piDst = rpiDst;
409  Int   iSum;
410  Pel*  piSrcTmp;
411  Int iSrcStride2 = iSrcStride*2;
412  Int iSrcStride3 = iSrcStride*3;
413  Int iSrcStride4 = iSrcStride*4;
414  Int iSrcStride5 = iSrcStride*5;
415  Int iSrcStride6 = iSrcStride*6;
416  Int iSrcStride7 = iSrcStride*7;
417
418  Int  iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;
419  for ( Int y = iHeight; y != 0; y-- )
420  {
421    piSrcTmp = &piSrc[ -3*iSrcStride ];
422    for ( Int x = 0; x < iWidth; x++ )
423    {
424      // { -1,4,-11,40,40,-11,4,-1   }
425      iTmp0 = piSrcTmp[          0]+piSrcTmp[iSrcStride7];
426      iTmp1 = piSrcTmp[iSrcStride ]+piSrcTmp[iSrcStride6];
427      iTmp2 = piSrcTmp[iSrcStride2]+piSrcTmp[iSrcStride5];
428      iTmp3 = piSrcTmp[iSrcStride3]+piSrcTmp[iSrcStride4];
429     
430      iTmpA = (iTmp3 << 2) - iTmp2;
431     
432      iSum  = (   iTmp1          << 2 )
433            + (   iTmpA          << 3 )
434            + (   iTmpA          << 1 )
435            -    iTmp0 -  iTmp2;       
436     
437      piDst[x * iDstStep] = iSum;
438      piSrcTmp += iSrcStep;
439    }
440    piSrc += iSrcStride;
441    piDst += iDstStride;
442  }
443  return;
444}
445
446template<UInt bitDepth>
447__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterHalfVer (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
448{
449  Pel*  piDst = rpiDst;
450  Int   iSum;
451  Pel*  piSrcTmp;
452 
453  Int iSrcStride2 = iSrcStride*2;
454  Int iSrcStride3 = iSrcStride*3;
455  Int iSrcStride4 = iSrcStride*4;
456  Int iSrcStride5 = iSrcStride*5;
457  Int iSrcStride6 = iSrcStride*6;
458  Int iSrcStride7 = iSrcStride*7;
459
460  Int  iTmp0, iTmp1, iTmp2, iTmp3, iTmpA;
461  for ( Int y = iHeight; y != 0; y-- )
462  {
463    piSrcTmp = &piSrc[ -3*iSrcStride ];
464    for ( Int x = 0; x < iWidth; x++ )
465    {
466      // { -1,4,-11,40,40,-11,4,-1   }
467      iTmp0 = piSrcTmp[          0]+piSrcTmp[iSrcStride7];
468      iTmp1 = piSrcTmp[iSrcStride ]+piSrcTmp[iSrcStride6];
469      iTmp2 = piSrcTmp[iSrcStride2]+piSrcTmp[iSrcStride5];
470      iTmp3 = piSrcTmp[iSrcStride3]+piSrcTmp[iSrcStride4];
471     
472      iTmpA = (iTmp3 << 2) - iTmp2;
473     
474      iSum  = (   iTmp1          << 2 )
475            + (   iTmpA          << 3 )
476            + (   iTmpA          << 1 )
477            -    iTmp0 -  iTmp2;       
478     
479      piDst[x * iDstStep] = xClipY( (iSum +  32) >>  6 );
480      piSrcTmp += iSrcStep;
481    }
482    piSrc += iSrcStride;
483    piDst += iDstStride;
484  }
485  return;
486}
487
488template<UInt bitDepth>
489__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst)
490{
491  Int*  piDst = rpiDst;
492  Int   iSum;
493  Pel*  piSrcTmp;
494  Int iSrcStride2 = iSrcStride*2;
495  Int iSrcStride3 = iSrcStride*3;
496  Int iSrcStride4 = iSrcStride*4;
497  Int iSrcStride5 = iSrcStride*5;
498  Int iSrcStride6 = iSrcStride*6;
499  Int iSrcStride7 = iSrcStride*7;
500
501  Int  iTmp1, iTmp2;
502  for ( Int y = iHeight; y != 0; y-- )
503  {
504    piSrcTmp = &piSrc[ -3*iSrcStride ];
505    for ( Int x = 0; x < iWidth; x++ )
506    {
507      // {-1,   4,  -10,  57,   19,  -7,   3,   -1  },
508     
509      iTmp1 = piSrcTmp[iSrcStride3] + piSrcTmp[iSrcStride5];
510      iTmp2 = piSrcTmp[iSrcStride6] + piSrcTmp[iSrcStride4];
511     
512      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]
513            - ( ( piSrcTmp[iSrcStride2] - iTmp2 ) << 1 )
514            + (  piSrcTmp[iSrcStride]             << 2 )
515            - ( ( piSrcTmp[iSrcStride2] + iTmp1 ) << 3 )
516            + (   piSrcTmp[iSrcStride4]           << 4 )
517            + (   piSrcTmp[iSrcStride3]           << 6 );
518     
519      piDst[x * iDstStep] = iSum;
520      piSrcTmp += iSrcStep;
521    }
522    piSrc += iSrcStride;
523    piDst += iDstStride;
524  }
525  return;
526}
527
528template<UInt bitDepth>
529__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter0Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
530{
531  Pel*  piDst = rpiDst;
532  Int   iSum;
533  Pel*  piSrcTmp;
534 
535  Int iSrcStride2 = iSrcStride*2;
536  Int iSrcStride3 = iSrcStride*3;
537  Int iSrcStride4 = iSrcStride*4;
538  Int iSrcStride5 = iSrcStride*5;
539  Int iSrcStride6 = iSrcStride*6;
540  Int iSrcStride7 = iSrcStride*7;
541
542  Int  iTmp1, iTmp2;
543  for ( Int y = iHeight; y != 0; y-- )
544  {
545    piSrcTmp = &piSrc[ -3*iSrcStride ];
546    for ( Int x = 0; x < iWidth; x++ )
547    {
548      // {-1,   4,  -10,  57,   19,  -7,   3,   -1  },
549     
550      iTmp1 = piSrcTmp[iSrcStride3] + piSrcTmp[iSrcStride5];
551      iTmp2 = piSrcTmp[iSrcStride6] + piSrcTmp[iSrcStride4];
552     
553      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]
554            - ( ( piSrcTmp[iSrcStride2] - iTmp2 ) << 1 )
555            + (  piSrcTmp[iSrcStride]             << 2 )
556            - ( ( piSrcTmp[iSrcStride2] + iTmp1 ) << 3 )
557            + (   piSrcTmp[iSrcStride4]           << 4 );
558     
559      piDst[x * iDstStep] = xClipY( ((iSum +  32) >>  6) + piSrcTmp[iSrcStride3] );
560      piSrcTmp += iSrcStep;
561    }
562    piSrc += iSrcStride;
563    piDst += iDstStride;
564  }
565  return;
566}
567
568template<UInt bitDepth>
569__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Int*& rpiDst)
570{
571  Int*  piDst = rpiDst;
572  Int   iSum;
573  Pel*  piSrcTmp;
574  Int iSrcStride2 = iSrcStride*2;
575  Int iSrcStride3 = iSrcStride*3;
576  Int iSrcStride4 = iSrcStride*4;
577  Int iSrcStride5 = iSrcStride*5;
578  Int iSrcStride6 = iSrcStride*6;
579  Int iSrcStride7 = iSrcStride*7;
580
581  Int  iTmp1, iTmp2;
582
583  for ( Int y = iHeight; y != 0; y-- )
584  {
585    piSrcTmp = &piSrc[ -3*iSrcStride ];
586    for ( Int x = 0; x < iWidth; x++ )
587    {
588      /// {-1,   3,  -7,  19,   57,  -10,   4,   -1  },
589      iTmp1 = piSrcTmp[iSrcStride4] + piSrcTmp[iSrcStride2];
590      iTmp2 = piSrcTmp[iSrcStride ] + piSrcTmp[iSrcStride3];
591     
592      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]
593            - ( ( piSrcTmp[iSrcStride5] - iTmp2 ) << 1 )
594            + (   piSrcTmp[iSrcStride6]           << 2 )
595            - ( ( piSrcTmp[iSrcStride5] + iTmp1 ) << 3 )
596            + (   piSrcTmp[iSrcStride3]           << 4 )
597            + (   piSrcTmp[iSrcStride4]           << 6 );
598           
599      piDst[x * iDstStep] = iSum;
600      piSrcTmp += iSrcStep;
601    }
602    piSrc += iSrcStride;
603    piDst += iDstStride;
604  }
605  return;
606}
607
608template<UInt bitDepth>
609__inline Void TRenInterpFilter<bitDepth>::xCTI_FilterQuarter1Ver (Pel* piSrc, Int iSrcStride, Int iSrcStep, Int iWidth, Int iHeight, Int iDstStride, Int iDstStep, Pel*& rpiDst)
610{
611  Pel*  piDst = rpiDst;
612  Int   iSum;
613  Pel*  piSrcTmp;
614  Int iSrcStride2 = iSrcStride*2;
615  Int iSrcStride3 = iSrcStride*3;
616  Int iSrcStride4 = iSrcStride*4;
617  Int iSrcStride5 = iSrcStride*5;
618  Int iSrcStride6 = iSrcStride*6;
619  Int iSrcStride7 = iSrcStride*7;
620
621  Int  iTmp1, iTmp2;
622
623  for ( Int y = iHeight; y != 0; y-- )
624  {
625    piSrcTmp = &piSrc[ -3*iSrcStride ];
626    for ( Int x = 0; x < iWidth; x++ )
627    {
628      /// {-1,   3,  -7,  19,   57,  -10,   4,   -1  },
629      iTmp1 = piSrcTmp[iSrcStride4] + piSrcTmp[iSrcStride2];
630      iTmp2 = piSrcTmp[iSrcStride ] + piSrcTmp[iSrcStride3];
631     
632      iSum  =  iTmp1 + iTmp2 - piSrcTmp[0] - piSrcTmp[iSrcStride7]
633            - ( ( piSrcTmp[iSrcStride5] - iTmp2 ) << 1 )
634            + (   piSrcTmp[iSrcStride6]           << 2 )
635            - ( ( piSrcTmp[iSrcStride5] + iTmp1 ) << 3 )
636            + (   piSrcTmp[iSrcStride3]           << 4 );
637           
638      piDst[x * iDstStep] = xClipY( ((iSum +  32) >>  6) +  piSrcTmp[iSrcStride4] );
639      piSrcTmp += iSrcStep;
640    }
641    piSrc += iSrcStride;
642    piDst += iDstStride;
643  }
644  return;
645}
646
647// ------------------------------------------------------------------------------------------------
648// DCTIF filters for Chroma
649// ------------------------------------------------------------------------------------------------
650template<UInt bitDepth>
651__inline Void TRenInterpFilter<bitDepth>::xCTI_Filter2DVerC (Pel* piSrc, Int iSrcStride,  Int iWidth, Int iHeight, Int iDstStride,  Int*& rpiDst, Int iMV)
652{
653  Int*  piDst = rpiDst;
654  Int   iSum;
655  Pel*  piSrcTmp;
656
657  switch (iMV)
658  {
659  case 1:
660  { 
661      for ( Int y = iHeight; y != 0; y-- )
662      {
663        piSrcTmp = &piSrc[ -iSrcStride ];
664        for ( Int x = 0; x < iWidth; x++ )
665        {
666          iSum      = xCTI_Filter_VP04_C_OCT0( piSrcTmp, iSrcStride );
667          piDst[x ] = iSum;
668          piSrcTmp++;
669        }
670        piSrc += iSrcStride;
671        piDst += iDstStride;
672      }
673  }
674  break;
675  case 2:
676  { 
677      for ( Int y = iHeight; y != 0; y-- )
678      {
679        piSrcTmp = &piSrc[ -iSrcStride ];
680        for ( Int x = 0; x < iWidth; x++ )
681        {
682          iSum      = xCTI_Filter_VP04_C_QUA0( piSrcTmp, iSrcStride );
683          piDst[x ] = iSum;
684          piSrcTmp++;
685        }
686        piSrc += iSrcStride;
687        piDst += iDstStride;
688      }
689  }
690  break;
691  case 6: 
692  { 
693      for ( Int y = iHeight; y != 0; y-- )
694      {
695        piSrcTmp = &piSrc[ -iSrcStride ];
696        for ( Int x = 0; x < iWidth; x++ )
697        {
698          iSum      = xCTI_Filter_VP04_C_QUA1( piSrcTmp, iSrcStride );
699          piDst[x ] = iSum;
700          piSrcTmp++;
701        }
702        piSrc += iSrcStride;
703        piDst += iDstStride;
704      }
705  }
706  break;
707  case 3: 
708  { 
709      for ( Int y = iHeight; y != 0; y-- )
710      {
711        piSrcTmp = &piSrc[ -iSrcStride ];
712        for ( Int x = 0; x < iWidth; x++ )
713        {
714          iSum      = xCTI_Filter_VP04_C_OCT1( piSrcTmp, iSrcStride );
715          piDst[x ] = iSum;
716          piSrcTmp++;
717        }
718        piSrc += iSrcStride;
719        piDst += iDstStride;
720      }
721  }
722  break;
723  case 5:
724  { 
725      for ( Int y = iHeight; y != 0; y-- )
726      {
727        piSrcTmp = &piSrc[ -iSrcStride ];
728        for ( Int x = 0; x < iWidth; x++ )
729        {
730          iSum      = xCTI_Filter_VP04_C_OCT2( piSrcTmp, iSrcStride );
731          piDst[x ] = iSum;
732          piSrcTmp++;
733        }
734        piSrc += iSrcStride;
735        piDst += iDstStride;
736      }
737  }
738  break;
739  case 7:
740  { 
741      for ( Int y = iHeight; y != 0; y-- )
742      {
743        piSrcTmp = &piSrc[ -iSrcStride ];
744        for ( Int x = 0; x < iWidth; x++ )
745        {
746          iSum      = xCTI_Filter_VP04_C_OCT3( piSrcTmp, iSrcStride );
747          piDst[x ] = iSum;
748          piSrcTmp++;
749        }
750        piSrc += iSrcStride;
751        piDst += iDstStride;
752      }
753  }
754  break;
755  case 4: 
756  {
757
758      for ( Int y = iHeight; y != 0; y-- )
759      {
760        piSrcTmp = &piSrc[ -iSrcStride ];
761        for ( Int x = 0; x < iWidth; x++ )
762        {
763          iSum      = xCTI_Filter_VPS04_C_HAL( piSrcTmp, iSrcStride );
764          piDst[x ] = iSum;
765          piSrcTmp++;
766        }
767        piSrc += iSrcStride;
768        piDst += iDstStride;
769      }
770  }
771  break;
772  default:
773    assert( 0 );
774  }
775  return;
776}
777
778template<UInt bitDepth>
779__inline Void TRenInterpFilter<bitDepth>::xCTI_Filter2DHorC(Int* piSrc, Int iSrcStride,  Int iWidth, Int iHeight, Int iDstStride,  Pel*& rpiDst, Int iMV)
780{
781  Pel*  piDst    = rpiDst;
782  Int   iSum;
783  Int*  piSrcTmp;
784
785  switch (iMV)
786  {
787  case 1:
788  { 
789      for ( Int y = iHeight; y != 0; y-- )
790      {
791        piSrcTmp = &piSrc[ -1 ];
792        for ( Int x = 0; x < iWidth; x++ )
793        {
794          iSum         = xCTI_Filter_VI04_C_OCT0( piSrcTmp, 1 );
795          piDst   [x ] = xClipC ((iSum +  2048) >>  12 );
796          piSrcTmp++;
797        }
798        piSrc += iSrcStride;
799        piDst += iDstStride;
800      }
801  }
802  break;
803  case 2:
804  { 
805      for ( Int y = iHeight; y != 0; y-- )
806      {
807        piSrcTmp = &piSrc[ -1 ];
808        for ( Int x = 0; x < iWidth; x++ )
809        {
810          iSum         = xCTI_Filter_VI04_C_QUA0( piSrcTmp, 1 );
811          piDst   [x ] = xClipC ((iSum +  2048) >>  12 );
812          piSrcTmp++;
813        }
814        piSrc += iSrcStride;
815        piDst += iDstStride;
816      }
817  }
818  break;
819  case 6:
820  { 
821      for ( Int y = iHeight; y != 0; y-- )
822      {
823        piSrcTmp = &piSrc[ -1 ];
824        for ( Int x = 0; x < iWidth; x++ )
825        {
826          iSum         = xCTI_Filter_VI04_C_QUA1( piSrcTmp, 1 );
827          piDst   [x ] = xClipC ((iSum +  2048) >>  12 );
828          piSrcTmp++;
829        }
830        piSrc += iSrcStride;
831        piDst += iDstStride;
832      }
833  }
834  break;
835  case 3:
836  { 
837      for ( Int y = iHeight; y != 0; y-- )
838      {
839        piSrcTmp = &piSrc[ -1 ];
840        for ( Int x = 0; x < iWidth; x++ )
841        {
842          iSum         = xCTI_Filter_VI04_C_OCT1( piSrcTmp, 1 );
843          piDst   [x ] = xClipC ((iSum +  2048) >>  12 );
844          piSrcTmp++;
845        }
846        piSrc += iSrcStride;
847        piDst += iDstStride;
848      }
849  }
850  break;
851  case 5:
852  { 
853      for ( Int y = iHeight; y != 0; y-- )
854      {
855        piSrcTmp = &piSrc[ -1 ];
856        for ( Int x = 0; x < iWidth; x++ )
857        {
858          iSum         = xCTI_Filter_VI04_C_OCT2( piSrcTmp, 1 );
859          piDst   [x ] = xClipC ((iSum +  2048) >>  12 );
860          piSrcTmp++;
861        }
862        piSrc += iSrcStride;
863        piDst += iDstStride;
864      }
865  }
866  break;
867  case 7:
868  { 
869      for ( Int y = iHeight; y != 0; y-- )
870      {
871        piSrcTmp = &piSrc[ -1 ];
872        for ( Int x = 0; x < iWidth; x++ )
873        {
874          iSum         = xCTI_Filter_VI04_C_OCT3( piSrcTmp, 1 );
875          piDst   [x ] = xClipC ((iSum +  2048) >>  12 );
876          piSrcTmp++;
877        }
878        piSrc += iSrcStride;
879        piDst += iDstStride;
880      }
881  }
882  break;
883  case 4:
884  {
885      for ( Int y = iHeight; y != 0; y-- )
886      {
887        piSrcTmp = &piSrc[ -1 ];
888        for ( Int x = 0; x < iWidth; x++ )
889        {
890          iSum      = xCTI_Filter_VIS04_C_HAL( piSrcTmp, 1 );
891          piDst   [x ] = xClipC ((iSum +  2048) >>  12 );
892          piSrcTmp++;
893        }
894        piSrc += iSrcStride;
895        piDst += iDstStride;
896      }
897  }
898  break;
899  default:
900    assert( 0 );
901  }
902
903  return;
904}
905
906template<UInt bitDepth>
907__inline Void TRenInterpFilter<bitDepth>::xCTI_Filter1DVerC (Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride,  Pel*& rpiDst, Int iMV)
908{
909  Pel*  piDst = rpiDst;
910  Int   iSum;
911  Pel*  piSrcTmp;
912
913  switch (iMV)
914  {
915  case 1:
916  { 
917      for ( Int y = iHeight; y != 0; y-- )
918      {
919        piSrcTmp = &piSrc[ -iSrcStride ];
920        for ( Int x = 0; x < iWidth; x++ )
921        {
922          iSum      = xCTI_Filter_VP04_C_OCT0( piSrcTmp,  iSrcStride );
923          piDst[x ] = xClipC ((iSum +  32) >>  6 );
924          piSrcTmp++;
925        }
926        piSrc += iSrcStride;
927        piDst += iDstStride;
928      }
929  }
930  break;
931  case 2:
932  { 
933      for ( Int y = iHeight; y != 0; y-- )
934      {
935        piSrcTmp = &piSrc[ -iSrcStride ];
936        for ( Int x = 0; x < iWidth; x++ )
937        {
938          iSum      = xCTI_Filter_VP04_C_QUA0( piSrcTmp,  iSrcStride );
939          piDst[x ] = xClipC ((iSum +  32) >>  6 );
940          piSrcTmp++;
941        }
942        piSrc += iSrcStride;
943        piDst += iDstStride;
944      }
945  }
946  break;
947  case 6:
948  { 
949      for ( Int y = iHeight; y != 0; y-- )
950      {
951        piSrcTmp = &piSrc[ -iSrcStride ];
952        for ( Int x = 0; x < iWidth; x++ )
953        {
954          iSum      = xCTI_Filter_VP04_C_QUA1( piSrcTmp,  iSrcStride );
955          piDst[x ] = xClipC ((iSum +  32) >>  6 );
956          piSrcTmp++;
957        }
958        piSrc += iSrcStride;
959        piDst += iDstStride;
960      }
961  }
962  break;
963  case 3:
964  { 
965      for ( Int y = iHeight; y != 0; y-- )
966      {
967        piSrcTmp = &piSrc[ -iSrcStride ];
968        for ( Int x = 0; x < iWidth; x++ )
969        {
970          iSum      = xCTI_Filter_VP04_C_OCT1( piSrcTmp,  iSrcStride );
971          piDst[x ] = xClipC ((iSum +  32) >>  6 );
972          piSrcTmp++;
973        }
974        piSrc += iSrcStride;
975        piDst += iDstStride;
976      }
977  }
978  break;
979  case 5:
980  { 
981      for ( Int y = iHeight; y != 0; y-- )
982      {
983        piSrcTmp = &piSrc[ -iSrcStride ];
984        for ( Int x = 0; x < iWidth; x++ )
985        {
986          iSum      = xCTI_Filter_VP04_C_OCT2( piSrcTmp,  iSrcStride );
987          piDst[x ] = xClipC ((iSum +  32) >>  6 );
988          piSrcTmp++;
989        }
990        piSrc += iSrcStride;
991        piDst += iDstStride;
992      }
993  }
994  break;
995  case 7:
996  { 
997      for ( Int y = iHeight; y != 0; y-- )
998      {
999        piSrcTmp = &piSrc[ -iSrcStride ];
1000        for ( Int x = 0; x < iWidth; x++ )
1001        {
1002          iSum      = xCTI_Filter_VP04_C_OCT3( piSrcTmp,  iSrcStride );
1003          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1004          piSrcTmp++;
1005        }
1006        piSrc += iSrcStride;
1007        piDst += iDstStride;
1008      }
1009  }
1010  break;
1011  case 4:
1012  {
1013      for ( Int y = iHeight; y != 0; y-- )
1014      {
1015        piSrcTmp = &piSrc[-iSrcStride ];
1016        for ( Int x = 0; x < iWidth; x++ )
1017        {
1018          iSum      = xCTI_Filter_VPS04_C_HAL( piSrcTmp, iSrcStride );
1019          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1020          piSrcTmp++;
1021        }
1022        piSrc += iSrcStride;
1023        piDst += iDstStride;
1024      }
1025  }
1026  break;
1027  default:
1028    assert( 0 );
1029  }
1030  return;
1031}
1032
1033template<UInt bitDepth>
1034__inline Void TRenInterpFilter<bitDepth>::xCTI_Filter1DHorC(Pel* piSrc, Int iSrcStride, Int iWidth, Int iHeight, Int iDstStride, Pel*& rpiDst, Int iMV)
1035{
1036  Pel*  piDst    = rpiDst;
1037  Int   iSum;
1038  Pel*  piSrcTmp;
1039
1040  switch (iMV)
1041  {
1042  case 1:
1043  { 
1044      for ( Int y = iHeight; y != 0; y-- )
1045      {
1046        piSrcTmp = &piSrc[ -1 ];
1047        for ( Int x = 0; x < iWidth; x++ )
1048        {
1049          iSum         = xCTI_Filter_VP04_C_OCT0( piSrcTmp,  1 );
1050          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1051          piSrcTmp++;
1052        }
1053        piSrc += iSrcStride;
1054        piDst += iDstStride;
1055      }
1056  }
1057  break;
1058  case 2:
1059  { 
1060      for ( Int y = iHeight; y != 0; y-- )
1061      {
1062        piSrcTmp = &piSrc[ -1 ];
1063        for ( Int x = 0; x < iWidth; x++ )
1064        {
1065          iSum         = xCTI_Filter_VP04_C_QUA0( piSrcTmp,  1 );
1066          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1067          piSrcTmp++;
1068        }
1069        piSrc += iSrcStride;
1070        piDst += iDstStride;
1071      }
1072  }
1073  break;
1074  case 6:
1075  { 
1076      for ( Int y = iHeight; y != 0; y-- )
1077      {
1078        piSrcTmp = &piSrc[ -1 ];
1079        for ( Int x = 0; x < iWidth; x++ )
1080        {
1081          iSum         = xCTI_Filter_VP04_C_QUA1( piSrcTmp,  1 );
1082          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1083          piSrcTmp++;
1084        }
1085        piSrc += iSrcStride;
1086        piDst += iDstStride;
1087      }
1088  }
1089  break;
1090  case 3:
1091  { 
1092      for ( Int y = iHeight; y != 0; y-- )
1093      {
1094        piSrcTmp = &piSrc[ -1 ];
1095        for ( Int x = 0; x < iWidth; x++ )
1096        {
1097          iSum         = xCTI_Filter_VP04_C_OCT1( piSrcTmp,  1 );
1098          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1099          piSrcTmp++;
1100        }
1101        piSrc += iSrcStride;
1102        piDst += iDstStride;
1103      }
1104  }
1105  break;
1106  case 5:
1107  { 
1108      for ( Int y = iHeight; y != 0; y-- )
1109      {
1110        piSrcTmp = &piSrc[ -1 ];
1111        for ( Int x = 0; x < iWidth; x++ )
1112        {
1113          iSum         = xCTI_Filter_VP04_C_OCT2( piSrcTmp,  1 );
1114          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1115          piSrcTmp++;
1116        }
1117        piSrc += iSrcStride;
1118        piDst += iDstStride;
1119      }
1120  }
1121  break;
1122  case 7:
1123  { 
1124      for ( Int y = iHeight; y != 0; y-- )
1125      {
1126        piSrcTmp = &piSrc[ -1 ];
1127        for ( Int x = 0; x < iWidth; x++ )
1128        {
1129          iSum         = xCTI_Filter_VP04_C_OCT3( piSrcTmp,  1 );
1130          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1131          piSrcTmp++;
1132        }
1133        piSrc += iSrcStride;
1134        piDst += iDstStride;
1135      }
1136  }
1137  break;
1138  case 4:
1139  {
1140      for ( Int y = iHeight; y != 0; y-- )
1141      {
1142        piSrcTmp = &piSrc[ -1 ];
1143        for ( Int x = 0; x < iWidth; x++ )
1144        {
1145          iSum         = xCTI_Filter_VPS04_C_HAL( piSrcTmp,  1 );
1146          piDst[x ] = xClipC ((iSum +  32) >>  6 );
1147          piSrcTmp++;
1148        }
1149        piSrc += iSrcStride;
1150        piDst += iDstStride;
1151      }
1152  }
1153  break;
1154  default:
1155    assert( 0 );
1156 }
1157  return;
1158}
1159
1160template<UInt bitDepth>
1161__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT0( Pel* pSrc,  Int iStride )
1162{// {  -3,  60,   8,   -1,} // 1/8
1163  Int iSum, iIdx = 0;
1164
1165  Int p0 = pSrc[0];     iIdx+= iStride;
1166  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1167  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1168  Int p3 = pSrc[iIdx]; 
1169  iSum = (p1<<6) -((p1+p0)<<2) +p0 +(p2<<3) -p3;
1170
1171  return iSum;
1172}
1173template<UInt bitDepth>
1174__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT0( Int* pSrc, Int iStride )
1175{ // {  -3,  60,   8,   -1,} //1/8
1176  Int iSum, iIdx = 0;
1177
1178  Int p0 = pSrc[0];     iIdx+= iStride;
1179  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1180  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1181  Int p3 = pSrc[iIdx]; 
1182  iSum = (p1<<6) -((p1+p0)<<2) +p0 +(p2<<3) -p3;
1183
1184  return iSum;
1185}
1186template<UInt bitDepth>
1187__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_QUA0( Pel* pSrc,  Int iStride )
1188{// {  -4,  54,  16,   -2,} // 1/4
1189  Int iSum, iIdx = 0;
1190
1191  Int p0 = pSrc[0];     iIdx+= iStride;
1192  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1193  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1194  Int p3 = pSrc[iIdx]; 
1195  iSum = (p1 << 6) + (p2 << 4) - (p1 << 3) - ( p0 << 2) - ((p1 + p3) << 1);
1196
1197  return iSum;
1198}
1199
1200template<UInt bitDepth>
1201__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_QUA0( Int* pSrc, Int iStride )
1202{ // {  -4,  54,  16,   -2,} //1/4
1203  Int iSum, iIdx = 0;
1204
1205  Int p0 = pSrc[0];     iIdx+= iStride;
1206  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1207  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1208  Int p3 = pSrc[iIdx]; 
1209  iSum = (p1 << 6) + (p2 << 4) - (p1 << 3) - ( p0 << 2) - ((p1 + p3) << 1);
1210
1211  return iSum;
1212}
1213template<UInt bitDepth>
1214__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_QUA1( Pel* pSrc,  Int iStride )
1215{// {  -2,  16,  54,   -4,}// 3/4
1216  Int iSum, iIdx = 0;
1217
1218  Int p0 = pSrc[0];     iIdx+= iStride;
1219  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1220  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1221  Int p3 = pSrc[iIdx]; 
1222  iSum = (p2 << 6) + (p1 << 4) - (p2 << 3) - ( p3 << 2) - ((p2 + p0) << 1);
1223
1224  return iSum;
1225}
1226
1227template<UInt bitDepth>
1228__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_QUA1( Int* pSrc, Int iStride )
1229{// {  -2,  16,  54,   -4,}// 3/4
1230  Int iSum, iIdx = 0;
1231
1232  Int p0 = pSrc[0];     iIdx+= iStride;
1233  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1234  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1235  Int p3 = pSrc[iIdx]; 
1236  iSum = (p2 << 6) + (p1 << 4) - (p2 << 3) - ( p3 << 2) - ((p2 + p0) << 1);
1237
1238  return iSum;
1239}
1240
1241template<UInt bitDepth>
1242__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT1( Pel* pSrc,  Int iStride )
1243{// {  -5,  46,  27,   -4,} // 3/8
1244  Int iSum, iIdx = 0;
1245
1246  Int p0 = pSrc[0];     iIdx+= iStride;
1247  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1248  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1249  Int p3 = pSrc[iIdx]; 
1250  Int t = p0 + p2;
1251  iSum = ((p1 + p2) << 5) + (p1 << 4) - ( (t + p3) << 2) - ( p1 << 1) - t;
1252
1253  return iSum;
1254}
1255
1256template<UInt bitDepth>
1257__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT1( Int* pSrc, Int iStride )
1258{ // {  -5,  46,  27,   -4,} //3/8
1259  Int iSum, iIdx = 0;
1260
1261  Int p0 = pSrc[0];     iIdx+= iStride;
1262  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1263  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1264  Int p3 = pSrc[iIdx]; 
1265  Int t = p0 + p2;
1266  iSum = ((p1 + p2) << 5) + (p1 << 4) - ( (t + p3) << 2) - ( p1 << 1) - t;
1267
1268  return iSum;
1269}
1270
1271template<UInt bitDepth>
1272__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VPS04_C_HAL( Pel* pSrc, Int iStride )
1273{
1274  // {  -4,  36,  36,   -4,}, // 1/2
1275  Int iSum;
1276  Int iTemp0 = pSrc[iStride*1]+pSrc[iStride*2];
1277  Int iTemp1 = pSrc[        0]+pSrc[iStride*3];
1278
1279  iSum  = ((iTemp0<<3) + iTemp0 -iTemp1)<<2;
1280
1281  return iSum;
1282}
1283
1284template<UInt bitDepth>
1285__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VIS04_C_HAL( Int* pSrc, Int iStride )
1286{
1287  // {  -4,  36,  36,   -4,}, //1/2
1288  Int iSum;
1289  Int iTemp0 = pSrc[iStride*1]+pSrc[iStride*2];
1290  Int iTemp1 = pSrc[        0]+pSrc[iStride*3];
1291
1292  iSum  = ((iTemp0<<3) + iTemp0 -iTemp1)<<2;
1293
1294  return iSum;
1295}
1296
1297template<UInt bitDepth>
1298__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT2( Pel* pSrc,  Int iStride )
1299{// {  -4,  27,  46,   -5,}, // 5/8
1300  Int iSum, iIdx = 0;
1301
1302  Int p0 = pSrc[0];     iIdx+= iStride;
1303  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1304  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1305  Int p3 = pSrc[iIdx]; 
1306  Int t = p1 + p3;
1307  iSum = ((p1 + p2) << 5) + (p2 << 4) - ( (t + p0) << 2) - ( p2 << 1) - t;
1308
1309  return iSum;
1310}
1311
1312template<UInt bitDepth>
1313__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT2( Int* pSrc, Int iStride )
1314{ // {  -4,  27,  46,   -5,}, // 5/8
1315  Int iSum, iIdx = 0;
1316
1317  Int p0 = pSrc[0];     iIdx+= iStride;
1318  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1319  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1320  Int p3 = pSrc[iIdx]; 
1321  Int t = p1 + p3;
1322  iSum = ((p1 + p2) << 5) + (p2 << 4) - ( (t + p0) << 2) - ( p2 << 1) - t;
1323
1324  return iSum;
1325}
1326
1327template<UInt bitDepth>
1328__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VP04_C_OCT3( Pel* pSrc,  Int iStride )
1329{// {  -1,   8,  60,   -3,} // 7/8
1330  Int iSum, iIdx = 0;
1331
1332  Int p0 = pSrc[0];     iIdx+= iStride;
1333  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1334  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1335  Int p3 = pSrc[iIdx]; 
1336  iSum = (p2<<6) -((p2+p3)<<2) +p3 +(p1<<3) -p0;
1337
1338  return iSum;
1339}
1340
1341template<UInt bitDepth>
1342__inline Int TRenInterpFilter<bitDepth>::xCTI_Filter_VI04_C_OCT3( Int* pSrc, Int iStride )
1343{ // {  -1,   8,  60,   -3,} // 7/8
1344  Int iSum, iIdx = 0;
1345
1346  Int p0 = pSrc[0];     iIdx+= iStride;
1347  Int p1 = pSrc[iIdx];  iIdx+= iStride;
1348  Int p2 = pSrc[iIdx];  iIdx+= iStride;
1349  Int p3 = pSrc[iIdx]; 
1350  iSum = (p2<<6) -((p2+p3)<<2) +p3 +(p1<<3) -p0;
1351
1352  return iSum;
1353}
1354
1355#endif // NH_3D
1356#endif // __TRENINTERP__
Note: See TracBrowser for help on using the repository browser.