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 namespace gnash {
33 namespace media {
34 namespace ffmpeg {
35 
38  unsigned int _pic_num;
39 
40 public:
41  VaapiSurfaceFfmpeg(boost::shared_ptr<VaapiSurface> surface,
42  boost::shared_ptr<VaapiContext> context)
43  : VaapiSurfaceProxy(surface, context), _pic_num(0)
44  { }
45 
46  unsigned int getPicNum() const
47  { return _pic_num; }
48 
49  void setPicNum(unsigned int pic_num)
50  { _pic_num = pic_num; }
51 };
52 
53 void vaapi_set_surface(AVFrame *pic, VaapiSurfaceFfmpeg *surface);
54 
55 static inline VaapiSurfaceFfmpeg *vaapi_get_surface(const AVFrame *pic)
56 {
57  return reinterpret_cast<VaapiSurfaceFfmpeg *>(pic->data[0]);
58 }
59 
61 class VaapiContextFfmpeg : public vaapi_context {
62  boost::shared_ptr<VaapiContext> _context;
63 
64 public:
65  VaapiContextFfmpeg(enum CodecID codec_id);
66 
67  bool initDecoder(unsigned int width, unsigned int height);
68 
70  { return new VaapiSurfaceFfmpeg(_context->acquireSurface(), _context); }
71 
72  static VaapiContextFfmpeg *create(enum CodecID codec_id);
73 };
74 
75 } // gnash.media.ffmpeg namespace
76 } // gnash.media namespace
77 } // gnash namespace
78 
79 #endif /* GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H */