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

Gopu Govindaswamy gopu at multicorewareinc.com
Tue Oct 8 13:46:13 CEST 2013


# 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

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;
 }
 
 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;
+
+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;
+        /** if one pic in the list */
+        if (count == 1)
+        {
+            start = end = NULL;
+            count--;
+        }
+        else
+        {
+            start = start->next;
+            temp->next = temp->prev = NULL;
+            count--;
+        }
+        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;
+            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"
+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;
+    }
+
+    /** 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 */
+    int size() { return count; }
+
+    /** Retrieve  the beginning  picture  */
+    TComPic* first()
+    {
+        if (start)
+            return start;
+    }
+
+    /** Retrieve  the end picture  */
+    TComPic* last() { return end; }
+
+    bool empty() const { return !start; }
+    operator bool() const { return !empty(); }
+};
+}
+
+#endif // ifndef X265_PICLIST_H


More information about the x265-devel mailing list