<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 2, 2013 at 5:54 PM, Gopu Govindaswamy <span dir="ltr"><<a href="mailto:gopu@multicorewareinc.com" target="_blank">gopu@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 Gopu Govindaswamy <<a href="mailto:gopu@multicorewareinc.com">gopu@multicorewareinc.com</a>><br>
# Date 1385986798 -19800<br>
# Node ID 8617e8ab6fafd5dea42e63f135f6df02761d5dd6<br>
# Parent a0f2c87c5f0a27a2f7e6e96af675efc419988d6e<br>
cuTree: integrated CuTree into RateControl and Added b-references into RC<br>
<br>
diff -r a0f2c87c5f0a -r 8617e8ab6faf source/common/common.cpp<br>
--- a/source/common/common.cpp Mon Dec 02 12:53:59 2013 +0530<br>
+++ b/source/common/common.cpp Mon Dec 02 17:49:58 2013 +0530<br>
@@ -398,6 +398,7 @@<br>
{<br>
//currently the default<br>
param->rc.aqMode = X265_AQ_NONE;<br>
+ param->rc.cuTree = 0;<br>
}<br>
else if (!strcmp(tune, "ssim"))<br>
{<br>
diff -r a0f2c87c5f0a -r 8617e8ab6faf source/encoder/ratecontrol.cpp<br>
--- a/source/encoder/ratecontrol.cpp Mon Dec 02 12:53:59 2013 +0530<br>
+++ b/source/encoder/ratecontrol.cpp Mon Dec 02 17:49:58 2013 +0530<br>
@@ -118,6 +118,7 @@<br>
if (cfg->param.rc.aqMode)<br>
{<br>
pic->m_lowres.qpAqOffset[block_xy] = qp_adj;<br>
+ pic->m_lowres.qpOffset[block_xy] = qp_adj;<br>
pic->m_lowres.invQscaleFactor[block_xy] = x265_exp2fix8(qp_adj);<br>
block_xy++;<br>
}<br>
@@ -141,6 +142,14 @@<br>
this->cfg = _cfg;<br>
ncu = (int)((cfg->param.sourceHeight * cfg->param.sourceWidth) / pow((int)16, 2.0));<br>
<br>
+ if (cfg->param.rc.cuTree)<br>
+ {<br>
+ qCompress = 1;<br>
+ cfg->param.rc.pbFactor = 1;<br>
+ }<br>
+ else<br>
+ qCompress = cfg->param.rc.qCompress;<br>
+<br>
// validate for cfg->param.rc, maybe it is need to add a function like x265_parameters_valiate()<br>
cfg->param.rc.rfConstant = Clip3((double)-QP_BD_OFFSET, (double)51, cfg->param.rc.rfConstant);<br>
if (cfg->param.rc.rateControlMode == X265_RC_CRF)<br>
@@ -149,8 +158,8 @@<br>
cfg->param.rc.bitrate = 0;<br>
<br>
double baseCplx = ncu * (cfg->param.bframes ? 120 : 80);<br>
- double mbtree_offset = 0; // added later<br>
- rateFactorConstant = pow(baseCplx, 1 - cfg->param.rc.qCompress) /<br>
+ double mbtree_offset = cfg->param.rc.cuTree ? (1.0 - cfg->param.rc.qCompress) * 13.5 : 0;<br>
+ rateFactorConstant = pow(baseCplx, 1 - qCompress) /<br>
qp2qScale(cfg->param.rc.rfConstant + mbtree_offset + QP_BD_OFFSET);<br>
}<br>
<br>
@@ -248,7 +257,7 @@<br>
accumPNorm = .01;<br>
accumPQp = (ABR_INIT_QP_MIN)*accumPNorm;<br>
/* estimated ratio that produces a reasonable QP for the first I-frame */<br>
- cplxrSum = .01 * pow(7.0e5, cfg->param.rc.qCompress) * pow(ncu, 0.5);<br>
+ cplxrSum = .01 * pow(7.0e5, qCompress) * pow(ncu, 0.5);<br>
wantedBitsWindow = bitrate * frameDuration;<br>
}<br>
else if (cfg->param.rc.rateControlMode == X265_RC_CRF)<br>
@@ -257,7 +266,7 @@<br>
accumPNorm = .01;<br>
accumPQp = ABR_INIT_QP * accumPNorm;<br>
/* estimated ratio that produces a reasonable QP for the first I-frame */<br>
- cplxrSum = .01 * pow(7.0e5, cfg->param.rc.qCompress) * pow(ncu, 0.5);<br>
+ cplxrSum = .01 * pow(7.0e5, qCompress) * pow(ncu, 0.5);<br>
wantedBitsWindow = bitrate * frameDuration;<br>
}<br>
<br>
@@ -351,9 +360,9 @@<br>
double q0 = prevRefSlice->getSliceQp();<br>
double q1 = nextRefSlice->getSliceQp();<br>
<br>
- if (prevRefSlice->getSliceType() == B_SLICE && prevRefSlice->isReferenced())<br>
+ if (prevRefSlice->getSliceType() == X265_TYPE_BREF && prevRefSlice->isReferenced())<br>
q0 -= pbOffset / 2;<br>
- if (nextRefSlice->getSliceType() == B_SLICE && nextRefSlice->isReferenced())<br>
+ if (nextRefSlice->getSliceType() == X265_TYPE_BREF && nextRefSlice->isReferenced())<br></blockquote><div><br></div><div>sliceType = X265_TYPE_BREF = > its already referenced, no need for the && condition check for isReferenced()</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
q1 -= pbOffset / 2;<br>
if (i0 && i1)<br>
q = (q0 + q1) / 2 + ipOffset;<br>
@@ -453,7 +462,7 @@<br>
q = Clip3(lqmin, lqmax, q);<br>
}<br>
}<br>
- else if (cfg->param.rc.rateControlMode == X265_RC_CRF && cfg->param.rc.qCompress != 1)<br>
+ else if (cfg->param.rc.rateControlMode == X265_RC_CRF && qCompress != 1)<br>
{<br>
q = qp2qScale(ABR_INIT_QP) / fabs(cfg->param.rc.ipFactor);<br>
}<br>
@@ -565,7 +574,15 @@<br>
{<br>
double q;<br>
<br>
- q = pow(rce->blurredComplexity, 1 - cfg->param.rc.qCompress);<br>
+ if (cfg->param.rc.cuTree)<br>
+ {<br>
+ double scale = curSlice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();<br>
+ double units = curSlice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick();<br>
+ double timescale = units / scale;<br>
+ q = pow(BASE_FRAME_DURATION / CLIP_DURATION(2 * timescale), 1 - cfg->param.rc.qCompress);<br>
+ }<br>
+ else<br>
+ q = pow(rce->blurredComplexity, 1 - cfg->param.rc.qCompress);<br>
<br>
// avoid NaN's in the rc_eq<br>
if (rce->texBits + rce->mvBits == 0)<br>
diff -r a0f2c87c5f0a -r 8617e8ab6faf source/encoder/ratecontrol.h<br>
--- a/source/encoder/ratecontrol.h Mon Dec 02 12:53:59 2013 +0530<br>
+++ b/source/encoder/ratecontrol.h Mon Dec 02 17:49:58 2013 +0530<br>
@@ -115,6 +115,7 @@<br>
int64_t totalBits; /* totalbits used for already encoded frames */<br>
double lastRceq;<br>
int framesDone; /* framesDone keeps track of # of frames passed through RateCotrol already */<br>
+ double qCompress;<br>
RateControl(TEncCfg * _cfg);<br>
<br>
// to be called for each frame to process RateControl and set QP<br>
diff -r a0f2c87c5f0a -r 8617e8ab6faf source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp Mon Dec 02 12:53:59 2013 +0530<br>
+++ b/source/encoder/slicetype.cpp Mon Dec 02 17:49:58 2013 +0530<br>
@@ -1366,7 +1366,7 @@<br>
}<br>
<br>
cuTreeFinish(Frames[lastnonb], averageDuration, lastnonb);<br>
- if (cfg->param.bBPyramid && bframes > 1 /* && !h->param.rc.i_vbv_buffer_size */)<br>
+ if (cfg->param.bBPyramid && bframes > 1 && !cfg->param.rc.vbvBufferSize)<br>
cuTreeFinish(Frames[lastnonb + (bframes + 1) / 2], averageDuration, 0);<br>
}<br>
<br>
@@ -1464,7 +1464,7 @@<br>
}<br>
}<br>
<br>
- if(/*h->param.rc.i_vbv_buffer_size &&*/ cfg->param.logLevel && referenced)<br>
+ if(cfg->param.rc.vbvBufferSize && cfg->param.logLevel && referenced)<br>
cuTreeFinish(Frames[b], averageDuration, b == p1 ? b - p0 : 0);<br>
<br>
}<br>
@@ -1481,7 +1481,8 @@<br>
* concepts are very similar. */<br>
<br>
int cuCount = widthInCU * heightInCU;<br>
- double strength = 5.0f * (1.0f - cfg->param.rc.qCompress);<br>
+ double strength = 5.0 * (1.0 - cfg->param.rc.qCompress);<br>
+<br>
for (int cuIndex = 0; cuIndex < cuCount; cuIndex++)<br>
{<br>
int intracost = (Frame->intraCost[cuIndex] * Frame->invQscaleFactor[cuIndex] + 128) >> 8;<br>
_______________________________________________<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>