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
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jeeva Raj A
VVCSoftware_VTM
Commits
f83271a0
Commit
f83271a0
authored
Jul 22, 2019
by
Christian Helmrich
Browse files
Options
Browse Files
Download
Plain Diff
merge from master
parents
ac87c3ff
c81b8ade
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
434 additions
and
8 deletions
+434
-8
source/App/DecoderApp/DecApp.cpp
source/App/DecoderApp/DecApp.cpp
+3
-0
source/App/StreamMergeApp/StreamMergeApp.cpp
source/App/StreamMergeApp/StreamMergeApp.cpp
+4
-1
source/Lib/CommonLib/CodingStatistics.h
source/Lib/CommonLib/CodingStatistics.h
+211
-0
source/Lib/CommonLib/CommonDef.h
source/Lib/CommonLib/CommonDef.h
+9
-0
source/Lib/CommonLib/ContextModelling.h
source/Lib/CommonLib/ContextModelling.h
+4
-0
source/Lib/CommonLib/DepQuant.cpp
source/Lib/CommonLib/DepQuant.cpp
+53
-0
source/Lib/CommonLib/QuantRDOQ.cpp
source/Lib/CommonLib/QuantRDOQ.cpp
+37
-1
source/Lib/CommonLib/QuantRDOQ.h
source/Lib/CommonLib/QuantRDOQ.h
+4
-0
source/Lib/CommonLib/TypeDef.h
source/Lib/CommonLib/TypeDef.h
+14
-0
source/Lib/CommonLib/Unit.cpp
source/Lib/CommonLib/Unit.cpp
+19
-0
source/Lib/CommonLib/Unit.h
source/Lib/CommonLib/Unit.h
+3
-0
source/Lib/CommonLib/UnitTools.cpp
source/Lib/CommonLib/UnitTools.cpp
+1
-1
source/Lib/DecoderLib/AnnexBread.cpp
source/Lib/DecoderLib/AnnexBread.cpp
+16
-0
source/Lib/DecoderLib/CABACReader.cpp
source/Lib/DecoderLib/CABACReader.cpp
+32
-2
source/Lib/EncoderLib/CABACWriter.cpp
source/Lib/EncoderLib/CABACWriter.cpp
+24
-3
No files found.
source/App/DecoderApp/DecApp.cpp
View file @
f83271a0
...
...
@@ -187,6 +187,9 @@ uint32_t DecApp::decode()
{
m_cDecLib
.
executeLoopFilters
();
m_cDecLib
.
finishPicture
(
poc
,
pcListPic
);
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
CodingStatistics
::
UpdateMaxStat
(
backupStats
);
#endif
}
loopFiltered
=
(
nalu
.
m_nalUnitType
==
NAL_UNIT_EOS
);
if
(
nalu
.
m_nalUnitType
==
NAL_UNIT_EOS
)
...
...
source/App/StreamMergeApp/StreamMergeApp.cpp
View file @
f83271a0
...
...
@@ -43,6 +43,9 @@
#include "StreamMergeApp.h"
#include "DecoderLib/AnnexBread.h"
#include "DecoderLib/NALread.h"
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#include "CommonLib/CodingStatistics.h"
#endif
//! \ingroup DecoderApp
//! \{
...
...
@@ -171,7 +174,7 @@ _byteStreamNALUnit(
while
(
bs
.
eofBeforeNBytes
(
24
/
8
,
istream
)
||
bs
.
peekBytes
(
24
/
8
,
istream
)
>
2
)
{
#if RExt__DECODER_DEBUG_BIT_STATISTICS
uint8_t
thebyte
=
bs
.
readByte
();
bodyStats
.
bits
+=
8
;
bodyStats
.
count
++
;
uint8_t
thebyte
=
bs
.
readByte
(
istream
);
bodyStats
.
bits
+=
8
;
bodyStats
.
count
++
;
nalUnit
.
push_back
(
thebyte
);
#else
nalUnit
.
push_back
(
bs
.
readByte
(
istream
));
...
...
source/Lib/CommonLib/CodingStatistics.h
View file @
f83271a0
...
...
@@ -86,6 +86,14 @@ enum CodingStatisticsType
STATS__CABAC_BITS__GT2_FLAG
,
STATS__CABAC_BITS__SIGN_BIT
,
STATS__CABAC_BITS__ESCAPE_BITS
,
#if TR_ONLY_COEFF_STATS
STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG_TS
,
STATS__CABAC_BITS__PAR_FLAG_TS
,
STATS__CABAC_BITS__GT1_FLAG_TS
,
STATS__CABAC_BITS__GT2_FLAG_TS
,
STATS__CABAC_BITS__SIGN_BIT_TS
,
STATS__CABAC_BITS__ESCAPE_BITS_TS
,
#endif
STATS__CABAC_BITS__SAO
,
STATS__CABAC_BITS__ALF
,
STATS__CABAC_TRM_BITS
,
...
...
@@ -171,6 +179,14 @@ static inline const char* getName(CodingStatisticsType name)
"CABAC_BITS__GT2_FLAG"
,
"CABAC_BITS__SIGN_BIT"
,
"CABAC_BITS__ESCAPE_BITS"
,
#if TR_ONLY_COEFF_STATS
"CABAC_BITS__SIG_COEFF_MAP_FLAG_TS"
,
"CABAC_BITS__PAR_FLAG_TS"
,
"CABAC_BITS__GT1_FLAG_TS"
,
"CABAC_BITS__GT2_FLAG_TS"
,
"CABAC_BITS__SIGN_BIT_TS"
,
"CABAC_BITS__ESCAPE_BITS_TS"
,
#endif
"CABAC_BITS__SAO"
,
"CABAC_BITS__LFNST"
,
"CABAC_BITS__ALF"
,
...
...
@@ -309,6 +325,13 @@ public:
{
bits
+=
src
.
bits
;
count
+=
src
.
count
;
sum
+=
src
.
sum
;
classCount
+=
src
.
classCount
;
return
*
this
;
}
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
SStat
&
operator
-=
(
const
SStat
&
src
)
{
bits
-=
src
.
bits
;
count
-=
src
.
count
;
sum
-=
src
.
sum
;
classCount
-=
src
.
classCount
;
return
*
this
;
}
#endif
};
struct
StatTool
...
...
@@ -327,12 +350,45 @@ public:
}
};
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
struct
SStat_max
{
SStat
max_CABAC_state
;
SStat
max_EP_state
;
SStat
trf_CABAC_state
;
SStat
trf_EP_state
;
SStat
acc_trf_CABAC_state
;
SStat
acc_trf_EP_state
;
SStat
prev_CABAC_state
;
SStat
prev_EP_state
;
SStat
prev_trf_CABAC_state
;
SStat
prev_trf_EP_state
;
void
clear
()
{
max_CABAC_state
.
clear
();
max_EP_state
.
clear
();
trf_CABAC_state
.
clear
();
trf_EP_state
.
clear
();
acc_trf_CABAC_state
.
clear
();
acc_trf_EP_state
.
clear
();
prev_CABAC_state
.
clear
();
prev_EP_state
.
clear
();
prev_trf_CABAC_state
.
clear
();
prev_trf_EP_state
.
clear
();
}
};
#endif
class
CodingStatisticsData
{
private:
SStat
statistics
[
STATS__NUM_STATS
+
1
][
CODING_STATS_NUM_SUBCLASSES
];
SStat
statistics_ep
[
STATS__NUM_STATS
+
1
][
CODING_STATS_NUM_SUBCLASSES
];
StatTool
statistics_tool
[
STATS__NUM_STATS
+
1
][
CODING_STATS_NUM_SUBCLASSES
];
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
SStat_max
statistics_max
;
#endif
std
::
map
<
std
::
string
,
SStat
>
mappings_ep
;
friend
class
CodingStatistics
;
};
...
...
@@ -429,6 +485,10 @@ private:
int64_t
classCounts
[
STATS__NUM_STATS
];
std
::
fill_n
(
classCounts
,
(
size_t
)
STATS__NUM_STATS
,
0
);
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
SStat_max
&
max
=
GetStatisticMax
();
#endif
int64_t
cr
=
0
;
// CABAC remainder, which is added to "STATS__CABAC_INITIALISATION"
{
int64_t
totalCABACbits
=
0
,
roundedCABACbits
=
0
;
...
...
@@ -522,6 +582,18 @@ private:
{
cabacSubTotal
.
classCount
=
classCounts
[
i
];
OutputLine
(
pName
,
'~'
,
"~~ST~~"
,
"~~ST~~"
,
"~~ST~~"
,
cabacSubTotal
,
epSubTotal
);
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
// For TRF
if
((
i
==
STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG
)
||
(
i
==
STATS__CABAC_BITS__PAR_FLAG
)
||
(
i
==
STATS__CABAC_BITS__GT1_FLAG
)
||
(
i
==
STATS__CABAC_BITS__GT2_FLAG
)
||
(
i
==
STATS__CABAC_BITS__ESCAPE_BITS
))
{
max
.
acc_trf_CABAC_state
+=
cabacSubTotal
;
max
.
acc_trf_EP_state
+=
epSubTotal
;
}
#endif
}
if
(
i
==
STATS__NAL_UNIT_TOTAL_BODY
)
{
...
...
@@ -604,6 +676,12 @@ private:
OutputDashedLine
(
"GRAND TOTAL"
);
epTotalBits
+=
cavlcTotalBits
;
OutputLine
(
"TOTAL"
,
'~'
,
"~~GT~~"
,
"~~GT~~"
,
"~~GT~~"
,
cabacTotalBits
,
epTotalBits
);
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
OutputDashedLine
(
""
);
OutputLine
(
"CABAC MAX FRAME stat"
,
'~'
,
"~~ST~~"
,
"~~ST~~"
,
"~~ST~~"
,
max
.
max_CABAC_state
,
max
.
max_EP_state
);
OutputLine
(
"CABAC MAX FRAME TRF stat"
,
'~'
,
"~~ST~~"
,
"~~ST~~"
,
"~~ST~~"
,
max
.
trf_CABAC_state
,
max
.
trf_EP_state
);
OutputLine
(
"CABAC Accumulated TRF stat"
,
'~'
,
"~~ST~~"
,
"~~ST~~"
,
"~~ST~~"
,
max
.
acc_trf_CABAC_state
,
max
.
acc_trf_EP_state
);
#endif
}
void
OutputToolStats
()
...
...
@@ -712,6 +790,10 @@ public:
static
StatTool
&
GetStatisticTool
(
const
CodingStatisticsClassType
&
stat
)
{
return
GetSingletonInstance
().
data
.
statistics_tool
[
stat
.
type
][
stat
.
subClass
];
}
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
static
SStat_max
&
GetStatisticMax
()
{
return
GetSingletonInstance
().
data
.
statistics_max
;
}
#endif
static
int
getNumOnes
(
int
bins
)
{
CHECK
(
bins
<
0
,
"Bins should not be nagative"
);
...
...
@@ -730,7 +812,11 @@ public:
CHECK
(
stat
.
type
==
STATS__CABAC_BITS__INVALID
,
"Should never be used."
);
SStat
&
s
=
GetStatisticEP
(
stat
);
s
.
bits
+=
numBits
;
#if EPBINCOUNT_FIX
s
.
count
+=
numBits
;
#else
s
.
count
++
;
#endif
s
.
sum
+=
getNumOnes
(
value
);
}
...
...
@@ -738,7 +824,11 @@ public:
{
SStat
&
s
=
GetStatisticEP
(
str
);
s
.
bits
+=
numBits
;
#if EPBINCOUNT_FIX
s
.
count
+=
numBits
;
#else
s
.
count
++
;
#endif
s
.
sum
+=
getNumOnes
(
value
);
}
...
...
@@ -746,7 +836,11 @@ public:
{
SStat
&
s
=
GetStatisticEP
(
pKey
);
s
.
bits
+=
numBits
;
#if EPBINCOUNT_FIX
s
.
count
+=
numBits
;
#else
s
.
count
++
;
#endif
s
.
sum
+=
getNumOnes
(
value
);
}
...
...
@@ -776,6 +870,123 @@ public:
s
.
count
++
;
s
.
sum
+=
val
;
}
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
static
void
UpdateMaxStat
(
CodingStatisticsData
*
data
)
{
SStat_max
&
max
=
GetStatisticMax
();
const
int64_t
es
=
CODINGSTATISTICS_ENTROPYSCALE
;
int64_t
countTotal
=
0
;
int64_t
classCounts
[
STATS__NUM_STATS
];
std
::
fill_n
(
classCounts
,
(
size_t
)
STATS__NUM_STATS
,
0
);
int64_t
cr
=
0
;
// CABAC remainder, which is added to "STATS__CABAC_INITIALISATION"
int64_t
totalCABACbits
=
0
,
roundedCABACbits
=
0
;
for
(
int
i
=
STATS__NAL_UNIT_PACKING
;
i
<
STATS__NUM_STATS
;
i
++
)
{
int64_t
classCount
=
0
;
for
(
uint32_t
c
=
0
;
c
<
CODING_STATS_NUM_SUBCLASSES
;
c
++
)
{
totalCABACbits
+=
data
->
statistics
[
i
][
c
].
bits
;
roundedCABACbits
+=
data
->
statistics
[
i
][
c
].
bits
/
es
;
classCount
+=
data
->
statistics
[
i
][
c
].
count
;
}
for
(
uint32_t
c
=
0
;
c
<
CODING_STATS_NUM_SUBCLASSES
;
c
++
)
{
data
->
statistics
[
i
][
c
].
classCount
=
classCount
;
}
classCounts
[
i
]
=
classCount
;
countTotal
+=
classCount
;
}
int64_t
remainder
=
totalCABACbits
-
roundedCABACbits
*
es
;
cr
=
(
remainder
+
es
/
2
)
/
es
;
classCounts
[
0
]
=
countTotal
;
SStat
cabacTotalBits
,
epTotalBits
,
cabacTrfTotalBits
,
epTrfTotalBits
;
cabacTotalBits
.
classCount
=
countTotal
;
epTotalBits
.
classCount
=
countTotal
;
cabacTrfTotalBits
.
classCount
=
countTotal
;
epTrfTotalBits
.
classCount
=
countTotal
;
// Calculate the actual bin and bit count
for
(
int
i
=
0
;
i
<
STATS__NUM_STATS
;
i
++
)
{
for
(
uint32_t
c
=
0
;
c
<
CODING_STATS_NUM_SUBCLASSES
;
c
++
)
{
SStat
&
sCABACorig
=
data
->
statistics
[
i
][
c
];
SStat
&
sEP
=
data
->
statistics_ep
[
i
][
c
];
if
(
sCABACorig
.
bits
==
0
&&
sEP
.
bits
==
0
)
{
continue
;
}
SStat
sCABAC
;
{
int64_t
thisCABACbits
=
sCABACorig
.
bits
/
es
;
if
(
i
==
STATS__CABAC_INITIALISATION
&&
sCABACorig
.
bits
!=
0
)
{
thisCABACbits
+=
cr
;
cr
=
0
;
}
sCABAC
.
bits
=
thisCABACbits
;
sCABAC
.
count
=
sCABACorig
.
count
;
sCABAC
.
sum
=
sCABACorig
.
sum
;
sCABAC
.
classCount
=
classCounts
[
i
];
}
if
(
i
!=
STATS__NAL_UNIT_TOTAL_BODY
)
{
cabacTotalBits
+=
sCABAC
;
epTotalBits
+=
sEP
;
// For TRF
if
((
i
==
STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG
)
||
(
i
==
STATS__CABAC_BITS__PAR_FLAG
)
||
(
i
==
STATS__CABAC_BITS__GT1_FLAG
)
||
(
i
==
STATS__CABAC_BITS__GT2_FLAG
)
||
(
i
==
STATS__CABAC_BITS__ESCAPE_BITS
))
{
cabacTrfTotalBits
+=
sCABAC
;
epTrfTotalBits
+=
sEP
;
}
}
}
}
SStat
delta_CABAC
=
cabacTotalBits
;
SStat
delta_EP
=
epTotalBits
;
SStat
delta_trf_CABAC
=
cabacTrfTotalBits
;
SStat
delta_trf_EP
=
epTrfTotalBits
;
delta_CABAC
-=
max
.
prev_CABAC_state
;
delta_EP
-=
max
.
prev_EP_state
;
delta_trf_CABAC
-=
max
.
prev_trf_CABAC_state
;
delta_trf_EP
-=
max
.
prev_trf_EP_state
;
int64_t
max_frame_bins
=
EPBIN_WEIGHT_FACTOR
*
max
.
max_CABAC_state
.
count
+
max
.
max_EP_state
.
count
;
int64_t
cur_frame_bins
=
EPBIN_WEIGHT_FACTOR
*
delta_CABAC
.
count
+
delta_EP
.
count
;
if
(
cur_frame_bins
>
max_frame_bins
)
{
max
.
max_CABAC_state
=
delta_CABAC
;
max
.
max_EP_state
=
delta_EP
;
max
.
trf_CABAC_state
=
delta_trf_CABAC
;
max
.
trf_EP_state
=
delta_trf_EP
;
}
max
.
prev_CABAC_state
=
cabacTotalBits
;
max
.
prev_EP_state
=
epTotalBits
;
max
.
prev_trf_CABAC_state
=
cabacTrfTotalBits
;
max
.
prev_trf_EP_state
=
epTrfTotalBits
;
}
#endif
};
#endif
source/Lib/CommonLib/CommonDef.h
View file @
f83271a0
...
...
@@ -330,10 +330,15 @@ static const int MMVD_ADD_NUM = (MMVD_MAX_RE
static
const
int
MMVD_MRG_MAX_RD_NUM
=
MRG_MAX_NUM_CANDS
;
static
const
int
MMVD_MRG_MAX_RD_BUF_NUM
=
(
MMVD_MRG_MAX_RD_NUM
+
1
);
///< increase buffer size by 1
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
static
const
int
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA
=
28
;
static
const
int
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA
=
28
;
#else
static
const
int
MAX_NUM_REG_BINS_4x4SUBBLOCK
=
32
;
///< max number of context-coded bins (incl. gt2 bins) per 4x4 subblock
static
const
int
MAX_NUM_GT2_BINS_4x4SUBBLOCK
=
4
;
///< max number of gt2 bins per 4x4 subblock
static
const
int
MAX_NUM_REG_BINS_2x2SUBBLOCK
=
8
;
///< max number of context-coded bins (incl. gt2 bins) per 2x2 subblock (chroma)
static
const
int
MAX_NUM_GT2_BINS_2x2SUBBLOCK
=
2
;
///< max number of gt2 bins per 2x2 subblock (chroma)
#endif
static
const
int
BIO_EXTEND_SIZE
=
1
;
static
const
int
BIO_TEMP_BUFFER_SIZE
=
(
MAX_CU_SIZE
+
2
*
BIO_EXTEND_SIZE
)
*
(
MAX_CU_SIZE
+
2
*
BIO_EXTEND_SIZE
);
...
...
@@ -454,6 +459,10 @@ static const int CSCALE_FP_PREC = 11;
static
const
int
NEIG_NUM_LOG
=
6
;
static
const
int
NEIG_NUM
=
1
<<
NEIG_NUM_LOG
;
#endif
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
static
const
int
EPBIN_WEIGHT_FACTOR
=
4
;
#endif
// ====================================================================================================================
// Macro functions
// ====================================================================================================================
...
...
source/Lib/CommonLib/ContextModelling.h
View file @
f83271a0
...
...
@@ -231,6 +231,10 @@ public:
return
auiGoRicePars
[
std
::
min
(
sum
,
31
)
];
}
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int
regBinLimit
;
#endif
private:
// constant
const
ComponentID
m_compID
;
...
...
source/Lib/CommonLib/DepQuant.cpp
View file @
f83271a0
...
...
@@ -89,6 +89,12 @@ namespace DQIntern
int
nextSbbBelow
;
int
posX
;
int
posY
;
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
ChannelType
chType
;
int
sbtInfo
;
int
tuWidth
;
int
tuHeight
;
#endif
};
class
Rom
;
...
...
@@ -370,6 +376,11 @@ namespace DQIntern
void
TUParameters
::
xSetScanInfo
(
ScanInfo
&
scanInfo
,
int
scanIdx
)
{
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
scanInfo
.
chType
=
m_chType
;
scanInfo
.
tuWidth
=
m_width
;
scanInfo
.
tuHeight
=
m_height
;
#endif
scanInfo
.
sbbSize
=
m_sbbSize
;
scanInfo
.
numSbb
=
m_numSbb
;
scanInfo
.
scanIdx
=
scanIdx
;
...
...
@@ -679,7 +690,11 @@ namespace DQIntern
m_QScale
=
g_quantScales
[
needsSqrt2ScaleAdjustment
?
1
:
0
][
qpRem
];
const
unsigned
qIdxBD
=
std
::
min
<
unsigned
>
(
maxLog2TrDynamicRange
+
1
,
8
*
sizeof
(
Intermediate_Int
)
+
invShift
-
IQUANT_SHIFT
-
1
);
m_maxQIdx
=
(
1
<<
(
qIdxBD
-
1
)
)
-
4
;
#if JVET_O0256_ADJUST_THD_DEPQUANT
m_thresLast
=
TCoeff
((
int64_t
(
4
)
<<
m_QShift
));
#else
m_thresLast
=
TCoeff
((
int64_t
(
3
)
<<
m_QShift
));
#endif
m_thresSSbb
=
TCoeff
((
int64_t
(
3
)
<<
m_QShift
));
// distortion calculation parameters
const
int64_t
qScale
=
(
gValue
==-
1
)
?
m_QScale
:
gValue
;
...
...
@@ -1018,7 +1033,11 @@ namespace DQIntern
int64_t
m_rdCost
;
uint16_t
m_absLevelsAndCtxInit
[
24
];
// 16x8bit for abs levels + 16x16bit for ctx init id
int8_t
m_numSigSbb
;
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int
m_remRegBins
;
#else
int8_t
m_remRegBins
;
#endif
int8_t
m_refSbbCtxId
;
BinFracBits
m_sbbFracBits
;
BinFracBits
m_sigFracBits
;
...
...
@@ -1030,6 +1049,11 @@ namespace DQIntern
const
CoeffFracBits
*
const
m_gtxFracBitsArray
;
const
uint32_t
*
const
m_goRiceZeroArray
;
CommonCtx
&
m_commonCtx
;
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
public:
unsigned
effWidth
;
unsigned
effHeight
;
#endif
};
...
...
@@ -1067,6 +1091,10 @@ namespace DQIntern
{
m_numSigSbb
=
1
;
m_refSbbCtxId
=
-
1
;
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int
ctxBinSampleRatio
=
(
scanInfo
.
chType
==
CHANNEL_TYPE_LUMA
)
?
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA
:
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA
;
m_remRegBins
=
(
effWidth
*
effHeight
*
ctxBinSampleRatio
)
/
16
-
(
decision
.
absLevel
<
2
?
decision
.
absLevel
:
3
);
#else
if
(
scanInfo
.
sbbSize
==
4
)
{
m_remRegBins
=
MAX_NUM_REG_BINS_2x2SUBBLOCK
-
(
decision
.
absLevel
<
2
?
decision
.
absLevel
:
3
);
...
...
@@ -1075,6 +1103,7 @@ namespace DQIntern
{
m_remRegBins
=
MAX_NUM_REG_BINS_4x4SUBBLOCK
-
(
decision
.
absLevel
<
2
?
decision
.
absLevel
:
3
);
}
#endif
::
memset
(
m_absLevelsAndCtxInit
,
0
,
48
*
sizeof
(
uint8_t
)
);
}
...
...
@@ -1258,6 +1287,17 @@ namespace DQIntern
const
int
sigNSbb
=
(
(
scanInfo
.
nextSbbRight
?
sbbFlags
[
scanInfo
.
nextSbbRight
]
:
false
)
||
(
scanInfo
.
nextSbbBelow
?
sbbFlags
[
scanInfo
.
nextSbbBelow
]
:
false
)
?
1
:
0
);
currState
.
m_numSigSbb
=
0
;
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
if
(
prevState
)
{
currState
.
m_remRegBins
=
prevState
->
m_remRegBins
;
}
else
{
int
ctxBinSampleRatio
=
(
scanInfo
.
chType
==
CHANNEL_TYPE_LUMA
)
?
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA
:
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA
;
currState
.
m_remRegBins
=
(
currState
.
effWidth
*
currState
.
effHeight
*
ctxBinSampleRatio
)
/
16
;
}
#else
if
(
scanInfo
.
sbbSize
==
4
)
{
currState
.
m_remRegBins
=
MAX_NUM_REG_BINS_2x2SUBBLOCK
;
...
...
@@ -1266,6 +1306,7 @@ namespace DQIntern
{
currState
.
m_remRegBins
=
MAX_NUM_REG_BINS_4x4SUBBLOCK
;
}
#endif
currState
.
m_goRicePar
=
0
;
currState
.
m_refSbbCtxId
=
currState
.
m_stateId
;
currState
.
m_sbbFracBits
=
m_sbbFlagBits
[
sigNSbb
];
...
...
@@ -1537,6 +1578,18 @@ namespace DQIntern
m_startState
.
init
();
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int
effectWidth
=
std
::
min
(
32
,
effWidth
);
int
effectHeight
=
std
::
min
(
32
,
effHeight
);
for
(
int
k
=
0
;
k
<
12
;
k
++
)
{
m_allStates
[
k
].
effWidth
=
effectWidth
;
m_allStates
[
k
].
effHeight
=
effectHeight
;
}
m_startState
.
effWidth
=
effectWidth
;
m_startState
.
effHeight
=
effectHeight
;
#endif
//===== populate trellis =====
for
(
int
scanIdx
=
firstTestPos
;
scanIdx
>=
0
;
scanIdx
--
)
{
...
...
source/Lib/CommonLib/QuantRDOQ.cpp
View file @
f83271a0
...
...
@@ -108,7 +108,9 @@ inline uint32_t QuantRDOQ::xGetCodedLevel( double& rd64CodedCost,
const
BinFracBits
&
fracBitsPar
,
const
BinFracBits
&
fracBitsGt1
,
const
BinFracBits
&
fracBitsGt2
,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const
int
remGt2Bins
,
#endif
const
int
remRegBins
,
unsigned
goRiceZero
,
uint16_t
ui16AbsGoRice
,
...
...
@@ -146,7 +148,11 @@ inline uint32_t QuantRDOQ::xGetCodedLevel( double& rd64CodedCost,
{
double
dErr
=
double
(
lLevelDouble
-
(
Intermediate_Int
(
uiAbsLevel
)
<<
iQBits
)
);
double
dCurrCost
=
dErr
*
dErr
*
errorScale
+
xGetICost
(
xGetICRate
(
uiAbsLevel
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
ui16AbsGoRice
,
true
,
maxLog2TrDynamicRange
)
);
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
double
dCurrCost
=
dErr
*
dErr
*
errorScale
+
xGetICost
(
xGetICRate
(
uiAbsLevel
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
ui16AbsGoRice
,
true
,
maxLog2TrDynamicRange
)
);
#else
double
dCurrCost
=
dErr
*
dErr
*
errorScale
+
xGetICost
(
xGetICRate
(
uiAbsLevel
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
ui16AbsGoRice
,
true
,
maxLog2TrDynamicRange
)
);
#endif
dCurrCost
+=
dCurrCostSig
;
if
(
dCurrCost
<
rd64CodedCost
)
...
...
@@ -175,7 +181,9 @@ inline int QuantRDOQ::xGetICRate( const uint32_t uiAbsLevel,
const
BinFracBits
&
fracBitsPar
,
const
BinFracBits
&
fracBitsGt1
,
const
BinFracBits
&
fracBitsGt2
,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const
int
remGt2Bins
,
#endif
const
int
remRegBins
,
unsigned
goRiceZero
,
const
uint16_t
ui16AbsGoRice
,
...
...
@@ -639,9 +647,14 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
double
d64BaseCost
=
0
;
int
iLastScanPos
=
-
1
;
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int
ctxBinSampleRatio
=
(
compID
==
COMPONENT_Y
)
?
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA
:
MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA
;
int
remRegBins
=
(
uiWidth
*
uiHeight
*
ctxBinSampleRatio
)
>>
4
;
#else
bool
is2x2subblock
=
(
iCGSizeM1
==
3
);
int
remGt2Bins
=
(
is2x2subblock
?
MAX_NUM_GT2_BINS_2x2SUBBLOCK
:
MAX_NUM_GT2_BINS_4x4SUBBLOCK
);
int
remRegBins
=
(
is2x2subblock
?
MAX_NUM_REG_BINS_2x2SUBBLOCK
:
MAX_NUM_REG_BINS_4x4SUBBLOCK
);
#endif
uint32_t
goRiceParam
=
0
;
double
*
pdCostCoeffGroupSig
=
m_pdCostCoeffGroupSig
;
...
...
@@ -736,16 +749,26 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
if
(
iScanPos
==
iLastScanPos
)
{
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
uiLevel
=
xGetCodedLevel
(
pdCostCoeff
[
iScanPos
],
pdCostCoeff0
[
iScanPos
],
pdCostSig
[
iScanPos
],
lLevelDouble
,
uiMaxAbsLevel
,
nullptr
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
goRiceParam
,
iQBits
,
errorScale
,
1
,
extendedPrecision
,
maxLog2TrDynamicRange
);
#else
uiLevel
=
xGetCodedLevel
(
pdCostCoeff
[
iScanPos
],
pdCostCoeff0
[
iScanPos
],
pdCostSig
[
iScanPos
],
lLevelDouble
,
uiMaxAbsLevel
,
nullptr
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
goRiceParam
,
iQBits
,
errorScale
,
1
,
extendedPrecision
,
maxLog2TrDynamicRange
);
#endif
}
else
{
DTRACE_COND
(
(
uiMaxAbsLevel
!=
0
),
g_trace_ctx
,
D_RDOQ_MORE
,
" uiCtxSig=%d"
,
ctxIdSig
);
const
BinFracBits
fracBitsSig
=
fracBits
.
getFracBitsArray
(
ctxIdSig
);
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
uiLevel
=
xGetCodedLevel
(
pdCostCoeff
[
iScanPos
],
pdCostCoeff0
[
iScanPos
],
pdCostSig
[
iScanPos
],
lLevelDouble
,
uiMaxAbsLevel
,
&
fracBitsSig
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
goRiceParam
,
iQBits
,
errorScale
,
0
,
extendedPrecision
,
maxLog2TrDynamicRange
);
#else
uiLevel
=
xGetCodedLevel
(
pdCostCoeff
[
iScanPos
],
pdCostCoeff0
[
iScanPos
],
pdCostSig
[
iScanPos
],
lLevelDouble
,
uiMaxAbsLevel
,
&
fracBitsSig
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
goRiceParam
,
iQBits
,
errorScale
,
0
,
extendedPrecision
,
maxLog2TrDynamicRange
);
#endif
sigRateDelta
[
uiBlkPos
]
=
(
remRegBins
<
4
?
0
:
fracBitsSig
.
intBits
[
1
]
-
fracBitsSig
.
intBits
[
0
]
);
}
...
...
@@ -757,16 +780,27 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
if
(
uiLevel
>
0
)
{
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int
rateNow
=
xGetICRate
(
uiLevel
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
);
rateIncUp
[
uiBlkPos
]
=
xGetICRate
(
uiLevel
+
1
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
)
-
rateNow
;
rateIncDown
[
uiBlkPos
]
=
xGetICRate
(
uiLevel
-
1
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
)
-
rateNow
;
#else
int
rateNow
=
xGetICRate
(
uiLevel
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
);
rateIncUp
[
uiBlkPos
]
=
xGetICRate
(
uiLevel
+
1
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
)
-
rateNow
;
rateIncDown
[
uiBlkPos
]
=
xGetICRate
(
uiLevel
-
1
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
)
-
rateNow
;
#endif
}
else
// uiLevel == 0
{
if
(
remRegBins
<
4
)
{
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int
rateNow
=
xGetICRate
(
uiLevel
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
);
rateIncUp
[
uiBlkPos
]
=
xGetICRate
(
uiLevel
+
1
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
)
-
rateNow
;
#else
int
rateNow
=
xGetICRate
(
uiLevel
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
);
rateIncUp
[
uiBlkPos
]
=
xGetICRate
(
uiLevel
+
1
,
fracBitsPar
,
fracBitsGt1
,
fracBitsGt2
,
remGt2Bins
,
remRegBins
,
goRiceZero
,
goRiceParam
,
extendedPrecision
,
maxLog2TrDynamicRange
)
-
rateNow
;
#endif
}
else
{
...
...
@@ -778,8 +812,10 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
if
(
(
(
iScanPos
&
iCGSizeM1
)
==
0
)
&&
(
iScanPos
>
0
)
)
{
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
remGt2Bins
=
(
is2x2subblock
?
MAX_NUM_GT2_BINS_2x2SUBBLOCK
:
MAX_NUM_GT2_BINS_4x4SUBBLOCK
);
remRegBins
=
(
is2x2subblock
?
MAX_NUM_REG_BINS_2x2SUBBLOCK
:
MAX_NUM_REG_BINS_4x4SUBBLOCK
)
-
remGt2Bins
;
#endif
goRiceParam
=
0
;
}
else
if
(
remRegBins
>=
4
)
...
...
source/Lib/CommonLib/QuantRDOQ.h
View file @
f83271a0
...
...
@@ -87,7 +87,9 @@ private:
const
BinFracBits
&
fracBitsPar
,
const
BinFracBits
&
fracBitsGt1
,
const
BinFracBits
&
fracBitsGt2
,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const
int
remGt2Bins
,
#endif
const
int
remRegBins
,
unsigned
goRiceZero
,
uint16_t
ui16AbsGoRice
,
...
...
@@ -100,7 +102,9 @@ private:
const
BinFracBits
&
fracBitsPar
,
const
BinFracBits
&
fracBitsGt1
,
const
BinFracBits
&
fracBitsGt2
,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const
int
remGt2Bins
,
#endif
const
int
remRegBins
,
unsigned
goRiceZero
,
const
uint16_t
ui16AbsGoRice
,
...
...
source/Lib/CommonLib/TypeDef.h
View file @
f83271a0
...
...
@@ -50,11 +50,15 @@
#include <assert.h>
#include <cassert>
#define JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT 1 // JVET-O0052 Method-1: TU-level context coded bin constraint