1 | |
---|
2 | |
---|
3 | /** \file TComDepthMapGenerator.h |
---|
4 | \brief depth map generator class (header) |
---|
5 | */ |
---|
6 | |
---|
7 | |
---|
8 | #ifndef __TCOM_DEPTH_MAP_GENERATOR__ |
---|
9 | #define __TCOM_DEPTH_MAP_GENERATOR__ |
---|
10 | |
---|
11 | |
---|
12 | #include "CommonDef.h" |
---|
13 | #include "TComPic.h" |
---|
14 | #include "TComPrediction.h" |
---|
15 | #include "TComSlice.h" |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | class TComSPSAccess // would be better to have a real SPS buffer |
---|
20 | { |
---|
21 | public: |
---|
22 | TComSPSAccess () { clear(); } |
---|
23 | ~TComSPSAccess() {} |
---|
24 | |
---|
25 | Void clear () { ::memset( m_aacActiveSPS, 0x00, sizeof( m_aacActiveSPS ) ); } |
---|
26 | Void addSPS ( TComSPS* pcSPS ) { m_aacActiveSPS[ pcSPS->isDepth() ? 1 : 0 ][ pcSPS->getViewId() ] = pcSPS; } |
---|
27 | TComSPS* getSPS ( UInt uiViewId, |
---|
28 | Bool bIsDepth = false ) { return m_aacActiveSPS[ bIsDepth ? 1 : 0 ][ uiViewId ]; } |
---|
29 | |
---|
30 | UInt getPdm () { if( m_aacActiveSPS[0][1] ) { return m_aacActiveSPS[0][1]->getPredDepthMapGeneration(); } return 0; } |
---|
31 | UInt getResPrd () { if( m_aacActiveSPS[0][1] ) { return m_aacActiveSPS[0][1]->getMultiviewResPredMode (); } return 0; } |
---|
32 | |
---|
33 | private: |
---|
34 | TComSPS* m_aacActiveSPS[ 2 ][ MAX_NUMBER_VIEWS ]; |
---|
35 | }; |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | class TComAUPicAccess // would be better to have a real decoded picture buffer |
---|
40 | { |
---|
41 | public: |
---|
42 | TComAUPicAccess () : m_iLastPoc( 0 ), m_uiMaxViewId( 0 ) { clear(); } |
---|
43 | ~TComAUPicAccess() {} |
---|
44 | |
---|
45 | Void clear () { ::memset( m_aacCurrAUPics, 0x00, sizeof( m_aacCurrAUPics ) ); } |
---|
46 | Void addPic ( TComPic* pcPic ) { if( m_iLastPoc != pcPic->getPOC() ) |
---|
47 | { |
---|
48 | clear(); |
---|
49 | m_iLastPoc = pcPic->getPOC(); |
---|
50 | } |
---|
51 | m_aacCurrAUPics[ pcPic->getSPS()->isDepth() ? 1 : 0 ][ pcPic->getSPS()->getViewId() ] = pcPic; |
---|
52 | if( pcPic->getSPS()->getViewId() > m_uiMaxViewId ) |
---|
53 | { |
---|
54 | m_uiMaxViewId = pcPic->getSPS()->getViewId(); |
---|
55 | } |
---|
56 | } |
---|
57 | TComPic* getPic ( UInt uiViewId, |
---|
58 | Bool bIsDepth = false ) { return m_aacCurrAUPics[ bIsDepth ? 1 : 0 ][ uiViewId ]; } |
---|
59 | UInt getMaxVId () { return m_uiMaxViewId; } |
---|
60 | |
---|
61 | private: |
---|
62 | Int m_iLastPoc; |
---|
63 | UInt m_uiMaxViewId; |
---|
64 | TComPic* m_aacCurrAUPics[ 2 ][ MAX_NUMBER_VIEWS ]; |
---|
65 | }; |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | class TComDepthMapGenerator |
---|
70 | { |
---|
71 | public: |
---|
72 | TComDepthMapGenerator (); |
---|
73 | ~TComDepthMapGenerator(); |
---|
74 | |
---|
75 | Void create ( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth ); |
---|
76 | Void destroy (); |
---|
77 | |
---|
78 | Void init ( TComPrediction* pcPrediction, TComSPSAccess* pcSPSAccess, TComAUPicAccess* pcAUPicAccess ); |
---|
79 | Void uninit (); |
---|
80 | |
---|
81 | Void initViewComponent ( TComPic* pcPic ); |
---|
82 | Bool predictDepthMap ( TComPic* pcPic ); |
---|
83 | Void updateDepthMap ( TComPic* pcPic ); |
---|
84 | Void dumpDepthMap ( TComPic* pcPic, char* pFilenameBase ); |
---|
85 | |
---|
86 | Void covertOrgDepthMap ( TComPic* pcPic ); |
---|
87 | |
---|
88 | UInt getBaseViewId ( UInt uiIdx ) { AOF( uiIdx < m_auiBaseIdList.size() ); return m_auiBaseIdList[uiIdx]; } |
---|
89 | Int getDisparity ( TComPic* pcPic, Int iPosX, Int iPosY, UInt uiRefViewId ); |
---|
90 | Int getPdmMergeCandidate ( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv ); |
---|
91 | Bool getPdmMvPred ( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, Bool bMerge ); |
---|
92 | Bool getIViewOrgDepthMvPred( TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv ); |
---|
93 | |
---|
94 | TComPrediction* getPrediction () { return m_pcPrediction; } |
---|
95 | TComSPSAccess* getSPSAccess () { return m_pcSPSAccess; } |
---|
96 | TComAUPicAccess* getAUPicAccess() { return m_pcAUPicAccess; } |
---|
97 | |
---|
98 | private: |
---|
99 | // picture operations |
---|
100 | Bool xConvertDepthMapCurr2Ref ( TComPic* pcRef, TComPic* pcCur ); |
---|
101 | Bool xConvertDepthMapRef2Curr ( TComPic* pcCur, TComPic* pcRef ); |
---|
102 | Bool xPredictDepthMap ( TComPic* pcPic ); |
---|
103 | Bool xFillDepthMapHoles ( TComPic* pcPic ); |
---|
104 | Void xClearDepthMap ( TComPic* pcPic, Int iVal = PDM_UNDEFINED_DEPTH ); |
---|
105 | Void xSetChroma ( TComPicYuv* pcPic, Int iVal ); |
---|
106 | |
---|
107 | // CU operations |
---|
108 | Void xPredictCUDepthMap ( TComDataCU* pcCU, UInt uiDepth, UInt uiAbsPartIdx ); // CU depth map prediction |
---|
109 | Void xIntraPredictCUDepthMap ( TComDataCU* pcCU, TComYuv* pcCUDepthMap ); // CU intra prediction |
---|
110 | Void xInterPredictCUDepthMap ( TComDataCU* pcCU, TComYuv* pcCUDepthMap ); // CU inter prediction |
---|
111 | |
---|
112 | // PU and block operations |
---|
113 | Void xIntraPredictBlkDepthMap ( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiAbsPartIdx, UInt uiTrDepth ); // block intra prediction |
---|
114 | Void xInterPredictPUDepthMap ( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ); // PU inter prediction/update |
---|
115 | Void xIViewPUDepthMapUpdate ( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ); // PU interview update |
---|
116 | Void xInterPUDepthMapUpdate ( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ); // PU inter update |
---|
117 | Void xInterPUDepthMapPrediction( TComDataCU* pcCU, TComYuv* pcCUDepthMap, UInt uiPartIdx ); // PU inter prediction |
---|
118 | Bool xGetPredDepth ( TComDataCU* pcCU, UInt uiPartIdx, Int& riPrdDepth, Int* piPosX = 0, Int* piPosY = 0 ); |
---|
119 | |
---|
120 | // conversion functions |
---|
121 | Int xGetVirtDepthFromDisparity( UInt uiBaseId, Int iDisparity ) |
---|
122 | { |
---|
123 | AOF( uiBaseId < m_uiCurrViewId ); |
---|
124 | Int* pPar = m_aaiConvParsDisparity2VirtDepth[ uiBaseId ]; |
---|
125 | Int iRes = ( pPar[ 0 ] * iDisparity + pPar[ 1 ] ) >> pPar[ 2 ]; |
---|
126 | return iRes; |
---|
127 | } |
---|
128 | Int xGetDisparityFromVirtDepth( UInt uiBaseId, Int iVirtDepth ) |
---|
129 | { |
---|
130 | AOF( uiBaseId < m_uiCurrViewId ); |
---|
131 | Int* pPar = m_aaiConvParsVirtDepth2Disparity[ uiBaseId ]; |
---|
132 | Int iRes = ( pPar[ 0 ] * iVirtDepth + pPar[ 1 ] ) >> pPar[ 2 ]; |
---|
133 | return iRes; |
---|
134 | } |
---|
135 | Int xGetVirtDepthFromOrigDepth( UInt uiViewId, Int iOrigDepth ) |
---|
136 | { |
---|
137 | AOF( uiViewId <= m_uiCurrViewId ); |
---|
138 | Int* pPar = m_aaiConvParsOrigDepth2VirtDepth[ uiViewId ]; |
---|
139 | Int iRes = ( pPar[ 0 ] * iOrigDepth + pPar[ 1 ] ) >> pPar[ 2 ]; |
---|
140 | return iRes; |
---|
141 | } |
---|
142 | Int xGetOrigDepthFromVirtDepth( UInt uiViewId, Int iVirtDepth ) |
---|
143 | { |
---|
144 | AOF( uiViewId <= m_uiCurrViewId ); |
---|
145 | Int* pPar = m_aaiConvParsVirtDepth2OrigDepth[ uiViewId ]; |
---|
146 | Int iRes = ( pPar[ 0 ] * iVirtDepth + pPar[ 1 ] ) >> pPar[ 2 ]; |
---|
147 | return iRes; |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | private: |
---|
152 | // general parameters |
---|
153 | Bool m_bCreated; |
---|
154 | Bool m_bInit; |
---|
155 | Bool m_bDecoder; |
---|
156 | TComPrediction* m_pcPrediction; |
---|
157 | TComSPSAccess* m_pcSPSAccess; |
---|
158 | TComAUPicAccess* m_pcAUPicAccess; |
---|
159 | UInt m_uiMaxDepth; |
---|
160 | UInt m_uiOrgDepthBitDepth; |
---|
161 | TComYuv** m_ppcYuv; |
---|
162 | TComDataCU** m_ppcCU; |
---|
163 | TComPicYuv m_cTmpPic; |
---|
164 | |
---|
165 | // conversion parameters |
---|
166 | UInt m_uiCurrViewId; |
---|
167 | Bool m_bPDMAvailable; |
---|
168 | std::vector<UInt> m_auiBaseIdList; |
---|
169 | Int m_aaiConvParsDisparity2VirtDepth[ MAX_NUMBER_VIEWS ][ 3 ]; // disparity ==> virtual depth (0:scale, 1:add, 2:shift) |
---|
170 | Int m_aaiConvParsVirtDepth2Disparity[ MAX_NUMBER_VIEWS ][ 3 ]; // virtual depth ==> disparity (0:scale, 1:add, 2:shift) |
---|
171 | Int m_aaiConvParsOrigDepth2VirtDepth[ MAX_NUMBER_VIEWS ][ 3 ]; // original depth ==> virtual depth (0:scale, 1:add, 2:shift) |
---|
172 | Int m_aaiConvParsVirtDepth2OrigDepth[ MAX_NUMBER_VIEWS ][ 3 ]; // virtual depth ==> original depth (0:scale, 1:add, 2:shift) |
---|
173 | |
---|
174 | // temporary arrays |
---|
175 | Bool m_aabDepthSet[ MAX_CU_SIZE >> 2 ][ MAX_CU_SIZE >> 2 ]; |
---|
176 | Int m_aai4x4Depth[ MAX_CU_SIZE >> 2 ][ MAX_CU_SIZE >> 2 ]; |
---|
177 | }; |
---|
178 | |
---|
179 | #endif // __TCOM_DEPTH_MAP_GENERATOR__ |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | |
---|