Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
karam naser
VVCSoftware_VTM
Commits
1a7aa7bd
Commit
1a7aa7bd
authored
May 14, 2021
by
karam naser
Browse files
further cleanups of intra TMP
parent
7054c8e5
Changes
35
Hide whitespace changes
Inline
Side-by-side
source/App/EncoderApp/EncApp.cpp
View file @
1a7aa7bd
...
...
@@ -788,7 +788,7 @@ void EncApp::xInitLibCfg()
m_cEncLib
.
setUseWrapAround
(
m_wrapAround
);
m_cEncLib
.
setWrapAroundOffset
(
m_wrapAroundOffset
);
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
m_cEncLib
.
setUseIntraTMP
(
m_IntraTMP
);
m_cEncLib
.
setIntraTMPMaxSize
(
m_IntraTMP_MaxSize
);
#endif
...
...
source/App/EncoderApp/EncAppCfg.cpp
View file @
1a7aa7bd
...
...
@@ -1044,7 +1044,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
(
"AdditionalInterHypRefFrames"
,
m_maxNumAddHypRefFrames
,
4
,
"max. number of ref frames for additional inter hypotheseis"
)
(
"AdditionalInterHypTries"
,
m_addHypTries
,
1
,
"number of tries for additional inter prediction hypotheseis"
)
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
(
"IntraTMP"
,
m_IntraTMP
,
false
,
"intra Template Matching (0: off, 1:on) [default: on]"
)
(
"IntraTMPMaxSize"
,
m_IntraTMP_MaxSize
,
64u
,
"intra Template Matching max CU size [default: 64]"
)
#endif
...
...
@@ -4176,12 +4176,12 @@ void EncAppCfg::xPrintParameter()
}
#endif
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
msg
(
DETAILS
,
"Intra TMP: %d
\n
"
,
m_IntraTMP
);
msg
(
DETAILS
,
"Max CU size of TMP: %d
\n
"
,
m_IntraTMP_MaxSize
);
msg
(
DETAILS
,
"dynamic search range with fixed comparison per pixel:
\n
"
);
msg
(
DETAILS
,
" searchRangeWidth = %d*Width
\n
"
,
I
DCC
_SearchRangeMultFactor
);
msg
(
DETAILS
,
" searchRangeHeight = %d*Heigh
\n
"
,
I
DCC
_SearchRangeMultFactor
);
msg
(
DETAILS
,
" searchRangeWidth = %d*Width
\n
"
,
I
NTRA_TMP
_SearchRangeMultFactor
);
msg
(
DETAILS
,
" searchRangeHeight = %d*Heigh
\n
"
,
I
NTRA_TMP
_SearchRangeMultFactor
);
#endif
msg
(
DETAILS
,
"Max Num Merge Candidates : %d
\n
"
,
m_maxNumMergeCand
);
...
...
@@ -4316,7 +4316,7 @@ void EncAppCfg::xPrintParameter()
{
msg
(
VERBOSE
,
"WrapAroundOffset:%d "
,
m_wrapAroundOffset
);
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
msg
(
VERBOSE
,
"IntraTMP:%d "
,
m_IntraTMP
);
msg
(
VERBOSE
,
"IntraTMP_MaxSize:%d "
,
m_IntraTMP_MaxSize
);
#endif
...
...
source/App/EncoderApp/EncAppCfg.h
View file @
1a7aa7bd
...
...
@@ -411,7 +411,7 @@ protected:
int
m_maxNumAddHypRefFrames
;
///< max. number of ref frames for additional inter hypotheseis
int
m_addHypTries
;
///< max. number of tries for additional inter hypotheseis
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
bool
m_IntraTMP
;
///< intra Template Matching
unsigned
m_IntraTMP_MaxSize
;
///< max CU size for which intra TMP is allowed
#endif
...
...
source/Lib/CommonLib/CommonDef.h
View file @
1a7aa7bd
...
...
@@ -477,8 +477,8 @@ static const int ALF_VB_POS_ABOVE_CTUROW_CHMA = 2;
static
const
int
MAX_ENCODER_DEBLOCKING_QUALITY_LAYERS
=
8
;
#endif
#if
IDCC_TPM_JEM
static
const
int
USE_MORE_BLOCKSIZE_DEPTH_MAX
=
IDCC_TMP_MaxSize_Depth
-
1
;
#if
JVET_V0130_INTRA_TMP
static
const
int
USE_MORE_BLOCKSIZE_DEPTH_MAX
=
5
;
static
const
int
INIT_THRESHOULD_SHIFTBITS
=
2
;
///< (default 2) Early skip threshold for checking distance.
#endif
...
...
source/Lib/CommonLib/ContextModelling.cpp
View file @
1a7aa7bd
...
...
@@ -778,7 +778,7 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx)
PU
::
restrictBiPredMergeCandsOne
(
pu
);
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
unsigned
DeriveCtx
::
CtxTmpFlag
(
const
CodingUnit
&
cu
)
{
const
CodingStructure
*
cs
=
cu
.
cs
;
...
...
source/Lib/CommonLib/ContextModelling.h
View file @
1a7aa7bd
...
...
@@ -611,7 +611,7 @@ unsigned CtxAffineFlag( const CodingUnit& cu );
unsigned
CtxPredModeFlag
(
const
CodingUnit
&
cu
);
unsigned
CtxIBCFlag
(
const
CodingUnit
&
cu
);
unsigned
CtxMipFlag
(
const
CodingUnit
&
cu
);
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
unsigned
CtxTmpFlag
(
const
CodingUnit
&
cu
);
#endif
unsigned
CtxPltCopyFlag
(
const
unsigned
prevRunType
,
const
unsigned
dist
);
...
...
source/Lib/CommonLib/Contexts.cpp
View file @
1a7aa7bd
...
...
@@ -1000,7 +1000,7 @@ const CtxSet ContextSetCfg::MipFlag = ContextSetCfg::addCtxSet
{
9
,
9
,
8
,
6
},
{
10
,
10
,
9
,
6
}
});
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
const
CtxSet
ContextSetCfg
::
TmpFlag
=
ContextSetCfg
::
addCtxSet
({
{
CNU
,
CNU
,
CNU
,
CNU
,
},
...
...
@@ -2089,7 +2089,7 @@ const CtxSet ContextSetCfg::MipFlag = ContextSetCfg::addCtxSet
{
33
,
49
,
50
,
25
,
},
{
9
,
10
,
9
,
6
,
},
});
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
const
CtxSet
ContextSetCfg
::
TmpFlag
=
ContextSetCfg
::
addCtxSet
({
{
CNU
,
CNU
,
CNU
,
CNU
,
},
...
...
source/Lib/CommonLib/Contexts.h
View file @
1a7aa7bd
...
...
@@ -245,7 +245,7 @@ public:
static
const
CtxSet
CclmModeIdx
;
static
const
CtxSet
IntraChromaPredMode
;
static
const
CtxSet
MipFlag
;
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
static
const
CtxSet
TmpFlag
;
#endif
#if MMLM
...
...
source/Lib/CommonLib/IntraPrediction.cpp
View file @
1a7aa7bd
...
...
@@ -686,7 +686,7 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA
if
(
sps
.
getSpsRangeExtension
().
getIntraSmoothingDisabledFlag
()
||
!
isLuma
(
chType
)
||
useISP
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
||
PU
::
isTmp
(
pu
,
chType
)
#endif
||
PU
::
isMIP
(
pu
,
chType
)
...
...
@@ -1394,7 +1394,7 @@ void IntraPrediction::initIntraPatternChTypeISP(const CodingUnit& cu, const Comp
}
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
bool
IntraPrediction
::
isRefTemplateAvailable
(
CodingUnit
&
cu
,
CompArea
&
area
)
{
const
ChannelType
chType
=
toChannelType
(
area
.
compID
);
...
...
source/Lib/CommonLib/IntraPrediction.h
View file @
1a7aa7bd
...
...
@@ -144,7 +144,7 @@ protected:
void
xPredIntraBDPCM
(
const
CPelBuf
&
pSrc
,
PelBuf
&
pDst
,
const
uint32_t
dirMode
,
const
ClpRng
&
clpRng
);
Pel
xGetPredValDc
(
const
CPelBuf
&
pSrc
,
const
Size
&
dstSize
);
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
bool
isRefTemplateAvailable
(
CodingUnit
&
cu
,
CompArea
&
area
);
#endif
...
...
source/Lib/CommonLib/Slice.cpp
View file @
1a7aa7bd
...
...
@@ -3113,7 +3113,7 @@ SPS::SPS()
#if ENABLE_DIMD
,
m_dimd
(
false
)
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
,
m_IntraTMP
(
false
)
,
m_IntraTMP_MaxSize
(
64
)
#endif
...
...
source/Lib/CommonLib/Slice.h
View file @
1a7aa7bd
...
...
@@ -1651,7 +1651,7 @@ private:
#if ENABLE_DIMD
bool
m_dimd
;
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
bool
m_IntraTMP
;
///< intra Template Matching
unsigned
m_IntraTMP_MaxSize
;
///< max CU size for which intra TMP is allowed
#endif
...
...
@@ -2077,7 +2077,7 @@ void setCCALFEnabledFlag( bool b )
void
setUseDimd
(
bool
b
)
{
m_dimd
=
b
;
}
bool
getUseDimd
()
const
{
return
m_dimd
;
}
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
void
setUseIntraTMP
(
bool
b
)
{
m_IntraTMP
=
b
;
}
bool
getUseIntraTMP
()
const
{
return
m_IntraTMP
;
}
void
setIntraTMPMaxSize
(
unsigned
n
)
{
m_IntraTMP_MaxSize
=
n
;
}
...
...
source/Lib/CommonLib/TrQuant.cpp
View file @
1a7aa7bd
...
...
@@ -55,11 +55,11 @@
#include "CommonLib/CodingStatistics.h"
#endif
#if I
DCC
_TMP_SIMD
#if I
NTRA
_TMP_SIMD
#include "CommonDefX86.h"
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
unsigned
int
g_uiDepth2Width
[
5
]
=
{
4
,
8
,
16
,
32
,
64
};
#endif
...
...
@@ -197,7 +197,7 @@ TrQuant::TrQuant() : m_quant( nullptr )
m_fwdICT
[
-
2
]
=
fwdTransformCbCr
<-
2
>
;
m_fwdICT
[
3
]
=
fwdTransformCbCr
<
3
>
;
m_fwdICT
[
-
3
]
=
fwdTransformCbCr
<-
3
>
;
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
m_pppTarPatch
=
NULL
;
#endif
}
...
...
@@ -210,17 +210,17 @@ TrQuant::~TrQuant()
delete
m_quant
;
m_quant
=
nullptr
;
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
if
(
m_pppTarPatch
!=
NULL
)
{
for
(
unsigned
int
uiDepth
=
0
;
uiDepth
<
USE_MORE_BLOCKSIZE_DEPTH_MAX
;
uiDepth
++
)
{
unsigned
int
blkSize
=
g_uiDepth2Width
[
uiDepth
];
unsigned
int
patchSize
=
blkSize
+
I
DCC
_TemplateSize
;
unsigned
int
patchSize
=
blkSize
+
I
NTRA_TMP
_TemplateSize
;
for
(
unsigned
int
uiRow
=
0
;
uiRow
<
patchSize
;
uiRow
++
)
{
if
(
m_pppTarPatch
[
uiDepth
][
uiRow
]
!=
NULL
)
...
...
@@ -275,7 +275,7 @@ void TrQuant::init( const Quant* otherQuant,
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
unsigned
int
blkSize
;
if
(
m_pppTarPatch
==
NULL
)
...
...
@@ -285,7 +285,7 @@ void TrQuant::init( const Quant* otherQuant,
{
blkSize
=
g_uiDepth2Width
[
uiDepth
];
unsigned
int
patchSize
=
blkSize
+
I
DCC
_TemplateSize
;
unsigned
int
patchSize
=
blkSize
+
I
NTRA_TMP
_TemplateSize
;
m_pppTarPatch
[
uiDepth
]
=
new
Pel
*
[
patchSize
];
for
(
unsigned
int
uiRow
=
0
;
uiRow
<
patchSize
;
uiRow
++
)
{
...
...
@@ -435,21 +435,21 @@ void TrQuant::invLfnstNxN( int* src, int* dst, const uint32_t mode, const uint32
}
}
#if
IDCC_TPM_JEM
void
insertNode
(
DistType
diff
,
int
&
iXOffset
,
int
&
iYOffset
,
DistType
&
pDiff
,
int
&
pX
,
int
&
pY
,
short
&
pId
,
unsigned
int
&
setId
)
#if
JVET_V0130_INTRA_TMP
void
insertNode
(
int
diff
,
int
&
iXOffset
,
int
&
iYOffset
,
int
&
pDiff
,
int
&
pX
,
int
&
pY
,
short
&
pId
,
unsigned
int
&
setId
)
{
pDiff
=
diff
;
pX
=
iXOffset
;
pY
=
iYOffset
;
pId
=
setId
;
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
void
clipMvIntraConstraint
(
CodingUnit
*
pcCU
,
int
regionId
,
int
&
iHorMin
,
int
&
iHorMax
,
int
&
iVerMin
,
int
&
iVerMax
,
unsigned
int
uiTemplateSize
,
unsigned
int
uiBlkWidth
,
unsigned
int
uiBlkHeight
,
int
iCurrY
,
int
iCurrX
,
int
offsetLCUY
,
int
offsetLCUX
)
{
int
SearchRange_Height
,
SearchRange_Width
;
SearchRange_Width
=
I
DCC
_SearchRangeMultFactor
*
uiBlkWidth
;
SearchRange_Height
=
I
DCC
_SearchRangeMultFactor
*
uiBlkHeight
;
SearchRange_Width
=
I
NTRA_TMP
_SearchRangeMultFactor
*
uiBlkWidth
;
SearchRange_Height
=
I
NTRA_TMP
_SearchRangeMultFactor
*
uiBlkHeight
;
int
iMvShift
=
0
;
int
iTemplateSize
=
uiTemplateSize
;
int
iBlkWidth
=
uiBlkWidth
;
...
...
@@ -496,7 +496,7 @@ void clipMvIntraConstraint(CodingUnit* pcCU, int regionId, int& iHorMin, int& iH
#endif
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
TempLibFast
::
TempLibFast
()
{
}
...
...
@@ -506,10 +506,10 @@ TempLibFast::~TempLibFast()
}
#endif
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
void
TempLibFast
::
initTemplateDiff
(
unsigned
int
uiPatchWidth
,
unsigned
int
uiPatchHeight
,
unsigned
int
uiBlkWidth
,
unsigned
int
uiBlkHeight
,
int
bitDepth
)
{
DistType
maxValue
=
((
1
<<
bitDepth
)
>>
(
INIT_THRESHOULD_SHIFTBITS
))
*
(
uiPatchHeight
*
uiPatchWidth
-
uiBlkHeight
*
uiBlkWidth
);
int
maxValue
=
((
1
<<
bitDepth
)
>>
(
INIT_THRESHOULD_SHIFTBITS
))
*
(
uiPatchHeight
*
uiPatchWidth
-
uiBlkHeight
*
uiBlkWidth
);
m_diffMax
=
maxValue
;
{
m_pDiff
=
maxValue
;
...
...
@@ -519,8 +519,8 @@ void TempLibFast::initTemplateDiff(unsigned int uiPatchWidth, unsigned int uiPat
void
TrQuant
::
getTargetTemplate
(
CodingUnit
*
pcCU
,
unsigned
int
uiBlkWidth
,
unsigned
int
uiBlkHeight
)
{
const
ComponentID
compID
=
COMPONENT_Y
;
unsigned
int
uiPatchWidth
=
uiBlkWidth
+
I
DCC
_TemplateSize
;
unsigned
int
uiPatchHeight
=
uiBlkHeight
+
I
DCC
_TemplateSize
;
unsigned
int
uiPatchWidth
=
uiBlkWidth
+
I
NTRA_TMP
_TemplateSize
;
unsigned
int
uiPatchHeight
=
uiBlkHeight
+
I
NTRA_TMP
_TemplateSize
;
unsigned
int
uiTarDepth
=
floorLog2
(
std
::
max
(
uiBlkHeight
,
uiBlkWidth
))
-
2
;
Pel
**
tarPatch
=
m_pppTarPatch
[
uiTarDepth
];
CompArea
area
=
pcCU
->
blocks
[
compID
];
...
...
@@ -533,8 +533,8 @@ void TrQuant::getTargetTemplate(CodingUnit* pcCU, unsigned int uiBlkWidth, unsig
//fill template
//up-left & up
Pel
*
tarTemp
;
Pel
*
pCurrTemp
=
pCurrStart
-
I
DCC
_TemplateSize
*
uiPicStride
-
I
DCC
_TemplateSize
;
for
(
uiY
=
0
;
uiY
<
I
DCC
_TemplateSize
;
uiY
++
)
Pel
*
pCurrTemp
=
pCurrStart
-
I
NTRA_TMP
_TemplateSize
*
uiPicStride
-
I
NTRA_TMP
_TemplateSize
;
for
(
uiY
=
0
;
uiY
<
I
NTRA_TMP
_TemplateSize
;
uiY
++
)
{
tarTemp
=
tarPatch
[
uiY
];
for
(
uiX
=
0
;
uiX
<
uiPatchWidth
;
uiX
++
)
...
...
@@ -544,10 +544,10 @@ void TrQuant::getTargetTemplate(CodingUnit* pcCU, unsigned int uiBlkWidth, unsig
pCurrTemp
+=
uiPicStride
;
}
//left
for
(
uiY
=
I
DCC
_TemplateSize
;
uiY
<
uiPatchHeight
;
uiY
++
)
for
(
uiY
=
I
NTRA_TMP
_TemplateSize
;
uiY
<
uiPatchHeight
;
uiY
++
)
{
tarTemp
=
tarPatch
[
uiY
];
for
(
uiX
=
0
;
uiX
<
I
DCC
_TemplateSize
;
uiX
++
)
for
(
uiX
=
0
;
uiX
<
I
NTRA_TMP
_TemplateSize
;
uiX
++
)
{
tarTemp
[
uiX
]
=
pCurrTemp
[
uiX
];
}
...
...
@@ -559,8 +559,8 @@ void TrQuant::candidateSearchIntra(CodingUnit* pcCU, unsigned int uiBlkWidth, un
{
const
ComponentID
compID
=
COMPONENT_Y
;
const
int
channelBitDepth
=
pcCU
->
cs
->
sps
->
getBitDepth
(
toChannelType
(
compID
));
unsigned
int
uiPatchWidth
=
uiBlkWidth
+
I
DCC
_TemplateSize
;
unsigned
int
uiPatchHeight
=
uiBlkHeight
+
I
DCC
_TemplateSize
;
unsigned
int
uiPatchWidth
=
uiBlkWidth
+
I
NTRA_TMP
_TemplateSize
;
unsigned
int
uiPatchHeight
=
uiBlkHeight
+
I
NTRA_TMP
_TemplateSize
;
unsigned
int
uiTarDepth
=
floorLog2
(
std
::
max
(
uiBlkWidth
,
uiBlkHeight
))
-
2
;
Pel
**
tarPatch
=
getTargetPatch
(
uiTarDepth
);
//Initialize the library for saving the best candidates
...
...
@@ -568,8 +568,8 @@ void TrQuant::candidateSearchIntra(CodingUnit* pcCU, unsigned int uiBlkWidth, un
short
setId
=
0
;
//record the reference picture.
searchCandidateFromOnePicIntra
(
pcCU
,
tarPatch
,
uiPatchWidth
,
uiPatchHeight
,
setId
);
//count collected candidate number
DistType
pDiff
=
m_tempLibFast
.
getDiff
();
DistType
maxDiff
=
m_tempLibFast
.
getDiffMax
();
int
pDiff
=
m_tempLibFast
.
getDiff
();
int
maxDiff
=
m_tempLibFast
.
getDiffMax
();
if
(
pDiff
<
maxDiff
)
...
...
@@ -581,12 +581,12 @@ void TrQuant::candidateSearchIntra(CodingUnit* pcCU, unsigned int uiBlkWidth, un
void
TrQuant
::
searchCandidateFromOnePicIntra
(
CodingUnit
*
pcCU
,
Pel
**
tarPatch
,
unsigned
int
uiPatchWidth
,
unsigned
int
uiPatchHeight
,
unsigned
int
setId
)
{
const
ComponentID
compID
=
COMPONENT_Y
;
unsigned
int
uiBlkWidth
=
uiPatchWidth
-
I
DCC
_TemplateSize
;
unsigned
int
uiBlkHeight
=
uiPatchHeight
-
I
DCC
_TemplateSize
;
unsigned
int
uiBlkWidth
=
uiPatchWidth
-
I
NTRA_TMP
_TemplateSize
;
unsigned
int
uiBlkHeight
=
uiPatchHeight
-
I
NTRA_TMP
_TemplateSize
;
int
pX
=
m_tempLibFast
.
getX
();
int
pY
=
m_tempLibFast
.
getY
();
DistType
pDiff
=
m_tempLibFast
.
getDiff
();
int
pDiff
=
m_tempLibFast
.
getDiff
();
short
pId
=
m_tempLibFast
.
getId
();
CompArea
area
=
pcCU
->
blocks
[
compID
];
int
refStride
=
pcCU
->
cs
->
picture
->
getRecoBuf
(
compID
).
stride
;
...
...
@@ -614,7 +614,7 @@ void TrQuant::searchCandidateFromOnePicIntra(CodingUnit* pcCU, Pel** tarPatch,
int
iYOffset
,
iXOffset
;
DistType
diff
;
int
diff
;
Pel
*
refCurr
;
...
...
@@ -629,7 +629,7 @@ void TrQuant::searchCandidateFromOnePicIntra(CodingUnit* pcCU, Pel** tarPatch,
//1. check the near pixels within LCU
//above pixels in LCU
int
iTemplateSize
=
I
DCC
_TemplateSize
;
int
iTemplateSize
=
I
NTRA_TMP
_TemplateSize
;
int
iBlkWidth
=
uiBlkWidth
;
int
iBlkHeight
=
uiBlkHeight
;
regionId
=
0
;
...
...
@@ -680,7 +680,7 @@ void TrQuant::searchCandidateFromOnePicIntra(CodingUnit* pcCU, Pel** tarPatch,
//2. check the pixels outside CTU
for
(
regionId
=
0
;
regionId
<
regionNum
;
regionId
++
)
{
// this function fills in the range the template matching for pixels outside the current CTU
clipMvIntraConstraint
(
pcCU
,
regionId
,
mvXMins
[
regionId
],
mvXMaxs
[
regionId
],
mvYMins
[
regionId
],
mvYMaxs
[
regionId
],
I
DCC
_TemplateSize
,
uiBlkWidth
,
uiBlkHeight
,
iCurrY
,
iCurrX
,
offsetLCUY
,
offsetLCUX
);
clipMvIntraConstraint
(
pcCU
,
regionId
,
mvXMins
[
regionId
],
mvXMaxs
[
regionId
],
mvYMins
[
regionId
],
mvYMaxs
[
regionId
],
I
NTRA_TMP
_TemplateSize
,
uiBlkWidth
,
uiBlkHeight
,
iCurrY
,
iCurrX
,
offsetLCUY
,
offsetLCUX
);
}
for
(
regionId
=
0
;
regionId
<
regionNum
;
regionId
++
)
{
...
...
@@ -717,8 +717,8 @@ void TrQuant::searchCandidateFromOnePicIntra(CodingUnit* pcCU, Pel** tarPatch,
bool
TrQuant
::
generateTMPrediction
(
Pel
*
piPred
,
unsigned
int
uiStride
,
unsigned
int
uiBlkWidth
,
unsigned
int
uiBlkHeight
,
int
&
foundCandiNum
)
{
bool
bSucceedFlag
=
true
;
unsigned
int
uiPatchWidth
=
uiBlkWidth
+
I
DCC
_TemplateSize
;
unsigned
int
uiPatchHeight
=
uiBlkHeight
+
I
DCC
_TemplateSize
;
unsigned
int
uiPatchWidth
=
uiBlkWidth
+
I
NTRA_TMP
_TemplateSize
;
unsigned
int
uiPatchHeight
=
uiBlkHeight
+
I
NTRA_TMP
_TemplateSize
;
foundCandiNum
=
m_uiVaildCandiNum
;
if
(
foundCandiNum
<
1
)
...
...
@@ -732,8 +732,8 @@ bool TrQuant::generateTMPrediction(Pel* piPred, unsigned int uiStride, unsigned
int
picStride
=
getStride
();
int
iOffsetY
,
iOffsetX
;
Pel
*
refTarget
;
unsigned
int
uiHeight
=
uiPatchHeight
-
I
DCC
_TemplateSize
;
unsigned
int
uiWidth
=
uiPatchWidth
-
I
DCC
_TemplateSize
;
unsigned
int
uiHeight
=
uiPatchHeight
-
I
NTRA_TMP
_TemplateSize
;
unsigned
int
uiWidth
=
uiPatchWidth
-
I
NTRA_TMP
_TemplateSize
;
//the data center: we use the prediction block as the center now.
//collect the candidates
...
...
@@ -755,16 +755,17 @@ bool TrQuant::generateTMPrediction(Pel* piPred, unsigned int uiStride, unsigned
return
bSucceedFlag
;
}
DistType
TrQuant
::
calcTemplateDiff
(
Pel
*
ref
,
unsigned
int
uiStride
,
Pel
**
tarPatch
,
unsigned
int
uiPatchWidth
,
unsigned
int
uiPatchHeight
,
DistType
iMax
)
int
TrQuant
::
calcTemplateDiff
(
Pel
*
ref
,
unsigned
int
uiStride
,
Pel
**
tarPatch
,
unsigned
int
uiPatchWidth
,
unsigned
int
uiPatchHeight
,
int
iMax
)
{
DistType
iDiffSum
=
0
;
#if INTRA_TMP_SIMD
int
iDiffSum
=
0
;
int
iY
;
Pel
*
refPatchRow
=
ref
-
I
DCC
_TemplateSize
*
uiStride
-
I
DCC
_TemplateSize
;
Pel
*
refPatchRow
=
ref
-
I
NTRA_TMP
_TemplateSize
*
uiStride
-
I
NTRA_TMP
_TemplateSize
;
Pel
*
tarPatchRow
;
uint32_t
uiSum
;
// horizontal difference
for
(
iY
=
0
;
iY
<
I
DCC
_TemplateSize
;
iY
++
)
for
(
iY
=
0
;
iY
<
I
NTRA_TMP
_TemplateSize
;
iY
++
)
{
tarPatchRow
=
tarPatch
[
iY
];
const
short
*
pSrc1
=
(
const
short
*
)
tarPatchRow
;
...
...
@@ -830,8 +831,8 @@ DistType TrQuant::calcTemplateDiff(Pel* ref, unsigned int uiStride, Pel** tarPat
}
// vertical difference
int
iCols
=
I
DCC
_TemplateSize
;
for
(
iY
=
I
DCC
_TemplateSize
;
iY
<
uiPatchHeight
;
iY
++
)
int
iCols
=
I
NTRA_TMP
_TemplateSize
;
for
(
iY
=
I
NTRA_TMP
_TemplateSize
;
iY
<
uiPatchHeight
;
iY
++
)
{
tarPatchRow
=
tarPatch
[
iY
];
const
short
*
pSrc1
=
(
const
short
*
)
tarPatchRow
;
...
...
@@ -872,6 +873,39 @@ DistType TrQuant::calcTemplateDiff(Pel* ref, unsigned int uiStride, Pel** tarPat
return
iDiffSum
;
#else
int
iY
,
iX
;
int
iDiffSum
=
0
;
Pel
*
refPatchRow
=
ref
-
INTRA_TMP_TemplateSize
*
uiStride
-
INTRA_TMP_TemplateSize
;
Pel
*
tarPatchRow
;
for
(
iY
=
0
;
iY
<
INTRA_TMP_TemplateSize
;
iY
++
)
{
tarPatchRow
=
tarPatch
[
iY
];
for
(
iX
=
0
;
iX
<
uiPatchWidth
;
iX
++
)
{
iDiffSum
+=
abs
(
refPatchRow
[
iX
]
-
tarPatchRow
[
iX
]);
}
if
(
iDiffSum
>
iMax
)
//for speeding up
{
return
iDiffSum
;
}
refPatchRow
+=
uiStride
;
}
for
(
iY
=
INTRA_TMP_TemplateSize
;
iY
<
uiPatchHeight
;
iY
++
)
{
tarPatchRow
=
tarPatch
[
iY
];
for
(
iX
=
0
;
iX
<
INTRA_TMP_TemplateSize
;
iX
++
)
{
iDiffSum
+=
abs
(
refPatchRow
[
iX
]
-
tarPatchRow
[
iX
]);
}
if
(
iDiffSum
>
iMax
)
//for speeding up
{
return
iDiffSum
;
}
refPatchRow
+=
uiStride
;
}
return
iDiffSum
;
#endif
}
#endif
...
...
@@ -930,7 +964,7 @@ void TrQuant::xInvLfnst( const TransformUnit &tu, const ComponentID compID )
{
intraMode
=
PLANAR_IDX
;
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
if
(
PU
::
isTmp
(
*
tu
.
cs
->
getPU
(
area
.
pos
(),
toChannelType
(
compID
)),
toChannelType
(
compID
)))
{
intraMode
=
PLANAR_IDX
;
...
...
@@ -1076,7 +1110,7 @@ void TrQuant::xFwdLfnst( const TransformUnit &tu, const ComponentID compID, cons
{
intraMode
=
PLANAR_IDX
;
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
if
(
PU
::
isTmp
(
*
tu
.
cs
->
getPU
(
area
.
pos
(),
toChannelType
(
compID
)),
toChannelType
(
compID
)))
{
intraMode
=
PLANAR_IDX
;
...
...
@@ -1319,7 +1353,7 @@ void TrQuant::getTrTypes(const TransformUnit tu, const ComponentID compID, int &
return
;
}
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
if
(
isImplicitMTS
||
isISP
||
tu
.
cu
->
TmpFlag
)
#else
if
(
isImplicitMTS
||
isISP
)
...
...
source/Lib/CommonLib/TrQuant.h
View file @
1a7aa7bd
...
...
@@ -57,7 +57,7 @@ typedef void InvTrans(const TCoeff*, TCoeff*, int, int, int, int, const TCoeff,
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
#define MAX_1DTRANS_LEN (1 << (((USE_MORE_BLOCKSIZE_DEPTH_MAX) + 1) << 1)) ///< 4x4 = 16, 8x8 = 64, 16x16=256, 32x32 = 1024
...
...
@@ -71,13 +71,13 @@ public:
int
m_pY
;
//offset Y
int
m_pXInteger
;
//offset X for integer pixel search
int
m_pYInteger
;
//offset Y for integer pixel search
DistType
m_pDiffInteger
;
int
m_pDiffInteger
;
int
getXInteger
()
{
return
m_pXInteger
;
}
int
getYInteger
()
{
return
m_pYInteger
;
}
DistType
getDiffInteger
()
{
return
m_pDiffInteger
;
}
int
getDiffInteger
()
{
return
m_pDiffInteger
;
}
short
m_pIdInteger
;
//frame id
short
getIdInteger
()
{
return
m_pIdInteger
;
}
DistType
m_pDiff
;
//mse
int
m_pDiff
;
//mse
short
m_pId
;
//frame id
...
...
@@ -86,7 +86,7 @@ public:
//void init();
int
getX
()
{
return
m_pX
;
}
int
getY
()
{
return
m_pY
;
}
DistType
getDiff
()
{
return
m_pDiff
;
}
int
getDiff
()
{
return
m_pDiff
;
}
short
getId
()
{
return
m_pId
;
}
/*void initDiff(unsigned int uiPatchSize, int bitDepth);
void initDiff(unsigned int uiPatchSize, int bitDepth, int iCandiNumber);*/
...
...
@@ -132,8 +132,8 @@ public:
void
fwdLfnstNxN
(
int
*
src
,
int
*
dst
,
const
uint32_t
mode
,
const
uint32_t
index
,
const
uint32_t
size
,
int
zeroOutSize
);
void
invLfnstNxN
(
int
*
src
,
int
*
dst
,
const
uint32_t
mode
,
const
uint32_t
index
,
const
uint32_t
size
,
int
zeroOutSize
);
#endif
#if
IDCC_TPM_JEM
DistType
calcTemplateDiff
(
Pel
*
ref
,
unsigned
int
uiStride
,
Pel
**
tarPatch
,
unsigned
int
uiPatchWidth
,
unsigned
int
uiPatchHeight
,
DistType
iMax
);
#if
JVET_V0130_INTRA_TMP
int
calcTemplateDiff
(
Pel
*
ref
,
unsigned
int
uiStride
,
Pel
**
tarPatch
,
unsigned
int
uiPatchWidth
,
unsigned
int
uiPatchHeight
,
int
iMax
);
Pel
**
getTargetPatch
(
unsigned
int
uiDepth
)
{
return
m_pppTarPatch
[
uiDepth
];
}
Pel
*
getRefPicUsed
()
{
return
m_refPicUsed
;
}
void
setRefPicUsed
(
Pel
*
ref
)
{
m_refPicUsed
=
ref
;
}
...
...
@@ -199,7 +199,7 @@ public:
protected:
TCoeff
m_tempCoeff
[
MAX_TB_SIZEY
*
MAX_TB_SIZEY
];
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
int
m_uiPartLibSize
;
TempLibFast
m_tempLibFast
;
Pel
*
m_refPicUsed
;
...
...
source/Lib/CommonLib/TypeDef.h
View file @
1a7aa7bd
/* The copyright in this software is being made available under the BSD
/* 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.
...
...
@@ -86,25 +86,6 @@
#define INTRA_RM_SMALL_BLOCK_SIZE_CONSTRAINTS 1 // Enable 2xN and Nx2 block by removing SCIPU constraints
#define CCLM_LATENCY_RESTRICTION_RMV 1 // remove the latency between luma and chroma restriction of CCLM
#define LMS_LINEAR_MODEL 1 // LMS for parameters derivation of CCLM and MMLM mode, Remove constraint in derivation of neighbouring samples
#define IDCC_TPM_JEM 1 // template matching prediction as implemented in JEM-7.2
#if IDCC_TPM_JEM
#define IDCC_TMP_SIMD 1
#define IDCC_SearchRangeMultFactor 5
#if IDCC_TMP_SIMD
#define IDCC_TemplateSize 4 // must be multiple of 4 for SIMD
#else
#define IDCC_TemplateSize 4
#endif
#define IDCC_TMP_MaxSize_Depth 6 // should be log2(IDCC_TMP_MaxSize): keep as 6 to avoid any error
typedef
int
DistType
;
#endif
//-- inter
#define CIIP_RM_BLOCK_SIZE_CONSTRAINTS 1 // Remove the 64x64 restriction and enable 8x4/4x8 block for CIIP
...
...
@@ -129,6 +110,12 @@ typedef int DistType;
#define SECONDARY_MPM 1 // Primary MPM and Secondary MPM: Add neighbouring modes into MPMs from positions AR, BL, AL, derived modes
#define ENABLE_DIMD 1 // Decoder side intra mode derivation
#define JVET_V0087_DIMD_NO_ISP ENABLE_DIMD // disallow combination of DIMD and ISP
#define JVET_V0130_INTRA_TMP 1 // intra template matching prediction
#if JVET_V0130_INTRA_TMP
#define INTRA_TMP_SearchRangeMultFactor 5
#define INTRA_TMP_SIMD 1
#define INTRA_TMP_TemplateSize 4 // must be multiple of 4 for SIMD
#endif
// Inter
#define CIIP_PDPC 1 // apply pdpc to megre prediction as a new CIIP mode (CIIP_PDPC) additional to CIIP mode
...
...
source/Lib/CommonLib/Unit.cpp
View file @
1a7aa7bd
...
...
@@ -303,7 +303,7 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other )
smvdMode
=
other
.
smvdMode
;
ispMode
=
other
.
ispMode
;
mipFlag
=
other
.
mipFlag
;
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP
TmpFlag
=
other
.
TmpFlag
;
#endif
#if INTER_LIC
...
...
@@ -387,7 +387,7 @@ void CodingUnit::initData()
smvdMode
=
0
;
ispMode
=
0
;
mipFlag
=
false
;
#if
IDCC_TPM_JEM
#if
JVET_V0130_INTRA_TMP