source: 3DVCSoftware/branches/HTM-6.2-dev2-Samsung/source/Lib/TLibCommon/TComMotionInfo.h @ 399

Last change on this file since 399 was 351, checked in by qualcomm, 12 years ago

JCT3V-D0181

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