From e9300d39033a26ef7b2e09ffed497c8761550b0d Mon Sep 17 00:00:00 2001
From: Jane Zhao <jie.zhao@lge.com>
Date: Fri, 22 Feb 2019 10:54:04 -0800
Subject: [PATCH] Reshaper High bitdepth bug fix
---
source/App/EncoderApp/EncAppCfg.cpp | 6 ++++++
source/Lib/CommonLib/Reshape.cpp | 7 +++++--
source/Lib/CommonLib/TypeDef.h | 2 ++
source/Lib/EncoderLib/EncReshape.cpp | 12 ++++++++++++
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index eb18b7e..75d476c 100644
a
|
b
|
bool EncAppCfg::parseCfg( int argc, char* argv[] ) |
1570 | 1570 | { |
1571 | 1571 | m_chromaFormatConstraint = (tmpConstraintChromaFormat == 0) ? m_chromaFormatIDC : numberToChromaFormat(tmpConstraintChromaFormat); |
1572 | 1572 | m_bitDepthConstraint = ( ( m_profile == Profile::MAIN10 || m_profile == Profile::NEXT ) ? 10 : 8 ); |
| 1573 | #if LGE_TEST_HIGH_BITDEPTH |
| 1574 | if (m_profile == Profile::NEXT) { m_bitDepthConstraint = 16; } |
| 1575 | #endif |
1573 | 1576 | } |
1574 | 1577 | |
1575 | 1578 | |
… |
… |
bool EncAppCfg::xCheckParameter() |
2094 | 2097 | } |
2095 | 2098 | else |
2096 | 2099 | { |
| 2100 | #if !LGE_TEST_HIGH_BITDEPTH |
2097 | 2101 | xConfirmPara(m_bitDepthConstraint!=((m_profile==Profile::MAIN10 || m_profile==Profile::NEXT)?10:8), "BitDepthConstraint must be 8 for MAIN profile and 10 for MAIN10 profile."); |
| 2102 | #endif |
| 2103 | |
2098 | 2104 | xConfirmPara(m_chromaFormatConstraint!=CHROMA_420 && m_profile!=Profile::NEXT, "ChromaFormatConstraint must be 420 for non main-RExt and non-Next profiles."); |
2099 | 2105 | xConfirmPara(m_intraConstraintFlag==true, "IntraConstraintFlag must be false for non main_RExt profiles."); |
2100 | 2106 | xConfirmPara(m_lowerBitRateConstraintFlag==false, "LowerBitrateConstraintFlag must be true for non main-RExt profiles."); |
diff --git a/source/Lib/CommonLib/Reshape.cpp b/source/Lib/CommonLib/Reshape.cpp
index 31ecca8..b88aefb 100644
a
|
b
|
void Reshape::constructReshaper() |
198 | 198 | int16_t Y2 = m_reshapePivot[i + 1]; |
199 | 199 | |
200 | 200 | m_fwdLUT[i*pwlFwdBinLen] = Clip3((Pel)0, (Pel)((1 << m_lumaBD) - 1), (Pel)Y1); |
201 | | |
| 201 | #if LGE_BUG_FIX |
| 202 | int log2PwlFwdBinLen = (pwlFwdBinLen>=MAX_CU_SIZE)? g_aucLog2[pwlFwdBinLen>> MAX_CU_DEPTH] + MAX_CU_DEPTH : g_aucLog2[pwlFwdBinLen]; |
| 203 | #else |
202 | 204 | int log2PwlFwdBinLen = g_aucLog2[pwlFwdBinLen]; |
203 | | |
| 205 | #endif |
| 206 | |
204 | 207 | int32_t scale = ((int32_t)(Y2 - Y1) * (1 << FP_PREC) + (1 << (log2PwlFwdBinLen - 1))) >> (log2PwlFwdBinLen); |
205 | 208 | for (int j = 1; j < pwlFwdBinLen; j++) |
206 | 209 | { |
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index e4da03d..a70ef1f 100644
a
|
b
|
|
50 | 50 | #include <assert.h> |
51 | 51 | #include <cassert> |
52 | 52 | |
| 53 | #define LGE_TEST_HIGH_BITDEPTH 1 |
| 54 | #define LGE_BUG_FIX 1 |
53 | 55 | #define JVET_M0055_DEBUG_CTU 1 // DebugCTU encoder debug option |
54 | 56 | |
55 | 57 | #define JVET_M0297_32PT_MTS_ZERO_OUT 1 // 32 point MTS based on skipping high frequency coefficients |
diff --git a/source/Lib/EncoderLib/EncReshape.cpp b/source/Lib/EncoderLib/EncReshape.cpp
index ce7d76a..62c7ffb 100644
a
|
b
|
void EncReshape::initLUTfromdQPModel() |
1102 | 1102 | int16_t Y1 = m_reshapePivot[i]; |
1103 | 1103 | int16_t Y2 = m_reshapePivot[i + 1]; |
1104 | 1104 | m_fwdLUT[i*pwlFwdBinLen] = Clip3((Pel)0, (Pel)((1 << m_lumaBD) - 1), (Pel)Y1); |
| 1105 | #if LGE_BUG_FIX |
| 1106 | int log2PwlFwdBinLen = (pwlFwdBinLen >= MAX_CU_SIZE) ? g_aucLog2[pwlFwdBinLen >> MAX_CU_DEPTH] + MAX_CU_DEPTH : g_aucLog2[pwlFwdBinLen]; |
| 1107 | #else |
1105 | 1108 | int log2PwlFwdBinLen = g_aucLog2[pwlFwdBinLen]; |
| 1109 | #endif |
1106 | 1110 | int32_t scale = ((int32_t)(Y2 - Y1) * (1 << FP_PREC) + (1 << (log2PwlFwdBinLen - 1))) >> (log2PwlFwdBinLen); |
1107 | 1111 | for (int j = 1; j < pwlFwdBinLen; j++) |
1108 | 1112 | { |
… |
… |
void EncReshape::constructReshaperSDR() |
1142 | 1146 | int totCW = bdShift != 0 ? (bdShift > 0 ? m_reshapeLUTSize / (1<<bdShift) : m_reshapeLUTSize * (1 << (-bdShift))) : m_reshapeLUTSize; |
1143 | 1147 | int histBins = PIC_ANALYZE_CW_BINS; |
1144 | 1148 | int histLenth = totCW/histBins; |
| 1149 | #if LGE_BUG_FIX |
| 1150 | int log2HistLenth = (histLenth >= MAX_CU_SIZE) ? g_aucLog2[histLenth >> MAX_CU_DEPTH] + MAX_CU_DEPTH : g_aucLog2[histLenth]; |
| 1151 | #else |
1145 | 1152 | int log2HistLenth = g_aucLog2[histLenth]; |
| 1153 | #endif |
1146 | 1154 | int16_t *tempFwdLUT = new int16_t[m_reshapeLUTSize + 1](); |
1147 | 1155 | int i, j; |
1148 | 1156 | int cwScaleBins1, cwScaleBins2; |
… |
… |
void EncReshape::constructReshaperSDR() |
1271 | 1279 | m_sliceReshapeInfo.maxNbitsNeededDeltaCW = std::max(1, (int)g_aucLog2[maxAbsDeltaCW << 1]); |
1272 | 1280 | |
1273 | 1281 | histLenth = m_initCW; |
| 1282 | #if LGE_BUG_FIX |
| 1283 | log2HistLenth = (histLenth >= MAX_CU_SIZE) ? g_aucLog2[histLenth >> MAX_CU_DEPTH] + MAX_CU_DEPTH : g_aucLog2[histLenth]; |
| 1284 | #else |
1274 | 1285 | log2HistLenth = g_aucLog2[histLenth]; |
| 1286 | #endif |
1275 | 1287 | |
1276 | 1288 | int sumBins = 0; |
1277 | 1289 | for (i = 0; i < PIC_CODE_CW_BINS; i++) { sumBins += m_binCW[i]; } |