diff --git a/source/Lib/CommonLib/Buffer.h b/source/Lib/CommonLib/Buffer.h index 1e19e564d77b90c30037384778bbe4814131474b..504ad8bc276f0e8e2a677fd7e15d246aef5f1d6b 100644 --- a/source/Lib/CommonLib/Buffer.h +++ b/source/Lib/CommonLib/Buffer.h @@ -1002,7 +1002,7 @@ struct PelStorage : public PelUnitBuf PelStorage(); ~PelStorage(); - void swap( PelStorage& other ); + void swap( PelStorage& other ); void createFromBuf( PelUnitBuf buf ); void create( const UnitArea &_unit ); void create( const ChromaFormat &_chromaFormat, const Area& _area, const unsigned _maxCUSize = 0, const unsigned _margin = 0, const unsigned _alignment = 0, const bool _scaleChromaMargin = true ); diff --git a/source/Lib/EncoderLib/EncCu.h b/source/Lib/EncoderLib/EncCu.h index 2f1d38c8c8103be4e1a9ea431794bde12d985676..167448c70c54bd14b4cd347ba58225e92184e306 100644 --- a/source/Lib/EncoderLib/EncCu.h +++ b/source/Lib/EncoderLib/EncCu.h @@ -353,6 +353,8 @@ public: **m_pBestCS2 = (**other.m_pBestCS2) ? new CodingStructure(***other.m_pBestCS2) : nullptr; m_pcEncCfg = other.m_pcEncCfg ? new EncCfg(*other.m_pcEncCfg) : nullptr; + + m_pcIntraSearch = other.m_pcIntraSearch ? new IntraSearch(*other.m_pcIntraSearch) : nullptr; ///////////CONTINUAR//////////// } //END ALBERTO diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h index 0904427395252cc1183eb111e934f54b3bf3588e..052b00451c403c162b2d2e2f57117e7c57a368ac 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.h +++ b/source/Lib/EncoderLib/EncModeCtrl.h @@ -48,6 +48,10 @@ #include #include +//ALBERTO +#include "RateCtrl.h" +//END ALBERTO + ////////////////////////////////////////////////////////////////////////// // Encoder modes to try out ////////////////////////////////////////////////////////////////////////// @@ -279,24 +283,68 @@ struct ComprCUCtx class EncModeCtrl { protected: - - const EncCfg *m_pcEncCfg; - const class RateCtrl *m_pcRateCtrl; - class RdCost *m_pcRdCost; - const Slice *m_slice; + const EncCfg* m_pcEncCfg; + const class RateCtrl* m_pcRateCtrl; + class RdCost* m_pcRdCost; + const Slice* m_slice; #if SHARP_LUMA_DELTA_QP - int m_lumaLevelToDeltaQPLUT[LUMA_LEVEL_TO_DQP_LUT_MAXSIZE]; - int m_lumaQPOffset; + int m_lumaLevelToDeltaQPLUT[LUMA_LEVEL_TO_DQP_LUT_MAXSIZE]; + int m_lumaQPOffset; #endif - std::map *m_bimQPMap; - bool m_fastDeltaQP; - static_vector m_ComprCUCtxList; - InterSearch* m_pcInterSearch; + std::map* m_bimQPMap; + bool m_fastDeltaQP; + static_vector m_ComprCUCtxList; + InterSearch* m_pcInterSearch; - bool m_doPlt; + bool m_doPlt; public: + // ALBERTO + EncModeCtrl::EncModeCtrl() + : m_pcEncCfg(nullptr) + , m_pcRateCtrl(nullptr) + , m_pcRdCost(nullptr) + , m_slice(nullptr) + , +#if SHARP_LUMA_DELTA_QP + m_lumaQPOffset(0) + , +#endif + m_bimQPMap(nullptr) + , m_fastDeltaQP(false) + , m_pcInterSearch(nullptr) + , m_doPlt(false) + {} + + EncModeCtrl(const EncModeCtrl& other) + { + m_pcEncCfg = other.m_pcEncCfg ? new EncCfg(*other.m_pcEncCfg) : nullptr; + m_pcRateCtrl = other.m_pcRateCtrl ? new class RateCtrl(*other.m_pcRateCtrl) : nullptr; + m_pcRdCost = other.m_pcRdCost ? new RdCost(*other.m_pcRdCost) : nullptr; + m_slice = other.m_slice ? new Slice(*other.m_slice) : nullptr; + + for (int i = 0; i < LUMA_LEVEL_TO_DQP_LUT_MAXSIZE; i++) + { + m_lumaLevelToDeltaQPLUT[i] = other.m_lumaLevelToDeltaQPLUT[i]; + } + m_lumaQPOffset = other.m_lumaQPOffset; + + m_bimQPMap = new std::map; + *m_bimQPMap = *other.m_bimQPMap; + for (auto& pair: *m_bimQPMap) + { + int* value = pair.second; + int* copy = new int(*value); + pair.second = copy; + } + + m_fastDeltaQP = other.m_fastDeltaQP; + m_ComprCUCtxList = other.m_ComprCUCtxList; + m_pcInterSearch = other.m_pcInterSearch ? new InterSearch(*other.m_pcInterSearch) : nullptr; + m_doPlt = other.m_doPlt; + } + //END ALBERTO virtual ~EncModeCtrl () {} virtual void create ( const EncCfg& cfg ) = 0; @@ -911,6 +959,34 @@ class EncModeCtrlMTnoRQT : public EncModeCtrl, public CacheBlkInfoCtrl #endif public: + //ALBERTO +// EncModeCtrlMTnoRQT() : EncModeCtrl(), CacheBlkInfoCtrl() +//#if REUSE_CU_RESULTS +// , BestEncInfoCache() +//#endif +// , SaveLoadEncInfoSbt() +// { +// m_skipThreshold = unsigned(); +// m_encCfg = EncCfg(); +// } +// +// EncModeCtrlMTnoRQT(const EncModeCtrlMTnoRQT& other) +// : EncModeCtrl(other) +// , CacheBlkInfoCtrl(other) +// , +//#if REUSE_CU_RESULTS +// BestEncInfoCache(other) +// , +//#endif +// SaveLoadEncInfoSbt(other) +// { +// m_skipThreshold = unsigned(other.m_skipThreshold); +//#if GDR_ENABLED +// m_encCfg = EncCfg(other.m_encCfg); +//#endif +// } + + //END ALBERTO virtual void create ( const EncCfg& cfg ); virtual void destroy (); diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index 9e12c55736d83ed282737a2396ae500df50e32b1..a603844e48941c0ded86d2e9c0b0d407a9e1d2bf 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -48,6 +48,9 @@ #include "CommonLib/Unit.h" #include "CommonLib/RdCost.h" #include "EncReshape.h" +//ALBERTO +#include "EncModeCtrl.h" +//END ALBERTO //! \ingroup EncoderLib //! \{ @@ -219,8 +222,12 @@ private: ModeInfo() : mipFlg(false), mipTrFlg(false), mRefId(0), ispMod(ISPType::NONE), modeId(0) {} ModeInfo(const bool mipf, const bool miptf, const int mrid, const ISPType ispm, const uint32_t mode) : mipFlg(mipf), mipTrFlg(miptf), mRefId(mrid), ispMod(ispm), modeId(mode) - { - } + {} + //ALBERTO + ModeInfo(const ModeInfo& other) + : mipFlg(other.mipFlg), mipTrFlg(other.mipTrFlg), mRefId(other.mRefId), ispMod(other.ispMod), modeId(other.modeId) + {} + //END ALBERTO bool operator==(const ModeInfo cmp) const { return (mipFlg == cmp.mipFlg && mipTrFlg == cmp.mipTrFlg && mRefId == cmp.mRefId && ispMod == cmp.ispMod && modeId == cmp.modeId); } }; @@ -408,7 +415,138 @@ protected: int m_prevRunPosRDOQ [2][NUM_TRELLIS_STATE]; double m_stateCostRDOQ [2][NUM_TRELLIS_STATE]; public: + //ALBERTO + IntraSearch(const IntraSearch& other) : IntraPrediction(other) + { + EncModeCtrlMTnoRQT* pointer = (dynamic_cast(other.m_modeCtrl)); + m_modeCtrl = other.m_modeCtrl ? new EncModeCtrlMTnoRQT(*pointer) : nullptr; //REVISAR M_MODE_CTRL COMPLETO ANTES DE CONTINUAR///////////////////////////////////////////////////////////////// + for (int i = 0; i < MAX_NUM_TBLOCKS; i++) + { + m_pSharedPredTransformSkip[i] = other.m_pSharedPredTransformSkip[i] ? new Pel(*other.m_pSharedPredTransformSkip[i]) : nullptr; + } + m_unitPool = XuPool(other.m_unitPool); + + m_pSplitCS = new CodingStructure***(); + *m_pSplitCS = new CodingStructure**(); + **m_pSplitCS = new CodingStructure*(); + ***m_pSplitCS = *other.m_pSplitCS && **other.m_pSplitCS && ***other.m_pSplitCS ? new CodingStructure(****other.m_pSplitCS) : nullptr; + + m_pFullCS = new CodingStructure***(); + *m_pFullCS = new CodingStructure**(); + **m_pFullCS = new CodingStructure*(); + ***m_pFullCS = *other.m_pFullCS && **other.m_pFullCS && ***other.m_pFullCS ? new CodingStructure(****other.m_pFullCS) : nullptr; + + m_pTempCS = new CodingStructure**(); + *m_pTempCS = new CodingStructure*(); + **m_pTempCS = *other.m_pTempCS && **other.m_pTempCS ? new CodingStructure(***other.m_pTempCS) : nullptr; + + m_pBestCS = new CodingStructure**(); + *m_pBestCS = new CodingStructure*(); + **m_pBestCS = *other.m_pBestCS && **other.m_pBestCS ? new CodingStructure(***other.m_pBestCS) : nullptr; + + m_pSaveCS = new CodingStructure*(); + *m_pSaveCS = *other.m_pSaveCS ? new CodingStructure(**other.m_pSaveCS) : nullptr; + + m_saveCuCostInSCIPU = other.m_numCuInSCIPU; + + for (int i = 0; i < NUM_INTER_CU_INFO_SAVE; i++) + { + m_cuAreaInSCIPU[i] = Area(m_cuAreaInSCIPU[i]); + m_cuCostInSCIPU[i] = double(m_cuCostInSCIPU[i]); + } + + for (int i = 0; i < other.m_ispCandList.size(); i++) + { + ISPType ispType = static_cast(i); + static_vector vecCopy; + for (int j = 0; j < other.m_ispCandList[ispType].size(); j++) + { + vecCopy.push_back(ModeInfo(other.m_ispCandList[ispType][j])); + } + m_ispCandList[ispType] = vecCopy; + } + m_regIntraRDListWithCosts = other.m_regIntraRDListWithCosts; + + for (int i = 0; i < NUM_LFNST_NUM_PER_SET; i++) + { + m_ispTestedModes[i] = ISPTestedModesInfo(other.m_ispTestedModes[i]); + } + m_curIspLfnstIdx = other.m_curIspLfnstIdx; + for (int i = 0; i < NUM_LFNST_NUM_PER_SET; i++) + { + m_bestModeCostStore[i] = other.m_bestModeCostStore[i]; + m_bestModeCostValid[i] = other.m_bestModeCostValid[i]; + for (int j = 0; j < NUM_LUMA_MODE; j++) + { + m_modeCostStore[i][j] = other.m_modeCostStore[i][j]; + m_savedRdModeList[i][j] = ModeInfo(other.m_savedRdModeList[i][j]); + } + m_savedNumRdModes[i] = other.m_savedNumRdModes[i]; + } + + for (int i = 0; i < 4 * NUM_LFNST_NUM_PER_SET * 2; i++) + { + for (int j = 0; j < FAST_UDI_MAX_RDMODE_NUM; j++) + { + m_savedRdModeFirstColorSpace[i][j] = ModeInfo(other.m_savedRdModeFirstColorSpace[i][j]); + m_savedBDPCMModeFirstColorSpace[i][j] = BdpcmMode(other.m_savedBDPCMModeFirstColorSpace[i][j]); + m_savedRdCostFirstColorSpace[i][j] = other.m_savedRdCostFirstColorSpace[i][j]; + } + m_numSavedRdModeFirstColorSpace[i] = other.m_numSavedRdModeFirstColorSpace[i]; + } + m_savedRdModeIdx = other.m_savedRdModeIdx; + + m_tmpStorageCtu.createFromBuf(other.m_tmpStorageCtu); + m_colorTransResiBuf.createFromBuf(other.m_colorTransResiBuf); + + m_savedRdModeListLFNST = other.m_savedRdModeListLFNST; + m_savedHadModeListLFNST = other.m_savedHadModeListLFNST; + m_savedNumRdModesLFNST = uint32_t(other.m_savedNumRdModesLFNST); + m_savedModeCostLFNST = other.m_savedModeCostLFNST; + m_savedHadListLFNST = other.m_savedHadListLFNST; + + for (std::size_t i = 0; i < m_orgTUs.size(); ++i) + { + m_orgTUs[i] = other.m_orgTUs[i] ? new TransformUnit(*other.m_orgTUs[i]) : nullptr; + } + + m_pcEncCfg = other.m_pcEncCfg ? new EncCfg(*other.m_pcEncCfg) : nullptr; + m_pcTrQuant = other.m_pcTrQuant ? new TrQuant(*other.m_pcTrQuant) :nullptr; + m_pcRdCost = other.m_pcRdCost ? new RdCost(*other.m_pcRdCost) : nullptr; + m_pcReshape = other.m_pcReshape ? new EncReshape(*other.m_pcReshape) : nullptr; + m_CABACEstimator = other.m_CABACEstimator ? new CABACWriter(*other.m_CABACEstimator) : nullptr; + m_ctxPool = other.m_ctxPool ? new CtxPool(*other.m_ctxPool) : nullptr; + m_isInitialized = other.m_isInitialized; + m_bestEscape = other.m_bestEscape; + + for (int i = 0; i < MAXPLTSIZE + 1; i++) + { + m_indexError[i] = other.m_indexError[i] ? new double(*other.m_indexError[i]) : nullptr; + } + m_minErrorIndexMap = other.m_minErrorIndexMap ? new uint8_t(*other.m_minErrorIndexMap) : nullptr; + + for (int i = 0; i < 2; i++) + { + for (int j = 0; j < NUM_TRELLIS_STATE; j++) + { + for (int k = 0; k < 2 * MAX_CU_BLKSIZE_PLT; k++) + { + m_indexMapRDOQ[i][j][k] = uint8_t(other.m_indexMapRDOQ[i][j][k]); + m_runMapRDOQ[i][j][k] = other.m_runMapRDOQ[i][j][k]; + } + m_prevRunTypeRDOQ[i][j] = other.m_prevRunTypeRDOQ[i][j]; + m_prevRunPosRDOQ[i][j] = other.m_prevRunPosRDOQ[i][j]; + m_stateCostRDOQ[i][j] = other.m_stateCostRDOQ[i][j]; + + } + } + for (int i = 0; i < NUM_TRELLIS_STATE; i++) + { + m_statePtRDOQ[i] = other.m_statePtRDOQ[i] ? new uint8_t(*other.m_statePtRDOQ[i]) : nullptr; + } + } + //END ALBERTO IntraSearch(); ~IntraSearch();