1 // Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
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.
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>
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
,
60 static void array_delete(void* voidptr
)
62 boost::uint8_t* ptr
= static_cast<boost::uint8_t*>(voidptr
);
66 static void noop(void* /*voidptr*/)
73 size_t size
; // in bytes
74 size_t width
; // in pixels
75 size_t height
; // in pixels
83 /// Abstract base class for video image space conversion.
85 class VideoConverter
: public boost::noncopyable
{
88 VideoConverter(ImgBuf::Type4CC srcFormat
, ImgBuf::Type4CC dstFormat
)
89 : _src_fmt(srcFormat
),
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;
105 ImgBuf::Type4CC _src_fmt
;
106 ImgBuf::Type4CC _dst_fmt
;
110 } // gnash.media namespace
113 #endif // __VIDEOCONVERTER_H__