source: 3DVCSoftware/branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComWedgelet.h @ 272

Last change on this file since 272 was 56, checked in by hschwarz, 13 years ago

updated trunk (move to HM6.1)

  • Property svn:eol-style set to native
File size: 8.3 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-2011, ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35
36#ifndef __TCOMWEDGELET__
37#define __TCOMWEDGELET__
38
39// Include files
40#include <assert.h>
41#include "CommonDef.h"
42
43#include <vector>
44
45enum WedgeResolution
46{
47  DOUBLE_PEL,
48  FULL_PEL,
49  HALF_PEL
50};
51
52// ====================================================================================================================
53// Class definition TComWedgelet
54// ====================================================================================================================
55class TComWedgelet
56{
57private:
58  UChar           m_uhXs;                       // line start X pos
59  UChar           m_uhYs;                       // line start Y pos
60  UChar           m_uhXe;                       // line end   X pos
61  UChar           m_uhYe;                       // line end   Y pos
62  UChar           m_uhOri;                      // orientation index
63  WedgeResolution m_eWedgeRes;                  // start/end pos resolution
64
65  UInt  m_uiWidth;
66  UInt  m_uiHeight;
67
68  Bool* m_pbPattern;
69
70  Void  xGenerateWedgePattern();
71  Void  xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride );
72
73public:
74  TComWedgelet( UInt uiWidth, UInt uiHeight );
75  TComWedgelet( const TComWedgelet &rcWedge );
76  virtual ~TComWedgelet();
77
78  Void  create ( UInt iWidth, UInt iHeight );   ///< create  wedgelet pattern
79  Void  destroy();                              ///< destroy wedgelet pattern
80  Void  clear  ();                              ///< clear   wedgelet pattern
81
82  UInt            getWidth   () { return m_uiWidth; }
83  UInt            getStride  () { return m_uiWidth; }
84  UInt            getHeight  () { return m_uiHeight; }
85  WedgeResolution getWedgeRes() { return m_eWedgeRes; }
86  Bool*           getPattern () { return m_pbPattern; }
87  UChar           getStartX  () { return m_uhXs; }
88  UChar           getStartY  () { return m_uhYs; }
89  UChar           getEndX    () { return m_uhXe; }
90  UChar           getEndY    () { return m_uhYe; }
91  UChar           getOri     () { return m_uhOri; }
92
93  Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes );
94
95  Bool  checkNotPlain();
96  Bool  checkIdentical( Bool* pbRefPattern );
97  Bool  checkInvIdentical( Bool* pbRefPattern );
98
99#if HHI_DMM_WEDGE_INTRA
100  Bool  checkPredDirAbovePossible( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffsett );
101  Bool  checkPredDirLeftPossible ( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffsett );
102
103  Void  getPredDirStartEndAbove( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd );
104  Void  getPredDirStartEndLeft ( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd );
105#endif
106};  // END CLASS DEFINITION TComWedgelet
107
108// type definition wedgelet pattern list
109typedef std::vector<TComWedgelet> WedgeList;
110
111// ====================================================================================================================
112// Class definition TComWedgeRef
113// ====================================================================================================================
114class TComWedgeRef
115{
116private:
117  UChar           m_uhXs;                       // line start X pos
118  UChar           m_uhYs;                       // line start Y pos
119  UChar           m_uhXe;                       // line end   X pos
120  UChar           m_uhYe;                       // line end   Y pos
121  UInt            m_uiRefIdx;                   // index of corresponding pattern of TComWedgelet object in wedge list
122
123public:
124  TComWedgeRef() {}
125  virtual ~TComWedgeRef() {}
126
127  UChar           getStartX  () { return m_uhXs; }
128  UChar           getStartY  () { return m_uhYs; }
129  UChar           getEndX    () { return m_uhXe; }
130  UChar           getEndY    () { return m_uhYe; }
131  UInt            getRefIdx  () { return m_uiRefIdx; }
132
133  Void  setWedgeRef( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UInt uiRefIdx ) { m_uhXs = uhXs; m_uhYs = uhYs; m_uhXe = uhXe; m_uhYe = uhYe; m_uiRefIdx = uiRefIdx; }
134};  // END CLASS DEFINITION TComWedgeRef
135
136// type definition wedgelet reference list
137typedef std::vector<TComWedgeRef> WedgeRefList;
138
139#if HHI_DMM_PRED_TEX
140enum WedgeDist
141{
142  WedgeDist_SAD  = 0,
143  WedgeDist_SSE  = 4,
144};
145
146class WedgeDistParam;
147typedef UInt (*FpWedgeDistFunc) (WedgeDistParam*);
148
149/// distortion parameter class
150class WedgeDistParam
151{
152public:
153  Pel*  pOrg;
154  Pel*  pCur;
155  Int   iStrideOrg;
156  Int   iStrideCur;
157  Int   iRows;
158  Int   iCols;
159  Int   iStep;
160  FpWedgeDistFunc DistFunc;
161  Int   iSubShift;
162
163  WedgeDistParam()
164  {
165    pOrg = NULL;
166    pCur = NULL;
167    iStrideOrg = 0;
168    iStrideCur = 0;
169    iRows = 0;
170    iCols = 0;
171    iStep = 1;
172    DistFunc = NULL;
173    iSubShift = 0;
174  }
175};
176
177// ====================================================================================================================
178// Class definition TComWedgeDist
179// ====================================================================================================================
180class TComWedgeDist
181{
182private:
183  Int                     m_iBlkWidth;
184  Int                     m_iBlkHeight;
185  FpWedgeDistFunc         m_afpDistortFunc[8];
186
187public:
188  TComWedgeDist();
189  virtual ~TComWedgeDist();
190
191  Void init();
192  Void setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, WedgeDistParam& rcDistParam );
193  UInt getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist = WedgeDist_SAD );
194
195private:
196  static UInt xGetSAD4          ( WedgeDistParam* pcDtParam );
197  static UInt xGetSAD8          ( WedgeDistParam* pcDtParam );
198  static UInt xGetSAD16         ( WedgeDistParam* pcDtParam );
199  static UInt xGetSAD32         ( WedgeDistParam* pcDtParam );
200  //static UInt xGetSAD64         ( WedgeDistParam* pcDtParam );
201
202  static UInt xGetSSE4          ( WedgeDistParam* pcDtParam );
203  static UInt xGetSSE8          ( WedgeDistParam* pcDtParam );
204  static UInt xGetSSE16         ( WedgeDistParam* pcDtParam );
205  static UInt xGetSSE32         ( WedgeDistParam* pcDtParam );
206  //static UInt xGetSSE64         ( WedgeDistParam* pcDtParam );
207
208};// END CLASS DEFINITION TComWedgeDist
209#endif
210
211// ====================================================================================================================
212// Function definition roftoi (mathematically correct rounding of float to int)
213// ====================================================================================================================
214__inline Int roftoi( Double value )
215{
216  (value < -0.5) ? (value -= 0.5) : (value += 0.5);
217  return ( (Int)value );
218}
219#endif // __TCOMWEDGELET__
Note: See TracBrowser for help on using the repository browser.