[x265] [PATCH] piclist: Added new class piclist for list manipulations

Steve Borho steve at borho.org
Tue Oct 8 20:39:30 CEST 2013


On Tue, Oct 8, 2013 at 6:46 AM, Gopu Govindaswamy <gopu at multicorewareinc.com
> wrote:

> # HG changeset patch
> # User Gopu Govindaswamy <gopu at multicorewareinc.com>
> # Date 1381232760 -19800
> # Node ID 166d3dbf2b70145a668d8c88582408574a5e8c64
> # Parent  9b3a427a1009d1853bbdc30abe1fd891864e6b38
> piclist: Added new class piclist for list manipulations
>
> Created new file piclist.cpp and piclist.h for linked list manipulation,
> there will be
> no intermediate storage in piclist, the piclist just link the TComPic
> object
>
> piclist is used to Replace TComList<TComPic> and this will remove
> std::list dependency in X265
>

Queued with a pile of cleanups


>
> diff -r 9b3a427a1009 -r 166d3dbf2b70 source/Lib/TLibCommon/TComPic.cpp
> --- a/source/Lib/TLibCommon/TComPic.cpp Tue Oct 08 11:12:12 2013 +0530
> +++ b/source/Lib/TLibCommon/TComPic.cpp Tue Oct 08 17:16:00 2013 +0530
> @@ -59,6 +59,8 @@
>      m_reconRowCount = 0;
>      m_countRefEncoders = 0;
>      memset(&m_lowres, 0, sizeof(m_lowres));
> +    next = NULL;
> +    prev = NULL;
>

class member naming convention calls for m_


>  }
>
>  TComPic::~TComPic()
> diff -r 9b3a427a1009 -r 166d3dbf2b70 source/Lib/TLibCommon/TComPic.h
> --- a/source/Lib/TLibCommon/TComPic.h   Tue Oct 08 11:12:12 2013 +0530
> +++ b/source/Lib/TLibCommon/TComPic.h   Tue Oct 08 17:16:00 2013 +0530
> @@ -81,6 +81,9 @@
>
>      Lowres                m_lowres;
>
> +    TComPic *next;
> +    TComPic *prev;
> +
>      TComPic();
>      virtual ~TComPic();
>
> diff -r 9b3a427a1009 -r 166d3dbf2b70 source/common/CMakeLists.txt
> --- a/source/common/CMakeLists.txt      Tue Oct 08 11:12:12 2013 +0530
> +++ b/source/common/CMakeLists.txt      Tue Oct 08 17:16:00 2013 +0530
> @@ -93,7 +93,8 @@
>      TShortYUV.cpp TShortYUV.h mv.h
>      reference.cpp reference.h
>      common.cpp common.h
> -    lowres.cpp lowres.h)
> +    lowres.cpp lowres.h
> +    piclist.cpp piclist.h)
>
>  if(ENABLE_PRIMITIVES_VEC)
>      add_subdirectory(vec)
> diff -r 9b3a427a1009 -r 166d3dbf2b70 source/common/piclist.cpp
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/common/piclist.cpp Tue Oct 08 17:16:00 2013 +0530
> @@ -0,0 +1,110 @@
>
> +/*****************************************************************************
> + * Copyright (C) 2013 x265 project
> + *
> + * Authors: Gopu Govindaswamy <gopu at multicorewareinc.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111,
> USA.
> + *
> + * This program is also available under a commercial proprietary license.
> + * For more information, contact us at licensing at multicorewareinc.com.
> +
> *****************************************************************************/
> +#include "piclist.h"
> +#include "TLibCommon/TComPic.h"
> +using namespace x265;
>

added a few blank lines here


> +void piclist::push_front(TComPic *pic)
> +{
>

it's tempting to pass TComPic by reference so we don't have to check for
NULL inside our function


> +    if (pic)
> +    {
> +        count++;
> +        if (start == NULL)
> +        {
> +            start = pic;
> +            end = pic;
> +        }
> +        else
> +        {
> +            pic->next = start;
> +            start->prev = pic;
> +            start = pic;
> +        }
>

modified to ensure pic->m_next and pic->m_prev are properly initialized


> +    }
> +}
> +
> +void piclist::push_back(TComPic *pic)
> +{
> +    if (pic)
> +    {
> +        count++;
> +        if (end == NULL)
> +        {
> +            start = pic;
> +            end = pic;
> +        }
> +        else
> +        {
> +            pic->prev = end;
> +            end->next = pic;
> +            end = pic;
> +        }
> modified to ensure pic->m_next and pic->m_prev are properly initialized
> +    }
> +}
> +
> +TComPic *piclist::pop_front()
> +{
> +    if (!empty())
> +    {
> +        TComPic *temp = start;
> +        /** if one pic in the list */
> +        if (count == 1)
> +        {
> +            start = end = NULL;
> +            count--;
> +        }
> +        else
> +        {
> +            start = start->next;
> +            temp->next = temp->prev = NULL;
> +            count--;
> +        }
> modified to ensure pic->m_next and pic->m_prev are properly updated,
> simplified
> +        return temp;
> +    }
> +    else
> +        return NULL;
> +}
> +
> +TComPic *piclist::pop_back()
> +{
> +    if (!empty())
> +    {
> +        TComPic* temp = end;
> +        /** if one pic in the list */
> +        if (count == 1)
> +        {
> +            start = end = NULL;
> +            count--;
> +        }
> +        else
> +        {
> +            TComPic* back = end->prev;
> +            back->next = NULL;
> +            end = back;
> modified to ensure pic->m_next and pic->m_prev are properly updated,
> simplified
> +            count--;
> +        }
> +        return temp;
> +    }
> +    else
> +        return NULL;
> +}
> diff -r 9b3a427a1009 -r 166d3dbf2b70 source/common/piclist.h
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/common/piclist.h   Tue Oct 08 17:16:00 2013 +0530
> @@ -0,0 +1,79 @@
>
> +/*****************************************************************************
> + * Copyright (C) 2013 x265 project
> + *
> + * Authors: Gopu Govindaswamy <gopu at multicorewareinc.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111,
> USA.
> + *
> + * This program is also available under a commercial proprietary license.
> + * For more information, contact us at licensing at multicorewareinc.com.
> +
> *****************************************************************************/
> +
> +#ifndef X265_PICLIST_H
> +#define X265_PICLIST_H
> +
> +#include "x265.h"
> +#include "common.h"
>

no need for either of these includes, all you need is NULL defined


> +namespace x265 {
> +
> +class TComPic;
>

added a blank line


> +class piclist
>

our class naming convention requires PicList


> +{
> +
> +    TComPic *start;
> +    TComPic *end;
>

m_start, m_end, m_count


> +
> +    /** Number of the picture in the list */
> +    int count;
> +
> +public:
> +    piclist()
> +    {
> +        start = NULL;
> +        end = NULL;
> +        count = 0;
> +    }
> +
> +    /** Pushing the picture at end of the list */
> +    void push_back(TComPic *pic);
> +
> +    /** Pushing the picture at beginning  of the list */
>

many comments had double spaces in them


> +    void push_front(TComPic *pic);
> +
> +    /** Retrieve  the picture at end of the list */
>

you used the term "Retrieve" in the comments for pop* and first() last()
which are entirely different operations; I changed the pop_* comments to
use the verb Pop


> +    TComPic* pop_back();
> +
> +    /** Retrieve  the picture at beginning  of the list */
> +    TComPic* pop_front();
>

our class method naming convention calls for popFront(), etc


> +
> +    /** Number of Picture in the list */
> +    int size() { return count; }
> +
> +    /** Retrieve  the beginning  picture  */
> +    TComPic* first()
> +    {
> +        if (start)
> +            return start;
> +    }
>

this shouldn't even compile (not all paths have return statements).  the
if() is entirely unnecessary.


> +
> +    /** Retrieve  the end picture  */
> +    TComPic* last() { return end; }
> +
> +    bool empty() const { return !start; }
> +    operator bool() const { return !empty(); }
>

I added a remove() method because I know we need one for freelist picture
reuse


> +};
> +}
> +
> +#endif // ifndef X265_PICLIST_H
> _______________________________________________
> 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/20131008/82e8f326/attachment-0001.html>


More information about the x265-devel mailing list