<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 30, 2013 at 2:40 AM, Shazeb Khan <span dir="ltr"><<a href="mailto:shazeb@multicorewareinc.com" target="_blank">shazeb@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Fri, Sep 27, 2013 at 10:19 PM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Fri, Sep 27, 2013 at 11:30 AM, Jean-Baptiste Kempf <span dir="ltr"><<a href="mailto:jb@videolan.org" target="_blank">jb@videolan.org</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On 27 Sep, <a href="mailto:shazeb@multicorewareinc.com" target="_blank">shazeb@multicorewareinc.com</a> wrote :<br>



<div>> -        X265_FREE(fpelPlane);<br>
> +        X265_FREE(fpelPlane - m_startPad);<br>
<br>
</div>Is this always allowed?<br></blockquote><div><br></div></div><div>It's not robust, this if statement also needs to verify refPlane is not NULL  applyWeight() also needs to check for earlier malloc failure and early-out.</div>

</div></div></div></blockquote><div><br></div></div><div>What shall be the proper way to handle this condition in applyWeight(): when fpelPlane has no allocation.</div><div><br></div><div>One way out is to have a flag in MotionReference object which must be set 'false' on malloc fail ('true' by default); and this flag must be checked before calling applyweight() and using the weighted pixels.</div>

<div>But the problem with this approach will be that the condition will stay unreported.</div><div><br></div><div>Any suggestions?</div></div></div></div></blockquote><div><br></div><div>There are two general theories here:</div>
<div><br></div><div>1 - there is no real recovery from a malloc failure.  You have to do your best to not crash and to communicate the failure back up to the user and prevent further API calls from crashing.. ie: you must have a safety breaker that trips and stops the encoder from using incomplete data structures.</div>
<div><br></div><div>2 - you can pre-allocate all of the memory you will need at encoder creation so mallocs are not required once the encode gets started.  This way you can report the malloc error at creation and the application can react more cleanly.</div>
<div><br></div><div>We should aim for a combination of these.  The former first and then work towards the latter.</div><div> </div></div>-- <br>Steve Borho
</div></div>