libcvd-members
[Top][All Lists]
Advanced

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

[libcvd-members] libcvd cvd/videosource.h cvd_src/videosource.cpp


From: Gerhard Reitmayr
Subject: [libcvd-members] libcvd cvd/videosource.h cvd_src/videosource.cpp
Date: Sun, 16 Dec 2007 19:18:39 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Gerhard Reitmayr <gerhard>      07/12/16 19:18:39

Modified files:
        cvd            : videosource.h 
        cvd_src        : videosource.cpp 

Log message:
        enabled open_video_source to work with qtbuffer

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videosource.h?cvsroot=libcvd&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videosource.cpp?cvsroot=libcvd&r1=1.1&r2=1.2

Patches:
Index: cvd/videosource.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videosource.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- cvd/videosource.h   30 Oct 2007 15:58:32 -0000      1.3
+++ cvd/videosource.h   16 Dec 2007 19:18:39 -0000      1.4
@@ -24,6 +24,10 @@
 #include <cvd/Linux/dvbuffer.h>
 #endif
 
+#if CVD_HAVE_QTBUFFER
+#include <cvd/OSX/qtbuffer.h>
+#endif
+
 namespace CVD {
     struct ParseException : public Exceptions::All
     {
@@ -51,6 +55,10 @@
     {
        return new DiskBuffer2<T>(files, fps, eob);    
     }
+    template <> inline VideoBuffer<vuy422> * makeDiskBuffer2(const 
std::vector<std::string>& files, double fps, VideoBufferFlags::OnEndOfBuffer 
eob)
+    {
+       throw VideoSourceException("DiskBuffer2 cannot handle type vuy422");
+    }
 
     void get_files_options(const VideoSource& vs, int& fps, int& ra_frames, 
VideoBufferFlags::OnEndOfBuffer& eob);
     
@@ -96,6 +104,16 @@
 
 #endif
 
+#if CVD_HAVE_QTBUFFER
+    template <class T> VideoBuffer<T> * makeQTBuffer( const ImageRef & size, 
int input)
+    {
+       throw VideoSourceException("QTBuffer cannot handle types other than 
vuy422");
+    }
+    template <> VideoBuffer<vuy422> * makeQTBuffer( const ImageRef & size, int 
input);
+    
+    void get_qt_options(const VideoSource & vs, ImageRef & size);
+#endif
+
     template <class T> VideoBuffer<T>* open_video_source(const VideoSource& vs)
     {
        if (vs.protocol == "files") {
@@ -135,6 +153,14 @@
            return vb;
        } 
 #endif
+#if CVD_HAVE_QTBUFFER
+    else if (vs.protocol == "qt") {
+        ImageRef size;
+        int input = atoi(vs.identifier.c_str());
+        get_qt_options(vs, size);
+        return makeQTBuffer<T>(size, input);
+    }
+#endif
        else
            throw VideoSourceException("undefined video source protocol: '" + 
vs.protocol + "'\n\t valid protocols: "
 #if CVD_HAVE_FFMPEG
@@ -146,6 +172,9 @@
 #if CVD_HAVE_DVBUFFER
                                       "dc1394, "
 #endif
+#if CVD_HAVE_QTBUFFER
+                                      "qt, "
+#endif
                                       "files");
     }
 

Index: cvd_src/videosource.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videosource.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/videosource.cpp     28 Sep 2006 17:14:48 -0000      1.1
+++ cvd_src/videosource.cpp     16 Dec 2007 19:18:39 -0000      1.2
@@ -360,4 +360,32 @@
    }
 #endif
 
+#if CVD_HAVE_QTBUFFER
+    template <> VideoBuffer<vuy422> * makeQTBuffer( const ImageRef & size, int 
input)
+    {
+        return new CVD::QTBuffer<vuy422>(size, input);
+    }
+    
+    void get_qt_options(const VideoSource & vs, ImageRef & size){
+       size = ImageRef(640, 480);
+       for (VideoSource::option_list::const_iterator it=vs.options.begin(); it 
!= vs.options.end(); ++it) {
+               if (it->first == "size") {
+               std::string s = it->second;
+               tolower(s);
+               if (s == "vga")
+                   size = ImageRef(640,480);
+               else if (s == "qvga")
+                   size = ImageRef(320,240);
+               else {
+                   std::istringstream size_in(s);
+                   char x;
+                   if (!(size_in >> size.x >> x >> size.y))
+                       throw ParseException("invalid image size specification: 
'"+it->second+"'\n\t valid specs: vga, qvga, <width>x<height>");
+               }
+           } else
+               throw VideoSourceException("invalid option for 'qt' protocol: 
"+it->first+"\n\t valid options: size");
+       }
+    }
+#endif
+
 }




reply via email to

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