1 | |
---|
2 | #ifndef __TENC3DASYMLUT__ |
---|
3 | #define __TENC3DASYMLUT__ |
---|
4 | |
---|
5 | #include "../TLibCommon/TCom3DAsymLUT.h" |
---|
6 | #include "../TLibCommon/TComSlice.h" |
---|
7 | #include "../TLibCommon/CommonDef.h" |
---|
8 | #include "../TLibCommon/TComPic.h" |
---|
9 | #include "TEncCfg.h" |
---|
10 | |
---|
11 | #if Q0048_CGS_3D_ASYMLUT |
---|
12 | |
---|
13 | typedef struct _ColorInfo |
---|
14 | { |
---|
15 | Double YY , UU , VV; |
---|
16 | Double Ys , Us , Vs; // sum of enhancement |
---|
17 | Double ys , us , vs; // sum of base |
---|
18 | Double Yy , Yu , Yv; // product of enhancement and base |
---|
19 | Double Uy , Uu , Uv; |
---|
20 | Double Vy , Vu , Vv; |
---|
21 | Double yy , yu , yv , uu , uv , vv; // product of base |
---|
22 | Double N; // number of pixel |
---|
23 | |
---|
24 | public: |
---|
25 | _ColorInfo & operator += ( const _ColorInfo & rColorInfo ) |
---|
26 | { |
---|
27 | YY += rColorInfo.YY; |
---|
28 | UU += rColorInfo.UU; |
---|
29 | VV += rColorInfo.VV; |
---|
30 | Ys += rColorInfo.Ys; |
---|
31 | Us += rColorInfo.Us; |
---|
32 | Vs += rColorInfo.Vs; |
---|
33 | ys += rColorInfo.ys; |
---|
34 | us += rColorInfo.us; |
---|
35 | vs += rColorInfo.vs; |
---|
36 | Yy += rColorInfo.Yy; |
---|
37 | Yu += rColorInfo.Yu; |
---|
38 | Yv += rColorInfo.Yv; |
---|
39 | Uy += rColorInfo.Uy; |
---|
40 | Uu += rColorInfo.Uu; |
---|
41 | Uv += rColorInfo.Uv; |
---|
42 | Vy += rColorInfo.Vy; |
---|
43 | Vu += rColorInfo.Vu; |
---|
44 | Vv += rColorInfo.Vv; |
---|
45 | yy += rColorInfo.yy; |
---|
46 | yu += rColorInfo.yu; |
---|
47 | yv += rColorInfo.yv; |
---|
48 | uu += rColorInfo.uu; |
---|
49 | uv += rColorInfo.uv; |
---|
50 | vv += rColorInfo.vv; |
---|
51 | N += rColorInfo.N; |
---|
52 | return *this; |
---|
53 | } |
---|
54 | |
---|
55 | }SColorInfo; |
---|
56 | |
---|
57 | |
---|
58 | class TEnc3DAsymLUT : public TCom3DAsymLUT |
---|
59 | { |
---|
60 | public: |
---|
61 | TEnc3DAsymLUT(); |
---|
62 | virtual ~TEnc3DAsymLUT(); |
---|
63 | |
---|
64 | virtual Void create( Int nMaxOctantDepth , Int nInputBitDepth , Int nInputBitDepthC , Int nOutputBitDepth , Int nOutputBitDepthC , Int nMaxYPartNumLog2 ); |
---|
65 | virtual Void destroy(); |
---|
66 | Double derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB ); |
---|
67 | Double estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc ); |
---|
68 | |
---|
69 | Void updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit ); |
---|
70 | Void setPPSBit(Int n) { m_nPPSBit = n; } |
---|
71 | Int getPPSBit() { return m_nPPSBit;} |
---|
72 | Void setDsOrigPic(TComPicYuv *pPicYuv) { m_pDsOrigPic = pPicYuv; }; |
---|
73 | |
---|
74 | protected: |
---|
75 | SColorInfo *** m_pColorInfo; |
---|
76 | SColorInfo *** m_pColorInfoC; |
---|
77 | TComPicYuv* m_pDsOrigPic; |
---|
78 | SCuboid *** m_pEncCuboid; |
---|
79 | SCuboid *** m_pBestEncCuboid; |
---|
80 | Int m_nAccuFrameBit; // base + enhancement layer |
---|
81 | Int m_nAccuFrameCGSBit; |
---|
82 | Int m_nPrevFrameCGSPartNumLog2; |
---|
83 | Double m_dTotalFrameBit; |
---|
84 | Int m_nTotalCGSBit; |
---|
85 | Int m_nPPSBit; |
---|
86 | Int m_nLUTBitDepth; |
---|
87 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
88 | Double m_dSumU; |
---|
89 | Double m_dSumV; |
---|
90 | Int m_nNChroma; |
---|
91 | #endif |
---|
92 | |
---|
93 | private: |
---|
94 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
95 | Double xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
96 | Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ); |
---|
97 | #else |
---|
98 | Double xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
99 | Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , |
---|
100 | Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ); |
---|
101 | #endif |
---|
102 | Void xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ); |
---|
103 | Void xxMapPartNum2DepthYPart( Int nPartNumLog2 , Int & rOctantDepth , Int & rYPartNumLog2 ); |
---|
104 | Int xxCoeff2Vertex( Double a , Double b , Double c , Double d , Int y , Int u , Int v ) { return ( ( Int )( a * y + b * u + c * v + d + 0.5 ) ); } |
---|
105 | Void xxCollectData( TComPic * pCurPic , UInt refLayerIdc ); |
---|
106 | Double xxDeriveVertexes( Int nResQuantBit , SCuboid *** pCurCuboid ); |
---|
107 | inline Double xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
108 | Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ); |
---|
109 | inline Double xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
110 | Double a , Double b , Double c , Double d ); |
---|
111 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
112 | inline Double xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
113 | Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ); |
---|
114 | #endif |
---|
115 | }; |
---|
116 | |
---|
117 | Double TEnc3DAsymLUT::xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
118 | Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ) |
---|
119 | { |
---|
120 | Double a = 1.0 * ( nP7 - nP3 ) / nLengthY; |
---|
121 | Double b = 1.0 * ( nP1 - nP0 ) / nLengthUV; |
---|
122 | Double c = 1.0 * ( nP3 - nP1 ) / nLengthUV; |
---|
123 | Double d = ( ( nP0 * nLengthUV + u0 * nP0 + ( v0 - u0 ) * nP1 - v0 * nP3 ) * nLengthY + y0 * nLengthUV * ( nP3 - nP7 ) ) / nLengthUV / nLengthY; |
---|
124 | return( xxCalEstDist( N , Ys , Yy , Yu , Yv , ys , us , vs , yy , yu , yv , uu , uv , vv , YY , a , b , c , d ) ); |
---|
125 | } |
---|
126 | |
---|
127 | Double TEnc3DAsymLUT::xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
128 | Double a , Double b , Double c , Double d ) |
---|
129 | { |
---|
130 | Double dError = N * d * d + 2 * b * c * uv + 2 * a * c * yv + 2 * a * b * yu - 2 * c * Yv - 2 * b * Yu - 2 * a * Yy + 2 * c * d * vs + 2 * b * d * us + 2 * a * d * ys + a * a * yy + c * c * vv + b * b * uu - 2 * d * Ys + YY; |
---|
131 | return( dError ); |
---|
132 | }; |
---|
133 | |
---|
134 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
135 | Double TEnc3DAsymLUT::xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , |
---|
136 | Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ) |
---|
137 | { |
---|
138 | const Int nOne = xGetNormCoeffOne(); |
---|
139 | Double a = 1.0 * nP0 / nOne; |
---|
140 | Double b = 1.0 * nP1 / nOne; |
---|
141 | Double c = 1.0 * nP3 / nOne; |
---|
142 | Double d = nP7; |
---|
143 | Double dError = N * d * d + 2 * b * c * uv + 2 * a * c * yv + 2 * a * b * yu - 2 * c * Yv - 2 * b * Yu - 2 * a * Yy + 2 * c * d * vs + 2 * b * d * us + 2 * a * d * ys + a * a * yy + c * c * vv + b * b * uu - 2 * d * Ys + YY; |
---|
144 | return( dError ); |
---|
145 | }; |
---|
146 | #endif |
---|
147 | |
---|
148 | #endif |
---|
149 | |
---|
150 | #endif |
---|