Gnash
0.8.10
|
00001 // vaapi.h: VA API acceleration. 00002 // 00003 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 00004 // Free Software Foundation, Inc. 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 00020 #ifndef GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H 00021 #define GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H 00022 00023 #include "VaapiContext.h" 00024 #include "VaapiSurface.h" 00025 #include "VaapiSurfaceProxy.h" 00026 00027 extern "C" { 00028 #include <libavcodec/avcodec.h> 00029 #include <libavcodec/vaapi.h> 00030 } 00031 00032 namespace gnash { 00033 namespace media { 00034 namespace ffmpeg { 00035 00037 class VaapiSurfaceFfmpeg : public VaapiSurfaceProxy { 00038 unsigned int _pic_num; 00039 00040 public: 00041 VaapiSurfaceFfmpeg(boost::shared_ptr<VaapiSurface> surface, 00042 boost::shared_ptr<VaapiContext> context) 00043 : VaapiSurfaceProxy(surface, context), _pic_num(0) 00044 { } 00045 00046 unsigned int getPicNum() const 00047 { return _pic_num; } 00048 00049 void setPicNum(unsigned int pic_num) 00050 { _pic_num = pic_num; } 00051 }; 00052 00053 void vaapi_set_surface(AVFrame *pic, VaapiSurfaceFfmpeg *surface); 00054 00055 static inline VaapiSurfaceFfmpeg *vaapi_get_surface(const AVFrame *pic) 00056 { 00057 return reinterpret_cast<VaapiSurfaceFfmpeg *>(pic->data[0]); 00058 } 00059 00061 class VaapiContextFfmpeg : public vaapi_context { 00062 boost::shared_ptr<VaapiContext> _context; 00063 00064 public: 00065 VaapiContextFfmpeg(enum CodecID codec_id); 00066 00067 bool initDecoder(unsigned int width, unsigned int height); 00068 00069 VaapiSurfaceFfmpeg *getSurface() 00070 { return new VaapiSurfaceFfmpeg(_context->acquireSurface(), _context); } 00071 00072 static VaapiContextFfmpeg *create(enum CodecID codec_id); 00073 }; 00074 00075 } // gnash.media.ffmpeg namespace 00076 } // gnash.media namespace 00077 } // gnash namespace 00078 00079 #endif /* GNASH_MEDIA_VIDEODECODERFFMPEGVAAPI_H */