source: 3DVCSoftware/branches/HTM-11.2-dev2-Qualcomm/source/Lib/TLibCommon/TComMotionInfo.h

Last change on this file was 976, checked in by tech, 10 years ago
  • Merged 11.1-dev0@975. (Clean ups)
  • Added coding results.
  • Changed version number.
  • Property svn:eol-style set to native
File size: 9.0 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#if H_3D_VSP
82typedef struct _InheritedVSPDisCand
83{
84  DisInfo m_acDvInfo;
85} InheritedVSPDisInfo;
86#endif
87// ====================================================================================================================
88// Class definition
89// ====================================================================================================================
90
91/// class for motion vector with reference index
92class TComMvField
93{
94private:
95  TComMv    m_acMv;
96  Int       m_iRefIdx;
97 
98public:
99  TComMvField() : m_iRefIdx( NOT_VALID ) {}
100 
101  Void setMvField( TComMv const & cMv, Int iRefIdx )
102  {
103    m_acMv    = cMv;
104    m_iRefIdx = iRefIdx;
105  }
106 
107  Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; }
108 
109  TComMv const & getMv() const { return  m_acMv; }
110  TComMv       & getMv()       { return  m_acMv; }
111 
112  Int getRefIdx() const { return  m_iRefIdx;       }
113  Int getHor   () const { return  m_acMv.getHor(); }
114  Int getVer   () const { return  m_acMv.getVer(); }
115#if H_3D_IV_MERGE
116  Bool operator== ( const TComMvField& rcMv ) const
117  {
118    return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx());
119  }
120#endif
121};
122
123/// class for motion information in one CU
124class TComCUMvField
125{
126private:
127  TComMv*   m_pcMv;
128  TComMv*   m_pcMvd;
129  Char*     m_piRefIdx;
130  UInt      m_uiNumPartition;
131  AMVPInfo  m_cAMVPInfo;
132   
133  template <typename T>
134  Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx );
135
136public:
137  TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {}
138  ~TComCUMvField() {}
139
140  // ------------------------------------------------------------------------------------------------------------------
141  // create / destroy
142  // ------------------------------------------------------------------------------------------------------------------
143 
144  Void    create( UInt uiNumPartition );
145  Void    destroy();
146 
147  // ------------------------------------------------------------------------------------------------------------------
148  // clear / copy
149  // ------------------------------------------------------------------------------------------------------------------
150
151  Void    clearMvField();
152 
153  Void    copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst );
154  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const;
155  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const;
156 
157  // ------------------------------------------------------------------------------------------------------------------
158  // get
159  // ------------------------------------------------------------------------------------------------------------------
160 
161  TComMv const & getMv    ( Int iIdx ) const { return  m_pcMv    [iIdx]; }
162  TComMv const & getMvd   ( Int iIdx ) const { return  m_pcMvd   [iIdx]; }
163  Int            getRefIdx( Int iIdx ) const { return  m_piRefIdx[iIdx]; }
164 
165  AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; }
166 
167  // ------------------------------------------------------------------------------------------------------------------
168  // set
169  // ------------------------------------------------------------------------------------------------------------------
170 
171  Void    setAllMv     ( TComMv const & rcMv,         PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
172  Void    setAllMvd    ( TComMv const & rcMvd,        PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
173  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
174  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
175#if H_3D_SPIVMP
176  Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
177#endif
178#if H_3D_VSP
179  Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
180  Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
181#endif
182
183  Void setNumPartition( Int iNumPart )
184  {
185    m_uiNumPartition = iNumPart;
186  }
187 
188  Void linkToWithOffset( TComCUMvField const * src, Int offset )
189  {
190    m_pcMv     = src->m_pcMv     + offset;
191    m_pcMvd    = src->m_pcMvd    + offset;
192    m_piRefIdx = src->m_piRefIdx + offset;
193  }
194 
195  Void compress(Char* pePredMode, Int scale); 
196};
197
198//! \}
199
200#if H_3D_IV_MERGE
201class TComMotionCand
202{
203public:
204  Bool                  m_bAvailable;
205  TComMvField           m_cMvField[2];
206  UChar                 m_uDir;
207#if H_3D_VSP
208  Int                   m_iVspFlag;
209#endif 
210  Bool                  m_bSPIVMPFlag;
211
212public:
213  TComMotionCand()
214  {
215    m_bAvailable = false;
216    m_uDir = 0;
217#if H_3D_VSP
218    m_iVspFlag = 0;
219#endif
220    m_bSPIVMPFlag = false;
221  }
222
223  ~TComMotionCand()
224  {
225
226  }
227
228  Void init()
229  {
230    TComMv cZeroMv;
231
232    m_bAvailable = false;
233    m_uDir = 0;
234#if H_3D_VSP
235    m_iVspFlag = 0;
236#endif
237    m_bSPIVMPFlag = false;
238    m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
239    m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
240  }
241
242  Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
243#if H_3D_VSP
244    , Int vspFlag
245#endif
246    , Bool bSPIVMPFlag
247    )
248  {
249    m_bAvailable = true;
250    m_cMvField[0] = pcMvFieldNeighbours[0];
251    m_cMvField[1] = pcMvFieldNeighbours[1];
252    m_uDir = uhInterDirNeighbours;
253#if H_3D_VSP
254    m_iVspFlag = vspFlag;
255#endif
256    m_bSPIVMPFlag = bSPIVMPFlag;
257  }
258
259
260  Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
261#if H_3D_VSP
262    , Int* vspFlag
263#endif
264    , Bool* pbSPIVMPFlag
265    )
266  {
267    pcMvFieldNeighbours[iCount<<1] = m_cMvField[0];
268    pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
269    puhInterDirNeighbours[iCount] = m_uDir;
270#if H_3D_VSP
271    vspFlag[iCount] = m_iVspFlag;
272#endif
273    pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
274  }
275};
276#endif
277
278
279#endif // __TCOMMOTIONINFO__
Note: See TracBrowser for help on using the repository browser.