<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 25, 2017 at 6:55 PM, <span dir="ltr"><<a href="mailto:bhavna@multicorewareinc.com" target="_blank">bhavna@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Bhavna Hariharan <<a href="mailto:bhavna@multicorewareinc.com">bhavna@multicorewareinc.com</a>><br>
# Date 1485246147 -19800<br>
# Tue Jan 24 13:52:27 2017 +0530<br>
# Node ID 639c197a700ab80e43a67fb29d8e0f<wbr>6e5ad56e25<br>
# Parent bdf2856cc3a1eafb9092bc52a2c232<wbr>3b4fe92a95<br>
complexAnalysis: increase analysis for areas capped by VBV<br>
<br>
diff -r bdf2856cc3a1 -r 639c197a700a source/common/cudata.cpp<br>
--- a/source/common/cudata.cpp Tue Jan 24 13:46:02 2017 +0530<br>
+++ b/source/common/cudata.cpp Tue Jan 24 13:52:27 2017 +0530<br>
@@ -306,6 +306,8 @@<br>
for (int8_t i = 0; i < NUM_TU_DEPTH; i++)<br>
m_refTuDepth[i] = -1;<br>
<br>
+ m_vbvAffected = false;<br>
+<br>
uint32_t widthInCU = m_slice->m_sps->numCuInWidth;<br>
m_cuLeft = (m_cuAddr % widthInCU) ? m_encData->getPicCTU(m_cuAddr - 1) : NULL;<br>
m_cuAbove = (m_cuAddr >= widthInCU) && !m_bFirstRowInSlice ? m_encData->getPicCTU(m_cuAddr - widthInCU) : NULL;<br>
diff -r bdf2856cc3a1 -r 639c197a700a source/common/cudata.h<br>
--- a/source/common/cudata.h Tue Jan 24 13:46:02 2017 +0530<br>
+++ b/source/common/cudata.h Tue Jan 24 13:52:27 2017 +0530<br>
@@ -164,6 +164,8 @@<br>
static cubcast_t s_partSet[NUM_FULL_DEPTH]; // pointer to broadcast set functions per absolute depth<br>
static uint32_t s_numPartInCUSize;<br>
<br>
+ bool m_vbvAffected;<br>
+<br>
FrameData* m_encData;<br>
const Slice* m_slice;<br>
<br>
diff -r bdf2856cc3a1 -r 639c197a700a source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp Tue Jan 24 13:46:02 2017 +0530<br>
+++ b/source/encoder/analysis.cpp Tue Jan 24 13:52:27 2017 +0530<br>
@@ -139,7 +139,7 @@<br>
invalidateContexts(0);<br>
#endif<br>
<br>
- int qp = setLambdaFromQP(ctu, m_slice->m_pps->bUseDQP ? calculateQpforCuSize(ctu, cuGeom) : m_slice->m_sliceQp);<br>
+ int qp = setLambdaFromQP(ctu, m_slice->m_pps->bUseDQP ? calculateQpforCuSize(ctu, cuGeom, 0) : m_slice->m_sliceQp);<br>
ctu.setQPSubParts((int8_t)qp, 0, 0);<br>
<br>
m_rqt[0].cur.load(<wbr>initialContext);<br>
@@ -439,7 +439,7 @@<br>
m_rqt[nextDepth].cur.load(*<wbr>nextContext);<br>
<br>
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)<br>
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom));<br>
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom, 0));<br>
<br>
compressIntraCU(parentCTU, childGeom, nextQP);<br>
<br>
@@ -742,7 +742,7 @@<br>
m_rqt[nextDepth].cur.load(*<wbr>nextContext);<br>
<br>
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)<br>
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom));<br>
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom, 0));<br>
<br>
splitRefs[subPartIdx] = compressInterCU_dist(<wbr>parentCTU, childGeom, nextQP);<br>
<br>
@@ -969,6 +969,9 @@<br>
<br>
SplitData Analysis::compressInterCU_rd0_<wbr>4(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)<br>
{<br>
+ if (m_param->complexAnalysis && parentCTU.m_vbvAffected && calculateQpforCuSize(<wbr>parentCTU, cuGeom, 1))<br>
+ return compressInterCU_rd5_6(<wbr>parentCTU, cuGeom, qp);<br>
+<br>
uint32_t depth = cuGeom.depth;<br>
uint32_t cuAddr = parentCTU.m_cuAddr;<br>
ModeDepth& md = m_modeDepth[depth];<br>
@@ -1100,7 +1103,7 @@<br>
m_rqt[nextDepth].cur.load(*<wbr>nextContext);<br>
<br>
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)<br>
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom));<br>
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom, 0));<br>
<br>
splitData[subPartIdx] = compressInterCU_rd0_4(<wbr>parentCTU, childGeom, nextQP);<br>
<br>
@@ -1537,6 +1540,9 @@<br>
<br>
SplitData Analysis::compressInterCU_rd5_<wbr>6(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)<br>
{<br>
+ if (m_param->complexAnalysis && parentCTU.m_vbvAffected && !calculateQpforCuSize(<wbr>parentCTU, cuGeom, 1))<br>
+ return compressInterCU_rd0_4(<wbr>parentCTU, cuGeom, qp);<br>
+<br>
uint32_t depth = cuGeom.depth;<br>
ModeDepth& md = m_modeDepth[depth];<br>
md.bestMode = NULL;<br>
@@ -1662,7 +1668,7 @@<br>
m_rqt[nextDepth].cur.load(*<wbr>nextContext);<br>
<br>
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)<br>
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom));<br>
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom, 0));<br>
<br>
splitData[subPartIdx] = compressInterCU_rd5_6(<wbr>parentCTU, childGeom, nextQP);<br>
<br>
@@ -2044,7 +2050,7 @@<br>
m_rqt[nextDepth].cur.load(*<wbr>nextContext);<br>
<br>
if (m_slice->m_pps->bUseDQP && nextDepth <= m_slice->m_pps->maxCuDQPDepth)<br>
- nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom));<br>
+ nextQP = setLambdaFromQP(parentCTU, calculateQpforCuSize(<wbr>parentCTU, childGeom, 0));<br>
<br>
qprdRefine(parentCTU, childGeom, nextQP, lqp);<br>
<br>
@@ -2874,7 +2880,7 @@<br>
return false;<br>
}<br>
<br>
-int Analysis::<wbr>calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, double baseQp)<br>
+int Analysis::<wbr>calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, int32_t complexCheck, double baseQp)<br>
{<br>
FrameData& curEncData = *m_frame->m_encData;<br>
double qp = baseQp >= 0 ? baseQp : curEncData.m_cuStat[ctu.m_<wbr>cuAddr].baseQp;<br>
@@ -2885,7 +2891,11 @@<br>
loopIncr = 16;<br>
/* Use cuTree offsets if cuTree enabled and frame is referenced, else use AQ offsets */<br>
bool isReferenced = IS_REFERENCED(m_frame);<br>
- double *qpoffs = (isReferenced && m_param->rc.cuTree) ? m_frame->m_lowres.<wbr>qpCuTreeOffset : m_frame->m_lowres.qpAqOffset;<br>
+ double *qpoffs;<br>
+ if (complexCheck)<br>
+ qpoffs = m_frame->m_lowres.qpAqOffset;<br>
+ else<br>
+ qpoffs = (isReferenced && m_param->rc.cuTree) ? m_frame->m_lowres.<wbr>qpCuTreeOffset : m_frame->m_lowres.qpAqOffset;<br>
if (qpoffs)<br>
{<br>
uint32_t width = m_frame->m_fencPic->m_<wbr>picWidth;<br>
@@ -2910,8 +2920,17 @@<br>
<br>
qp_offset /= cnt;<br>
qp += qp_offset;<br>
+ if (complexCheck)<br>
+ {<br>
+ int32_t offset = ((int)(qp_offset * 100 + .5));<br>
+ double threshold = (1 - ((X265_MAX_ANALYSIS_STRENGTH - m_param->complexAnalysis) * 0.5));<br>
+ int32_t max_threshold = ((int)(threshold * 100 + .5));<br>
+ if (offset < max_threshold)<br>
+ return 1;<br>
+ else<br>
+ return 0;<br>
+ }<br>
}<br>
-<br>
return x265_clip3(m_param->rc.qpMin, m_param->rc.qpMax, (int)(qp + 0.5));<br>
}<br>
<br>
diff -r bdf2856cc3a1 -r 639c197a700a source/encoder/analysis.h<br>
--- a/source/encoder/analysis.h Tue Jan 24 13:46:02 2017 +0530<br>
+++ b/source/encoder/analysis.h Tue Jan 24 13:52:27 2017 +0530<br>
@@ -174,7 +174,7 @@<br>
/* generate residual and recon pixels for an entire CTU recursively (RD0) */<br>
void encodeResidue(const CUData& parentCTU, const CUGeom& cuGeom);<br>
<br>
- int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, double baseQP = -1);<br>
+ int calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, int32_t complexCheck, double baseQP = -1);<br>
<br>
void calculateNormFactor(CUData& ctu, int qp);<br>
void normFactor(const pixel* src, uint32_t blockSize, CUData& ctu, int qp, TextType ttype);<br>
diff -r bdf2856cc3a1 -r 639c197a700a source/encoder/frameencoder.<wbr>cpp<br>
--- a/source/encoder/frameencoder.<wbr>cpp Tue Jan 24 13:46:02 2017 +0530<br>
+++ b/source/encoder/frameencoder.<wbr>cpp Tue Jan 24 13:52:27 2017 +0530<br>
@@ -1316,6 +1316,9 @@<br>
&& analysisFrameData-><wbr>highDistortionCtuCount && analysisFrameData-><wbr>lowDistortionCtuCount)<br>
curEncData.m_cuStat[cuAddr].<wbr>baseQp += analysisFrameData->offset[<wbr>cuAddr];<br>
<br>
+ if (m_param->complexAnalysis && (int32_t)(m_rce.qpaRc - m_rce.qpNoVbv) > 0)<br>
+ ctu->m_vbvAffected = true;<br>
+<br>
// Does all the CU analysis, returns best top level mode decision<br>
Mode& best = tld.analysis.compressCTU(*ctu, *m_frame, m_cuGeoms[m_ctuGeomMap[cuAddr]<wbr>], rowCoder);<br>
<br>
diff -r bdf2856cc3a1 -r 639c197a700a source/x265.h<br>
--- a/source/x265.h Tue Jan 24 13:46:02 2017 +0530<br>
+++ b/source/x265.h Tue Jan 24 13:52:27 2017 +0530<br>
@@ -390,6 +390,8 @@<br>
#define X265_AQ_AUTO_VARIANCE 2<br>
#define X265_AQ_AUTO_VARIANCE_BIASED 3<br>
<br>
+#define X265_MAX_ANALYSIS_STRENGTH 4<br>
+<br></blockquote><div><br></div><div>Your range check in param.cpp should use this macro instead of a hard-coded value now.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/* NOTE! For this release only X265_CSP_I420 and X265_CSP_I444 are supported */<br>
<br>
/* Supported internal color space types (according to semantics of chroma_format_idc) */<br>
______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>