libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd/cvd videobuffer.h videosource.h videobuf...


From: Edward Rosten
Subject: [libcvd-members] libcvd/cvd videobuffer.h videosource.h videobuf...
Date: Fri, 23 Oct 2009 14:49:43 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        09/10/23 14:49:43

Modified files:
        cvd            : videobuffer.h videosource.h 
Added files:
        cvd            : videobufferwithdata.h 

Log message:
        Removed the evil extra_data field from video buffer.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videobuffer.h?cvsroot=libcvd&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videosource.h?cvsroot=libcvd&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videobufferwithdata.h?cvsroot=libcvd&rev=1.1

Patches:
Index: videobuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videobuffer.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- videobuffer.h       15 Dec 2008 14:26:46 -0000      1.15
+++ videobuffer.h       23 Oct 2009 14:49:43 -0000      1.16
@@ -27,30 +27,6 @@
 
 namespace CVD {
 
-/// Base class for objects that a video buffer can 
-/// manage the lifetime of.
-class VideoBufferData
-{
-       public:
-               virtual ~VideoBufferData(){}
-};
-
-template<class T> class VideoBufferDataAuto: public VideoBufferData
-{
-       private:
-               T* data;
-
-       public:
-               VideoBufferDataAuto(T* d)
-               :data(d)
-               {}
-
-               virtual ~VideoBufferDataAuto()
-               {
-                       delete data;
-               }
-};
-
 ///The semsntics of the videobuffer. See VideoFrame::type()
 struct VideoBufferType
 {
@@ -139,16 +115,12 @@
                virtual void seek_to(double)
                {}
                
-               /// Certain video buffers, especially the decorator classes, 
and buffers
-               /// such as ServerPushJpegBuffer have additional data 
-               /// with the same lifetime as the buffer. This is a tool to 
allow management of
-               /// this data.
-               std::auto_ptr<VideoBufferData> extra_data;
 
        private:
                VideoBufferType::Type m_type;
 };
 
+
 namespace Exceptions
 {
        /// %Exceptions specific to VideoBuffer

Index: videosource.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videosource.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- videosource.h       11 Mar 2009 21:35:12 -0000      1.17
+++ videosource.h       23 Oct 2009 14:49:43 -0000      1.18
@@ -2,6 +2,7 @@
 #define VIDEOSOURCE_H
 
 #include <iostream>
+#include <fstream>
 #include <sstream>
 #include <string>
 #include <vector>
@@ -9,6 +10,7 @@
 
 #include <cvd/config.h>
 
+#include <cvd/videobufferwithdata.h>
 #include <cvd/readaheadvideobuffer.h>
 #include <cvd/colourspaces.h>
 
@@ -63,14 +65,10 @@
        using std::auto_ptr;
        using std::ifstream;
 
-       auto_ptr<ifstream> stream(new ifstream(filename.c_str()));
+       auto_ptr<std::ifstream> stream(new ifstream(filename.c_str()));
        
-       ServerPushJpegBuffer<T>* b = new ServerPushJpegBuffer<T>(*stream.get());
-       
-       auto_ptr<VideoBufferData> h(new 
VideoBufferDataAuto<ifstream>(stream.release()));
-
-       b->extra_data = h;
-       return b;
+       auto_ptr<VideoBuffer<T> > buf(static_cast<VideoBuffer<T>*>(new 
ServerPushJpegBuffer<T>(*stream)));
+       return new VideoBufferWithData<T, std::ifstream>(buf, stream);
     }
 
     template <> inline VideoBuffer<vuy422> * makeJPEGStream(const std::string&)
@@ -189,9 +187,7 @@
                else
                {
                        auto_ptr<VideoBuffer<T> > b(new 
ReadAheadVideoBuffer<T>(*(jpeg_buffer.get()), ra_frames));
-                       auto_ptr<VideoBufferData> h(new 
VideoBufferDataAuto<VideoBuffer<T> >(jpeg_buffer.release()));
-                       b->extra_data = h;
-                       return b.release();
+                       return new VideoBufferWithData<T, VideoBuffer<T> >(b, 
jpeg_buffer);
                }
        }
 #if CVD_HAVE_GLOB

Index: videobufferwithdata.h
===================================================================
RCS file: videobufferwithdata.h
diff -N videobufferwithdata.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ videobufferwithdata.h       23 Oct 2009 14:49:43 -0000      1.1
@@ -0,0 +1,87 @@
+/*                       
+       This file is part of the CVD Library.
+
+       Copyright (C) 2005 The Authors
+
+       This library is free software; you can redistribute it and/or
+       modify it under the terms of the GNU Lesser General Public
+       License as published by the Free Software Foundation; either
+       version 2.1 of the License, or (at your option) any later version.
+
+       This library 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
+       Lesser General Public License for more details.
+
+       You should have received a copy of the GNU Lesser General Public
+       License along with this library; if not, write to the Free Software
+       Foundation, Inc., 
+    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+#ifndef CVD_VIDEOBUFFERWITHDATA_H
+#define CVD_VIDEOBUFFERWITHDATA_H
+
+#include <cvd/videobuffer.h>
+#include <memory>
+
+namespace CVD {
+
+/// Certain video buffers, especially the decorator classes, and buffers
+/// such as ServerPushJpegBuffer have additional data 
+/// with the same lifetime as the buffer. This is a tool to allow management of
+/// this data. This class manages a video buffer and some data concurrently.
+/// @param T The pixel type of the video frames
+/// @ingroup gVideoBuffer
+template <class T, class D> 
+class VideoBufferWithData: public VideoBuffer<T> 
+{
+       public: 
+               VideoBufferWithData(std::auto_ptr<VideoBuffer<T> > buf_, 
std::auto_ptr<D> d)
+               :VideoBuffer<T>(buf->type()), buf(buf_),extra_data(d)
+               {}
+
+               ImageRef size()
+               {
+                       return buf->size();
+               }
+
+               VideoFrame<T>* get_frame()
+               {
+                       return buf->get_frame();
+               }
+
+               void put_frame(VideoFrame<T>* f)
+               {
+                       buf->put_frame(f);
+               }       
+
+               bool frame_pending()
+               {
+                       return buf->frame_pending();
+               }       
+
+               void flush()
+               {
+                       return buf->flush();
+               }       
+
+               double frame_rate()
+               {
+                       return buf->frame_rate();
+               }
+
+               double seek_to()
+               {
+                       return buf->seek_to();
+               }
+
+
+       private:
+               std::auto_ptr<VideoBuffer<T> > buf;
+       public:
+               std::auto_ptr<D> extra_data;
+};
+
+}
+
+#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]