1 | |
---|
2 | #ifndef __TCOM3DASYMLUT__ |
---|
3 | #define __TCOM3DASYMLUT__ |
---|
4 | |
---|
5 | #include "TypeDef.h" |
---|
6 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
7 | #include <cassert> |
---|
8 | #include <vector> |
---|
9 | #endif |
---|
10 | |
---|
11 | #if Q0048_CGS_3D_ASYMLUT |
---|
12 | |
---|
13 | typedef struct _SYUVP |
---|
14 | { |
---|
15 | Pel Y , U , V; |
---|
16 | }SYUVP; |
---|
17 | |
---|
18 | typedef struct _SCuboid // vertexes for tetrahedral interpolation |
---|
19 | { |
---|
20 | SYUVP P[4]; // YUV: P0(0,0,0), P1(0,1,0), P3(0,1,1), P7(1,1,1) |
---|
21 | }SCuboid; |
---|
22 | |
---|
23 | class TComPicYuv; |
---|
24 | |
---|
25 | class TCom3DAsymLUT |
---|
26 | { |
---|
27 | public: |
---|
28 | TCom3DAsymLUT(); |
---|
29 | virtual ~TCom3DAsymLUT(); |
---|
30 | |
---|
31 | virtual Void create( Int nMaxOctantDepth , Int nInputBitDepth , Int nInputBitDepthC , Int nOutputBitDepth , Int nOutputBitDepthC , Int nMaxYPartNumLog2 |
---|
32 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
33 | , Int nAdaptCThresholdU , Int nAdaptCThresholdV |
---|
34 | #endif |
---|
35 | ); |
---|
36 | virtual Void destroy(); |
---|
37 | |
---|
38 | Int getMaxOctantDepth() { return m_nMaxOctantDepth; } |
---|
39 | Int getCurOctantDepth() { return m_nCurOctantDepth; } |
---|
40 | Int getInputBitDepthY() { return m_nInputBitDepthY; } |
---|
41 | Int getOutputBitDepthY() { return m_nOutputBitDepthY; } |
---|
42 | Int getInputBitDepthC() { return m_nInputBitDepthC; } |
---|
43 | Int getOutputBitDepthC() { return m_nOutputBitDepthC; } |
---|
44 | Int getResQuantBit() { return m_nResQuanBit; } |
---|
45 | Void setResQuantBit(Int n){ m_nResQuanBit = n; } |
---|
46 | #if R0300_CGS_RES_COEFF_CODING |
---|
47 | Int getMappingShift() { return m_nMappingShift; } |
---|
48 | Int getDeltaBits() { return m_nDeltaBits; } |
---|
49 | Void setDeltaBits(Int n) { m_nDeltaBits = n; } |
---|
50 | #endif |
---|
51 | Int getMaxYPartNumLog2() { return m_nMaxYPartNumLog2; } |
---|
52 | Int getCurYPartNumLog2() { return m_nCurYPartNumLog2; } |
---|
53 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
54 | Void addRefLayerId( UInt uiRefLayerId ) |
---|
55 | { |
---|
56 | if( !isRefLayer( uiRefLayerId ) ) |
---|
57 | m_vRefLayerId.push_back( uiRefLayerId ); |
---|
58 | } |
---|
59 | size_t getRefLayerNum() { return m_vRefLayerId.size(); } |
---|
60 | UInt getRefLayerId( UInt n ) { assert( n < m_vRefLayerId.size() ); return m_vRefLayerId[n]; } |
---|
61 | Bool isRefLayer( UInt uiRefLayerId ); |
---|
62 | #endif |
---|
63 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
64 | Void setAdaptChromaThresholdU( Int n ) { m_nAdaptCThresholdU = n; } |
---|
65 | Int getAdaptChromaThresholdU() { return m_nAdaptCThresholdU; } |
---|
66 | Void setAdaptChromaThresholdV( Int n ) { m_nAdaptCThresholdV = n; } |
---|
67 | Int getAdaptChromaThresholdV() { return m_nAdaptCThresholdV; } |
---|
68 | #endif |
---|
69 | |
---|
70 | Void colorMapping( TComPicYuv * pcPicSrc, TComPicYuv * pcPicDst ); |
---|
71 | Void copy3DAsymLUT( TCom3DAsymLUT * pSrc ); |
---|
72 | |
---|
73 | SYUVP xGetCuboidVertexPredAll( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx , SCuboid *** pCurCuboid=NULL ); |
---|
74 | SYUVP getCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx ); |
---|
75 | Void setCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx , Int deltaY , Int deltaU , Int deltaV ); |
---|
76 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
77 | Void xInitCuboids( ); |
---|
78 | Void xCuboidsFilledCheck( Int yIdx , Int uIdx , Int vIdx ); |
---|
79 | Void xCuboidsFilledCheck( Bool bDecode ); |
---|
80 | Void display( Bool bFilled=true ); |
---|
81 | Void xSetExplicit( Int yIdx , Int uIdx , Int vIdx ) { m_pCuboidExplicit[yIdx][uIdx][vIdx] = true ; xSetFilled(yIdx,uIdx,vIdx); } |
---|
82 | Void xSetFilled( Int yIdx , Int uIdx , Int vIdx ) { m_pCuboidFilled[yIdx][uIdx][vIdx] = true ; } |
---|
83 | #endif |
---|
84 | |
---|
85 | private: |
---|
86 | Int m_nMaxOctantDepth; |
---|
87 | Int m_nCurOctantDepth; |
---|
88 | Int m_nInputBitDepthY; |
---|
89 | Int m_nOutputBitDepthY; |
---|
90 | Int m_nInputBitDepthC; |
---|
91 | Int m_nOutputBitDepthC; |
---|
92 | Int m_nDeltaBitDepthC; |
---|
93 | Int m_nDeltaBitDepth; |
---|
94 | Int m_nMaxYPartNumLog2; |
---|
95 | Int m_nCurYPartNumLog2; |
---|
96 | Int m_nMaxPartNumLog2; |
---|
97 | Int m_nYSize; |
---|
98 | Int m_nUSize; |
---|
99 | Int m_nVSize; |
---|
100 | Int m_nYShift2Idx; |
---|
101 | Int m_nUShift2Idx; |
---|
102 | Int m_nVShift2Idx; |
---|
103 | Int m_nMappingShift; |
---|
104 | Int m_nMappingOffset; |
---|
105 | Int m_nResQuanBit; |
---|
106 | #if R0300_CGS_RES_COEFF_CODING |
---|
107 | Int m_nDeltaBits; |
---|
108 | #endif |
---|
109 | SCuboid *** m_pCuboid; |
---|
110 | const static Int m_nVertexIdxOffset[4][3]; |
---|
111 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
112 | std::vector<UInt> m_vRefLayerId; |
---|
113 | #endif |
---|
114 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
115 | Int m_nAdaptCThresholdU; |
---|
116 | Int m_nAdaptCThresholdV; |
---|
117 | #endif |
---|
118 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
119 | Bool *** m_pCuboidExplicit; |
---|
120 | Bool *** m_pCuboidFilled; |
---|
121 | #endif |
---|
122 | |
---|
123 | protected: |
---|
124 | template <class T> |
---|
125 | Void xAllocate3DArray( T*** &p , Int xSize , Int ySize , Int zSize ); |
---|
126 | template <class T> |
---|
127 | Void xReset3DArray( T*** &p , Int xSize , Int ySize , Int zSize ); |
---|
128 | template <class T> |
---|
129 | Void xFree3DArray( T *** &p ); |
---|
130 | |
---|
131 | Void xUpdatePartitioning( Int nCurOctantDepth , Int nCurYPartNumLog2 |
---|
132 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
133 | , Int nAdaptCThresholdU , Int nAdaptCThreshodV |
---|
134 | #endif |
---|
135 | ); |
---|
136 | SYUVP xGetCuboidVertexPredA( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx ); |
---|
137 | Pel xMapY( Pel y , Pel u , Pel v ); |
---|
138 | SYUVP xMapUV( Pel y , Pel u , Pel v ); |
---|
139 | Int xGetMaxPartNumLog2() { return m_nMaxPartNumLog2; } |
---|
140 | Int xGetYSize() { return m_nYSize; } |
---|
141 | Int xGetUSize() { return m_nUSize; } |
---|
142 | Int xGetVSize() { return m_nVSize; } |
---|
143 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
144 | Int xGetYIdx(Pel y) { return( y >> m_nYShift2Idx ); } |
---|
145 | Int xGetUIdx(Pel u) { return( m_nCurOctantDepth == 1 ? u >= m_nAdaptCThresholdU : u >> m_nUShift2Idx ); } |
---|
146 | Int xGetVIdx(Pel v) { return( m_nCurOctantDepth == 1 ? v >= m_nAdaptCThresholdV : v >> m_nVShift2Idx ); } |
---|
147 | Int xGetNormCoeffOne() { return( 1 << m_nMappingShift ); } |
---|
148 | #else |
---|
149 | Int xGetYShift2Idx() { return m_nYShift2Idx; } |
---|
150 | Int xGetUShift2Idx() { return m_nUShift2Idx; } |
---|
151 | Int xGetVShift2Idx() { return m_nVShift2Idx; } |
---|
152 | #endif |
---|
153 | SCuboid & xGetCuboid( Int yIdx , Int uIdx , Int vIdx ){ return m_pCuboid[yIdx][uIdx][vIdx]; } |
---|
154 | Void xSaveCuboids( SCuboid *** pSrcCuboid ); |
---|
155 | }; |
---|
156 | |
---|
157 | template <class T> |
---|
158 | Void TCom3DAsymLUT::xAllocate3DArray( T *** &p , Int xSize , Int ySize , Int zSize ) |
---|
159 | { |
---|
160 | p = new T**[xSize]; |
---|
161 | p[0] = new T*[xSize*ySize]; |
---|
162 | for( Int x = 1 ; x < xSize ; x++ ) |
---|
163 | { |
---|
164 | p[x] = p[x-1] + ySize; |
---|
165 | } |
---|
166 | p[0][0] = new T[xSize*ySize*zSize]; |
---|
167 | for( Int x = 0 ; x < xSize ; x++ ) |
---|
168 | { |
---|
169 | for( Int y = 0 ; y < ySize ; y++ ) |
---|
170 | { |
---|
171 | p[x][y] = p[0][0] + x * ySize * zSize + y * zSize; |
---|
172 | } |
---|
173 | } |
---|
174 | } |
---|
175 | |
---|
176 | template <class T> |
---|
177 | Void TCom3DAsymLUT::xFree3DArray( T *** &p ) |
---|
178 | { |
---|
179 | if( p != NULL ) |
---|
180 | { |
---|
181 | if( p[0] != NULL ) |
---|
182 | { |
---|
183 | if( p[0][0] != NULL ) |
---|
184 | { |
---|
185 | delete [] p[0][0]; |
---|
186 | } |
---|
187 | delete [] p[0]; |
---|
188 | } |
---|
189 | delete [] p; |
---|
190 | p = NULL; |
---|
191 | } |
---|
192 | } |
---|
193 | |
---|
194 | template <class T> |
---|
195 | Void TCom3DAsymLUT::xReset3DArray( T*** &p , Int xSize , Int ySize , Int zSize ) |
---|
196 | { |
---|
197 | memset( p[0][0] , 0 , sizeof( T ) * xSize * ySize * zSize ); |
---|
198 | } |
---|
199 | |
---|
200 | #endif |
---|
201 | |
---|
202 | #endif |
---|