[x265] [PATCH 2 of 2] remove redundant file reads

bhavna at multicorewareinc.com bhavna at multicorewareinc.com
Fri Jun 23 09:23:05 CEST 2017


# HG changeset patch
# User Bhavna Hariharan <bhavna at multicorewareinc.com>
# Date 1497957678 -19800
#      Tue Jun 20 16:51:18 2017 +0530
# Branch stable
# Node ID 12efe46f4872d4e7e2e6bbc197b5a7dce0064642
# Parent  f4de3ccf989164ed89cc48e49e55d627a8414522
remove redundant file reads

diff -r f4de3ccf9891 -r 12efe46f4872 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Tue May 23 12:42:54 2017 +0530
+++ b/source/encoder/encoder.cpp	Tue Jun 20 16:51:18 2017 +0530
@@ -88,6 +88,8 @@
 
 #if ENABLE_DYNAMIC_HDR10
     m_hdr10plus_api = hdr10plus_api_get();
+    numCimInfo = 0;
+    cim = NULL;
 #endif
 
     m_prevTonemapPayload.payload = NULL;
@@ -431,6 +433,10 @@
 
 void Encoder::destroy()
 {
+#if ENABLE_DYNAMIC_HDR10
+    m_hdr10plus_api->hdr10plus_clear_movie(cim, numCimInfo);
+#endif
+        
     if (m_exportedPic)
     {
         ATOMIC_DEC(&m_exportedPic->m_countRefEncoders);
@@ -604,18 +610,19 @@
 #if ENABLE_DYNAMIC_HDR10
         if (m_bToneMap)
         {
-            uint8_t *cim = NULL;
-            if (m_hdr10plus_api->hdr10plus_json_to_frame_cim(m_param->toneMapFile, pic_in->poc, cim))
+            if (pic_in->poc == 0)
+                numCimInfo = m_hdr10plus_api->hdr10plus_json_to_movie_cim(m_param->toneMapFile, cim);
+            if (pic_in->poc < numCimInfo)
             {
                 int32_t i = 0;
                 toneMap.payloadSize = 0;
-                while (cim[i] == 0xFF)
-                    toneMap.payloadSize += cim[i++] + 1;
-                toneMap.payloadSize += cim[i] + 1;
+                while (cim[i][pic_in->poc] == 0xFF)
+                    toneMap.payloadSize += cim[pic_in->poc][i++] + 1;
+                toneMap.payloadSize += cim[pic_in->poc][i] + 1;
 
                 toneMap.payload = (uint8_t*)x265_malloc(sizeof(uint8_t) * toneMap.payloadSize);
                 toneMap.payloadType = USER_DATA_REGISTERED_ITU_T_T35;
-                memcpy(toneMap.payload, cim, toneMap.payloadSize);
+                memcpy(toneMap.payload, cim[pic_in->poc], toneMap.payloadSize);
             }
         }
 #endif
diff -r f4de3ccf9891 -r 12efe46f4872 source/encoder/encoder.h
--- a/source/encoder/encoder.h	Tue May 23 12:42:54 2017 +0530
+++ b/source/encoder/encoder.h	Tue Jun 20 16:51:18 2017 +0530
@@ -178,6 +178,8 @@
 
 #ifdef ENABLE_DYNAMIC_HDR10
     const hdr10plus_api     *m_hdr10plus_api;
+    uint8_t                 **cim;
+    int                     numCimInfo;
 #endif
 
     x265_sei_payload        m_prevTonemapPayload;


More information about the x265-devel mailing list