Gnash  0.8.11dev
VideoDecoderFfmpeg.h
Go to the documentation of this file.
1 // VideoDecoderFfmpeg.h: Video decoding using the FFMPEG library.
2 //
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef GNASH_VIDEODECODERFFMPEG_H
21 #define GNASH_VIDEODECODERFFMPEG_H
22 
23 #ifdef HAVE_CONFIG_H
24 #include "gnashconfig.h"
25 #endif
26 
27 #include <vector>
28 #include <memory>
29 #include "dsodefs.h" //For DSOEXPORT
30 #include "VideoDecoder.h"
31 #include "MediaParser.h" // for videoCodecType enum
32 #include "ffmpegHeaders.h"
33 
34 namespace gnash {
35 namespace media {
36 namespace ffmpeg {
37 
38 // Forward declarations
39 class CodecContextWrapper;
40 #ifdef HAVE_SWSCALE_H
41 class SwsContextWrapper;
42 #endif
43 
44 
47 
48 public:
49 
51 
53 
55 
56  void push(const EncodedVideoFrame& buffer);
57 
58  std::unique_ptr<image::GnashImage> pop();
59 
60  bool peek();
61 
62  int width() const;
63 
64  int height() const;
65 
66 private:
67 
69  //
72  static CODECID flashToFfmpegCodec(videoCodecType format);
73 
83  std::unique_ptr<image::GnashImage> frameToImage(AVCodecContext* srcCtx,
84  const AVFrame& srcFrame);
85 
86  void init(enum CODECID format, int width, int height,
87  std::uint8_t* extradata=nullptr, int extradataSize=0);
88 
89  std::unique_ptr<image::GnashImage> decode(const std::uint8_t* input,
90  std::uint32_t input_size);
91 
92  std::unique_ptr<image::GnashImage> decode(const EncodedVideoFrame* vf)
93  {
94  return decode(vf->data(), vf->dataSize());
95  }
96 
97  AVCodec* _videoCodec;
98  std::unique_ptr<CodecContextWrapper> _videoCodecCtx;
99 
100 #if HAVE_SWSCALE_H
101  //
107  std::unique_ptr<SwsContextWrapper> _swsContext;
108 #endif
109 
110  std::vector<const EncodedVideoFrame*> _video_frames;
111 };
112 
113 } // gnash.media.ffmpeg namespace
114 } // gnash.media namespace
115 } // gnash namespace
116 
117 #endif // __VIDEODECODERFFMPEG_H__
VideoDecoderFfmpeg.h
gnash::media::ffmpeg::ExtraVideoInfoFfmpeg::dataSize
size_t dataSize
Definition: MediaParserFfmpeg.h:70
ffmpegHeaders.h
height
@ height
Definition: klash_part.cpp:329
FRAMEALLOC
#define FRAMEALLOC
Definition: ffmpegHeaders.h:126
CODECID
#define CODECID
Definition: ffmpegHeaders.h:137
gnash::VaapiSurfaceProxy::get
std::shared_ptr< VaapiSurface > get() const
Return VA surface.
Definition: VaapiSurfaceProxy.h:43
dsodefs.h
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
gnash::key::i
@ i
Definition: GnashKey.h:155
gnash::media::VideoDecoder
Abstract base class for embedded video decoders.
Definition: VideoDecoder.h:46
_
#define _(String)
Definition: log.h:44
gnash::media::VIDEO_CODEC_VP6A
@ VIDEO_CODEC_VP6A
On2 VP6 Alpha video codec.
Definition: MediaParser.h:90
gnash::media::VIDEO_CODEC_SCREENVIDEO
@ VIDEO_CODEC_SCREENVIDEO
Screenvideo codec.
Definition: MediaParser.h:84
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::media::VIDEO_CODEC_H263
@ VIDEO_CODEC_H263
H263/SVQ3 video codec.
Definition: MediaParser.h:81
gnash::media::ffmpeg::VaapiContextFfmpeg
VA context implementation for FFmpeg.
Definition: VideoDecoderFfmpegVaapi.h:67
gnash::media::ffmpeg::VideoDecoderFfmpeg::push
void push(const EncodedVideoFrame &buffer)
Push an encoded video frame into the decoder.
Definition: VideoDecoderFfmpeg.cpp:396
AV_PIX_FMT_NONE
#define AV_PIX_FMT_NONE
Definition: ffmpegHeaders.h:205
gnash::media::VideoInfo
Information about a video stream.
Definition: MediaParser.h:323
utility.h
FrameDeleter
Definition: ffmpegHeaders.h:128
AV_PIX_FMT_RGB24
#define AV_PIX_FMT_RGB24
Definition: ffmpegHeaders.h:206
gnash::media::VideoInfo::extra
std::unique_ptr< ExtraInfo > extra
Extra info about video stream, if when needed.
Definition: MediaParser.h:388
gnash::media::ffmpeg::ExtraVideoInfoFfmpeg
Extra info found in video stream by the parser.
Definition: MediaParserFfmpeg.h:61
gnash::GnashVaapiImage
GnashImage implementation using a VA surface.
Definition: GnashVaapiImage.h:36
gnash::media::VIDEO_CODEC_H264
@ VIDEO_CODEC_H264
MPEG-4 Part 10, or Advanced Video Coding.
Definition: MediaParser.h:96
UNUSED
#define UNUSED(x)
Definition: utility.h:113
AV_PIX_FMT_RGBA
#define AV_PIX_FMT_RGBA
Definition: ffmpegHeaders.h:207
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::media::EncodedVideoFrame::data
const std::uint8_t * data() const
Return pointer to actual data. Ownership retained by this class.
Definition: MediaParser.h:431
gnash::media::ffmpeg::VideoDecoderFfmpeg::~VideoDecoderFfmpeg
DSOEXPORT ~VideoDecoderFfmpeg()
Definition: VideoDecoderFfmpeg.cpp:231
gnash::media::ExtraVideoInfoFlv::size
size_t size
Video stream header size.
Definition: FLVParser.h:68
FLVParser.h
gnash::media::ExtraVideoInfoFlv::data
std::unique_ptr< std::uint8_t[]> data
Video stream header.
Definition: FLVParser.h:65
gnash::media::EncodedVideoFrame::dataSize
std::uint32_t dataSize() const
Return size of data buffer.
Definition: MediaParser.h:434
gnash::media::ffmpeg::VaapiContextFfmpeg::VaapiContextFfmpeg
VaapiContextFfmpeg(enum CODECID codec_id)
Definition: VideoDecoderFfmpegVaapi.cpp:97
gnash::media::VIDEO_CODEC_VP6
@ VIDEO_CODEC_VP6
On2 VP6 video codec.
Definition: MediaParser.h:87
GnashVaapiImage.h
gnash::media::VideoInfo::type
codecType type
Definition: MediaParser.h:372
AVPixelFormat
#define AVPixelFormat
Definition: ffmpegHeaders.h:189
gnash::media::ffmpeg::ExtraVideoInfoFfmpeg::data
std::uint8_t * data
Definition: MediaParserFfmpeg.h:69
MediaParser.h
gnash::media::CODEC_TYPE_FLASH
@ CODEC_TYPE_FLASH
The internal flash codec ids.
Definition: MediaParser.h:68
VideoDecoder.h
gnash::media::ffmpeg::VaapiContextFfmpeg::create
static VaapiContextFfmpeg * create(enum CODECID codec_id)
Definition: VideoDecoderFfmpegVaapi.cpp:117
gnash::media::VideoInfo::height
std::uint16_t height
Definition: MediaParser.h:369
VideoDecoderFfmpegVaapi.h
MediaParserFfmpeg.h
gnash::media::EncodedVideoFrame
An encoded video frame.
Definition: MediaParser.h:403
gnash::media::ffmpeg::VideoDecoderFfmpeg::width
int width() const
Get the width in pixels of the Video.
Definition: VideoDecoderFfmpeg.cpp:236
AV_PIX_FMT_VAAPI_VLD
#define AV_PIX_FMT_VAAPI_VLD
Definition: ffmpegHeaders.h:208
gnash::vaapi_is_enabled
bool vaapi_is_enabled()
Check whether video acceleration is enabled.
Definition: vaapi_utils.cpp:35
gnash::media::VideoInfo::codec
int codec
Definition: MediaParser.h:367
gnash::media::ffmpeg::VideoDecoderFfmpeg
FFMPEG based VideoDecoder.
Definition: VideoDecoderFfmpeg.h:46
gnash::media::videoCodecType
videoCodecType
Video codec ids as defined in flash.
Definition: MediaParser.h:76
gnash::media::ffmpeg::VideoDecoderFfmpeg::peek
bool peek()
Check whether a decoded frame is ready to be popped.
Definition: VideoDecoderFfmpeg.cpp:416
gnash::media::ffmpeg::VaapiSurfaceFfmpeg
VA surface implementation for FFmpeg.
Definition: VideoDecoderFfmpegVaapi.h:43
gnash::media::ffmpeg::vaapi_set_surface
void vaapi_set_surface(AVFrame *pic, VaapiSurfaceFfmpeg *surface)
Attach VA surface to FFmpeg picture.
Definition: VideoDecoderFfmpegVaapi.cpp:84
gnashconfig.h
gnash::media::ffmpeg::VideoDecoderFfmpeg::height
int height() const
Get the height in pixels of the Video.
Definition: VideoDecoderFfmpeg.cpp:243
gnash::media::VideoInfo::width
std::uint16_t width
Definition: MediaParser.h:368
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::media::ffmpeg::VideoDecoderFfmpeg::VideoDecoderFfmpeg
DSOEXPORT VideoDecoderFfmpeg(videoCodecType format, int width, int height)
Definition: VideoDecoderFfmpeg.cpp:118
gnash::media::ffmpeg::VideoDecoderFfmpeg::pop
std::unique_ptr< image::GnashImage > pop()
Pop a decoded frame from the decoder. THIS METHOD MAY BLOCK.
Definition: VideoDecoderFfmpeg.cpp:402
width
@ width
Definition: klash_part.cpp:329
gnash::media::ExtraVideoInfoFlv
Extra video info found in some FLV embedded streams.
Definition: FLVParser.h:44
vaapi_utils.h
GnashException.h
gnash::MediaException
An exception from MediaHandler subsystem.
Definition: GnashException.h:50
gnash::image::TYPE_RGBA
@ TYPE_RGBA
Definition: GnashImage.h:50