1 // vaapi.h: VA API acceleration.
3 // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
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 #ifndef GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H
20 #define GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H
22 #include "VaapiContext.h"
23 #include "VaapiSurface.h"
24 #include "VaapiSurfaceProxy.h"
27 #include <libavcodec/avcodec.h>
28 #include <libavcodec/vaapi.h>
35 /// VA surface implementation for FFmpeg
36 class VaapiSurfaceFfmpeg
: public VaapiSurfaceProxy
{
37 unsigned int _pic_num
;
40 VaapiSurfaceFfmpeg(boost::shared_ptr
<VaapiSurface
> surface
,
41 boost::shared_ptr
<VaapiContext
> context
)
42 : VaapiSurfaceProxy(surface
, context
), _pic_num(0)
45 unsigned int getPicNum() const
48 void setPicNum(unsigned int pic_num
)
49 { _pic_num
= pic_num
; }
52 void vaapi_set_surface(AVFrame
*pic
, VaapiSurfaceFfmpeg
*surface
);
54 static inline VaapiSurfaceFfmpeg
*vaapi_get_surface(const AVFrame
*pic
)
56 return reinterpret_cast<VaapiSurfaceFfmpeg
*>(pic
->data
[0]);
59 /// VA context implementation for FFmpeg
60 class VaapiContextFfmpeg
: public vaapi_context
{
61 boost::shared_ptr
<VaapiContext
> _context
;
64 VaapiContextFfmpeg(enum CodecID codec_id
);
66 bool initDecoder(unsigned int width
, unsigned int height
);
68 VaapiSurfaceFfmpeg
*getSurface()
69 { return new VaapiSurfaceFfmpeg(_context
->acquireSurface(), _context
); }
71 static VaapiContextFfmpeg
*create(enum CodecID codec_id
);
74 } // gnash.media.ffmpeg namespace
75 } // gnash.media namespace
78 #endif /* GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H */