1 // VaapiImageFormat.h: VA image format abstraction
2 //
3 // Copyright (C) 2009, 2010, 2011, 2012 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
18 //
19 
20 #ifndef GNASH_VAAPIIMAGEFORMAT_H
21 #define GNASH_VAAPIIMAGEFORMAT_H
22 
23 #include "dsodefs.h"
24 #include "vaapi_common.h"
25 
26 /// Color spaces
27 enum VaapiColorspace {
28     VAAPI_COLORSPACE_UNKNOWN,   /// Unknown colorspace
29     VAAPI_COLORSPACE_YUV,       /// YUV colorspace
30     VAAPI_COLORSPACE_RGB        /// RGB colorspace
31 };
32 
33 /// Image types
34 enum VaapiImageFormat {
35     /// Best format for the underlying hardware
36     VAAPI_IMAGE_NONE  = 0,
37     /// Planar YUV 4:2:0, 12-bit, 1 plane for Y and 1 plane for UV
38     VAAPI_IMAGE_NV12  = VA_FOURCC('N','V','1','2'),
39     /// Planar YUV 4:2:0, 12-bit, 3 planes for Y V U
40     VAAPI_IMAGE_YV12  = VA_FOURCC('Y','V','1','2'),
41     /// Planar YUV 4:2:0, 12-bit, 3 planes for Y U V
42     VAAPI_IMAGE_I420  = VA_FOURCC('I','4','2','0'),
43     /// Packed RGB 8:8:8, 32-bit, A R G B
44     VAAPI_IMAGE_ARGB  = VA_FOURCC('A','R','G','B'),
45     /// Packed RGB 8:8:8, 32-bit, R G B A
46     VAAPI_IMAGE_RGBA  = VA_FOURCC('R','G','B','A'),
47     /// Packed RGB 8:8:8, 32-bit, A R G B
48     VAAPI_IMAGE_ABGR  = VA_FOURCC('A','B','G','R'),
49     /// Packed RGB 8:8:8, 32-bit, R G B A
50     VAAPI_IMAGE_BGRA  = VA_FOURCC('B','G','R','A'),
51     /// Packed RGB 8:8:8, 32-bit, A R G B, native endian byte-order
52     VAAPI_IMAGE_RGB32 = VA_FOURCC('R','G','B', 32),
53     /// Packed RGB 8:8:8, 24-bit, R G B
54     VAAPI_IMAGE_RGB24 = VA_FOURCC('R','G','B', 24)
55 };
56 
57 /// Get colorspace for the specified image format
58 VaapiColorspace DSOEXPORT
59 vaapi_image_format_get_colorspace(VaapiImageFormat format);
60 
61 /// Check whether image format is RGB
vaapi_image_format_is_rgb(VaapiImageFormat format)62 static inline bool vaapi_image_format_is_rgb(VaapiImageFormat format)
63 {
64     return vaapi_image_format_get_colorspace(format) == VAAPI_COLORSPACE_RGB;
65 }
66 
67 /// Check whether image format is YUV
vaapi_image_format_is_yuv(VaapiImageFormat format)68 static inline bool vaapi_image_format_is_yuv(VaapiImageFormat format)
69 {
70     return vaapi_image_format_get_colorspace(format) == VAAPI_COLORSPACE_YUV;
71 }
72 
73 /// Return image format from a VA image format
74 VaapiImageFormat vaapi_get_image_format(VAImageFormat const &format);
75 
76 #endif // GNASH_VAAPIIMAGEFORMAT_H
77 
78 // local Variables:
79 // mode: C++
80 // indent-tabs-mode: nil
81 // End:
82 
83 
84