Gnash  0.8.10
VideoConverter.h
Go to the documentation of this file.
00001 //
00002 //   Copyright (C) 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc.
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 
00020 #ifndef GNASH_VIDEOCONVERTER_H
00021 #define GNASH_VIDEOCONVERTER_H
00022 
00023 #include <boost/noncopyable.hpp>
00024 #include <boost/cstdint.hpp>
00025 #include <boost/array.hpp>
00026 #include <memory>
00027 
00028 namespace gnash {
00029 namespace media {
00030 
00031 
00032 
00034 //
00042 
00043 struct ImgBuf : public boost::noncopyable
00044 {
00045     typedef boost::uint32_t Type4CC;
00046     typedef void (*FreeFunc)(void*);
00047 
00048     ImgBuf(Type4CC t, boost::uint8_t* dataptr, size_t datasize, size_t w,
00049            size_t h)
00050     : type(t),
00051       data(dataptr),
00052       size(datasize),
00053       width(w),
00054       height(h),
00055       dealloc(array_delete)
00056     {}
00057     
00058     ~ImgBuf()
00059     {
00060         dealloc(data);
00061     }
00062     
00063     static void array_delete(void* voidptr)
00064     {
00065         boost::uint8_t* ptr = static_cast<boost::uint8_t*>(voidptr);
00066         delete [] ptr;
00067     }
00068     
00069     static void noop(void* /*voidptr*/)
00070     {
00071     }
00072 
00073     Type4CC type;
00074     boost::uint8_t* data;
00075 
00076     size_t size; // in bytes
00077     size_t width; // in pixels
00078     size_t height; // in pixels
00079     
00080     boost::array<size_t, 4> stride;
00081     
00082     FreeFunc dealloc;
00083 };
00084 
00085 
00087 
00088 class VideoConverter : public boost::noncopyable {
00089 
00090 public:
00091     VideoConverter(ImgBuf::Type4CC srcFormat, ImgBuf::Type4CC dstFormat)
00092      : _src_fmt(srcFormat),
00093        _dst_fmt(dstFormat) 
00094     {
00095     }
00096     
00097     virtual ~VideoConverter()
00098     {
00099     }
00100   
00102     //
00105     virtual std::auto_ptr<ImgBuf> convert(const ImgBuf& src) = 0;
00106   
00107 protected:
00108     ImgBuf::Type4CC  _src_fmt;
00109     ImgBuf::Type4CC  _dst_fmt;
00110 };
00111 
00112         
00113 } // gnash.media namespace 
00114 } // gnash namespace
00115 
00116 #endif // __VIDEOCONVERTER_H__