[677] | 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_nPrevFrameBit[3][MAX_TLAYER]; // base + enhancement layer |
---|
| 81 | Int m_nPrevFrameCGSBit[3][MAX_TLAYER]; |
---|
| 82 | Int m_nPrevFrameCGSPartNumLog2[3][MAX_TLAYER]; |
---|
| 83 | Int m_nPrevFrameOverWritePPS[3][MAX_TLAYER]; |
---|
| 84 | Double m_dTotalFrameBit; |
---|
| 85 | Int m_nTotalCGSBit; |
---|
| 86 | Int m_nPPSBit; |
---|
| 87 | Int m_nLUTBitDepth; |
---|
| 88 | |
---|
| 89 | private: |
---|
| 90 | 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 , |
---|
| 91 | Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , |
---|
| 92 | Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ); |
---|
| 93 | Void xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ); |
---|
| 94 | Void xxMapPartNum2DepthYPart( Int nPartNumLog2 , Int & rOctantDepth , Int & rYPartNumLog2 ); |
---|
| 95 | 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 ) ); } |
---|
| 96 | Void xxCollectData( TComPic * pCurPic , UInt refLayerIdc ); |
---|
| 97 | Double xxDeriveVertexes( Int nResQuantBit , SCuboid *** pCurCuboid ); |
---|
| 98 | 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 , |
---|
| 99 | Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ); |
---|
| 100 | 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 , |
---|
| 101 | Double a , Double b , Double c , Double d ); |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | 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 , |
---|
| 105 | Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ) |
---|
| 106 | { |
---|
| 107 | Double a = 1.0 * ( nP7 - nP3 ) / nLengthY; |
---|
| 108 | Double b = 1.0 * ( nP1 - nP0 ) / nLengthUV; |
---|
| 109 | Double c = 1.0 * ( nP3 - nP1 ) / nLengthUV; |
---|
| 110 | Double d = ( ( nP0 * nLengthUV + u0 * nP0 + ( v0 - u0 ) * nP1 - v0 * nP3 ) * nLengthY + y0 * nLengthUV * ( nP3 - nP7 ) ) / nLengthUV / nLengthY; |
---|
| 111 | return( xxCalEstDist( N , Ys , Yy , Yu , Yv , ys , us , vs , yy , yu , yv , uu , uv , vv , YY , a , b , c , d ) ); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | 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 , |
---|
| 115 | Double a , Double b , Double c , Double d ) |
---|
| 116 | { |
---|
| 117 | 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; |
---|
| 118 | return( dError ); |
---|
| 119 | }; |
---|
| 120 | #endif |
---|
| 121 | |
---|
| 122 | #endif |
---|