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-2014, 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     TComPicSym.h
35     \brief    picture symbol class (header)
36 */
37 
38 #ifndef __TCOMPICSYM__
39 #define __TCOMPICSYM__
40 
41 
42 // Include files
43 #include "CommonDef.h"
44 #include "TComSlice.h"
45 #include "TComDataCU.h"
46 class TComSampleAdaptiveOffset;
47 class TComPPS;
48 
49 //! \ingroup TLibCommon
50 //! \{
51 
52 // ====================================================================================================================
53 // Class definition
54 // ====================================================================================================================
55 
56 class TComTile
57 {
58 private:
59   UInt      m_tileWidthInCtus;
60   UInt      m_tileHeightInCtus;
61   UInt      m_rightEdgePosInCtus;
62   UInt      m_bottomEdgePosInCtus;
63   UInt      m_firstCtuRsAddr;
64 
65 public:
66   TComTile();
67   virtual ~TComTile();
68 
setTileWidthInCtus(UInt i)69   Void      setTileWidthInCtus     ( UInt i )            { m_tileWidthInCtus = i; }
getTileWidthInCtus()70   UInt      getTileWidthInCtus     () const              { return m_tileWidthInCtus; }
setTileHeightInCtus(UInt i)71   Void      setTileHeightInCtus    ( UInt i )            { m_tileHeightInCtus = i; }
getTileHeightInCtus()72   UInt      getTileHeightInCtus    () const              { return m_tileHeightInCtus; }
setRightEdgePosInCtus(UInt i)73   Void      setRightEdgePosInCtus  ( UInt i )            { m_rightEdgePosInCtus = i; }
getRightEdgePosInCtus()74   UInt      getRightEdgePosInCtus  () const              { return m_rightEdgePosInCtus; }
setBottomEdgePosInCtus(UInt i)75   Void      setBottomEdgePosInCtus ( UInt i )            { m_bottomEdgePosInCtus = i; }
getBottomEdgePosInCtus()76   UInt      getBottomEdgePosInCtus () const              { return m_bottomEdgePosInCtus; }
setFirstCtuRsAddr(UInt i)77   Void      setFirstCtuRsAddr      ( UInt i )            { m_firstCtuRsAddr = i; }
getFirstCtuRsAddr()78   UInt      getFirstCtuRsAddr      () const              { return m_firstCtuRsAddr; }
79 };
80 
81 /// picture symbol class
82 class TComPicSym
83 {
84 private:
85   UInt          m_frameWidthInCtus;
86   UInt          m_frameHeightInCtus;
87 
88   UInt          m_uiMaxCUWidth;
89   UInt          m_uiMaxCUHeight;
90   UInt          m_uiMinCUWidth;
91   UInt          m_uiMinCUHeight;
92 
93   UChar         m_uhTotalDepth;       ///< max. depth
94   UInt          m_numPartitionsInCtu;
95   UInt          m_numPartInCtuWidth;
96   UInt          m_numPartInCtuHeight;
97   UInt          m_numCtusInFrame;
98 
99   TComSlice**   m_apcTComSlice;
100   UInt          m_uiNumAllocatedSlice;
101   TComDataCU**  m_pictureCtuArray;        ///< array of CU data.
102 
103   Int           m_numTileColumnsMinus1;
104   Int           m_numTileRowsMinus1;
105   std::vector<TComTile> m_tileParameters;
106   UInt*         m_ctuTsToRsAddrMap;    ///< for a given TS (Tile-Scan; coding order) address, returns the RS (Raster-Scan) address. cf CtbAddrTsToRs in specification.
107   UInt*         m_puiTileIdxMap;       ///< the map of the tile index relative to CTU raster scan address
108   UInt*         m_ctuRsToTsAddrMap;    ///< for a given RS (Raster-Scan) address, returns the TS (Tile-Scan; coding order) address. cf CtbAddrRsToTs in specification.
109 
110   SAOBlkParam *m_saoBlkParams;
111 
112 public:
113   Void               create  ( ChromaFormat chromaFormatIDC, Int iPicWidth, Int iPicHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth );
114   Void               destroy ();
115 
116   TComPicSym  ();
getSlice(UInt i)117   TComSlice*         getSlice(UInt i)                                      { return m_apcTComSlice[i];             }
getSlice(UInt i)118   const TComSlice*   getSlice(UInt i) const                                { return m_apcTComSlice[i];             }
getFrameWidthInCtus()119   UInt               getFrameWidthInCtus() const                           { return m_frameWidthInCtus;            }
getFrameHeightInCtus()120   UInt               getFrameHeightInCtus() const                          { return m_frameHeightInCtus;           }
getMinCUWidth()121   UInt               getMinCUWidth() const                                 { return m_uiMinCUWidth;                }
getMinCUHeight()122   UInt               getMinCUHeight() const                                { return m_uiMinCUHeight;               }
getNumberOfCtusInFrame()123   UInt               getNumberOfCtusInFrame() const                        { return m_numCtusInFrame;              }
getCtu(UInt ctuRsAddr)124   TComDataCU*        getCtu( UInt ctuRsAddr )                              { return m_pictureCtuArray[ctuRsAddr];  }
getCtu(UInt ctuRsAddr)125   const TComDataCU*  getCtu( UInt ctuRsAddr ) const                        { return m_pictureCtuArray[ctuRsAddr];  }
126 
setSlice(TComSlice * p,UInt i)127   Void               setSlice(TComSlice* p, UInt i)                        { m_apcTComSlice[i] = p;           }
getNumAllocatedSlice()128   UInt               getNumAllocatedSlice() const                          { return m_uiNumAllocatedSlice;         }
129   Void               allocateNewSlice();
130   Void               clearSliceBuffer();
getNumPartitionsInCtu()131   UInt               getNumPartitionsInCtu() const                         { return m_numPartitionsInCtu;   }
getNumPartInCtuWidth()132   UInt               getNumPartInCtuWidth() const                          { return m_numPartInCtuWidth;    }
getNumPartInCtuHeight()133   UInt               getNumPartInCtuHeight() const                         { return m_numPartInCtuHeight;   }
setNumTileColumnsMinus1(Int i)134   Void               setNumTileColumnsMinus1( Int i )                      { m_numTileColumnsMinus1 = i;    }
getNumTileColumnsMinus1()135   Int                getNumTileColumnsMinus1() const                       { return m_numTileColumnsMinus1; }
setNumTileRowsMinus1(Int i)136   Void               setNumTileRowsMinus1( Int i )                         { m_numTileRowsMinus1 = i;       }
getNumTileRowsMinus1()137   Int                getNumTileRowsMinus1() const                          { return m_numTileRowsMinus1;    }
getNumTiles()138   Int                getNumTiles() const                                   { return (m_numTileRowsMinus1+1)*(m_numTileColumnsMinus1+1); }
getTComTile(UInt tileIdx)139   TComTile*          getTComTile  ( UInt tileIdx )                         { return &(m_tileParameters[tileIdx]); }
getTComTile(UInt tileIdx)140   const TComTile*    getTComTile  ( UInt tileIdx ) const                   { return &(m_tileParameters[tileIdx]); }
setCtuTsToRsAddrMap(Int ctuTsAddr,Int ctuRsAddr)141   Void               setCtuTsToRsAddrMap( Int ctuTsAddr, Int ctuRsAddr )   { *(m_ctuTsToRsAddrMap + ctuTsAddr) = ctuRsAddr; }
getCtuTsToRsAddrMap(Int ctuTsAddr)142   UInt               getCtuTsToRsAddrMap( Int ctuTsAddr ) const            { return *(m_ctuTsToRsAddrMap + (ctuTsAddr>=m_numCtusInFrame ? m_numCtusInFrame : ctuTsAddr)); }
getTileIdxMap(Int ctuRsAddr)143   UInt               getTileIdxMap( Int ctuRsAddr ) const                  { return *(m_puiTileIdxMap + ctuRsAddr); }
setCtuRsToTsAddrMap(Int ctuRsAddr,Int ctuTsOrder)144   Void               setCtuRsToTsAddrMap( Int ctuRsAddr, Int ctuTsOrder )  { *(m_ctuRsToTsAddrMap + ctuRsAddr) = ctuTsOrder; }
getCtuRsToTsAddrMap(Int ctuRsAddr)145   UInt               getCtuRsToTsAddrMap( Int ctuRsAddr ) const            { return *(m_ctuRsToTsAddrMap + (ctuRsAddr>=m_numCtusInFrame ? m_numCtusInFrame : ctuRsAddr)); }
146   Void               initTiles(TComPPS *pps);
147 
148   Void               initCtuTsRsAddrMaps();
getSAOBlkParam()149   SAOBlkParam*       getSAOBlkParam()                                      { return m_saoBlkParams;}
getSAOBlkParam()150   const SAOBlkParam* getSAOBlkParam() const                                { return m_saoBlkParams;}
151   Void               deriveLoopFilterBoundaryAvailibility(Int ctuRsAddr,
152                                                           Bool& isLeftAvail, Bool& isRightAvail, Bool& isAboveAvail, Bool& isBelowAvail,
153                                                           Bool& isAboveLeftAvail, Bool& isAboveRightAvail, Bool& isBelowLeftAvail, Bool& isBelowRightAvail);
154 protected:
155   UInt               xCalculateNextCtuRSAddr( UInt uiCurrCtuRSAddr );
156 
157 };// END CLASS DEFINITION TComPicSym
158 
159 //! \}
160 
161 #endif // __TCOMPICSYM__
162 
163