source: 3DVCSoftware/branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComWedgelet.h @ 321

Last change on this file since 321 was 296, checked in by tech, 12 years ago

Reintegrated branch 5.1-dev0 rev. 295.

  • Property svn:eol-style set to native
File size: 9.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-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#if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA
53#define NUM_WEDGE_REFINES 8
54#define NO_IDX MAX_UINT
55#endif
56
57// ====================================================================================================================
58// Class definition TComWedgelet
59// ====================================================================================================================
60class TComWedgelet
61{
62private:
63  UChar           m_uhXs;                       // line start X pos
64  UChar           m_uhYs;                       // line start Y pos
65  UChar           m_uhXe;                       // line end   X pos
66  UChar           m_uhYe;                       // line end   Y pos
67  UChar           m_uhOri;                      // orientation index
68  WedgeResolution m_eWedgeRes;                  // start/end pos resolution
69#if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA
70  Bool            m_bIsCoarse; 
71  UInt            m_uiAng;
72#endif
73
74  UInt  m_uiWidth;
75  UInt  m_uiHeight;
76
77  Bool* m_pbPattern;
78
79  Void  xGenerateWedgePattern();
80  Void  xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride );
81
82public:
83  TComWedgelet( UInt uiWidth, UInt uiHeight );
84  TComWedgelet( const TComWedgelet &rcWedge );
85  virtual ~TComWedgelet();
86
87  Void  create ( UInt iWidth, UInt iHeight );   ///< create  wedgelet pattern
88  Void  destroy();                              ///< destroy wedgelet pattern
89  Void  clear  ();                              ///< clear   wedgelet pattern
90
91  UInt            getWidth   () { return m_uiWidth; }
92  UInt            getStride  () { return m_uiWidth; }
93  UInt            getHeight  () { return m_uiHeight; }
94  WedgeResolution getWedgeRes() { return m_eWedgeRes; }
95  Bool*           getPattern () { return m_pbPattern; }
96  UChar           getStartX  () { return m_uhXs; }
97  UChar           getStartY  () { return m_uhYs; }
98  UChar           getEndX    () { return m_uhXe; }
99  UChar           getEndY    () { return m_uhYe; }
100  UChar           getOri     () { return m_uhOri; }
101#if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA
102  Bool            getIsCoarse() { return m_bIsCoarse; }
103  UInt            getAng     () { return m_uiAng; }
104  Void            findClosetAngle();
105
106  Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false );
107#else
108  Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes );
109#endif
110
111  Bool  checkNotPlain();
112  Bool  checkIdentical( Bool* pbRefPattern );
113  Bool  checkInvIdentical( Bool* pbRefPattern );
114
115#if HHI_DMM_WEDGE_INTRA
116  Bool  checkPredDirAbovePossible( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffsett );
117  Bool  checkPredDirLeftPossible ( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffsett );
118
119  Void  getPredDirStartEndAbove( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd );
120  Void  getPredDirStartEndLeft ( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd );
121#endif
122};  // END CLASS DEFINITION TComWedgelet
123
124// type definition wedgelet pattern list
125typedef std::vector<TComWedgelet> WedgeList;
126
127// ====================================================================================================================
128// Class definition TComWedgeRef
129// ====================================================================================================================
130class TComWedgeRef
131{
132private:
133  UChar           m_uhXs;                       // line start X pos
134  UChar           m_uhYs;                       // line start Y pos
135  UChar           m_uhXe;                       // line end   X pos
136  UChar           m_uhYe;                       // line end   Y pos
137  UInt            m_uiRefIdx;                   // index of corresponding pattern of TComWedgelet object in wedge list
138
139public:
140  TComWedgeRef() {}
141  virtual ~TComWedgeRef() {}
142
143  UChar           getStartX  () { return m_uhXs; }
144  UChar           getStartY  () { return m_uhYs; }
145  UChar           getEndX    () { return m_uhXe; }
146  UChar           getEndY    () { return m_uhYe; }
147  UInt            getRefIdx  () { return m_uiRefIdx; }
148
149  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; }
150};  // END CLASS DEFINITION TComWedgeRef
151
152// type definition wedgelet reference list
153typedef std::vector<TComWedgeRef> WedgeRefList;
154
155#if HHI_DMM_PRED_TEX || HHI_DMM_WEDGE_INTRA
156// ====================================================================================================================
157// Class definition TComWedgeNode
158// ====================================================================================================================
159class TComWedgeNode
160{
161private:
162  UInt            m_uiPatternIdx;
163  UInt            m_uiRefineIdx[NUM_WEDGE_REFINES];
164
165public:
166  TComWedgeNode();
167  virtual ~TComWedgeNode() {}
168
169  UInt            getPatternIdx();
170  UInt            getRefineIdx ( UInt uiPos );
171
172  Void            setPatternIdx( UInt uiIdx );
173  Void            setRefineIdx ( UInt uiIdx, UInt uiPos );
174};  // END CLASS DEFINITION TComWedgeNode
175
176// type definition wedgelet node list
177typedef std::vector<TComWedgeNode> WedgeNodeList;
178#endif
179
180#if HHI_DMM_PRED_TEX
181enum WedgeDist
182{
183  WedgeDist_SAD  = 0,
184  WedgeDist_SSE  = 4,
185};
186
187class WedgeDistParam;
188typedef UInt (*FpWedgeDistFunc) (WedgeDistParam*);
189
190/// distortion parameter class
191class WedgeDistParam
192{
193public:
194  Pel*  pOrg;
195  Pel*  pCur;
196  Int   iStrideOrg;
197  Int   iStrideCur;
198  Int   iRows;
199  Int   iCols;
200  Int   iStep;
201  FpWedgeDistFunc DistFunc;
202  Int   iSubShift;
203
204  WedgeDistParam()
205  {
206    pOrg = NULL;
207    pCur = NULL;
208    iStrideOrg = 0;
209    iStrideCur = 0;
210    iRows = 0;
211    iCols = 0;
212    iStep = 1;
213    DistFunc = NULL;
214    iSubShift = 0;
215  }
216};
217
218// ====================================================================================================================
219// Class definition TComWedgeDist
220// ====================================================================================================================
221class TComWedgeDist
222{
223private:
224  Int                     m_iBlkWidth;
225  Int                     m_iBlkHeight;
226  FpWedgeDistFunc         m_afpDistortFunc[8];
227
228public:
229  TComWedgeDist();
230  virtual ~TComWedgeDist();
231
232  Void init();
233  Void setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, WedgeDistParam& rcDistParam );
234  UInt getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist = WedgeDist_SAD );
235
236private:
237  static UInt xGetSAD4          ( WedgeDistParam* pcDtParam );
238  static UInt xGetSAD8          ( WedgeDistParam* pcDtParam );
239  static UInt xGetSAD16         ( WedgeDistParam* pcDtParam );
240  static UInt xGetSAD32         ( WedgeDistParam* pcDtParam );
241
242  static UInt xGetSSE4          ( WedgeDistParam* pcDtParam );
243  static UInt xGetSSE8          ( WedgeDistParam* pcDtParam );
244  static UInt xGetSSE16         ( WedgeDistParam* pcDtParam );
245  static UInt xGetSSE32         ( WedgeDistParam* pcDtParam );
246
247};// END CLASS DEFINITION TComWedgeDist
248#endif
249
250// ====================================================================================================================
251// Function definition roftoi (mathematically correct rounding of float to int)
252// ====================================================================================================================
253__inline Int roftoi( Double value )
254{
255  (value < -0.5) ? (value -= 0.5) : (value += 0.5);
256  return ( (Int)value );
257}
258#endif // __TCOMWEDGELET__
Note: See TracBrowser for help on using the repository browser.