[x265] [PATCH 4 of 4] Adding few checks and an init() function in MotionRefrence class

Steve Borho steve at borho.org
Tue Oct 1 20:08:57 CEST 2013


On Tue, Oct 1, 2013 at 2:51 AM, <shazeb at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
> # Date 1380608621 -19800
> #      Tue Oct 01 11:53:41 2013 +0530
> # Node ID 051ccb452f2442ec9c054e2c8758df1843058bab
> # Parent  0da50ad39b4137976e4e2b295c32e1a710843b60
> Adding few checks and an init() function in MotionRefrence class...
>

the ellipsis in the summary is unnecessary; I've queued this one and the
first one.


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



-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20131001/ea64f714/attachment.html>


More information about the x265-devel mailing list