1 // vaapi_utils.cpp: VA API utilities
3 // Copyright (C) 2009, 2010, 2011 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 "vaapi_utils.h"
26 static bool g_vaapi_is_enabled
= false;
28 // Enable video acceleration (with VA API)
29 void vaapi_set_is_enabled(bool enabled
)
31 g_vaapi_is_enabled
= enabled
;
34 // Check whether video acceleration is enabled
35 bool vaapi_is_enabled()
37 return g_vaapi_is_enabled
;
41 void DSOEXPORT
vaapi_dprintf(const char *format
, ...)
44 va_start(args
, format
);
45 fprintf(stdout
, "[GnashVaapi] ");
46 vfprintf(stdout
, format
, args
);
50 // Check VA status for success or print out an error
51 bool vaapi_check_status(VAStatus status
, const char *msg
)
53 if (status
!= VA_STATUS_SUCCESS
) {
54 vaapi_dprintf("%s: %s\n", msg
, vaErrorStr(status
));
60 /// Return a string representation of a FOURCC
61 const char *string_of_FOURCC(boost::uint32_t fourcc
)
64 static char str
[2][5]; // XXX: 2 buffers should be enough for most purposes
68 str
[buf
][1] = fourcc
>> 8;
69 str
[buf
][2] = fourcc
>> 16;
70 str
[buf
][3] = fourcc
>> 24;
75 // Return a string representation of a VAProfile
76 const char *string_of_VAProfile(VAProfile profile
)
79 #define PROFILE(profile) \
80 case VAProfile##profile: return "VAProfile" #profile
84 PROFILE(MPEG4AdvancedSimple
);
86 PROFILE(H264Baseline
);
98 // Return a string representation of a VAEntrypoint
99 const char *string_of_VAEntrypoint(VAEntrypoint entrypoint
)
101 switch (entrypoint
) {
102 #define ENTRYPOINT(entrypoint) \
103 case VAEntrypoint##entrypoint: return "VAEntrypoint" #entrypoint
108 ENTRYPOINT(Deblocking
);
115 } // end of gnash namespace
119 // indent-tabs-mode: nil