1 // VaapiImageFormat.cpp: 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 #include "VaapiImageFormat.h"
21 
22 // Get colorspace for the specified image format
vaapi_image_format_get_colorspace(VaapiImageFormat format)23 VaapiColorspace vaapi_image_format_get_colorspace(VaapiImageFormat format)
24 {
25     switch (format) {
26     case VAAPI_IMAGE_NV12:
27     case VAAPI_IMAGE_YV12:
28     case VAAPI_IMAGE_I420:
29         return VAAPI_COLORSPACE_YUV;
30     case VAAPI_IMAGE_ARGB:
31     case VAAPI_IMAGE_RGBA:
32     case VAAPI_IMAGE_ABGR:
33     case VAAPI_IMAGE_BGRA:
34     case VAAPI_IMAGE_RGB32:
35     case VAAPI_IMAGE_RGB24:
36         return VAAPI_COLORSPACE_RGB;
37     default:;
38     }
39     return VAAPI_COLORSPACE_UNKNOWN;
40 }
41 
42 // Return image format from a VA image format
vaapi_get_image_format(VAImageFormat const & format)43 VaapiImageFormat vaapi_get_image_format(VAImageFormat const &format)
44 {
45     // XXX: check RGB formats and endianess
46     return static_cast<VaapiImageFormat>(format.fourcc);
47 }
48 
49 // local Variables:
50 // mode: C++
51 // indent-tabs-mode: nil
52 // End:
53 
54