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 00062 virtual RawVideoBuffer* source_buffer() 00063 { 00064 return &m_vidbuf; 00065 } 00066 00068 ImageRef size() 00069 { 00070 return m_size; 00071 } 00072 00073 virtual bool frame_pending() 00074 { 00075 return m_vidbuf.frame_pending(); 00076 } 00077 00078 virtual void seek_to(double t) 00079 { 00080 return m_vidbuf.seek_to(t); 00081 } 00082 00083 virtual double frame_rate() 00084 { 00085 return m_vidbuf.frame_rate(); 00086 } 00087 00088 virtual CVD::ColourspaceFrame<T>* get_frame() 00089 { 00090 VideoFrame<From>* fr = m_vidbuf.get_frame(); 00091 Image<T> cv = convert_image<T>(*fr); 00092 00093 ColourspaceFrame<T>* ret = new ColourspaceFrame<T>(fr->timestamp(), cv); 00094 00095 m_vidbuf.put_frame(fr); 00096 00097 return ret; 00098 } 00099 00100 virtual void put_frame(CVD::VideoFrame<T>* f) 00101 { 00102 //Check that the type is correct... 00103 ColourspaceFrame<T>* csf = dynamic_cast<ColourspaceFrame<T>*>(f); 00104 00105 if(csf == NULL) 00106 throw CVD::Exceptions::VideoBuffer::BadPutFrame(); 00107 else 00108 delete csf; 00109 } 00110 00111 private: 00112 CVD::VideoBuffer<From>& m_vidbuf; 00113 ImageRef m_size; 00114 }; 00115 00116 00118 template <class T, class From> class ColourspaceBuffer_managed : public ColourspaceBuffer<T, From> 00119 { 00120 public: 00123 ColourspaceBuffer_managed(CVD::VideoBuffer<From>* buf) 00124 :ColourspaceBuffer<T,From>(*buf),vb(buf) 00125 { 00126 } 00127 00128 ~ColourspaceBuffer_managed() 00129 { 00130 delete vb; 00131 } 00132 00133 private: 00134 VideoBuffer<From>* vb; 00135 00136 }; 00137 00138 } 00139 #endif