[x265] [PATCH] encoder: Added pad size in Malloc

Gopu Govindaswamy gopu at multicorewareinc.com
Thu Sep 5 10:59:21 CEST 2013


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1378371552 -19800
# Node ID 2d5e0732c38a49d3ce671f5784b02e9e971462f3
# Parent  0a5662f7e27f068918ee170e9e41026bc629f1d8
encoder: Added pad size in Malloc

diff -r 0a5662f7e27f -r 2d5e0732c38a source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Sep 05 14:26:05 2013 +0530
+++ b/source/encoder/encoder.cpp	Thu Sep 05 14:29:12 2013 +0530
@@ -338,12 +338,12 @@
     AccessUnit au;
     if (encoder->getStreamHeaders(au) == 0)
     {
-        int memsize = 0;
+        long memsize = 0;
         int nalcount = 0;
         for (AccessUnit::const_iterator t = au.begin(); t != au.end(); t++)
         {
             const NALUnitEBSP& temp = **t;
-            memsize += (int)temp.m_nalUnitData.str().size();
+            memsize += (long)temp.m_nalUnitData.str().size() + 4;
             nalcount++;
         }
 
@@ -403,7 +403,7 @@
         }
 
         *pp_nal = &encoder->m_nals[0];
-        if (pi_nal) *pi_nal = nalcount;
+        if (pi_nal) *pi_nal = (int)nalcount;
         return 0;
     }
     else
@@ -419,12 +419,12 @@
 
     if (pp_nal && numEncoded)
     {
-        int memsize = 0;
+        long memsize = 0;
         int nalcount = 0;
         for (AccessUnit::const_iterator t = au.begin(); t != au.end(); t++)
         {
             const NALUnitEBSP& temp = **t;
-            memsize += (int)temp.m_nalUnitData.str().size();
+            memsize += (long)temp.m_nalUnitData.str().size() + 4;
             nalcount++;
         }
 
@@ -432,7 +432,7 @@
             X265_FREE(encoder->m_nals);
 
         if (encoder->m_packetData)
-            X265_FREE(encoder->m_packetData);
+           X265_FREE(encoder->m_packetData);
 
         encoder->m_packetData = (char*)X265_MALLOC(char, memsize);
         encoder->m_nals = (x265_nal_t*)X265_MALLOC(x265_nal_t, nalcount);
@@ -484,7 +484,7 @@
         }
 
         *pp_nal = &encoder->m_nals[0];
-        if (pi_nal) *pi_nal = nalcount;
+        if (pi_nal) *pi_nal =(int) nalcount;
     }
     else if (pi_nal)
         *pi_nal = 0;


More information about the x265-devel mailing list