10
10
// This program is distributed in the hope that it will be useful,
11
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
// GNU General Public License for more details.
15
15
// You should have received a copy of the GNU General Public License
16
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
// $Id: VideoDecoderFfmpeg.h,v 1.1.2.2 2008/02/27 20:55:02 bjacques Exp $
21
#ifndef __VIDEODECODERFFMPEG_H__
22
#define __VIDEODECODERFFMPEG_H__
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef GNASH_VIDEODECODERFFMPEG_H
21
#define GNASH_VIDEODECODERFFMPEG_H
24
23
#ifdef HAVE_CONFIG_H
25
24
#include "gnashconfig.h"
28
#include "dsodefs.h" //For DSOEXPORT
29
30
#include "VideoDecoder.h"
32
#include <ffmpeg/avcodec.h>
31
#include "MediaParser.h" // for videoCodecType enum
32
#include "ffmpegHeaders.h"
39
/// Forward declarations
40
class CodecContextWrapper;
42
class SwsContextWrapper;
40
46
class VideoDecoderFfmpeg : public VideoDecoder {
43
VideoDecoderFfmpeg(videoCodecType format, int width, int height);
44
~VideoDecoderFfmpeg();
46
void push(const EncodedVideoFrame& buffer);
48
std::auto_ptr<image::rgb> pop();
53
/// \brief converts an video frame from (almost) any type to RGB24.
55
/// @param srcCtx The source context that was used to decode srcFrame.
56
/// @param srcFrame the source frame to be converted.
57
/// @return an AVPicture containing the converted image. Please be advised
58
/// that the RGB data pointer is stored in AVPicture::data[0]. The
59
/// caller owns that pointer, which must be freed with delete [].
60
/// It is advised to wrap the pointer in a boost::scoped_array.
61
/// If conversion fails, AVPicture::data[0] will be NULL.
62
static AVPicture convertRGB24(AVCodecContext* srcCtx, const AVFrame& srcFrame);
66
std::auto_ptr<image::rgb> decode(boost::uint8_t* input, boost::uint32_t input_size);
70
AVCodecContext* _videoCodecCtx;
71
std::vector<const EncodedVideoFrame*> _video_frames;
50
DSOEXPORT VideoDecoderFfmpeg(videoCodecType format, int width, int height);
52
DSOEXPORT VideoDecoderFfmpeg(VideoInfo& info);
54
DSOEXPORT ~VideoDecoderFfmpeg();
56
void push(const EncodedVideoFrame& buffer);
58
std::auto_ptr<image::ImageBase> pop();
63
/// \brief converts an video frame from (almost) any type to RGB24.
65
/// @param srcCtx The source context that was used to decode srcFrame.
66
/// @param srcFrame the source frame to be converted.
67
/// @return an AVPicture containing the converted image. Please be advised
68
/// that the RGB data pointer is stored in AVPicture::data[0]. The
69
/// caller owns that pointer, which must be freed with delete [].
70
/// It is advised to wrap the pointer in a boost::scoped_array.
71
/// If conversion fails, AVPicture::data[0] will be NULL.
72
std::auto_ptr<image::ImageBase> frameToImage(AVCodecContext* srcCtx, const AVFrame& srcFrame);
74
/// Convert FLASH codec id to FFMPEG codec id
76
/// @return CODEC_ID_NONE for unsupported flash codecs
78
DSOEXPORT static enum CodecID flashToFfmpegCodec(videoCodecType format);
82
void init(enum CodecID format, int width, int height, boost::uint8_t* extradata=0, int extradataSize=0);
84
std::auto_ptr<image::ImageBase> decode(const boost::uint8_t* input, boost::uint32_t input_size);
86
std::auto_ptr<image::ImageBase> decode(const EncodedVideoFrame* vf)
88
return decode(vf->data(), vf->dataSize());
92
std::auto_ptr<CodecContextWrapper> _videoCodecCtx;
95
/// A pointer to a wrapper round an SwsContext
97
/// This is constructed with a SwsContext*, which
98
/// can be NULL, so it is important to check
99
/// not only that the wrapper exists, but also
100
/// the context inside it.
101
std::auto_ptr<SwsContextWrapper> _swsContext;
104
std::vector<const EncodedVideoFrame*> _video_frames;
74
107
} // gnash.media namespace
75
108
} // gnash namespace