<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 20, 2013 at 2:14 AM, Gopu Govindaswamy <span dir="ltr"><<a href="mailto:gopu@multicorewareinc.com" target="_blank">gopu@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Gopu Govindaswamy <<a href="mailto:gopu@multicorewareinc.com">gopu@multicorewareinc.com</a>><br>
# Date 1379661247 -19800<br>
# Node ID 3692f665008c8ce96a97872b92bb83aa34ef1049<br>
# Parent 03195b8c3267dee542fe12886617902b7333a202<br>
encoder: Do not use X265_MALLOC use CHECKED_MALLOC<br>
<br>
Currently X265_MALLOC did't validate the returned pointer, CHECKED_MALLOC Always<br>
validate the returned pointer and print the Log message and jumps to fail lable<br>
if returned pointer is not valid,<br></blockquote><div><br></div><div>queued for default with one change, see below</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
diff -r 03195b8c3267 -r 3692f665008c source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Fri Sep 20 12:15:09 2013 +0530<br>
+++ b/source/encoder/encoder.cpp Fri Sep 20 12:44:07 2013 +0530<br>
@@ -47,7 +47,7 @@<br>
<br>
void configure(x265_param_t *param);<br>
void determineLevelAndProfile(x265_param_t *param);<br>
- void extract_naldata(AccessUnit &au, size_t &nalcount);<br>
+ int extract_naldata(AccessUnit &au, size_t &nalcount);<br>
};<br>
<br>
x265_t::x265_t()<br>
@@ -364,11 +364,13 @@<br>
if (encoder->getStreamHeaders(au) == 0)<br>
{<br>
size_t nalcount;<br>
- encoder->extract_naldata( au, nalcount);<br>
-<br>
- *pp_nal = &encoder->m_nals[0];<br>
- if (pi_nal) *pi_nal = (int)nalcount;<br>
- return 0;<br>
+ if (encoder->extract_naldata( au, nalcount) == 0)<br></blockquote><div><br></div><div>it is x264 style to use if (!foo) instead of if (foo==0), and I think we should follow that convention</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ {<br>
+ *pp_nal = &encoder->m_nals[0];<br>
+ if (pi_nal) *pi_nal = (int)nalcount;<br>
+ return 0;<br>
+ }<br>
+ return -1;<br>
}<br>
else<br>
return -1;<br>
@@ -417,7 +419,7 @@<br>
BitCost::destroy();<br>
}<br>
<br>
-void x265_t::extract_naldata( AccessUnit &au, size_t &nalcount)<br>
+int x265_t::extract_naldata( AccessUnit &au, size_t &nalcount)<br>
{<br>
UInt memsize = 0;<br>
nalcount = 0;<br>
@@ -434,8 +436,8 @@<br>
if (m_nals)<br>
X265_FREE(m_nals);<br>
<br>
- m_packetData = (char*)X265_MALLOC(char, memsize);<br>
- m_nals = (x265_nal_t*)X265_MALLOC(x265_nal_t, nalcount);<br>
+ CHECKED_MALLOC(m_packetData, char, memsize);<br>
+ CHECKED_MALLOC(m_nals, x265_nal_t, nalcount);<br>
nalcount = 0;<br>
memsize = 0;<br>
<br>
@@ -483,4 +485,8 @@<br>
m_nals[i].p_payload = (uint8_t*)m_packetData + offset;<br>
offset += m_nals[i].i_payload;<br>
}<br>
+<br>
+ return 0;<br>
+fail:<br>
+ return -1;<br>
}<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>