source: 3DVCSoftware/branches/HTM-4.1-dev2-Orange/source/Lib/TLibCommon/TComMotionInfo.h @ 391

Last change on this file since 391 was 161, checked in by mediatek-htm, 12 years ago

Integration of B0083 (macro MTK_UNCONSTRAINED_MVI).
by Jian-Liang Lin (jl.lin@…)

  • Property svn:eol-style set to native
File size: 7.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-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 QC_MULTI_DIS_CAN
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  Int    iN;                                ///< number of motion vector predictor candidates
67} DisInfo;
68#endif
69// Class definition
70// ====================================================================================================================
71
72/// class for motion vector with reference index
73class TComMvField
74{
75private:
76  TComMv    m_acMv;
77  Int       m_iRefIdx;
78 
79public:
80  TComMvField() : m_iRefIdx( NOT_VALID ) {}
81 
82  Void setMvField( TComMv const & cMv, Int iRefIdx )
83  {
84    m_acMv    = cMv;
85    m_iRefIdx = iRefIdx;
86  }
87 
88  Void setRefIdx( Int refIdx ) { m_iRefIdx = refIdx; }
89 
90  TComMv const & getMv() const { return  m_acMv; }
91  TComMv       & getMv()       { return  m_acMv; }
92 
93  Int getRefIdx() const { return  m_iRefIdx;       }
94  Int getHor   () const { return  m_acMv.getHor(); }
95  Int getVer   () const { return  m_acMv.getVer(); }
96};
97
98/// class for motion information in one CU
99class TComCUMvField
100{
101private:
102  TComMv*   m_pcMv;
103  TComMv*   m_pcMvd;
104  Char*     m_piRefIdx;
105  UInt      m_uiNumPartition;
106  AMVPInfo  m_cAMVPInfo;
107   
108  template <typename T>
109  Void setAll( T *p, T const & val, PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx );
110
111public:
112  TComCUMvField() : m_pcMv(NULL), m_pcMvd(NULL), m_piRefIdx(NULL), m_uiNumPartition(0) {}
113  ~TComCUMvField() {}
114
115  // ------------------------------------------------------------------------------------------------------------------
116  // create / destroy
117  // ------------------------------------------------------------------------------------------------------------------
118 
119  Void    create( UInt uiNumPartition );
120  Void    destroy();
121 
122  // ------------------------------------------------------------------------------------------------------------------
123  // clear / copy
124  // ------------------------------------------------------------------------------------------------------------------
125
126  Void    clearMvField();
127 
128  Void    copyFrom( TComCUMvField const * pcCUMvFieldSrc, Int iNumPartSrc, Int iPartAddrDst );
129  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst ) const;
130  Void    copyTo  ( TComCUMvField* pcCUMvFieldDst, Int iPartAddrDst, UInt uiOffset, UInt uiNumPart ) const;
131 
132  // ------------------------------------------------------------------------------------------------------------------
133  // get
134  // ------------------------------------------------------------------------------------------------------------------
135 
136  TComMv const & getMv    ( Int iIdx ) const { return  m_pcMv    [iIdx]; }
137  TComMv const & getMvd   ( Int iIdx ) const { return  m_pcMvd   [iIdx]; }
138  Int            getRefIdx( Int iIdx ) const { return  m_piRefIdx[iIdx]; }
139 
140  AMVPInfo* getAMVPInfo () { return &m_cAMVPInfo; }
141 
142  // ------------------------------------------------------------------------------------------------------------------
143  // set
144  // ------------------------------------------------------------------------------------------------------------------
145 
146  Void    setAllMv     ( TComMv const & rcMv,         PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
147  Void    setAllMvd    ( TComMv const & rcMvd,        PartSize eCUMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
148  Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
149  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
150
151  Void setNumPartition( Int iNumPart )
152  {
153    m_uiNumPartition = iNumPart;
154  }
155 
156  Void linkToWithOffset( TComCUMvField const * src, Int offset )
157  {
158    m_pcMv     = src->m_pcMv     + offset;
159    m_pcMvd    = src->m_pcMvd    + offset;
160    m_piRefIdx = src->m_piRefIdx + offset;
161  }
162 
163#if HHI_MPI
164  Void compress(Char* pePredMode, UChar* puhInterDir, Int scale);
165#else
166  Void compress(Char* pePredMode, Int scale); 
167#endif
168#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
169  Void decreaseMvAccuracy( Int iPartAddr, Int iNumPart, Int iShift );
170#endif
171
172#if MTK_UNCONSTRAINED_MVI
173  Void setUndefinedMv( Int iPartAddr, Int iNumPart, Char* pePredMode, UChar* puhInterDir, Int refIdx, Int InterDir );
174#endif
175};
176
177//! \}
178
179#endif // __TCOMMOTIONINFO__
Note: See TracBrowser for help on using the repository browser.