Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
VVCSoftware_VTM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
jvet
VVCSoftware_VTM
Commits
0d9ccf21
Commit
0d9ccf21
authored
Jan 31, 2019
by
Jeeva Raj A
Committed by
Jeeva Raj A
Feb 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JVET M0147 - DMVR (Decoder-side Motion Vector Refinement)
- CE9.2.1g + RefinedMV only for MC and TMVP + SAD cost
parent
e9a4a4ff
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1386 additions
and
12 deletions
+1386
-12
cfg/encoder_randomaccess_vtm.cfg
cfg/encoder_randomaccess_vtm.cfg
+1
-0
source/App/EncoderApp/EncApp.cpp
source/App/EncoderApp/EncApp.cpp
+3
-0
source/App/EncoderApp/EncAppCfg.cpp
source/App/EncoderApp/EncAppCfg.cpp
+9
-0
source/App/EncoderApp/EncAppCfg.h
source/App/EncoderApp/EncAppCfg.h
+3
-0
source/Lib/CommonLib/Buffer.cpp
source/Lib/CommonLib/Buffer.cpp
+40
-0
source/Lib/CommonLib/Buffer.h
source/Lib/CommonLib/Buffer.h
+10
-0
source/Lib/CommonLib/CommonDef.h
source/Lib/CommonLib/CommonDef.h
+8
-0
source/Lib/CommonLib/InterPrediction.cpp
source/Lib/CommonLib/InterPrediction.cpp
+573
-1
source/Lib/CommonLib/InterPrediction.h
source/Lib/CommonLib/InterPrediction.h
+49
-0
source/Lib/CommonLib/InterpolationFilter.cpp
source/Lib/CommonLib/InterpolationFilter.cpp
+176
-0
source/Lib/CommonLib/InterpolationFilter.h
source/Lib/CommonLib/InterpolationFilter.h
+44
-4
source/Lib/CommonLib/RdCost.cpp
source/Lib/CommonLib/RdCost.cpp
+7
-3
source/Lib/CommonLib/Slice.cpp
source/Lib/CommonLib/Slice.cpp
+3
-0
source/Lib/CommonLib/Slice.h
source/Lib/CommonLib/Slice.h
+7
-0
source/Lib/CommonLib/TypeDef.h
source/Lib/CommonLib/TypeDef.h
+2
-0
source/Lib/CommonLib/Unit.cpp
source/Lib/CommonLib/Unit.cpp
+21
-0
source/Lib/CommonLib/Unit.h
source/Lib/CommonLib/Unit.h
+4
-0
source/Lib/CommonLib/UnitTools.cpp
source/Lib/CommonLib/UnitTools.cpp
+73
-2
source/Lib/CommonLib/UnitTools.h
source/Lib/CommonLib/UnitTools.h
+9
-0
source/Lib/CommonLib/x86/BufferX86.h
source/Lib/CommonLib/x86/BufferX86.h
+123
-0
source/Lib/CommonLib/x86/InterpolationFilterX86.h
source/Lib/CommonLib/x86/InterpolationFilterX86.h
+142
-0
source/Lib/DecoderLib/DecLib.cpp
source/Lib/DecoderLib/DecLib.cpp
+3
-1
source/Lib/DecoderLib/VLCReader.cpp
source/Lib/DecoderLib/VLCReader.cpp
+3
-0
source/Lib/EncoderLib/EncCfg.h
source/Lib/EncoderLib/EncCfg.h
+7
-0
source/Lib/EncoderLib/EncCu.cpp
source/Lib/EncoderLib/EncCu.cpp
+57
-1
source/Lib/EncoderLib/EncGOP.cpp
source/Lib/EncoderLib/EncGOP.cpp
+3
-0
source/Lib/EncoderLib/EncLib.cpp
source/Lib/EncoderLib/EncLib.cpp
+3
-0
source/Lib/EncoderLib/VLCWriter.cpp
source/Lib/EncoderLib/VLCWriter.cpp
+3
-0
No files found.
cfg/encoder_randomaccess_vtm.cfg
View file @
0d9ccf21
...
...
@@ -150,6 +150,7 @@ IBC : 0 # turned off in CTC
AllowDisFracMMVD : 1
AffineAmvr : 1
LumaReshapeEnable : 1 # luma reshaping. 0: disable 1:enable
DMVR : 1
# Fast tools
PBIntraFast : 1
...
...
source/App/EncoderApp/EncApp.cpp
View file @
0d9ccf21
...
...
@@ -268,6 +268,9 @@ void EncApp::xInitLibCfg()
#endif
#if JVET_M0247_AFFINE_AMVR_ENCOPT
m_cEncLib
.
setUseAffineAmvrEncOpt
(
m_AffineAmvrEncOpt
);
#endif
#if JVET_M0147_DMVR
m_cEncLib
.
setDMVR
(
m_DMVR
);
#endif
m_cEncLib
.
setIBCMode
(
m_IBCMode
);
m_cEncLib
.
setIBCLocalSearchRangeX
(
m_IBCLocalSearchRangeX
);
...
...
source/App/EncoderApp/EncAppCfg.cpp
View file @
0d9ccf21
...
...
@@ -875,6 +875,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
#endif
#if JVET_M0247_AFFINE_AMVR_ENCOPT
(
"AffineAmvrEncOpt"
,
m_AffineAmvrEncOpt
,
false
,
"Enable encoder optimization of affine AMVR"
)
#endif
#if JVET_M0147_DMVR
(
"DMVR"
,
m_DMVR
,
#endif
(
"IBC"
,
m_IBCMode
,
0u
,
"IBCMode (0x1:enabled, 0x0:disabled) [default: disabled]"
)
(
"IBCLocalSearchRangeX"
,
m_IBCLocalSearchRangeX
,
128u
,
"Search range of IBC local search in x direction"
)
...
...
@@ -1971,6 +1974,9 @@ bool EncAppCfg::xCheckParameter()
xConfirmPara
(
m_GBi
,
"GBi is only allowed with NEXT profile"
);
xConfirmPara
(
m_GBiFast
,
"GBiFast is only allowed with NEXT profile"
);
xConfirmPara
(
m_Triangle
,
"Triangle is only allowed with NEXT profile"
);
#if JVET_M0147_DMVR
xConfirmPara
(
m_DMVR
,
"DMVR only allowed with NEXT profile"
);
#endif
// ADD_NEW_TOOL : (parameter check) add a check for next tools here
}
else
...
...
@@ -3202,6 +3208,9 @@ void EncAppCfg::xPrintParameter()
#if JVET_M0247_AFFINE_AMVR_ENCOPT
m_AffineAmvrEncOpt
=
m_AffineAmvr
?
m_AffineAmvrEncOpt
:
false
;
msg
(
VERBOSE
,
"AffineAmvrEncOpt:%d "
,
m_AffineAmvrEncOpt
);
#endif
#if JVET_M0147_DMVR
msg
(
VERBOSE
,
"DMVR:%d "
,
m_DMVR
);
#endif
}
msg
(
VERBOSE
,
"IBC:%d "
,
m_IBCMode
);
...
...
source/App/EncoderApp/EncAppCfg.h
View file @
0d9ccf21
...
...
@@ -249,6 +249,9 @@ protected:
#if JVET_M0247_AFFINE_AMVR_ENCOPT
bool
m_AffineAmvrEncOpt
;
#endif
#if JVET_M0147_DMVR
bool
m_DMVR
;
#endif
unsigned
m_IBCMode
;
unsigned
m_IBCLocalSearchRangeX
;
...
...
source/Lib/CommonLib/Buffer.cpp
View file @
0d9ccf21
...
...
@@ -299,6 +299,10 @@ PelBufferOps::PelBufferOps()
calcBIOPar
=
calcBIOParCore
;
calcBlkGradient
=
calcBlkGradientCore
;
#if JVET_M0147_DMVR
copyBuffer
=
copyBufferCore
;
padding
=
paddingCore
;
#endif
#if ENABLE_SIMD_OPT_GBI
removeWeightHighFreq8
=
removeWeightHighFreq
;
removeWeightHighFreq4
=
removeWeightHighFreq
;
...
...
@@ -313,6 +317,42 @@ PelBufferOps g_pelBufOP = PelBufferOps();
#endif
#endif
#if JVET_M0147_DMVR
void
copyBufferCore
(
Pel
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
)
{
int
numBytes
=
width
*
sizeof
(
Pel
);
for
(
int
i
=
0
;
i
<
height
;
i
++
)
{
memcpy
(
dst
+
i
*
dstStride
,
src
+
i
*
srcStride
,
numBytes
);
}
}
void
paddingCore
(
Pel
*
ptr
,
int
iStride
,
int
iWidth
,
int
iHeight
,
int
padSize
)
{
/*left and right padding*/
Pel
*
ptrTemp1
=
ptr
;
Pel
*
ptrTemp2
=
ptr
+
(
iWidth
-
1
);
int
offset
=
0
;
for
(
int
i
=
0
;
i
<
iHeight
;
i
++
)
{
offset
=
iStride
*
i
;
for
(
int
j
=
1
;
j
<=
padSize
;
j
++
)
{
*
(
ptrTemp1
-
j
+
offset
)
=
*
(
ptrTemp1
+
offset
);
*
(
ptrTemp2
+
j
+
offset
)
=
*
(
ptrTemp2
+
offset
);
}
}
/*Top and Bottom padding*/
int
numBytes
=
(
iWidth
+
padSize
+
padSize
)
*
sizeof
(
Pel
);
ptrTemp1
=
(
ptr
-
padSize
);
ptrTemp2
=
(
ptr
+
(
iStride
*
(
iHeight
-
1
))
-
padSize
);
for
(
int
i
=
1
;
i
<=
padSize
;
i
++
)
{
memcpy
(
ptrTemp1
-
(
i
*
iStride
),
(
ptrTemp1
),
numBytes
);
memcpy
(
ptrTemp2
+
(
i
*
iStride
),
(
ptrTemp2
),
numBytes
);
}
}
#endif
template
<
>
void
AreaBuf
<
Pel
>::
addWeightedAvg
(
const
AreaBuf
<
const
Pel
>
&
other1
,
const
AreaBuf
<
const
Pel
>
&
other2
,
const
ClpRng
&
clpRng
,
const
int8_t
gbiIdx
)
{
...
...
source/Lib/CommonLib/Buffer.h
View file @
0d9ccf21
...
...
@@ -77,6 +77,10 @@ struct PelBufferOps
void
(
*
calcBIOPar
)
(
const
Pel
*
srcY0Temp
,
const
Pel
*
srcY1Temp
,
const
Pel
*
gradX0
,
const
Pel
*
gradX1
,
const
Pel
*
gradY0
,
const
Pel
*
gradY1
,
int
*
dotProductTemp1
,
int
*
dotProductTemp2
,
int
*
dotProductTemp3
,
int
*
dotProductTemp5
,
int
*
dotProductTemp6
,
const
int
src0Stride
,
const
int
src1Stride
,
const
int
gradStride
,
const
int
widthG
,
const
int
heightG
);
#endif
void
(
*
calcBlkGradient
)(
int
sx
,
int
sy
,
int
*
arraysGx2
,
int
*
arraysGxGy
,
int
*
arraysGxdI
,
int
*
arraysGy2
,
int
*
arraysGydI
,
int
&
sGx2
,
int
&
sGy2
,
int
&
sGxGy
,
int
&
sGxdI
,
int
&
sGydI
,
int
width
,
int
height
,
int
unitSize
);
#if JVET_M0147_DMVR
void
(
*
copyBuffer
)(
Pel
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
);
void
(
*
padding
)(
Pel
*
dst
,
int
stride
,
int
width
,
int
height
,
int
padSize
);
#endif
#if ENABLE_SIMD_OPT_GBI
void
(
*
removeWeightHighFreq8
)
(
Pel
*
src0
,
int
src0Stride
,
const
Pel
*
src1
,
int
src1Stride
,
int
width
,
int
height
,
int
shift
,
int
gbiWeight
);
void
(
*
removeWeightHighFreq4
)
(
Pel
*
src0
,
int
src0Stride
,
const
Pel
*
src1
,
int
src1Stride
,
int
width
,
int
height
,
int
shift
,
int
gbiWeight
);
...
...
@@ -90,6 +94,12 @@ extern PelBufferOps g_pelBufOP;
#endif
#endif
#if JVET_M0147_DMVR
void
paddingCore
(
Pel
*
ptr
,
int
iStride
,
int
iWidth
,
int
iHeight
,
int
padSize
);
void
copyBufferCore
(
Pel
*
src
,
int
srcStride
,
Pel
*
Dst
,
int
dstStride
,
int
width
,
int
height
);
#endif
template
<
typename
T
>
struct
AreaBuf
:
public
Size
{
...
...
source/Lib/CommonLib/CommonDef.h
View file @
0d9ccf21
...
...
@@ -332,6 +332,14 @@ static const uint32_t LUMA_LEVEL_TO_DQP_LUT_MAXSIZE = 1024; ///<
#if !JVET_M0464_UNI_MTS
static
const
int
NUM_EMT_CU_FLAG_CTX
=
6
;
///< number of context models for EMT CU-level flag
#endif
#if JVET_M0147_DMVR
static
const
int
DMVR_SUBCU_WIDTH
=
16
;
static
const
int
DMVR_SUBCU_HEIGHT
=
16
;
static
const
int
DMVR_SUBCU_WIDTH_LOG2
=
4
;
static
const
int
DMVR_SUBCU_HEIGHT_LOG2
=
4
;
static
const
int
MAX_NUM_SUBCU_DMVR
=
((
MAX_CU_SIZE
*
MAX_CU_SIZE
)
>>
(
DMVR_SUBCU_WIDTH_LOG2
+
DMVR_SUBCU_HEIGHT_LOG2
));
static
const
int
DMVR_NUM_ITERATION
=
2
;
#endif
//QTBT high level parameters
//for I slice luma CTB configuration para.
...
...
source/Lib/CommonLib/InterPrediction.cpp
View file @
0d9ccf21
This diff is collapsed.
Click to expand it.
source/Lib/CommonLib/InterPrediction.h
View file @
0d9ccf21
...
...
@@ -94,6 +94,33 @@ protected:
int
m_iRefListIdx
;
PelStorage
m_triangleBuf
;
Mv
*
m_storedMv
;
#if JVET_M0147_DMVR
/*buffers for bilinear Filter data for DMVR refinement*/
Pel
*
m_cYuvPredTempDMVRL0
;
Pel
*
m_cYuvPredTempDMVRL1
;
int
m_biLinearBufStride
;
/*buffers for padded data*/
PelUnitBuf
m_cYuvRefBuffDMVRL0
;
PelUnitBuf
m_cYuvRefBuffDMVRL1
;
Pel
*
m_cRefSamplesDMVRL0
[
MAX_NUM_COMPONENT
];
Pel
*
m_cRefSamplesDMVRL1
[
MAX_NUM_COMPONENT
];
enum
SAD_POINT_INDEX
{
NOT_AVAILABLE
=
-
1
,
SAD_BOTTOM
=
0
,
SAD_TOP
,
SAD_RIGHT
,
SAD_LEFT
,
SAD_TOP_LEFT
,
SAD_TOP_RIGHT
,
SAD_BOTTOM_LEFT
,
SAD_BOTTOM_RIGHT
,
SAD_CENTER
,
SAD_COUNT
};
Mv
m_pSearchOffset
[
5
]
=
{
Mv
(
0
,
1
),
Mv
(
0
,
-
1
),
Mv
(
1
,
0
),
Mv
(
-
1
,
0
),
Mv
(
0
,
0
)
};
uint64_t
m_SADsArray
[((
DMVR_NUM_ITERATION
<<
1
)
+
1
)
*
((
DMVR_NUM_ITERATION
<<
1
)
+
1
)];
#endif
Pel
*
m_gradX0
;
Pel
*
m_gradY0
;
...
...
@@ -112,10 +139,22 @@ protected:
,
const
bool
luma
,
const
bool
chroma
);
void
xPredInterBi
(
PredictionUnit
&
pu
,
PelUnitBuf
&
pcYuvPred
);
#if JVET_M0147_DMVR
void
xPredInterBlk
(
const
ComponentID
&
compID
,
const
PredictionUnit
&
pu
,
const
Picture
*
refPic
,
const
Mv
&
_mv
,
PelUnitBuf
&
dstPic
,
const
bool
&
bi
,
const
ClpRng
&
clpRng
,
const
bool
&
bioApplied
,
bool
isIBC
,
SizeType
dmvrWidth
=
0
,
SizeType
dmvrHeight
=
0
,
bool
bilinearMC
=
false
,
Pel
*
srcPadBuf
=
NULL
,
int32_t
srcPadStride
=
0
);
#else
void
xPredInterBlk
(
const
ComponentID
&
compID
,
const
PredictionUnit
&
pu
,
const
Picture
*
refPic
,
const
Mv
&
_mv
,
PelUnitBuf
&
dstPic
,
const
bool
&
bi
,
const
ClpRng
&
clpRng
,
const
bool
&
bioApplied
,
bool
isIBC
);
#endif
void
xAddBIOAvg4
(
const
Pel
*
src0
,
int
src0Stride
,
const
Pel
*
src1
,
int
src1Stride
,
Pel
*
dst
,
int
dstStride
,
const
Pel
*
gradX0
,
const
Pel
*
gradX1
,
const
Pel
*
gradY0
,
const
Pel
*
gradY1
,
int
gradStride
,
int
width
,
int
height
,
int
tmpx
,
int
tmpy
,
int
shift
,
int
offset
,
const
ClpRng
&
clpRng
);
#if JVET_M0063_BDOF_FIX
...
...
@@ -169,6 +208,16 @@ public:
#else
void
weightedTriangleBlk
(
PredictionUnit
&
pu
,
bool
weights
,
const
bool
splitDir
,
int32_t
channel
,
PelUnitBuf
&
predDst
,
PelUnitBuf
&
predSrc0
,
PelUnitBuf
&
predSrc1
);
#endif
#if JVET_M0147_DMVR
void
xPrefetchPad
(
PredictionUnit
&
pu
,
PelUnitBuf
&
pcPad
,
RefPicList
refId
);
void
xFinalPaddedMCForDMVR
(
PredictionUnit
&
pu
,
PelUnitBuf
&
pcYuvSrc0
,
PelUnitBuf
&
pcYuvSrc1
,
PelUnitBuf
&
pcPad0
,
PelUnitBuf
&
pcPad1
,
const
bool
bBIOApplied
,
const
Mv
startMV
[
NUM_REF_PIC_LIST_01
]
);
void
xBIPMVRefine
(
int
bd
,
Pel
*
pRefL0
,
Pel
*
pRefL1
,
uint64_t
&
minCost
,
int16_t
*
delta_mv
,
uint64_t
*
pSADsArray
,
int
width
,
int
height
);
uint64_t
xDMVRCost
(
int
iBitDepth
,
Pel
*
pRef
,
uint32_t
uiRefStride
,
const
Pel
*
pOrg
,
uint32_t
uiOrgStride
,
int
iWidth
,
int
iHeight
);
void
xinitMC
(
PredictionUnit
&
pu
,
const
ClpRngs
&
clpRngs
);
void
xProcessDMVR
(
PredictionUnit
&
pu
,
PelUnitBuf
&
pcYuvDst
,
const
ClpRngs
&
clpRngs
,
const
bool
bBIOApplied
);
#endif
#if JVET_J0090_MEMORY_BANDWITH_MEASURE
void
cacheAssign
(
CacheModel
*
cache
);
...
...
source/Lib/CommonLib/InterpolationFilter.cpp
View file @
0d9ccf21
...
...
@@ -131,6 +131,27 @@ const TFilterCoeff InterpolationFilter::m_bilinearFilter[LUMA_INTERPOLATION_FILT
{
4
,
60
,
},
};
#if JVET_M0147_DMVR
const
TFilterCoeff
InterpolationFilter
::
m_bilinearFilterPrec4
[
LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
][
NTAPS_BILINEAR
]
=
{
{
16
,
0
,
},
{
15
,
1
,
},
{
14
,
2
,
},
{
13
,
3
,
},
{
12
,
4
,
},
{
11
,
5
,
},
{
10
,
6
,
},
{
9
,
7
,
},
{
8
,
8
,
},
{
7
,
9
,
},
{
6
,
10
,
},
{
5
,
11
,
},
{
4
,
12
,
},
{
3
,
13
,
},
{
2
,
14
,
},
{
1
,
15
,
}
};
#endif
// ====================================================================================================================
// Private member functions
// ====================================================================================================================
...
...
@@ -197,7 +218,11 @@ InterpolationFilter::InterpolationFilter()
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template
<
bool
isFirst
,
bool
isLast
>
#if JVET_M0147_DMVR
void
InterpolationFilter
::
filterCopy
(
const
ClpRng
&
clpRng
,
const
Pel
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
biMC10BitOut
)
#else
void
InterpolationFilter
::
filterCopy
(
const
ClpRng
&
clpRng
,
const
Pel
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
)
#endif
{
int
row
,
col
;
...
...
@@ -223,6 +248,40 @@ void InterpolationFilter::filterCopy( const ClpRng& clpRng, const Pel *src, int
{
const
int
shift
=
std
::
max
<
int
>
(
2
,
(
IF_INTERNAL_PREC
-
clpRng
.
bd
));
#if JVET_M0147_DMVR
if
(
biMC10BitOut
)
{
int
shift10BitOut
,
offset
;
if
((
clpRng
.
bd
-
IF_INTERNAL_PREC_BILINEAR
)
>
0
)
{
shift10BitOut
=
(
clpRng
.
bd
-
IF_INTERNAL_PREC_BILINEAR
);
offset
=
(
1
<<
(
shift10BitOut
-
1
));
for
(
row
=
0
;
row
<
height
;
row
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
{
dst
[
col
]
=
(
src
[
col
]
+
offset
)
>>
shift10BitOut
;
}
src
+=
srcStride
;
dst
+=
dstStride
;
}
}
else
{
shift10BitOut
=
(
IF_INTERNAL_PREC_BILINEAR
-
clpRng
.
bd
);
for
(
row
=
0
;
row
<
height
;
row
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
{
dst
[
col
]
=
src
[
col
]
<<
shift10BitOut
;
}
src
+=
srcStride
;
dst
+=
dstStride
;
}
}
}
else
#endif
for
(
row
=
0
;
row
<
height
;
row
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
...
...
@@ -240,6 +299,40 @@ void InterpolationFilter::filterCopy( const ClpRng& clpRng, const Pel *src, int
{
const
int
shift
=
std
::
max
<
int
>
(
2
,
(
IF_INTERNAL_PREC
-
clpRng
.
bd
));
#if JVET_M0147_DMVR
if
(
biMC10BitOut
)
{
int
shift10BitOut
,
offset
;
if
((
clpRng
.
bd
-
IF_INTERNAL_PREC_BILINEAR
)
>
0
)
{
shift10BitOut
=
(
clpRng
.
bd
-
IF_INTERNAL_PREC_BILINEAR
);
offset
=
(
1
<<
(
shift10BitOut
-
1
));
for
(
row
=
0
;
row
<
height
;
row
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
{
dst
[
col
]
=
(
src
[
col
]
+
offset
)
>>
shift10BitOut
;
}
src
+=
srcStride
;
dst
+=
dstStride
;
}
}
else
{
shift10BitOut
=
(
IF_INTERNAL_PREC_BILINEAR
-
clpRng
.
bd
);
for
(
row
=
0
;
row
<
height
;
row
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
{
dst
[
col
]
=
src
[
col
]
<<
shift10BitOut
;
}
src
+=
srcStride
;
dst
+=
dstStride
;
}
}
}
else
#endif
for
(
row
=
0
;
row
<
height
;
row
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
...
...
@@ -282,7 +375,11 @@ void InterpolationFilter::filterCopy( const ClpRng& clpRng, const Pel *src, int
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template
<
int
N
,
bool
isVertical
,
bool
isFirst
,
bool
isLast
>
#if JVET_M0147_DMVR
void
InterpolationFilter
::
filter
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
TFilterCoeff
const
*
coeff
,
bool
biMC10BitOut
)
#else
void
InterpolationFilter
::
filter
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
TFilterCoeff
const
*
coeff
)
#endif
{
int
row
,
col
;
...
...
@@ -327,6 +424,13 @@ void InterpolationFilter::filter(const ClpRng& clpRng, Pel const *src, int srcSt
offset
=
(
isFirst
)
?
-
IF_INTERNAL_OFFS
<<
shift
:
0
;
}
#if JVET_M0147_DMVR
if
(
biMC10BitOut
)
{
shift
=
IF_FILTER_PREC_BILINEAR
-
(
IF_INTERNAL_PREC_BILINEAR
-
clpRng
.
bd
);
offset
=
1
<<
(
shift
-
1
);
}
#endif
for
(
row
=
0
;
row
<
height
;
row
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
...
...
@@ -387,20 +491,36 @@ void InterpolationFilter::filter(const ClpRng& clpRng, Pel const *src, int srcSt
* \param coeff Pointer to filter taps
*/
template
<
int
N
>
#if JVET_M0147_DMVR
void
InterpolationFilter
::
filterHor
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isLast
,
TFilterCoeff
const
*
coeff
,
bool
biMC10BitOut
)
#else
void
InterpolationFilter
::
filterHor
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isLast
,
TFilterCoeff
const
*
coeff
)
#endif
{
//#if ENABLE_SIMD_OPT_MCIF
if
(
N
==
8
)
{
#if JVET_M0147_DMVR
m_filterHor
[
0
][
1
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
,
biMC10BitOut
);
#else
m_filterHor
[
0
][
1
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
);
#endif
}
else
if
(
N
==
4
)
{
#if JVET_M0147_DMVR
m_filterHor
[
1
][
1
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
,
biMC10BitOut
);
#else
m_filterHor
[
1
][
1
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
);
#endif
}
else
if
(
N
==
2
)
{
#if JVET_M0147_DMVR
m_filterHor
[
2
][
1
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
,
biMC10BitOut
);
#else
m_filterHor
[
2
][
1
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
);
#endif
}
else
{
...
...
@@ -424,20 +544,36 @@ void InterpolationFilter::filterHor(const ClpRng& clpRng, Pel const *src, int sr
* \param coeff Pointer to filter taps
*/
template
<
int
N
>
#if JVET_M0147_DMVR
void
InterpolationFilter
::
filterVer
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isFirst
,
bool
isLast
,
TFilterCoeff
const
*
coeff
,
bool
biMC10BitOut
)
#else
void
InterpolationFilter
::
filterVer
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isFirst
,
bool
isLast
,
TFilterCoeff
const
*
coeff
)
#endif
{
//#if ENABLE_SIMD_OPT_MCIF
if
(
N
==
8
)
{
#if JVET_M0147_DMVR
m_filterVer
[
0
][
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
,
biMC10BitOut
);
#else
m_filterVer
[
0
][
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
);
#endif
}
else
if
(
N
==
4
)
{
#if JVET_M0147_DMVR
m_filterVer
[
1
][
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
,
biMC10BitOut
);
#else
m_filterVer
[
1
][
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
);
#endif
}
else
if
(
N
==
2
)
{
#if JVET_M0147_DMVR
m_filterVer
[
2
][
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
,
biMC10BitOut
);
#else
m_filterVer
[
2
][
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
coeff
);
#endif
}
else
{
THROW
(
"Invalid tap number"
);
...
...
@@ -463,29 +599,49 @@ void InterpolationFilter::filterVer(const ClpRng& clpRng, Pel const *src, int sr
* \param fmt Chroma format
* \param bitDepth Bit depth
*/
#if JVET_M0147_DMVR
void
InterpolationFilter
::
filterHor
(
const
ComponentID
compID
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
int
frac
,
bool
isLast
,
const
ChromaFormat
fmt
,
const
ClpRng
&
clpRng
,
int
nFilterIdx
,
bool
biMC10BitOut
)
#else
void
InterpolationFilter
::
filterHor
(
const
ComponentID
compID
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
int
frac
,
bool
isLast
,
const
ChromaFormat
fmt
,
const
ClpRng
&
clpRng
,
int
nFilterIdx
)
#endif
{
if
(
frac
==
0
)
{
#if JVET_M0147_DMVR
m_filterCopy
[
true
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
biMC10BitOut
);
#else
m_filterCopy
[
true
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
);
#endif
}
else
if
(
isLuma
(
compID
)
)
{
CHECK
(
frac
<
0
||
frac
>=
LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
,
"Invalid fraction"
);
if
(
nFilterIdx
==
1
)
{
#if JVET_M0147_DMVR
filterHor
<
NTAPS_BILINEAR
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isLast
,
m_bilinearFilterPrec4
[
frac
],
biMC10BitOut
);
#else
filterHor
<
NTAPS_BILINEAR
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isLast
,
m_bilinearFilter
[
frac
]);
#endif
}
else
{
#if JVET_M0147_DMVR
filterHor
<
NTAPS_LUMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isLast
,
m_lumaFilter
[
frac
],
biMC10BitOut
);
#else
filterHor
<
NTAPS_LUMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isLast
,
m_lumaFilter
[
frac
]
);
#endif
}
}
else
{
const
uint32_t
csx
=
getComponentScaleX
(
compID
,
fmt
);
CHECK
(
frac
<
0
||
csx
>=
2
||
(
frac
<<
(
1
-
csx
)
)
>=
CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
,
"Invalid fraction"
);
#if JVET_M0147_DMVR
filterHor
<
NTAPS_CHROMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isLast
,
m_chromaFilter
[
frac
<<
(
1
-
csx
)],
biMC10BitOut
);
#else
filterHor
<
NTAPS_CHROMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isLast
,
m_chromaFilter
[
frac
<<
(
1
-
csx
)]
);
#endif
}
}
...
...
@@ -506,29 +662,49 @@ void InterpolationFilter::filterHor( const ComponentID compID, Pel const *src, i
* \param fmt Chroma format
* \param bitDepth Bit depth
*/
#if JVET_M0147_DMVR
void
InterpolationFilter
::
filterVer
(
const
ComponentID
compID
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
int
frac
,
bool
isFirst
,
bool
isLast
,
const
ChromaFormat
fmt
,
const
ClpRng
&
clpRng
,
int
nFilterIdx
,
bool
biMC10BitOut
)
#else
void
InterpolationFilter
::
filterVer
(
const
ComponentID
compID
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
int
frac
,
bool
isFirst
,
bool
isLast
,
const
ChromaFormat
fmt
,
const
ClpRng
&
clpRng
,
int
nFilterIdx
)
#endif
{
if
(
frac
==
0
)
{
#if JVET_M0147_DMVR
m_filterCopy
[
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
biMC10BitOut
);
#else
m_filterCopy
[
isFirst
][
isLast
](
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
);
#endif
}
else
if
(
isLuma
(
compID
)
)
{
CHECK
(
frac
<
0
||
frac
>=
LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
,
"Invalid fraction"
);
if
(
nFilterIdx
==
1
)
{
#if JVET_M0147_DMVR
filterVer
<
NTAPS_BILINEAR
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isFirst
,
isLast
,
m_bilinearFilterPrec4
[
frac
],
biMC10BitOut
);
#else
filterVer
<
NTAPS_BILINEAR
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isFirst
,
isLast
,
m_bilinearFilter
[
frac
]);
#endif
}
else
{
#if JVET_M0147_DMVR
filterVer
<
NTAPS_LUMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isFirst
,
isLast
,
m_lumaFilter
[
frac
],
biMC10BitOut
);
#else
filterVer
<
NTAPS_LUMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isFirst
,
isLast
,
m_lumaFilter
[
frac
]
);
#endif
}
}
else
{
const
uint32_t
csy
=
getComponentScaleY
(
compID
,
fmt
);
CHECK
(
frac
<
0
||
csy
>=
2
||
(
frac
<<
(
1
-
csy
)
)
>=
CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
,
"Invalid fraction"
);
#if JVET_M0147_DMVR
filterVer
<
NTAPS_CHROMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isFirst
,
isLast
,
m_chromaFilter
[
frac
<<
(
1
-
csy
)],
biMC10BitOut
);
#else
filterVer
<
NTAPS_CHROMA
>
(
clpRng
,
src
,
srcStride
,
dst
,
dstStride
,
width
,
height
,
isFirst
,
isLast
,
m_chromaFilter
[
frac
<<
(
1
-
csy
)]
);
#endif
}
}
...
...
source/Lib/CommonLib/InterpolationFilter.h
View file @
0d9ccf21
...
...
@@ -48,7 +48,10 @@
#define IF_INTERNAL_PREC 14 ///< Number of bits for internal precision
#define IF_FILTER_PREC 6 ///< Log2 of sum of filter taps
#define IF_INTERNAL_OFFS (1<<(IF_INTERNAL_PREC-1)) ///< Offset used internally
#if JVET_M0147_DMVR
#define IF_INTERNAL_PREC_BILINEAR 10 ///< Number of bits for internal precision
#define IF_FILTER_PREC_BILINEAR 4 ///< Bilinear filter coeff precision so that intermediate value will not exceed 16 bit for SIMD - bit exact
#endif
/**
* \brief Interpolation filter class
*/
...
...
@@ -57,17 +60,36 @@ class InterpolationFilter
static
const
TFilterCoeff
m_lumaFilter
[
LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
][
NTAPS_LUMA
];
///< Luma filter taps
static
const
TFilterCoeff
m_chromaFilter
[
CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
][
NTAPS_CHROMA
];
///< Chroma filter taps
static
const
TFilterCoeff
m_bilinearFilter
[
LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
][
NTAPS_BILINEAR
];
///< bilinear filter taps
#if JVET_M0147_DMVR
static
const
TFilterCoeff
m_bilinearFilterPrec4
[
LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS
][
NTAPS_BILINEAR
];
///< bilinear filter taps
#endif
public:
template
<
bool
isFirst
,
bool
isLast
>
#if JVET_M0147_DMVR
static
void
filterCopy
(
const
ClpRng
&
clpRng
,
const
Pel
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
biMC10BitOut
);
#else
static
void
filterCopy
(
const
ClpRng
&
clpRng
,
const
Pel
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
);
#endif
template
<
int
N
,
bool
isVertical
,
bool
isFirst
,
bool
isLast
>
#if JVET_M0147_DMVR
static
void
filter
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
TFilterCoeff
const
*
coeff
,
bool
biMC10BitOut
);
#else
static
void
filter
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
TFilterCoeff
const
*
coeff
);
#endif
template
<
int
N
>
#if JVET_M0147_DMVR
void
filterHor
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isLast
,
TFilterCoeff
const
*
coeff
,
bool
biMC10BitOut
);
#else
void
filterHor
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isLast
,
TFilterCoeff
const
*
coeff
);
#endif
template
<
int
N
>
#if JVET_M0147_DMVR
void
filterVer
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isFirst
,
bool
isLast
,
TFilterCoeff
const
*
coeff
,
bool
biMC10BitOut
);
#else
void
filterVer
(
const
ClpRng
&
clpRng
,
Pel
const
*
src
,
int
srcStride
,
Pel
*
dst
,
int
dstStride
,
int
width
,
int
height
,
bool
isFirst
,
bool
isLast
,
TFilterCoeff
const
*
coeff
);
#endif
protected:
#if JVET_J0090_MEMORY_BANDWITH_MEASURE
...
...
@@ -76,10 +98,21 @@ protected:
public: