2 Copyright (c) 2012, Broadcom Europe Ltd
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef INTERFACE_VC_IMAGE_STRUCTS_H
29 #define INTERFACE_VC_IMAGE_STRUCTS_H
31 /* This file gets included by the VCE compiler, which gets confused
32 * easily by the VCOS headers. So cannot include vcos.h here.
34 #include "interface/vcos/vcos_stdint.h"
35 #include "interface/vcos/vcos_attr.h"
37 #include "helpers/debug_utils/debug_writer.h"
39 #include "interface/vctypes/vc_image_types.h"
41 /* Format specific infos for vc images */
43 /* YUV information, co-sited h/v flags & colour space words */
45 VC_IMAGE_YUVINFO_UNSPECIFIED = 0, /* Unknown or unset - defaults to BT601 interstitial */
47 /* colour-space conversions data [4 bits] */
48 /* Note that colour conversions for SMPTE 170M are identical to BT.601 */
49 VC_IMAGE_YUVINFO_CSC_ITUR_BT601 = 1, /* ITU-R BT.601-5 [SDTV] (compatible with VideoCore-II) */
50 VC_IMAGE_YUVINFO_CSC_ITUR_BT709 = 2, /* ITU-R BT.709-3 [HDTV] */
51 VC_IMAGE_YUVINFO_CSC_JPEG_JFIF = 3, /* JPEG JFIF */
52 VC_IMAGE_YUVINFO_CSC_FCC = 4, /* Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
53 VC_IMAGE_YUVINFO_CSC_SMPTE_240M = 5, /* Society of Motion Picture and Television Engineers 240M (1999) */
54 VC_IMAGE_YUVINFO_CSC_ITUR_BT470_2_M = 6, /* ITU-R BT.470-2 System M */
55 VC_IMAGE_YUVINFO_CSC_ITUR_BT470_2_BG = 7, /* ITU-R BT.470-2 System B,G */
56 VC_IMAGE_YUVINFO_CSC_JPEG_JFIF_Y16_255 = 8, /* JPEG JFIF, but with 16..255 luma */
57 VC_IMAGE_YUVINFO_CSC_CUSTOM = 15, /* Custom colour matrix follows header */
58 VC_IMAGE_YUVINFO_CSC_SMPTE_170M = VC_IMAGE_YUVINFO_CSC_ITUR_BT601,
60 /* co-sited flags, assumed interstitial if not co-sited [2 bits] */
61 VC_IMAGE_YUVINFO_H_COSITED = 256,
62 VC_IMAGE_YUVINFO_V_COSITED = 512,
64 VC_IMAGE_YUVINFO_TOP_BOTTOM = 1024,
65 VC_IMAGE_YUVINFO_DECIMATED = 2048,
66 VC_IMAGE_YUVINFO_PACKED = 4096,
68 /* Certain YUV image formats can either be V/U interleaved or U/V interleaved */
69 VC_IMAGE_YUVINFO_IS_VU = 0x8000,
71 /* Force Metaware to use 16 bits */
72 VC_IMAGE_YUVINFO_FORCE_ENUM_16BIT = 0xffff,
75 #define VC_IMAGE_YUV_UV_STRIPE_WIDTH_LOG2 7
76 #define VC_IMAGE_YUV_UV_STRIPE_WIDTH (1 << VC_IMAGE_YUV_UV_STRIPE_WIDTH_LOG2)
78 #define VC_IMAGE_YUV_UV32_STRIPE_WIDTH_LOG2 5
79 #define VC_IMAGE_YUV_UV32_STRIPE_WIDTH (1 << VC_IMAGE_YUV_UV32_STRIPE_WIDTH_LOG2)
81 /* 64 pixel wide stripes, 128 byte wide as 16bits/component */
82 #define VC_IMAGE_YUV_UV_16_STRIPE_WIDTH_LOG2 6
83 #define VC_IMAGE_YUV_UV_16_STRIPE_WIDTH (1 << VC_IMAGE_YUV_UV_16_STRIPE_WIDTH_LOG2)
84 #define VC_IMAGE_YUV_UV_16_STRIPE_STRIDE_LOG2 7
85 #define VC_IMAGE_YUV_UV_16_STRIPE_STRIDE (1 << VC_IMAGE_YUV_UV_16_STRIPE_STRIDE_LOG2)
87 /* The image structure. */
88 typedef struct vc_image_extra_uv_s {
91 } VC_IMAGE_EXTRA_UV_T;
93 typedef struct vc_image_extra_rgba_s {
94 unsigned component_order : 24, /* diagnostic use only */
96 transparent_colour: 1,
99 } VC_IMAGE_EXTRA_RGBA_T;
101 typedef struct vc_image_extra_pal_s {
104 } VC_IMAGE_EXTRA_PAL_T;
106 // These fields are subject to change / being moved around
107 typedef struct vc_image_extra_tf_s {
108 signed int mipmap_levels : 8;
109 unsigned int xxx : 23;
110 unsigned int cube_map : 1;
112 } VC_IMAGE_EXTRA_TF_T;
114 typedef struct vc_image_extra_bayer_s {
115 unsigned short order;
116 unsigned short format;
118 } VC_IMAGE_EXTRA_BAYER_T;
120 //The next block can be used with Visual C++
121 //which treats enums as long ints
122 typedef struct vc_image_extra_msbayer_s {
124 unsigned char format;
125 unsigned char dummy1;
126 unsigned char dummy2;
128 } VC_IMAGE_EXTRA_MSBAYER_T;
130 typedef struct vc_image_extra_codec_s {
132 int maxsize; //NB this will be copied to image.size in parmalloc()
133 } VC_IMAGE_EXTRA_CODEC_T;
135 #define VC_IMAGE_OPENGL_RGBA32 0x14011908 //GL_UNSIGNED_BYTE GL_RGBA
136 #define VC_IMAGE_OPENGL_RGB24 0x14011907 //GL_UNSIGNED_BYTE GL_RGB
137 #define VC_IMAGE_OPENGL_RGBA16 0x80331908 //GL_UNSIGNED_SHORT_4_4_4_4 GL_RGBA
138 #define VC_IMAGE_OPENGL_RGBA5551 0x80341908 //GL_UNSIGNED_SHORT_5_5_5_1 GL_RGBA
139 #define VC_IMAGE_OPENGL_RGB565 0x83631907 //GL_UNSIGNED_SHORT_5_6_5 GL_RGB
140 #define VC_IMAGE_OPENGL_YA88 0x1401190A //GL_UNSIGNED_BYTE GL_LUMINANCE_ALPHA
141 #define VC_IMAGE_OPENGL_Y8 0x14011909 //GL_UNSIGNED_BYTE GL_LUMINANCE
142 #define VC_IMAGE_OPENGL_A8 0x14011906 //GL_UNSIGNED_BYTE GL_ALPHA
143 #define VC_IMAGE_OPENGL_ETC1 0x8D64 //GL_ETC1_RGB8_OES
144 #define VC_IMAGE_OPENGL_PALETTE4_RGB24 0x8B90 //GL_PALETTE4_RGB8_OES
145 #define VC_IMAGE_OPENGL_PALETTE4_RGBA32 0x8B91 //GL_PALETTE4_RGBA8_OES
146 #define VC_IMAGE_OPENGL_PALETTE4_RGB565 0x8B92 //GL_PALETTE4_R5_G6_B5_OES
147 #define VC_IMAGE_OPENGL_PALETTE4_RGBA16 0x8B93 //GL_PALETTE4_RGBA4_OES
148 #define VC_IMAGE_OPENGL_PALETTE4_RGB5551 0x8B94 //GL_PALETTE4_RGB5_A1_OES
149 #define VC_IMAGE_OPENGL_PALETTE8_RGB24 0x8B95 //GL_PALETTE8_RGB8_OES
150 #define VC_IMAGE_OPENGL_PALETTE8_RGBA32 0x8B96 //GL_PALETTE8_RGBA8_OES
151 #define VC_IMAGE_OPENGL_PALETTE8_RGB565 0x8B97 //GL_PALETTE8_R5_G6_B5_OES
152 #define VC_IMAGE_OPENGL_PALETTE8_RGBA16 0x8B98 //GL_PALETTE8_RGBA4_OES
153 #define VC_IMAGE_OPENGL_PALETTE8_RGB5551 0x8B99 //GL_PALETTE8_RGB5_A1_OES
155 typedef struct vc_image_extra_opengl_s {
156 unsigned int format_and_type;
158 } VC_IMAGE_EXTRA_OPENGL_T;
161 VC_IMAGE_EXTRA_UV_T uv;
162 VC_IMAGE_EXTRA_RGBA_T rgba;
163 VC_IMAGE_EXTRA_PAL_T pal;
164 VC_IMAGE_EXTRA_TF_T tf;
165 VC_IMAGE_EXTRA_BAYER_T bayer;
166 VC_IMAGE_EXTRA_MSBAYER_T msbayer;
167 VC_IMAGE_EXTRA_CODEC_T codec;
168 VC_IMAGE_EXTRA_OPENGL_T opengl;
171 /* structure containing various colour meta-data for each format */
174 VC_IMAGE_YUVINFO_T yuv; /* We know Metaware will use 16 bits for this enum, so use the correct type for debug info */
176 unsigned short yuv; /* Information pertinent to all YUV implementations */
178 unsigned short info; /* dummy, force size to min 16 bits */
183 * Image handle object, which must be locked before image data becomes
186 * A handle to an image where the image data does not have a guaranteed
187 * storage location. A call to \c vc_image_lock() must be made to convert
188 * this into a \c VC_IMAGE_BUF_T, which guarantees that image data can
189 * be accessed safely.
191 * This type will also be used in cases where it's unclear whether or not
192 * the buffer is already locked, and in legacy code.
196 VC_IMAGE_TYPE_T type; /* Metaware will use 16 bits for this enum
197 so use the correct type for debug info */
199 unsigned short type; /* should restrict to 16 bits */
201 VC_IMAGE_INFO_T info; /* format-specific info; zero for VC02 behaviour */
202 unsigned short width; /* width in pixels */
203 unsigned short height; /* height in pixels */
204 int pitch; /* pitch of image_data array in bytes */
205 int size; /* number of bytes available in image_data array */
206 void *image_data; /* pixel data */
207 VC_IMAGE_EXTRA_T extra; /* extra data like palette pointer */
208 struct vc_metadata_header_s *metadata; /* metadata header for the image */
209 struct opaque_vc_pool_object_s *pool_object; /* nonNULL if image was allocated from a vc_pool */
210 uint32_t mem_handle; /* the mem handle for relocatable memory storage */
211 int metadata_size; /* size of metadata of each channel in bytes */
212 int channel_offset; /* offset of consecutive channels in bytes */
213 uint32_t video_timestamp;/* 90000 Hz RTP times domain - derived from audio timestamp */
214 uint8_t num_channels; /* number of channels (2 for stereo) */
215 uint8_t current_channel;/* the channel this header is currently pointing to */
216 uint8_t linked_multichann_flag;/* Indicate the header has the linked-multichannel structure*/
217 uint8_t is_channel_linked; /* Track if the above structure is been used to link the header
218 into a linked-mulitchannel image */
219 uint8_t channel_index; /* index of the channel this header represents while
220 it is being linked. */
221 uint8_t _dummy[3]; /* pad struct to 64 bytes */
226 /* Currently battling with the size of enums when running through static analysis stage */
227 typedef int vc_image_t_size_check[(sizeof(VC_IMAGE_T) == 68) * 2 - 1];
229 /* compile time assert to ensure size of VC_IMAGE_T is as expected, if the
230 compiler kicks out a "negative subscript" message then the size
231 of VC_IMAGE_T is *not* 64 bytes, which is a problem ... */
232 typedef int vc_image_t_size_check[(sizeof(VC_IMAGE_T) == 64) * 2 - 1];
235 /******************************************************************************
236 Debugging rules (defined in camera_debug.c)
237 *****************************************************************************/
238 extern DEBUG_WRITE_ENUM_LOOKUP_T vc_image_type_lookup[];
239 extern DEBUG_WRITE_ENUM_LOOKUP_T vc_image_bayer_order_lookup[];
240 extern DEBUG_WRITE_ENUM_LOOKUP_T vc_image_bayer_format_lookup[];
241 extern DEBUG_WRITE_RULE_T vc_image_info_rule[];
242 extern DEBUG_WRITE_RULE_T vc_image_rule[];
244 #endif /* __VC_INCLUDE_IMAGE_TYPES_H__ */