Skip to content
Snippets Groups Projects
Slice.h 142 KiB
Newer Older
  • Learn to ignore specific revisions
  •   APS**          getAPSs() { return &m_apss[0]; }
      ParameterSetMap<APS>* getApsMap() { return &m_apsMap; }
    
      void           storeAPS(APS *aps, const std::vector<uint8_t> &naluData)    { m_apsMap.storePS((aps->getAPSId() << NUM_APS_TYPE_LEN) + aps->getAPSType(), aps, &naluData); };
      APS*           getAPS(int apsId, int apsType)                              { return m_apsMap.getPS((apsId << NUM_APS_TYPE_LEN) + apsType); };
      bool           getAPSChangedFlag(int apsId, int apsType) const             { return m_apsMap.getChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
      void           clearAPSChangedFlag(int apsId, int apsType)                 { m_apsMap.clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
      APS*           getFirstAPS()                                               { return m_apsMap.getFirstPS(); };
      bool           activateAPS(int apsId, int apsType);
    
      const SPS*     getActiveSPS()const                                         { return m_spsMap.getPS(m_activeSPSId); };
    
      const DPS*     getActiveDPS()const                                         { return m_dpsMap.getPS(m_activeDPSId); };
    
    
    protected:
      ParameterSetMap<SPS> m_spsMap;
      ParameterSetMap<PPS> m_ppsMap;
    
    Hendry's avatar
    Hendry committed
      ParameterSetMap<APS> m_apsMap;
    
      ParameterSetMap<DPS> m_dpsMap;
    
      int m_activeDPSId; // -1 for nothing active
    
      int m_activeSPSId; // -1 for nothing active
    };
    
    class PreCalcValues
    {
    public:
      PreCalcValues( const SPS& sps, const PPS& pps, bool _isEncoder )
        : chrFormat           ( sps.getChromaFormatIdc() )
    
    Karsten Suehring's avatar
    Karsten Suehring committed
        , multiBlock422       ( false )
    
        , maxCUWidth          ( sps.getMaxCUWidth() )
        , maxCUHeight         ( sps.getMaxCUHeight() )
        , maxCUWidthMask      ( maxCUWidth  - 1 )
        , maxCUHeightMask     ( maxCUHeight - 1 )
        , maxCUWidthLog2      ( g_aucLog2[ maxCUWidth  ] )
        , maxCUHeightLog2     ( g_aucLog2[ maxCUHeight ] )
        , minCUWidth          ( sps.getMaxCUWidth()  >> sps.getMaxCodingDepth() )
        , minCUHeight         ( sps.getMaxCUHeight() >> sps.getMaxCodingDepth() )
        , minCUWidthLog2      ( g_aucLog2[ minCUWidth  ] )
        , minCUHeightLog2     ( g_aucLog2[ minCUHeight ] )
        , partsInCtuWidth     ( 1 << sps.getMaxCodingDepth() )
        , partsInCtuHeight    ( 1 << sps.getMaxCodingDepth() )
        , partsInCtu          ( 1 << (sps.getMaxCodingDepth() << 1) )
        , widthInCtus         ( (sps.getPicWidthInLumaSamples () + sps.getMaxCUWidth () - 1) / sps.getMaxCUWidth () )
        , heightInCtus        ( (sps.getPicHeightInLumaSamples() + sps.getMaxCUHeight() - 1) / sps.getMaxCUHeight() )
        , sizeInCtus          ( widthInCtus * heightInCtus )
        , lumaWidth           ( sps.getPicWidthInLumaSamples() )
        , lumaHeight          ( sps.getPicHeightInLumaSamples() )
        , fastDeltaQPCuMaxSize( Clip3(sps.getMaxCUHeight() >> (sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u) )
    
    Karsten Suehring's avatar
    Karsten Suehring committed
        , noChroma2x2         (  false )
    
        , ISingleTree         ( !sps.getUseDualITree() )
        , maxBtDepth          { sps.getMaxBTDepthI(), sps.getMaxBTDepth(), sps.getMaxBTDepthIChroma() }
    
        , minBtSize           { 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize() }
    
        , maxBtSize           { sps.getMaxBTSizeI(), sps.getMaxBTSize(), sps.getMaxBTSizeIChroma() }
    
        , minTtSize           { 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize(), 1u << sps.getLog2MinCodingBlockSize() }
    
        , maxTtSize           { sps.getMaxTTSizeI(), sps.getMaxTTSize(), sps.getMaxTTSizeIChroma() }
        , minQtSize           { sps.getMinQTSize(I_SLICE, CHANNEL_TYPE_LUMA), sps.getMinQTSize(B_SLICE, CHANNEL_TYPE_LUMA), sps.getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA) }
    
      {}
    
      const ChromaFormat chrFormat;
      const bool         multiBlock422;
      const unsigned     maxCUWidth;
      const unsigned     maxCUHeight;
      // to get CTU position, use (x & maxCUWidthMask) rather than (x % maxCUWidth)
      const unsigned     maxCUWidthMask;
      const unsigned     maxCUHeightMask;
      const unsigned     maxCUWidthLog2;
      const unsigned     maxCUHeightLog2;
      const unsigned     minCUWidth;
      const unsigned     minCUHeight;
      const unsigned     minCUWidthLog2;
      const unsigned     minCUHeightLog2;
      const unsigned     partsInCtuWidth;
      const unsigned     partsInCtuHeight;
      const unsigned     partsInCtu;
      const unsigned     widthInCtus;
      const unsigned     heightInCtus;
      const unsigned     sizeInCtus;
      const unsigned     lumaWidth;
      const unsigned     lumaHeight;
      const unsigned     fastDeltaQPCuMaxSize;
      const bool         noChroma2x2;
      const bool         isEncoder;
      const bool         ISingleTree;
    
    private:
      const unsigned     maxBtDepth[3];
      const unsigned     minBtSize [3];
      const unsigned     maxBtSize [3];
      const unsigned     minTtSize [3];
      const unsigned     maxTtSize [3];
      const unsigned     minQtSize [3];
    
      unsigned getValIdx    ( const Slice &slice, const ChannelType chType ) const;
    
    public:
      unsigned getMaxBtDepth( const Slice &slice, const ChannelType chType ) const;
      unsigned getMinBtSize ( const Slice &slice, const ChannelType chType ) const;
      unsigned getMaxBtSize ( const Slice &slice, const ChannelType chType ) const;
      unsigned getMinTtSize ( const Slice &slice, const ChannelType chType ) const;
      unsigned getMaxTtSize ( const Slice &slice, const ChannelType chType ) const;
      unsigned getMinQtSize ( const Slice &slice, const ChannelType chType ) const;
    };
    
    #if ENABLE_TRACING
    void xTraceVPSHeader();
    
    void xTraceDPSHeader();
    
    void xTraceAPSHeader();
    
    void xTraceSliceHeader();
    void xTraceAccessUnitDelimiter();
    #endif
    
    #endif // __SLICE__