<div dir="ltr"># HG changeset patch<br># User Snehaa Giridharan <<a href="mailto:snehaa@multicorewareinc.com">snehaa@multicorewareinc.com</a>><br># Date 1584537699 -19800<br>#      Wed Mar 18 18:51:39 2020 +0530<br># Node ID 53c879b944a444c291727fa7e2888eedd855b660<br># Parent  1010e8e347a292c4e6651a7ae374fd5ef039724b<br>Add option to get global maxrate<br><br>This global maxrate can be used for HRD signaling<br><br>diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt<br>--- a/source/CMakeLists.txt<br>+++ b/source/CMakeLists.txt<br>@@ -29,7 +29,7 @@<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 190)<br>+set(X265_BUILD 191)<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in">x265.def.in</a>"<br>                "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in">x265_config.h.in</a>"<br>diff --git a/source/common/param.cpp b/source/common/param.cpp<br>--- a/source/common/param.cpp<br>+++ b/source/common/param.cpp<br>@@ -286,6 +286,7 @@<br>     param->rc.bEnableConstVbv = 0;<br>     param->bResetZoneConfig = 1;<br>     param->reconfigWindowSize = 0;<br>+    param->decoderVbvMaxRate = 0;<br> <br>     /* Video Usability Information (VUI) */<br>     param->vui.aspectRatioIdc = 0;<br>@@ -1799,6 +1800,7 @@<br>     }<br>     CHECK(param->confWinRightOffset < 0, "Conformance Window Right Offset must be 0 or greater");<br>     CHECK(param->confWinBottomOffset < 0, "Conformance Window Bottom Offset must be 0 or greater");<br>+    CHECK(param->decoderVbvMaxRate < 0, "Invalid Decoder Vbv Maxrate. Value can not be less than zero");<br>     return check_failed;<br> }<br> <br>@@ -2219,6 +2221,7 @@<br>     if (p->bEnableSceneCutAwareQp)<br>         s += sprintf(s, " scenecut-window=%d max-qp-delta=%d", p->scenecutWindow, p->maxQpDelta);<br>     s += sprintf(s, "conformance-window-offsets right=%d bottom=%d", p->confWinRightOffset, p->confWinBottomOffset);<br>+    s += sprintf(s, " decoder-max-rate=%d", p->decoderVbvMaxRate);<br> #undef BOOL<br>     return buf;<br> }<br>@@ -2435,6 +2438,7 @@<br>     dst->rc.zonefileCount = src->rc.zonefileCount;<br>     dst->reconfigWindowSize = src->reconfigWindowSize;<br>     dst->bResetZoneConfig = src->bResetZoneConfig;<br>+    dst->decoderVbvMaxRate = src->decoderVbvMaxRate;<br> <br>     if (src->rc.zonefileCount && src->rc.zones)<br>     {<br>diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp<br>--- a/source/encoder/ratecontrol.cpp<br>+++ b/source/encoder/ratecontrol.cpp<br>@@ -335,7 +335,7 @@<br>         int vbvBufferSize = m_param->rc.vbvBufferSize * 1000;<br>         int vbvMaxBitrate = m_param->rc.vbvMaxBitrate * 1000;<br> <br>-        if (m_param->bEmitHRDSEI)<br>+        if (m_param->bEmitHRDSEI && !m_param->decoderVbvMaxRate)<br>         {<br>             const HRDInfo* hrd = &sps.vuiParameters.hrdParameters;<br>             vbvBufferSize = hrd->cpbSizeValue << (hrd->cpbSizeScale + CPB_SHIFT);<br>@@ -781,8 +781,10 @@<br>     // Init HRD<br>     HRDInfo* hrd = &sps.vuiParameters.hrdParameters;<br>     hrd->cbrFlag = m_isCbr;<br>-    if (m_param->reconfigWindowSize)<br>+    if (m_param->reconfigWindowSize) {<br>         hrd->cbrFlag = 0;<br>+        vbvMaxBitrate = m_param->decoderVbvMaxRate * 1000;<br>+    }<br> <br>     // normalize HRD size and rate to the value / scale notation<br>     hrd->bitRateScale = x265_clip3(0, 15, calcScale(vbvMaxBitrate) - BR_SHIFT);<br>diff --git a/source/x265.h b/source/x265.h<br>--- a/source/x265.h<br>+++ b/source/x265.h<br>@@ -1905,6 +1905,9 @@<br> <br>     /* Edge variance threshold for quad tree establishment. */<br>     float    edgeVarThreshold;<br>+<br>+    /* Maxrate that could be signaled to the decoder. Default 0. API only. */<br>+    int      decoderVbvMaxRate;<br> } x265_param;<br> <br> /* x265_param_alloc:<br><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><i><font face="georgia, serif">Thanks and Regards,</font></i></div><div><i><b><font face="georgia, serif">Snehaa.G</font></b></i></div></div></div></div></div></div></div></div></div></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=5d1cffcc-cd7a-478a-8410-76188ea236f6" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">I’m protected online with Avast Free Antivirus. <a href="https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=5d1cffcc-cd7a-478a-8410-76188ea236f6" target="_blank" style="color:#4453ea">Get it here — it’s free forever.</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>