
/** \file     TEncCfg.h
    \brief    encoder configuration class (header)
*/

#ifndef __TENCCFG__
#define __TENCCFG__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "../TLibCommon/CommonDef.h"
#include "TEncSeqStructure.h"
#include <assert.h>

#include <vector>

// ====================================================================================================================
// Class definition
// ====================================================================================================================

/// encoder configuration class
class TEncCfg
{
protected:
  //==== File I/O ========
  Int       m_iFrameRate;
  Int       m_FrameSkip;
  Int       m_iSourceWidth;
  Int       m_iSourceHeight;
  Int       m_iFrameToBeEncoded;

  //====== Coding Structure ========
#if DCM_DECODING_REFRESH
  UInt      m_uiDecodingRefreshType;            ///< the type of decoding refresh employed for the random access.
#endif

  UInt      m_uiCodedPictureStoreSize ;
  Int       m_iGOPSize;
  Int       m_iRateGOPSize;

  // SB
  std::string     m_cInputFormatString ;

  Int       m_iQP;                              //  if (AdaptiveQP == OFF)

  Int       m_aiTLayerQPOffset[MAX_TLAYER];
  Int       m_aiPad[2];

  //======= Transform =============
  UInt      m_uiQuadtreeTULog2MaxSize;
  UInt      m_uiQuadtreeTULog2MinSize;
  UInt      m_uiQuadtreeTUMaxDepthInter;
  UInt      m_uiQuadtreeTUMaxDepthIntra;

  //====== B Slice ========

  //====== Entropy Coding ========
  Int       m_iSymbolMode;                      //  (CAVLC, CABAC)

  //====== Loop/Deblock Filter ========
  Bool      m_bLoopFilterDisable;
  Int       m_iLoopFilterAlphaC0Offset;
  Int       m_iLoopFilterBetaOffset;

#if MTK_SAO
  Bool      m_bUseSAO;
#endif

  //====== Motion search ========
  Int       m_iFastSearch;                      //  0:Full search  1:Diamond  2:PMVFAST
  Int       m_iSearchRange;                     //  0:Full frame
  Int       m_bipredSearchRange;
  Int       m_iMaxDeltaQP;                      //  Max. absolute delta QP (1:default)

//GT VSO
  //====== View Synthesis Optimization ======
  Bool      m_bForceLambdaScale;
#if RDO_DIST_INT
  Bool      m_bAllowNegDist;
#endif
  Double    m_dLambdaScaleVSO;
  UInt      m_uiVSOMode;
//GT VSO end

  //====== Tool list ========
  Bool      m_bUseSBACRD;
  Bool      m_bUseALF;
#if MQT_ALF_NPASS
  Int       m_iALFEncodePassReduction;
#endif
  Bool      m_bUseASR;
  Bool      m_bUseHADME;
#if DCM_COMB_LIST
  Bool      m_bUseLComb;
  Bool      m_bLCMod;
#endif
  Bool      m_bUseRDOQ;
#if !SB_NO_LowDelayCoding
  Bool      m_bUseLDC;
#endif
  Bool      m_bUsePAD;
  Bool      m_bUseFastEnc;

//GT VSO
  Bool      m_bUseVSO;
//GT VSO end

  Bool      m_bOmitUnusedBlocks;
  Bool      m_bUseMRG; // SOPH:
#if LM_CHROMA
  Bool      m_bUseLMChroma;
#endif

  Int*      m_aidQP;
  UInt      m_uiDeltaQpRD;

#if HHI_RMP_SWITCH
  Bool      m_bUseRMP;
#endif
#ifdef ROUNDING_CONTROL_BIPRED
  Bool m_useRoundingControlBipred;
#endif
#if CONSTRAINED_INTRA_PRED
  Bool      m_bUseConstrainedIntraPred;
#endif
#if HHI_DMM_INTRA
  Bool m_bUseDepthModelModes;
#endif
  Bool m_bUseMVI;

  //====== Slice ========
  Int       m_iSliceMode;
  Int       m_iSliceArgument;
  //====== Entropy Slice ========
  Int       m_iEntropySliceMode;
  Int       m_iEntropySliceArgument;
#if MTK_NONCROSS_INLOOP_FILTER
  Bool      m_bLFCrossSliceBoundaryFlag;
#endif

  bool m_pictureDigestEnabled; ///< enable(1)/disable(0) md5 computation and SEI signalling

#ifdef WEIGHT_PRED
  //====== Weighted Prediction ========
  Bool      m_bUseWeightPred;       // Use of Weighting Prediction (P_SLICE)
  UInt      m_uiBiPredIdc;          // Use of Bi-Directional Weighting Prediction (B_SLICE)
#endif

  TEncSeqStructure m_cSequenceStructure;
  //std::vector<int>  m_aiLayerQPOffset;

  UInt        m_uiViewId;
  Int         m_iViewOrderIdx;
  Bool        m_bIsDepth;
  UInt        m_uiCamParPrecision;
  Bool        m_bCamParInSliceHeader;
  Int**       m_aaiCodedScale;
  Int**       m_aaiCodedOffset;

  UInt        m_uiPredDepthMapGeneration;
  UInt        m_uiMultiviewMvPredMode;
  UInt        m_uiPdmPrecision;
  Int**       m_aaiPdmScaleNomDelta;
  Int**       m_aaiPdmOffset;
  UInt        m_uiMultiviewMvRegMode;
  Double      m_dMultiviewMvRegLambdaScale;
  UInt        m_uiMultiviewResPredMode;

  PicOrderCnt m_iQpChangeFrame;
  Int         m_iQpChangeOffsetVideo;
  Int         m_iQpChangeOffsetDepth;
#if SB_INTERVIEW_SKIP
  UInt        m_uiInterViewSkip;
#if SB_INTERVIEW_SKIP_LAMBDA_SCALE
  Double      m_dInterViewSkipLambdaScale;
#endif
#endif

public:
  TEncCfg()          {}
  virtual ~TEncCfg() {}

  Void      setFrameRate                    ( Int   i )      { m_iFrameRate = i; }
  Void      setFrameSkip                    ( unsigned int i ) { m_FrameSkip = i; }
  Void      setSourceWidth                  ( Int   i )      { m_iSourceWidth = i; }
  Void      setSourceHeight                 ( Int   i )      { m_iSourceHeight = i; }
  Void      setFrameToBeEncoded             ( Int   i )      { m_iFrameToBeEncoded = i; }

  //====== Coding Structure ========
#if DCM_DECODING_REFRESH
  Void      setDecodingRefreshType          ( Int   i )      { m_uiDecodingRefreshType = (UInt)i; }
#endif
  Void      setCPSSize                      ( Int   i )      { m_uiCodedPictureStoreSize = (UInt) i ;}
  Void      setGOPSize                      ( Int   i )      { m_iGOPSize = i; }
  Void      setRateGOPSize                  ( Int   i )      { m_iRateGOPSize = i; }

  Void      setViewId                       ( UInt  u )      { m_uiViewId               = u; }
  Void      setViewOrderIdx                 ( Int   i )      { m_iViewOrderIdx          = i; }
  Void      setIsDepth                      ( Bool  b )      { m_bIsDepth               = b; }
  Void      setCamParPrecision              ( UInt  u )      { m_uiCamParPrecision      = u; }
  Void      setCamParInSliceHeader          ( Bool  b )      { m_bCamParInSliceHeader   = b; }
  Void      setCodedScale                   ( Int** p )      { m_aaiCodedScale          = p; }
  Void      setCodedOffset                  ( Int** p )      { m_aaiCodedOffset         = p; }

  Void      setPredDepthMapGeneration       ( UInt  u )      { m_uiPredDepthMapGeneration   = u; }
  Void      setMultiviewMvPredMode          ( UInt  u )      { m_uiMultiviewMvPredMode      = u; }
  Void      setPdmPrecision                 ( UInt  u )      { m_uiPdmPrecision             = u; }
  Void      setPdmScaleNomDelta             ( Int** p )      { m_aaiPdmScaleNomDelta        = p; }
  Void      setPdmOffset                    ( Int** p )      { m_aaiPdmOffset               = p; }
  Void      setMultiviewMvRegMode           ( UInt  u )      { m_uiMultiviewMvRegMode       = u; }
  Void      setMultiviewMvRegLambdaScale    ( Double d)      { m_dMultiviewMvRegLambdaScale = d; }
  Void      setMultiviewResPredMode         ( UInt  u )      { m_uiMultiviewResPredMode     = u; }

#if SB_INTERVIEW_SKIP
  Void      setInterViewSkip            ( UInt  u )       { m_uiInterViewSkip         = u; }
  Bool      getInterViewSkip            ( )       { return bool(m_uiInterViewSkip) ;}
#if SB_INTERVIEW_SKIP_LAMBDA_SCALE
  Void      setInterViewSkipLambdaScale ( UInt  u )       { m_dInterViewSkipLambdaScale = u; }
  Double      getInterViewSkipLambdaScale ()                { return m_dInterViewSkipLambdaScale; }
#endif
#endif

  Bool      isDepthCoder                    ()               { return m_bIsDepth; }

  Void      setSeqStructure( std::string s )                 { m_cSequenceStructure.init( s ); }

  Void      setQP                           ( Int   i )      { m_iQP = i; }

  Void      setTemporalLayerQPOffset        ( Int*  piTemporalLayerQPOffset )      { for ( Int i = 0; i < MAX_TLAYER; i++ ) m_aiTLayerQPOffset[i] = piTemporalLayerQPOffset[i]; }
  Void      setPad                          ( Int*  iPad                   )      { for ( Int i = 0; i < 2; i++ ) m_aiPad[i] = iPad[i]; }

  //======== Transform =============
  Void      setQuadtreeTULog2MaxSize        ( UInt  u )      { m_uiQuadtreeTULog2MaxSize = u; }
  Void      setQuadtreeTULog2MinSize        ( UInt  u )      { m_uiQuadtreeTULog2MinSize = u; }
  Void      setQuadtreeTUMaxDepthInter      ( UInt  u )      { m_uiQuadtreeTUMaxDepthInter = u; }
  Void      setQuadtreeTUMaxDepthIntra      ( UInt  u )      { m_uiQuadtreeTUMaxDepthIntra = u; }

  //====== b; Slice ========

  //====== Entropy Coding ========
  Void      setSymbolMode                   ( Int   i )      { m_iSymbolMode = i; }

  //====== Loop/Deblock Filter ========
  Void      setLoopFilterDisable            ( Bool  b )      { m_bLoopFilterDisable       = b; }
  Void      setLoopFilterAlphaC0Offset      ( Int   i )      { m_iLoopFilterAlphaC0Offset = i; }
  Void      setLoopFilterBetaOffset         ( Int   i )      { m_iLoopFilterBetaOffset    = i; }

  //====== Motion search ========
  Void      setFastSearch                   ( Int   i )      { m_iFastSearch = i; }
  Void      setSearchRange                  ( Int   i )      { m_iSearchRange = i; }
  Void      setBipredSearchRange            ( Int   i )      { m_bipredSearchRange = i; }
  Void      setMaxDeltaQP                   ( Int   i )      { m_iMaxDeltaQP = i; }

//GT VSO
 //==== VSO  ==========
  Void      setVSOMode                      ( UInt  ui )    { m_uiVSOMode   = ui; }
  Void      setForceLambdaScaleVSO          ( Bool  b )     { m_bForceLambdaScale = b; };
  Void      setLambdaScaleVSO               ( Double d )    { m_dLambdaScaleVSO   = d; };
#if RDO_DIST_INT
  Void      setAllowNegDist                 ( Bool b  )     { m_bAllowNegDist     = b; };
#endif
//GT VSO end

  //====== Sequence ========
  Int       getFrameRate                    ()      { return  m_iFrameRate; }
  unsigned int getFrameSkip                 ()      { return  m_FrameSkip; }
  Int       getSourceWidth                  ()      { return  m_iSourceWidth; }
  Int       getSourceHeight                 ()      { return  m_iSourceHeight; }
  Int       getFrameToBeEncoded             ()      { return  m_iFrameToBeEncoded; }

  //==== Coding Structure ========
#if DCM_DECODING_REFRESH
  UInt      getDecodingRefreshType          ()      { return  m_uiDecodingRefreshType; }
#endif
  UInt getCodedPictureBufferSize            ()      { return m_uiCodedPictureStoreSize ;}

  Int       getGOPSize                      ()      { return  m_iGOPSize; }
  Int       getRateGOPSize                  ()      { return  m_iRateGOPSize; }

  Int       getQP                           ()      { return  m_iQP; }

  Int       getTemporalLayerQPOffset        ( Int i )      { assert (i < MAX_TLAYER ); return  m_aiTLayerQPOffset[i]; }
  Int       getPad                          ( Int i )      { assert (i < 2 );                      return  m_aiPad[i]; }

  //======== Transform =============
  UInt      getQuadtreeTULog2MaxSize        ()      const { return m_uiQuadtreeTULog2MaxSize; }
  UInt      getQuadtreeTULog2MinSize        ()      const { return m_uiQuadtreeTULog2MinSize; }
  UInt      getQuadtreeTUMaxDepthInter      ()      const { return m_uiQuadtreeTUMaxDepthInter; }
  UInt      getQuadtreeTUMaxDepthIntra      ()      const { return m_uiQuadtreeTUMaxDepthIntra; }

  //==== b; Slice ========

  //==== Entropy Coding ========
  Int       getSymbolMode                   ()      { return  m_iSymbolMode; }

  //==== Loop/Deblock Filter ========
  Bool      getLoopFilterDisable            ()      { return  m_bLoopFilterDisable;       }
  Int       getLoopFilterAlphaC0Offget      ()      { return  m_iLoopFilterAlphaC0Offset; }
  Int       getLoopFilterBetaOffget         ()      { return  m_iLoopFilterBetaOffset;    }

  //==== Motion search ========
  Int       getFastSearch                   ()      { return  m_iFastSearch; }
  Int       getSearchRange                  ()      { return  m_iSearchRange; }
  Int       getMaxDeltaQP                   ()      { return  m_iMaxDeltaQP; }

  UInt      getMultiviewMvRegMode           ()      { return  m_uiMultiviewMvRegMode; }
  Double    getMultiviewMvRegLambdaScale    ()      { return  m_dMultiviewMvRegLambdaScale; }

//GT VSO
  //==== VSO  ==========
  UInt      getVSOMode                      ()      { return m_uiVSOMode; }
  Bool      getForceLambdaScaleVSO          ()      { return m_bForceLambdaScale; }
  Double    getLambdaScaleVSO               ()      { return m_dLambdaScaleVSO;   }
#if RDO_DIST_INT
  Bool      getAllowNegDist                 ()      { return m_bAllowNegDist;     }
#endif

//GT VSO end

  //==== Tool list ========
  Void      setUseSBACRD                    ( Bool  b )     { m_bUseSBACRD  = b; }
  Void      setUseASR                       ( Bool  b )     { m_bUseASR     = b; }
  Void      setUseHADME                     ( Bool  b )     { m_bUseHADME   = b; }
  Void      setUseALF                       ( Bool  b )     { m_bUseALF   = b; }
#if DCM_COMB_LIST
  Void      setUseLComb                     ( Bool  b )     { m_bUseLComb   = b; }
  Void      setLCMod                        ( Bool  b )     { m_bLCMod   = b;    }
#endif
  Void      setUseRDOQ                      ( Bool  b )     { m_bUseRDOQ    = b; }
#if !SB_NO_LowDelayCoding
  Void      setUseLDC                       ( Bool  b )     { m_bUseLDC     = b; }
#endif
  Void      setUsePAD                       ( Bool  b )     { m_bUsePAD     = b; }
  Void      setUseFastEnc                   ( Bool  b )     { m_bUseFastEnc = b; }
  //GT VSO
  Void      setUseVSO                       ( Bool  b )     { m_bUseVSO     = b; }
  //GT VSO end
  Void      setUseMRG                       ( Bool  b )     { m_bUseMRG     = b; } // SOPH:
#if CONSTRAINED_INTRA_PRED
  Void      setUseConstrainedIntraPred      ( Bool  b )     { m_bUseConstrainedIntraPred = b; }
#endif
  Void      setdQPs                         ( Int*  p )     { m_aidQP       = p; }
  Void      setDeltaQpRD                    ( UInt  u )     {m_uiDeltaQpRD  = u; }

  Void      setOmitUnusedBlocks             ( Bool b )       { m_bOmitUnusedBlocks = b; }

  Bool      getUseSBACRD                    ()      { return m_bUseSBACRD;  }
  Bool      getUseASR                       ()      { return m_bUseASR;     }
  Bool      getUseHADME                     ()      { return m_bUseHADME;   }
  Bool      getUseALF                       ()      { return m_bUseALF;     }
#if MQT_ALF_NPASS
  Void      setALFEncodePassReduction       (Int i)  { m_iALFEncodePassReduction = i; }
  Int       getALFEncodePassReduction       ()       { return m_iALFEncodePassReduction; }
#endif
#if DCM_COMB_LIST
  Bool      getUseLComb                     ()      { return m_bUseLComb;   }
  Bool      getLCMod                        ()      { return m_bLCMod; }
#endif
  Bool      getUseRDOQ                      ()      { return m_bUseRDOQ;    }
#if !SB_NO_LowDelayCoding
  Bool      getUseLDC                       ()      { return m_bUseLDC;     }
#endif
  Bool      getUsePAD                       ()      { return m_bUsePAD;     }
  Bool      getUseFastEnc                   ()      { return m_bUseFastEnc; }

//GT VSO
  Bool      getUseVSO                       ()      { return m_bUseVSO;     }
//GT VSO end
  Bool      getUseMRG                       ()      { return m_bUseMRG;     } // SOPH:
#if CONSTRAINED_INTRA_PRED
  Bool      getUseConstrainedIntraPred      ()      { return m_bUseConstrainedIntraPred; }
#endif
#if HHI_DMM_INTRA
  Void setUseDepthModelModes( Bool b) { m_bUseDepthModelModes = b;    }
  Bool getUseDepthModelModes()        { return m_bUseDepthModelModes; }
#endif

  Bool getOmitUnusedBlocks             ()      { return m_bOmitUnusedBlocks; }

#if LM_CHROMA
  Bool getUseLMChroma                       ()      { return m_bUseLMChroma;        }
  Void setUseLMChroma                       ( Bool b ) { m_bUseLMChroma  = b;       }
#endif

  Int*      getdQPs                         ()      { return m_aidQP;       }
  UInt      getDeltaQpRD                    ()      { return m_uiDeltaQpRD; }
#if HHI_RMP_SWITCH
  Void      setUseRMP                      ( Bool b ) { m_bUseRMP = b; }
  Bool      getUseRMP                      ()      {return m_bUseRMP; }
#endif
#ifdef ROUNDING_CONTROL_BIPRED
  Void setUseRoundingControlBipred(Bool b) { m_useRoundingControlBipred = b; }
  Bool getUseRoundingControlBipred() { return m_useRoundingControlBipred; }
#endif
  //====== Slice ========
  Void  setSliceMode                   ( Int  i )       { m_iSliceMode = i;              }
  Void  setSliceArgument               ( Int  i )       { m_iSliceArgument = i;          }
  Int   getSliceMode                   ()              { return m_iSliceMode;           }
  Int   getSliceArgument               ()              { return m_iSliceArgument;       }
  //====== Entropy Slice ========
  Void  setEntropySliceMode            ( Int  i )      { m_iEntropySliceMode = i;       }
  Void  setEntropySliceArgument        ( Int  i )      { m_iEntropySliceArgument = i;   }
  Int   getEntropySliceMode            ()              { return m_iEntropySliceMode;    }
  Int   getEntropySliceArgument        ()              { return m_iEntropySliceArgument;}
#if MTK_NONCROSS_INLOOP_FILTER
  Void      setLFCrossSliceBoundaryFlag     ( Bool   bValue  )    { m_bLFCrossSliceBoundaryFlag = bValue; }
  Bool      getLFCrossSliceBoundaryFlag     ()                    { return m_bLFCrossSliceBoundaryFlag;   }
#endif
#if MTK_SAO
  Void      setUseSAO                  (Bool bVal)     {m_bUseSAO = bVal;}
  Bool      getUseSAO                  ()              {return m_bUseSAO;}
#endif
  Void      setUseMVI                  (Bool bVal)     {m_bUseMVI = bVal;}

  void setPictureDigestEnabled(bool b) { m_pictureDigestEnabled = b; }
  bool getPictureDigestEnabled() { return m_pictureDigestEnabled; }

#ifdef WEIGHT_PRED
  Void      setUseWP                        ( Bool  b )   { m_bUseWeightPred    = b;    }
  Void      setWPBiPredIdc                  ( UInt u )    { m_uiBiPredIdc       = u;    }
  Bool      getUseWP                        ()            { return m_bUseWeightPred;    }
  UInt      getWPBiPredIdc                  ()            { return m_uiBiPredIdc;       }
#endif

  Void setQpChangeFrame( PicOrderCnt iPoc ) { m_iQpChangeFrame = iPoc; }
  Int  getQpChangeFrame() { return (Int)m_iQpChangeFrame; }
  Void setQpChangeOffsetVideo( Int iOffset ) { m_iQpChangeOffsetVideo = iOffset; }
  Int  getQpChangeOffsetVideo() { return m_iQpChangeOffsetVideo; }
  Void setQpChangeOffsetDepth( Int iOffset ) { m_iQpChangeOffsetDepth = iOffset; }
  Int  getQpChangeOffsetDepth() { return m_iQpChangeOffsetDepth; }
};

#endif // !defined(AFX_TENCCFG_H__6B99B797_F4DA_4E46_8E78_7656339A6C41__INCLUDED_)

