[x265] [PATCH] Add x265_rc_stats structure to collect rc data for each frame

Divya Manivannan divya at multicorewareinc.com
Tue Feb 16 14:02:31 CET 2016


# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1454681600 -19800
#      Fri Feb 05 19:43:20 2016 +0530
# Node ID 7ea8d66a886697b8f93e5ca917e509a05af371cc
# Parent  425b583f25dbb57af86fc5c128548038954baf31
Add x265_rc_stats structure to collect rc data for each frame

diff -r 425b583f25db -r 7ea8d66a8866 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Feb 11 13:15:03 2016 +0530
+++ b/source/CMakeLists.txt	Fri Feb 05 19:43:20 2016 +0530
@@ -30,7 +30,7 @@
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 80)
+set(X265_BUILD 81)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 425b583f25db -r 7ea8d66a8866 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Feb 11 13:15:03 2016 +0530
+++ b/source/encoder/encoder.cpp	Fri Feb 05 19:43:20 2016 +0530
@@ -783,6 +783,21 @@
                 if (m_rateControl->writeRateControlFrameStats(outFrame, &curEncoder->m_rce))
                     m_aborted = true;
 
+            if (pic_out && !m_param->rc.bStatRead)
+            {
+                pic_out->rcData.qpaRc = outFrame->m_encData->m_avgQpRc;
+                pic_out->rcData.qRceq = curEncoder->m_rce.qRceq;
+                pic_out->rcData.qpNoVbv = curEncoder->m_rce.qpNoVbv;
+                pic_out->rcData.coeffBits = outFrame->m_encData->m_frameStats.coeffBits;
+                pic_out->rcData.miscBits = outFrame->m_encData->m_frameStats.miscBits;
+                pic_out->rcData.mvBits = outFrame->m_encData->m_frameStats.mvBits;
+                pic_out->rcData.newQScale = x265_qp2qScale(outFrame->m_encData->m_avgQpRc);
+                pic_out->rcData.poc = curEncoder->m_rce.poc;
+                pic_out->rcData.encodeOrder = curEncoder->m_rce.encodeOrder;
+                pic_out->rcData.sliceType = curEncoder->m_rce.sliceType;
+                pic_out->rcData.keptAsRef = curEncoder->m_rce.sliceType == B_SLICE && !IS_REFERENCED(outFrame) ? false : true;
+            }
+
             /* Allow this frame to be recycled if no frame encoders are using it for reference */
             if (!pic_out)
             {
diff -r 425b583f25db -r 7ea8d66a8866 source/input/y4m.cpp
--- a/source/input/y4m.cpp	Thu Feb 11 13:15:03 2016 +0530
+++ b/source/input/y4m.cpp	Fri Feb 05 19:43:20 2016 +0530
@@ -417,6 +417,8 @@
     {
         int pixelbytes = depth > 8 ? 2 : 1;
         pic.bitDepth = depth;
+        pic.framesize = framesize;
+        pic.height = height;
         pic.colorSpace = colorSpace;
         pic.stride[0] = width * pixelbytes;
         pic.stride[1] = pic.stride[0] >> x265_cli_csps[colorSpace].width[1];
diff -r 425b583f25db -r 7ea8d66a8866 source/input/yuv.cpp
--- a/source/input/yuv.cpp	Thu Feb 11 13:15:03 2016 +0530
+++ b/source/input/yuv.cpp	Fri Feb 05 19:43:20 2016 +0530
@@ -225,6 +225,8 @@
         uint32_t pixelbytes = depth > 8 ? 2 : 1;
         pic.colorSpace = colorSpace;
         pic.bitDepth = depth;
+        pic.framesize = framesize;
+        pic.height = height;
         pic.stride[0] = width * pixelbytes;
         pic.stride[1] = pic.stride[0] >> x265_cli_csps[colorSpace].width[1];
         pic.stride[2] = pic.stride[0] >> x265_cli_csps[colorSpace].width[2];
diff -r 425b583f25db -r 7ea8d66a8866 source/x265.h
--- a/source/x265.h	Thu Feb 11 13:15:03 2016 +0530
+++ b/source/x265.h	Fri Feb 05 19:43:20 2016 +0530
@@ -150,6 +150,22 @@
     x265_cu_stats    cuStats;
 } x265_frame_stats;
 
+/* Ratecontrol statistics */
+typedef struct x265_rc_stats
+{
+    double  qpaRc;
+    double  qRceq;
+    double  qpNoVbv;
+    double  newQScale;
+    int     mvBits;
+    int     miscBits;
+    int     coeffBits;
+    int     poc;
+    int     encodeOrder;
+    int     sliceType;
+    bool    keptAsRef;
+} x265_rc_stats;
+
 /* Used to pass pictures into the encoder, and to get picture data back out of
  * the encoder.  The input and output semantics are different */
 typedef struct x265_picture
@@ -173,6 +189,10 @@
     /* Stride is the number of bytes between row starts */
     int     stride[3];
 
+    size_t framesize;
+
+    int    height;
+
     /* Must be specified on input pictures. x265_picture_init() will set it to
      * the encoder's internal bit depth, but this field must describe the depth
      * of the input pictures. Must be between 8 and 16. Values larger than 8
@@ -221,6 +241,10 @@
     /* Frame level statistics */
     x265_frame_stats frameData;
 
+    /* Ratecontrol statistics for collecting the ratecontrol information.
+     * It is not used for collecting the last pass ratecontrol data in 
+     * multi pass ratecontrol mode. */
+    x265_rc_stats rcData;
 } x265_picture;
 
 typedef enum


More information about the x265-devel mailing list