VPI - Vision Programming Interface

1.0 Release

ImageFormat.h
Go to the documentation of this file.
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 
56 #ifndef NV_VPI_IMAGE_FORMAT_H
57 #define NV_VPI_IMAGE_FORMAT_H
58 
59 #include "ColorSpec.h"
60 #include "DataLayout.h"
61 #include "PixelType.h"
62 
63 #include <assert.h>
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
94 #ifdef __GNUC__
95 # pragma GCC diagnostic push
96 # pragma GCC diagnostic ignored "-Wpedantic"
97 #endif
98 typedef enum
99 {
102 
104  VPI_IMAGE_FORMAT_U8 = VPI_DETAIL_MAKE_NONCOLOR_FMT(PL, UNSIGNED, X000, 1, X8),
105 
107  VPI_IMAGE_FORMAT_S8 = VPI_DETAIL_MAKE_NONCOLOR_FMT(PL, SIGNED, X000, 1, X8),
108 
110  VPI_IMAGE_FORMAT_U16 = VPI_DETAIL_MAKE_NONCOLOR_FMT(PL, UNSIGNED, X000, 1, X16),
111 
113  VPI_IMAGE_FORMAT_S16 = VPI_DETAIL_MAKE_NONCOLOR_FMT(PL, SIGNED, X000, 1, X16),
114 
116  VPI_IMAGE_FORMAT_F32 = VPI_DETAIL_MAKE_NONCOLOR_FMT(PL, FLOAT, X000, 1, X32),
117 
119  VPI_IMAGE_FORMAT_F64 = VPI_DETAIL_MAKE_NONCOLOR_FMT(PL, FLOAT, X000, 1, X64),
120 
122  VPI_IMAGE_FORMAT_2F32 = VPI_DETAIL_MAKE_NONCOLOR_FMT(PL, FLOAT, XY00, 1, X32_Y32),
123 
132  VPI_IMAGE_FORMAT_NV12 = VPI_DETAIL_MAKE_YCbCr_FMT(BT601, 420, PL, UNSIGNED, XYZ0, 2, X8, X8_Y8),
133 
142  VPI_IMAGE_FORMAT_NV12_BL = VPI_DETAIL_MAKE_YCbCr_FMT(BT601, 420, BL, UNSIGNED, XYZ0, 2, X8, X8_Y8),
143 
152  VPI_IMAGE_FORMAT_NV12_ER = VPI_DETAIL_MAKE_YCbCr_FMT(BT601_ER, 420, PL, UNSIGNED, XYZ0, 2, X8, X8_Y8),
153 
162  VPI_IMAGE_FORMAT_NV12_ER_BL = VPI_DETAIL_MAKE_YCbCr_FMT(BT601_ER, 420, BL, UNSIGNED, XYZ0, 2, X8, X8_Y8),
163 
165  VPI_IMAGE_FORMAT_UYVY = VPI_DETAIL_MAKE_YCbCr_FMT(BT601, 422, PL, UNSIGNED, XYZ1, 1, Y8_X8__Z8_X8),
166 
168  VPI_IMAGE_FORMAT_UYVY_BL = VPI_DETAIL_MAKE_YCbCr_FMT(BT601, 422, BL, UNSIGNED, XYZ1, 1, Y8_X8__Z8_X8),
169 
171  VPI_IMAGE_FORMAT_UYVY_ER = VPI_DETAIL_MAKE_YCbCr_FMT(BT601_ER, 422, PL, UNSIGNED, XYZ1, 1, Y8_X8__Z8_X8),
172 
174  VPI_IMAGE_FORMAT_UYVY_ER_BL = VPI_DETAIL_MAKE_YCbCr_FMT(BT601_ER, 422, BL, UNSIGNED, XYZ1, 1, Y8_X8__Z8_X8),
175 
179  VPI_IMAGE_FORMAT_YUYV = VPI_DETAIL_MAKE_YCbCr_FMT(BT601, 422, PL, UNSIGNED, XYZ1, 1, X8_Y8__X8_Z8),
180 
184  VPI_IMAGE_FORMAT_YUYV_BL = VPI_DETAIL_MAKE_YCbCr_FMT(BT601, 422, BL, UNSIGNED, XYZ1, 1, X8_Y8__X8_Z8),
185 
189  VPI_IMAGE_FORMAT_YUYV_ER = VPI_DETAIL_MAKE_YCbCr_FMT(BT601_ER, 422, PL, UNSIGNED, XYZ1, 1, X8_Y8__X8_Z8),
190 
194  VPI_IMAGE_FORMAT_YUYV_ER_BL = VPI_DETAIL_MAKE_YCbCr_FMT(BT601_ER, 422, BL, UNSIGNED, XYZ1, 1, X8_Y8__X8_Z8),
195 
197  VPI_IMAGE_FORMAT_RGB8 = VPI_DETAIL_MAKE_COLOR_FMT(RGB, UNDEFINED, PL, UNSIGNED, XYZ1, 1, X8_Y8_Z8),
198 
200  VPI_IMAGE_FORMAT_BGR8 = VPI_DETAIL_MAKE_COLOR_FMT(RGB, UNDEFINED, PL, UNSIGNED, ZYX1, 1, X8_Y8_Z8),
201 
203  VPI_IMAGE_FORMAT_RGBA8 = VPI_DETAIL_MAKE_COLOR_FMT(RGB, UNDEFINED, PL, UNSIGNED, XYZW, 1, X8_Y8_Z8_W8),
204 
206  VPI_IMAGE_FORMAT_BGRA8 = VPI_DETAIL_MAKE_COLOR_FMT(RGB, UNDEFINED, PL, UNSIGNED, ZYXW, 1, X8_Y8_Z8_W8),
207 
209  VPI_IMAGE_FORMAT_FORCE64 = INT64_MAX
210  /* \endcond */
212 #ifdef __GNUC__
213 # pragma GCC diagnostic pop
214 #endif
215 
236 #ifdef VPI_DOXYGEN
237 # define VPI_MAKE_YCbCr_IMAGE_FORMAT_ABBREV(colorSpec, chromaSubsamp, memLayout, dataType, swizzle, numPlanes, \
238  packing0, packing1, ...)
239 #else
240 # define VPI_MAKE_YCbCr_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_YCbCr_FMT
241 #endif
242 
265 #ifdef VPI_DOXYGEN
266 # define VPI_MAKE_YCbCr_IMAGE_FORMAT(colorModel, colorSpec, chromaSubsamp, memLayout, dataType, swizzle, numPlanes, \
267  packing0, packing1, ...)
268 #else
269 # define VPI_MAKE_YCbCr_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_YCbCr_FORMAT
270 #endif
271 
295 #ifdef VPI_DOXYGEN
296 # define VPI_MAKE_COLOR_IMAGE_FORMAT_ABBREV(colorModel, colorSpec, memLayout, dataType, swizzle, numPlanes, \
297  packing0, packing1, ...)
298 #else
299 # define VPI_MAKE_COLOR_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_COLOR_FMT
300 #endif
301 
326 #ifdef VPI_DOXYGEN
327 # define VPI_MAKE_COLOR_IMAGE_FORMAT(colorModel, colorSpec, memLayout, dataType, swizzle, numPlanes, packing0, \
328  packing1, ...)
329 #else
330 # define VPI_MAKE_COLOR_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_COLOR_FORMAT
331 #endif
332 
350 #ifdef VPI_DOXYGEN
351 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT_ABBREV(memLayout, dataType, numPlanes, packing0, packing1, ...)
352 #else
353 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_NONCOLOR_FMT
354 #endif
355 
373 #ifdef VPI_DOXYGEN
374 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT(memLayout, dataType, numPlanes, packing0, packing1, ...)
375 #else
376 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_NONCOLOR_FORMAT
377 #endif
378 
398 #ifdef VPI_DOXYGEN
399 # define VPI_MAKE_RAW_IMAGE_FORMAT_ABBREV(rawPattern, memLayout, dataType, numPlanes, swizzle, packing)
400 #else
401 # define VPI_MAKE_RAW_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_RAW_FMT
402 #endif
403 
422 #ifdef VPI_DOXYGEN
423 # define VPI_MAKE_RAW_IMAGE_FORMAT(rawPattern, memLayout, dataType, numPlanes, swizzle, packing)
424 #else
425 # define VPI_MAKE_RAW_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_RAW_FORMAT
426 #endif
427 
446  VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle,
447  VPIPacking packing0, VPIPacking packing1, VPIPacking packing2,
448  VPIPacking packing3);
449 
471  VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle,
472  VPIPacking packing0, VPIPacking packing1, VPIPacking packing2,
473  VPIPacking packing3);
474 
491  VPIPacking packing0, VPIPacking packing1, VPIPacking packing2,
492  VPIPacking packing3);
493 
510 VPI_PUBLIC VPIImageFormat vpiMakeRawImageFormat(VPIRawPattern rawPattern, VPIMemLayout memLayout, VPIDataType dataType,
511  VPISwizzle swizzle, VPIPacking packing0, VPIPacking packing1,
512  VPIPacking packing2, VPIPacking packing3);
513 
524 VPI_PUBLIC VPIImageFormat vpiMakeImageFormatFromFourCC(uint32_t fourcc, VPIColorSpec colorSpec, VPIMemLayout memLayout);
525 
532 VPI_PUBLIC uint32_t vpiImageFormatGetFourCC(VPIImageFormat fmt);
533 
542 
559  VPIPacking packing0, VPIPacking packing1,
560  VPIPacking packing2, VPIPacking packing3);
561 
569 VPI_PUBLIC int vpiImageFormatGetPlaneBitsPerPixel(VPIImageFormat fmt, int plane);
570 
579 
587 
595 
604 
613 
621 
633 
642 
650 
661 
670 
678 VPI_PUBLIC int vpiImageFormatGetPlaneChannelCount(VPIImageFormat fmt, int plane);
679 
687 
695 
701 VPI_PUBLIC void vpiImageFormatGetBitsPerChannel(VPIImageFormat fmt, int32_t *bits);
702 
711 
720 
729  VPIImageFormat plane2, VPIImageFormat plane3);
730 
738 VPI_PUBLIC const char *vpiImageFormatGetName(VPIImageFormat fmt);
739 
748 
758 
778 
781 #ifdef __cplusplus
782 }
783 #endif
784 
785 #endif /* NV_VPI_IMAGE_FORMAT_H */
Defines types and functions to handle color specs.
Defines types and functions to handle data layouts.
VPIPixelType vpiImageFormatGetPlanePixelType(VPIImageFormat fmt, int plane)
Get the pixel type of image format's plane.
VPIChromaSubsampling vpiImageFormatGetChromaSubsampling(VPIImageFormat fmt)
Get the image format's chroma subsampling type.
VPIImageFormat vpiImageFormatGetPlaneFormat(VPIImageFormat fmt, int plane)
Get the plane format of an image format.
int vpiImageFormatHasSameDataLayout(VPIImageFormat a, VPIImageFormat b)
Returns whether the image formats have the same data layout.
VPIMemLayout vpiImageFormatGetMemLayout(VPIImageFormat fmt)
Get the image format's memory layout.
VPIPacking vpiImageFormatGetPlanePacking(VPIImageFormat fmt, int plane)
Get the packing for a given plane of an image format.
VPISwizzle vpiImageFormatGetPlaneSwizzle(VPIImageFormat fmt, int plane)
Get the swizzle operation of the given image format's plane.
VPIImageFormat vpiImageFormatSetMemLayout(VPIImageFormat fmt, VPIMemLayout memLayout)
Set the image format's memory layout.
VPIImageFormat vpiImageFormatSetDataType(VPIImageFormat fmt, VPIDataType dataType)
Set the image format's data type.
VPIImageFormat vpiMakeYCbCrImageFormat(VPIColorSpec colorSpec, VPIChromaSubsampling chromaSub, VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle, VPIPacking packing0, VPIPacking packing1, VPIPacking packing2, VPIPacking packing3)
Creates a user-defined YCbCr color image format.
VPIColorSpec vpiImageFormatGetColorSpec(VPIImageFormat fmt)
Get the image format's color standard.
int vpiImageFormatGetChannelCount(VPIImageFormat fmt)
Get the total number of channels of an image format.
VPIImageFormat vpiMakeImageFormatFromPlanes(VPIImageFormat plane0, VPIImageFormat plane1, VPIImageFormat plane2, VPIImageFormat plane3)
Constructs an image format given the format of each plane.
VPIImageFormat vpiImageFormatSetRawPattern(VPIImageFormat fmt, VPIRawPattern rawPattern)
Sets the raw color pattern of the image format.
VPIImageFormat vpiMakeImageFormatFromFourCC(uint32_t fourcc, VPIColorSpec colorSpec, VPIMemLayout memLayout)
Creates a image format from a FourCC code.
int vpiImageFormatGetPlaneBitsPerPixel(VPIImageFormat fmt, int plane)
Get the image format's plane bits per pixel count.
VPIDataType vpiImageFormatGetDataType(VPIImageFormat fmt)
Get the image format's data type.
VPIImageFormat vpiImageFormatSetSwizzleAndPacking(VPIImageFormat fmt, VPISwizzle swizzle, VPIPacking packing0, VPIPacking packing1, VPIPacking packing2, VPIPacking packing3)
Replaces the swizzle and packing of an existing image format.
VPIRawPattern vpiImageFormatGetRawPattern(VPIImageFormat fmt)
Returns the raw color pattern of the image format.
VPIImageFormat vpiImageFormatSetColorSpec(VPIImageFormat fmt, VPIColorSpec colorSpec)
Set the image format's color standard.
VPIImageFormat vpiMakeColorImageFormat(VPIColorModel colorModel, VPIColorSpec colorSpec, VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle, VPIPacking packing0, VPIPacking packing1, VPIPacking packing2, VPIPacking packing3)
Creates a user-defined color image format.
int vpiImageFormatGetPlaneChannelCount(VPIImageFormat fmt, int plane)
Get the number of channels in a plane of an image format.
VPIImageFormat vpiImageFormatSetChromaSubsampling(VPIImageFormat fmt, VPIChromaSubsampling css)
Set the image format's chroma subsampling type.
VPISwizzle vpiImageFormatGetSwizzle(VPIImageFormat fmt)
Get the image format's channel swizzle operation.
VPIImageFormat vpiMakeNonColorImageFormat(VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle, VPIPacking packing0, VPIPacking packing1, VPIPacking packing2, VPIPacking packing3)
Creates a user-defined non-color image format.
VPIImageFormat vpiMakeRawImageFormat(VPIRawPattern rawPattern, VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle, VPIPacking packing0, VPIPacking packing1, VPIPacking packing2, VPIPacking packing3)
Creates a user-defined raw image format.
VPIColorModel vpiImageFormatGetColorModel(VPIImageFormat fmt)
Get the image format's color model.
void vpiImageFormatGetBitsPerChannel(VPIImageFormat fmt, int32_t *bits)
Get the image format's bit size for each channel.
const char * vpiImageFormatGetName(VPIImageFormat fmt)
Returns a string representation of the image format.
int vpiImageFormatGetPlaneCount(VPIImageFormat fmt)
Get the number of planes of an image format.
uint32_t vpiImageFormatGetFourCC(VPIImageFormat fmt)
Returns the FourCC code corresponding to an image format.
Defines types and functions to handle pixel types.
VPIColorSpec
Color spec definitions.
Definition: ColorSpec.h:162
VPIRawPattern
Defines Bayer patterns used by RAW color model.
Definition: ColorSpec.h:301
VPIColorModel
Defines color models.
Definition: ColorSpec.h:77
VPIChromaSubsampling
Defines how chroma-subsampling is done.
Definition: ColorSpec.h:398
VPISwizzle
Defines the supported channel swizzle operations.
Definition: DataLayout.h:282
VPIPacking
Defines how channels are packed into an image plane element.
Definition: DataLayout.h:128
VPIMemLayout
Defines how the 2D plane pixels are laid out in memory.
Definition: DataLayout.h:225
VPIDataType
Defines the channel data type.
Definition: DataLayout.h:210
VPIImageFormat
Pre-defined image formats.
Definition: ImageFormat.h:99
VPIPixelType
Pre-defined pixel types.
Definition: PixelType.h:84
@ VPI_IMAGE_FORMAT_UYVY_ER
YUV422 8-bit pitch-linear format in one plane with UYVY ordering and full range.
Definition: ImageFormat.h:171
@ VPI_IMAGE_FORMAT_BGR8
Single plane with interleaved BGR 8-bit channel.
Definition: ImageFormat.h:200
@ VPI_IMAGE_FORMAT_RGB8
Single plane with interleaved RGB 8-bit channel.
Definition: ImageFormat.h:197
@ VPI_IMAGE_FORMAT_UYVY_ER_BL
YUV422 8-bit block-linear format in one plane with UYVY ordering and full range.
Definition: ImageFormat.h:174
@ VPI_IMAGE_FORMAT_NV12_ER
YUV420sp 8-bit pitch-linear format with full range.
Definition: ImageFormat.h:152
@ VPI_IMAGE_FORMAT_UYVY_BL
YUV422 8-bit block-linear format in one plane with UYVY ordering and limited range.
Definition: ImageFormat.h:168
@ VPI_IMAGE_FORMAT_INVALID
Denotes an invalid image format.
Definition: ImageFormat.h:101
@ VPI_IMAGE_FORMAT_U16
Single plane with one 16-bit unsigned integer channel.
Definition: ImageFormat.h:110
@ VPI_IMAGE_FORMAT_NV12_BL
YUV420sp 8-bit block-linear format with limited range.
Definition: ImageFormat.h:142
@ VPI_IMAGE_FORMAT_U8
Single plane with one 8-bit unsigned integer channel.
Definition: ImageFormat.h:104
@ VPI_IMAGE_FORMAT_2F32
Single plane with two interleaved 32-bit floating point channels.
Definition: ImageFormat.h:122
@ VPI_IMAGE_FORMAT_BGRA8
Single plane with interleaved BGRA 8-bit channel.
Definition: ImageFormat.h:206
@ VPI_IMAGE_FORMAT_YUYV_BL
YUV422 8-bit block-linear format in one plane with YUVY ordering and limited range.
Definition: ImageFormat.h:184
@ VPI_IMAGE_FORMAT_YUYV_ER
YUV422 8-bit pitch-linear format in one plane with YUVY ordering and full range.
Definition: ImageFormat.h:189
@ VPI_IMAGE_FORMAT_S16
Single plane with one 16-bit signed integer channel.
Definition: ImageFormat.h:113
@ VPI_IMAGE_FORMAT_NV12
YUV420sp 8-bit pitch-linear format with limited range.
Definition: ImageFormat.h:132
@ VPI_IMAGE_FORMAT_F32
Single plane with one 32-bit floating point channel.
Definition: ImageFormat.h:116
@ VPI_IMAGE_FORMAT_YUYV_ER_BL
YUV422 8-bit block-linear format in one plane with YUVY ordering and full range.
Definition: ImageFormat.h:194
@ VPI_IMAGE_FORMAT_S8
Single plane with one 8-bit signed integer channel.
Definition: ImageFormat.h:107
@ VPI_IMAGE_FORMAT_RGBA8
Single plane with interleaved RGBA 8-bit channel.
Definition: ImageFormat.h:203
@ VPI_IMAGE_FORMAT_YUYV
YUV422 8-bit pitch-linear format in one plane with YUVY ordering and mitedrange.
Definition: ImageFormat.h:179
@ VPI_IMAGE_FORMAT_UYVY
YUV422 8-bit pitch-linear format in one plane with UYVY ordering and limited range.
Definition: ImageFormat.h:165
@ VPI_IMAGE_FORMAT_F64
Single plane with one 64-bit floating point channel.
Definition: ImageFormat.h:119
@ VPI_IMAGE_FORMAT_NV12_ER_BL
YUV420sp 8-bit block-linear format with full range.
Definition: ImageFormat.h:162