Since we're logging an error for missing _interfaceHandler (which we maybe shuldn...
[gnash.git] / libvaapi / vaapi_utils.cpp
blobd41d975fee5ff58c98cd426e907887541b7a18d2
1 // vaapi_utils.cpp: VA API utilities
2 //
3 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 //
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.
9 //
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.
14 //
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"
21 #include <stdio.h>
22 #include <stdarg.h>
24 namespace gnash {
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;
40 // Debug output
41 void DSOEXPORT vaapi_dprintf(const char *format, ...)
43 va_list args;
44 va_start(args, format);
45 fprintf(stdout, "[GnashVaapi] ");
46 vfprintf(stdout, format, args);
47 va_end(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));
55 return false;
57 return true;
60 /// Return a string representation of a FOURCC
61 const char *string_of_FOURCC(boost::uint32_t fourcc)
63 static int buf;
64 static char str[2][5]; // XXX: 2 buffers should be enough for most purposes
66 buf ^= 1;
67 str[buf][0] = fourcc;
68 str[buf][1] = fourcc >> 8;
69 str[buf][2] = fourcc >> 16;
70 str[buf][3] = fourcc >> 24;
71 str[buf][4] = '\0';
72 return str[buf];
75 // Return a string representation of a VAProfile
76 const char *string_of_VAProfile(VAProfile profile)
78 switch (profile) {
79 #define PROFILE(profile) \
80 case VAProfile##profile: return "VAProfile" #profile
81 PROFILE(MPEG2Simple);
82 PROFILE(MPEG2Main);
83 PROFILE(MPEG4Simple);
84 PROFILE(MPEG4AdvancedSimple);
85 PROFILE(MPEG4Main);
86 PROFILE(H264Baseline);
87 PROFILE(H264Main);
88 PROFILE(H264High);
89 PROFILE(VC1Simple);
90 PROFILE(VC1Main);
91 PROFILE(VC1Advanced);
92 #undef PROFILE
93 default: break;
95 return "<unknown>";
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
104 ENTRYPOINT(VLD);
105 ENTRYPOINT(IZZ);
106 ENTRYPOINT(IDCT);
107 ENTRYPOINT(MoComp);
108 ENTRYPOINT(Deblocking);
109 #undef ENTRYPOINT
110 default: break;
112 return "<unknown>";
115 } // end of gnash namespace
117 // local Variables:
118 // mode: C++
119 // indent-tabs-mode: nil
120 // End: