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 |
---|
77 | Void xInitCuboids( ); |
---|
78 | Void xCuboidsExplicitCheck( Int yIdx , Int uIdx , Int vIdx ); |
---|
79 | Void xCuboidsExplicitCheck( Bool bDecode ); |
---|
80 | Void xSetExplicit( Int yIdx , Int uIdx , Int vIdx ) { m_pCuboidExplicit[yIdx][uIdx][vIdx] = true ;} |
---|
81 | #endif |
---|
82 | |
---|
83 | private: |
---|
84 | Int m_nMaxOctantDepth; |
---|
85 | Int m_nCurOctantDepth; |
---|
86 | Int m_nInputBitDepthY; |
---|
87 | Int m_nOutputBitDepthY; |
---|
88 | Int m_nInputBitDepthC; |
---|
89 | Int m_nOutputBitDepthC; |
---|
90 | Int m_nDeltaBitDepthC; |
---|
91 | Int m_nDeltaBitDepth; |
---|
92 | Int m_nMaxYPartNumLog2; |
---|
93 | Int m_nCurYPartNumLog2; |
---|
94 | Int m_nMaxPartNumLog2; |
---|
95 | Int m_nYSize; |
---|
96 | Int m_nUSize; |
---|
97 | Int m_nVSize; |
---|
98 | Int m_nYShift2Idx; |
---|
99 | Int m_nUShift2Idx; |
---|
100 | Int m_nVShift2Idx; |
---|
101 | Int m_nMappingShift; |
---|
102 | Int m_nMappingOffset; |
---|
103 | Int m_nResQuanBit; |
---|
104 | #if R0300_CGS_RES_COEFF_CODING |
---|
105 | Int m_nDeltaBits; |
---|
106 | #endif |
---|
107 | SCuboid *** m_pCuboid; |
---|
108 | const static Int m_nVertexIdxOffset[4][3]; |
---|
109 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
110 | std::vector<UInt> m_vRefLayerId; |
---|
111 | #endif |
---|
112 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
113 | Int m_nAdaptCThresholdU; |
---|
114 | Int m_nAdaptCThresholdV; |
---|
115 | #endif |
---|
116 | #if R0164_CGS_LUT_BUGFIX |
---|
117 | Bool *** m_pCuboidExplicit; |
---|
118 | #endif |
---|
119 | |
---|
120 | protected: |
---|
121 | template <class T> |
---|
122 | Void xAllocate3DArray( T*** &p , Int xSize , Int ySize , Int zSize ); |
---|
123 | template <class T> |
---|
124 | Void xReset3DArray( T*** &p , Int xSize , Int ySize , Int zSize ); |
---|
125 | template <class T> |
---|
126 | Void xFree3DArray( T *** &p ); |
---|
127 | |
---|
128 | Void xUpdatePartitioning( Int nCurOctantDepth , Int nCurYPartNumLog2 |
---|
129 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
130 | , Int nAdaptCThresholdU , Int nAdaptCThreshodV |
---|
131 | #endif |
---|
132 | ); |
---|
133 | SYUVP xGetCuboidVertexPredA( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx ); |
---|
134 | Pel xMapY( Pel y , Pel u , Pel v ); |
---|
135 | SYUVP xMapUV( Pel y , Pel u , Pel v ); |
---|
136 | Int xGetMaxPartNumLog2() { return m_nMaxPartNumLog2; } |
---|
137 | Int xGetYSize() { return m_nYSize; } |
---|
138 | Int xGetUSize() { return m_nUSize; } |
---|
139 | Int xGetVSize() { return m_nVSize; } |
---|
140 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
141 | Int xGetYIdx(Pel y) { return( y >> m_nYShift2Idx ); } |
---|
142 | Int xGetUIdx(Pel u) { return( m_nCurOctantDepth == 1 ? u >= m_nAdaptCThresholdU : u >> m_nUShift2Idx ); } |
---|
143 | Int xGetVIdx(Pel v) { return( m_nCurOctantDepth == 1 ? v >= m_nAdaptCThresholdV : v >> m_nVShift2Idx ); } |
---|
144 | Int xGetNormCoeffOne() { return( 1 << m_nMappingShift ); } |
---|
145 | #else |
---|
146 | Int xGetYShift2Idx() { return m_nYShift2Idx; } |
---|
147 | Int xGetUShift2Idx() { return m_nUShift2Idx; } |
---|
148 | Int xGetVShift2Idx() { return m_nVShift2Idx; } |
---|
149 | #endif |
---|
150 | SCuboid & xGetCuboid( Int yIdx , Int uIdx , Int vIdx ){ return m_pCuboid[yIdx][uIdx][vIdx]; } |
---|
151 | Void xSaveCuboids( SCuboid *** pSrcCuboid ); |
---|
152 | }; |
---|
153 | |
---|
154 | template <class T> |
---|
155 | Void TCom3DAsymLUT::xAllocate3DArray( T *** &p , Int xSize , Int ySize , Int zSize ) |
---|
156 | { |
---|
157 | p = new T**[xSize]; |
---|
158 | p[0] = new T*[xSize*ySize]; |
---|
159 | for( Int x = 1 ; x < xSize ; x++ ) |
---|
160 | { |
---|
161 | p[x] = p[x-1] + ySize; |
---|
162 | } |
---|
163 | p[0][0] = new T[xSize*ySize*zSize]; |
---|
164 | for( Int x = 0 ; x < xSize ; x++ ) |
---|
165 | { |
---|
166 | for( Int y = 0 ; y < ySize ; y++ ) |
---|
167 | { |
---|
168 | p[x][y] = p[0][0] + x * ySize * zSize + y * zSize; |
---|
169 | } |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | template <class T> |
---|
174 | Void TCom3DAsymLUT::xFree3DArray( T *** &p ) |
---|
175 | { |
---|
176 | if( p != NULL ) |
---|
177 | { |
---|
178 | if( p[0] != NULL ) |
---|
179 | { |
---|
180 | if( p[0][0] != NULL ) |
---|
181 | { |
---|
182 | delete [] p[0][0]; |
---|
183 | } |
---|
184 | delete [] p[0]; |
---|
185 | } |
---|
186 | delete [] p; |
---|
187 | p = NULL; |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | template <class T> |
---|
192 | Void TCom3DAsymLUT::xReset3DArray( T*** &p , Int xSize , Int ySize , Int zSize ) |
---|
193 | { |
---|
194 | memset( p[0][0] , 0 , sizeof( T ) * xSize * ySize * zSize ); |
---|
195 | } |
---|
196 | |
---|
197 | #endif |
---|
198 | |
---|
199 | #endif |
---|