1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef KHRN_INT_IMAGE_H
29#define KHRN_INT_IMAGE_H
30
31#include "interface/khronos/common/khrn_int_util.h"
32
33/******************************************************************************
34formats
35******************************************************************************/
36
37typedef enum {
38 /*
39 layout of KHRN_IMAGE_FORMAT_T bits
40
41 When changing this, remember to change
42 middleware/khronos/common/2708/khrn_image_4.inc too
43 */
44
45 IMAGE_FORMAT_MEM_LAYOUT_MASK = 0x7 << 0,
46 IMAGE_FORMAT_MEM_LAYOUT_SHIFT = 0,
47 IMAGE_FORMAT_MEM_LAYOUT_BC = 3,
48
49 IMAGE_FORMAT_RSO = 0 << 0, /* raster scan order */
50 IMAGE_FORMAT_BRCM1 = 1 << 0,
51 IMAGE_FORMAT_BRCM2 = 2 << 0,
52 IMAGE_FORMAT_BRCM3 = 3 << 0,
53 IMAGE_FORMAT_BRCM4 = 4 << 0,
54
55 IMAGE_FORMAT_COMP_MASK = 0x3 << 6,
56
57 IMAGE_FORMAT_UNCOMP = 0 << 6,
58 IMAGE_FORMAT_ETC1 = 1 << 6,
59 IMAGE_FORMAT_YUYV = 3 << 6,
60
61 /* uncomp */
62
63 IMAGE_FORMAT_PIXEL_SIZE_MASK = 0x7 << 3,
64 IMAGE_FORMAT_PIXEL_SIZE_SHIFT = 3,
65
66 IMAGE_FORMAT_1 = 0 << 3,
67 IMAGE_FORMAT_4 = 1 << 3,
68 IMAGE_FORMAT_8 = 2 << 3,
69 IMAGE_FORMAT_16 = 3 << 3,
70 IMAGE_FORMAT_24 = 4 << 3,
71 IMAGE_FORMAT_32 = 5 << 3,
72 IMAGE_FORMAT_64 = 6 << 3,
73
74 IMAGE_FORMAT_PIXEL_TYPE_MASK = 0x3 << 8,
75
76 IMAGE_FORMAT_COLOR = 0 << 8,
77 IMAGE_FORMAT_PALETTE = 1 << 8,
78 IMAGE_FORMAT_SAMPLE = 2 << 8,
79 IMAGE_FORMAT_DEPTH = 3 << 8, /* packed z and stencil */
80
81 /* uncomp, color */
82
83 IMAGE_FORMAT_RGB = 1 << 10,
84 IMAGE_FORMAT_L = 1 << 11,
85 IMAGE_FORMAT_A = 1 << 12,
86
87 IMAGE_FORMAT_XBGRX = 0 << 13, /* r in low bits */
88 IMAGE_FORMAT_XRGBX = 1 << 13, /* r in high bits */
89
90 IMAGE_FORMAT_YUYV_STD = 0 << 13, /* Standard ordering */
91 IMAGE_FORMAT_YUYV_REV = 1 << 13, /* Reversed (UYVY) ordering */
92
93 IMAGE_FORMAT_AX = 0 << 14, /* alpha/x in high bits */
94 IMAGE_FORMAT_XA = 1 << 14, /* alpha/x in low bits */
95
96 IMAGE_FORMAT_PIXEL_LAYOUT_MASK = 0x7 << 15,
97
98 /* pixel size used to differentiate between eg 4444 and 8888 */
99 /* unspecified (0) means one channel occupying entire pixel */
100 /* IMAGE_FORMAT_32 */
101 IMAGE_FORMAT_8888 = 1 << 15,
102 /* IMAGE_FORMAT_24 */
103 IMAGE_FORMAT_888 = 1 << 15,
104 /* IMAGE_FORMAT_16 */
105 IMAGE_FORMAT_4444 = 1 << 15,
106 IMAGE_FORMAT_5551 = 2 << 15, /* (or 1555) */
107 IMAGE_FORMAT_565 = 3 << 15,
108 IMAGE_FORMAT_88 = 4 << 15,
109
110 IMAGE_FORMAT_PRE = 1 << 18, /* premultiplied (for vg) */
111 IMAGE_FORMAT_LIN = 1 << 19, /* linear (for vg) */
112
113 /* uncomp, depth */
114
115 IMAGE_FORMAT_Z = 1 << 10,
116 IMAGE_FORMAT_STENCIL = 1 << 11,
117
118 /*
119 some IMAGE_FORMAT_Ts
120
121 Components are listed with the most significant bits first.
122
123 On little-endian systems, it is as if a pixel was loaded as a little-endian
124 integer. This means they are in the *opposite* order to how they appear in memory (e.g. in ABGR_8888
125 format, the first byte would be the red component of the first pixel).
126
127 On big-endian systems, it is as if a pixel was loaded as a big-endian integer.
128 This means that the components are written in the same order that they appear in
129 memory (e.g. in ABGR_8888 format, the first byte would be alpha).
130 */
131
132 #define IMAGE_FORMAT_PACK(A, B, C, D, E, F, G, H, I) \
133 (IMAGE_FORMAT_##A | IMAGE_FORMAT_##B | IMAGE_FORMAT_##C | IMAGE_FORMAT_##D | IMAGE_FORMAT_##E | \
134 IMAGE_FORMAT_##F | IMAGE_FORMAT_##G | IMAGE_FORMAT_##H | IMAGE_FORMAT_##I)
135 #define IMAGE_FORMAT__ 0
136
137 RGBA_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, A, XRGBX, XA, 8888),
138 BGRA_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, A, XBGRX, XA, 8888),
139 ARGB_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, A, XRGBX, AX, 8888),
140 ABGR_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, A, XBGRX, AX, 8888),
141 RGBX_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, _, XRGBX, XA, 8888),
142 BGRX_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, _, XBGRX, XA, 8888),
143 XRGB_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, _, XRGBX, AX, 8888),
144 XBGR_8888 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, COLOR , RGB, _, XBGRX, AX, 8888),
145 RGB_888 = IMAGE_FORMAT_PACK(_, UNCOMP, 24, COLOR , RGB, _, XRGBX, _ , 888 ),
146 BGR_888 = IMAGE_FORMAT_PACK(_, UNCOMP, 24, COLOR , RGB, _, XBGRX, _ , 888 ),
147 RGBA_4444 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XRGBX, XA, 4444),
148 BGRA_4444 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XBGRX, XA, 4444),
149 ARGB_4444 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XRGBX, AX, 4444),
150 ABGR_4444 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XBGRX, AX, 4444),
151 RGBA_5551 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XRGBX, XA, 5551),
152 BGRA_5551 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XBGRX, XA, 5551),
153 ARGB_1555 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XRGBX, AX, 5551),
154 ABGR_1555 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, A, XBGRX, AX, 5551),
155 RGB_565 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, _, XRGBX, _ , 565 ),
156 BGR_565 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , RGB, _, XBGRX, _ , 565 ),
157 LA_88 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , L , A, _ , XA, 88 ),
158 AL_88 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, COLOR , L , A, _ , AX, 88 ),
159 L_8 = IMAGE_FORMAT_PACK(_, UNCOMP, 8 , COLOR , L , _, _ , _ , _ ),
160 L_1 = IMAGE_FORMAT_PACK(_, UNCOMP, 1 , COLOR , L , _, _ , _ , _ ),
161 A_8 = IMAGE_FORMAT_PACK(_, UNCOMP, 8 , COLOR , _ , A, _ , _ , _ ),
162 A_4 = IMAGE_FORMAT_PACK(_, UNCOMP, 4 , COLOR , _ , A, _ , _ , _ ),
163 A_1 = IMAGE_FORMAT_PACK(_, UNCOMP, 1 , COLOR , _ , A, _ , _ , _ ),
164 PALETTE_4 = IMAGE_FORMAT_PACK(_, UNCOMP, 4 , PALETTE, _ , _, _ , _ , _ ),
165 SAMPLE_16 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, SAMPLE , _ , _, _ , _ , _ ),
166 SAMPLE_8 = IMAGE_FORMAT_PACK(_, UNCOMP, 8 , SAMPLE , _ , _, _ , _ , _ ),
167 DEPTH_32 = IMAGE_FORMAT_PACK(_, UNCOMP, 32, DEPTH , Z, STENCIL, _, _ , _ ),
168 DEPTH_16 = IMAGE_FORMAT_PACK(_, UNCOMP, 16, DEPTH , Z, _ , _, _ , _ ),
169 ETC1 = IMAGE_FORMAT_PACK(_, ETC1 , _ , _ , _ , _, _ , _ , _ ),
170 DEPTH_64 = IMAGE_FORMAT_PACK(_, UNCOMP, 64, DEPTH , Z, STENCIL, _, _ , _ ),
171 YUV_422 = IMAGE_FORMAT_PACK(_, YUYV , _ , _ , _ , _, YUYV_STD , _ , _ ),
172 YUV_422_REV = IMAGE_FORMAT_PACK(_, YUYV , _ , _ , _ , _, YUYV_REV , _ , _ ),
173
174 #undef IMAGE_FORMAT__
175 #undef IMAGE_FORMAT_PACK
176
177 /* texture unit formats */
178 ABGR_8888_TF = ABGR_8888 | IMAGE_FORMAT_BRCM1,
179 ARGB_8888_TF = ARGB_8888 | IMAGE_FORMAT_BRCM1,
180 RGBA_8888_TF = RGBA_8888 | IMAGE_FORMAT_BRCM1,
181 XBGR_8888_TF = XBGR_8888 | IMAGE_FORMAT_BRCM1,
182 XRGB_8888_TF = XRGB_8888 | IMAGE_FORMAT_BRCM1,
183 RGBX_8888_TF = RGBX_8888 | IMAGE_FORMAT_BRCM1,
184 RGBA_4444_TF = RGBA_4444 | IMAGE_FORMAT_BRCM1,
185 RGBA_5551_TF = RGBA_5551 | IMAGE_FORMAT_BRCM1,
186 RGB_565_TF = RGB_565 | IMAGE_FORMAT_BRCM1,
187 BGR_565_TF = BGR_565 | IMAGE_FORMAT_BRCM1,
188 L_8_TF = L_8 | IMAGE_FORMAT_BRCM1,
189 A_8_TF = A_8 | IMAGE_FORMAT_BRCM1,
190 AL_88_TF = AL_88 | IMAGE_FORMAT_BRCM1,
191 LA_88_TF = LA_88 | IMAGE_FORMAT_BRCM1,
192 ETC1_TF = ETC1 | IMAGE_FORMAT_BRCM1,
193 PALETTE_4_TF = PALETTE_4 | IMAGE_FORMAT_BRCM1,
194 SAMPLE_8_TF = SAMPLE_8 | IMAGE_FORMAT_BRCM1,
195 SAMPLE_16_TF = SAMPLE_16 | IMAGE_FORMAT_BRCM1,
196 L_1_TF = L_1 | IMAGE_FORMAT_BRCM1,
197 A_4_TF = A_4 | IMAGE_FORMAT_BRCM1,
198 A_1_TF = A_1 | IMAGE_FORMAT_BRCM1,
199 DEPTH_16_TF = DEPTH_16 | IMAGE_FORMAT_BRCM1,
200 DEPTH_32_TF = DEPTH_32 | IMAGE_FORMAT_BRCM1,
201
202 /* their linear T equivalents */
203 ABGR_8888_LT = ABGR_8888 | IMAGE_FORMAT_BRCM2,
204 ARGB_8888_LT = ARGB_8888 | IMAGE_FORMAT_BRCM2,
205 RGBA_8888_LT = RGBA_8888 | IMAGE_FORMAT_BRCM2,
206 XBGR_8888_LT = XBGR_8888 | IMAGE_FORMAT_BRCM2,
207 XRGB_8888_LT = XRGB_8888 | IMAGE_FORMAT_BRCM2,
208 RGBX_8888_LT = RGBX_8888 | IMAGE_FORMAT_BRCM2,
209 RGBA_4444_LT = RGBA_4444 | IMAGE_FORMAT_BRCM2,
210 RGBA_5551_LT = RGBA_5551 | IMAGE_FORMAT_BRCM2,
211 RGB_565_LT = RGB_565 | IMAGE_FORMAT_BRCM2,
212 L_8_LT = L_8 | IMAGE_FORMAT_BRCM2,
213 A_8_LT = A_8 | IMAGE_FORMAT_BRCM2,
214 AL_88_LT = AL_88 | IMAGE_FORMAT_BRCM2,
215 LA_88_LT = LA_88 | IMAGE_FORMAT_BRCM2,
216 ETC1_LT = ETC1 | IMAGE_FORMAT_BRCM2,
217 PALETTE_4_LT = PALETTE_4 | IMAGE_FORMAT_BRCM2,
218 SAMPLE_8_LT = SAMPLE_8 | IMAGE_FORMAT_BRCM2,
219 SAMPLE_16_LT = SAMPLE_16 | IMAGE_FORMAT_BRCM2,
220 L_1_LT = L_1 | IMAGE_FORMAT_BRCM2,
221 A_4_LT = A_4 | IMAGE_FORMAT_BRCM2,
222 A_1_LT = A_1 | IMAGE_FORMAT_BRCM2,
223 DEPTH_16_LT = DEPTH_16 | IMAGE_FORMAT_BRCM2,
224 DEPTH_32_LT = DEPTH_32 | IMAGE_FORMAT_BRCM2,
225
226 /* some raster order formats */
227 RGBA_8888_RSO = RGBA_8888 | IMAGE_FORMAT_RSO,
228 BGRA_8888_RSO = BGRA_8888 | IMAGE_FORMAT_RSO,
229 ARGB_8888_RSO = ARGB_8888 | IMAGE_FORMAT_RSO,
230 ABGR_8888_RSO = ABGR_8888 | IMAGE_FORMAT_RSO,
231 RGBX_8888_RSO = RGBX_8888 | IMAGE_FORMAT_RSO,
232 BGRX_8888_RSO = BGRX_8888 | IMAGE_FORMAT_RSO,
233 XRGB_8888_RSO = XRGB_8888 | IMAGE_FORMAT_RSO,
234 XBGR_8888_RSO = XBGR_8888 | IMAGE_FORMAT_RSO,
235 BGR_888_RSO = BGR_888 | IMAGE_FORMAT_RSO,
236 RGB_888_RSO = RGB_888 | IMAGE_FORMAT_RSO,
237 RGBA_4444_RSO = RGBA_4444 | IMAGE_FORMAT_RSO,
238 BGRA_4444_RSO = BGRA_4444 | IMAGE_FORMAT_RSO,
239 ARGB_4444_RSO = ARGB_4444 | IMAGE_FORMAT_RSO,
240 ABGR_4444_RSO = ABGR_4444 | IMAGE_FORMAT_RSO,
241 RGBA_5551_RSO = RGBA_5551 | IMAGE_FORMAT_RSO,
242 BGRA_5551_RSO = BGRA_5551 | IMAGE_FORMAT_RSO,
243 ARGB_1555_RSO = ARGB_1555 | IMAGE_FORMAT_RSO,
244 ABGR_1555_RSO = ABGR_1555 | IMAGE_FORMAT_RSO,
245 RGB_565_RSO = RGB_565 | IMAGE_FORMAT_RSO,
246 BGR_565_RSO = BGR_565 | IMAGE_FORMAT_RSO,
247 AL_88_RSO = AL_88 | IMAGE_FORMAT_RSO,
248 LA_88_RSO = LA_88 | IMAGE_FORMAT_RSO,
249 L_8_RSO = L_8 | IMAGE_FORMAT_RSO,
250 L_1_RSO = L_1 | IMAGE_FORMAT_RSO,
251 A_8_RSO = A_8 | IMAGE_FORMAT_RSO,
252 A_4_RSO = A_4 | IMAGE_FORMAT_RSO,
253 A_1_RSO = A_1 | IMAGE_FORMAT_RSO,
254
255 YUV_422_RSO = YUV_422 | IMAGE_FORMAT_RSO,
256 YUV_422_REV_RSO = YUV_422_REV | IMAGE_FORMAT_RSO,
257
258 ARGB_8888_PRE = ARGB_8888 | IMAGE_FORMAT_PRE,
259
260 /* TLB dump formats */
261 DEPTH_32_TLBD = DEPTH_32 | IMAGE_FORMAT_BRCM4,
262 DEPTH_COL_64_TLBD = DEPTH_64 | IMAGE_FORMAT_BRCM4,
263 COL_32_TLBD = BGRA_8888 | IMAGE_FORMAT_BRCM4,
264
265 IMAGE_FORMAT_INVALID = 0xffffffff
266} KHRN_IMAGE_FORMAT_T;
267
268static INLINE bool khrn_image_is_rso(KHRN_IMAGE_FORMAT_T format)
269{
270 vcos_assert(format != IMAGE_FORMAT_INVALID);
271 return (format & IMAGE_FORMAT_MEM_LAYOUT_MASK) == IMAGE_FORMAT_RSO;
272}
273
274static INLINE bool khrn_image_is_brcm1(KHRN_IMAGE_FORMAT_T format)
275{
276 vcos_assert(format != IMAGE_FORMAT_INVALID);
277 return (format & IMAGE_FORMAT_MEM_LAYOUT_MASK) == IMAGE_FORMAT_BRCM1;
278}
279
280static INLINE bool khrn_image_is_brcm2(KHRN_IMAGE_FORMAT_T format)
281{
282 vcos_assert(format != IMAGE_FORMAT_INVALID);
283 return (format & IMAGE_FORMAT_MEM_LAYOUT_MASK) == IMAGE_FORMAT_BRCM2;
284}
285
286static INLINE KHRN_IMAGE_FORMAT_T khrn_image_to_rso_format(KHRN_IMAGE_FORMAT_T format)
287{
288 vcos_assert(format != IMAGE_FORMAT_INVALID);
289 return (KHRN_IMAGE_FORMAT_T)((format & ~IMAGE_FORMAT_MEM_LAYOUT_MASK) | IMAGE_FORMAT_RSO);
290}
291
292static INLINE KHRN_IMAGE_FORMAT_T khrn_image_to_tf_format(KHRN_IMAGE_FORMAT_T format)
293{
294 vcos_assert(format != IMAGE_FORMAT_INVALID);
295 return (KHRN_IMAGE_FORMAT_T)((format & ~IMAGE_FORMAT_MEM_LAYOUT_MASK) | IMAGE_FORMAT_BRCM1);
296}
297
298static INLINE KHRN_IMAGE_FORMAT_T khrn_image_to_lt_format(KHRN_IMAGE_FORMAT_T format)
299{
300 vcos_assert(format != IMAGE_FORMAT_INVALID);
301 return (KHRN_IMAGE_FORMAT_T)((format & ~IMAGE_FORMAT_MEM_LAYOUT_MASK) | IMAGE_FORMAT_BRCM2);
302}
303
304static INLINE bool khrn_image_is_uncomp(KHRN_IMAGE_FORMAT_T format)
305{
306 vcos_assert(format != IMAGE_FORMAT_INVALID);
307 return (format & IMAGE_FORMAT_COMP_MASK) == IMAGE_FORMAT_UNCOMP;
308}
309
310static INLINE bool khrn_image_is_color(KHRN_IMAGE_FORMAT_T format)
311{
312 vcos_assert(format != IMAGE_FORMAT_INVALID);
313 return (format & (IMAGE_FORMAT_COMP_MASK | IMAGE_FORMAT_PIXEL_TYPE_MASK)) == (IMAGE_FORMAT_UNCOMP | IMAGE_FORMAT_COLOR);
314}
315
316static INLINE bool khrn_image_is_gray(KHRN_IMAGE_FORMAT_T format)
317{
318 vcos_assert(format != IMAGE_FORMAT_INVALID);
319 return (format & (IMAGE_FORMAT_L)) != 0;
320}
321
322static INLINE bool khrn_image_is_paletted(KHRN_IMAGE_FORMAT_T format)
323{
324 vcos_assert(format != IMAGE_FORMAT_INVALID);
325 return (format & (IMAGE_FORMAT_COMP_MASK | IMAGE_FORMAT_PIXEL_TYPE_MASK)) == (IMAGE_FORMAT_UNCOMP | IMAGE_FORMAT_PALETTE);
326}
327
328static INLINE bool khrn_image_is_depth(KHRN_IMAGE_FORMAT_T format)
329{
330 vcos_assert(format != IMAGE_FORMAT_INVALID);
331 return (format & (IMAGE_FORMAT_COMP_MASK | IMAGE_FORMAT_PIXEL_TYPE_MASK)) == (IMAGE_FORMAT_UNCOMP | IMAGE_FORMAT_DEPTH);
332}
333
334static INLINE bool khrn_image_is_etc1(KHRN_IMAGE_FORMAT_T format)
335{
336 vcos_assert(format != IMAGE_FORMAT_INVALID);
337 return (format & IMAGE_FORMAT_COMP_MASK) == IMAGE_FORMAT_ETC1;
338}
339
340static INLINE bool khrn_image_is_yuv422(KHRN_IMAGE_FORMAT_T format)
341{
342 vcos_assert(format != IMAGE_FORMAT_INVALID);
343 return (format & IMAGE_FORMAT_COMP_MASK) == IMAGE_FORMAT_YUYV;
344}
345
346extern uint32_t khrn_image_get_bpp(KHRN_IMAGE_FORMAT_T format);
347
348extern uint32_t khrn_image_get_red_size(KHRN_IMAGE_FORMAT_T format);
349extern uint32_t khrn_image_get_green_size(KHRN_IMAGE_FORMAT_T format);
350extern uint32_t khrn_image_get_blue_size(KHRN_IMAGE_FORMAT_T format);
351extern uint32_t khrn_image_get_alpha_size(KHRN_IMAGE_FORMAT_T format);
352extern uint32_t khrn_image_get_z_size(KHRN_IMAGE_FORMAT_T format);
353extern uint32_t khrn_image_get_stencil_size(KHRN_IMAGE_FORMAT_T format);
354
355extern uint32_t khrn_image_get_log2_brcm2_width(KHRN_IMAGE_FORMAT_T format);
356extern uint32_t khrn_image_get_log2_brcm2_height(KHRN_IMAGE_FORMAT_T format);
357extern uint32_t khrn_image_get_log2_brcm1_width(KHRN_IMAGE_FORMAT_T format);
358extern uint32_t khrn_image_get_log2_brcm1_height(KHRN_IMAGE_FORMAT_T format);
359
360/******************************************************************************
361image handling
362******************************************************************************/
363
364typedef struct {
365 KHRN_IMAGE_FORMAT_T format;
366
367 uint16_t width;
368 uint16_t height;
369
370 int32_t stride; /* in bytes */
371
372 void *aux;
373 void *storage;
374} KHRN_IMAGE_WRAP_T;
375
376extern uint32_t khrn_image_pad_width(KHRN_IMAGE_FORMAT_T format, uint32_t width);
377extern uint32_t khrn_image_pad_height(KHRN_IMAGE_FORMAT_T format, uint32_t height);
378extern uint32_t khrn_image_get_stride(KHRN_IMAGE_FORMAT_T format, uint32_t width);
379extern uint32_t khrn_image_get_size(KHRN_IMAGE_FORMAT_T format, uint32_t width, uint32_t height);
380
381extern void khrn_image_wrap(KHRN_IMAGE_WRAP_T *wrap, KHRN_IMAGE_FORMAT_T format, uint32_t width, uint32_t height, int32_t stride, void *storage);
382
383#endif
384