Commit 9f4195e0 authored by Xiang Li's avatar Xiang Li

Merge branch 'K0076_CPR' into 'master'

K0076 CPR mode

See merge request jvet/VVCSoftware_BMS!71
parents f4e22ea8 8c7b5dde
Pipeline #56 passed with stage
......@@ -114,6 +114,7 @@ LMChroma : 1
DMVR : 1
IMV : 2
DepQuant : 1
CPR : 1
# Fast tools
PBIntraFast : 1
......
......@@ -130,6 +130,7 @@ LMChroma : 1
DMVR : 1
IMV : 2
DepQuant : 1
CPR : 1
CompositeLTReference : 0
......
......@@ -130,6 +130,7 @@ LMChroma : 1
DMVR : 1
IMV : 2
DepQuant : 1
CPR : 1
CompositeLTReference : 0
......
......@@ -145,6 +145,7 @@ DMVR : 1
IMV : 2
DepQuant : 1
BIO : 1
CPR : 1
# Fast tools
PBIntraFast : 1
......
......@@ -303,6 +303,15 @@ void EncApp::xInitLibCfg()
#endif
#if JVET_K0157
m_cEncLib.setUseCompositeRef ( m_compositeRefEnabled );
#endif
#if JVET_K0076_CPR
m_cEncLib.setIBCMode ( m_IBCMode );
m_cEncLib.setIBCLocalSearchRangeX ( m_IBCLocalSearchRangeX );
m_cEncLib.setIBCLocalSearchRangeY ( m_IBCLocalSearchRangeY );
m_cEncLib.setIBCHashSearch ( m_IBCHashSearch );
m_cEncLib.setIBCHashSearchMaxCand ( m_IBCHashSearchMaxCand );
m_cEncLib.setIBCHashSearchRange4SmallBlk ( m_IBCHashSearchRange4SmallBlk );
m_cEncLib.setIBCFastMethod ( m_IBCFastMethod );
#endif
// ADD_NEW_TOOL : (encoder app) add setting of tool enabling flags and associated parameters here
......
......@@ -915,6 +915,15 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
#endif
#if JVET_K0157
("CompositeLTReference", m_compositeRefEnabled, false, "Enable Composite Long Term Reference Frame")
#endif
#if JVET_K0076_CPR
( "CPR", m_IBCMode, 0u, "IBCMode (0x1:enabled, 0x0:disabled) [default: disabled]")
( "IBCLocalSearchRangeX", m_IBCLocalSearchRangeX, 128u, "Search range of IBC local search in x direction")
( "IBCLocalSearchRangeY", m_IBCLocalSearchRangeY, 128u, "Search range of IBC local search in y direction")
( "IBCHashSearch", m_IBCHashSearch, 1u, "Hash based IBC search")
( "IBCHashSearchMaxCand", m_IBCHashSearchMaxCand, 256u, "Max candidates for hash based IBC search")
( "IBCHashSearchRange4SmallBlk", m_IBCHashSearchRange4SmallBlk, 256u, "Small block search range in based IBC search")
( "IBCFastMethod", m_IBCFastMethod, 6u, "Fast methods for IBC")
#endif
// ADD_NEW_TOOL : (encoder app) add parsing parameters here
......@@ -2036,6 +2045,9 @@ bool EncAppCfg::xCheckParameter()
xConfirmPara( m_ALF, "ALF is only allowed with NEXT profile" );
#endif
xConfirmPara( m_OBMC, "OBMC is only allowed in NEXT profile" );
#endif
#if JVET_K0076_CPR
xConfirmPara(m_IBCMode, "IBC Mode only allowed with NEXT profile");
#endif
xConfirmPara( m_useFastLCTU, "Fast large CTU can only be applied when encoding with NEXT profile" );
#if !JVET_K0220_ENC_CTRL
......@@ -3433,6 +3445,9 @@ void EncAppCfg::xPrintParameter()
#endif
#if JVET_K0157
msg(VERBOSE, "CompositeLTReference:%d ", m_compositeRefEnabled);
#endif
#if JVET_K0076_CPR
msg(VERBOSE, "CPR:%d ", m_IBCMode);
#endif
}
// ADD_NEW_TOOL (add some output indicating the usage of tools)
......
......@@ -285,6 +285,15 @@ protected:
#endif
#if JVET_K0157
bool m_compositeRefEnabled;
#endif
#if JVET_K0076_CPR
unsigned m_IBCMode;
unsigned m_IBCLocalSearchRangeX;
unsigned m_IBCLocalSearchRangeY;
unsigned m_IBCHashSearch;
unsigned m_IBCHashSearchMaxCand;
unsigned m_IBCHashSearchRange4SmallBlk;
unsigned m_IBCFastMethod;
#endif
// ADD_NEW_TOOL : (encoder app) add tool enabling flags and associated parameters here
......
......@@ -27,6 +27,9 @@ file( GLOB AVX2_SRC_FILES "../CommonLib/x86/avx2/*.cpp" )
# get sse4.1 source files
file( GLOB SSE41_SRC_FILES "../CommonLib/x86/sse41/*.cpp" )
# get sse4.2 source files
file( GLOB SSE42_SRC_FILES "../CommonLib/x86/sse42/*.cpp" )
# get libmd5 source files
file( GLOB MD5_SRC_FILES "../libmd5/*.cpp" )
......@@ -35,7 +38,7 @@ file( GLOB MD5_INC_FILES "../libmd5/*.h" )
# get all source files
set( SRC_FILES ${BASE_SRC_FILES} ${X86_SRC_FILES} ${SSE41_SRC_FILES} ${AVX_SRC_FILES} ${AVX2_SRC_FILES} ${MD5_SRC_FILES} )
set( SRC_FILES ${BASE_SRC_FILES} ${X86_SRC_FILES} ${SSE41_SRC_FILES} ${SSE42_SRC_FILES} ${AVX_SRC_FILES} ${AVX2_SRC_FILES} ${MD5_SRC_FILES} )
# get all include files
set( INC_FILES ${BASE_INC_FILES} ${X86_INC_FILES} ${MD5_INC_FILES} )
......@@ -86,6 +89,7 @@ target_link_libraries( ${LIB_NAME} Threads::Threads )
# set needed compile definitions
set_property( SOURCE ${SSE41_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_SSE41 )
set_property( SOURCE ${SSE42_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_SSE42 )
set_property( SOURCE ${AVX_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_AVX )
set_property( SOURCE ${AVX2_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_AVX2 )
# set needed compile flags
......@@ -94,6 +98,7 @@ if( MSVC )
set_property( SOURCE ${AVX2_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2" )
elseif( UNIX )
set_property( SOURCE ${SSE41_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-msse4.1" )
set_property( SOURCE ${SSE42_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-msse4.2" )
set_property( SOURCE ${AVX_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-mavx" )
set_property( SOURCE ${AVX2_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-mavx2" )
endif()
......
......@@ -2303,6 +2303,10 @@ void AdaptiveLoopFilter::xCUAdaptive( CodingStructure& cs, const PelUnitBuf &rec
for( auto &currCU : cs.traverseCUs( ctuArea, CH_L ) )
{
#if JVET_K0076_CPR_DT
if (currCU.chType != CH_L)
break;
#endif
const Position& cuPos = currCU.lumaPos();
const int qtDepth = currCU.qtDepth;
const unsigned qtSize = maxCUSize >> qtDepth;
......
......@@ -667,8 +667,11 @@ struct UnitBuf
void removeHighFreq ( const UnitBuf<T>& other, const bool bClip, const ClpRngs& clpRngs);
#if JEM_TOOLS
#if JVET_K0076_CPR_DT
void smoothWithRef(const UnitBuf<const T>& refBuf, const ClpRngs& clpRngs, const bool lumaCh = true, const bool chromaCh = true);
#else
void smoothWithRef ( const UnitBuf<const T>& refBuf, const ClpRngs& clpRngs );
#endif
#endif
UnitBuf< T> subBuf (const UnitArea& subArea);
const UnitBuf<const T> subBuf (const UnitArea& subArea) const;
......@@ -813,11 +816,21 @@ const UnitBuf<const T> UnitBuf<T>::subBuf( const UnitArea& subArea ) const
#if JEM_TOOLS
template<typename T>
#if JVET_K0076_CPR_DT
void UnitBuf<T>::smoothWithRef(const UnitBuf<const T>& refBuf, const ClpRngs& clpRngs, const bool lumaCh, const bool chromaCh)
#else
void UnitBuf<T>::smoothWithRef( const UnitBuf<const T>& refBuf, const ClpRngs& clpRngs )
#endif
{
for( int comp = 0; comp < bufs.size(); comp++ )
{
const ComponentID compID = ComponentID( comp );
#if JVET_K0076_CPR_DT
if (compID == COMPONENT_Y && !lumaCh)
continue;
if (compID != COMPONENT_Y && !chromaCh)
continue;
#endif
get( compID ).smoothWithRef( refBuf.get( compID ), clpRngs.comp[compID] );
}
}
......
......@@ -24,6 +24,9 @@ file( GLOB AVX_SRC_FILES "x86/avx/*.cpp" )
# get avx2 source files
file( GLOB AVX2_SRC_FILES "x86/avx2/*.cpp" )
# get sse4.2 source files
file( GLOB SSE42_SRC_FILES "x86/sse42/*.cpp" )
# get sse4.1 source files
file( GLOB SSE41_SRC_FILES "x86/sse41/*.cpp" )
......@@ -35,7 +38,7 @@ file( GLOB MD5_INC_FILES "../libmd5/*.h" )
# get all source files
set( SRC_FILES ${BASE_SRC_FILES} ${X86_SRC_FILES} ${SSE41_SRC_FILES} ${AVX_SRC_FILES} ${AVX2_SRC_FILES} ${MD5_SRC_FILES} )
set( SRC_FILES ${BASE_SRC_FILES} ${X86_SRC_FILES} ${SSE41_SRC_FILES} ${SSE42_SRC_FILES} ${AVX_SRC_FILES} ${AVX2_SRC_FILES} ${MD5_SRC_FILES} )
# get all include files
set( INC_FILES ${BASE_INC_FILES} ${X86_INC_FILES} ${MD5_INC_FILES} )
......@@ -85,6 +88,7 @@ target_link_libraries( ${LIB_NAME} Threads::Threads )
# set needed compile definitions
set_property( SOURCE ${SSE41_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_SSE41 )
set_property( SOURCE ${SSE42_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_SSE42 )
set_property( SOURCE ${AVX_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_AVX )
set_property( SOURCE ${AVX2_SRC_FILES} APPEND PROPERTY COMPILE_DEFINITIONS USE_AVX2 )
# set needed compile flags
......@@ -93,6 +97,7 @@ if( MSVC )
set_property( SOURCE ${AVX2_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2" )
elseif( UNIX )
set_property( SOURCE ${SSE41_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-msse4.1" )
set_property( SOURCE ${SSE42_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-msse4.2" )
set_property( SOURCE ${AVX_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-mavx" )
set_property( SOURCE ${AVX2_SRC_FILES} APPEND PROPERTY COMPILE_FLAGS "-mavx2" )
endif()
......
......@@ -564,7 +564,13 @@ cTUTraverser CodingStructure::traverseTUs( const UnitArea& unit, const ChannelTy
void CodingStructure::allocateVectorsAtPicLevel()
{
const int twice = ( !pcv->ISingleTree && slice->isIntra() && pcv->chrFormat != CHROMA_400 ) ? 2 : 1;
const int twice = (
#if JVET_K0076_CPR_DT
(!pcv->ISingleTree && (slice->isIntra() || (this->slice->getNumRefIdx(REF_PIC_LIST_0) == 1 && this->slice->getNumRefIdx(REF_PIC_LIST_1) == 0 && this->slice->getRefPOC(REF_PIC_LIST_0, 0) == this->slice->getPOC())))
#else
!pcv->ISingleTree && slice->isIntra()
#endif
&& pcv->chrFormat != CHROMA_400 ) ? 2 : 1;
size_t allocSize = twice * unitScale[0].scale( area.blocks[0].size() ).area();
cus.reserve( allocSize );
......@@ -762,7 +768,11 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
if( cpyResi ) picture->getResiBuf( clippedArea ).copyFrom( subResiBuf );
if( cpyReco ) picture->getRecoBuf( clippedArea ).copyFrom( subRecoBuf );
#if JVET_K0076_CPR_DT
if (!subStruct.m_isTuEnc && (!slice->isIntra() && subStruct.chType != CHANNEL_TYPE_CHROMA))
#else
if( !subStruct.m_isTuEnc && !slice->isIntra() )
#endif
{
// copy motion buffer
MotionBuf ownMB = getMotionBuf ( clippedArea );
......@@ -1398,3 +1408,38 @@ const TransformUnit* CodingStructure::getTURestricted( const Position &pos, cons
}
}
#if JVET_K0076_CPR_DT
IbcLumaCoverage CodingStructure::getIbcLumaCoverage(const CompArea& chromaArea) const
{
CHECK(chType != CHANNEL_TYPE_CHROMA, "Error");
static const unsigned int unitArea = MIN_PU_SIZE * MIN_PU_SIZE;
CompArea lumaArea = CompArea(COMPONENT_Y, chromaArea.chromaFormat, chromaArea.lumaPos(), recalcSize(chromaArea.chromaFormat, CHANNEL_TYPE_CHROMA, CHANNEL_TYPE_LUMA, chromaArea.size()));
lumaArea = clipArea(lumaArea, picture->block(COMPONENT_Y));
const unsigned int fullArea = lumaArea.area();
unsigned int ibcArea = 0;
for (SizeType y = 0; y < lumaArea.height; y += MIN_PU_SIZE)
{
for (SizeType x = 0; x < lumaArea.width; x += MIN_PU_SIZE)
{
Position pos = lumaArea.offset(x, y);
if (picture->cs->getMotionInfo(pos).isInter) // need to change if inter slice allows dualtree
{
ibcArea += unitArea;
}
}
}
IbcLumaCoverage coverage = IBC_LUMA_COVERAGE_FULL;
if (ibcArea == 0)
{
coverage = IBC_LUMA_COVERAGE_NONE;
}
else if (ibcArea < fullArea)
{
coverage = IBC_LUMA_COVERAGE_PARTIAL;
}
return coverage;
}
#endif
\ No newline at end of file
......@@ -58,7 +58,15 @@ enum PictureType
PIC_ORG_RESI,
NUM_PIC_TYPES
};
#if JVET_K0076_CPR_DT
enum IbcLumaCoverage
{
IBC_LUMA_COVERAGE_FULL = 0,
IBC_LUMA_COVERAGE_PARTIAL,
IBC_LUMA_COVERAGE_NONE,
NUM_IBC_LUMA_COVERAGE,
};
#endif
extern XUCache g_globalUnitCache;
// ---------------------------------------------------------------------------
......@@ -77,6 +85,9 @@ public:
Slice *slice;
UnitScale unitScale[MAX_NUM_COMPONENT];
#if JVET_K0076_CPR
ChannelType chType;
#endif
int baseQP;
int prevQP[MAX_NUM_CHANNEL_TYPE];
......@@ -147,7 +158,9 @@ public:
cCUTraverser traverseCUs(const UnitArea& _unit, const ChannelType _chType) const;
cPUTraverser traversePUs(const UnitArea& _unit, const ChannelType _chType) const;
cTUTraverser traverseTUs(const UnitArea& _unit, const ChannelType _chType) const;
#if JVET_K0076_CPR_DT
IbcLumaCoverage getIbcLumaCoverage(const CompArea& chromaArea) const;
#endif
// ---------------------------------------------------------------------------
// encoding search utilities
// ---------------------------------------------------------------------------
......
......@@ -114,7 +114,28 @@ struct UnitScale
Size scale( const Size &size ) const { return { size.width >> posx, size.height >> posy }; }
Area scale( const Area &_area ) const { return Area( scale( _area.pos() ), scale( _area.size() ) ); }
};
#if JVET_K0076_CPR
namespace std
{
template <>
struct hash<Position> : public unary_function<Position, uint64_t>
{
uint64_t operator()(const Position& value) const
{
return (((uint64_t)value.x << 32) + value.y);
}
};
template <>
struct hash<Size> : public unary_function<Size, uint64_t>
{
uint64_t operator()(const Size& value) const
{
return (((uint64_t)value.width << 32) + value.height);
}
};
}
#endif
inline size_t rsAddr(const Position &pos, const uint32_t stride, const UnitScale &unitScale )
{
return (size_t)(stride >> unitScale.posx) * (size_t)(pos.y >> unitScale.posy) + (size_t)(pos.x >> unitScale.posx);
......
......@@ -449,7 +449,14 @@ static const int NTAPS_CHROMA = 4; ///< Numb
#if JEM_TOOLS
static const int NTAPS_LUMA_FRUC = 2;
#endif
#if JVET_K0076_CPR
static const int IBC_MAX_CAND_SIZE = 16; // max block size for ibc search
static const int IBC_NUM_CANDIDATES = 64; ///< Maximum number of candidates to store/test
static const int CHROMA_REFINEMENT_CANDIDATES = 8; /// 8 candidates BV to choose from
static const int IBC_FAST_METHOD_NOINTRA_IBCCBF0 = 0x01;
static const int IBC_FAST_METHOD_BUFFERBV = 0X02;
static const int IBC_FAST_METHOD_ADAPTIVE_SEARCHRANGE = 0X04;
#endif
// ====================================================================================================================
// Macro functions
// ====================================================================================================================
......
......@@ -764,7 +764,14 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx )
pu.mvpIdx [REF_PIC_LIST_1] = NOT_VALID;
pu.mvpNum [REF_PIC_LIST_0] = NOT_VALID;
pu.mvpNum [REF_PIC_LIST_1] = NOT_VALID;
#if JVET_K0076_CPR
if (interDirNeighbours[candIdx] == 1 && pu.cs->slice->getRefPic(REF_PIC_LIST_0, mvFieldNeighbours[candIdx << 1].refIdx)->getPOC() == pu.cs->slice->getPOC())
{
pu.cu->ibc = true;
pu.bv = pu.mv[REF_PIC_LIST_0];
pu.bv >>= 2; // used for only integer resolution
}
#endif
#if JEM_TOOLS
if( pu.lumaSize() == pu.cu->lumaSize() )
{
......
This diff is collapsed.
/* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
*
* Copyright (c) 2010-2017, ITU/ISO/IEC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \file IbcHashMap.h
\brief IBC hash map encoder class (header)
*/
#ifndef __IBCHASHMAP__
#define __IBCHASHMAP__
// Include files
#include "CommonLib/CommonDef.h"
#include "CommonLib/IntraPrediction.h"
#include "CommonLib/InterPrediction.h"
#include "CommonLib/TrQuant.h"
#include "CommonLib/Unit.h"
#include "CommonLib/UnitPartitioner.h"
#include <unordered_map>
#include <vector>
//! \ingroup EncoderLib
//! \{
// ====================================================================================================================
// Class definition
// ====================================================================================================================
class IbcHashMap
{
private:
int m_picWidth;
int m_picHeight;
unsigned int** m_pos2Hash;
std::unordered_map<unsigned int, std::vector<Position>> m_hash2Pos;
unsigned int xxCalcBlockHash(const Pel* pel, const int stride, const int width, const int height, unsigned int crc);
template<ChromaFormat chromaFormat>
void xxBuildPicHashMap(const PelUnitBuf& pic);
static uint32_t xxComputeCrc32c16bit(uint32_t crc, const Pel pel);
public:
uint32_t (*m_computeCrc32c) (uint32_t crc, const Pel pel);
IbcHashMap();
virtual ~IbcHashMap();
void init(const int picWidth, const int picHeight);
void destroy();
void rebuildPicHashMap(const PelUnitBuf& pic);
bool ibcHashMatch(const Area& lumaArea, std::vector<Position>& cand, const CodingStructure& cs, const int maxCand, const int searchRange4SmallBlk);
int getHashHitRatio(const Area& lumaArea);
#ifdef TARGET_SIMD_X86
void initIbcHashMapX86();
template <X86_VEXT vext>
void _initIbcHashMapX86();
#endif
};
//! \}
#endif // __IBCHASHMAP__
......@@ -663,10 +663,52 @@ void InterPrediction::xSubPuMC( PredictionUnit& pu, PelUnitBuf& predBuf, const R
}
#endif
#if JVET_K0076_CPR_DT
void InterPrediction::xChromaMC(PredictionUnit &pu, PelUnitBuf& pcYuvPred)
{
// separated tree, chroma
const CompArea lumaArea = CompArea(COMPONENT_Y, pu.chromaFormat, pu.Cb().lumaPos(), recalcSize(pu.chromaFormat, CHANNEL_TYPE_CHROMA, CHANNEL_TYPE_LUMA, pu.Cb().size()));
PredictionUnit subPu;
subPu.cs = pu.cs;
subPu.cu = pu.cu;
Picture * refPic = pu.cu->slice->getPic();
for (int y = lumaArea.y; y < lumaArea.y + lumaArea.height; y += MIN_PU_SIZE)
{
for (int x = lumaArea.x; x < lumaArea.x + lumaArea.width; x += MIN_PU_SIZE)
{
const MotionInfo &curMi = pu.cs->picture->cs->getMotionInfo(Position{ x, y });
subPu.UnitArea::operator=(UnitArea(pu.chromaFormat, Area(x, y, MIN_PU_SIZE, MIN_PU_SIZE)));
PelUnitBuf subPredBuf = pcYuvPred.subBuf(UnitAreaRelative(pu, subPu));
xPredInterBlk(COMPONENT_Cb, subPu, refPic, curMi.mv[0], subPredBuf, false, pu.cu->slice->clpRng(COMPONENT_Cb)
#if JEM_TOOLS
void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi, const bool& bBIOApplied /*= false*/, const bool& bDMVRApplied /*= false*/ )
, false, false, FRUC_MERGE_OFF, false
#endif
);
xPredInterBlk(COMPONENT_Cr, subPu, refPic, curMi.mv[0], subPredBuf, false, pu.cu->slice->clpRng(COMPONENT_Cr)
#if JEM_TOOLS
, false, false, FRUC_MERGE_OFF, false
#endif
);
}
}
}
#endif
#if JEM_TOOLS
void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi, const bool& bBIOApplied /*= false*/, const bool& bDMVRApplied /*= false*/
#if JVET_K0076_CPR_DT
, const bool luma, const bool chroma
#endif
)
#else
void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi )
void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi
#if JVET_K0076_CPR_DT
, const bool luma, const bool chroma
#endif
)
#endif
{
const SPS &sps = *pu.cs->sps;
......@@ -702,7 +744,12 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList&
for( uint32_t comp = COMPONENT_Y; comp < pcYuvPred.bufs.size() && comp <= m_maxCompIDToPred; comp++ )
{
const ComponentID compID = ComponentID( comp );
#if JVET_K0076_CPR_DT
if (compID == COMPONENT_Y && !luma)
continue;
if (compID != COMPONENT_Y && !chroma)
continue;
#endif
#if JEM_TOOLS
if( pu.cu->affine )
{
......@@ -1811,8 +1858,33 @@ void InterPrediction::xWeightedAverage( const PredictionUnit& pu, const CPelUnit
}
}
void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBuf, const RefPicList &eRefPicList )
void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBuf, const RefPicList &eRefPicList
#if JVET_K0076_CPR_DT
, const bool luma, const bool chroma
#endif
)
{
#if JVET_K0076_CPR_DT
// dual tree handling for CPR as the only ref
if (!luma || !chroma)
{
if (!luma && chroma)
{
xChromaMC(pu, predBuf);
return;
}
else // (luma && !chroma)
{
xPredInterUni(pu, eRefPicList, predBuf, false,
#if JEM_TOOLS
false, false,
#endif
luma, chroma);
return;
}
}
// else, go with regular MC below
#endif
CodingStructure &cs = *pu.cs;
const PPS &pps = *cs.pps;
const SliceType sliceType = cs.slice->getSliceType();
......@@ -1836,7 +1908,11 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu
else
{
#if JEM_TOOLS || JVET_K0346
#if JVET_K0076_CPR
if (pu.mergeType != MRG_TYPE_DEFAULT_N && pu.mergeType != MRG_TYPE_IBC)
#else
if( pu.mergeType != MRG_TYPE_DEFAULT_N )
#endif
{
xSubPuMC( pu, predBuf, eRefPicList );
}
......@@ -1855,14 +1931,22 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu
return;
}
void InterPrediction::motionCompensation( CodingUnit &cu, const RefPicList &eRefPicList )
void InterPrediction::motionCompensation( CodingUnit &cu, const RefPicList &eRefPicList
#if JVET_K0076_CPR_DT
, const bool luma, const bool chroma
#endif
)
{
for( auto &pu : CU::traversePUs( cu ) )
{
PelUnitBuf predBuf = cu.cs->getPredBuf( pu );
#if JEM_TOOLS
pu.mvRefine = true;
motionCompensation( pu, predBuf, eRefPicList );
motionCompensation( pu, predBuf, eRefPicList
#if JVET_K0076_CPR_DT
, luma, chroma
#endif
);
pu.mvRefine = false;
#else
motionCompensation( pu, predBuf, eRefPicList );
......@@ -1870,10 +1954,18 @@ void InterPrediction::motionCompensation( CodingUnit &cu, const RefPicList &eRef
}
}
void InterPrediction::motionCompensation( PredictionUnit &pu, const RefPicList &eRefPicList /*= REF_PIC_LIST_X*/ )
void InterPrediction::motionCompensation( PredictionUnit &pu, const RefPicList &eRefPicList /*= REF_PIC_LIST_X*/
#if JVET_K0076_CPR_DT
, const bool luma, const bool chroma
#endif
)
{
PelUnitBuf predBuf = pu.cs->getPredBuf( pu );
motionCompensation( pu, predBuf, eRefPicList );
motionCompensation( pu, predBuf, eRefPicList
#if JVET_K0076_CPR_DT
, luma, chroma
#endif
);
}
#if JEM_TOOLS
......@@ -2944,6 +3036,10 @@ void InterPrediction::xFrucCollectBlkStartMv( PredictionUnit& pu, const MergeCtx
for( int nMergeIndex = 0; nMergeIndex < mergeCtx.numValidMergeCand << 1; nMergeIndex++ )
{
bool mrgTpDflt = ( pu.cs->sps->getSpsNext().getUseSubPuMvp() ) ? mergeCtx.mrgTypeNeighbours[nMergeIndex>>1] == MRG_TYPE_DEFAULT_N : true;
#if JVET_K0076_CPR
if ((mergeCtx.interDirNeighbours[nMergeIndex >> 1] == 1 || mergeCtx.interDirNeighbours[nMergeIndex >> 1] == 3) && pu.cs->slice->getRefPic(REF_PIC_LIST_0, mergeCtx.mvFieldNeighbours[nMergeIndex].refIdx)->getPOC() == pu.cs->slice->getPOC())
continue;
#endif
if( mergeCtx.mvFieldNeighbours[nMergeIndex].refIdx >= 0 && mrgTpDflt )
{
if( nTargetRefIdx >= 0 && ( mergeCtx.mvFieldNeighbours[nMergeIndex].refIdx != nTargetRefIdx || ( nMergeIndex & 0x01 ) != ( int )eTargetRefList ) )
......
......@@ -217,10 +217,18 @@ protected:
#endif
#if JEM_TOOLS
void xPredInterUni ( const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi, const bool& bBIOApplied = false, const bool& bDMVRApplied = false );
void xPredInterUni ( const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi, const bool& bBIOApplied = false, const bool& bDMVRApplied = false
#if JVET_K0076_CPR_DT
, const bool luma = true, const bool chroma = true
#endif
);
void xPredInterBi ( PredictionUnit& pu, PelUnitBuf &pcYuvPred, bool obmc = false );
#else
void xPredInterUni ( const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi );
void xPredInterUni ( const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi
#if JVET_K0076_CPR_DT
, const bool luma = true, const bool chroma = true
#endif
);
void xPredInterBi ( PredictionUnit& pu, PelUnitBuf &pcYuvPred );
#endif
void xPredInterBlk ( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv& _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng
......@@ -262,7 +270,9 @@ protected:
#if JEM_TOOLS
void xSubBlockMotionCompensation( PredictionUnit &pu, PelUnitBuf &pcYuvPred );
#endif
#if JVET_K0076_CPR_DT
void xChromaMC ( PredictionUnit &pu, PelUnitBuf& pcYuvPred );
#endif
void destroy();
#if JEM_TOOLS
......@@ -355,9 +365,21 @@ public:
void init (RdCost* pcRdCost, ChromaFormat chromaFormatIDC);
// inter
void motionCompensation (PredictionUnit &pu, PelUnitBuf& predBuf, const RefPicList &eRefPicList = REF_PIC_LIST_X);
void motionCompensation (PredictionUnit &pu, const RefPicList &eRefPicList = REF_PIC_LIST_X);
void motionCompensation (CodingUnit &cu, const RefPicList &eRefPicList = REF_PIC_LIST_X);