source: 3DVCSoftware/branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.h @ 1317

Last change on this file since 1317 was 1317, checked in by tech, 9 years ago

Clean-ups. HLS.

  • Property svn:eol-style set to native
File size: 9.2 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6* Copyright (c) 2010-2015, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TComMotionInfo.h
35    \brief    motion information handling classes (header)
36    \todo     TComMvField seems to be better to be inherited from TComMv
37*/
38
39#ifndef __TCOMMOTIONINFO__
40#define __TCOMMOTIONINFO__
41
42#include <memory.h>
43#include "CommonDef.h"
44#include "TComMv.h"
45
46//! \ingroup TLibCommon
47//! \{
48
49// ====================================================================================================================
50// Type definition
51// ====================================================================================================================
52
53#if NH_3D_SPIVMP
54class TComDataCU;
55#endif
56/// parameters for AMVP
57typedef struct _AMVPInfo
58{
59  TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS_MEM ];  ///< array of motion vector predictor candidates
60  Int    iN;                                ///< number of motion vector predictor candidates
61} AMVPInfo;
62
63#if NH_3D_NBDV
64typedef struct _DisCand
65{
66  TComMv m_acNBDV;              // DV from NBDV
67#if NH_3D_NBDV_REF
68  TComMv m_acDoNBDV;            // DV from DoNBDV
69#endif 
70  Int    m_aVIdxCan;            // View order index (the same with the NBDV and the DoNBDV)
71} DisInfo;
72
73typedef struct _IDVCand // IDV
74{
75  TComMv m_acMvCand[2][ IDV_CANDS ];           
76  Int    m_aVIdxCan[2][ IDV_CANDS ];           
77  Bool   m_bAvailab[2][ IDV_CANDS ];
78  Bool   m_bFound;                               
79} IDVInfo;
80#endif
81
82// ====================================================================================================================
83// Class definition
84// ====================================================================================================================
85
86/// class for motion vector with reference index
87class TComMvField
88{
89private:
90  TComMv    m_acMv;
91  Int       m_iRefIdx;
92 
93public:
94  TComMvField() : m_iRefIdx( NOT_VALID ) {}
95 
96  Void setMvField( TComMv const & cMv, Int iRefIdx )
97  {
98    m_acMv    = cMv;
99    m_iRefIdx = iRefIdx;
100  }
101 
102  Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; }
103 
104  TComMv const & getMv() const { return  m_acMv; }
105  TComMv       & getMv()       { return  m_acMv; }
106 
107  Int getRefIdx() const { return  m_iRefIdx;       }
108  Int getHor   () const { return  m_acMv.getHor(); }
109  Int getVer   () const { return  m_acMv.getVer(); }
110#if NH_3D_IV_MERGE
111  Bool operator== ( const TComMvField& rcMv ) const
112  {
113    return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx());
114  }
115#endif
116};
117
118/// class for motion information in one CU
119class TComCUMvField
120{
121private:
122  TComMv*   m_pcMv;
123  TComMv*   m_pcMvd;
124  Char*     m_piRefIdx;
125  UInt      m_uiNumPartition;
126  AMVPInfo  m_cAMVPInfo;
127   
128  template <typename T>
129  Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx );
130
131public:
132  TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {}
133  ~TComCUMvField() {}
134
135  // ------------------------------------------------------------------------------------------------------------------
136  // create / destroy
137  // ------------------------------------------------------------------------------------------------------------------
138 
139  Void    create( UInt uiNumPartition );
140  Void    destroy();
141 
142  // ------------------------------------------------------------------------------------------------------------------
143  // clear / copy
144  // ------------------------------------------------------------------------------------------------------------------
145
146  Void    clearMvField();
147 
148  Void    copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst );
149  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const;
150  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const;
151 
152  // ------------------------------------------------------------------------------------------------------------------
153  // get
154  // ------------------------------------------------------------------------------------------------------------------
155 
156  TComMv const & getMv    ( Int iIdx ) const { return  m_pcMv    [iIdx]; }
157  TComMv const & getMvd   ( Int iIdx ) const { return  m_pcMvd   [iIdx]; }
158  Int            getRefIdx( Int iIdx ) const { return  m_piRefIdx[iIdx]; }
159 
160  AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; }
161 
162  // ------------------------------------------------------------------------------------------------------------------
163  // set
164  // ------------------------------------------------------------------------------------------------------------------
165 
166  Void    setAllMv     ( TComMv const & rcMv,         PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
167  Void    setAllMvd    ( TComMv const & rcMvd,        PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
168  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
169  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
170#if NH_3D_SPIVMP
171  Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
172#endif
173#if NH_3D_VSP
174  Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
175  Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
176#endif
177
178  Void setNumPartition( Int iNumPart )
179  {
180    m_uiNumPartition = iNumPart;
181  }
182 
183  Void linkToWithOffset( TComCUMvField const * src, Int offset )
184  {
185    m_pcMv     = src->m_pcMv     + offset;
186    m_pcMvd    = src->m_pcMvd    + offset;
187    m_piRefIdx = src->m_piRefIdx + offset;
188  }
189 
190  Void compress(Char* pePredMode, Int scale); 
191#if NH_MV
192  Void print   (Char* pePredMode);
193#endif
194};
195
196//! \}
197
198#if NH_3D_MLC
199/// class for container of merge candidate
200class TComMotionCand
201{
202public:
203  Bool                  m_bAvailable;
204  TComMvField           m_cMvField[2];
205  UChar                 m_uDir;
206#if NH_3D_VSP
207  Int                   m_iVspFlag;
208#endif
209#if NH_3D_SPIVMP
210  Bool                  m_bSPIVMPFlag;
211#endif
212
213public:
214  TComMotionCand()
215  {
216    m_bAvailable = false;
217    m_uDir = 0;
218#if NH_3D_VSP
219    m_iVspFlag = 0;
220#endif
221#if NH_3D_SPIVMP
222    m_bSPIVMPFlag = false;
223#endif
224  }
225
226  ~TComMotionCand()
227  {
228
229  }
230
231  Void init()
232  {
233    TComMv cZeroMv;
234
235    m_bAvailable = false;
236    m_uDir = 0;
237#if NH_3D_VSP
238    m_iVspFlag = 0;
239#endif
240#if NH_3D_SPIVMP
241    m_bSPIVMPFlag = false;
242#endif
243    m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
244    m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
245  }
246
247  Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
248#if NH_3D_VSP
249    , Int vspFlag
250#endif
251#if NH_3D_SPIVMP
252    , Bool bSPIVMPFlag
253#endif
254    )
255  {
256    m_bAvailable = true;
257    m_cMvField[0] = pcMvFieldNeighbours[0];
258    m_cMvField[1] = pcMvFieldNeighbours[1];
259    m_uDir = uhInterDirNeighbours;
260#if NH_3D_VSP
261    m_iVspFlag = vspFlag;
262#endif
263#if NH_3D_SPIVMP
264    m_bSPIVMPFlag = bSPIVMPFlag;
265#endif
266  }
267 
268  Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
269#if NH_3D_VSP
270    , Int* vspFlag
271#endif
272#if NH_3D_SPIVMP
273    , Bool* pbSPIVMPFlag
274#endif
275    )
276  {
277    pcMvFieldNeighbours[iCount<<1] = m_cMvField[0];
278    pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
279    puhInterDirNeighbours[iCount] = m_uDir;
280#if NH_3D_VSP
281    vspFlag[iCount] = m_iVspFlag;
282#endif
283#if NH_3D_SPIVMP
284    pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
285#endif
286  }
287
288
289  Void print( Int i );
290
291};
292
293
294#endif
295
296
297#endif // __TCOMMOTIONINFO__
Note: See TracBrowser for help on using the repository browser.