Add missing newlines escape. Should fix build failures on lucid-linux-x86
[gnash.git] / libmedia / VideoConverter.h
blobc730e6d999bc611704f5208b5e2fa0079bfd8b95
1 // Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef GNASH_VIDEOCONVERTER_H
19 #define GNASH_VIDEOCONVERTER_H
21 #include <boost/noncopyable.hpp>
22 #include <boost/cstdint.hpp>
23 #include <memory>
25 namespace gnash {
26 namespace media {
30 /// Image buffer wrapper
32 /// Unfortunately, the GnashImage buffer class currently insists on owning
33 /// its buffer. Hacking around this results in things like gnashGstBuffer,
34 /// which is less than desirable. Furthermore, it only supports a handful of
35 /// pixel and image formats. Something more elaborate is needed to support the
36 /// various YUV formats and different bit depths for RGB. But in the mean time:
37 /// here's a simple image class for use in VideoConverter, at least until we
38 /// merge the image classes.
40 struct ImgBuf : public boost::noncopyable
42 typedef boost::uint32_t Type4CC;
43 typedef void (*FreeFunc)(void*);
45 ImgBuf(Type4CC t, boost::uint8_t* dataptr, size_t datasize, size_t w,
46 size_t h)
47 : type(t),
48 data(dataptr),
49 size(datasize),
50 width(w),
51 height(h),
52 dealloc(array_delete)
55 ~ImgBuf()
57 dealloc(data);
60 static void array_delete(void* voidptr)
62 boost::uint8_t* ptr = static_cast<boost::uint8_t*>(voidptr);
63 delete [] ptr;
66 static void noop(void* /*voidptr*/)
70 Type4CC type;
71 boost::uint8_t* data;
73 size_t size; // in bytes
74 size_t width; // in pixels
75 size_t height; // in pixels
77 size_t stride[4];
79 FreeFunc dealloc;
83 /// Abstract base class for video image space conversion.
85 class VideoConverter : public boost::noncopyable {
87 public:
88 VideoConverter(ImgBuf::Type4CC srcFormat, ImgBuf::Type4CC dstFormat)
89 : _src_fmt(srcFormat),
90 _dst_fmt(dstFormat)
94 virtual ~VideoConverter()
98 /// Convert a (video) image from one colorspace to another.
100 /// @param src the image to convert
101 /// @return the converted image or a NULL auto_ptr if an error occurred.
102 virtual std::auto_ptr<ImgBuf> convert(const ImgBuf& src) = 0;
104 protected:
105 ImgBuf::Type4CC _src_fmt;
106 ImgBuf::Type4CC _dst_fmt;
110 } // gnash.media namespace
111 } // gnash namespace
113 #endif // __VIDEOCONVERTER_H__