Commit a7807c14 authored by Nan Hu's avatar Nan Hu
Browse files

M0428

parent 9248cfdf
......@@ -300,6 +300,9 @@ void EncApp::xInitLibCfg()
m_cEncLib.setQuadtreeTULog2MinSize ( m_quadtreeTULog2MinSize );
m_cEncLib.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter );
m_cEncLib.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra );
#if JVET_M0428_ENC_DB_OPT
m_cEncLib.setUseEncDbOpt(m_encDbOpt);
#endif
m_cEncLib.setUseFastLCTU ( m_useFastLCTU );
m_cEncLib.setFastInterSearchMode ( m_fastInterSearchMode );
m_cEncLib.setUseEarlyCU ( m_bUseEarlyCU );
......
......@@ -898,6 +898,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
("WrapAroundOffset", m_wrapAroundOffset, 0u, "Offset in luma samples used for computing the horizontal wrap-around position")
// ADD_NEW_TOOL : (encoder app) add parsing parameters here
#if JVET_M0428_ENC_DB_OPT
("EncDbOpt", m_encDbOpt, false, "Encoder optimization with deblocking filter")
#endif
#if JVET_M0427_INLOOP_RESHAPER
("LumaReshapeEnable", m_lumaReshapeEnable, false, "Enable Reshaping for Luma Channel")
("ReshapeSignalType", m_reshapeSignalType, 0u, "Input signal type: 0: SDR, 1:PQ, 2:HLG")
......@@ -3246,6 +3249,9 @@ void EncAppCfg::xPrintParameter()
msg(VERBOSE, "(Sigal:%s ", m_reshapeSignalType==0? "SDR" : "HDR-PQ");
msg(VERBOSE, ") ");
}
#endif
#if JVET_M0428_ENC_DB_OPT
msg(VERBOSE, "EncDbOpt:%d ", m_encDbOpt);
#endif
msg( VERBOSE, "\nFAST TOOL CFG: " );
if( m_LargeCTU )
......
......@@ -276,6 +276,9 @@ protected:
uint32_t m_reshapeSignalType;
uint32_t m_intraCMD;
ReshapeCW m_reshapeCW;
#endif
#if JVET_M0428_ENC_DB_OPT
bool m_encDbOpt;
#endif
unsigned m_uiMaxCUWidth; ///< max. CU width in pixel
unsigned m_uiMaxCUHeight; ///< max. CU height in pixel
......
......@@ -751,6 +751,11 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe
{
CHECK( this == &subStruct, "Trying to init self as sub-structure" );
#if JVET_M0428_ENC_DB_OPT
subStruct.useDbCost = false;
subStruct.costDbOffset = 0;
#endif
for( uint32_t i = 0; i < subStruct.area.blocks.size(); i++ )
{
CHECKD( subStruct.area.blocks[i].size() != subArea.blocks[i].size(), "Trying to init sub-structure of incompatible size" );
......@@ -852,7 +857,9 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
fracBits += subStruct.fracBits;
dist += subStruct.dist;
cost += subStruct.cost;
#if JVET_M0428_ENC_DB_OPT
costDbOffset += subStruct.costDbOffset;
#endif
if( parent )
{
// allow this to be false at the top level
......@@ -916,7 +923,9 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
fracBits += subStruct.fracBits;
dist += subStruct.dist;
cost += subStruct.cost;
#if JVET_M0428_ENC_DB_OPT
costDbOffset += subStruct.costDbOffset;
#endif
if( parent )
{
// allow this to be false at the top level
......@@ -978,7 +987,9 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel
fracBits = other.fracBits;
dist = other.dist;
cost = other.cost;
#if JVET_M0428_ENC_DB_OPT
costDbOffset = other.costDbOffset;
#endif
CHECKD( area != other.area, "Incompatible sizes" );
const UnitArea dualITreeArea = CS::getArea( *this, this->area, chType );
......@@ -1110,6 +1121,10 @@ void CodingStructure::initStructData( const int &QP, const bool &_isLosses, cons
cost = MAX_DOUBLE;
#if JVET_M0102_INTRA_SUBPARTITIONS
lumaCost = MAX_DOUBLE;
#endif
#if JVET_M0428_ENC_DB_OPT
costDbOffset = 0;
useDbCost = false;
#endif
interHad = std::numeric_limits<Distortion>::max();
}
......
......@@ -179,6 +179,10 @@ public:
static_vector<double, NUM_ENC_FEATURES> features;
double cost;
#if JVET_M0428_ENC_DB_OPT
bool useDbCost;
double costDbOffset;
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS
double lumaCost;
#endif
......
......@@ -126,7 +126,19 @@ void LoopFilter::create( const unsigned uiMaxCUDepth )
m_aapucBS [edgeDir].resize( numPartitions );
m_aapbEdgeFilter[edgeDir].resize( numPartitions );
}
#if JVET_M0428_ENC_DB_OPT
m_bEnc = false;
#endif
}
#if JVET_M0428_ENC_DB_OPT
void LoopFilter::initEncPicYuvBuffer(ChromaFormat chromaFormat, int lumaWidth, int lumaHeight)
{
const UnitArea picArea(chromaFormat, Area(0, 0, lumaWidth, lumaHeight));
m_encPicYuvBuffer.destroy();
m_encPicYuvBuffer.create(picArea);
}
#endif
void LoopFilter::destroy()
{
......@@ -135,6 +147,9 @@ void LoopFilter::destroy()
m_aapucBS [edgeDir].clear();
m_aapbEdgeFilter[edgeDir].clear();
}
#if JVET_M0428_ENC_DB_OPT
m_encPicYuvBuffer.destroy();
#endif
}
/**
......@@ -731,7 +746,11 @@ void LoopFilter::xEdgeFilterLuma(const CodingUnit& cu, const DeblockEdgeDir edge
const CompArea& lumaArea = cu.block(COMPONENT_Y);
const PreCalcValues& pcv = *cu.cs->pcv;
#if JVET_M0428_ENC_DB_OPT
PelBuf picYuvRec = m_bEnc ? m_encPicYuvBuffer.getBuf(lumaArea) : cu.cs->getRecoBuf(lumaArea);
#else
PelBuf picYuvRec = cu.cs->getRecoBuf( lumaArea );
#endif
Pel *piSrc = picYuvRec.buf;
const int iStride = picYuvRec.stride;
Pel *piTmpSrc = piSrc;
......@@ -1003,9 +1022,13 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed
const PreCalcValues& pcv = *cu.cs->pcv;
unsigned rasterIdx = getRasterIdx( lumaPos, pcv );
#if JVET_M0428_ENC_DB_OPT
PelBuf picYuvRecCb = m_bEnc ? m_encPicYuvBuffer.getBuf(cu.block(COMPONENT_Cb)) : cu.cs->getRecoBuf(cu.block(COMPONENT_Cb));
PelBuf picYuvRecCr = m_bEnc ? m_encPicYuvBuffer.getBuf(cu.block(COMPONENT_Cr)) : cu.cs->getRecoBuf(cu.block(COMPONENT_Cr));
#else
PelBuf picYuvRecCb = cu.cs->getRecoBuf( cu.block(COMPONENT_Cb) );
PelBuf picYuvRecCr = cu.cs->getRecoBuf( cu.block(COMPONENT_Cr) );
#endif
Pel *piSrcCb = picYuvRecCb.buf;
Pel *piSrcCr = picYuvRecCr.buf;
const int iStride = picYuvRecCb.stride;
......
......@@ -58,11 +58,16 @@ private:
static_vector<char, MAX_NUM_PARTS_IN_CTU> m_aapucBS [NUM_EDGE_DIR]; ///< Bs for [Ver/Hor][Y/U/V][Blk_Idx]
static_vector<bool, MAX_NUM_PARTS_IN_CTU> m_aapbEdgeFilter[NUM_EDGE_DIR];
LFCUParam m_stLFCUParam; ///< status structure
#if JVET_M0428_ENC_DB_OPT
PelStorage m_encPicYuvBuffer;
bool m_bEnc;
#endif
private:
#if !JVET_M0428_ENC_DB_OPT
/// CU-level deblocking function
void xDeblockCU ( CodingUnit& cu, const DeblockEdgeDir edgeDir );
#endif
// set / get functions
void xSetLoopfilterParam ( const CodingUnit& cu );
......@@ -111,6 +116,14 @@ public:
LoopFilter();
~LoopFilter();
#if JVET_M0428_ENC_DB_OPT
/// CU-level deblocking function
void xDeblockCU(CodingUnit& cu, const DeblockEdgeDir edgeDir);
void initEncPicYuvBuffer(ChromaFormat chromaFormat, int lumaWidth, int lumaHeight);
PelStorage& getDbEncPicYuvBuffer() { return m_encPicYuvBuffer; }
void setEnc(bool b) { m_bEnc = b; }
#endif
void create ( const unsigned uiMaxCUDepth );
void destroy ();
......
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_M0428_ENC_DB_OPT 1 // Encoder optimization with deblocking filter
#define JVET_M0055_DEBUG_CTU 1 // DebugCTU encoder debug option
#define JVET_M0297_32PT_MTS_ZERO_OUT 1 // 32 point MTS based on skipping high frequency coefficients
......
......@@ -276,6 +276,9 @@ protected:
unsigned m_reshapeSignalType;
unsigned m_intraCMD;
ReshapeCW m_reshapeCW;
#endif
#if JVET_M0428_ENC_DB_OPT
bool m_encDbOpt;
#endif
bool m_useFastLCTU;
bool m_useFastMrg;
......@@ -847,6 +850,10 @@ public:
void setMaxCodingDepth ( uint32_t u ) { m_maxTotalCUDepth = u; }
uint32_t getMaxCodingDepth () const { return m_maxTotalCUDepth; }
void setLog2DiffMaxMinCodingBlockSize( uint32_t u ) { m_log2DiffMaxMinCodingBlockSize = u; }
#if JVET_M0428_ENC_DB_OPT
void setUseEncDbOpt ( bool n ) { m_encDbOpt = n; }
bool getUseEncDbOpt () const { return m_encDbOpt; }
#endif
void setUseFastLCTU ( bool n ) { m_useFastLCTU = n; }
bool getUseFastLCTU () const { return m_useFastLCTU; }
......
This diff is collapsed.
......@@ -46,6 +46,9 @@
#include "CommonLib/Unit.h"
#include "CommonLib/UnitPartitioner.h"
#include "CommonLib/IbcHashMap.h"
#if JVET_M0428_ENC_DB_OPT
#include "CommonLib/LoopFilter.h"
#endif
#if REUSE_CU_RESULTS
#include "DecoderLib/DecCu.h"
......@@ -84,7 +87,9 @@ class EncCu
#endif
{
private:
#if JVET_M0428_ENC_DB_OPT
bool m_bestModeUpdated;
#endif
struct CtxPair
{
Ctx start;
......@@ -116,6 +121,9 @@ private:
TrQuant* m_pcTrQuant;
RdCost* m_pcRdCost;
EncSlice* m_pcSliceEncoder;
#if JVET_M0428_ENC_DB_OPT
LoopFilter* m_pcLoopFilter;
#endif
CABACWriter* m_CABACEstimator;
RateCtrl* m_pcRateCtrl;
......@@ -191,6 +199,11 @@ public:
protected:
#if JVET_M0428_ENC_DB_OPT
void xCalDebCost ( CodingStructure &cs, Partitioner &partitioner, bool calDist = false );
Distortion getDistortionDb ( CodingStructure &cs, CPelBuf org, CPelBuf reco, ComponentID compID, const CompArea& compArea, bool afterDb );
#endif
void xCompressCU ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm
, LutMotionCand *&tempMotCandLUTs
, LutMotionCand *&bestMotCandLUTs
......
......@@ -130,7 +130,12 @@ void EncLib::create ()
}
m_cLoopFilter.create( m_maxTotalCUDepth );
#if JVET_M0428_ENC_DB_OPT
if (!m_bLoopFilterDisable)
{
m_cLoopFilter.initEncPicYuvBuffer(m_chromaFormatIDC, getSourceWidth(), getSourceHeight());
}
#endif
if( m_alf )
{
m_cEncALF.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, m_bitDepth, m_inputBitDepth );
......
......@@ -1983,7 +1983,11 @@ bool EncModeCtrlMTnoRQT::useModeResult( const EncTestMode& encTestmode, CodingSt
}
// for now just a simple decision based on RD-cost or choose tempCS if bestCS is not yet coded
#if JVET_M0428_ENC_DB_OPT
if( !cuECtx.bestCS || ( ( tempCS->features[ENC_FT_RD_COST] + ( tempCS->useDbCost ? tempCS->costDbOffset : 0 ) ) < ( cuECtx.bestCS->features[ENC_FT_RD_COST] + ( tempCS->useDbCost ? cuECtx.bestCS->costDbOffset : 0 ) ) ) )
#else
if( !cuECtx.bestCS || tempCS->features[ENC_FT_RD_COST] < cuECtx.bestCS->features[ENC_FT_RD_COST] )
#endif
{
cuECtx.bestCS = tempCS;
cuECtx.bestCU = tempCS->cus[0];
......
......@@ -908,6 +908,9 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner )
if( cu.ispMode && !csTemp->cus[0]->firstTU->cbf[COMPONENT_Y] )
{
csTemp->cost = MAX_DOUBLE;
#if JVET_M0428_ENC_DB_OPT
csTemp->costDbOffset = 0;
#endif
}
#else
xRecurIntraCodingLumaQT( *csTemp, partitioner );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment