[x265] [PATCH 3 of 7] encoder: introduce an instance to hold the latest param setting in the encoder

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Tue May 5 17:51:42 CEST 2015


# HG changeset patch
# User Aarthi Thirumalai
# Date 1427264624 -19800
#      Wed Mar 25 11:53:44 2015 +0530
# Node ID 303a09b9cb9419564804c3b79bca3caa61e07e82
# Parent  084e7ed97059873201ccb4762eeb9d3a55dd3238
encoder: introduce an instance to hold the latest param setting in the encoder

this will be used to hold the latest param options when dynamically reconfiguring the encoder parameters

diff -r 084e7ed97059 -r 303a09b9cb94 source/encoder/api.cpp
--- a/source/encoder/api.cpp	Wed Mar 25 16:30:43 2015 +0530
+++ b/source/encoder/api.cpp	Wed Mar 25 11:53:44 2015 +0530
@@ -40,7 +40,8 @@
         return NULL;
 
     x265_param *param = X265_MALLOC(x265_param, 1);
-    if (!param)
+    x265_param *latestParam = X265_MALLOC(x265_param, 1);
+    if (!param || !latestParam)
         return NULL;
 
     memcpy(param, p, sizeof(x265_param));
@@ -61,11 +62,11 @@
 
     // may change params for auto-detect, etc
     encoder->configure(param);
-    
     // may change rate control and CPB params
     if (!enforceLevel(*param, encoder->m_vps))
     {
         delete encoder;
+        x265_param_free(latestParam);
         return NULL;
     }
 
@@ -80,9 +81,12 @@
     }
 
     encoder->create();
+    encoder->m_latestParam = latestParam;
+    memcpy(latestParam, param, sizeof(x265_param));
     if (encoder->m_aborted)
     {
         delete encoder;
+        x265_param_free(latestParam);
         return NULL;
     }
 
diff -r 084e7ed97059 -r 303a09b9cb94 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Wed Mar 25 16:30:43 2015 +0530
+++ b/source/encoder/encoder.cpp	Wed Mar 25 11:53:44 2015 +0530
@@ -73,6 +73,7 @@
     m_outputCount = 0;
     m_csvfpt = NULL;
     m_param = NULL;
+    m_latestParam = NULL;
     m_cuOffsetY = NULL;
     m_cuOffsetC = NULL;
     m_buOffsetY = NULL;
@@ -376,6 +377,8 @@
 
         X265_FREE(m_param);
     }
+    if (m_latestParam)
+        X265_FREE(m_latestParam);
 }
 
 void Encoder::updateVbvPlan(RateControl* rc)
diff -r 084e7ed97059 -r 303a09b9cb94 source/encoder/encoder.h
--- a/source/encoder/encoder.h	Wed Mar 25 16:30:43 2015 +0530
+++ b/source/encoder/encoder.h	Wed Mar 25 11:53:44 2015 +0530
@@ -125,6 +125,7 @@
     uint32_t           m_numDelayedPic;
 
     x265_param*        m_param;
+    x265_param*        m_latestParam;
     RateControl*       m_rateControl;
     Lookahead*         m_lookahead;
     Window             m_conformanceWindow;


More information about the x265-devel mailing list