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

Last change on this file since 1097 was 1084, checked in by tech, 10 years ago

Merged branches/HTM-12.1-dev0@1083.

  • 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-2014, 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  Bool bDV;
66  TComMv m_acNBDV;              // DV from NBDV
67#if H_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 H_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 H_3D_SPIVMP
171  Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
172#endif
173#if H_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};
192
193//! \}
194
195#if H_3D_IV_MERGE
196class TComMotionCand
197{
198public:
199  Bool                  m_bAvailable;
200  TComMvField           m_cMvField[2];
201  UChar                 m_uDir;
202#if H_3D_VSP
203  Int                   m_iVspFlag;
204#endif 
205  Bool                  m_bSPIVMPFlag;
206
207public:
208  TComMotionCand()
209  {
210    m_bAvailable = false;
211    m_uDir = 0;
212#if H_3D_VSP
213    m_iVspFlag = 0;
214#endif
215    m_bSPIVMPFlag = false;
216  }
217
218  ~TComMotionCand()
219  {
220
221  }
222
223  Void init()
224  {
225    TComMv cZeroMv;
226
227    m_bAvailable = false;
228    m_uDir = 0;
229#if H_3D_VSP
230    m_iVspFlag = 0;
231#endif
232    m_bSPIVMPFlag = false;
233    m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
234    m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
235  }
236
237  Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
238#if H_3D_VSP
239    , Int vspFlag
240#endif
241    , Bool bSPIVMPFlag
242    )
243  {
244    m_bAvailable = true;
245    m_cMvField[0] = pcMvFieldNeighbours[0];
246    m_cMvField[1] = pcMvFieldNeighbours[1];
247    m_uDir = uhInterDirNeighbours;
248#if H_3D_VSP
249    m_iVspFlag = vspFlag;
250#endif
251    m_bSPIVMPFlag = bSPIVMPFlag;
252  }
253
254
255  Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
256#if H_3D_VSP
257    , Int* vspFlag
258#endif
259    , Bool* pbSPIVMPFlag
260    )
261  {
262    pcMvFieldNeighbours[iCount<<1] = m_cMvField[0];
263    pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
264    puhInterDirNeighbours[iCount] = m_uDir;
265#if H_3D_VSP
266    vspFlag[iCount] = m_iVspFlag;
267#endif
268    pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
269  }
270};
271#endif
272
273
274#endif // __TCOMMOTIONINFO__
Note: See TracBrowser for help on using the repository browser.