[x265] [PATCH] API function to reconfigure scalinglists

Vignesh V Menon vignesh at multicorewareinc.com
Tue Dec 13 05:19:48 CET 2016


# HG changeset patch
# User Vignesh Vijayakumar <vignesh at multicorewareinc.com>
# Date 1480914995 -19800
#      Mon Dec 05 10:46:35 2016 +0530
# Node ID fb436beef19588e35160624e32fdffcf9506efce
# Parent  c97c64ab8b8eaea8b1de611adc9022815d88b09b
API function to reconfigure scalinglists

diff -r c97c64ab8b8e -r fb436beef195 source/CMakeLists.txt
--- a/source/CMakeLists.txt Thu May 26 17:49:25 2016 +0530
+++ b/source/CMakeLists.txt Mon Dec 05 10:46:35 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 102)
+set(X265_BUILD 103)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r c97c64ab8b8e -r fb436beef195 source/encoder/api.cpp
--- a/source/encoder/api.cpp Thu May 26 17:49:25 2016 +0530
+++ b/source/encoder/api.cpp Mon Dec 05 10:46:35 2016 +0530
@@ -31,6 +31,10 @@
 #include "nal.h"
 #include "bitcost.h"

+#ifdef _WIN32
+#define strdup _strdup
+#endif
+
 /* multilib namespace reflectors */
 #if LINKED_8BIT
 namespace x265_8bit {
@@ -189,6 +193,23 @@
     return ret;
 }

+int x265_scalinglists_reconfig(x265_encoder* enc, const char *filename)
+{
+    if (!enc || !filename)
+        return -1;
+    Encoder* encoder = static_cast<Encoder*>(enc);
+    if (!encoder->m_latestParam)
+        return -1;
+    encoder->m_latestParam->bRepeatHeaders = true;
+    encoder->m_latestParam->scalingLists = strdup(filename);
+    if
(encoder->m_scalingList.parseScalingList(encoder->m_latestParam->scalingLists))
+        return -1;
+    encoder->m_scalingList.setupQuantMatrices();
+    encoder->m_reconfigure = true;
+    encoder->printReconfigureParams();
+    return 0;
+}
+
 int x265_encoder_encode(x265_encoder *enc, x265_nal **pp_nal, uint32_t
*pi_nal, x265_picture *pic_in, x265_picture *pic_out)
 {
     if (!enc)
diff -r c97c64ab8b8e -r fb436beef195 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Thu May 26 17:49:25 2016 +0530
+++ b/source/encoder/encoder.cpp Mon Dec 05 10:46:35 2016 +0530
@@ -408,6 +408,14 @@
     if (m_analysisFile)
         fclose(m_analysisFile);

+    if (m_latestParam != NULL && m_latestParam != m_param)
+    {
+        if (m_latestParam->scalingLists != m_param->scalingLists)
+            free((char*)m_latestParam->scalingLists);
+
+        PARAM_NS::x265_param_free(m_latestParam);
+    }
+
     if (m_param)
     {
         /* release string arguments that were strdup'd */
@@ -420,8 +428,6 @@

         PARAM_NS::x265_param_free(m_param);
     }
-
-    PARAM_NS::x265_param_free(m_latestParam);
 }

 void Encoder::updateVbvPlan(RateControl* rc)
@@ -2474,6 +2480,7 @@
     TOOLCMP(oldParam->bEnableRectInter, newParam->bEnableRectInter,
"rect=%d to %d\n");
     TOOLCMP(oldParam->maxNumMergeCand, newParam->maxNumMergeCand,
"max-merge=%d to %d\n");
     TOOLCMP(oldParam->bIntraInBFrames, newParam->bIntraInBFrames,
"b-intra=%d to %d\n");
+    TOOLCMP(oldParam->scalingLists, newParam->scalingLists,
"scalinglists=%s to %s\n");
 }

 bool Encoder::computeSPSRPSIndex()
diff -r c97c64ab8b8e -r fb436beef195 source/x265.h
--- a/source/x265.h Thu May 26 17:49:25 2016 +0530
+++ b/source/x265.h Mon Dec 05 10:46:35 2016 +0530
@@ -1498,6 +1498,10 @@
  *      parameters to take this into account. */
 int x265_encoder_reconfig(x265_encoder *, x265_param *);

+/* x265_scalinglists_reconfig:
+ *      quantization coefficients from the input file will be copied. */
+int x265_scalinglists_reconfig(x265_encoder* enc, const char *filename);
+
 /* x265_encoder_get_stats:
  *       returns encoder statistics */
 void x265_encoder_get_stats(x265_encoder *encoder, x265_stats *, uint32_t
statsSizeBytes);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20161213/653357a3/attachment.html>


More information about the x265-devel mailing list