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 */
#define CODECID
Definition: VideoDecoderFfmpegVaapi.h:33
VA surface implementation for FFmpeg.
Definition: VideoDecoderFfmpegVaapi.h:43
VaapiSurfaceFfmpeg * getSurface()
Definition: VideoDecoderFfmpegVaapi.h:75
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
void vaapi_set_surface(AVFrame *pic, VaapiSurfaceFfmpeg *surface)
Attach VA surface to FFmpeg picture.
Definition: VideoDecoderFfmpegVaapi.cpp:84
Definition: klash_part.cpp:329
unsigned int getPicNum() const
Definition: VideoDecoderFfmpegVaapi.h:52
VA context implementation for FFmpeg.
Definition: VideoDecoderFfmpegVaapi.h:67
Definition: klash_part.cpp:329
VaapiSurfaceFfmpeg(std::shared_ptr< VaapiSurface > surface, std::shared_ptr< VaapiContext > context)
Definition: VideoDecoderFfmpegVaapi.h:47
void setPicNum(unsigned int pic_num)
Definition: VideoDecoderFfmpegVaapi.h:55
VA surface proxy used to release surface to context.
Definition: VaapiSurfaceProxy.h:33