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

Steve Borho steve at borho.org
Tue Oct 8 10:05:11 CEST 2013


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

> # HG changeset patch
> # User Gopu Govindaswamy <gopu at multicorewareinc.com>
> # Date 1381217437 -19800
> # Node ID ef8a18d9a3605f90644b563ef7976727b769e60a
> # 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
>
> diff -r 9b3a427a1009 -r ef8a18d9a360 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 13:00:37 2013 +0530
> @@ -59,6 +59,8 @@
>      m_reconRowCount = 0;
>      m_countRefEncoders = 0;
>      memset(&m_lowres, 0, sizeof(m_lowres));
> +    next = NULL;
> +    prev = NULL;
>  }
>
>  TComPic::~TComPic()
> diff -r 9b3a427a1009 -r ef8a18d9a360 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 13:00:37 2013 +0530
> @@ -81,6 +81,9 @@
>
>      Lowres                m_lowres;
>
> +    TComPic *next;
> +    TComPic *prev;
> +
>      TComPic();
>      virtual ~TComPic();
>
> diff -r 9b3a427a1009 -r ef8a18d9a360 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 13:00:37 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 ef8a18d9a360 source/common/piclist.cpp
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/common/piclist.cpp Tue Oct 08 13:00:37 2013 +0530
> @@ -0,0 +1,91 @@
>
> +/*****************************************************************************
> + * 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"
> +using namespace x265;
> +
> +void piclist::push_front(TComPic *pic)
> +{
> +    if (pic)
> +    {
> +        count++;
> +        if (start == NULL)
> +        {
> +            start = pic;
> +            end = pic;
> +        }
> +        else
> +        {
> +            pic->next = start;
> +            start->prev = pic;
> +            start = pic;
> +        }
> +    }
> +}
> +
> +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;
> +        }
> +    }
> +}
> +
> +TComPic *piclist::pop_front()
> +{
> +    if (!empty())
> +    {
> +        TComPic *temp = start;
> +        start = start->next;
> +        temp->next = temp->prev = NULL;
> +        count--;
> +        return temp;
> +    }
> +    else
> +        return NULL;
> +}
> +
> +TComPic *piclist::pop_back()
> +{
> +    if (!empty())
> +    {
> +        TComPic* temp = end;
> +        TComPic* back = end->prev;
> +        back->next = NULL;
> +        end = back;
> +        count--;
> +        return temp;
> +    }
> +    else
> +        return NULL;
> +}
> diff -r 9b3a427a1009 -r ef8a18d9a360 source/common/piclist.h
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
> +++ b/source/common/piclist.h   Tue Oct 08 13:00:37 2013 +0530
> @@ -0,0 +1,81 @@
>
> +/*****************************************************************************
> + * 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 "TLibCommon/TComPic.h"
>

There's no need to include TComPic.h when the class is forward decl'd below


> +
> +namespace x265 {
> +
> +class TComPic;
> +class piclist {
> +
> +    TComPic *start;
> +    TComPic *end;
> +
> +    /** Number of the picture in the list */
> +    int count;
> +
> +public:
> +    piclist()
> +    {
> +        start    = NULL;
> +        end      = NULL;
> +        count    = 0;
> +    }
>

white-space nits


> +
> +    /** Pushing the picture at end of the list */
> +    void push_back(TComPic *pic);
> +
> +    /** Pushing the picture at beginning  of the list */
> +    void push_front(TComPic *pic);
> +
> +    /** Retrieve  the picture at end of the list */
> +    TComPic* pop_back();
> +
> +    /** Retrieve  the picture at beginning  of the list */
> +    TComPic* pop_front();
> +
> +    /** Number of Picture in the list */
> +    UInt size() { return count; }
> +
> +    /** Retrieve  the beginning  picture  */
> +    TComPic* first()
> +    {
> +        if (start)
> +            return start;
> +        else
> +            NULL;
>

missing a return here, but it seems "return start;" would be fine without
any conditionals


> +    }
> +
> +    /** Retrieve  the end picture  */
> +    TComPic* last() { return end; }
> +
> +    bool empty() const { return !start; }
> +    operator bool() const { return !empty(); }
> +};
> +}
> +
> +#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/4e0a6baf/attachment-0001.html>


More information about the x265-devel mailing list