[x265] [PATCH 2 of 2] rc: restrict low tolerance for bitrate fluctuations to strict-cbr option
Aarthi Priya Thirumalai
aarthi at multicorewareinc.com
Sun Jan 11 11:28:28 CET 2015
# HG changeset patch
# User Aarthi Thirumalai
# Date 1419064540 -19800
# Sat Dec 20 14:05:40 2014 +0530
# Node ID 1e7de45ddd54a1af7feab49d807c3fde7d34e1f8
# Parent d55fed4ebcd22823f8ffb878fa898b5d288cbb6a
rc: restrict low tolerance for bitrate fluctuations to strict-cbr option
diff -r d55fed4ebcd2 -r 1e7de45ddd54 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Tue Dec 23 16:32:30 2014 +0530
+++ b/source/encoder/ratecontrol.cpp Sat Dec 20 14:05:40 2014 +0530
@@ -1759,7 +1759,7 @@
for (int j = 0; bufferFillCur >= 0; j++)
{
int type = curFrame->m_lowres.plannedType[j];
- if (type == X265_TYPE_AUTO)
+ if (type == X265_TYPE_AUTO || totalDuration >= 1.0)
break;
totalDuration += m_frameDuration;
double wantedFrameSize = m_vbvMaxRate *
m_frameDuration;
@@ -1773,17 +1773,21 @@
bufferFillCur -= curBits;
}
- /* Try to get the buffer no more than 80% filled, but
don't set an impossible goal. */
- double tol = isIFramePresent ? 1 / totalDuration :
totalDuration < 0.5 ? 2 : 1;
- targetFill = X265_MIN(m_bufferFill + totalDuration *
m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.8 * totalDuration * tol));
+ /* Try to get the buffer at least 50% filled, but don't
set an impossible goal. */
+ double finalDur = 1;
+ if (m_param->rc.bStrictCbr)
+ {
+ finalDur = x265_clip3(0.4, 1.0, totalDuration);
+ }
+ targetFill = X265_MIN(m_bufferFill + totalDuration *
m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.5 * finalDur));
if (bufferFillCur < targetFill)
{
q *= 1.01;
loopTerminate |= 1;
continue;
}
- /* Try to get the buffer atleast 50% filled, but don't set
an impossible goal. */
- targetFill = x265_clip3(m_bufferSize - (m_bufferSize *
totalDuration * 0.5), m_bufferSize, m_bufferFill - totalDuration *
m_vbvMaxRate * 0.5);
+ /* Try to get the buffer not more than 80% filled, but
don't set an impossible goal. */
+ targetFill = x265_clip3(m_bufferSize * (1 - 0.2 *
finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);
if (m_isCbr && bufferFillCur > targetFill)
{
q /= 1.01;
@@ -1976,7 +1980,7 @@
if (row < sps.numCuInHeight - 1)
{
/* More threads means we have to be more cautious in letting
ratecontrol use up extra bits. */
- double rcTol = (bufferLeftPlanned * 0.2) /
m_param->frameNumThreads * m_param->rc.rateTolerance;
+ double rcTol = bufferLeftPlanned / m_param->frameNumThreads *
m_param->rc.rateTolerance;
int32_t encodedBitsSoFar = 0;
double accFrameBits = predictRowsSizeSum(curFrame, rce, qpVbv,
encodedBitsSoFar);
@@ -1994,7 +1998,7 @@
while (qpVbv < qpMax
&& ((accFrameBits > rce->frameSizePlanned + rcTol) ||
- (rce->bufferFill - accFrameBits < bufferLeftPlanned *
0.2) ||
+ (rce->bufferFill - accFrameBits < bufferLeftPlanned *
0.5) ||
(accFrameBits > rce->frameSizePlanned && qpVbv <
rce->qpNoVbv)))
{
qpVbv += stepSize;
On Sun, Jan 11, 2015 at 3:57 PM, Aarthi Priya Thirumalai <
aarthi at multicorewareinc.com> wrote:
> no, there were a few conflicts because my local tip wasn't updated.
> Sending again..
>
> On Thu, Jan 8, 2015 at 8:02 PM, Steve Borho <steve at borho.org> wrote:
>
>> On 01/07, aarthi at multicorewareinc.com wrote:
>> > # HG changeset patch
>> > # User Aarthi Thirumalai
>> > # Date 1419064540 -19800
>> > # Sat Dec 20 14:05:40 2014 +0530
>> > # Node ID 5d658640bcf115f2add4da1619eeaec50177973f
>> > # Parent 9b30c4b16dfc4c673b57ee4c567fa8956a41e2fc
>> > rc: restrict low tolerance for bitrate fluctuations to strict-cbr option
>>
>> this patch isn't applying; perhaps it depends on the RCstart/stop patch
>>
>> > diff -r 9b30c4b16dfc -r 5d658640bcf1 source/encoder/ratecontrol.cpp
>> > --- a/source/encoder/ratecontrol.cpp Tue Dec 23 16:32:30 2014 +0530
>> > +++ b/source/encoder/ratecontrol.cpp Sat Dec 20 14:05:40 2014 +0530
>> > @@ -1759,7 +1759,7 @@
>> > for (int j = 0; bufferFillCur >= 0; j++)
>> > {
>> > int type = curFrame->m_lowres.plannedType[j];
>> > - if (type == X265_TYPE_AUTO)
>> > + if (type == X265_TYPE_AUTO || totalDuration >= 1.0)
>> > break;
>> > totalDuration += m_frameDuration;
>> > double wantedFrameSize = m_vbvMaxRate *
>> m_frameDuration;
>> > @@ -1773,17 +1773,21 @@
>> > bufferFillCur -= curBits;
>> > }
>> >
>> > - /* Try to get the buffer no more than 80% filled, but
>> don't set an impossible goal. */
>> > - double tol = isIFramePresent ? 1 / totalDuration :
>> totalDuration < 0.5 ? 2 : 1;
>> > - targetFill = X265_MIN(m_bufferFill + totalDuration *
>> m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.8 * totalDuration * tol));
>> > + /* Try to get the buffer at least 50% filled, but
>> don't set an impossible goal. */
>> > + double finalDur = 1;
>> > + if (m_param->rc.bStrictCbr)
>> > + {
>> > + finalDur = Clip3(0.4, 1.0, totalDuration);
>> > + }
>> > + targetFill = X265_MIN(m_bufferFill + totalDuration *
>> m_vbvMaxRate * 0.5 , m_bufferSize * (1 - 0.5 * finalDur));
>> > if (bufferFillCur < targetFill)
>> > {
>> > q *= 1.01;
>> > loopTerminate |= 1;
>> > continue;
>> > }
>> > - /* Try to get the buffer atleast 50% filled, but don't
>> set an impossible goal. */
>> > - targetFill = Clip3(m_bufferSize - (m_bufferSize *
>> totalDuration * 0.5), m_bufferSize, m_bufferFill - totalDuration *
>> m_vbvMaxRate * 0.5);
>> > + /* Try to get the buffer not more than 80% filled, but
>> don't set an impossible goal. */
>> > + targetFill = Clip3(m_bufferSize * (1 - 0.2 * finalDur)
>> , m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);
>> > if (m_isCbr && bufferFillCur > targetFill)
>> > {
>> > q /= 1.01;
>> > @@ -1976,7 +1980,7 @@
>> > if (row < sps.numCuInHeight - 1)
>> > {
>> > /* More threads means we have to be more cautious in letting
>> ratecontrol use up extra bits. */
>> > - double rcTol = (bufferLeftPlanned * 0.2) /
>> m_param->frameNumThreads * m_param->rc.rateTolerance;
>> > + double rcTol = bufferLeftPlanned / m_param->frameNumThreads *
>> m_param->rc.rateTolerance;
>> > int32_t encodedBitsSoFar = 0;
>> > double accFrameBits = predictRowsSizeSum(curFrame, rce, qpVbv,
>> encodedBitsSoFar);
>> >
>> > @@ -1994,7 +1998,7 @@
>> >
>> > while (qpVbv < qpMax
>> > && ((accFrameBits > rce->frameSizePlanned + rcTol) ||
>> > - (rce->bufferFill - accFrameBits < bufferLeftPlanned
>> * 0.2) ||
>> > + (rce->bufferFill - accFrameBits < bufferLeftPlanned
>> * 0.5) ||
>> > (accFrameBits > rce->frameSizePlanned && qpVbv <
>> rce->qpNoVbv)))
>> > {
>> > qpVbv += stepSize;
>> > _______________________________________________
>> > x265-devel mailing list
>> > x265-devel at videolan.org
>> > https://mailman.videolan.org/listinfo/x265-devel
>>
>> --
>> Steve Borho
>> _______________________________________________
>> x265-devel mailing list
>> x265-devel at videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20150111/df325929/attachment-0001.html>
More information about the x265-devel
mailing list