On Tue, Oct 8, 2013 at 6:46 AM, Gopu Govindaswamy <[email protected] > wrote:
> # HG changeset patch > # User Gopu Govindaswamy <[email protected]> > # 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 <[email protected]> > + * > + * 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 [email protected]. > + > *****************************************************************************/ > +#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 <[email protected]> > + * > + * 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 [email protected]. > + > *****************************************************************************/ > + > +#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 > [email protected] > https://mailman.videolan.org/listinfo/x265-devel > -- Steve Borho
_______________________________________________ x265-devel mailing list [email protected] https://mailman.videolan.org/listinfo/x265-devel
