source: 3DVCSoftware/branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComMotionInfo.h @ 1279

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

Merged 14.1-update-dev2@1277.

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