1 // VaapiSubpicture.cpp: VA subpicture abstraction
3 // Copyright (C) 2009, 2010 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
20 #include <boost/format.hpp>
23 #include "VaapiSubpicture.h"
24 #include "VaapiGlobalContext.h"
25 #include "VaapiException.h"
26 #include "VaapiImage.h"
27 #include "vaapi_utils.h"
31 VaapiSubpicture::VaapiSubpicture(boost::shared_ptr
<VaapiImage
> image
)
33 , _subpicture(VA_INVALID_ID
)
35 log_debug("VaapiSubpicture::VaapiSubpicture(): format '%s'\n", string_of_FOURCC(image
->format()));
39 msg
= boost::format("Could not create %s subpicture")
40 % string_of_FOURCC(image
->format());
41 throw VaapiException(msg
.str());
45 VaapiSubpicture::~VaapiSubpicture()
47 GNASH_REPORT_FUNCTION
;
52 bool VaapiSubpicture::create()
54 GNASH_REPORT_FUNCTION
;
60 VaapiGlobalContext
* const gvactx
= VaapiGlobalContext::get();
65 VASubpictureID subpicture
;
66 VAStatus status
= vaCreateSubpicture(gvactx
->display(), _image
->get(), &subpicture
);
67 if (!vaapi_check_status(status
, "vaCreateSubpicture()")) {
71 _subpicture
= subpicture
;
75 void VaapiSubpicture::destroy()
77 VaapiGlobalContext
* const gvactx
= VaapiGlobalContext::get();
82 if (_subpicture
!= VA_INVALID_ID
) {
83 VAStatus status
= vaDestroySubpicture(gvactx
->display(), _subpicture
);
84 if (!vaapi_check_status(status
, "vaDestroySubpicture()"))
86 _subpicture
= VA_INVALID_ID
;
90 } // end of gnash namespace
94 // indent-tabs-mode: nil