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
Remy Foray
VVCSoftware_VTM
Commits
cf0eff9f
Commit
cf0eff9f
authored
Jan 29, 2019
by
Yu Han
Browse files
Add IBC from VTM3.0 to master
parent
818a0736
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
source/Lib/CommonLib/CodingStructure.cpp
View file @
cf0eff9f
...
...
@@ -746,7 +746,11 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C
if
(
cpyResi
)
picture
->
getResiBuf
(
clippedArea
).
copyFrom
(
subResiBuf
);
if
(
cpyReco
)
picture
->
getRecoBuf
(
clippedArea
).
copyFrom
(
subRecoBuf
);
#if IBC_SEPERATE_MODE
if
(
!
subStruct
.
m_isTuEnc
&&
((
!
slice
->
isIntra
()
||
slice
->
getSPS
()
->
getSpsNext
().
getIBCMode
())
&&
subStruct
.
chType
!=
CHANNEL_TYPE_CHROMA
))
#else
if
(
!
subStruct
.
m_isTuEnc
&&
(
!
slice
->
isIntra
()
&&
subStruct
.
chType
!=
CHANNEL_TYPE_CHROMA
))
#endif
{
// copy motion buffer
MotionBuf
ownMB
=
getMotionBuf
(
clippedArea
);
...
...
@@ -926,7 +930,11 @@ void CodingStructure::copyStructure( const CodingStructure& other, const Channel
pu
=
*
ppu
;
}
#if IBC_SEPERATE_MODE
if
(
!
other
.
slice
->
isIntra
()
||
other
.
slice
->
getSPS
()
->
getSpsNext
().
getIBCMode
())
#else
if
(
!
other
.
slice
->
isIntra
()
)
#endif
{
// copy motion buffer
MotionBuf
ownMB
=
getMotionBuf
();
...
...
@@ -981,7 +989,11 @@ void CodingStructure::initStructData( const int &QP, const bool &_isLosses, cons
isLossless
=
_isLosses
;
}
#if IBC_SEPERATE_MODE
if
(
!
skipMotBuf
&&
(
!
parent
||
((
!
slice
->
isIntra
()
||
slice
->
getSPS
()
->
getSpsNext
().
getIBCMode
())
&&
!
m_isTuEnc
)))
#else
if
(
!
skipMotBuf
&&
(
!
parent
||
(
(
slice
->
getSliceType
()
!=
I_SLICE
)
&&
!
m_isTuEnc
)
)
)
#endif
{
getMotionBuf
()
.
memset
(
0
);
}
...
...
source/Lib/CommonLib/ContextModelling.cpp
View file @
cf0eff9f
...
...
@@ -451,6 +451,20 @@ unsigned DeriveCtx::CtxPredModeFlag( const CodingUnit& cu )
}
#endif
#if IBC_SEPERATE_MODE
unsigned
DeriveCtx
::
CtxIBCFlag
(
const
CodingUnit
&
cu
)
{
const
CodingStructure
*
cs
=
cu
.
cs
;
unsigned
ctxId
=
0
;
const
CodingUnit
*
cuLeft
=
cs
->
getCURestricted
(
cu
.
lumaPos
().
offset
(
-
1
,
0
),
cu
,
CH_L
);
ctxId
=
(
cuLeft
&&
CU
::
isIBC
(
*
cuLeft
))
?
1
:
0
;
const
CodingUnit
*
cuAbove
=
cs
->
getCURestricted
(
cu
.
lumaPos
().
offset
(
0
,
-
1
),
cu
,
CH_L
);
ctxId
=
(
cuAbove
&&
CU
::
isIBC
(
*
cuAbove
))
?
1
:
0
;
return
ctxId
;
}
#endif
void
MergeCtx
::
setMergeInfo
(
PredictionUnit
&
pu
,
int
candIdx
)
{
CHECK
(
candIdx
>=
numValidMergeCand
,
"Merge candidate does not exist"
);
...
...
@@ -470,12 +484,20 @@ 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 IBC_SEPERATE_MODE // remove macro VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE
if
(
CU
::
isIBC
(
*
pu
.
cu
))
{
pu
.
bv
=
pu
.
mv
[
REF_PIC_LIST_0
];
pu
.
bv
>>=
(
2
+
MV_FRACTIONAL_BITS_DIFF
);
// used for only integer resolution
}
#else
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
.
changePrecision
(
MV_PRECISION_INTERNAL
,
MV_PRECISION_INT
);
// used for only integer resolution
}
#endif
pu
.
cu
->
GBiIdx
=
(
interDirNeighbours
[
candIdx
]
==
3
)
?
GBiIdx
[
candIdx
]
:
GBI_DEFAULT
;
#if JVET_M0068_M0171_MMVD_CLEANUP
...
...
source/Lib/CommonLib/ContextModelling.h
View file @
cf0eff9f
...
...
@@ -317,6 +317,9 @@ unsigned CtxTriangleFlag( const CodingUnit& cu );
#if JVET_M0502_PRED_MODE_CTX
unsigned
CtxPredModeFlag
(
const
CodingUnit
&
cu
);
#endif
#if IBC_SEPERATE_MODE
unsigned
CtxIBCFlag
(
const
CodingUnit
&
cu
);
#endif
}
#endif // __CONTEXTMODELLING__
source/Lib/CommonLib/Contexts.cpp
View file @
cf0eff9f
...
...
@@ -1326,6 +1326,21 @@ const CtxSet ContextSetCfg::TriangleIdx = ContextSetCfg::addCtxSet
});
// clang-format on
#if IBC_SEPERATE_MODE
const
CtxSet
ContextSetCfg
::
IBCFlag
=
ContextSetCfg
::
addCtxSet
({
#if TRAINED_CABAC_INIT_TABLES
{
165
,
137
,
153
,
},
{
106
,
122
,
138
,
},
{
CNU
,
CNU
,
CNU
,
},
#else
{
151
,
137
,
154
,
},
{
151
,
137
,
154
,
},
{
CNU
,
CNU
,
CNU
,
},
#endif
});
#endif
const
unsigned
ContextSetCfg
::
NumberOfContexts
=
(
unsigned
)
ContextSetCfg
::
sm_InitTables
[
0
].
size
();
...
...
source/Lib/CommonLib/Contexts.h
View file @
cf0eff9f
...
...
@@ -306,6 +306,9 @@ public:
static
const
CtxSet
TriangleIdx
;
#if JVET_M0444_SMVD
static
const
CtxSet
SmvdFlag
;
#endif
#if IBC_SEPERATE_MODE
static
const
CtxSet
IBCFlag
;
#endif
static
const
unsigned
NumberOfContexts
;
...
...
source/Lib/CommonLib/InterPrediction.cpp
View file @
cf0eff9f
...
...
@@ -375,7 +375,11 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList&
int
iRefIdx
=
pu
.
refIdx
[
eRefPicList
];
Mv
mv
[
3
];
bool
isIBC
=
false
;
#if IBC_SEPERATE_MODE
if
(
CU
::
isIBC
(
*
pu
.
cu
))
#else
if
(
pu
.
cs
->
slice
->
getRefPic
(
eRefPicList
,
iRefIdx
)
->
getPOC
()
==
pu
.
cs
->
slice
->
getPOC
())
#endif
{
isIBC
=
true
;
}
...
...
@@ -411,11 +415,27 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList&
}
else
{
#if IBC_SEPERATE_MODE
if
(
isIBC
)
{
xPredInterBlk
(
compID
,
pu
,
pu
.
cu
->
slice
->
getPic
(),
mv
[
0
],
pcYuvPred
,
bi
,
pu
.
cu
->
slice
->
clpRng
(
compID
)
,
bioApplied
,
isIBC
);
}
else
{
xPredInterBlk
(
compID
,
pu
,
pu
.
cu
->
slice
->
getRefPic
(
eRefPicList
,
iRefIdx
),
mv
[
0
],
pcYuvPred
,
bi
,
pu
.
cu
->
slice
->
clpRng
(
compID
)
,
bioApplied
,
isIBC
);
}
#else
xPredInterBlk
(
compID
,
pu
,
pu
.
cu
->
slice
->
getRefPic
(
eRefPicList
,
iRefIdx
),
mv
[
0
],
pcYuvPred
,
bi
,
pu
.
cu
->
slice
->
clpRng
(
compID
)
,
bioApplied
,
isIBC
);
#endif
}
}
}
...
...
@@ -468,7 +488,12 @@ void InterPrediction::xPredInterBi(PredictionUnit& pu, PelUnitBuf &pcYuvPred)
RefPicList
eRefPicList
=
(
refList
?
REF_PIC_LIST_1
:
REF_PIC_LIST_0
);
#if IBC_SEPERATE_MODE
CHECK
(
pu
.
refIdx
[
refList
]
>
slice
.
getNumRefIdx
(
eRefPicList
),
"Invalid reference index"
);
CHECK
((
CU
::
isInter
(
*
pu
.
cu
)
&&
pu
.
refIdx
[
refList
]
>=
slice
.
getNumRefIdx
(
eRefPicList
)),
"Invalid reference index"
);
#else
CHECK
(
pu
.
refIdx
[
refList
]
>=
slice
.
getNumRefIdx
(
eRefPicList
),
"Invalid reference index"
);
#endif
m_iRefListIdx
=
refList
;
PelUnitBuf
pcMbBuf
=
(
pu
.
chromaFormat
==
CHROMA_400
?
...
...
source/Lib/CommonLib/MotionInfo.h
View file @
cf0eff9f
...
...
@@ -101,19 +101,31 @@ struct MvField
struct
MotionInfo
{
bool
isInter
;
#if IBC_SEPERATE_MODE
bool
isIBCmot
;
#endif
char
interDir
;
uint16_t
sliceIdx
;
Mv
mv
[
NUM_REF_PIC_LIST_01
];
int16_t
refIdx
[
NUM_REF_PIC_LIST_01
];
Mv
bv
;
#if IBC_SEPERATE_MODE
MotionInfo
()
:
isInter
(
false
),
isIBCmot
(
false
),
interDir
(
0
),
sliceIdx
(
0
),
refIdx
{
NOT_VALID
,
NOT_VALID
}
{
}
// ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else
MotionInfo
(
int
i
)
:
isInter
(
i
!=
0
),
isIBCmot
(
false
),
interDir
(
0
),
sliceIdx
(
0
),
refIdx
{
0
,
0
}
{
CHECKD
(
i
!=
0
,
"The argument for this constructor has to be '0'"
);
}
#else
MotionInfo
()
:
isInter
(
false
),
interDir
(
0
),
sliceIdx
(
0
),
refIdx
{
NOT_VALID
,
NOT_VALID
}
{
}
// ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else
MotionInfo
(
int
i
)
:
isInter
(
i
!=
0
),
interDir
(
0
),
sliceIdx
(
0
),
refIdx
{
0
,
0
}
{
CHECKD
(
i
!=
0
,
"The argument for this constructor has to be '0'"
);
}
#endif
bool
operator
==
(
const
MotionInfo
&
mi
)
const
{
if
(
isInter
!=
mi
.
isInter
)
return
false
;
#if IBC_SEPERATE_MODE
if
(
isIBCmot
!=
mi
.
isIBCmot
)
return
false
;
#endif
if
(
isInter
)
{
if
(
sliceIdx
!=
mi
.
sliceIdx
)
return
false
;
...
...
@@ -211,5 +223,8 @@ struct LutMotionCand
{
MotionInfo
*
motionCand
;
int
currCnt
;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
int
currCntIBC
;
#endif
};
#endif // __MOTIONINFO__
source/Lib/CommonLib/Slice.cpp
View file @
cf0eff9f
...
...
@@ -435,6 +435,7 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
pcRefPic
=
xGetLongTermRefPic
(
rcListPic
,
m_pRPS
->
getPOC
(
i
),
m_pRPS
->
getCheckLTMSBPresent
(
i
));
}
}
#if IBC_SEPERATE_MODE==0
if
(
getSPS
()
->
getSpsNext
().
getIBCMode
())
{
RefPicSetLtCurr
[
NumPicLtCurr
]
=
getPic
();
...
...
@@ -442,6 +443,7 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
getPic
()
->
longTerm
=
true
;
NumPicLtCurr
++
;
}
#endif
// ref_pic_list_init
Picture
*
rpsCurrList0
[
MAX_NUM_REF
+
1
];
Picture
*
rpsCurrList1
[
MAX_NUM_REF
+
1
];
...
...
@@ -454,11 +456,13 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
// - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
if
(
getRapPicFlag
())
{
#if IBC_SEPERATE_MODE==0
if
(
getSPS
()
->
getSpsNext
().
getIBCMode
())
{
CHECK
(
numPicTotalCurr
!=
1
,
"Invalid state"
);
}
else
#endif
CHECK
(
numPicTotalCurr
!=
0
,
"Invalid state"
);
}
...
...
@@ -529,11 +533,13 @@ void Slice::setRefPicList( PicList& rcListPic, bool checkNumPocTotalCurr, bool b
m_bIsUsedAsLongTerm
[
REF_PIC_LIST_1
][
rIdx
]
=
(
cIdx
>=
NumPicStCurr0
+
NumPicStCurr1
);
}
}
#if IBC_SEPERATE_MODE==0
if
(
getSPS
()
->
getSpsNext
().
getIBCMode
())
{
m_apcRefPicList
[
REF_PIC_LIST_0
][
m_aiNumRefIdx
[
REF_PIC_LIST_0
]
-
1
]
=
getPic
();
m_bIsUsedAsLongTerm
[
REF_PIC_LIST_0
][
m_aiNumRefIdx
[
REF_PIC_LIST_0
]
-
1
]
=
true
;
}
#endif
// For generalized B
// note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
if
(
bCopyL0toL1ErrorCase
&&
isInterB
()
&&
getNumRefIdx
(
REF_PIC_LIST_1
)
==
0
)
...
...
@@ -1612,14 +1618,28 @@ void Slice::initMotionLUTs()
{
m_MotionCandLut
=
new
LutMotionCand
;
m_MotionCandLut
->
currCnt
=
0
;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLut
->
currCntIBC
=
0
;
#endif
m_MotionCandLut
->
motionCand
=
nullptr
;
#if IBC_SEPERATE_MODE
m_MotionCandLut
->
motionCand
=
new
MotionInfo
[
MAX_NUM_HMVP_CANDS
*
2
];
#else
m_MotionCandLut
->
motionCand
=
new
MotionInfo
[
MAX_NUM_HMVP_CANDS
];
#endif
#if JVET_M0170_MRG_SHARELIST
m_MotionCandLuTsBkup
=
new
LutMotionCand
;
m_MotionCandLuTsBkup
->
currCnt
=
0
;
#if IBC_SEPERATE_MODE_AND_MER && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLuTsBkup
->
currCntIBC
=
0
;
#endif
m_MotionCandLuTsBkup
->
motionCand
=
nullptr
;
#if IBC_SEPERATE_MODE_AND_MER
m_MotionCandLuTsBkup
->
motionCand
=
new
MotionInfo
[
MAX_NUM_HMVP_CANDS
*
2
];
#else
m_MotionCandLuTsBkup
->
motionCand
=
new
MotionInfo
[
MAX_NUM_HMVP_CANDS
];
#endif
#endif
}
void
Slice
::
destroyMotionLUTs
()
{
...
...
@@ -1637,8 +1657,14 @@ void Slice::destroyMotionLUTs()
void
Slice
::
resetMotionLUTs
()
{
m_MotionCandLut
->
currCnt
=
0
;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLut
->
currCntIBC
=
0
;
#endif
#if JVET_M0170_MRG_SHARELIST
m_MotionCandLuTsBkup
->
currCnt
=
0
;
#if IBC_SEPERATE_MODE_AND_MER && IBC_SEPERATE_MODE_REDUCTION==0
m_MotionCandLuTsBkup
->
currCntIBC
=
0
;
#endif
#endif
}
...
...
@@ -1653,8 +1679,46 @@ MotionInfo Slice::getMotionInfoFromLUTBkup(int MotCandIdx) const
}
#endif
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
void
Slice
::
addMotionInfoToLUTs
(
LutMotionCand
*
lutMC
,
MotionInfo
newMi
,
bool
ibcflag
)
#else
void
Slice
::
addMotionInfoToLUTs
(
LutMotionCand
*
lutMC
,
MotionInfo
newMi
)
#endif
{
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
int
currCntIBC
=
ibcflag
?
lutMC
->
currCntIBC
:
lutMC
->
currCnt
;
int
offset
=
ibcflag
?
MAX_NUM_HMVP_CANDS
:
0
;
bool
pruned
=
false
;
int
sameCandIdx
=
0
;
for
(
int
idx
=
0
;
idx
<
currCntIBC
;
idx
++
)
{
if
(
lutMC
->
motionCand
[
idx
+
offset
]
==
newMi
)
{
sameCandIdx
=
idx
;
pruned
=
true
;
break
;
}
}
if
(
pruned
||
currCntIBC
==
MAX_NUM_HMVP_CANDS
)
{
memmove
(
&
lutMC
->
motionCand
[
sameCandIdx
+
offset
],
&
lutMC
->
motionCand
[
sameCandIdx
+
offset
+
1
],
sizeof
(
MotionInfo
)
*
(
currCntIBC
-
sameCandIdx
-
1
));
memcpy
(
&
lutMC
->
motionCand
[
currCntIBC
+
offset
-
1
],
&
newMi
,
sizeof
(
MotionInfo
));
}
else
{
if
(
ibcflag
)
{
memcpy
(
&
lutMC
->
motionCand
[
currCntIBC
+
offset
],
&
newMi
,
sizeof
(
MotionInfo
));
lutMC
->
currCntIBC
++
;
}
else
{
memcpy
(
&
lutMC
->
motionCand
[
currCntIBC
],
&
newMi
,
sizeof
(
MotionInfo
));
lutMC
->
currCnt
++
;
}
}
#else
int
currCnt
=
lutMC
->
currCnt
;
bool
pruned
=
false
;
...
...
@@ -1678,6 +1742,7 @@ void Slice::addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi)
{
memcpy
(
&
lutMC
->
motionCand
[
lutMC
->
currCnt
++
],
&
newMi
,
sizeof
(
MotionInfo
));
}
#endif
}
void
Slice
::
updateMotionLUTs
(
LutMotionCand
*
lutMC
,
CodingUnit
&
cu
)
...
...
@@ -1686,19 +1751,34 @@ void Slice::updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu)
if
(
cu
.
affine
)
{
return
;
}
if
(
cu
.
triangle
)
{
return
;
}
MotionInfo
newMi
=
selectedPU
->
getMotionInfo
();
MotionInfo
newMi
=
selectedPU
->
getMotionInfo
();
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
addMotionInfoToLUTs
(
lutMC
,
newMi
,
CU
::
isIBC
(
cu
));
#else
addMotionInfoToLUTs
(
lutMC
,
newMi
);
#endif
}
void
Slice
::
copyMotionLUTs
(
LutMotionCand
*
Src
,
LutMotionCand
*
Dst
)
{
memcpy
(
Dst
->
motionCand
,
Src
->
motionCand
,
sizeof
(
MotionInfo
)
*
(
std
::
min
(
Src
->
currCnt
,
MAX_NUM_HMVP_CANDS
)));
Dst
->
currCnt
=
Src
->
currCnt
;
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
memcpy
(
Dst
->
motionCand
+
MAX_NUM_HMVP_CANDS
,
Src
->
motionCand
+
MAX_NUM_HMVP_CANDS
,
sizeof
(
MotionInfo
)
*
(
std
::
min
(
Src
->
currCntIBC
,
MAX_NUM_HMVP_CANDS
)));
Dst
->
currCntIBC
=
Src
->
currCntIBC
;
#endif
}
unsigned
Slice
::
getMinPictureDistance
()
const
{
int
minPicDist
=
MAX_INT
;
#if IBC_SEPERATE_MODE
if
(
getSPS
()
->
getSpsNext
().
getIBCMode
())
{
minPicDist
=
0
;
}
else
#endif
if
(
!
isIntra
()
)
{
const
int
currPOC
=
getPOC
();
...
...
source/Lib/CommonLib/Slice.h
View file @
cf0eff9f
...
...
@@ -1949,6 +1949,9 @@ public:
void
initMotionLUTs
();
void
destroyMotionLUTs
();
void
resetMotionLUTs
();
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
int
getAvailableLUTIBCMrgNum
()
const
{
return
m_MotionCandLut
->
currCntIBC
;
}
#endif
int
getAvailableLUTMrgNum
()
const
{
return
m_MotionCandLut
->
currCnt
;
}
#if JVET_M0170_MRG_SHARELIST
int
getAvailableLUTBkupMrgNum
()
const
{
return
m_MotionCandLuTsBkup
->
currCnt
;
}
...
...
@@ -1957,8 +1960,11 @@ public:
MotionInfo
getMotionInfoFromLUTs
(
int
MotCandIdx
)
const
;
LutMotionCand
*
getMotionLUTs
()
{
return
m_MotionCandLut
;
}
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
void
addMotionInfoToLUTs
(
LutMotionCand
*
lutMC
,
MotionInfo
newMi
,
bool
ibcflag
);
#else
void
addMotionInfoToLUTs
(
LutMotionCand
*
lutMC
,
MotionInfo
newMi
);
#endif
void
updateMotionLUTs
(
LutMotionCand
*
lutMC
,
CodingUnit
&
cu
);
void
copyMotionLUTs
(
LutMotionCand
*
Src
,
LutMotionCand
*
Dst
);
...
...
source/Lib/CommonLib/TypeDef.h
View file @
cf0eff9f
...
...
@@ -50,6 +50,21 @@
#include
<assert.h>
#include
<cassert>
#define JVET_M0483_IBC 1 //
#if JVET_M0483_IBC
#define IBC_SEPERATE_MODE 1 //JVET-M0483_method3
#define IBC_SEPERATE_MODE_FIX 1 //JVET-M0483_method3 bug fix ticket 129 and 140
#define IBC_SEPERATE_MODE_REDUCTION 0
#define IBC_SIZE_CONSTRAINT 0
#define IBC_SEPERATE_FUNCTION 1
#define CLEAN_getInterMergeCandidates 1
#define CLEAN_fillMvpCand 1
#define MODIFY_for_vtm4 1
#define IBC_SEPERATE_MODE_AND_MER 1
#define DEBUG_M0483 1
#endif
#define JVET_M0145_AFFINE_MV_CLIP 1 // Missing clipping for MV storage in affine
#define JVET_M0381_ONE_CTX_FOR_SUBBLOCK_MRG_IDX 1 // CE2.2.2 a: one context for subblock Merge index
...
...
@@ -443,7 +458,12 @@ enum PredMode
{
MODE_INTER
=
0
,
///< inter-prediction mode
MODE_INTRA
=
1
,
///< intra-prediction mode
#if IBC_SEPERATE_MODE
MODE_IBC
=
2
,
///< ibc-prediction mode
NUMBER_OF_PREDICTION_MODES
=
3
,
#else
NUMBER_OF_PREDICTION_MODES
=
2
,
#endif
};
/// reference list index
...
...
source/Lib/CommonLib/Unit.cpp
View file @
cf0eff9f
...
...
@@ -277,7 +277,9 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other )
shareParentPos
=
other
.
shareParentPos
;
shareParentSize
=
other
.
shareParentSize
;
#endif
#if IBC_SEPERATE_MODE==0
ibc
=
other
.
ibc
;
#endif
#if JVET_M0444_SMVD
smvdMode
=
other
.
smvdMode
;
#endif
...
...
@@ -319,7 +321,9 @@ void CodingUnit::initData()
shareParentSize
.
width
=
-
1
;
shareParentSize
.
height
=
-
1
;
#endif
#if IBC_SEPERATE_MODE==0
ibc
=
false
;
#endif
#if JVET_M0444_SMVD
smvdMode
=
0
;
#endif
...
...
source/Lib/CommonLib/Unit.h
View file @
cf0eff9f
...
...
@@ -316,7 +316,9 @@ struct CodingUnit : public UnitArea
Position
shareParentPos
;
Size
shareParentSize
;
#endif
#if IBC_SEPERATE_MODE ==0
bool
ibc
;
#endif
#if JVET_M0444_SMVD
uint8_t
smvdMode
;
#endif
...
...
source/Lib/CommonLib/UnitTools.cpp
View file @
cf0eff9f
This diff is collapsed.
Click to expand it.
source/Lib/CommonLib/UnitTools.h
View file @
cf0eff9f
...
...
@@ -57,6 +57,9 @@ namespace CU
{
bool
isIntra
(
const
CodingUnit
&
cu
);
bool
isInter
(
const
CodingUnit
&
cu
);
#if IBC_SEPERATE_MODE
bool
isIBC
(
const
CodingUnit
&
cu
);
#endif
bool
isRDPCMEnabled
(
const
CodingUnit
&
cu
);
bool
isLosslessCoded
(
const
CodingUnit
&
cu
);
uint32_t
getIntraSizeIdx
(
const
CodingUnit
&
cu
);
...
...
@@ -107,11 +110,17 @@ namespace PU
void
getInterMergeCandidates
(
const
PredictionUnit
&
pu
,
MergeCtx
&
mrgCtx
,
int
mmvdList
,
const
int
&
mrgCandIdx
=
-
1
);
#if IBC_SEPERATE_FUNCTION
void
getIBCMergeCandidates
(
const
PredictionUnit
&
pu
,
MergeCtx
&
mrgCtx
,
const
int
&
mrgCandIdx
=
-
1
);
#endif
void
getInterMMVDMergeCandidates
(
const
PredictionUnit
&
pu
,
MergeCtx
&
mrgCtx
,
const
int
&
mrgCandIdx
=
-
1
);
int
getDistScaleFactor
(
const
int
&
currPOC
,
const
int
&
currRefPOC
,
const
int
&
colPOC
,
const
int
&
colRefPOC
);
bool
isDiffMER
(
const
PredictionUnit
&
pu
,
const
PredictionUnit
&
pu2
);
bool
getColocatedMVP
(
const
PredictionUnit
&
pu
,
const
RefPicList
&
eRefPicList
,
const
Position
&
pos
,
Mv
&
rcMv
,
const
int
&
refIdx
);
void
fillMvpCand
(
PredictionUnit
&
pu
,
const
RefPicList
&
eRefPicList
,
const
int
&
refIdx
,
AMVPInfo
&
amvpInfo
);
#if IBC_SEPERATE_FUNCTION
void
fillIBCMvpCand
(
PredictionUnit
&
pu
,
const
RefPicList
&
eRefPicList
,
const
int
&
refIdx
,
AMVPInfo
&
amvpInfo
);
#endif
void
fillAffineMvpCand
(
PredictionUnit
&
pu
,
const
RefPicList
&
eRefPicList
,
const
int
&
refIdx
,
AffineAMVPInfo
&
affiAMVPInfo
);
bool
addMVPCandUnscaled
(
const
PredictionUnit
&
pu
,
const
RefPicList
&
eRefPicList
,
const
int
&
iRefIdx
,
const
Position
&
pos
,
const
MvpDir
&
eDir
,
AMVPInfo
&
amvpInfo
);
bool
addMVPCandWithScaling
(
const
PredictionUnit
&
pu
,
const
RefPicList
&
eRefPicList
,
const
int
&
iRefIdx
,
const
Position
&
pos
,
const
MvpDir
&
eDir
,
AMVPInfo
&
amvpInfo
);
...
...
@@ -119,14 +128,21 @@ namespace PU
bool
xCheckSimilarMotion
(
const
int
mergeCandIndex
,
const
int
prevCnt
,
const
MergeCtx
mergeCandList
,
bool
hasPruned
[
MRG_MAX_NUM_CANDS
]);
#if JVET_L0090_PAIR_AVG
bool
addMergeHMVPCand
(
const
Slice
&
slice
,
MergeCtx
&
mrgCtx
,
bool
canFastExit
,
const
int
&
mrgCandIdx
,
const
uint32_t
maxNumMergeCandMin1
,
int
&
cnt
,
const
int
prevCnt
,
bool
isAvailableSubPu
,
unsigned
subPuMvpPos
#if IBC_SEPERATE_MODE==0
,
int
mmvdList
#endif
#if IBC_SEPERATE_MODE && IBC_SEPERATE_MODE_REDUCTION==0
,
bool
ibc_flag
#endif
#if JVET_M0170_MRG_SHARELIST
,
bool
isShared
#endif
);
#else
bool
addMergeHMVPCand
(
const
Slice
&
slice
,
MergeCtx
&
mrgCtx
,
bool
isCandInter
[
MRG_MAX_NUM_CANDS
],
bool
canFastExit
,
const
int
&
mrgCandIdx
,
const
uint32_t
maxNumMergeCandMin1
,
int
&
cnt
,
const
int
prevCnt
,
bool
isAvailableSubPu
,
unsigned
subPuMvpPos
#if IBC_SEPERATE_MODE==0
,
int
mmvdList
#endif
);
#endif
void
addAMVPHMVPCand
(
const
PredictionUnit
&
pu
,
const
RefPicList
eRefPicList
,
const
RefPicList
eRefPicList2nd
,
const
int
currRefPOC
,
AMVPInfo
&
info
,
uint8_t
imv
);
...
...
@@ -143,7 +159,9 @@ namespace PU
bool
getInterMergeSubPuMvpCand
(
const
PredictionUnit
&
pu
,
MergeCtx
&
mrgCtx
,
bool
&
LICFlag
,
const
int
count
,
int
mmvdList
#if !JVET_M0409_ATMVP_FIX
#if IBC_SEPERATE_MODE==0
,
const
int
countIBC
#endif
#endif
);
bool
getInterMergeSubPuRecurCand
(
const
PredictionUnit
&
pu
,
MergeCtx
&
mrgCtx
,
const
int
count
);
...
...
source/Lib/DecoderLib/CABACReader.cpp
View file @
cf0eff9f
...
...
@@ -885,7 +885,11 @@ bool CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx&
}
// skip flag
#if IBC_SEPERATE_MODE
if
((
!
cs
.
slice
->
isIntra
()
||
cs
.
slice
->
getSPS
()
->
getSpsNext
().
getIBCMode
())
&&
cu
.
Y
().
valid
())
#else
if
(
!
cs
.
slice
->
isIntra
()
&&
cu
.
Y
().
valid
())
#endif
{
cu_skip_flag
(
cu
);
}
...
...
@@ -948,12 +952,83 @@ void CABACReader::cu_skip_flag( CodingUnit& cu )
{
RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET
(
STATS__CABAC_BITS__SKIP_FLAG
);
#if IBC_SEPERATE_MODE
#if IBC_SEPERATE_MODE_FIX
if
(
cu
.
slice
->
isIntra
()
&&
cu
.
cs
->
slice
->
getSPS
()
->
getSpsNext
().
getIBCMode
())
#else
if
(
cu
.
slice
->
isIntra
())
#endif
{
cu
.
skip
=
false
;
cu
.
rootCbf
=
false
;
cu
.
predMode
=
MODE_INTRA
;
//cu.partSize = SIZE_2Nx2N; //Todo
cu
.
mmvdSkip
=
false
;
if
(
cu
.
lwidth
()
>
IBC_MAX_CAND_SIZE
||
cu
.
lheight
()
>
IBC_MAX_CAND_SIZE
)
// currently only check 32x32 and below block for ibc merge/skip
{
}
else
{
unsigned
ctxId
=
DeriveCtx
::
CtxSkipFlag
(
cu
);
unsigned
skip
=
m_BinDecoder
.
decodeBin
(
Ctx
::
SkipFlag
(
ctxId
));
if
(
skip
)
{
cu
.
skip
=
true
;
cu
.
rootCbf
=
false
;
cu
.
predMode
=
MODE_IBC
;
//cu.partSize = SIZE_2Nx2N;//Todo
cu
.
mmvdSkip
=
false
;
}
}
return
;
}
#endif
unsigned
ctxId
=
DeriveCtx
::
CtxSkipFlag
(
cu
);
unsigned
skip
=
m_BinDecoder
.
decodeBin
(
Ctx
::
SkipFlag
(
ctxId
)
);
DTRACE
(
g_trace_ctx
,
D_SYNTAX
,
"cu_skip_flag() ctx=%d skip=%d
\n
"
,
ctxId
,
skip
?
1
:
0
);
#if IBC_SEPERATE_MODE