source: 3DVCSoftware/branches/HTM-9.0r1-F0122/source/Lib/TLibCommon/TComWedgelet.h @ 747

Last change on this file since 747 was 724, checked in by tech, 10 years ago

Merged HTM-8.2-dev0@723.

  • Property svn:eol-style set to native
File size: 8.2 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
45#if H_3D_DIM
46#define DIM_OFFSET     (NUM_INTRA_MODE+1) // offset for DMM and RBC mode numbers (PM: not consistent with spec, but non-overlapping with chroma, see DM_CHROMA_IDX)
47#define DIM_MIN_SIZE                   4  // min. block size for DMM and RBC modes
48#define DIM_MAX_SIZE                  32  // max. block size for DMM and RBC modes
49
50enum DIM_IDX
51{
52#if SEC_DMM3_RBC_F0147
53  DMM1_IDX = 0,
54  DMM4_IDX = 1,
55#else
56  DMM1_IDX = 0,
57  DMM3_IDX = 1,
58  DMM4_IDX = 2,
59  RBC_IDX  = 3
60#endif
61};
62
63#if SEC_DMM3_RBC_F0147
64#define DMM_NUM_TYPE   2
65#define DIM_NUM_TYPE   (DMM_NUM_TYPE)
66#else
67#define DMM_NUM_TYPE   3
68#define RBC_NUM_TYPE   1
69#define DIM_NUM_TYPE   (DMM_NUM_TYPE+RBC_NUM_TYPE)
70#endif
71#define DIM_NO_IDX     MAX_UINT
72
73__inline UInt getDimType  ( Int intraMode ) { Int dimType = (intraMode-DIM_OFFSET)/2; return (dimType >= 0 && dimType < DIM_NUM_TYPE) ? (UInt)dimType : DIM_NO_IDX; }
74__inline Bool isDimMode   ( Int intraMode ) { return (getDimType( intraMode ) < DIM_NUM_TYPE); }
75__inline Bool isDimDeltaDC( Int intraMode ) { return (isDimMode( intraMode ) && ((intraMode-DIM_OFFSET)%2) == 1); }
76#endif
77
78#if H_3D_DIM_RBC
79#define RBC_THRESHOLD              20
80#define RBC_MAX_EDGE_NUM_PER_4x4   8
81#define RBC_MAX_DISTANCE           255
82#endif
83
84#if H_3D_DIM_DMM
85#define DMM_NO_WEDGEINDEX       MAX_UINT
86#define DMM_NUM_WEDGE_REFINES   8
87#if !SEC_DMM3_RBC_F0147
88#define DMM3_SIMPLIFY_TR        1
89#endif
90
91enum WedgeResolution
92{
93  DOUBLE_PEL,
94  FULL_PEL,
95  HALF_PEL
96};
97
98
99// ====================================================================================================================
100// Class definition TComWedgelet
101// ====================================================================================================================
102class TComWedgelet
103{
104private:
105  UChar           m_uhXs;                       // line start X pos
106  UChar           m_uhYs;                       // line start Y pos
107  UChar           m_uhXe;                       // line end   X pos
108  UChar           m_uhYe;                       // line end   Y pos
109  UChar           m_uhOri;                      // orientation index
110  WedgeResolution m_eWedgeRes;                  // start/end pos resolution
111  Bool            m_bIsCoarse; 
112  UInt            m_uiAng;
113
114  UInt  m_uiWidth;
115  UInt  m_uiHeight;
116
117  Bool* m_pbPattern;
118
119  Void  xGenerateWedgePattern();
120  Void  xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride );
121
122public:
123  TComWedgelet( UInt uiWidth, UInt uiHeight );
124  TComWedgelet( const TComWedgelet &rcWedge );
125  virtual ~TComWedgelet();
126
127  Void  create ( UInt iWidth, UInt iHeight );   ///< create  wedgelet pattern
128  Void  destroy();                              ///< destroy wedgelet pattern
129  Void  clear  ();                              ///< clear   wedgelet pattern
130
131  UInt            getWidth   () { return m_uiWidth; }
132  UInt            getStride  () { return m_uiWidth; }
133  UInt            getHeight  () { return m_uiHeight; }
134  WedgeResolution getWedgeRes() { return m_eWedgeRes; }
135  Bool*           getPattern () { return m_pbPattern; }
136  UChar           getStartX  () { return m_uhXs; }
137  UChar           getStartY  () { return m_uhYs; }
138  UChar           getEndX    () { return m_uhXe; }
139  UChar           getEndY    () { return m_uhYe; }
140  UChar           getOri     () { return m_uhOri; }
141  Bool            getIsCoarse() { return m_bIsCoarse; }
142  UInt            getAng     () { return m_uiAng; }
143
144  Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false );
145  Void  findClosestAngle();
146
147  Bool  checkNotPlain();
148  Bool  checkIdentical( Bool* pbRefPattern );
149  Bool  checkInvIdentical( Bool* pbRefPattern );
150
151};  // END CLASS DEFINITION TComWedgelet
152
153// type definition wedgelet pattern list
154typedef std::vector<TComWedgelet> WedgeList;
155
156// ====================================================================================================================
157// Class definition TComWedgeRef
158// ====================================================================================================================
159class TComWedgeRef
160{
161private:
162  UChar           m_uhXs;                       // line start X pos
163  UChar           m_uhYs;                       // line start Y pos
164  UChar           m_uhXe;                       // line end   X pos
165  UChar           m_uhYe;                       // line end   Y pos
166  UInt            m_uiRefIdx;                   // index of corresponding pattern of TComWedgelet object in wedge list
167
168public:
169  TComWedgeRef() {}
170  virtual ~TComWedgeRef() {}
171
172  UChar           getStartX  () { return m_uhXs; }
173  UChar           getStartY  () { return m_uhYs; }
174  UChar           getEndX    () { return m_uhXe; }
175  UChar           getEndY    () { return m_uhYe; }
176  UInt            getRefIdx  () { return m_uiRefIdx; }
177
178  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; }
179};  // END CLASS DEFINITION TComWedgeRef
180
181// type definition wedgelet reference list
182typedef std::vector<TComWedgeRef> WedgeRefList;
183
184// ====================================================================================================================
185// Class definition TComWedgeNode
186// ====================================================================================================================
187class TComWedgeNode
188{
189private:
190  UInt            m_uiPatternIdx;
191  UInt            m_uiRefineIdx[DMM_NUM_WEDGE_REFINES];
192
193public:
194  TComWedgeNode();
195  virtual ~TComWedgeNode() {}
196
197  UInt            getPatternIdx();
198  UInt            getRefineIdx ( UInt uiPos );
199
200  Void            setPatternIdx( UInt uiIdx );
201  Void            setRefineIdx ( UInt uiIdx, UInt uiPos );
202};  // END CLASS DEFINITION TComWedgeNode
203
204// type definition wedgelet node list
205typedef std::vector<TComWedgeNode> WedgeNodeList;
206#endif //H_3D_DIM_DMM
207
208
209// ====================================================================================================================
210// Function definition roftoi (mathematically correct rounding of float to int)
211// ====================================================================================================================
212__inline Int roftoi( Double value )
213{
214  (value < -0.5) ? (value -= 0.5) : (value += 0.5);
215  return ( (Int)value );
216}
217#endif // __TCOMWEDGELET__
Note: See TracBrowser for help on using the repository browser.