VPI - Vision Programming Interface

2.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 typedef uint64_t VPIImageFormat;
95 
97 #define VPI_IMAGE_FORMAT_INVALID ((VPIImageFormat)0)
98 
100 #define VPI_IMAGE_FORMAT_U8 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, UNSIGNED, X000, X8)
101 
103 #define VPI_IMAGE_FORMAT_U8_BL VPI_DETAIL_MAKE_NONCOLOR_FMT1(BL, UNSIGNED, X000, X8)
104 
106 #define VPI_IMAGE_FORMAT_S8 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, SIGNED, X000, X8)
107 
109 #define VPI_IMAGE_FORMAT_U16 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, UNSIGNED, X000, X16)
110 
112 #define VPI_IMAGE_FORMAT_U32 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, UNSIGNED, X000, X32)
113 
115 #define VPI_IMAGE_FORMAT_S32 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, SIGNED, X000, X32)
116 
118 #define VPI_IMAGE_FORMAT_S16 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, SIGNED, X000, X16)
119 
121 #define VPI_IMAGE_FORMAT_S16_BL VPI_DETAIL_MAKE_NONCOLOR_FMT1(BL, SIGNED, X000, X16)
122 
124 #define VPI_IMAGE_FORMAT_2S16 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, SIGNED, XY00, X16_Y16)
125 
127 #define VPI_IMAGE_FORMAT_2S16_BL VPI_DETAIL_MAKE_NONCOLOR_FMT1(BL, SIGNED, XY00, X16_Y16)
128 
130 #define VPI_IMAGE_FORMAT_F32 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, FLOAT, X000, X32)
131 
133 #define VPI_IMAGE_FORMAT_F64 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, FLOAT, X000, X64)
134 
136 #define VPI_IMAGE_FORMAT_2F32 VPI_DETAIL_MAKE_NONCOLOR_FMT1(PL, FLOAT, XY00, X32_Y32)
137 
141 #define VPI_IMAGE_FORMAT_Y8 VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, NONE, PL, UNSIGNED, X000, X8)
142 
146 #define VPI_IMAGE_FORMAT_Y8_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, NONE, BL, UNSIGNED, X000, X8)
147 
151 #define VPI_IMAGE_FORMAT_Y8_ER VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, NONE, PL, UNSIGNED, X000, X8)
152 
156 #define VPI_IMAGE_FORMAT_Y8_ER_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, NONE, BL, UNSIGNED, X000, X8)
157 
161 #define VPI_IMAGE_FORMAT_Y16 VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, NONE, PL, UNSIGNED, X000, X16)
162 
166 #define VPI_IMAGE_FORMAT_Y16_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, NONE, BL, UNSIGNED, X000, X16)
167 
171 #define VPI_IMAGE_FORMAT_Y16_ER VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, NONE, PL, UNSIGNED, X000, X16)
172 
176 #define VPI_IMAGE_FORMAT_Y16_ER_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, NONE, BL, UNSIGNED, X000, X16)
177 
186 #define VPI_IMAGE_FORMAT_NV12 VPI_DETAIL_MAKE_YCbCr_FMT2(BT601, 420, PL, UNSIGNED, XYZ0, X8, X8_Y8)
187 
196 #define VPI_IMAGE_FORMAT_NV12_BL VPI_DETAIL_MAKE_YCbCr_FMT2(BT601, 420, BL, UNSIGNED, XYZ0, X8, X8_Y8)
197 
206 #define VPI_IMAGE_FORMAT_NV12_ER VPI_DETAIL_MAKE_YCbCr_FMT2(BT601_ER, 420, PL, UNSIGNED, XYZ0, X8, X8_Y8)
207 
216 #define VPI_IMAGE_FORMAT_NV12_ER_BL VPI_DETAIL_MAKE_YCbCr_FMT2(BT601_ER, 420, BL, UNSIGNED, XYZ0, X8, X8_Y8)
217 
225 #define VPI_IMAGE_FORMAT_NV24 VPI_DETAIL_MAKE_YCbCr_FMT2(BT601, 444, PL, UNSIGNED, XYZ0, X8, X8_Y8)
226 
234 #define VPI_IMAGE_FORMAT_NV24_BL VPI_DETAIL_MAKE_YCbCr_FMT2(BT601, 444, BL, UNSIGNED, XYZ0, X8, X8_Y8)
235 
243 #define VPI_IMAGE_FORMAT_NV24_ER VPI_DETAIL_MAKE_YCbCr_FMT2(BT601_ER, 444, PL, UNSIGNED, XYZ0, X8, X8_Y8)
244 
252 #define VPI_IMAGE_FORMAT_NV24_ER_BL VPI_DETAIL_MAKE_YCbCr_FMT2(BT601_ER, 444, BL, UNSIGNED, XYZ0, X8, X8_Y8)
253 
255 #define VPI_IMAGE_FORMAT_UYVY VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, 422, PL, UNSIGNED, XYZ1, Y8_X8__Z8_X8)
256 
258 #define VPI_IMAGE_FORMAT_UYVY_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, 422, BL, UNSIGNED, XYZ1, Y8_X8__Z8_X8)
259 
261 #define VPI_IMAGE_FORMAT_UYVY_ER VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, 422, PL, UNSIGNED, XYZ1, Y8_X8__Z8_X8)
262 
264 #define VPI_IMAGE_FORMAT_UYVY_ER_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, 422, BL, UNSIGNED, XYZ1, Y8_X8__Z8_X8)
265 
269 #define VPI_IMAGE_FORMAT_YUYV VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, 422, PL, UNSIGNED, XYZ1, X8_Y8__X8_Z8)
270 
274 #define VPI_IMAGE_FORMAT_YUYV_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601, 422, BL, UNSIGNED, XYZ1, X8_Y8__X8_Z8)
275 
279 #define VPI_IMAGE_FORMAT_YUYV_ER VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, 422, PL, UNSIGNED, XYZ1, X8_Y8__X8_Z8)
280 
284 #define VPI_IMAGE_FORMAT_YUYV_ER_BL VPI_DETAIL_MAKE_YCbCr_FMT1(BT601_ER, 422, BL, UNSIGNED, XYZ1, X8_Y8__X8_Z8)
285 
287 #define VPI_IMAGE_FORMAT_RGB8 VPI_DETAIL_MAKE_COLOR_FMT1(RGB, UNDEFINED, PL, UNSIGNED, XYZ1, X8_Y8_Z8)
288 
290 #define VPI_IMAGE_FORMAT_BGR8 VPI_DETAIL_MAKE_COLOR_FMT1(RGB, UNDEFINED, PL, UNSIGNED, ZYX1, X8_Y8_Z8)
291 
293 #define VPI_IMAGE_FORMAT_RGBA8 VPI_DETAIL_MAKE_COLOR_FMT1(RGB, UNDEFINED, PL, UNSIGNED, XYZW, X8_Y8_Z8_W8)
294 
296 #define VPI_IMAGE_FORMAT_BGRA8 VPI_DETAIL_MAKE_COLOR_FMT1(RGB, UNDEFINED, PL, UNSIGNED, ZYXW, X8_Y8_Z8_W8)
297 
318 #ifdef VPI_DOXYGEN
319 # define VPI_MAKE_YCbCr_IMAGE_FORMAT_ABBREV(colorSpec, chromaSubsamp, memLayout, dataType, swizzle, numPlanes, \
320  packing0, packing1, ...)
321 #else
322 # define VPI_MAKE_YCbCr_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_YCbCr_FMT
323 #endif
324 
347 #ifdef VPI_DOXYGEN
348 # define VPI_MAKE_YCbCr_IMAGE_FORMAT(colorModel, colorSpec, chromaSubsamp, memLayout, dataType, swizzle, numPlanes, \
349  packing0, packing1, ...)
350 #else
351 # define VPI_MAKE_YCbCr_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_YCbCr_FORMAT
352 #endif
353 
376 #ifdef VPI_DOXYGEN
377 # define VPI_MAKE_COLOR_IMAGE_FORMAT_ABBREV(colorModel, colorSpec, memLayout, dataType, swizzle, numPlanes, \
378  packing0, packing1, ...)
379 #else
380 # define VPI_MAKE_COLOR_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_COLOR_FMT
381 #endif
382 
406 #ifdef VPI_DOXYGEN
407 # define VPI_MAKE_COLOR_IMAGE_FORMAT(colorModel, colorSpec, memLayout, dataType, swizzle, numPlanes, packing0, \
408  packing1, ...)
409 #else
410 # define VPI_MAKE_COLOR_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_COLOR_FORMAT
411 #endif
412 
431 #ifdef VPI_DOXYGEN
432 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT_ABBREV(memLayout, dataType, swizzle, numPlanes, packing0, packing1, ...)
433 #else
434 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_NONCOLOR_FMT
435 #endif
436 
454 #ifdef VPI_DOXYGEN
455 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT(memLayout, dataType, swizzle, numPlanes, packing0, packing1, ...)
456 #else
457 # define VPI_MAKE_NONCOLOR_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_NONCOLOR_FORMAT
458 #endif
459 
478 #ifdef VPI_DOXYGEN
479 # define VPI_MAKE_RAW_IMAGE_FORMAT_ABBREV(rawPattern, memLayout, dataType, numPlanes, swizzle, packing)
480 #else
481 # define VPI_MAKE_RAW_IMAGE_FORMAT_ABBREV (VPIImageFormat) VPI_DETAIL_MAKE_RAW_FMT
482 #endif
483 
502 #ifdef VPI_DOXYGEN
503 # define VPI_MAKE_RAW_IMAGE_FORMAT(rawPattern, memLayout, dataType, numPlanes, swizzle, packing)
504 #else
505 # define VPI_MAKE_RAW_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_RAW_FORMAT
506 #endif
507 
530  VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle,
531  VPIPacking packing0, VPIPacking packing1, VPIPacking packing2,
532  VPIPacking packing3);
533 
561  VPIMemLayout memLayout, VPIDataType dataType, VPISwizzle swizzle,
562  VPIPacking packing0, VPIPacking packing1, VPIPacking packing2,
563  VPIPacking packing3);
564 
585  VPIPacking packing0, VPIPacking packing1, VPIPacking packing2,
586  VPIPacking packing3);
587 
608 VPI_PUBLIC VPIImageFormat vpiMakeRawImageFormat(VPIRawPattern rawPattern, VPIMemLayout memLayout, VPIDataType dataType,
609  VPISwizzle swizzle, VPIPacking packing0, VPIPacking packing1,
610  VPIPacking packing2, VPIPacking packing3);
611 
624 VPI_PUBLIC VPIImageFormat vpiMakeImageFormatFromFourCC(uint32_t fourcc, VPIColorSpec colorSpec, VPIMemLayout memLayout);
625 
634 VPI_PUBLIC uint32_t vpiImageFormatGetFourCC(VPIImageFormat fmt);
635 
648 
671  VPIPacking packing0, VPIPacking packing1,
672  VPIPacking packing2, VPIPacking packing3);
673 
685 VPI_PUBLIC int vpiImageFormatGetPlaneBitsPerPixel(VPIImageFormat fmt, int plane);
686 
698 
708 
718 
732 
744 
754 
770 
781 
791 
806 
816 
825 VPI_PUBLIC int vpiImageFormatGetPlaneChannelCount(VPIImageFormat fmt, int plane);
826 
834 
842 
850 VPI_PUBLIC void vpiImageFormatGetBitsPerChannel(VPIImageFormat fmt, int32_t *bits);
851 
864 
877 
902  VPIImageFormat plane2, VPIImageFormat plane3);
903 
912 VPI_PUBLIC const char *vpiImageFormatGetName(VPIImageFormat fmt);
913 
924 
937 
957 
960 #ifdef __cplusplus
961 }
962 #endif
963 
964 #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:303
VPIColorModel
Defines color models.
Definition: ColorSpec.h:77
VPIChromaSubsampling
Defines how chroma-subsampling is done.
Definition: ColorSpec.h:400
VPISwizzle
Defines the supported channel swizzle operations.
Definition: DataLayout.h:337
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:278
VPIDataType
Defines the channel data type.
Definition: DataLayout.h:260
uint64_t VPIPixelType
Pre-defined pixel types.
Definition: PixelType.h:78
uint64_t VPIImageFormat
Pre-defined image formats.
Definition: ImageFormat.h:94