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