<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 1, 2013 at 2:51 AM,  <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"># HG changeset patch<br>
# User Shazeb Nawaz Khan <<a href="mailto:shazeb@multicorewareinc.com">shazeb@multicorewareinc.com</a>><br>
# Date 1380608621 -19800<br>
#      Tue Oct 01 11:53:41 2013 +0530<br>
# Node ID 051ccb452f2442ec9c054e2c8758df1843058bab<br>
# Parent  0da50ad39b4137976e4e2b295c32e1a710843b60<br>
Adding few checks and an init() function in MotionRefrence class...<br></blockquote><div><br></div><div>the ellipsis in the summary is unnecessary; I've queued this one and the first one.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

to properly signal malloc failure for 'fpelPlane'; handling to be added later<br>
<br>
diff -r 0da50ad39b41 -r 051ccb452f24 source/Lib/TLibCommon/TComPicYuv.cpp<br>
--- a/source/Lib/TLibCommon/TComPicYuv.cpp      Tue Oct 01 11:38:34 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComPicYuv.cpp      Tue Oct 01 11:53:41 2013 +0530<br>
@@ -250,7 +250,8 @@<br>
         else if (mref->isWeighted == false)<br>
             return mref;<br>
     }<br>
-    mref = new MotionReference(this, w);<br>
+    mref = new MotionReference();<br>
+    mref->init(this, w);<br>
     mref->m_next = m_refList;<br>
     m_refList = mref;<br>
     return mref;<br>
diff -r 0da50ad39b41 -r 051ccb452f24 source/common/reference.cpp<br>
--- a/source/common/reference.cpp       Tue Oct 01 11:38:34 2013 +0530<br>
+++ b/source/common/reference.cpp       Tue Oct 01 11:53:41 2013 +0530<br>
@@ -24,6 +24,7 @@<br>
<br>
 #include "TLibCommon/TypeDef.h"<br>
 #include "TLibCommon/TComPicYuv.h"<br>
+#include "TLibCommon/TComPic.h"<br>
 #include "TLibCommon/TComSlice.h"<br>
 #include "primitives.h"<br>
 #include "reference.h"<br>
@@ -51,12 +52,16 @@<br>
     return false;<br>
 }<br>
<br>
-MotionReference::MotionReference(TComPicYuv* pic, wpScalingParam *w)<br>
+MotionReference::MotionReference()<br>
+{}<br>
+<br>
+int MotionReference::init(TComPicYuv* pic, wpScalingParam *w)<br>
 {<br>
     m_reconPic = pic;<br>
     lumaStride = pic->getStride();<br>
     m_startPad = pic->m_lumaMarginY * lumaStride + pic->m_lumaMarginX;<br>
     m_next = NULL;<br>
+    isWeighted = false;<br>
<br>
     if (w)<br>
     {<br>
@@ -66,17 +71,20 @@<br>
         size_t padheight = height + pic->m_lumaMarginY * 2;<br>
<br>
         setWeight(*w);<br>
-        fpelPlane = (pixel*)X265_MALLOC(pixel,  padwidth * padheight) + m_startPad;<br>
+        fpelPlane = (pixel*)X265_MALLOC(pixel,  padwidth * padheight);<br>
+        if (fpelPlane) fpelPlane += m_startPad;<br>
+        else return -1;<br>
     }<br>
     else<br>
     {<br>
         /* directly reference the pre-extended integer pel plane */<br>
         fpelPlane = pic->m_picBufY + m_startPad;<br>
     }<br>
+    return 0;<br>
 }<br>
<br>
 MotionReference::~MotionReference()<br>
 {<br>
-    if (isWeighted)<br>
-        X265_FREE(fpelPlane);<br>
+    if (isWeighted && fpelPlane)<br>
+        X265_FREE(fpelPlane - m_startPad);<br>
 }<br>
diff -r 0da50ad39b41 -r 051ccb452f24 source/common/reference.h<br>
--- a/source/common/reference.h Tue Oct 01 11:38:34 2013 +0530<br>
+++ b/source/common/reference.h Tue Oct 01 11:53:41 2013 +0530<br>
@@ -30,6 +30,7 @@<br>
 // private x265 namespace<br>
<br>
 class TComPicYuv;<br>
+class TComPic;<br>
 struct WpScalingParam;<br>
 typedef WpScalingParam wpScalingParam;<br>
<br>
@@ -56,9 +57,9 @@<br>
 {<br>
 public:<br>
<br>
-    MotionReference(TComPicYuv*, wpScalingParam* w = NULL);<br>
-<br>
+    MotionReference();<br>
     ~MotionReference();<br>
+    int  init(TComPicYuv*, wpScalingParam* w = NULL);<br>
<br>
     MotionReference *m_next;<br>
     TComPicYuv      *m_reconPic;<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>