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

M0428

parent 9248cfdf
...@@ -300,6 +300,9 @@ void EncApp::xInitLibCfg() ...@@ -300,6 +300,9 @@ void EncApp::xInitLibCfg()
m_cEncLib.setQuadtreeTULog2MinSize ( m_quadtreeTULog2MinSize ); m_cEncLib.setQuadtreeTULog2MinSize ( m_quadtreeTULog2MinSize );
m_cEncLib.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); m_cEncLib.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter );
m_cEncLib.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); m_cEncLib.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra );
#if JVET_M0428_ENC_DB_OPT
m_cEncLib.setUseEncDbOpt(m_encDbOpt);
#endif
m_cEncLib.setUseFastLCTU ( m_useFastLCTU ); m_cEncLib.setUseFastLCTU ( m_useFastLCTU );
m_cEncLib.setFastInterSearchMode ( m_fastInterSearchMode ); m_cEncLib.setFastInterSearchMode ( m_fastInterSearchMode );
m_cEncLib.setUseEarlyCU ( m_bUseEarlyCU ); m_cEncLib.setUseEarlyCU ( m_bUseEarlyCU );
......
...@@ -898,6 +898,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ...@@ -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") ("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 // 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 #if JVET_M0427_INLOOP_RESHAPER
("LumaReshapeEnable", m_lumaReshapeEnable, false, "Enable Reshaping for Luma Channel") ("LumaReshapeEnable", m_lumaReshapeEnable, false, "Enable Reshaping for Luma Channel")
("ReshapeSignalType", m_reshapeSignalType, 0u, "Input signal type: 0: SDR, 1:PQ, 2:HLG") ("ReshapeSignalType", m_reshapeSignalType, 0u, "Input signal type: 0: SDR, 1:PQ, 2:HLG")
...@@ -3246,6 +3249,9 @@ void EncAppCfg::xPrintParameter() ...@@ -3246,6 +3249,9 @@ void EncAppCfg::xPrintParameter()
msg(VERBOSE, "(Sigal:%s ", m_reshapeSignalType==0? "SDR" : "HDR-PQ"); msg(VERBOSE, "(Sigal:%s ", m_reshapeSignalType==0? "SDR" : "HDR-PQ");
msg(VERBOSE, ") "); msg(VERBOSE, ") ");
} }
#endif
#if JVET_M0428_ENC_DB_OPT
msg(VERBOSE, "EncDbOpt:%d ", m_encDbOpt);
#endif #endif
msg( VERBOSE, "\nFAST TOOL CFG: " ); msg( VERBOSE, "\nFAST TOOL CFG: " );
if( m_LargeCTU ) if( m_LargeCTU )
......
...@@ -276,6 +276,9 @@ protected: ...@@ -276,6 +276,9 @@ protected:
uint32_t m_reshapeSignalType; uint32_t m_reshapeSignalType;
uint32_t m_intraCMD; uint32_t m_intraCMD;
ReshapeCW m_reshapeCW; ReshapeCW m_reshapeCW;
#endif
#if JVET_M0428_ENC_DB_OPT
bool m_encDbOpt;
#endif #endif
unsigned m_uiMaxCUWidth; ///< max. CU width in pixel unsigned m_uiMaxCUWidth; ///< max. CU width in pixel
unsigned m_uiMaxCUHeight; ///< max. CU height in pixel unsigned m_uiMaxCUHeight; ///< max. CU height in pixel
......
...@@ -751,6 +751,11 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe ...@@ -751,6 +751,11 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe
{ {
CHECK( this == &subStruct, "Trying to init self as sub-structure" ); 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++ ) 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" ); 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 ...@@ -852,7 +857,9 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
fracBits += subStruct.fracBits; fracBits += subStruct.fracBits;
dist += subStruct.dist; dist += subStruct.dist;
cost += subStruct.cost; cost += subStruct.cost;
#if JVET_M0428_ENC_DB_OPT
costDbOffset += subStruct.costDbOffset;
#endif
if( parent ) if( parent )
{ {
// allow this to be false at the top level // allow this to be false at the top level
...@@ -916,7 +923,9 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C ...@@ -916,7 +923,9 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
fracBits += subStruct.fracBits; fracBits += subStruct.fracBits;
dist += subStruct.dist; dist += subStruct.dist;
cost += subStruct.cost; cost += subStruct.cost;
#if JVET_M0428_ENC_DB_OPT
costDbOffset += subStruct.costDbOffset;
#endif
if( parent ) if( parent )
{ {
// allow this to be false at the top level // allow this to be false at the top level
...@@ -978,7 +987,9 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel ...@@ -978,7 +987,9 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel
fracBits = other.fracBits; fracBits = other.fracBits;
dist = other.dist; dist = other.dist;
cost = other.cost; cost = other.cost;
#if JVET_M0428_ENC_DB_OPT
costDbOffset = other.costDbOffset;
#endif
CHECKD( area != other.area, "Incompatible sizes" ); CHECKD( area != other.area, "Incompatible sizes" );
const UnitArea dualITreeArea = CS::getArea( *this, this->area, chType ); const UnitArea dualITreeArea = CS::getArea( *this, this->area, chType );
...@@ -1110,6 +1121,10 @@ void CodingStructure::initStructData( const int &QP, const bool &_isLosses, cons ...@@ -1110,6 +1121,10 @@ void CodingStructure::initStructData( const int &QP, const bool &_isLosses, cons
cost = MAX_DOUBLE; cost = MAX_DOUBLE;
#if JVET_M0102_INTRA_SUBPARTITIONS #if JVET_M0102_INTRA_SUBPARTITIONS
lumaCost = MAX_DOUBLE; lumaCost = MAX_DOUBLE;
#endif
#if JVET_M0428_ENC_DB_OPT
costDbOffset = 0;
useDbCost = false;
#endif #endif
interHad = std::numeric_limits<Distortion>::max(); interHad = std::numeric_limits<Distortion>::max();
} }
......
...@@ -179,6 +179,10 @@ public: ...@@ -179,6 +179,10 @@ public:
static_vector<double, NUM_ENC_FEATURES> features; static_vector<double, NUM_ENC_FEATURES> features;
double cost; double cost;
#if JVET_M0428_ENC_DB_OPT
bool useDbCost;
double costDbOffset;
#endif
#if JVET_M0102_INTRA_SUBPARTITIONS #if JVET_M0102_INTRA_SUBPARTITIONS
double lumaCost; double lumaCost;
#endif #endif
......
...@@ -126,7 +126,19 @@ void LoopFilter::create( const unsigned uiMaxCUDepth ) ...@@ -126,7 +126,19 @@ void LoopFilter::create( const unsigned uiMaxCUDepth )
m_aapucBS [edgeDir].resize( numPartitions ); m_aapucBS [edgeDir].resize( numPartitions );
m_aapbEdgeFilter[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() void LoopFilter::destroy()
{ {
...@@ -135,6 +147,9 @@ void LoopFilter::destroy() ...@@ -135,6 +147,9 @@ void LoopFilter::destroy()
m_aapucBS [edgeDir].clear(); m_aapucBS [edgeDir].clear();
m_aapbEdgeFilter[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 ...@@ -731,7 +746,11 @@ void LoopFilter::xEdgeFilterLuma(const CodingUnit& cu, const DeblockEdgeDir edge
const CompArea& lumaArea = cu.block(COMPONENT_Y); const CompArea& lumaArea = cu.block(COMPONENT_Y);
const PreCalcValues& pcv = *cu.cs->pcv; 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 ); PelBuf picYuvRec = cu.cs->getRecoBuf( lumaArea );
#endif
Pel *piSrc = picYuvRec.buf; Pel *piSrc = picYuvRec.buf;
const int iStride = picYuvRec.stride; const int iStride = picYuvRec.stride;
Pel *piTmpSrc = piSrc; Pel *piTmpSrc = piSrc;
...@@ -1003,9 +1022,13 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed ...@@ -1003,9 +1022,13 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed
const PreCalcValues& pcv = *cu.cs->pcv; const PreCalcValues& pcv = *cu.cs->pcv;
unsigned rasterIdx = getRasterIdx( lumaPos, 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 picYuvRecCb = cu.cs->getRecoBuf( cu.block(COMPONENT_Cb) );
PelBuf picYuvRecCr = cu.cs->getRecoBuf( cu.block(COMPONENT_Cr) ); PelBuf picYuvRecCr = cu.cs->getRecoBuf( cu.block(COMPONENT_Cr) );
#endif
Pel *piSrcCb = picYuvRecCb.buf; Pel *piSrcCb = picYuvRecCb.buf;
Pel *piSrcCr = picYuvRecCr.buf; Pel *piSrcCr = picYuvRecCr.buf;
const int iStride = picYuvRecCb.stride; const int iStride = picYuvRecCb.stride;
......
...@@ -58,11 +58,16 @@ private: ...@@ -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<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]; static_vector<bool, MAX_NUM_PARTS_IN_CTU> m_aapbEdgeFilter[NUM_EDGE_DIR];
LFCUParam m_stLFCUParam; ///< status structure LFCUParam m_stLFCUParam; ///< status structure
#if JVET_M0428_ENC_DB_OPT
PelStorage m_encPicYuvBuffer;
bool m_bEnc;
#endif
private: private:
#if !JVET_M0428_ENC_DB_OPT
/// CU-level deblocking function /// CU-level deblocking function
void xDeblockCU ( CodingUnit& cu, const DeblockEdgeDir edgeDir ); void xDeblockCU ( CodingUnit& cu, const DeblockEdgeDir edgeDir );
#endif
// set / get functions // set / get functions
void xSetLoopfilterParam ( const CodingUnit& cu ); void xSetLoopfilterParam ( const CodingUnit& cu );
...@@ -111,6 +116,14 @@ public: ...@@ -111,6 +116,14 @@ public:
LoopFilter(); LoopFilter();
~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 create ( const unsigned uiMaxCUDepth );
void destroy (); void destroy ();
......
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#include <assert.h> #include <assert.h>
#include <cassert> #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_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 #define JVET_M0297_32PT_MTS_ZERO_OUT 1 // 32 point MTS based on skipping high frequency coefficients
......
...@@ -276,6 +276,9 @@ protected: ...@@ -276,6 +276,9 @@ protected:
unsigned m_reshapeSignalType; unsigned m_reshapeSignalType;
unsigned m_intraCMD; unsigned m_intraCMD;
ReshapeCW m_reshapeCW; ReshapeCW m_reshapeCW;
#endif
#if JVET_M0428_ENC_DB_OPT
bool m_encDbOpt;
#endif #endif
bool m_useFastLCTU; bool m_useFastLCTU;
bool m_useFastMrg; bool m_useFastMrg;
...@@ -847,6 +850,10 @@ public: ...@@ -847,6 +850,10 @@ public:
void setMaxCodingDepth ( uint32_t u ) { m_maxTotalCUDepth = u; } void setMaxCodingDepth ( uint32_t u ) { m_maxTotalCUDepth = u; }
uint32_t getMaxCodingDepth () const { return m_maxTotalCUDepth; } uint32_t getMaxCodingDepth () const { return m_maxTotalCUDepth; }
void setLog2DiffMaxMinCodingBlockSize( uint32_t u ) { m_log2DiffMaxMinCodingBlockSize = u; } 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; } void setUseFastLCTU ( bool n ) { m_useFastLCTU = n; }
bool getUseFastLCTU () const { return m_useFastLCTU; } bool getUseFastLCTU () const { return m_useFastLCTU; }
......
This diff is collapsed.
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
#include "CommonLib/Unit.h" #include "CommonLib/Unit.h"
#include "CommonLib/UnitPartitioner.h" #include "CommonLib/UnitPartitioner.h"
#include "CommonLib/IbcHashMap.h" #include "CommonLib/IbcHashMap.h"
#if JVET_M0428_ENC_DB_OPT
#include "CommonLib/LoopFilter.h"
#endif
#if REUSE_CU_RESULTS #if REUSE_CU_RESULTS
#include "DecoderLib/DecCu.h" #include "DecoderLib/DecCu.h"
...@@ -84,7 +87,9 @@ class EncCu ...@@ -84,7 +87,9 @@ class EncCu
#endif #endif
{ {
private: private:
#if JVET_M0428_ENC_DB_OPT
bool m_bestModeUpdated;
#endif
struct CtxPair struct CtxPair
{ {
Ctx start; Ctx start;
...@@ -116,6 +121,9 @@ private: ...@@ -116,6 +121,9 @@ private:
TrQuant* m_pcTrQuant; TrQuant* m_pcTrQuant;
RdCost* m_pcRdCost; RdCost* m_pcRdCost;
EncSlice* m_pcSliceEncoder; EncSlice* m_pcSliceEncoder;
#if JVET_M0428_ENC_DB_OPT
LoopFilter* m_pcLoopFilter;
#endif
CABACWriter* m_CABACEstimator; CABACWriter* m_CABACEstimator;
RateCtrl* m_pcRateCtrl; RateCtrl* m_pcRateCtrl;
...@@ -191,6 +199,11 @@ public: ...@@ -191,6 +199,11 @@ public:
protected: 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 void xCompressCU ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm
, LutMotionCand *&tempMotCandLUTs , LutMotionCand *&tempMotCandLUTs
, LutMotionCand *&bestMotCandLUTs , LutMotionCand *&bestMotCandLUTs
......
...@@ -130,7 +130,12 @@ void EncLib::create () ...@@ -130,7 +130,12 @@ void EncLib::create ()
} }
m_cLoopFilter.create( m_maxTotalCUDepth ); 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 ) if( m_alf )
{ {
m_cEncALF.create( getSourceWidth(), getSourceHeight(), m_chromaFormatIDC, m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, m_bitDepth, m_inputBitDepth ); 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 ...@@ -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 // 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] ) if( !cuECtx.bestCS || tempCS->features[ENC_FT_RD_COST] < cuECtx.bestCS->features[ENC_FT_RD_COST] )
#endif
{ {
cuECtx.bestCS = tempCS; cuECtx.bestCS = tempCS;
cuECtx.bestCU = tempCS->cus[0]; cuECtx.bestCU = tempCS->cus[0];
......
...@@ -908,6 +908,9 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) ...@@ -908,6 +908,9 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner )
if( cu.ispMode && !csTemp->cus[0]->firstTU->cbf[COMPONENT_Y] ) if( cu.ispMode && !csTemp->cus[0]->firstTU->cbf[COMPONENT_Y] )
{ {
csTemp->cost = MAX_DOUBLE; csTemp->cost = MAX_DOUBLE;
#if JVET_M0428_ENC_DB_OPT
csTemp->costDbOffset = 0;
#endif
} }
#else #else
xRecurIntraCodingLumaQT( *csTemp, partitioner ); 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