2
* libzvbi - Image definitions
4
* Copyright (C) 2003, 2004 Michael H. Schimek
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20
/* $Id: image_format.h,v 1.3 2005/01/31 07:15:51 mschimek Exp $ */
22
#ifndef __ZVBI3_IMAGE_FORMAT_H__
23
#define __ZVBI3_IMAGE_FORMAT_H__
25
#include <inttypes.h> /* uint64_t */
35
/** Pixel format identifier. */
37
VBI3_PIXFMT_NONE, /**< */
38
VBI3_PIXFMT_UNKNOWN = VBI3_PIXFMT_NONE, /**< */
40
VBI3_PIXFMT_RESERVED0,
43
* Planar YUV formats. Letters XYZ describe the contents of the
44
* first to last plane in memory. Numbers follow standard naming
45
* conventions, e. g. YUV422 means YUV 4:2:2.
47
* Relative plane sizes of VBI3_PIXFMT_YUV444: 4x4 4x4 4x4
50
VBI3_PIXFMT_YVU444, /**< 4x4 4x4 4x4 */
51
VBI3_PIXFMT_YUV422, /**< 4x4 2x4 2x4 */
52
VBI3_PIXFMT_YVU422, /**< 4x4 2x4 2x4 */
53
VBI3_PIXFMT_YUV411, /**< 4x4 1x4 1x4 */
54
VBI3_PIXFMT_YVU411, /**< 4x4 1x4 1x4 */
55
VBI3_PIXFMT_YUV420, /**< 4x4 2x2 2x2 */
56
VBI3_PIXFMT_YVU420, /**< 4x4 2x2 2x2 */
57
VBI3_PIXFMT_YUV410, /**< 4x4 1x1 1x1 */
58
VBI3_PIXFMT_YVU410, /**< 4x4 1x1 1x1 */
61
* Packed YUV formats. Letters WXYZ describe register contents
62
* from last to most significant bit. Numbers are the significant
63
* bits without alpha bits. Appendix _LE means LSB is stored
64
* first in memory, _BE means MSB.
66
* VBI3_PIXFMT_YUVA24_LE in register: 0xAAVVUUYY, memory: Y U V A
68
VBI3_PIXFMT_YUVA24_LE,
69
VBI3_PIXFMT_YUVA24_BE, /**< 0xAAVVUUYY, A V U Y */
70
VBI3_PIXFMT_YVUA24_LE, /**< 0xAAUUVVYY, Y V U A */
71
VBI3_PIXFMT_YVUA24_BE, /**< 0xAAUUVVYY, A U V Y */
73
VBI3_PIXFMT_AVUY24_BE = VBI3_PIXFMT_YUVA24_LE, /**< */
74
VBI3_PIXFMT_AVUY24_LE, /**< */
75
VBI3_PIXFMT_AUVY24_BE, /**< */
76
VBI3_PIXFMT_AUVY24_LE, /**< */
78
VBI3_PIXFMT_YUV24_LE, /**< 0xVVUUYY, Y U V */
79
VBI3_PIXFMT_YUV24_BE, /**< 0xVVUUYY, V U Y */
80
VBI3_PIXFMT_YVU24_LE, /**< 0xUUVVYY, Y V U */
81
VBI3_PIXFMT_YVU24_BE, /**< 0xUUVVYY, U V Y */
83
VBI3_PIXFMT_VUY24_BE = VBI3_PIXFMT_YUV24_LE, /**< */
84
VBI3_PIXFMT_VUY24_LE, /**< */
85
VBI3_PIXFMT_UVY24_BE, /**< */
86
VBI3_PIXFMT_UVY24_LE, /**< */
89
* Packed YUV 4:2:2 formats. Letters WXYZ describe color components
90
* stored at ascending memory addresses, 8 bits each.
92
* VBI3_PIXFMT_YUYV: Y0, (U0 + U1) / 2, Y1, (V0 + V1) / 2 in memory
95
VBI3_PIXFMT_YVYU, /**< Y0 V Y1 U */
96
VBI3_PIXFMT_UYVY, /**< U Y0 V Y1 */
97
VBI3_PIXFMT_VYUY, /**< V Y0 U Y1 */
99
VBI3_PIXFMT_RESERVED1,
101
/** Y only, 8 bit per pixel. */
104
VBI3_PIXFMT_RESERVED2,
105
VBI3_PIXFMT_RESERVED3,
108
* Packed RGB formats. Letters WXYZ describe register contents
109
* from last to most significant bit. Numbers are the significant
110
* bits without alpha bits. Appendix _LE means LSB is stored
111
* first in memory, _BE means MSB.
113
* VBI3_PIXFMT_RGBA24_LE in register: 0xAABBGGRR, memory: R G B A
115
VBI3_PIXFMT_RGBA24_LE,
116
VBI3_PIXFMT_RGBA24_BE, /**< 0xAABBGGRR, A B G R */
117
VBI3_PIXFMT_BGRA24_LE, /**< 0xAARRGGBB, B G R A */
118
VBI3_PIXFMT_BGRA24_BE, /**< 0xAARRGGBB, A R G B */
120
VBI3_PIXFMT_ABGR24_BE = VBI3_PIXFMT_RGBA24_LE, /**< */
121
VBI3_PIXFMT_ABGR24_LE, /**< */
122
VBI3_PIXFMT_ARGB24_BE, /**< */
123
VBI3_PIXFMT_ARGB24_LE, /**< */
125
VBI3_PIXFMT_RGB24_LE, /* 0xBBGGRR, R G B */
126
VBI3_PIXFMT_RGB24_BE, /* 0xRRGGBB, B G R */
128
VBI3_PIXFMT_BGR24_BE = VBI3_PIXFMT_RGB24_LE, /**< */
129
VBI3_PIXFMT_BGR24_LE, /**< */
131
/** In register: bbbbbggg gggrrrrr (msb to lsb) */
132
VBI3_PIXFMT_RGB16_LE,
133
VBI3_PIXFMT_RGB16_BE, /**< */
134
VBI3_PIXFMT_BGR16_LE, /**< rrrrrggg gggbbbbb */
135
VBI3_PIXFMT_BGR16_BE, /**< */
137
VBI3_PIXFMT_RGBA15_LE, /**< abbbbbgg gggrrrrr */
138
VBI3_PIXFMT_RGBA15_BE, /**< */
139
VBI3_PIXFMT_BGRA15_LE, /**< arrrrrgg gggbbbbb */
140
VBI3_PIXFMT_BGRA15_BE, /**< */
142
VBI3_PIXFMT_ARGB15_LE, /**< bbbbbggg ggrrrrra */
143
VBI3_PIXFMT_ARGB15_BE, /**< */
144
VBI3_PIXFMT_ABGR15_LE, /**< rrrrrggg ggbbbbba */
145
VBI3_PIXFMT_ABGR15_BE, /**< */
147
VBI3_PIXFMT_RGBA12_LE, /**< aaaabbbb ggggrrrr */
148
VBI3_PIXFMT_RGBA12_BE, /**< */
149
VBI3_PIXFMT_BGRA12_LE, /**< aaaarrrr ggggbbbb */
150
VBI3_PIXFMT_BGRA12_BE, /**< */
151
VBI3_PIXFMT_ARGB12_LE, /**< bbbbgggg rrrraaaa */
152
VBI3_PIXFMT_ARGB12_BE, /**< */
153
VBI3_PIXFMT_ABGR12_LE, /**< rrrrgggg bbbbaaaa */
154
VBI3_PIXFMT_ABGR12_BE, /**< */
156
VBI3_PIXFMT_RGB8, /**< bbgggrrr */
157
VBI3_PIXFMT_BGR8, /**< rrrgggbb */
159
VBI3_PIXFMT_RGBA7, /**< abbgggrr */
160
VBI3_PIXFMT_BGRA7, /**< arrgggbb */
161
VBI3_PIXFMT_ARGB7, /**< bbgggrra */
162
VBI3_PIXFMT_ABGR7 /**< rrgggbba */
165
#define VBI3_MAX_PIXFMTS 64
168
* A set of pixel formats is used where more than one
169
* format may apply. Use VBI3_PIXFMT_SET macros
172
typedef uint64_t vbi3_pixfmt_set;
174
#define VBI3_PIXFMT_SET(pixfmt) (((vbi3_pixfmt_set) 1) << (pixfmt))
176
#define VBI3_PIXFMT_SET_UNKNOWN 0
177
#define VBI3_PIXFMT_SET_EMPTY 0
178
#define VBI3_PIXFMT_SET_YUV_PLANAR (VBI3_PIXFMT_SET (VBI3_PIXFMT_YUV444) | \
179
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVU444) | \
180
VBI3_PIXFMT_SET (VBI3_PIXFMT_YUV422) | \
181
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVU422) | \
182
VBI3_PIXFMT_SET (VBI3_PIXFMT_YUV411) | \
183
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVU411) | \
184
VBI3_PIXFMT_SET (VBI3_PIXFMT_YUV420) | \
185
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVU420) | \
186
VBI3_PIXFMT_SET (VBI3_PIXFMT_YUV410) | \
187
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVU410))
188
#define VBI3_PIXFMT_SET_YUVA24 (VBI3_PIXFMT_SET (VBI3_PIXFMT_YUVA24_LE) | \
189
VBI3_PIXFMT_SET (VBI3_PIXFMT_YUVA24_BE) | \
190
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVUA24_LE) | \
191
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVUA24_BE))
192
#define VBI3_PIXFMT_SET_YUV24 (VBI3_PIXFMT_SET (VBI3_PIXFMT_YUV24_LE) | \
193
VBI3_PIXFMT_SET (VBI3_PIXFMT_YUV24_BE) | \
194
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVU24_LE) | \
195
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVU24_BE))
196
#define VBI3_PIXFMT_SET_YUV16 (VBI3_PIXFMT_SET (VBI3_PIXFMT_YUYV) | \
197
VBI3_PIXFMT_SET (VBI3_PIXFMT_YVYU) | \
198
VBI3_PIXFMT_SET (VBI3_PIXFMT_UYVY) | \
199
VBI3_PIXFMT_SET (VBI3_PIXFMT_VYUY))
200
#define VBI3_PIXFMT_SET_YUV_PACKED (VBI3_PIXFMT_SET_YUVA24 | \
201
VBI3_PIXFMT_SET_YUV24 | \
202
VBI3_PIXFMT_SET_YUV16 | \
203
VBI3_PIXFMT_SET (VBI3_PIXFMT_Y8))
204
#define VBI3_PIXFMT_SET_YUV (VBI3_PIXFMT_SET_YUV_PLANAR | \
205
VBI3_PIXFMT_SET_YUV_PACKED)
206
#define VBI3_PIXFMT_SET_RGBA24 (VBI3_PIXFMT_SET (VBI3_PIXFMT_RGBA24_LE) | \
207
VBI3_PIXFMT_SET (VBI3_PIXFMT_RGBA24_BE) | \
208
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGRA24_LE) | \
209
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGRA24_BE))
210
#define VBI3_PIXFMT_SET_RGB24 (VBI3_PIXFMT_SET (VBI3_PIXFMT_RGB24_LE) | \
211
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGR24_LE))
212
#define VBI3_PIXFMT_SET_RGB16 (VBI3_PIXFMT_SET (VBI3_PIXFMT_RGB16_LE) | \
213
VBI3_PIXFMT_SET (VBI3_PIXFMT_RGB16_BE) | \
214
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGR16_LE) | \
215
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGR16_BE))
216
#define VBI3_PIXFMT_SET_RGB15 (VBI3_PIXFMT_SET (VBI3_PIXFMT_RGBA15_LE) | \
217
VBI3_PIXFMT_SET (VBI3_PIXFMT_RGBA15_BE) | \
218
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGRA15_LE) | \
219
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGRA15_BE) | \
220
VBI3_PIXFMT_SET (VBI3_PIXFMT_ARGB15_LE) | \
221
VBI3_PIXFMT_SET (VBI3_PIXFMT_ARGB15_BE) | \
222
VBI3_PIXFMT_SET (VBI3_PIXFMT_ABGR15_LE) | \
223
VBI3_PIXFMT_SET (VBI3_PIXFMT_ABGR15_BE))
224
#define VBI3_PIXFMT_SET_RGB12 (VBI3_PIXFMT_SET (VBI3_PIXFMT_RGBA12_LE) | \
225
VBI3_PIXFMT_SET (VBI3_PIXFMT_RGBA12_BE) | \
226
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGRA12_LE) | \
227
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGRA12_BE) | \
228
VBI3_PIXFMT_SET (VBI3_PIXFMT_ARGB12_LE) | \
229
VBI3_PIXFMT_SET (VBI3_PIXFMT_ARGB12_BE) | \
230
VBI3_PIXFMT_SET (VBI3_PIXFMT_ABGR12_LE) | \
231
VBI3_PIXFMT_SET (VBI3_PIXFMT_ABGR12_BE))
232
#define VBI3_PIXFMT_SET_RGB8 (VBI3_PIXFMT_SET (VBI3_PIXFMT_RGB8) | \
233
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGR8))
234
#define VBI3_PIXFMT_SET_RGB7 (VBI3_PIXFMT_SET (VBI3_PIXFMT_RGBA7) | \
235
VBI3_PIXFMT_SET (VBI3_PIXFMT_BGRA7) | \
236
VBI3_PIXFMT_SET (VBI3_PIXFMT_ARGB7) | \
237
VBI3_PIXFMT_SET (VBI3_PIXFMT_ABGR7))
238
#define VBI3_PIXFMT_SET_RGB_PACKED (VBI3_PIXFMT_SET_RGBA24 | \
239
VBI3_PIXFMT_SET_RGB24 | \
240
VBI3_PIXFMT_SET_RGB16 | \
241
VBI3_PIXFMT_SET_RGB15 | \
242
VBI3_PIXFMT_SET_RGB12 | \
243
VBI3_PIXFMT_SET_RGB8 | \
244
VBI3_PIXFMT_SET_RGB7)
245
#define VBI3_PIXFMT_SET_RGB (VBI3_PIXFMT_SET_RGB_PACKED)
246
#define VBI3_PIXFMT_SET_PLANAR (VBI3_PIXFMT_SET_YUV_PLANAR)
247
#define VBI3_PIXFMT_SET_PACKED (VBI3_PIXFMT_SET_YUV_PACKED | \
248
VBI3_PIXFMT_SET_RGB_PACKED)
249
#define VBI3_PIXFMT_SET_ALL (VBI3_PIXFMT_SET_YUV | \
252
#define VBI3_PIXFMT_IS_YUV(pixfmt) \
253
(0 != (VBI3_PIXFMT_SET (pixfmt) & VBI3_PIXFMT_SET_YUV))
254
#define VBI3_PIXFMT_IS_RGB(pixfmt) \
255
(0 != (VBI3_PIXFMT_SET (pixfmt) & VBI3_PIXFMT_SET_RGB))
256
#define VBI3_PIXFMT_IS_PLANAR(pixfmt) \
257
(0 != (VBI3_PIXFMT_SET (pixfmt) & VBI3_PIXFMT_SET_PLANAR))
258
#define VBI3_PIXFMT_IS_PACKED(pixfmt) \
259
(0 != (VBI3_PIXFMT_SET (pixfmt) & VBI3_PIXFMT_SET_PACKED))
261
#ifndef DOXYGEN_SHOULD_SKIP_THIS
263
#define _VBI3_PIXFMT_SET_4 (VBI3_PIXFMT_SET_YUVA24 | \
264
VBI3_PIXFMT_SET_RGBA24)
265
#define _VBI3_PIXFMT_SET_3 (VBI3_PIXFMT_SET_YUV24 | \
266
VBI3_PIXFMT_SET_RGB24)
267
#define _VBI3_PIXFMT_SET_2 (VBI3_PIXFMT_SET_YUV16 | \
268
VBI3_PIXFMT_SET_RGB16 | \
269
VBI3_PIXFMT_SET_RGB15 | \
270
VBI3_PIXFMT_SET_RGB12)
271
#define _VBI3_PIXFMT_SET_1 (VBI3_PIXFMT_SET_YUV_PLANAR | \
272
VBI3_PIXFMT_SET (VBI3_PIXFMT_Y8) | \
273
VBI3_PIXFMT_SET_RGB8 | \
274
VBI3_PIXFMT_SET_RGB7)
278
#define vbi3_pixfmt_bytes_per_pixel(pixfmt) \
279
(!__builtin_constant_p (pixfmt) ? \
280
_vbi3_pixfmt_bytes_per_pixel (pixfmt) : \
281
((VBI3_PIXFMT_SET (pixfmt) & _VBI3_PIXFMT_SET_4) ? 4U : \
282
((VBI3_PIXFMT_SET (pixfmt) & _VBI3_PIXFMT_SET_3) ? 3U : \
283
((VBI3_PIXFMT_SET (pixfmt) & _VBI3_PIXFMT_SET_2) ? 2U : \
284
((VBI3_PIXFMT_SET (pixfmt) & _VBI3_PIXFMT_SET_1) ? 1U : \
288
* @param pixfmt Pixel format.
290
* Returns the number of bytes per pixel used by a pixel format.
291
* For planar YUV formats (which may take a fraction of bytes
292
* on average) the result is 1.
295
* Number of bytes per pixel, 0 if @a pixfmt is invalid.
297
#define vbi3_pixfmt_bytes_per_pixel(pixfmt) \
298
(_vbi3_pixfmt_bytes_per_pixel (pixfmt))
302
vbi3_pixfmt_name (vbi3_pixfmt pixfmt)
303
__attribute__ ((const));
305
#ifndef DOXYGEN_SHOULD_SKIP_THIS
308
_vbi3_pixfmt_bytes_per_pixel (vbi3_pixfmt pixfmt)
309
__attribute__ ((const));
313
/** Color space identifier. No values defined yet. */
315
VBI3_COLOR_SPACE_NONE, /**< */
316
VBI3_COLOR_SPACE_UNKNOWN = VBI3_COLOR_SPACE_NONE, /**< */
319
/** This structure describes an image buffer. */
322
* Image width in pixels, for planar formats this refers to
323
* the Y plane and must be a multiple of vbi3_pixel_format.uv_hscale.
328
* Image height in pixels, for planar formats this refers to
329
* the Y plane and must be a multiple of tv_pixel_format.uv_vscale.
334
* For packed formats bytes_per_line >= (width *
335
* vbi3_pixel_format.bits_per_pixel + 7) / 8. For planar formats
336
* this refers to the Y plane only, with implied y_size =
337
* bytes_per_line * height.
339
unsigned int bytes_per_line;
341
/** For planar formats only, refers to the U and V plane. */
342
unsigned int uv_bytes_per_line;
345
* For packed formats the image offset in bytes from the buffer
346
* start. For planar formats this refers to the Y plane.
351
* For planar formats only, the byte offset of the U and V
352
* plane from the start of the buffer.
354
unsigned int u_offset;
355
unsigned int v_offset;
358
* Buffer size. For packed formats size >= offset + height *
359
* bytes_per_line. For planar formats size >=
360
* MAX (offset + y_size, u_offset + uv_size, v_offset + uv_size).
364
/** Pixel format used by the buffer. */
367
/** Color space used by the buffer. */
368
vbi3_color_space color_space;
375
#endif /* __ZVBI3_IMAGE_FORMAT_H__ */