Gnash  0.8.11dev
VideoDecoderFfmpegVaapi.h
Go to the documentation of this file.
1 // vaapi.h: VA API acceleration.
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_MEDIA_VIDEODECODERFFMPEGVAAPI_H
21 #define GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H
22 
23 #include "VaapiContext.h"
24 #include "VaapiSurface.h"
25 #include "VaapiSurfaceProxy.h"
26 
27 extern "C" {
28 #include <libavcodec/avcodec.h>
29 #include <libavcodec/vaapi.h>
30 }
31 
32 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,18,102)
33 #define CODECID AVCodecID
34 #else
35 #define CODECID CodecID
36 #endif
37 
38 namespace gnash {
39 namespace media {
40 namespace ffmpeg {
41 
44  unsigned int _pic_num;
45 
46 public:
47  VaapiSurfaceFfmpeg(std::shared_ptr<VaapiSurface> surface,
48  std::shared_ptr<VaapiContext> context)
49  : VaapiSurfaceProxy(surface, context), _pic_num(0)
50  { }
51 
52  unsigned int getPicNum() const
53  { return _pic_num; }
54 
55  void setPicNum(unsigned int pic_num)
56  { _pic_num = pic_num; }
57 };
58 
59 void vaapi_set_surface(AVFrame *pic, VaapiSurfaceFfmpeg *surface);
60 
61 static inline VaapiSurfaceFfmpeg *vaapi_get_surface(const AVFrame *pic)
62 {
63  return reinterpret_cast<VaapiSurfaceFfmpeg *>(pic->data[0]);
64 }
65 
67 class VaapiContextFfmpeg : public vaapi_context {
68  std::shared_ptr<VaapiContext> _context;
69 
70 public:
71  VaapiContextFfmpeg(enum CODECID codec_id);
72 
73  bool initDecoder(unsigned int width, unsigned int height);
74 
76  { return new VaapiSurfaceFfmpeg(_context->acquireSurface(), _context); }
77 
78  static VaapiContextFfmpeg *create(enum CODECID codec_id);
79 };
80 
81 } // gnash.media.ffmpeg namespace
82 } // gnash.media namespace
83 } // gnash namespace
84 
85 #endif /* GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H */
gnash::VaapiContext
VA context abstraction.
Definition: VaapiContext.h:51
height
@ height
Definition: klash_part.cpp:329
gnash::VaapiGlobalContext
VA API global context.
Definition: VaapiGlobalContext.h:33
gnash::media::ffmpeg::VaapiSurfaceFfmpeg::VaapiSurfaceFfmpeg
VaapiSurfaceFfmpeg(std::shared_ptr< VaapiSurface > surface, std::shared_ptr< VaapiContext > context)
Definition: VideoDecoderFfmpegVaapi.h:47
CODECID
#define CODECID
Definition: ffmpegHeaders.h:137
gnash::VaapiSurfaceProxy::get
std::shared_ptr< VaapiSurface > get() const
Return VA surface.
Definition: VaapiSurfaceProxy.h:43
gnash::VaapiGlobalContext::display
VADisplay display() const
Get the VA display.
Definition: VaapiGlobalContext.h:71
gnash::key::i
@ i
Definition: GnashKey.h:155
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::VaapiSurfaceProxy
VA surface proxy used to release surface to context.
Definition: VaapiSurfaceProxy.h:33
gnash::media::ffmpeg::VaapiContextFfmpeg
VA context implementation for FFmpeg.
Definition: VideoDecoderFfmpegVaapi.h:67
gnash::media::ffmpeg::VaapiContextFfmpeg::initDecoder
bool initDecoder(unsigned int width, unsigned int height)
Definition: VideoDecoderFfmpegVaapi.cpp:103
gnash::VaapiGlobalContext::get
static VaapiGlobalContext * get()
Get the unique global VA context.
Definition: VaapiGlobalContext.cpp:130
VaapiContext.h
CODECID
#define CODECID
Definition: VideoDecoderFfmpegVaapi.h:33
gnash::media::ffmpeg::VaapiContextFfmpeg::VaapiContextFfmpeg
VaapiContextFfmpeg(enum CODECID codec_id)
Definition: VideoDecoderFfmpegVaapi.cpp:97
gnash::media::ffmpeg::VaapiSurfaceFfmpeg::setPicNum
void setPicNum(unsigned int pic_num)
Definition: VideoDecoderFfmpegVaapi.h:55
gnash::media::ffmpeg::VaapiContextFfmpeg::create
static VaapiContextFfmpeg * create(enum CODECID codec_id)
Definition: VideoDecoderFfmpegVaapi.cpp:117
VideoDecoderFfmpegVaapi.h
VaapiGlobalContext.h
gnash::media::ffmpeg::VaapiContextFfmpeg::getSurface
VaapiSurfaceFfmpeg * getSurface()
Definition: VideoDecoderFfmpegVaapi.h:75
VaapiSurface.h
gnash::vaapi_is_enabled
bool vaapi_is_enabled()
Check whether video acceleration is enabled.
Definition: vaapi_utils.cpp:35
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
VaapiSurfaceProxy.h
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
width
@ width
Definition: klash_part.cpp:329
gnash::media::ffmpeg::VaapiSurfaceFfmpeg::getPicNum
unsigned int getPicNum() const
Definition: VideoDecoderFfmpegVaapi.h:52
GnashException.h