VPI - Vision Programming Interface
3.2 Release
FormatUtils.h
1
/*
2
* Copyright 2020-2021 NVIDIA Corporation. All rights reserved.
3
*
4
* NOTICE TO LICENSEE:
5
*
6
* This source code and/or documentation ("Licensed Deliverables") are
7
* subject to NVIDIA intellectual property rights under U.S. and
8
* international Copyright laws.
9
*
10
* These Licensed Deliverables contained herein is PROPRIETARY and
11
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
12
* conditions of a form of NVIDIA software license agreement by and
13
* between NVIDIA and Licensee ("License Agreement") or electronically
14
* accepted by Licensee. Notwithstanding any terms or conditions to
15
* the contrary in the License Agreement, reproduction or disclosure
16
* of the Licensed Deliverables to any third party without the express
17
* written consent of NVIDIA is prohibited.
18
*
19
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32
* OF THESE LICENSED DELIVERABLES.
33
*
34
* U.S. Government End Users. These Licensed Deliverables are a
35
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36
* 1995), consisting of "commercial computer software" and "commercial
37
* computer software documentation" as such terms are used in 48
38
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41
* U.S. Government End Users acquire the Licensed Deliverables with
42
* only those rights set forth herein.
43
*
44
* Any use of the Licensed Deliverables in individual and commercial
45
* software must include, in the user documentation and internal
46
* comments to the code, the above Disclaimer and U.S. Government End
47
* Users Notice.
48
*/
49
50
#ifndef NV_VPI_DETAIL_FORMATUTILS_H
51
#define NV_VPI_DETAIL_FORMATUTILS_H
52
53
#include <stdint.h>
54
55
// Utilities ================================
56
57
#define VPI_DETAIL_SET_BITFIELD(value, offset, size) (((uint64_t)(value) & ((1ULL << (size)) - 1)) << (offset))
58
#define VPI_DETAIL_GET_BITFIELD(value, offset, size) (((uint64_t)(value) >> (offset)) & ((1ULL << (size)) - 1))
59
60
#define VPI_DETAIL_ENCODE_BPP(bpp) \
61
((bpp) <= 8 ? 0 \
62
: ((bpp) <= 32 ? (bpp) / 8 - 1 \
63
: ((bpp) <= 64 ? (bpp) / 16 + 1 : ((bpp) <= 128 ? (bpp) / 32 + 3 : (bpp) / 64 + 5))))
64
65
#define VPI_DETAIL_BPP_NCH(bpp, chcount) \
66
(VPI_DETAIL_SET_BITFIELD(VPI_DETAIL_ENCODE_BPP(bpp), 6, 4) | VPI_DETAIL_SET_BITFIELD((chcount)-1, 4, 2) | \
67
VPI_DETAIL_SET_BITFIELD((bpp) <= 2 ? (bpp) : ((bpp) == 4 ? 3 : ((bpp) == 8 ? 4 : 0)), 0, 4))
68
69
#define VPI_DETAIL_MAKE_SWIZZLE(x, y, z, w) \
70
(VPI_DETAIL_SET_BITFIELD(x, 0, 3) | VPI_DETAIL_SET_BITFIELD(y, 3, 3) | VPI_DETAIL_SET_BITFIELD(z, 6, 3) | \
71
VPI_DETAIL_SET_BITFIELD(w, 9, 3))
72
73
#define VPI_DETAIL_MAKE_SWZL(x, y, z, w) \
74
VPI_DETAIL_MAKE_SWIZZLE(VPI_CHANNEL_##x, VPI_CHANNEL_##y, VPI_CHANNEL_##z, VPI_CHANNEL_##w)
75
76
#define VPI_DETAIL_DEF_SWIZZLE_ENUM(x, y, z, w) VPI_SWIZZLE_##x##y##z##w = VPI_DETAIL_MAKE_SWZL(x, y, z, w)
77
78
#define VPI_DETAIL_ADJUST_BPP_ENCODING(PACK, BPP, PACKLEN) \
79
((PACKLEN) == 0 && (BPP) == 0 && (PACK) == 4 ? (uint64_t)-1 : (BPP))
80
81
#define VPI_DETAIL_ENCODE_PACKING(P, CHLEN, PACKLEN, BPPLEN) \
82
(VPI_DETAIL_SET_BITFIELD( \
83
VPI_DETAIL_ADJUST_BPP_ENCODING(VPI_DETAIL_GET_BITFIELD(P, 0, 4), VPI_DETAIL_GET_BITFIELD(P, 6, 4), PACKLEN), \
84
(PACKLEN) + (CHLEN), BPPLEN) | \
85
VPI_DETAIL_SET_BITFIELD(VPI_DETAIL_GET_BITFIELD(P, 4, 2), PACKLEN, CHLEN) | \
86
VPI_DETAIL_SET_BITFIELD(VPI_DETAIL_GET_BITFIELD(P, 0, 4), 0, PACKLEN))
87
88
#define VPI_DETAIL_EXTRACT_PACKING_CHANNELS(Packing) (VPI_DETAIL_GET_BITFIELD(Packing, 4, 2) + 1)
89
90
/* clang-format off */
91
#define VPI_DETAIL_MAKE_FMTTYPE(ColorModel, ColorSpecOrRawPattern, Subsampling, MemLayout, DataType, Swizzle, \
92
Packing0, Packing1, Packing2, Packing3) \
93
( \
94
VPI_DETAIL_SET_BITFIELD(DataType, 61, 3) | VPI_DETAIL_SET_BITFIELD(Swizzle, 0, 4 * 3) | \
95
VPI_DETAIL_SET_BITFIELD(MemLayout, 12, 3) | \
96
((ColorModel) == VPI_COLOR_MODEL_YCbCr \
97
? VPI_DETAIL_SET_BITFIELD(ColorSpecOrRawPattern, 20, 15) | VPI_DETAIL_SET_BITFIELD(Subsampling, 17, 3) \
98
: ((ColorModel) == VPI_COLOR_MODEL_UNDEFINED \
99
? VPI_DETAIL_SET_BITFIELD((1U<<19)-1, 16, 19) \
100
: (VPI_DETAIL_SET_BITFIELD(1,16,1) | \
101
((ColorModel)-2 < 0x7 \
102
? VPI_DETAIL_SET_BITFIELD(ColorSpecOrRawPattern, 20, 15) \
103
| VPI_DETAIL_SET_BITFIELD((ColorModel)-2, 17, 3) \
104
: (VPI_DETAIL_SET_BITFIELD(0x7, 17, 3) | \
105
((ColorModel) == VPI_COLOR_MODEL_RAW \
106
? VPI_DETAIL_SET_BITFIELD(ColorSpecOrRawPattern, 21, 6) \
107
: (VPI_DETAIL_SET_BITFIELD(1, 20, 1) | VPI_DETAIL_SET_BITFIELD((ColorModel)-(7+2+1), 21, 6)) \
108
) \
109
) \
110
) \
111
) \
112
) \
113
) | \
114
VPI_DETAIL_SET_BITFIELD(VPI_DETAIL_ENCODE_PACKING(Packing0, 2, 3, 4), 35, 9) | \
115
VPI_DETAIL_SET_BITFIELD(VPI_DETAIL_ENCODE_PACKING(Packing1, 1, 3, 3), 44, 7) | \
116
VPI_DETAIL_SET_BITFIELD(VPI_DETAIL_ENCODE_PACKING(Packing2, 1, 3, 3), 51, 7) | \
117
VPI_DETAIL_SET_BITFIELD(VPI_DETAIL_ENCODE_PACKING(Packing3, 0, 0, 3), 58, 3))
118
/* clang-format on */
119
120
#define VPI_DETAIL_MAKE_FORMAT(ColorModel, ColorSpecOrRawPattern, Subsampling, MemLayout, DataType, Swizzle, Packing0, \
121
Packing1, Packing2, Packing3) \
122
((VPIImageFormat)VPI_DETAIL_MAKE_FMTTYPE(ColorModel, ColorSpecOrRawPattern, Subsampling, MemLayout, DataType, \
123
Swizzle, Packing0, Packing1, Packing2, Packing3))
124
125
#define VPI_DETAIL_MAKE_FMT(ColorModel, ColorSpec, CSS, MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
126
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_##ColorModel, VPI_COLOR_SPEC_##ColorSpec, VPI_CSS_##CSS, \
127
VPI_MEM_LAYOUT_##MemLayout, VPI_DATA_TYPE_##DataType, VPI_SWIZZLE_##Swizzle, \
128
VPI_PACKING_##P0, VPI_PACKING_##P1, VPI_PACKING_##P2, VPI_PACKING_##P3)
129
130
// MAKE_COLOR ================================================
131
132
// Full arg name
133
134
#define VPI_DETAIL_MAKE_COLOR_FORMAT1(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0) \
135
VPI_DETAIL_MAKE_FORMAT(ColorModel, ColorSpec, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, 0, 0, 0)
136
137
#define VPI_DETAIL_MAKE_COLOR_FORMAT2(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0, P1) \
138
VPI_DETAIL_MAKE_FORMAT(ColorModel, ColorSpec, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, P1, 0, 0)
139
140
#define VPI_DETAIL_MAKE_COLOR_FORMAT3(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0, P1, P2) \
141
VPI_DETAIL_MAKE_FORMAT(ColorModel, ColorSpec, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, P1, P2, 0)
142
143
#define VPI_DETAIL_MAKE_COLOR_FORMAT4(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
144
VPI_DETAIL_MAKE_FORMAT(ColorModel, ColorSpec, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, P1, P2, P3)
145
146
#define VPI_DETAIL_MAKE_COLOR_FORMAT(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, PlaneCount, ...) \
147
VPI_DETAIL_MAKE_COLOR_FORMAT##PlaneCount(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, __VA_ARGS__)
148
149
// Abbreviated
150
151
#define VPI_DETAIL_MAKE_COLOR_FMT1(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0) \
152
VPI_DETAIL_MAKE_FMT(ColorModel, ColorSpec, NONE, MemLayout, DataType, Swizzle, P0, 0, 0, 0)
153
154
#define VPI_DETAIL_MAKE_COLOR_FMT2(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0, P1) \
155
VPI_DETAIL_MAKE_FMT(ColorModel, ColorSpec, NONE, MemLayout, DataType, Swizzle, P0, P1, 0, 0)
156
157
#define VPI_DETAIL_MAKE_COLOR_FMT3(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0, P1, P3) \
158
VPI_DETAIL_MAKE_FMT(ColorModel, ColorSpec, NONE, MemLayout, DataType, Swizzle, P0, P1, P3, 0)
159
160
#define VPI_DETAIL_MAKE_COLOR_FMT4(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, P0, P1, P3, P4) \
161
VPI_DETAIL_MAKE_FMT(ColorModel, ColorSpec, NONE, MemLayout, DataType, Swizzle, P0, P1, P3, P4)
162
163
#define VPI_DETAIL_MAKE_COLOR_FMT(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, PlaneCount, ...) \
164
VPI_DETAIL_MAKE_COLOR_FMT##PlaneCount(ColorModel, ColorSpec, MemLayout, DataType, Swizzle, __VA_ARGS__)
165
166
// MAKE_PIXEL =========================
167
168
// Full arg name
169
170
#define VPI_DETAIL_MAKE_PIXEL_TYPE(MemLayout, DataType, Packing) \
171
((VPIPixelType)VPI_DETAIL_MAKE_FMTTYPE( \
172
VPI_COLOR_MODEL_UNDEFINED, VPI_COLOR_SPEC_UNDEFINED, VPI_CSS_NONE, MemLayout, DataType, \
173
VPI_DETAIL_MAKE_SWIZZLE(VPI_CHANNEL_X, VPI_DETAIL_EXTRACT_PACKING_CHANNELS(Packing) >= 2 ? VPI_CHANNEL_Y : 0, \
174
VPI_DETAIL_EXTRACT_PACKING_CHANNELS(Packing) >= 3 ? VPI_CHANNEL_Z : 0, \
175
VPI_DETAIL_EXTRACT_PACKING_CHANNELS(Packing) >= 4 ? VPI_CHANNEL_W : 0), \
176
Packing, 0, 0, 0))
177
178
// Abbreviated
179
180
#define VPI_DETAIL_MAKE_PIX_TYPE(MemLayout, DataType, Packing) \
181
VPI_DETAIL_MAKE_PIXEL_TYPE(VPI_MEM_LAYOUT_##MemLayout, VPI_DATA_TYPE_##DataType, VPI_PACKING_##Packing)
182
183
// MAKE_NONCOLOR ==================================
184
185
// Full arg name
186
187
#define VPI_DETAIL_MAKE_NONCOLOR_FORMAT1(MemLayout, DataType, Swizzle, P0) \
188
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_UNDEFINED, VPI_COLOR_SPEC_UNDEFINED, VPI_CSS_NONE, MemLayout, DataType, \
189
Swizzle, P0, 0, 0, 0)
190
191
#define VPI_DETAIL_MAKE_NONCOLOR_FORMAT2(MemLayout, DataType, Swizzle, P0, P1) \
192
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_UNDEFINED, VPI_COLOR_SPEC_UNDEFINED, VPI_CSS_NONE, MemLayout, DataType, \
193
Swizzle, P0, P1, 0, 0)
194
195
#define VPI_DETAIL_MAKE_NONCOLOR_FORMAT3(MemLayout, DataType, Swizzle, P0, P1, P2) \
196
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_UNDEFINED, VPI_COLOR_SPEC_UNDEFINED, VPI_CSS_NONE, MemLayout, DataType, \
197
Swizzle, P0, P1, P2, 0)
198
199
#define VPI_DETAIL_MAKE_NONCOLOR_FORMAT4(MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
200
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_UNDEFINED, VPI_COLOR_SPEC_UNDEFINED, VPI_CSS_NONE, MemLayout, DataType, \
201
Swizzle, P0, P1, P2, P3)
202
203
#define VPI_DETAIL_MAKE_NONCOLOR_FORMAT(MemLayout, DataType, Swizzle, PlaneCount, ...) \
204
VPI_DETAIL_MAKE_NONCOLOR_FORMAT##PlaneCount(MemLayout, DataType, Swizzle, __VA_ARGS__)
205
206
// Abbreviated
207
208
#define VPI_DETAIL_MAKE_NONCOLOR_FMT1(MemLayout, DataType, Swizzle, P0) \
209
VPI_DETAIL_MAKE_FMT(UNDEFINED, UNDEFINED, NONE, MemLayout, DataType, Swizzle, P0, 0, 0, 0)
210
211
#define VPI_DETAIL_MAKE_NONCOLOR_FMT2(MemLayout, DataType, Swizzle, P0, P1) \
212
VPI_DETAIL_MAKE_FMT(UNDEFINED, UNDEFINED, NONE, MemLayout, DataType, Swizzle, P0, P1, 0, 0)
213
214
#define VPI_DETAIL_MAKE_NONCOLOR_FMT3(MemLayout, DataType, Swizzle, P0, P1, P2) \
215
VPI_DETAIL_MAKE_FMT(UNDEFINED, UNDEFINED, NONE, MemLayout, DataType, Swizzle, P0, P1, P2, 0)
216
217
#define VPI_DETAIL_MAKE_NONCOLOR_FMT4(MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
218
VPI_DETAIL_MAKE_FMT(UNDEFINED, UNDEFINED, NONE, MemLayout, DataType, Swizzle, P0, P1, P2, P3)
219
220
#define VPI_DETAIL_MAKE_NONCOLOR_FMT(MemLayout, DataType, Swizzle, PlaneCount, ...) \
221
VPI_DETAIL_MAKE_NONCOLOR_FMT##PlaneCount(MemLayout, DataType, Swizzle, __VA_ARGS__)
222
223
// MAKE_RAW =============================================
224
225
// Full arg name
226
227
#define VPI_DETAIL_MAKE_RAW_FORMAT1(RawPattern, MemLayout, DataType, Swizzle, P0) \
228
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_RAW, RawPattern, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, 0, 0, 0)
229
230
#define VPI_DETAIL_MAKE_RAW_FORMAT2(RawPattern, MemLayout, DataType, Swizzle, P0, P1) \
231
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_RAW, RawPattern, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, P1, 0, 0)
232
233
#define VPI_DETAIL_MAKE_RAW_FORMAT3(RawPattern, MemLayout, DataType, Swizzle, P0, P1, P2) \
234
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_RAW, RawPattern, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, P1, P2, 0)
235
236
#define VPI_DETAIL_MAKE_RAW_FORMAT4(RawPattern, MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
237
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_RAW, RawPattern, VPI_CSS_NONE, MemLayout, DataType, Swizzle, P0, P1, P2, P3)
238
239
#define VPI_DETAIL_MAKE_RAW_FORMAT(RawPattern, MemLayout, DataType, Swizzle, PlaneCount, ...) \
240
VPI_DETAIL_MAKE_RAW_FORMAT##PlaneCount(RawPattern, MemLayout, DataType, Swizzle, __VA_ARGS__)
241
242
// Abbreviated
243
244
#define VPI_DETAIL_MAKE_RAW_FMT1(RawPattern, MemLayout, DataType, Swizzle, P0) \
245
VPI_DETAIL_MAKE_RAW_FORMAT1(VPI_RAW_##RawPattern, VPI_MEM_LAYOUT_##MemLayout, VPI_DATA_TYPE_##DataType, \
246
VPI_SWIZZLE_##Swizzle, VPI_PACKING_##P0)
247
248
#define VPI_DETAIL_MAKE_RAW_FMT2(RawPattern, MemLayout, DataType, Swizzle, P0, P1) \
249
VPI_DETAIL_MAKE_RAW_FORMAT2(VPI_RAW_##RawPattern, VPI_MEM_LAYOUT_##MemLayout, VPI_DATA_TYPE_##DataType, \
250
VPI_SWIZZLE_##Swizzle, VPI_PACKING_##P0, VPI_PACKING_##P1)
251
252
#define VPI_DETAIL_MAKE_RAW_FMT3(RawPattern, MemLayout, DataType, Swizzle, P0, P1, P2) \
253
VPI_DETAIL_MAKE_RAW_FORMAT3(VPI_RAW_##RawPattern, VPI_MEM_LAYOUT_##MemLayout, VPI_DATA_TYPE_##DataType, \
254
VPI_SWIZZLE_##Swizzle, VPI_PACKING_##P0, VPI_PACKING_##P1, VPI_PACKING_##P2)
255
256
#define VPI_DETAIL_MAKE_RAW_FMT4(RawPattern, MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
257
VPI_DETAIL_MAKE_RAW_FORMAT4(VPI_RAW_##RawPattern, VPI_MEM_LAYOUT_##MemLayout, VPI_DATA_TYPE_##DataType, \
258
VPI_SWIZZLE_##Swizzle, VPI_PACKING_##P0, VPI_PACKING_##P1, VPI_PACKING_##P2, \
259
VPI_PACKING_##P3)
260
261
#define VPI_DETAIL_MAKE_RAW_FMT(RawPattern, MemLayout, DataType, Swizzle, PlaneCount, ...) \
262
VPI_DETAIL_MAKE_RAW_FMT##PlaneCount(RawPattern, MemLayout, DataType, Swizzle, __VA_ARGS__)
263
264
// MAKE_YCbCr ===============================================
265
266
// Full arg name
267
268
#define VPI_DETAIL_MAKE_YCbCr_FORMAT1(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0) \
269
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_##YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, 0, 0, 0)
270
271
#define VPI_DETAIL_MAKE_YCbCr_FORMAT2(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1) \
272
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_##YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, 0, \
273
0)
274
275
#define VPI_DETAIL_MAKE_YCbCr_FORMAT3(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, P2) \
276
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_##YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, \
277
P2, 0)
278
279
#define VPI_DETAIL_MAKE_YCbCr_FORMAT4(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
280
VPI_DETAIL_MAKE_FORMAT(VPI_COLOR_MODEL_##YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, \
281
P2, P3)
282
283
#define VPI_DETAIL_MAKE_YCbCr_FORMAT(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, PlaneCount, ...) \
284
VPI_DETAIL_MAKE_YCbCr_FORMAT##PlaneCount(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, __VA_ARGS__)
285
286
// Abbreviated
287
288
#define VPI_DETAIL_MAKE_YCbCr_FMT1(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0) \
289
VPI_DETAIL_MAKE_FMT(YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, 0, 0, 0)
290
291
#define VPI_DETAIL_MAKE_YCbCr_FMT2(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1) \
292
VPI_DETAIL_MAKE_FMT(YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, 0, 0)
293
294
#define VPI_DETAIL_MAKE_YCbCr_FMT3(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, P2) \
295
VPI_DETAIL_MAKE_FMT(YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, P2, 0)
296
297
#define VPI_DETAIL_MAKE_YCbCr_FMT4(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, P2, P3) \
298
VPI_DETAIL_MAKE_FMT(YCbCr, ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, P0, P1, P2, P3)
299
300
#define VPI_DETAIL_MAKE_YCbCr_FMT(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, PlaneCount, ...) \
301
VPI_DETAIL_MAKE_YCbCr_FMT##PlaneCount(ColorSpec, ChromaSubsamp, MemLayout, DataType, Swizzle, __VA_ARGS__)
302
303
// MAKE_COLOR_SPEC --------------------------------------------
304
305
#define VPI_DETAIL_MAKE_COLOR_SPEC(CSpace, Encoding, XferFunc, Range, LocHoriz, LocVert) \
306
(VPI_DETAIL_SET_BITFIELD((CSpace), 0, 3) | VPI_DETAIL_SET_BITFIELD(XferFunc, 3, 4) | \
307
VPI_DETAIL_SET_BITFIELD(Encoding, 7, 3) | VPI_DETAIL_SET_BITFIELD(LocHoriz, 10, 2) | \
308
VPI_DETAIL_SET_BITFIELD(LocVert, 12, 2) | VPI_DETAIL_SET_BITFIELD(Range, 14, 1))
309
310
#define VPI_DETAIL_MAKE_CSPC(CSpace, Encoding, XferFunc, Range, LocHoriz, LocVert) \
311
VPI_DETAIL_MAKE_COLOR_SPEC(VPI_COLOR_##CSpace, VPI_YCbCr_##Encoding, VPI_COLOR_##XferFunc, VPI_COLOR_##Range, \
312
VPI_CHROMA_##LocHoriz, VPI_CHROMA_##LocVert)
313
314
#endif
/* NV_VPI_DETAIL_FORMATUTILS_H */
Generated by NVIDIA | Thu Sep 26 2024 14:53:33 | 326505d9a4a74983db9d9e474ea50eed0b530df7