[x265] [PATCH] rc: Use RcStats information if available from pic_in

gopi.satykrishna at multicorewareinc.com gopi.satykrishna at multicorewareinc.com
Thu May 18 15:24:54 CEST 2017


# HG changeset patch
# User Gopi Satykrishna Akisetty <gopi.satykrishna at multicorewareinc.com>
# Date 1495026531 -19800
#      Wed May 17 18:38:51 2017 +0530
# Node ID afdca6b5f90d1e4708466671871d378952e95fbc
# Parent  4b846d3bac97134b8a91e3569bcb9f981b47ccc0
rc: Use RcStats information if available from pic_in

diff -r 4b846d3bac97 -r afdca6b5f90d source/CMakeLists.txt
--- a/source/CMakeLists.txt	Wed May 17 17:27:41 2017 +0530
+++ b/source/CMakeLists.txt	Wed May 17 18:38:51 2017 +0530
@@ -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 117)
+set(X265_BUILD 118)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 4b846d3bac97 -r afdca6b5f90d source/common/param.cpp
--- a/source/common/param.cpp	Wed May 17 17:27:41 2017 +0530
+++ b/source/common/param.cpp	Wed May 17 18:38:51 2017 +0530
@@ -276,6 +276,7 @@
     param->toneMapFile = NULL;
     param->bDhdr10opt = 0;
     param->bCTUInfo = 0;
+    param->bUseRcStats = 0;
 }
 
 int x265_param_default_preset(x265_param* param, const char* preset, const char* tune)
diff -r 4b846d3bac97 -r afdca6b5f90d source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Wed May 17 17:27:41 2017 +0530
+++ b/source/encoder/encoder.cpp	Wed May 17 18:38:51 2017 +0530
@@ -772,6 +772,32 @@
             inFrame->m_lowres.bScenecut = !!inFrame->m_analysisData.bScenecut;
             inFrame->m_lowres.satdCost = inFrame->m_analysisData.satdCost;
         }
+        if (m_param->bUseRcStats && pic_in->rcData)
+        {
+            RcStats* rc = (RcStats*)pic_in->rcData;
+            m_rateControl->m_accumPQp = rc->cumulativePQp;
+            m_rateControl->m_accumPNorm = rc->cumulativePNorm;
+            m_rateControl->m_isNextGop = true;
+            for (int j = 0; j < 3; j++)
+                m_rateControl->m_lastQScaleFor[j] = rc->lastQScaleFor[j];
+            m_rateControl->m_wantedBitsWindow = rc->wantedBitsWindow;
+            m_rateControl->m_cplxrSum = rc->cplxrSum;
+            m_rateControl->m_totalBits = rc->totalBits;
+            m_rateControl->m_encodedBits = rc->encodedBits;
+            m_rateControl->m_shortTermCplxSum = rc->shortTermCplxSum;
+            m_rateControl->m_shortTermCplxCount = rc->shortTermCplxCount;
+            if (m_rateControl->m_isVbv)
+            {
+                m_rateControl->m_bufferFillFinal = rc->bufferFillFinal;
+                for (int i = 0; i < 4; i++)
+                {
+                    m_rateControl->m_pred[i].coeff = rc->coeff[i];
+                    m_rateControl->m_pred[i].count = rc->count[i];
+                    m_rateControl->m_pred[i].offset = rc->offset[i];
+                }
+            }
+            m_param->bUseRcStats = 0;
+        }
         if (m_reconfigureRc)
             inFrame->m_reconfigureRc = true;
 
diff -r 4b846d3bac97 -r afdca6b5f90d source/x265.h
--- a/source/x265.h	Wed May 17 17:27:41 2017 +0530
+++ b/source/x265.h	Wed May 17 18:38:51 2017 +0530
@@ -1408,6 +1408,9 @@
 
     /* Determine how x265 react to the content information recieved through the API */
     int       bCTUInfo;
+
+    /* Use ratecontrol statistics from pic_in, if available*/
+    int       bUseRcStats;
 } x265_param;
 /* x265_param_alloc:
  *  Allocates an x265_param instance. The returned param structure is not


More information about the x265-devel mailing list