[x265] [PATCH] complexAnalysis: clean up
bhavna at multicorewareinc.com
bhavna at multicorewareinc.com
Mon Jan 30 06:20:26 CET 2017
# HG changeset patch
# User Bhavna Hariharan <bhavna at multicorewareinc.com>
# Date 1485752700 -19800
# Mon Jan 30 10:35:00 2017 +0530
# Node ID ef7fb79103aa20a6888863eadb7a27d62b3710da
# Parent 2f075fe8d4c519b5801d07592b6773e65f0c7456
complexAnalysis: clean up
diff -r 2f075fe8d4c5 -r ef7fb79103aa doc/reST/cli.rst
--- a/doc/reST/cli.rst Wed Jan 25 15:03:17 2017 +0530
+++ b/doc/reST/cli.rst Mon Jan 30 10:35:00 2017 +0530
@@ -947,10 +947,11 @@
.. option:: --complex-analysis <0..4>
- Increases the RD-level at points where the bitrate drops due to vbv.
- The number of CUs for which the RD is reconfigured is determined based
- on the strength. Strength 1 gives the best FPS, strength 4 gives the
- best SSIM. Strength 0 switches this feature off. Default: 0.
+ Increases the RD level at points where quality drops due to VBV rate
+ control enforcement. The number of CUs for which the RD is reconfigured
+ is determined based on the strength. Strength 1 gives the best FPS,
+ strength 4 gives the best SSIM. Strength 0 switches this feature off.
+ Default: 0.
Effective for RD levels 4 and below.
diff -r 2f075fe8d4c5 -r ef7fb79103aa source/common/param.cpp
--- a/source/common/param.cpp Wed Jan 25 15:03:17 2017 +0530
+++ b/source/common/param.cpp Mon Jan 30 10:35:00 2017 +0530
@@ -1169,7 +1169,7 @@
"RD Level is out of range");
CHECK(param->rdoqLevel < 0 || param->rdoqLevel > 2,
"RDOQ Level is out of range");
- CHECK(param->complexAnalysis < 0 || param->complexAnalysis > 4,
+ CHECK(param->complexAnalysis < 0 || param->complexAnalysis > X265_MAX_ANALYSIS_STRENGTH,
"Complex analysis strength must be between 0 and 4");
CHECK(param->bframes && param->bframes >= param->lookaheadDepth && !param->rc.bStatRead,
"Lookahead depth must be greater than the max consecutive bframe count");
diff -r 2f075fe8d4c5 -r ef7fb79103aa source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp Wed Jan 25 15:03:17 2017 +0530
+++ b/source/encoder/analysis.cpp Mon Jan 30 10:35:00 2017 +0530
@@ -139,7 +139,7 @@
invalidateContexts(0);
#endif
- int qp = setLambdaFromQP(ctu, m_slice->m_pps->bUseDQP ? calculateQpforCuSize(ctu, cuGeom, 0) : m_slice->m_sliceQp);
+ int qp = setLambdaFromQP(ctu, m_slice->m_pps->bUseDQP ? calculateQpforCuSize(ctu, cuGeom) : m_slice->m_sliceQp);
ctu.setQPSubParts((int8_t)qp, 0, 0);
m_rqt[0].cur.load(initialContext);
@@ -439,7 +439,7 @@
m_rqt[nextDepth].cur.load(*nextContext);
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom, 0));
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom));
compressIntraCU(parentCTU, childGeom, nextQP);
@@ -742,7 +742,7 @@
m_rqt[nextDepth].cur.load(*nextContext);
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom, 0));
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom));
splitRefs[subPartIdx] = compressInterCU_dist(parentCTU, childGeom, nextQP);
@@ -969,7 +969,7 @@
SplitData Analysis::compressInterCU_rd0_4(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)
{
- if (m_param->complexAnalysis && parentCTU.m_vbvAffected && calculateQpforCuSize(parentCTU, cuGeom, 1))
+ if (parentCTU.m_vbvAffected && calculateQpforCuSize(parentCTU, cuGeom, 1))
return compressInterCU_rd5_6(parentCTU, cuGeom, qp);
uint32_t depth = cuGeom.depth;
@@ -1103,7 +1103,7 @@
m_rqt[nextDepth].cur.load(*nextContext);
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom, 0));
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom));
splitData[subPartIdx] = compressInterCU_rd0_4(parentCTU, childGeom, nextQP);
@@ -1540,7 +1540,7 @@
SplitData Analysis::compressInterCU_rd5_6(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)
{
- if (m_param->complexAnalysis && parentCTU.m_vbvAffected && !calculateQpforCuSize(parentCTU, cuGeom, 1))
+ if (parentCTU.m_vbvAffected && !calculateQpforCuSize(parentCTU, cuGeom, 1))
return compressInterCU_rd0_4(parentCTU, cuGeom, qp);
uint32_t depth = cuGeom.depth;
@@ -1668,7 +1668,7 @@
m_rqt[nextDepth].cur.load(*nextContext);
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom, 0));
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom));
splitData[subPartIdx] = compressInterCU_rd5_6(parentCTU, childGeom, nextQP);
@@ -2050,7 +2050,7 @@
m_rqt[nextDepth].cur.load(*nextContext);
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom, 0));
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(parentCTU, childGeom));
qprdRefine(parentCTU, childGeom, nextQP, lqp);
@@ -2922,15 +2922,16 @@
qp += qp_offset;
if (complexCheck)
{
- int32_t offset = ((int)(qp_offset * 100 + .5));
+ int32_t offset = (int32_t)(qp_offset * 100 + .5);
double threshold = (1 - ((X265_MAX_ANALYSIS_STRENGTH - m_param->complexAnalysis) * 0.5));
- int32_t max_threshold = ((int)(threshold * 100 + .5));
+ int32_t max_threshold = (int32_t)(threshold * 100 + .5);
if (offset < max_threshold)
return 1;
else
return 0;
}
}
+
return x265_clip3(m_param->rc.qpMin, m_param->rc.qpMax, (int)(qp + 0.5));
}
diff -r 2f075fe8d4c5 -r ef7fb79103aa source/encoder/analysis.h
--- a/source/encoder/analysis.h Wed Jan 25 15:03:17 2017 +0530
+++ b/source/encoder/analysis.h Mon Jan 30 10:35:00 2017 +0530
@@ -174,7 +174,7 @@
/* generate residual and recon pixels for an entire CTU recursively (RD0) */
void encodeResidue(const CUData& parentCTU, const CUGeom& cuGeom);
- int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, int32_t complexCheck, double baseQP = -1);
+ int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, int32_t complexCheck = 0, double baseQP = -1);
void calculateNormFactor(CUData& ctu, int qp);
void normFactor(const pixel* src, uint32_t blockSize, CUData& ctu, int qp, TextType ttype);
diff -r 2f075fe8d4c5 -r ef7fb79103aa source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Wed Jan 25 15:03:17 2017 +0530
+++ b/source/encoder/encoder.cpp Mon Jan 30 10:35:00 2017 +0530
@@ -2160,7 +2160,7 @@
if (m_param->complexAnalysis && (!bIsVbv || !p->rc.aqMode || p->rdLevel > 4))
{
p->complexAnalysis = 0;
- x265_log(p, X265_LOG_WARNING, "Complex-analysis disabled, requires RD > 4, VBV and aq-mode enabled\n");
+ x265_log(p, X265_LOG_WARNING, "Complex-analysis disabled, requires RD <= 4, VBV and aq-mode enabled\n");
}
if (p->uhdBluray)
diff -r 2f075fe8d4c5 -r ef7fb79103aa source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Wed Jan 25 15:03:17 2017 +0530
+++ b/source/encoder/ratecontrol.cpp Mon Jan 30 10:35:00 2017 +0530
@@ -228,11 +228,6 @@
x265_log(m_param, X265_LOG_WARNING, "VBV is incompatible with constant QP, ignored.\n");
m_param->rc.vbvBufferSize = 0;
m_param->rc.vbvMaxBitrate = 0;
- if (m_param->complexAnalysis)
- {
- x265_log(m_param, X265_LOG_WARNING, "Complex analysis requires VBV, complex analysis disabled.\n");
- m_param->complexAnalysis = 0;
- }
}
else if (m_param->rc.vbvMaxBitrate == 0)
{
diff -r 2f075fe8d4c5 -r ef7fb79103aa source/x265.h
--- a/source/x265.h Wed Jan 25 15:03:17 2017 +0530
+++ b/source/x265.h Mon Jan 30 10:35:00 2017 +0530
@@ -858,9 +858,6 @@
* RDOQ is at level 2. Default: 0 */
int rdoqLevel;
- /* Increase RD at points where bitrate drops due to vbv. Default 0 */
- double complexAnalysis;
-
/* Enable the implicit signaling of the sign bit of the last coefficient of
* each transform unit. This saves one bit per TU at the expense of figuring
* out which coefficient can be toggled with the least distortion.
@@ -1374,6 +1371,10 @@
* selection during analysis of CTUs, can achieve significant gain in terms of
* objective quality metrics SSIM and PSNR */
int bSsimRd;
+
+ /* Increase RD at points where bitrate drops due to vbv. Default 0 */
+ double complexAnalysis;
+
} x265_param;
/* x265_param_alloc:
diff -r 2f075fe8d4c5 -r ef7fb79103aa source/x265cli.h
--- a/source/x265cli.h Wed Jan 25 15:03:17 2017 +0530
+++ b/source/x265cli.h Mon Jan 30 10:35:00 2017 +0530
@@ -345,7 +345,7 @@
H0(" --[no-]psy-rd <0..5.0> Strength of psycho-visual rate distortion optimization, 0 to disable. Default %.1f\n", param->psyRd);
H0(" --[no-]rdoq-level <0|1|2> Level of RDO in quantization 0:none, 1:levels, 2:levels & coding groups. Default %d\n", param->rdoqLevel);
H0(" --[no-]psy-rdoq <0..50.0> Strength of psycho-visual optimization in RDO quantization, 0 to disable. Default %.1f\n", param->psyRdoq);
- H0(" --complex-analysis <0..4.0> Strength of complex analysis, 0 to disable. Default %.1f\n", param->complexAnalysis);
+ H0(" --complex-analysis <0..4.0> Strength of complex analysis, 0 to disable. Default %.2f\n", param->complexAnalysis);
H0(" --[no-]ssim-rd Enable ssim rate distortion optimization, 0 to disable. Default %s\n", OPT(param->bSsimRd));
H0(" --[no-]rd-refine Enable QP based RD refinement for rd levels 5 and 6. Default %s\n", OPT(param->bEnableRdRefine));
H0(" --[no-]early-skip Enable early SKIP detection. Default %s\n", OPT(param->bEnableEarlySkip));
More information about the x265-devel
mailing list