From 4dc3a5e777973b9178d430f57fce8e988aeb1431 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez Date: Thu, 9 Mar 2023 03:30:00 +0100 Subject: [PATCH] =?UTF-8?q?Commit=20n=C2=BA=208=20(09-03-2023)=20<->=203:3?= =?UTF-8?q?1=20AM=20------------------------------------------------------?= =?UTF-8?q?----------=20Continuar=20con=20el=20constructor=20de=20copia=20?= =?UTF-8?q?de=20-=20CacheBlkInfoCtrl(other)=20-=20SaveLoadEncInfoSbt(other?= =?UTF-8?q?)=20-=20BestEncInfoCache(other)=20-----------------------------?= =?UTF-8?q?-----------------------------------=20Objetivo=20Terminar=20con?= =?UTF-8?q?structor=20de=20copia=20de=20EncModeCtrlMTnoRTQ=20para=20atribu?= =?UTF-8?q?to=20EncModeCtrl=20de=20EnCu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Lib/CommonLib/Contexts.cpp | 9 +- source/Lib/EncoderLib/EncModeCtrl.cpp | 46 +++++++++ source/Lib/EncoderLib/EncModeCtrl.h | 13 ++- source/Lib/EncoderLib/IntraSearch.h | 17 ++-- source/Lib/EncoderLib/RateCtrl.h | 130 ++++++++++++++++++++++++++ 5 files changed, 200 insertions(+), 15 deletions(-) diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 53429fc..df2f091 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -956,11 +956,10 @@ template class CtxStore; Ctx::Ctx() : m_bpmType(BpmType::NONE) {} Ctx::Ctx(const BinProbModel_Std *dummy) : m_bpmType(BpmType::STD), m_CtxStore_Std(true) {} -Ctx::Ctx(const Ctx &ctx) : m_bpmType(ctx.m_bpmType), m_CtxStore_Std(ctx.m_CtxStore_Std) +//ALBERTO +Ctx::Ctx(const Ctx& ctx) : m_bpmType(ctx.m_bpmType), m_CtxStore_Std(ctx.m_CtxStore_Std), m_baseLevel(ctx.m_baseLevel) { - ::memcpy( m_GRAdaptStats, ctx.m_GRAdaptStats, sizeof( unsigned ) * RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS ); - //ALBERTO - m_baseLevel = ctx.m_baseLevel; - //END ALBERTO + ::memcpy(m_GRAdaptStats, ctx.m_GRAdaptStats, sizeof(unsigned) * RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS); } +//END ALBERTO diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index 3243bc7..3b1b704 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -51,6 +51,39 @@ static constexpr double UNSET_IMV_COST = MAX_DOUBLE * 0.125; // Some large, unique value +//ALBERTO +EncModeCtrl::EncModeCtrl() {} +EncModeCtrl::EncModeCtrl(const EncModeCtrl& other) + : m_pcEncCfg(other.m_pcEncCfg ? new EncCfg(*other.m_pcEncCfg) : nullptr) + , m_pcRateCtrl(other.m_pcRateCtrl ? new 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) +#if SHARP_LUMA_DELTA_QP + , m_lumaQPOffset(other.m_lumaQPOffset) +#endif + , m_fastDeltaQP(other.m_fastDeltaQP) + , m_ComprCUCtxList(other.m_ComprCUCtxList) + , m_pcInterSearch(new InterSearch(*other.m_pcInterSearch)) + , m_doPlt(other.m_doPlt) +{ + const int* a = nullptr; + a = new int(3); + if (other.m_bimQPMap) + { + m_bimQPMap = new std::map; + for (auto const& entry: *other.m_bimQPMap) + { + int* copyArray = new int[entry.first]; + std::memcpy(copyArray, entry.second, sizeof(int) * entry.first); + (*m_bimQPMap)[entry.first] = copyArray; + } + } + else + { + m_bimQPMap = nullptr; + } +} +//END ALBERTO void EncModeCtrl::init( EncCfg *pCfg, RateCtrl *pRateCtrl, RdCost* pRdCost ) { m_pcEncCfg = pCfg; @@ -1038,6 +1071,19 @@ static bool interHadActive( const ComprCUCtx& ctx ) ////////////////////////////////////////////////////////////////////////// // EncModeCtrlQTBT ////////////////////////////////////////////////////////////////////////// +//ALBERTO +EncModeCtrlMTnoRQT::EncModeCtrlMTnoRQT() {} + +EncModeCtrlMTnoRQT::EncModeCtrlMTnoRQT(const EncModeCtrlMTnoRQT& other) + : m_encCfg(other.m_encCfg) + , m_skipThreshold(other.m_skipThreshold) + , EncModeCtrl(other) + , CacheBlkInfoCtrl(other) + , SaveLoadEncInfoSbt(other), BestEncInfoCache(other) +{ + +} +//END ALBERTO void EncModeCtrlMTnoRQT::create( const EncCfg& cfg ) { diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h index eb0d036..78e28fe 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.h +++ b/source/Lib/EncoderLib/EncModeCtrl.h @@ -283,7 +283,9 @@ protected: const EncCfg *m_pcEncCfg; const class RateCtrl *m_pcRateCtrl; class RdCost *m_pcRdCost; - const Slice *m_slice; + //ALBERTO + const Slice *m_slice = nullptr; + //END ALBERTO #if SHARP_LUMA_DELTA_QP int m_lumaLevelToDeltaQPLUT[LUMA_LEVEL_TO_DQP_LUT_MAXSIZE]; int m_lumaQPOffset; @@ -296,7 +298,10 @@ protected: bool m_doPlt; public: - + //ALBERTO + EncModeCtrl(); + EncModeCtrl(const EncModeCtrl& other); + //END ALBERTO virtual ~EncModeCtrl () {} virtual void create ( const EncCfg& cfg ) = 0; @@ -911,6 +916,10 @@ class EncModeCtrlMTnoRQT : public EncModeCtrl, public CacheBlkInfoCtrl #endif public: + //ALBERTO + EncModeCtrlMTnoRQT(); + EncModeCtrlMTnoRQT(const EncModeCtrlMTnoRQT& other); + //END ALBERTO virtual void create ( const EncCfg& cfg ); virtual void destroy (); virtual void initCTUEncoding ( const Slice &slice ); diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index f281545..1f8fa97 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -414,15 +414,16 @@ public: IntraSearch(); //ALBERTO - IntraSearch(IntraSearch& other) + IntraSearch(IntraSearch& other) + : m_modeCtrl((EncModeCtrl*) new EncModeCtrlMTnoRQT(*dynamic_cast(other.m_modeCtrl))) { - m_modeCtrl = new EncModeCtrlMTnoRQT(); - m_modeCtrl->create(*other.m_pcEncCfg); - for (int i = 0; i < MAX_NUM_TBLOCKS; i++) - { - m_pSharedPredTransformSkip[i] = new Pel(*other.m_pSharedPredTransformSkip[i]); - //CONTINUAR CON EL RESTO DE ATRIBUTOS - } + //m_modeCtrl = new EncModeCtrlMTnoRQT(); + //m_modeCtrl->create(*other.m_pcEncCfg); + //for (int i = 0; i < MAX_NUM_TBLOCKS; i++) + //{ + // m_pSharedPredTransformSkip[i] = new Pel(*other.m_pSharedPredTransformSkip[i]); + // //CONTINUAR CON EL RESTO DE ATRIBUTOS + //} } //END ALBERTO ~IntraSearch(); diff --git a/source/Lib/EncoderLib/RateCtrl.h b/source/Lib/EncoderLib/RateCtrl.h index 0ed7b6c..48bab1b 100644 --- a/source/Lib/EncoderLib/RateCtrl.h +++ b/source/Lib/EncoderLib/RateCtrl.h @@ -95,6 +95,57 @@ struct TRCParameter class EncRCSeq { public: + //ALBERTO + EncRCSeq(const EncRCSeq& other) + { + m_totalFrames = other.m_totalFrames; + m_targetRate = other.m_targetRate; + m_frameRate = other.m_frameRate; + m_GOPSize = other.m_GOPSize; + m_intraPeriod = other.m_intraPeriod; + m_picWidth = other.m_picWidth; + m_picHeight = other.m_picHeight; + m_LCUWidth = other.m_LCUWidth; + m_LCUHeight = other.m_LCUHeight; + m_numberOfLevel = other.m_numberOfLevel; + m_averageBits = other.m_averageBits; + + m_numberOfPixel = other.m_numberOfPixel; + m_targetBits = other.m_targetBits; + m_numberOfLCU = other.m_numberOfLCU; + m_bitsRatio = new int[m_GOPSize]; + memcpy(m_bitsRatio, other.m_bitsRatio, sizeof(int) * m_GOPSize); + m_GOPID2Level = new int[m_GOPSize]; + memcpy(m_GOPID2Level, other.m_GOPID2Level, sizeof(int) * m_GOPSize); + + m_picPara = new TRCParameter[m_numberOfLevel]; + for (int i = 0; i < m_numberOfLevel; i++) + { + m_picPara[i] = other.m_picPara[i]; + } + + m_LCUPara = new TRCParameter*[m_numberOfLevel]; + for (int i = 0; i < m_numberOfLevel; i++) + { + m_LCUPara[i] = new TRCParameter[m_numberOfLCU]; + for (int j = 0; j < m_numberOfLCU; j++) + { + m_LCUPara[i][j] = other.m_LCUPara[i][j]; + } + } + + m_framesLeft = other.m_framesLeft; + m_bitsLeft = other.m_bitsLeft; + m_seqTargetBpp = other.m_seqTargetBpp; + m_alphaUpdate = other.m_alphaUpdate; + m_betaUpdate = other.m_betaUpdate; + m_useLCUSeparateModel = other.m_useLCUSeparateModel; + + m_adaptiveBit = other.m_adaptiveBit; + m_lastLambda = other.m_lastLambda; + m_bitDepth = other.m_bitDepth; + } + //END ALBERTO EncRCSeq(); ~EncRCSeq(); @@ -187,6 +238,35 @@ private: class EncRCGOP { public: + //ALBERTO + EncRCGOP::EncRCGOP(const EncRCGOP& other) + { + // Copiar los punteros de miembro profundo y los datos primitivos + m_numPic = other.m_numPic; + m_targetBits = other.m_targetBits; + m_picLeft = other.m_picLeft; + m_bitsLeft = other.m_bitsLeft; + m_minEstLambda = other.m_minEstLambda; + m_maxEstLambda = other.m_maxEstLambda; + + if (other.m_encRCSeq) + { + m_encRCSeq = new EncRCSeq(*other.m_encRCSeq); + } + else + { + m_encRCSeq = nullptr; + } + + // Copiar la matriz dinámica + m_picTargetBitInGOP = new int[m_numPic]; + for (int i = 0; i < m_numPic; i++) + { + m_picTargetBitInGOP[i] = other.m_picTargetBitInGOP[i]; + } + } + //END ALBERTO + EncRCGOP(); ~EncRCGOP(); @@ -224,6 +304,38 @@ private: class EncRCPic { public: + //ALBERTO + EncRCPic(const EncRCPic& other): + m_frameLevel(other.m_frameLevel) + , m_numberOfPixel(other.m_numberOfPixel) + , m_numberOfLCU(other.m_numberOfLCU) + , m_targetBits(other.m_targetBits) + , m_estHeaderBits(other.m_estHeaderBits) + , m_estPicQP(other.m_estPicQP) + , m_lowerBound(other.m_lowerBound) + , m_estPicLambda(other.m_estPicLambda) + , m_LCULeft(other.m_LCULeft) + , m_bitsLeft(other.m_bitsLeft) + , m_pixelsLeft(other.m_pixelsLeft) + , m_picActualHeaderBits(other.m_picActualHeaderBits) + , m_totalCostIntra(other.m_totalCostIntra) + , m_remainingCostIntra(other.m_remainingCostIntra) + , m_picActualBits(other.m_picActualBits) + , m_picQP(other.m_picQP) + , m_picLambda(other.m_picLambda) + , m_picMSE(other.m_picMSE) + , m_validPixelsInPic(other.m_validPixelsInPic) + { + m_encRCSeq = new EncRCSeq(*other.m_encRCSeq); + m_encRCGOP = new EncRCGOP(*other.m_encRCGOP); + m_LCUs = new TRCLCU[other.m_numberOfLCU]; + + for (int i = 0; i < other.m_numberOfLCU; i++) + { + m_LCUs[i] = other.m_LCUs[i]; + } + } + //END ALBERTO EncRCPic(); ~EncRCPic(); @@ -321,6 +433,24 @@ private: class RateCtrl { public: + //ALBERTO + RateCtrl(const RateCtrl& other) + : m_RCQP(other.m_RCQP) + , m_CpbSaturationEnabled(other.m_CpbSaturationEnabled) + , m_cpbState(other.m_cpbState) + , m_cpbSize(other.m_cpbSize) + , m_bufferingRate(other.m_bufferingRate) + { + m_encRCSeq = other.m_encRCSeq ? new EncRCSeq(*other.m_encRCSeq): nullptr; + m_encRCGOP = other.m_encRCGOP ? new EncRCGOP(*other.m_encRCGOP): nullptr; + m_encRCPic = other.m_encRCPic ? new EncRCPic(*other.m_encRCPic): nullptr; + + for (auto pic: other.m_listRCPictures) + { + m_listRCPictures.push_back(new EncRCPic(*pic)); + } + } + //END ALBERTO RateCtrl(); ~RateCtrl(); -- 2.24.1