[x265] [PATCH] Add option to get global maxrate

Snehaa Giridharan snehaa at multicorewareinc.com
Wed Mar 18 14:35:07 CET 2020


# HG changeset patch
# User Snehaa Giridharan <snehaa at multicorewareinc.com>
# Date 1584537699 -19800
#      Wed Mar 18 18:51:39 2020 +0530
# Node ID 53c879b944a444c291727fa7e2888eedd855b660
# Parent  1010e8e347a292c4e6651a7ae374fd5ef039724b
Add option to get global maxrate

This global maxrate can be used for HRD signaling

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -29,7 +29,7 @@
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 190)
+set(X265_BUILD 191)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff --git a/source/common/param.cpp b/source/common/param.cpp
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -286,6 +286,7 @@
     param->rc.bEnableConstVbv = 0;
     param->bResetZoneConfig = 1;
     param->reconfigWindowSize = 0;
+    param->decoderVbvMaxRate = 0;

     /* Video Usability Information (VUI) */
     param->vui.aspectRatioIdc = 0;
@@ -1799,6 +1800,7 @@
     }
     CHECK(param->confWinRightOffset < 0, "Conformance Window Right Offset
must be 0 or greater");
     CHECK(param->confWinBottomOffset < 0, "Conformance Window Bottom
Offset must be 0 or greater");
+    CHECK(param->decoderVbvMaxRate < 0, "Invalid Decoder Vbv Maxrate.
Value can not be less than zero");
     return check_failed;
 }

@@ -2219,6 +2221,7 @@
     if (p->bEnableSceneCutAwareQp)
         s += sprintf(s, " scenecut-window=%d max-qp-delta=%d",
p->scenecutWindow, p->maxQpDelta);
     s += sprintf(s, "conformance-window-offsets right=%d bottom=%d",
p->confWinRightOffset, p->confWinBottomOffset);
+    s += sprintf(s, " decoder-max-rate=%d", p->decoderVbvMaxRate);
 #undef BOOL
     return buf;
 }
@@ -2435,6 +2438,7 @@
     dst->rc.zonefileCount = src->rc.zonefileCount;
     dst->reconfigWindowSize = src->reconfigWindowSize;
     dst->bResetZoneConfig = src->bResetZoneConfig;
+    dst->decoderVbvMaxRate = src->decoderVbvMaxRate;

     if (src->rc.zonefileCount && src->rc.zones)
     {
diff --git a/source/encoder/ratecontrol.cpp b/source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp
+++ b/source/encoder/ratecontrol.cpp
@@ -335,7 +335,7 @@
         int vbvBufferSize = m_param->rc.vbvBufferSize * 1000;
         int vbvMaxBitrate = m_param->rc.vbvMaxBitrate * 1000;

-        if (m_param->bEmitHRDSEI)
+        if (m_param->bEmitHRDSEI && !m_param->decoderVbvMaxRate)
         {
             const HRDInfo* hrd = &sps.vuiParameters.hrdParameters;
             vbvBufferSize = hrd->cpbSizeValue << (hrd->cpbSizeScale +
CPB_SHIFT);
@@ -781,8 +781,10 @@
     // Init HRD
     HRDInfo* hrd = &sps.vuiParameters.hrdParameters;
     hrd->cbrFlag = m_isCbr;
-    if (m_param->reconfigWindowSize)
+    if (m_param->reconfigWindowSize) {
         hrd->cbrFlag = 0;
+        vbvMaxBitrate = m_param->decoderVbvMaxRate * 1000;
+    }

     // normalize HRD size and rate to the value / scale notation
     hrd->bitRateScale = x265_clip3(0, 15, calcScale(vbvMaxBitrate) -
BR_SHIFT);
diff --git a/source/x265.h b/source/x265.h
--- a/source/x265.h
+++ b/source/x265.h
@@ -1905,6 +1905,9 @@

     /* Edge variance threshold for quad tree establishment. */
     float    edgeVarThreshold;
+
+    /* Maxrate that could be signaled to the decoder. Default 0. API only.
*/
+    int      decoderVbvMaxRate;
 } x265_param;

 /* x265_param_alloc:

-- 
*Thanks and Regards,*
*Snehaa.G*

<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>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<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>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20200318/bc5c9deb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Add option to get global maxrate.diff
Type: application/octet-stream
Size: 3632 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20200318/bc5c9deb/attachment.obj>


More information about the x265-devel mailing list