source: 3DVCSoftware/trunk/source/Lib/TLibCommon/TComMotionInfo.h @ 1179

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

Merged branch 13.1-dev0@1178.

  • Property svn:eol-style set to native
File size: 8.9 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//! \ingroup TLibCommon
46//! \{
47
48// ====================================================================================================================
49// Type definition
50// ====================================================================================================================
51
52#if H_3D_SPIVMP
53class TComDataCU;
54#endif
55/// parameters for AMVP
56typedef struct _AMVPInfo
57{
58  TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS_MEM ];  ///< array of motion vector predictor candidates
59  Int    iN;                                ///< number of motion vector predictor candidates
60} AMVPInfo;
61
62#if H_3D_NBDV
63typedef struct _DisCand
64{
65#if !SEC_ARP_REM_ENC_RESTRICT_K0035
66  Bool bDV;
67#endif
68  TComMv m_acNBDV;              // DV from NBDV
69#if H_3D_NBDV_REF
70  TComMv m_acDoNBDV;            // DV from DoNBDV
71#endif 
72  Int    m_aVIdxCan;            // View order index (the same with the NBDV and the DoNBDV)
73} DisInfo;
74
75typedef struct _IDVCand // IDV
76{
77  TComMv m_acMvCand[2][ IDV_CANDS ];           
78  Int    m_aVIdxCan[2][ IDV_CANDS ];           
79  Bool   m_bAvailab[2][ IDV_CANDS ];
80  Bool   m_bFound;                               
81} IDVInfo;
82#endif
83
84// ====================================================================================================================
85// Class definition
86// ====================================================================================================================
87
88/// class for motion vector with reference index
89class TComMvField
90{
91private:
92  TComMv    m_acMv;
93  Int       m_iRefIdx;
94 
95public:
96  TComMvField() : m_iRefIdx( NOT_VALID ) {}
97 
98  Void setMvField( TComMv const & cMv, Int iRefIdx )
99  {
100    m_acMv    = cMv;
101    m_iRefIdx = iRefIdx;
102  }
103 
104  Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; }
105 
106  TComMv const & getMv() const { return  m_acMv; }
107  TComMv       & getMv()       { return  m_acMv; }
108 
109  Int getRefIdx() const { return  m_iRefIdx;       }
110  Int getHor   () const { return  m_acMv.getHor(); }
111  Int getVer   () const { return  m_acMv.getVer(); }
112#if H_3D_IV_MERGE
113  Bool operator== ( const TComMvField& rcMv ) const
114  {
115    return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx());
116  }
117#endif
118};
119
120/// class for motion information in one CU
121class TComCUMvField
122{
123private:
124  TComMv*   m_pcMv;
125  TComMv*   m_pcMvd;
126  Char*     m_piRefIdx;
127  UInt      m_uiNumPartition;
128  AMVPInfo  m_cAMVPInfo;
129   
130  template <typename T>
131  Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx );
132
133public:
134  TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {}
135  ~TComCUMvField() {}
136
137  // ------------------------------------------------------------------------------------------------------------------
138  // create / destroy
139  // ------------------------------------------------------------------------------------------------------------------
140 
141  Void    create( UInt uiNumPartition );
142  Void    destroy();
143 
144  // ------------------------------------------------------------------------------------------------------------------
145  // clear / copy
146  // ------------------------------------------------------------------------------------------------------------------
147
148  Void    clearMvField();
149 
150  Void    copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst );
151  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const;
152  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const;
153 
154  // ------------------------------------------------------------------------------------------------------------------
155  // get
156  // ------------------------------------------------------------------------------------------------------------------
157 
158  TComMv const & getMv    ( Int iIdx ) const { return  m_pcMv    [iIdx]; }
159  TComMv const & getMvd   ( Int iIdx ) const { return  m_pcMvd   [iIdx]; }
160  Int            getRefIdx( Int iIdx ) const { return  m_piRefIdx[iIdx]; }
161 
162  AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; }
163 
164  // ------------------------------------------------------------------------------------------------------------------
165  // set
166  // ------------------------------------------------------------------------------------------------------------------
167 
168  Void    setAllMv     ( TComMv const & rcMv,         PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
169  Void    setAllMvd    ( TComMv const & rcMvd,        PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
170  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
171  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
172#if H_3D_SPIVMP
173  Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
174#endif
175#if H_3D_VSP
176  Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
177  Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
178#endif
179
180  Void setNumPartition( Int iNumPart )
181  {
182    m_uiNumPartition = iNumPart;
183  }
184 
185  Void linkToWithOffset( TComCUMvField const * src, Int offset )
186  {
187    m_pcMv     = src->m_pcMv     + offset;
188    m_pcMvd    = src->m_pcMvd    + offset;
189    m_piRefIdx = src->m_piRefIdx + offset;
190  }
191 
192  Void compress(Char* pePredMode, Int scale); 
193};
194
195//! \}
196
197#if H_3D_IV_MERGE
198class TComMotionCand
199{
200public:
201  Bool                  m_bAvailable;
202  TComMvField           m_cMvField[2];
203  UChar                 m_uDir;
204#if H_3D_VSP
205  Int                   m_iVspFlag;
206#endif 
207  Bool                  m_bSPIVMPFlag;
208
209public:
210  TComMotionCand()
211  {
212    m_bAvailable = false;
213    m_uDir = 0;
214#if H_3D_VSP
215    m_iVspFlag = 0;
216#endif
217    m_bSPIVMPFlag = false;
218  }
219
220  ~TComMotionCand()
221  {
222
223  }
224
225  Void init()
226  {
227    TComMv cZeroMv;
228
229    m_bAvailable = false;
230    m_uDir = 0;
231#if H_3D_VSP
232    m_iVspFlag = 0;
233#endif
234    m_bSPIVMPFlag = false;
235    m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
236    m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
237  }
238
239  Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
240#if H_3D_VSP
241    , Int vspFlag
242#endif
243    , Bool bSPIVMPFlag
244    )
245  {
246    m_bAvailable = true;
247    m_cMvField[0] = pcMvFieldNeighbours[0];
248    m_cMvField[1] = pcMvFieldNeighbours[1];
249    m_uDir = uhInterDirNeighbours;
250#if H_3D_VSP
251    m_iVspFlag = vspFlag;
252#endif
253    m_bSPIVMPFlag = bSPIVMPFlag;
254  }
255
256
257  Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
258#if H_3D_VSP
259    , Int* vspFlag
260#endif
261    , Bool* pbSPIVMPFlag
262    )
263  {
264    pcMvFieldNeighbours[iCount<<1] = m_cMvField[0];
265    pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
266    puhInterDirNeighbours[iCount] = m_uDir;
267#if H_3D_VSP
268    vspFlag[iCount] = m_iVspFlag;
269#endif
270    pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
271  }
272};
273#endif
274
275
276#endif // __TCOMMOTIONINFO__
Note: See TracBrowser for help on using the repository browser.