source: 3DVCSoftware/branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPic.h

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

Removed 3D.

  • Property svn:eol-style set to native
File size: 18.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     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
47//! \ingroup TLibCommon
48//! \{
49
50// ====================================================================================================================
51// Class definition
52// ====================================================================================================================
53
54/// picture class (symbol + YUV buffers)
55
56
57
58#if NH_MV
59class TComPic; 
60
61class TComDecodedRps
62{
63public: 
64
65  TComDecodedRps()
66  {
67    m_refPicSetsCurr[0] = &m_refPicSetStCurrBefore;
68    m_refPicSetsCurr[1] = &m_refPicSetStCurrAfter ;
69    m_refPicSetsCurr[2] = &m_refPicSetLtCurr      ; 
70
71    m_refPicSetsLt  [0] = &m_refPicSetLtCurr      ; 
72    m_refPicSetsLt  [1] = &m_refPicSetLtFoll      ;
73
74    m_refPicSetsAll [0] = &m_refPicSetStCurrBefore;
75    m_refPicSetsAll [1] = &m_refPicSetStCurrAfter ;
76    m_refPicSetsAll [2] = &m_refPicSetStFoll      ;
77    m_refPicSetsAll [3] = &m_refPicSetLtCurr      ;
78    m_refPicSetsAll [4] = &m_refPicSetLtFoll      ;
79  };   
80
81  std::vector<Int>       m_pocStCurrBefore;
82  std::vector<Int>       m_pocStCurrAfter;
83  std::vector<Int>       m_pocStFoll;   
84  std::vector<Int>       m_pocLtCurr;
85  std::vector<Int>       m_pocLtFoll; 
86
87  Int                    m_numPocStCurrBefore;
88  Int                    m_numPocStCurrAfter;
89  Int                    m_numPocStFoll;
90  Int                    m_numPocLtCurr;
91  Int                    m_numPocLtFoll;
92
93  std::vector<TComPic*>  m_refPicSetStCurrBefore; 
94  std::vector<TComPic*>  m_refPicSetStCurrAfter; 
95  std::vector<TComPic*>  m_refPicSetStFoll; 
96  std::vector<TComPic*>  m_refPicSetLtCurr; 
97  std::vector<TComPic*>  m_refPicSetLtFoll;   
98
99  std::vector<TComPic*>* m_refPicSetsCurr[3];
100  std::vector<TComPic*>* m_refPicSetsLt  [2];
101  std::vector<TComPic*>* m_refPicSetsAll [5];
102
103  // Annex F
104  Int                    m_numActiveRefLayerPics0;
105  Int                    m_numActiveRefLayerPics1;     
106
107  std::vector<TComPic*>  m_refPicSetInterLayer0;
108  std::vector<TComPic*>  m_refPicSetInterLayer1;
109};
110#endif
111
112class TComPic
113{
114public:
115  typedef enum { PIC_YUV_ORG=0, PIC_YUV_REC=1, PIC_YUV_TRUE_ORG=2, NUM_PIC_YUV=3 } PIC_YUV_T;
116     // TRUE_ORG is the input file without any pre-encoder colour space conversion (but with possible bit depth increment)
117  TComPicYuv*   getPicYuvTrueOrg()        { return  m_apcPicYuv[PIC_YUV_TRUE_ORG]; }
118
119private:
120  UInt                  m_uiTLayer;               //  Temporal layer
121  Bool                  m_bUsedByCurr;            //  Used by current picture
122  Bool                  m_bIsLongTerm;            //  IS long term picture
123  TComPicSym            m_picSym;                 //  Symbol
124  TComPicYuv*           m_apcPicYuv[NUM_PIC_YUV];
125
126  TComPicYuv*           m_pcPicYuvPred;           //  Prediction
127  TComPicYuv*           m_pcPicYuvResi;           //  Residual
128  Bool                  m_bReconstructed;
129  Bool                  m_bNeededForOutput;
130
131  UInt                  m_uiCurrSliceIdx;         // Index of current slice
132  Bool                  m_bCheckLTMSB;
133
134  Bool                  m_isTop;
135  Bool                  m_isField;
136
137  std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink;
138
139  SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
140#if NH_MV
141  Int                   m_layerId;
142  Int                   m_viewId;
143  Bool                  m_bPicOutputFlag;                // Semantics variable
144  Bool                  m_hasGeneratedRefPics; 
145  Bool                  m_isPocResettingPic; 
146  Bool                  m_isFstPicOfAllLayOfPocResetPer; 
147  Int64                 m_decodingOrder; 
148  Bool                  m_noRaslOutputFlag; 
149  Bool                  m_noClrasOutputFlag; 
150  Int                   m_picLatencyCount; 
151  Bool                  m_isGenerated;
152  Bool                  m_isGeneratedCl833; 
153  Bool                  m_activatesNewVps;
154  TComDecodedRps        m_decodedRps;
155#endif
156public:
157  TComPic();
158  virtual ~TComPic();
159
160  Void          create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual /*= false*/ );
161
162  virtual Void  destroy();
163
164  UInt          getTLayer() const               { return m_uiTLayer;   }
165  Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
166
167  Bool          getUsedByCurr() const            { return m_bUsedByCurr; }
168  Void          setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; }
169  Bool          getIsLongTerm() const            { return m_bIsLongTerm; }
170  Void          setIsLongTerm( Bool lt ) { m_bIsLongTerm = lt; }
171  Void          setCheckLTMSBPresent     (Bool b ) {m_bCheckLTMSB=b;}
172  Bool          getCheckLTMSBPresent     () { return m_bCheckLTMSB;}
173
174  TComPicSym*   getPicSym()           { return  &m_picSym;    }
175  const TComPicSym* getPicSym() const { return  &m_picSym;    }
176  TComSlice*    getSlice(Int i)       { return  m_picSym.getSlice(i);  }
177  Int           getPOC() const        { return  m_picSym.getSlice(m_uiCurrSliceIdx)->getPOC();  }
178  TComDataCU*   getCtu( UInt ctuRsAddr )           { return  m_picSym.getCtu( ctuRsAddr ); }
179  const TComDataCU* getCtu( UInt ctuRsAddr ) const { return  m_picSym.getCtu( ctuRsAddr ); }
180
181  TComPicYuv*   getPicYuvOrg()        { return  m_apcPicYuv[PIC_YUV_ORG]; }
182  TComPicYuv*   getPicYuvRec()        { return  m_apcPicYuv[PIC_YUV_REC]; }
183
184  TComPicYuv*   getPicYuvPred()       { return  m_pcPicYuvPred; }
185  TComPicYuv*   getPicYuvResi()       { return  m_pcPicYuvResi; }
186  Void          setPicYuvPred( TComPicYuv* pcPicYuv )       { m_pcPicYuvPred = pcPicYuv; }
187  Void          setPicYuvResi( TComPicYuv* pcPicYuv )       { m_pcPicYuvResi = pcPicYuv; }
188
189  UInt          getNumberOfCtusInFrame() const     { return m_picSym.getNumberOfCtusInFrame(); }
190  UInt          getNumPartInCtuWidth() const       { return m_picSym.getNumPartInCtuWidth();   }
191  UInt          getNumPartInCtuHeight() const      { return m_picSym.getNumPartInCtuHeight();  }
192  UInt          getNumPartitionsInCtu() const      { return m_picSym.getNumPartitionsInCtu();  }
193  UInt          getFrameWidthInCtus() const        { return m_picSym.getFrameWidthInCtus();    }
194  UInt          getFrameHeightInCtus() const       { return m_picSym.getFrameHeightInCtus();   }
195  UInt          getMinCUWidth() const              { return m_picSym.getMinCUWidth();          }
196  UInt          getMinCUHeight() const             { return m_picSym.getMinCUHeight();         }
197
198  Int           getStride(const ComponentID id) const          { return m_apcPicYuv[PIC_YUV_REC]->getStride(id); }
199  Int           getComponentScaleX(const ComponentID id) const    { return m_apcPicYuv[PIC_YUV_REC]->getComponentScaleX(id); }
200  Int           getComponentScaleY(const ComponentID id) const    { return m_apcPicYuv[PIC_YUV_REC]->getComponentScaleY(id); }
201  ChromaFormat  getChromaFormat() const                           { return m_apcPicYuv[PIC_YUV_REC]->getChromaFormat(); }
202  Int           getNumberValidComponents() const                  { return m_apcPicYuv[PIC_YUV_REC]->getNumberValidComponents(); }
203
204  Void          setReconMark (Bool b) { m_bReconstructed = b;     }
205  Bool          getReconMark () const      { return m_bReconstructed;  }
206  Void          setOutputMark (Bool b) { m_bNeededForOutput = b;     }
207  Bool          getOutputMark () const      { return m_bNeededForOutput;  }
208
209  Void          compressMotion();
210  UInt          getCurrSliceIdx() const           { return m_uiCurrSliceIdx;                }
211  Void          setCurrSliceIdx(UInt i)      { m_uiCurrSliceIdx = i;                   }
212  UInt          getNumAllocatedSlice() const      {return m_picSym.getNumAllocatedSlice();}
213  Void          allocateNewSlice()           {m_picSym.allocateNewSlice();         }
214  Void          clearSliceBuffer()           {m_picSym.clearSliceBuffer();         }
215
216  const Window& getConformanceWindow() const { return m_picSym.getSPS().getConformanceWindow(); }
217  Window        getDefDisplayWindow() const  { return m_picSym.getSPS().getVuiParametersPresentFlag() ? m_picSym.getSPS().getVuiParameters()->getDefaultDisplayWindow() : Window(); }
218
219  Bool          getSAOMergeAvailability(Int currAddr, Int mergeAddr);
220
221  UInt          getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice);
222
223  /* field coding parameters*/
224
225   Void              setTopField(Bool b)                  {m_isTop = b;}
226   Bool              isTopField()                         {return m_isTop;}
227   Void              setField(Bool b)                     {m_isField = b;}
228   Bool              isField()                            {return m_isField;}
229
230#if NH_MV
231   Void          setLayerId            ( Int layerId )    { m_layerId      = layerId; }
232   Int           getLayerId            () const           { return m_layerId;    }
233   
234   Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
235   Int           getViewId             () const           { return m_viewId;     }
236
237   Void          setPicOutputFlag(Bool b)                 { m_bPicOutputFlag = b;      }
238   Bool          getPicOutputFlag() const                 { return m_bPicOutputFlag ;  }
239
240   Bool          getPocResetPeriodId();
241
242   Void          markAsUsedForShortTermReference();
243   Void          markAsUsedForLongTermReference(); 
244   Void          markAsUnusedForReference(); 
245
246   Bool          getMarkedUnUsedForReference();
247   Bool          getMarkedAsShortTerm();
248
249   Void          setHasGeneratedRefPics(Bool val)       { m_hasGeneratedRefPics  = val;    }
250   Bool          getHasGeneratedRefPics( )              { return m_hasGeneratedRefPics;   }
251
252   Void          setIsPocResettingPic(Bool val)         { m_isPocResettingPic = val;    }
253   Bool          getIsPocResettingPic( )                { return m_isPocResettingPic;   }
254
255   Void          setIsFstPicOfAllLayOfPocResetPer(Bool val) { m_isFstPicOfAllLayOfPocResetPer = val;  }
256   Bool          getIsFstPicOfAllLayOfPocResetPer( )        { return m_isFstPicOfAllLayOfPocResetPer; }
257
258   Int64         getDecodingOrder( )                    { return m_decodingOrder;       }
259   Void          setDecodingOrder( UInt64 val  )        { m_decodingOrder = val;        }
260
261   Bool          getNoRaslOutputFlag()                  { return m_noRaslOutputFlag;     }
262   Void          setNoRaslOutputFlag( Bool b )          { m_noRaslOutputFlag = b;        }
263
264   Bool          getNoClrasOutputFlag()                 { return m_noClrasOutputFlag;    }
265   Void          setNoClrasOutputFlag( Bool b )         { m_noClrasOutputFlag = b;       }
266
267   Int           getPicLatencyCount()                   { return m_picLatencyCount;      }
268   Void          setPicLatencyCount( Int val )          { m_picLatencyCount = val;       }
269
270   Bool          getIsGenerated() const                 { return m_isGenerated;          }
271   Void          setIsGenerated( Bool b )               { m_isGenerated = b;             }
272
273   Bool          getIsGeneratedCl833() const            { return m_isGeneratedCl833;     }
274   Void          setIsGeneratedCl833( Bool b )          { m_isGeneratedCl833 = b;        }
275
276   Int           getTemporalId( )                       { return getSlice(0)->getTemporalId(); }
277
278   Bool          getActivatesNewVps()                   { return m_activatesNewVps;      }
279   Void          setActivatesNewVps( Bool b )           { m_activatesNewVps = b;         }
280
281   TComDecodedRps* getDecodedRps()                      { return &m_decodedRps;          }
282
283   Bool          isIrap()                               { return getSlice(0)->isIRAP(); } 
284   Bool          isBla ()                               { return getSlice(0)->isBla (); } 
285   Bool          isIdr ()                               { return getSlice(0)->isIdr (); } 
286   Bool          isCra ()                               { return getSlice(0)->isCra (); } 
287   Bool          isSlnr ()                              { return getSlice(0)->isSlnr (); }
288   Bool          isRasl ()                              { return getSlice(0)->isRasl (); }
289   Bool          isRadl ()                              { return getSlice(0)->isRadl (); }
290   Bool          isStsa ()                              { return getSlice(0)->isStsa (); }
291   Bool          isTsa ()                               { return getSlice(0)->isTsa  (); }
292
293   Void          print( Int outputLevel );
294
295#endif
296
297  /** transfer ownership of seis to this picture */
298  Void setSEIs(SEIMessages& seis) { m_SEIs = seis; }
299
300  /**
301   * return the current list of SEI messages associated with this picture.
302   * Pointer is valid until this->destroy() is called */
303  SEIMessages& getSEIs() { return m_SEIs; }
304
305  /**
306   * return the current list of SEI messages associated with this picture.
307   * Pointer is valid until this->destroy() is called */
308  const SEIMessages& getSEIs() const { return m_SEIs; }
309};// END CLASS DEFINITION TComPic
310
311#if NH_MV
312
313class TComAu : public TComList<TComPic*>
314{
315 
316public:
317
318  Int                 getPoc            ( )                     {  assert(!empty()); return back()->getPOC            ();  }
319  Void                setPicLatencyCount( Int picLatenyCount );
320  Int                 getPicLatencyCount( )                     {  assert(!empty()); return back()->getPicLatencyCount();  } 
321  TComPic*            getPic            ( Int nuhLayerId  );
322  Void                addPic            ( TComPic* pic, Bool pocUnkown );
323  Bool                containsPic       ( TComPic* pic ); 
324};
325
326
327class TComSubDpb : public TComList<TComPic*>
328{
329private: 
330  Int m_nuhLayerId; 
331public: 
332  TComSubDpb( Int nuhLayerid );
333
334  Int                 getLayerId                      ( ) { return m_nuhLayerId; }
335
336  TComPic*            getPic                          ( Int poc  );
337  TComPic*            getPicFromLsb                   ( Int pocLsb, Int maxPicOrderCntLsb );
338  TComPic*            getShortTermRefPic              ( Int poc  );
339  TComList<TComPic*>  getPicsMarkedNeedForOutput      ( );
340
341  Void                markAllAsUnusedForReference     ( );
342
343  Void                addPic                          ( TComPic* pic );
344  Void                removePics                      ( std::vector<TComPic*> picToRemove );
345  Bool                areAllPicsMarkedNotNeedForOutput( );
346};
347
348class TComPicLists
349{
350private: 
351  TComList<TComAu*    >       m_aus; 
352  TComList<TComSubDpb*>       m_subDpbs; 
353  Bool                        m_printPicOutput; 
354public: 
355  TComPicLists() { m_printPicOutput = false; };
356  ~TComPicLists();
357
358  // Add and remove single pictures
359  Void                   addNewPic( TComPic* pic );
360  Void                   removePic( TComPic* pic );
361
362  // Get Pics
363  TComPic*               getPic                         ( Int layerIdInNuh, Int poc );
364  TComPicYuv*            getPicYuv                      ( Int layerIdInNuh, Int poc, Bool recon );
365
366  // Get and AUs and SubDPBs
367  TComSubDpb*            getSubDpb                      ( Int nuhLayerId, Bool create );
368  TComList<TComSubDpb*>* getSubDpbs                     ( );
369                                                       
370  TComAu*                addAu                          ( Int poc  );
371  TComAu*                getAu                          ( Int poc, Bool create );
372  TComList<TComAu*>*     getAus                         ( );
373  TComList<TComAu*>      getAusHavingPicsMarkedForOutput( );
374
375  // Mark pictures and set POCs
376  Void                   markSubDpbAsUnusedForReference ( Int layerIdInNuh );
377  Void                   markSubDpbAsUnusedForReference ( TComSubDpb& subDpb );
378  Void                   markAllSubDpbAsUnusedForReference(  );
379  Void                   decrementPocsInSubDpb          ( Int nuhLayerId, Int deltaPocVal );
380 
381  // Empty Sub DPBs
382  Void                   emptyAllSubDpbs                ( );
383  Void                   emptySubDpbs                   ( TComList<TComSubDpb*>* subDpbs);
384  Void                   emptySubDpb                    ( TComSubDpb* subDpb);
385  Void                   emptySubDpb                    ( Int nuhLayerId );
386
387  Void                   emptyNotNeedForOutputAndUnusedForRef      ( );
388  Void                   emptySubDpbNotNeedForOutputAndUnusedForRef( Int layerId  );
389  Void                   emptySubDpbNotNeedForOutputAndUnusedForRef( TComSubDpb subDpb ); 
390
391  // For printing to std::out
392  Void                   setPrintPicOutput ( Bool printPicOutput ) { m_printPicOutput = printPicOutput; };
393  Void                   print(); 
394
395
396}; 
397
398// END CLASS DEFINITION TComPicLists
399
400#endif
401
402
403//! \}
404
405#endif // __TCOMPIC__
Note: See TracBrowser for help on using the repository browser.