source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibCommon/TComPic.h @ 1426

Last change on this file since 1426 was 1419, checked in by seregin, 10 years ago

remove global variables g_mvScalingFactor and g_posScalingFactor, and make them TComPic members

  • Property svn:eol-style set to native
File size: 12.5 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     TComPic.h
35    \brief    picture class (header)
36*/
37
38#ifndef __TCOMPIC__
39#define __TCOMPIC__
40
41// Include files
42#include "CommonDef.h"
43#include "TComPicSym.h"
44#include "TComPicYuv.h"
45#include "TComBitStream.h"
46#if AVC_BASE
47#include <fstream>
48#endif
49
50//! \ingroup TLibCommon
51//! \{
52
53// ====================================================================================================================
54// Class definition
55// ====================================================================================================================
56
57/// picture class (symbol + YUV buffers)
58
59class TComPic
60{
61public:
62  typedef enum { PIC_YUV_ORG=0, PIC_YUV_REC=1, PIC_YUV_TRUE_ORG=2, NUM_PIC_YUV=3 } PIC_YUV_T;
63     // TRUE_ORG is the input file without any pre-encoder colour space conversion (but with possible bit depth increment)
64  TComPicYuv*   getPicYuvTrueOrg()        { return  m_apcPicYuv[PIC_YUV_TRUE_ORG]; }
65
66private:
67  UInt                  m_uiTLayer;               //  Temporal layer
68  Bool                  m_bUsedByCurr;            //  Used by current picture
69  Bool                  m_bIsLongTerm;            //  IS long term picture
70  TComPicSym            m_picSym;                 //  Symbol
71  TComPicYuv*           m_apcPicYuv[NUM_PIC_YUV];
72
73  TComPicYuv*           m_pcPicYuvPred;           //  Prediction
74  TComPicYuv*           m_pcPicYuvResi;           //  Residual
75  Bool                  m_bReconstructed;
76  Bool                  m_bNeededForOutput;
77  UInt                  m_uiCurrSliceIdx;         // Index of current slice
78  Bool                  m_bCheckLTMSB;
79
80  Bool                  m_isTop;
81  Bool                  m_isField;
82
83  std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink;
84
85  SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
86#if SVC_EXTENSION
87  UInt                  m_layerId;              //  Layer ID
88  Bool                  m_bSpatialEnhLayer[MAX_LAYERS];       // whether current layer is a spatial enhancement layer,
89  TComPicYuv*           m_pcFullPelBaseRec[MAX_LAYERS];    // upsampled base layer recontruction for difference domain inter prediction
90  Bool                  m_equalPictureSizeAndOffsetFlag[MAX_LAYERS];
91  Int*                  m_mvScalingFactor[2];
92  Int*                  m_posScalingFactor[2];
93#if CGS_3D_ASYMLUT
94  Int                   m_nFrameBit;
95#endif
96  Bool                  m_currAuFlag;
97#endif
98public:
99  TComPic();
100  virtual ~TComPic();
101
102#if SVC_EXTENSION
103  Void          create( const TComVPS& vps, const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual /*= false*/, const UInt layerId );
104#else
105  Void          create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual /*= false*/ );
106#endif
107
108  virtual Void  destroy();
109
110  UInt          getTLayer() const               { return m_uiTLayer;   }
111  Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
112
113  Bool          getUsedByCurr() const            { return m_bUsedByCurr; }
114  Void          setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; }
115  Bool          getIsLongTerm() const            { return m_bIsLongTerm; }
116  Void          setIsLongTerm( Bool lt ) { m_bIsLongTerm = lt; }
117  Void          setCheckLTMSBPresent     (Bool b ) {m_bCheckLTMSB=b;}
118  Bool          getCheckLTMSBPresent     () { return m_bCheckLTMSB;}
119
120  TComPicSym*   getPicSym()           { return  &m_picSym;    }
121  TComSlice*    getSlice(Int i)       { return  m_picSym.getSlice(i);  }
122  Int           getPOC() const        { return  m_picSym.getSlice(m_uiCurrSliceIdx)->getPOC();  }
123  TComDataCU*   getCtu( UInt ctuRsAddr )           { return  m_picSym.getCtu( ctuRsAddr ); }
124  const TComDataCU* getCtu( UInt ctuRsAddr ) const { return  m_picSym.getCtu( ctuRsAddr ); }
125
126  TComPicYuv*   getPicYuvOrg()        { return  m_apcPicYuv[PIC_YUV_ORG]; }
127  TComPicYuv*   getPicYuvRec()        { return  m_apcPicYuv[PIC_YUV_REC]; }
128
129  TComPicYuv*   getPicYuvPred()       { return  m_pcPicYuvPred; }
130  TComPicYuv*   getPicYuvResi()       { return  m_pcPicYuvResi; }
131  Void          setPicYuvPred( TComPicYuv* pcPicYuv )       { m_pcPicYuvPred = pcPicYuv; }
132  Void          setPicYuvResi( TComPicYuv* pcPicYuv )       { m_pcPicYuvResi = pcPicYuv; }
133
134  UInt          getNumberOfCtusInFrame() const     { return m_picSym.getNumberOfCtusInFrame(); }
135  UInt          getNumPartInCtuWidth() const       { return m_picSym.getNumPartInCtuWidth();   }
136  UInt          getNumPartInCtuHeight() const      { return m_picSym.getNumPartInCtuHeight();  }
137  UInt          getNumPartitionsInCtu() const      { return m_picSym.getNumPartitionsInCtu();  }
138  UInt          getFrameWidthInCtus() const        { return m_picSym.getFrameWidthInCtus();    }
139  UInt          getFrameHeightInCtus() const       { return m_picSym.getFrameHeightInCtus();   }
140  UInt          getMinCUWidth() const              { return m_picSym.getMinCUWidth();          }
141  UInt          getMinCUHeight() const             { return m_picSym.getMinCUHeight();         }
142
143  Int           getStride(const ComponentID id) const          { return m_apcPicYuv[PIC_YUV_REC]->getStride(id); }
144  Int           getComponentScaleX(const ComponentID id) const    { return m_apcPicYuv[PIC_YUV_REC]->getComponentScaleX(id); }
145  Int           getComponentScaleY(const ComponentID id) const    { return m_apcPicYuv[PIC_YUV_REC]->getComponentScaleY(id); }
146  ChromaFormat  getChromaFormat() const                           { return m_apcPicYuv[PIC_YUV_REC]->getChromaFormat(); }
147  Int           getNumberValidComponents() const                  { return m_apcPicYuv[PIC_YUV_REC]->getNumberValidComponents(); }
148
149  Void          setReconMark (Bool b) { m_bReconstructed = b;     }
150  Bool          getReconMark () const      { return m_bReconstructed;  }
151  Void          setOutputMark (Bool b) { m_bNeededForOutput = b;     }
152  Bool          getOutputMark () const      { return m_bNeededForOutput;  }
153
154  Void          compressMotion();
155  UInt          getCurrSliceIdx() const           { return m_uiCurrSliceIdx;                }
156  Void          setCurrSliceIdx(UInt i)      { m_uiCurrSliceIdx = i;                   }
157  UInt          getNumAllocatedSlice() const      {return m_picSym.getNumAllocatedSlice();}
158  Void          allocateNewSlice()           {m_picSym.allocateNewSlice();         }
159  Void          clearSliceBuffer()           {m_picSym.clearSliceBuffer();         }
160
161#if SVC_EXTENSION
162  const Window& getConformanceWindow() const { return m_picSym.getSlice(0)->getConformanceWindow(); }
163#else
164  const Window& getConformanceWindow() const { return m_picSym.getSPS().getConformanceWindow(); }
165#endif
166  Window        getDefDisplayWindow() const  { return m_picSym.getSPS().getVuiParametersPresentFlag() ? m_picSym.getSPS().getVuiParameters()->getDefaultDisplayWindow() : Window(); }
167
168  Bool          getSAOMergeAvailability(Int currAddr, Int mergeAddr);
169
170  UInt          getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice);
171
172  /* field coding parameters*/
173
174   Void              setTopField(Bool b)                  {m_isTop = b;}
175   Bool              isTopField()                         {return m_isTop;}
176   Void              setField(Bool b)                     {m_isField = b;}
177   Bool              isField()                            {return m_isField;}
178
179  /** transfer ownership of seis to this picture */
180  Void setSEIs(SEIMessages& seis) { m_SEIs = seis; }
181
182  /**
183   * return the current list of SEI messages associated with this picture.
184   * Pointer is valid until this->destroy() is called */
185  SEIMessages& getSEIs() { return m_SEIs; }
186
187  /**
188   * return the current list of SEI messages associated with this picture.
189   * Pointer is valid until this->destroy() is called */
190  const SEIMessages& getSEIs() const { return m_SEIs; }
191
192#if SVC_EXTENSION
193  Void          setLayerId(UInt layerId)                                    { m_layerId = layerId;                                       }
194  UInt          getLayerId()                                                { return m_layerId;                                          }
195  UInt          getLayerIdx()                                               { return getSlice(0)->getVPS()->getLayerIdxInVps(m_layerId); }
196  Bool          isSpatialEnhLayer(UInt refLayerIdc)                         { return m_bSpatialEnhLayer[refLayerIdc];                    }
197  Void          setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b)           { m_bSpatialEnhLayer[refLayerIdc] = b;                       }
198  Void          setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p)       { m_pcFullPelBaseRec[refLayerIdc] = p;                       }
199  TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)                      { return  m_pcFullPelBaseRec[refLayerIdc];                   }
200  Bool          isILR( UInt currLayerId )                                   { return ( m_bIsLongTerm && m_layerId < currLayerId );       }
201  Bool          equalPictureSizeAndOffsetFlag(UInt refLayerIdc)             { return m_equalPictureSizeAndOffsetFlag[refLayerIdc];       }
202  Void          setEqualPictureSizeAndOffsetFlag(UInt refLayerIdc, Bool b)  { m_equalPictureSizeAndOffsetFlag[refLayerIdc] = b;          }
203  Void          copyUpsampledMvField(UInt refLayerIdc, Int** mvScalingFactor, Int** posScalingFactor);
204  Void          initUpsampledMvField();
205  Bool          checkSameRefInfo();
206  Void          copyUpsampledPictureYuv(TComPicYuv* pcPicYuvIn, TComPicYuv* pcPicYuvOut); 
207  Void          setMvScalingFactor(UInt refLayerIdc, Int compX, Int compY)  { m_mvScalingFactor[0][refLayerIdc] = compX; m_mvScalingFactor[1][refLayerIdc] = compY;   }
208  Void          setPosScalingFactor(UInt refLayerIdc, Int compX, Int compY) { m_posScalingFactor[0][refLayerIdc] = compX; m_posScalingFactor[1][refLayerIdc] = compY; }
209  Int           getMvScalingFactor(UInt refLayerIdc, UChar comp) const      { return m_mvScalingFactor[comp][refLayerIdc];  }
210  Int           getPosScalingFactor(UInt refLayerIdc, UChar comp) const     { return m_posScalingFactor[comp][refLayerIdc]; }
211  Int**         getPosScalingFactor()                                       { return m_posScalingFactor; }
212  Int**         getMvScalingFactor()                                        { return m_mvScalingFactor;  }
213  Void          createMvScalingFactor(UInt numOfILRPs);
214  Void          createPosScalingFactor(UInt numOfILRPs);
215#if CGS_3D_ASYMLUT
216  Void          setFrameBit( Int n )                                        { m_nFrameBit = n;     }
217  Int           getFrameBit()                                               { return m_nFrameBit;  }
218#endif
219  Bool          isCurrAu()                                                  { return m_currAuFlag; }
220  Void          setCurrAuFlag(Bool x)                                       { m_currAuFlag = x;    }
221#endif //SVC_EXTENSION
222};// END CLASS DEFINITION TComPic
223
224//! \}
225
226#endif // __TCOMPIC__
Note: See TracBrowser for help on using the repository browser.