source: 3DVCSoftware/branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComMotionInfo.h @ 213

Last change on this file since 213 was 213, checked in by mitsubishi-htm, 11 years ago

A final release, as planned

  • Migrate to HTM 5.1
  • For VC project files, only VC9 file is updated
  • To be used as an additional anchor for CE1.h for 3rd JCTVC meeting at Geneva
  • Property svn:eol-style set to native
File size: 7.4 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-2012, 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#if VSP_N
46#include "TComSlice.h"
47#endif
48
49//! \ingroup TLibCommon
50//! \{
51
52// ====================================================================================================================
53// Type definition
54// ====================================================================================================================
55
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// ====================================================================================================================
64#if QC_MULTI_DIS_CAN_A0097
65typedef struct _DisCand
66{
67  TComMv m_acMvCand[ DIS_CANS ];            ///< array of motion vector predictor candidates
68  Int    m_aVIdxCan[ DIS_CANS ];            ///< array of motion vector predictor candidates
69  Int    iN;                                ///< number of motion vector predictor candidates
70} DisInfo;
71#endif
72// Class definition
73// ====================================================================================================================
74
75/// class for motion vector with reference index
76class TComMvField
77{
78private:
79  TComMv    m_acMv;
80  Int       m_iRefIdx;
81 
82public:
83  TComMvField() : m_iRefIdx( NOT_VALID ) {}
84 
85  Void setMvField( TComMv const & cMv, Int iRefIdx )
86  {
87    m_acMv    = cMv;
88    m_iRefIdx = iRefIdx;
89  }
90 
91  Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; }
92 
93  TComMv const & getMv() const { return  m_acMv; }
94  TComMv       & getMv()       { return  m_acMv; }
95 
96  Int getRefIdx() const { return  m_iRefIdx;       }
97  Int getHor   () const { return  m_acMv.getHor(); }
98  Int getVer   () const { return  m_acMv.getVer(); }
99#if QC_MRG_CANS_B0048
100  Bool operator== ( const TComMvField& rcMv ) const
101  {
102    return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx());
103  }
104#endif
105};
106
107/// class for motion information in one CU
108class TComCUMvField
109{
110private:
111  TComMv*   m_pcMv;
112  TComMv*   m_pcMvd;
113  Char*     m_piRefIdx;
114  UInt      m_uiNumPartition;
115  AMVPInfo  m_cAMVPInfo;
116   
117  template <typename T>
118  Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx );
119
120public:
121  TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {}
122  ~TComCUMvField() {}
123
124  // ------------------------------------------------------------------------------------------------------------------
125  // create / destroy
126  // ------------------------------------------------------------------------------------------------------------------
127 
128  Void    create( UInt uiNumPartition );
129  Void    destroy();
130 
131  // ------------------------------------------------------------------------------------------------------------------
132  // clear / copy
133  // ------------------------------------------------------------------------------------------------------------------
134
135  Void    clearMvField();
136 
137  Void    copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst );
138  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const;
139  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const;
140 
141  // ------------------------------------------------------------------------------------------------------------------
142  // get
143  // ------------------------------------------------------------------------------------------------------------------
144 
145  TComMv const & getMv    ( Int iIdx ) const { return  m_pcMv    [iIdx]; }
146  TComMv const & getMvd   ( Int iIdx ) const { return  m_pcMvd   [iIdx]; }
147  Int            getRefIdx( Int iIdx ) const { return  m_piRefIdx[iIdx]; }
148 
149  AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; }
150 
151  // ------------------------------------------------------------------------------------------------------------------
152  // set
153  // ------------------------------------------------------------------------------------------------------------------
154 
155  Void    setAllMv     ( TComMv const & rcMv,         PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
156  Void    setAllMvd    ( TComMv const & rcMvd,        PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
157  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
158  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
159
160  Void setNumPartition( Int iNumPart )
161  {
162    m_uiNumPartition = iNumPart;
163  }
164 
165  Void linkToWithOffset( TComCUMvField const * src, Int offset )
166  {
167    m_pcMv     = src->m_pcMv     + offset;
168    m_pcMvd    = src->m_pcMvd    + offset;
169    m_piRefIdx = src->m_piRefIdx + offset;
170  }
171 
172#if HHI_MPI
173  Void compress(Char* pePredMode, UChar* puhInterDir, Int scale);
174#else
175  Void compress(Char* pePredMode, Int scale); 
176#endif
177#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
178  Void decreaseMvAccuracy( Int iPartAddr, Int iNumPart, Int iShift );
179#endif
180
181#if MTK_UNCONSTRAINED_MVI_B0083
182  Void setUndefinedMv( Int iPartAddr, Int iNumPart, Char* pePredMode, UChar* puhInterDir, Int refIdx, Int InterDir
183#if NTT_FIX_UNCONSTRAINED_MVI
184                     , Int iNumRefIdx
185#endif
186    );
187#endif
188};
189
190//! \}
191
192#endif // __TCOMMOTIONINFO__
Note: See TracBrowser for help on using the repository browser.