00001 /* 00002 This file is part of the CVD Library. 00003 00004 Copyright (C) 2005 The Authors 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 00019 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 // PAS 17/6/04 (revised 16/2/05) 00022 00023 #ifndef __CVD_DEINTERLACEBUFFER_H 00024 #define __CVD_DEINTERLACEBUFFER_H 00025 00026 #include <cvd/localvideobuffer.h> 00027 #include <cvd/image_convert.h> 00028 #include <cvd/colourspace_convert.h> 00029 #include <cvd/colourspace_frame.h> 00030 00031 namespace CVD 00032 { 00052 template <class T, class From> class ColourspaceBuffer : public CVD::LocalVideoBuffer<T> 00053 { 00054 public: 00057 ColourspaceBuffer(CVD::VideoBuffer<From>& buf) 00058 :LocalVideoBuffer<T>(buf.type()),m_vidbuf(buf),m_size(buf.size()) 00059 { 00060 } 00061 00063 ImageRef size() 00064 { 00065 return m_size; 00066 } 00067 00068 virtual bool frame_pending() 00069 { 00070 return m_vidbuf.frame_pending(); 00071 } 00072 00073 virtual void seek_to(double t) 00074 { 00075 return m_vidbuf.seek_to(t); 00076 } 00077 00078 virtual double frame_rate() 00079 { 00080 return m_vidbuf.frame_rate(); 00081 } 00082 00083 virtual CVD::ColourspaceFrame<T>* get_frame() 00084 { 00085 VideoFrame<From>* fr = m_vidbuf.get_frame(); 00086 Image<T> cv = convert_image<T>(*fr); 00087 00088 ColourspaceFrame<T>* ret = new ColourspaceFrame<T>(fr->timestamp(), cv); 00089 00090 m_vidbuf.put_frame(fr); 00091 00092 return ret; 00093 } 00094 00095 virtual void put_frame(CVD::VideoFrame<T>* f) 00096 { 00097 //Check that the type is correct... 00098 ColourspaceFrame<T>* csf = dynamic_cast<ColourspaceFrame<T>*>(f); 00099 00100 if(csf == NULL) 00101 throw CVD::Exceptions::VideoBuffer::BadPutFrame(); 00102 else 00103 delete csf; 00104 } 00105 00106 private: 00107 CVD::VideoBuffer<From>& m_vidbuf; 00108 ImageRef m_size; 00109 }; 00110 00111 00113 template <class T, class From> class ColourspaceBuffer_managed : public ColourspaceBuffer<T, From> 00114 { 00115 public: 00118 ColourspaceBuffer_managed(CVD::VideoBuffer<From>* buf) 00119 :ColourspaceBuffer<T,From>(*buf),vb(buf) 00120 { 00121 } 00122 00123 ~ColourspaceBuffer_managed() 00124 { 00125 delete vb; 00126 } 00127 00128 private: 00129 VideoBuffer<From>* vb; 00130 00131 }; 00132 00133 } 00134 #endif