VPI - Vision Programming Interface

0.4.4 Release

ImageFormat.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 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 "Format.h"
60 #include "PixelFormat.h"
61 
62 #include <assert.h>
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
93 typedef enum
94 {
97 
99  VPI_IMAGE_FORMAT_U8 = VPI_DETAIL_MAKE_IMAGE_FORMAT(NONCOLOR, NONE, PL, UNSIGNED, X000, 1, X8),
100 
102  VPI_IMAGE_FORMAT_S8 = VPI_DETAIL_MAKE_IMAGE_FORMAT(NONCOLOR, NONE, PL, SIGNED, X000, 1, X8),
103 
105  VPI_IMAGE_FORMAT_U16 = VPI_DETAIL_MAKE_IMAGE_FORMAT(NONCOLOR, NONE, PL, UNSIGNED, X000, 1, X16),
106 
108  VPI_IMAGE_FORMAT_S16 = VPI_DETAIL_MAKE_IMAGE_FORMAT(NONCOLOR, NONE, PL, SIGNED, X000, 1, X16),
109 
111  VPI_IMAGE_FORMAT_F32 = VPI_DETAIL_MAKE_IMAGE_FORMAT(NONCOLOR, NONE, PL, FLOAT, X000, 1, X32),
112 
114  VPI_IMAGE_FORMAT_F64 = VPI_DETAIL_MAKE_IMAGE_FORMAT(NONCOLOR, NONE, PL, FLOAT, X000, 1, X64),
115 
117  VPI_IMAGE_FORMAT_2F32 = VPI_DETAIL_MAKE_IMAGE_FORMAT(NONCOLOR, NONE, PL, FLOAT, XY00, 1, X32_Y32),
118 
123  VPI_IMAGE_FORMAT_NV12 = VPI_DETAIL_MAKE_IMAGE_FORMAT(YCbCr601_ER, 420_COSITED, PL, UNSIGNED, XYZ0, 2, X8, X8_Y8),
124 
129  VPI_IMAGE_FORMAT_NV12_BL = VPI_DETAIL_MAKE_IMAGE_FORMAT(YCbCr601_ER, 420_COSITED, BL, UNSIGNED, XYZ0, 2, X8, X8_Y8),
130 
132  VPI_IMAGE_FORMAT_RGB8 = VPI_DETAIL_MAKE_IMAGE_FORMAT(RGB, NONE, PL, UNSIGNED, XYZ1, 1, X8_Y8_Z8),
133 
135  VPI_IMAGE_FORMAT_BGR8 = VPI_DETAIL_MAKE_IMAGE_FORMAT(RGB, NONE, PL, UNSIGNED, ZYX1, 1, X8_Y8_Z8),
136 
138  VPI_IMAGE_FORMAT_RGBA8 = VPI_DETAIL_MAKE_IMAGE_FORMAT(RGB, NONE, PL, UNSIGNED, XYZW, 1, X8_Y8_Z8_W8),
139 
141  VPI_IMAGE_FORMAT_BGRA8 = VPI_DETAIL_MAKE_IMAGE_FORMAT(RGB, NONE, PL, UNSIGNED, ZYXW, 1, X8_Y8_Z8_W8),
142 
144  VPI_IMAGE_FORMAT_FORCE64 = INT64_MAX
145  /* \endcond */
147 
165 #ifdef VPI_DOXYGEN
166 # define VPI_MAKE_IMAGE_FORMAT(colorSpace, chromaSubsamp, memLayout, dataType, swizzle, numPlanes, packing0, \
167  packing1, ...)
168 #else
169 # define VPI_MAKE_IMAGE_FORMAT (VPIImageFormat) VPI_DETAIL_MAKE_IMAGE_FORMAT
170 #endif
171 
173 #define vpiMakeImageFormat VPI_APINAME(vpiMakeImageFormat, 004)
174 #define vpiMakeImageFormatFromPlanes VPI_APINAME(vpiMakeImageFormatFromPlanes, 004)
175 #define vpiImageFormatGetPlanePacking VPI_APINAME(vpiImageFormatGetPlanePacking, 004)
176 #define vpiImageFormatGetPlaneBitsPerPixel VPI_APINAME(vpiImageFormatGetPlaneBitsPerPixel, 004)
177 #define vpiImageFormatGetDataType VPI_APINAME(vpiImageFormatGetDataType, 004)
178 #define vpiImageFormatGetSwizzle VPI_APINAME(vpiImageFormatGetSwizzle, 004)
179 #define vpiImageFormatGetSwizzleX VPI_APINAME(vpiImageFormatGetSwizzleX, 004)
180 #define vpiImageFormatGetSwizzleY VPI_APINAME(vpiImageFormatGetSwizzleY, 004)
181 #define vpiImageFormatGetSwizzleZ VPI_APINAME(vpiImageFormatGetSwizzleZ, 004)
182 #define vpiImageFormatGetSwizzleW VPI_APINAME(vpiImageFormatGetSwizzleW, 004)
183 #define vpiImageFormatGetMemLayout VPI_APINAME(vpiImageFormatGetMemLayout, 004)
184 #define vpiImageFormatGetColorSpace VPI_APINAME(vpiImageFormatGetColorSpace, 004)
185 #define vpiImageFormatGetColorModel VPI_APINAME(vpiImageFormatGetColorModel, 004)
186 #define vpiImageFormatGetChromaSubsampling VPI_APINAME(vpiImageFormatGetChromaSubsampling, 004)
187 #define vpiImageFormatGetChromaSubsamplingDivHoriz VPI_APINAME(vpiImageFormatGetChromaSubsamplingDivHoriz, 004)
188 #define vpiImageFormatGetChromaSubsamplingDivVert VPI_APINAME(vpiImageFormatGetChromaSubsamplingDivVert, 004)
189 #define vpiImageFormatGetChromaSubsamplingCenterHoriz VPI_APINAME(vpiImageFormatGetChromaSubsamplingCenterHoriz, 004)
190 #define vpiImageFormatGetChromaSubsamplingCenterVert VPI_APINAME(vpiImageFormatGetChromaSubsamplingCenterVert, 004)
191 #define vpiImageFormatGetPlaneChannelCount VPI_APINAME(vpiImageFormatGetPlaneChannelCount, 004)
192 #define vpiImageFormatGetPlaneCount VPI_APINAME(vpiImageFormatGetPlaneCount, 004)
193 #define vpiImageFormatGetChannelCount VPI_APINAME(vpiImageFormatGetChannelCount, 004)
194 #define vpiImageFormatGetPlaneSwizzle VPI_APINAME(vpiImageFormatGetPlaneSwizzle, 004)
195 #define vpiImageFormatGetPlaneFormat VPI_APINAME(vpiImageFormatGetPlaneFormat, 004)
196 
213  VPIMemLayout memLayout, VPIFormatDataType dataType, VPISwizzle swizzle,
214  VPIFormatPacking packing0, VPIFormatPacking packing1,
215  VPIFormatPacking packing2, VPIFormatPacking packing3);
216 
225 
233 VPI_PUBLIC int vpiImageFormatGetPlaneBitsPerPixel(VPIImageFormat fmt, int plane);
234 
243 
251 
259 
268 
280 
292 
304 
316 
325 
333 
342 
350 
358 
367 
375 
383 
391 
400 
409 
417 VPI_PUBLIC int vpiImageFormatGetPlaneChannelCount(VPIImageFormat fmt, int plane);
418 
426 
434 
443 
452 
461  VPIImageFormat plane2, VPIImageFormat plane3);
462 
465 #ifdef __cplusplus
466 }
467 #endif
468 
469 #endif // NV_VPI_IMAGE_FORMAT_H
VPI_IMAGE_FORMAT_NV12
@ VPI_IMAGE_FORMAT_NV12
YUV420sp 8-bit pitch-linear format composed of two planes:
Definition: ImageFormat.h:123
VPI_IMAGE_FORMAT_INVALID
@ VPI_IMAGE_FORMAT_INVALID
Denotes an invalid image format.
Definition: ImageFormat.h:96
vpiImageFormatGetSwizzleY
VPISwizzleChannel vpiImageFormatGetSwizzleY(VPIImageFormat fmt)
Get the color model channel that corresponds to the second component of given image format.
vpiImageFormatGetPlanePacking
VPIFormatPacking vpiImageFormatGetPlanePacking(VPIImageFormat fmt, int plane)
Get the packing for a given plane of an image format.
vpiImageFormatGetChromaSubsamplingDivHoriz
int vpiImageFormatGetChromaSubsamplingDivHoriz(VPIImageFormat fmt)
Get the image format's chroma subsampling horizontal downscale factor.
VPIChromaSubsampling
VPIChromaSubsampling
Defines how chroma-subsampling is done.
Definition: Format.h:460
vpiImageFormatGetSwizzle
VPISwizzle vpiImageFormatGetSwizzle(VPIImageFormat fmt)
Get the image format's channel swizzle operation.
vpiImageFormatGetPlaneSwizzle
VPISwizzle vpiImageFormatGetPlaneSwizzle(VPIImageFormat fmt, int plane)
Get the swizzle operation of the given image format's plane.
vpiImageFormatGetChannelCount
int vpiImageFormatGetChannelCount(VPIImageFormat fmt)
Get the total number of channels of an image format.
vpiImageFormatGetSwizzleW
VPISwizzleChannel vpiImageFormatGetSwizzleW(VPIImageFormat fmt)
Get the color model channel that corresponds to the fourth component of given image format.
VPI_IMAGE_FORMAT_NV12_BL
@ VPI_IMAGE_FORMAT_NV12_BL
YUV420sp 8-bit block-linear format composed of two planes:
Definition: ImageFormat.h:129
vpiImageFormatGetPlaneChannelCount
int vpiImageFormatGetPlaneChannelCount(VPIImageFormat fmt, int plane)
Get the number of channels in a plane of an image format.
VPISwizzle
VPISwizzle
Defines the supported channel swizzle operations.
Definition: Format.h:276
vpiImageFormatGetPlaneBitsPerPixel
int vpiImageFormatGetPlaneBitsPerPixel(VPIImageFormat fmt, int plane)
Get the image format's plane bits per pixel count.
Format.h
Defines types and functions to handle memory formats.
VPI_IMAGE_FORMAT_U16
@ VPI_IMAGE_FORMAT_U16
Single plane with one 16-bit unsigned integer channel.
Definition: ImageFormat.h:105
VPI_IMAGE_FORMAT_BGRA8
@ VPI_IMAGE_FORMAT_BGRA8
Single plane with interleaved BGRA 8-bit channel.
Definition: ImageFormat.h:141
VPI_IMAGE_FORMAT_BGR8
@ VPI_IMAGE_FORMAT_BGR8
Single plane with interleaved BGR 8-bit channel.
Definition: ImageFormat.h:135
VPIColorSpace
VPIColorSpace
Defines color spaces.
Definition: Format.h:356
vpiImageFormatGetColorSpace
VPIColorSpace vpiImageFormatGetColorSpace(VPIImageFormat fmt)
Get the image format's color space.
VPI_IMAGE_FORMAT_F64
@ VPI_IMAGE_FORMAT_F64
Single plane with one 64-bit floating point channel.
Definition: ImageFormat.h:114
VPIFormatDataType
VPIFormatDataType
Defines the channel data type.
Definition: Format.h:211
VPI_IMAGE_FORMAT_S16
@ VPI_IMAGE_FORMAT_S16
Single plane with one 16-bit signed integer channel.
Definition: ImageFormat.h:108
VPI_IMAGE_FORMAT_S8
@ VPI_IMAGE_FORMAT_S8
Single plane with one 8-bit signed integer channel.
Definition: ImageFormat.h:102
VPIFormatPacking
VPIFormatPacking
Defines how channels are packed into an image plane element.
Definition: Format.h:132
vpiImageFormatGetMemLayout
VPIMemLayout vpiImageFormatGetMemLayout(VPIImageFormat fmt)
Get the image format's memory layout.
vpiImageFormatSetColorSpace
VPIImageFormat vpiImageFormatSetColorSpace(VPIImageFormat fmt, VPIColorSpace colorSpace)
Set the image format's color space.
vpiImageFormatGetDataType
VPIFormatDataType vpiImageFormatGetDataType(VPIImageFormat fmt)
Get the image format's data type.
vpiImageFormatSetMemLayout
VPIImageFormat vpiImageFormatSetMemLayout(VPIImageFormat fmt, VPIMemLayout memLayout)
Set the image format's memory layout.
VPIPixelFormat
VPIPixelFormat
Pre-defined pixel formats.
Definition: PixelFormat.h:80
VPIMemLayout
VPIMemLayout
Defines how the 2D plane pixels are laid out in memory.
Definition: Format.h:224
VPI_IMAGE_FORMAT_U8
@ VPI_IMAGE_FORMAT_U8
Single plane with one 8-bit unsigned integer channel.
Definition: ImageFormat.h:99
vpiImageFormatGetColorModel
VPIColorModel vpiImageFormatGetColorModel(VPIImageFormat fmt)
Get the image format's color model.
VPI_IMAGE_FORMAT_2F32
@ VPI_IMAGE_FORMAT_2F32
Single plane with two interleaved 32-bit floating point channels.
Definition: ImageFormat.h:117
vpiImageFormatGetPlaneFormat
VPIImageFormat vpiImageFormatGetPlaneFormat(VPIImageFormat fmt, int plane)
Get the plane format of an image format.
vpiImageFormatGetChromaSubsamplingCenterHoriz
int vpiImageFormatGetChromaSubsamplingCenterHoriz(VPIImageFormat fmt)
Get the image format's chroma horizontal sample position.
vpiImageFormatSetChromaSubsampling
VPIImageFormat vpiImageFormatSetChromaSubsampling(VPIImageFormat fmt, VPIChromaSubsampling css)
Set the image format's chroma subsampling type.
vpiImageFormatGetSwizzleX
VPISwizzleChannel vpiImageFormatGetSwizzleX(VPIImageFormat fmt)
Get the color model channel that corresponds to the first component of given image format.
VPI_IMAGE_FORMAT_RGB8
@ VPI_IMAGE_FORMAT_RGB8
Single plane with interleaved RGB 8-bit channel.
Definition: ImageFormat.h:132
vpiImageFormatSetDataType
VPIImageFormat vpiImageFormatSetDataType(VPIImageFormat fmt, VPIFormatDataType dataType)
Set the image format's data type.
VPIColorModel
VPIColorModel
Defines color models.
Definition: Format.h:341
VPI_IMAGE_FORMAT_F32
@ VPI_IMAGE_FORMAT_F32
Single plane with one 32-bit floating point channel.
Definition: ImageFormat.h:111
vpiImageFormatGetChromaSubsampling
VPIChromaSubsampling vpiImageFormatGetChromaSubsampling(VPIImageFormat fmt)
Get the image format's chroma subsampling type.
VPISwizzleChannel
VPISwizzleChannel
Defines the format channel names.
Definition: Format.h:259
vpiImageFormatGetChromaSubsamplingCenterVert
int vpiImageFormatGetChromaSubsamplingCenterVert(VPIImageFormat fmt)
Get the image format's chroma vertical sample position.
vpiImageFormatGetPlaneCount
int vpiImageFormatGetPlaneCount(VPIImageFormat fmt)
Get the number of planes of an image format.
vpiImageFormatGetChromaSubsamplingDivVert
int vpiImageFormatGetChromaSubsamplingDivVert(VPIImageFormat fmt)
Get the image format's chroma subsampling vertical downscale factor.
VPI_IMAGE_FORMAT_RGBA8
@ VPI_IMAGE_FORMAT_RGBA8
Single plane with interleaved RGBA 8-bit channel.
Definition: ImageFormat.h:138
vpiImageFormatGetSwizzleZ
VPISwizzleChannel vpiImageFormatGetSwizzleZ(VPIImageFormat fmt)
Get the color model channel that corresponds to the third component of given image format.
VPIImageFormat
VPIImageFormat
Pre-defined image formats.
Definition: ImageFormat.h:94
PixelFormat.h
Defines types and functions to handle pixel formats.
vpiMakeImageFormatFromPlanes
VPIImageFormat vpiMakeImageFormatFromPlanes(VPIImageFormat plane0, VPIImageFormat plane1, VPIImageFormat plane2, VPIImageFormat plane3)
Constructs an image format given the format of each plane.
vpiImageFormatGetPlanePixelFormat
VPIPixelFormat vpiImageFormatGetPlanePixelFormat(VPIImageFormat fmt, int plane)
Get the pixel format of image format's plane.
vpiMakeImageFormat
VPIImageFormat vpiMakeImageFormat(VPIColorSpace colorSpace, VPIChromaSubsampling chromaSub, VPIMemLayout memLayout, VPIFormatDataType dataType, VPISwizzle swizzle, VPIFormatPacking packing0, VPIFormatPacking packing1, VPIFormatPacking packing2, VPIFormatPacking packing3)
Creates an user-defined image format.