1 /* 2 * GStreamer 3 * Copyright (C) 2016 Matthew Waters <matthew@centricular.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library 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 GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_VULKAN_FORMAT_H__ 22 #define __GST_VULKAN_FORMAT_H__ 23 24 #include <gst/vulkan/vulkan.h> 25 26 G_BEGIN_DECLS 27 28 typedef struct _GstVulkanFormatInfo GstVulkanFormatInfo; 29 30 /** 31 * GST_VULKAN_MAX_COMPONENTS: 32 * 33 * Since: 1.18 34 */ 35 #define GST_VULKAN_MAX_COMPONENTS 4 36 37 /** 38 * GstVulkanFormatScaling: 39 * @GST_VULKAN_FORMAT_SCALING_UNORM: [0, 2^n - 1] -> [0.0, 1.0] 40 * @GST_VULKAN_FORMAT_SCALING_SNORM: [-2^(n-1), 2^(n-1) - 1] -> [-1.0, 1.0] 41 * @GST_VULKAN_FORMAT_SCALING_USCALED: [0, 2^n - 1] -> [0.0, float(2^n - 1)] 42 * @GST_VULKAN_FORMAT_SCALING_SSCALED: [-2^(n-1), 2^(n-1) - 1] -> [float(-2^(n-1)), float(2^(n-1) - 1)] 43 * @GST_VULKAN_FORMAT_SCALING_UINT: [0, 2^n - 1] -> [0, 2^n - 1] 44 * @GST_VULKAN_FORMAT_SCALING_SINT: [-2^(n-1), 2^(n-1) - 1] -> [-2^(n-1), 2^(n-1) - 1] 45 * @GST_VULKAN_FORMAT_SCALING_SRGB: @GST_VULKAN_FORMAT_SCALING_UNORM but the first three components are gamma corrected for the sRGB colour space. 46 * 47 * Since: 1.18 48 */ 49 typedef enum 50 { 51 GST_VULKAN_FORMAT_SCALING_UNORM = 1, 52 GST_VULKAN_FORMAT_SCALING_SNORM, 53 GST_VULKAN_FORMAT_SCALING_USCALED, 54 GST_VULKAN_FORMAT_SCALING_SSCALED, 55 GST_VULKAN_FORMAT_SCALING_UINT, 56 GST_VULKAN_FORMAT_SCALING_SINT, 57 GST_VULKAN_FORMAT_SCALING_SRGB, 58 } GstVulkanFormatScaling; 59 60 /** 61 * GstVulkanFormatFlags: 62 * @GST_VULKAN_FORMAT_FLAG_YUV: is a YUV format 63 * @GST_VULKAN_FORMAT_FLAG_RGB: is a RGB format 64 * @GST_VULKAN_FORMAT_FLAG_ALPHA: has an alpha channel 65 * @GST_VULKAN_FORMAT_FLAG_LE: data is stored in little-endiate byte order 66 * @GST_VULKAN_FORMAT_FLAG_COMPLEX: data is stored complex and cannot be read/write only using the information in the #GstVulkanFormatInfo 67 * 68 * Since: 1.18 69 */ 70 typedef enum 71 { 72 GST_VULKAN_FORMAT_FLAG_YUV = (1 << 0), 73 GST_VULKAN_FORMAT_FLAG_RGB = (1 << 1), 74 GST_VULKAN_FORMAT_FLAG_ALPHA = (1 << 2), 75 GST_VULKAN_FORMAT_FLAG_LE = (1 << 3), 76 GST_VULKAN_FORMAT_FLAG_COMPLEX = (1 << 4), 77 } GstVulkanFormatFlags; 78 79 /** 80 * GstVulkanFormatInfo: 81 * @format: the Vulkan format being described 82 * @name: name of this format 83 * @scaling: how raw data is interpreted and scaled 84 * @flags: flags that apply to this format 85 * @bits: The number of bits used to pack data items. This can be less than 86 * 8 when multiple pixels are stored in a byte. for values > 8 multiple 87 * bytes should be read according to the endianness flag before 88 * applying the shift and mask. 89 * @n_components; number of components in this format 90 * @shift: the number of bits to shift away to get the component data 91 * @depth: the depth in bits for each component 92 * @n_planes: the number of planes for this format. The number of planes can 93 * be less than the amount of components when multiple components 94 * are packed into one plane. 95 * @plane: the plane number where a component can be found 96 * @poffset: the offset in the plane where the first pixel of the components 97 * can be found. 98 * @w_sub: subsampling factor of the width for the component. 99 * Use GST_VIDEO_SUB_SCALE to scale a width. 100 * @h_sub: subsampling factor of the height for the component. 101 * Use GST_VIDEO_SUB_SCALE to scale a height. 102 * 103 * Since: 1.18 104 */ 105 struct _GstVulkanFormatInfo 106 { 107 VkFormat format; 108 const gchar *name; 109 GstVulkanFormatScaling scaling; 110 GstVulkanFormatFlags flags; 111 guint bits; 112 guint n_components; 113 guint8 shift[GST_VULKAN_MAX_COMPONENTS]; 114 guint8 depth[GST_VULKAN_MAX_COMPONENTS]; 115 gint8 pixel_stride[GST_VULKAN_MAX_COMPONENTS]; 116 guint n_planes; 117 guint8 plane[GST_VULKAN_MAX_COMPONENTS]; 118 guint8 poffset[GST_VULKAN_MAX_COMPONENTS]; 119 guint8 w_sub[GST_VULKAN_MAX_COMPONENTS]; 120 guint8 h_sub[GST_VULKAN_MAX_COMPONENTS]; 121 }; 122 123 GST_VULKAN_API 124 const GstVulkanFormatInfo * gst_vulkan_format_get_info (VkFormat format); 125 126 G_END_DECLS 127 128 #endif /* __GST_VULKAN_FORMAT_H__ */ 129