| 1 | /* |
| 2 | * This copyright notice applies to this header file only: |
| 3 | * |
| 4 | * Copyright (c) 2010-2022 NVIDIA Corporation |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person |
| 7 | * obtaining a copy of this software and associated documentation |
| 8 | * files (the "Software"), to deal in the Software without |
| 9 | * restriction, including without limitation the rights to use, |
| 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | * copies of the software, and to permit persons to whom the |
| 12 | * software is furnished to do so, subject to the following |
| 13 | * conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be |
| 16 | * included in all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 25 | * OTHER DEALINGS IN THE SOFTWARE. |
| 26 | */ |
| 27 | |
| 28 | /********************************************************************************************************************/ |
| 29 | //! \file nvcuvid.h |
| 30 | //! NVDECODE API provides video decoding interface to NVIDIA GPU devices. |
| 31 | //! \date 2015-2022 |
| 32 | //! This file contains the interface constants, structure definitions and function prototypes. |
| 33 | /********************************************************************************************************************/ |
| 34 | |
| 35 | #if !defined(__NVCUVID_H__) |
| 36 | #define __NVCUVID_H__ |
| 37 | |
| 38 | #include "cuviddec.h" |
| 39 | |
| 40 | #if defined(__cplusplus) |
| 41 | extern "C" { |
| 42 | #endif /* __cplusplus */ |
| 43 | |
| 44 | #define MAX_CLOCK_TS 3 |
| 45 | |
| 46 | /***********************************************/ |
| 47 | //! |
| 48 | //! High-level helper APIs for video sources |
| 49 | //! |
| 50 | /***********************************************/ |
| 51 | |
| 52 | typedef void *CUvideosource; |
| 53 | typedef void *CUvideoparser; |
| 54 | typedef long long CUvideotimestamp; |
| 55 | |
| 56 | |
| 57 | /************************************************************************/ |
| 58 | //! \enum cudaVideoState |
| 59 | //! Video source state enums |
| 60 | //! Used in cuvidSetVideoSourceState and cuvidGetVideoSourceState APIs |
| 61 | /************************************************************************/ |
| 62 | typedef enum { |
| 63 | cudaVideoState_Error = -1, /**< Error state (invalid source) */ |
| 64 | cudaVideoState_Stopped = 0, /**< Source is stopped (or reached end-of-stream) */ |
| 65 | cudaVideoState_Started = 1 /**< Source is running and delivering data */ |
| 66 | } cudaVideoState; |
| 67 | |
| 68 | /************************************************************************/ |
| 69 | //! \enum cudaAudioCodec |
| 70 | //! Audio compression enums |
| 71 | //! Used in CUAUDIOFORMAT structure |
| 72 | /************************************************************************/ |
| 73 | typedef enum { |
| 74 | cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */ |
| 75 | cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */ |
| 76 | cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */ |
| 77 | cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */ |
| 78 | cudaAudioCodec_LPCM, /**< PCM Audio */ |
| 79 | cudaAudioCodec_AAC, /**< AAC Audio */ |
| 80 | } cudaAudioCodec; |
| 81 | |
| 82 | /************************************************************************/ |
| 83 | //! \ingroup STRUCTS |
| 84 | //! \struct HEVCTIMECODESET |
| 85 | //! Used to store Time code extracted from Time code SEI in HEVC codec |
| 86 | /************************************************************************/ |
| 87 | typedef struct _HEVCTIMECODESET |
| 88 | { |
| 89 | unsigned int time_offset_value; |
| 90 | unsigned short n_frames; |
| 91 | unsigned char clock_timestamp_flag; |
| 92 | unsigned char units_field_based_flag; |
| 93 | unsigned char counting_type; |
| 94 | unsigned char full_timestamp_flag; |
| 95 | unsigned char discontinuity_flag; |
| 96 | unsigned char cnt_dropped_flag; |
| 97 | unsigned char seconds_value; |
| 98 | unsigned char minutes_value; |
| 99 | unsigned char hours_value; |
| 100 | unsigned char seconds_flag; |
| 101 | unsigned char minutes_flag; |
| 102 | unsigned char hours_flag; |
| 103 | unsigned char time_offset_length; |
| 104 | unsigned char reserved; |
| 105 | } HEVCTIMECODESET; |
| 106 | |
| 107 | /************************************************************************/ |
| 108 | //! \ingroup STRUCTS |
| 109 | //! \struct HEVCSEITIMECODE |
| 110 | //! Used to extract Time code SEI in HEVC codec |
| 111 | /************************************************************************/ |
| 112 | typedef struct _HEVCSEITIMECODE |
| 113 | { |
| 114 | HEVCTIMECODESET time_code_set[MAX_CLOCK_TS]; |
| 115 | unsigned char num_clock_ts; |
| 116 | } HEVCSEITIMECODE; |
| 117 | |
| 118 | /**********************************************************************************/ |
| 119 | //! \ingroup STRUCTS |
| 120 | //! \struct CUSEIMESSAGE; |
| 121 | //! Used in CUVIDSEIMESSAGEINFO structure |
| 122 | /**********************************************************************************/ |
| 123 | typedef struct _CUSEIMESSAGE |
| 124 | { |
| 125 | unsigned char sei_message_type; /**< OUT: SEI Message Type */ |
| 126 | unsigned char reserved[3]; |
| 127 | unsigned int sei_message_size; /**< OUT: SEI Message Size */ |
| 128 | } CUSEIMESSAGE; |
| 129 | |
| 130 | /************************************************************************************************/ |
| 131 | //! \ingroup STRUCTS |
| 132 | //! \struct CUVIDEOFORMAT |
| 133 | //! Video format |
| 134 | //! Used in cuvidGetSourceVideoFormat API |
| 135 | /************************************************************************************************/ |
| 136 | typedef struct |
| 137 | { |
| 138 | cudaVideoCodec codec; /**< OUT: Compression format */ |
| 139 | /** |
| 140 | * OUT: frame rate = numerator / denominator (for example: 30000/1001) |
| 141 | */ |
| 142 | struct { |
| 143 | /**< OUT: frame rate numerator (0 = unspecified or variable frame rate) */ |
| 144 | unsigned int numerator; |
| 145 | /**< OUT: frame rate denominator (0 = unspecified or variable frame rate) */ |
| 146 | unsigned int denominator; |
| 147 | } frame_rate; |
| 148 | unsigned char progressive_sequence; /**< OUT: 0=interlaced, 1=progressive */ |
| 149 | unsigned char bit_depth_luma_minus8; /**< OUT: high bit depth luma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */ |
| 150 | unsigned char bit_depth_chroma_minus8; /**< OUT: high bit depth chroma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */ |
| 151 | unsigned char min_num_decode_surfaces; /**< OUT: Minimum number of decode surfaces to be allocated for correct |
| 152 | decoding. The client can send this value in ulNumDecodeSurfaces |
| 153 | (in CUVIDDECODECREATEINFO structure). |
| 154 | This guarantees correct functionality and optimal video memory |
| 155 | usage but not necessarily the best performance, which depends on |
| 156 | the design of the overall application. The optimal number of |
| 157 | decode surfaces (in terms of performance and memory utilization) |
| 158 | should be decided by experimentation for each application, but it |
| 159 | cannot go below min_num_decode_surfaces. |
| 160 | If this value is used for ulNumDecodeSurfaces then it must be |
| 161 | returned to parser during sequence callback. */ |
| 162 | unsigned int coded_width; /**< OUT: coded frame width in pixels */ |
| 163 | unsigned int coded_height; /**< OUT: coded frame height in pixels */ |
| 164 | /** |
| 165 | * area of the frame that should be displayed |
| 166 | * typical example: |
| 167 | * coded_width = 1920, coded_height = 1088 |
| 168 | * display_area = { 0,0,1920,1080 } |
| 169 | */ |
| 170 | struct { |
| 171 | int left; /**< OUT: left position of display rect */ |
| 172 | int top; /**< OUT: top position of display rect */ |
| 173 | int right; /**< OUT: right position of display rect */ |
| 174 | int bottom; /**< OUT: bottom position of display rect */ |
| 175 | } display_area; |
| 176 | cudaVideoChromaFormat chroma_format; /**< OUT: Chroma format */ |
| 177 | unsigned int bitrate; /**< OUT: video bitrate (bps, 0=unknown) */ |
| 178 | /** |
| 179 | * OUT: Display Aspect Ratio = x:y (4:3, 16:9, etc) |
| 180 | */ |
| 181 | struct { |
| 182 | int x; |
| 183 | int y; |
| 184 | } display_aspect_ratio; |
| 185 | /** |
| 186 | * Video Signal Description |
| 187 | * Refer section E.2.1 (VUI parameters semantics) of H264 spec file |
| 188 | */ |
| 189 | struct { |
| 190 | unsigned char video_format : 3; /**< OUT: 0-Component, 1-PAL, 2-NTSC, 3-SECAM, 4-MAC, 5-Unspecified */ |
| 191 | unsigned char video_full_range_flag : 1; /**< OUT: indicates the black level and luma and chroma range */ |
| 192 | unsigned char reserved_zero_bits : 4; /**< Reserved bits */ |
| 193 | unsigned char color_primaries; /**< OUT: chromaticity coordinates of source primaries */ |
| 194 | unsigned char transfer_characteristics; /**< OUT: opto-electronic transfer characteristic of the source picture */ |
| 195 | unsigned char matrix_coefficients; /**< OUT: used in deriving luma and chroma signals from RGB primaries */ |
| 196 | } video_signal_description; |
| 197 | unsigned int seqhdr_data_length; /**< OUT: Additional bytes following (CUVIDEOFORMATEX) */ |
| 198 | } CUVIDEOFORMAT; |
| 199 | |
| 200 | /****************************************************************/ |
| 201 | //! \ingroup STRUCTS |
| 202 | //! \struct CUVIDOPERATINGPOINTINFO |
| 203 | //! Operating point information of scalable bitstream |
| 204 | /****************************************************************/ |
| 205 | typedef struct |
| 206 | { |
| 207 | cudaVideoCodec codec; |
| 208 | union |
| 209 | { |
| 210 | struct |
| 211 | { |
| 212 | unsigned char operating_points_cnt; |
| 213 | unsigned char reserved24_bits[3]; |
| 214 | unsigned short operating_points_idc[32]; |
| 215 | } av1; |
| 216 | unsigned char CodecReserved[1024]; |
| 217 | }; |
| 218 | } CUVIDOPERATINGPOINTINFO; |
| 219 | |
| 220 | /**********************************************************************************/ |
| 221 | //! \ingroup STRUCTS |
| 222 | //! \struct CUVIDSEIMESSAGEINFO |
| 223 | //! Used in cuvidParseVideoData API with PFNVIDSEIMSGCALLBACK pfnGetSEIMsg |
| 224 | /**********************************************************************************/ |
| 225 | typedef struct _CUVIDSEIMESSAGEINFO |
| 226 | { |
| 227 | void *pSEIData; /**< OUT: SEI Message Data */ |
| 228 | CUSEIMESSAGE *pSEIMessage; /**< OUT: SEI Message Info */ |
| 229 | unsigned int sei_message_count; /**< OUT: SEI Message Count */ |
| 230 | unsigned int picIdx; /**< OUT: SEI Message Pic Index */ |
| 231 | } CUVIDSEIMESSAGEINFO; |
| 232 | |
| 233 | /****************************************************************/ |
| 234 | //! \ingroup STRUCTS |
| 235 | //! \struct CUVIDAV1SEQHDR |
| 236 | //! AV1 specific sequence header information |
| 237 | /****************************************************************/ |
| 238 | typedef struct { |
| 239 | unsigned int max_width; |
| 240 | unsigned int max_height; |
| 241 | unsigned char reserved[1016]; |
| 242 | } CUVIDAV1SEQHDR; |
| 243 | |
| 244 | /****************************************************************/ |
| 245 | //! \ingroup STRUCTS |
| 246 | //! \struct CUVIDEOFORMATEX |
| 247 | //! Video format including raw sequence header information |
| 248 | //! Used in cuvidGetSourceVideoFormat API |
| 249 | /****************************************************************/ |
| 250 | typedef struct |
| 251 | { |
| 252 | CUVIDEOFORMAT format; /**< OUT: CUVIDEOFORMAT structure */ |
| 253 | union { |
| 254 | CUVIDAV1SEQHDR av1; |
| 255 | unsigned char raw_seqhdr_data[1024]; /**< OUT: Sequence header data */ |
| 256 | }; |
| 257 | } CUVIDEOFORMATEX; |
| 258 | |
| 259 | /****************************************************************/ |
| 260 | //! \ingroup STRUCTS |
| 261 | //! \struct CUAUDIOFORMAT |
| 262 | //! Audio formats |
| 263 | //! Used in cuvidGetSourceAudioFormat API |
| 264 | /****************************************************************/ |
| 265 | typedef struct |
| 266 | { |
| 267 | cudaAudioCodec codec; /**< OUT: Compression format */ |
| 268 | unsigned int channels; /**< OUT: number of audio channels */ |
| 269 | unsigned int samplespersec; /**< OUT: sampling frequency */ |
| 270 | unsigned int bitrate; /**< OUT: For uncompressed, can also be used to determine bits per sample */ |
| 271 | unsigned int reserved1; /**< Reserved for future use */ |
| 272 | unsigned int reserved2; /**< Reserved for future use */ |
| 273 | } CUAUDIOFORMAT; |
| 274 | |
| 275 | |
| 276 | /***************************************************************/ |
| 277 | //! \enum CUvideopacketflags |
| 278 | //! Data packet flags |
| 279 | //! Used in CUVIDSOURCEDATAPACKET structure |
| 280 | /***************************************************************/ |
| 281 | typedef enum { |
| 282 | CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */ |
| 283 | CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */ |
| 284 | CUVID_PKT_DISCONTINUITY = 0x04, /**< Set when a discontinuity has to be signalled */ |
| 285 | CUVID_PKT_ENDOFPICTURE = 0x08, /**< Set when the packet contains exactly one frame or one field */ |
| 286 | CUVID_PKT_NOTIFY_EOS = 0x10, /**< If this flag is set along with CUVID_PKT_ENDOFSTREAM, an additional (dummy) |
| 287 | display callback will be invoked with null value of CUVIDPARSERDISPINFO which |
| 288 | should be interpreted as end of the stream. */ |
| 289 | } CUvideopacketflags; |
| 290 | |
| 291 | /*****************************************************************************/ |
| 292 | //! \ingroup STRUCTS |
| 293 | //! \struct CUVIDSOURCEDATAPACKET |
| 294 | //! Data Packet |
| 295 | //! Used in cuvidParseVideoData API |
| 296 | //! IN for cuvidParseVideoData |
| 297 | /*****************************************************************************/ |
| 298 | typedef struct _CUVIDSOURCEDATAPACKET |
| 299 | { |
| 300 | unsigned long flags; /**< IN: Combination of CUVID_PKT_XXX flags */ |
| 301 | unsigned long payload_size; /**< IN: number of bytes in the payload (may be zero if EOS flag is set) */ |
| 302 | const unsigned char *payload; /**< IN: Pointer to packet payload data (may be NULL if EOS flag is set) */ |
| 303 | CUvideotimestamp timestamp; /**< IN: Presentation time stamp (10MHz clock), only valid if |
| 304 | CUVID_PKT_TIMESTAMP flag is set */ |
| 305 | } CUVIDSOURCEDATAPACKET; |
| 306 | |
| 307 | // Callback for packet delivery |
| 308 | typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *); |
| 309 | |
| 310 | /**************************************************************************************************************************/ |
| 311 | //! \ingroup STRUCTS |
| 312 | //! \struct CUVIDSOURCEPARAMS |
| 313 | //! Describes parameters needed in cuvidCreateVideoSource API |
| 314 | //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported |
| 315 | //! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. |
| 316 | /**************************************************************************************************************************/ |
| 317 | typedef struct _CUVIDSOURCEPARAMS |
| 318 | { |
| 319 | unsigned int ulClockRate; /**< IN: Time stamp units in Hz (0=default=10000000Hz) */ |
| 320 | unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */ |
| 321 | unsigned int uReserved : 31; /**< Reserved for future use - set to zero */ |
| 322 | unsigned int uReserved1[6]; /**< Reserved for future use - set to zero */ |
| 323 | void *pUserData; /**< IN: User private data passed in to the data handlers */ |
| 324 | PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< IN: Called to deliver video packets */ |
| 325 | PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< IN: Called to deliver audio packets. */ |
| 326 | void *pvReserved2[8]; /**< Reserved for future use - set to NULL */ |
| 327 | } CUVIDSOURCEPARAMS; |
| 328 | |
| 329 | |
| 330 | /**********************************************/ |
| 331 | //! \ingroup ENUMS |
| 332 | //! \enum CUvideosourceformat_flags |
| 333 | //! CUvideosourceformat_flags |
| 334 | //! Used in cuvidGetSourceVideoFormat API |
| 335 | /**********************************************/ |
| 336 | typedef enum { |
| 337 | CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */ |
| 338 | } CUvideosourceformat_flags; |
| 339 | |
| 340 | #if !defined(__APPLE__) |
| 341 | /***************************************************************************************************************************/ |
| 342 | //! \ingroup FUNCTS |
| 343 | //! \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams) |
| 344 | //! Create CUvideosource object. CUvideosource spawns demultiplexer thread that provides two callbacks: |
| 345 | //! pfnVideoDataHandler() and pfnAudioDataHandler() |
| 346 | //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported |
| 347 | //! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. |
| 348 | /***************************************************************************************************************************/ |
| 349 | CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams); |
| 350 | |
| 351 | /***************************************************************************************************************************/ |
| 352 | //! \ingroup FUNCTS |
| 353 | //! \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams) |
| 354 | //! Create video source |
| 355 | /***************************************************************************************************************************/ |
| 356 | CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams); |
| 357 | |
| 358 | /********************************************************************/ |
| 359 | //! \ingroup FUNCTS |
| 360 | //! \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj) |
| 361 | //! Destroy video source |
| 362 | /********************************************************************/ |
| 363 | CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj); |
| 364 | |
| 365 | /******************************************************************************************/ |
| 366 | //! \ingroup FUNCTS |
| 367 | //! \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state) |
| 368 | //! Set video source state to: |
| 369 | //! cudaVideoState_Started - to signal the source to run and deliver data |
| 370 | //! cudaVideoState_Stopped - to stop the source from delivering the data |
| 371 | //! cudaVideoState_Error - invalid source |
| 372 | /******************************************************************************************/ |
| 373 | CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state); |
| 374 | |
| 375 | /******************************************************************************************/ |
| 376 | //! \ingroup FUNCTS |
| 377 | //! \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj) |
| 378 | //! Get video source state |
| 379 | //! Returns: |
| 380 | //! cudaVideoState_Started - if Source is running and delivering data |
| 381 | //! cudaVideoState_Stopped - if Source is stopped or reached end-of-stream |
| 382 | //! cudaVideoState_Error - if Source is in error state |
| 383 | /******************************************************************************************/ |
| 384 | cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj); |
| 385 | |
| 386 | /******************************************************************************************************************/ |
| 387 | //! \ingroup FUNCTS |
| 388 | //! \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags) |
| 389 | //! Gets video source format in pvidfmt, flags is set to combination of CUvideosourceformat_flags as per requirement |
| 390 | /******************************************************************************************************************/ |
| 391 | CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags); |
| 392 | |
| 393 | /**************************************************************************************************************************/ |
| 394 | //! \ingroup FUNCTS |
| 395 | //! \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags) |
| 396 | //! Get audio source format |
| 397 | //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported |
| 398 | //! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. |
| 399 | /**************************************************************************************************************************/ |
| 400 | CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags); |
| 401 | |
| 402 | #endif |
| 403 | /**********************************************************************************/ |
| 404 | //! \ingroup STRUCTS |
| 405 | //! \struct CUVIDPARSERDISPINFO |
| 406 | //! Used in cuvidParseVideoData API with PFNVIDDISPLAYCALLBACK pfnDisplayPicture |
| 407 | /**********************************************************************************/ |
| 408 | typedef struct _CUVIDPARSERDISPINFO |
| 409 | { |
| 410 | int picture_index; /**< OUT: Index of the current picture */ |
| 411 | int progressive_frame; /**< OUT: 1 if progressive frame; 0 otherwise */ |
| 412 | int top_field_first; /**< OUT: 1 if top field is displayed first; 0 otherwise */ |
| 413 | int repeat_first_field; /**< OUT: Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, |
| 414 | -1=unpaired field) */ |
| 415 | CUvideotimestamp timestamp; /**< OUT: Presentation time stamp */ |
| 416 | } CUVIDPARSERDISPINFO; |
| 417 | |
| 418 | /***********************************************************************************************************************/ |
| 419 | //! Parser callbacks |
| 420 | //! The parser will call these synchronously from within cuvidParseVideoData(), whenever there is sequence change or a picture |
| 421 | //! is ready to be decoded and/or displayed. First argument in functions is "void *pUserData" member of structure CUVIDSOURCEPARAMS |
| 422 | //! Return values from these callbacks are interpreted as below. If the callbacks return failure, it will be propagated by |
| 423 | //! cuvidParseVideoData() to the application. |
| 424 | //! Parser picks default operating point as 0 and outputAllLayers flag as 0 if PFNVIDOPPOINTCALLBACK is not set or return value is |
| 425 | //! -1 or invalid operating point. |
| 426 | //! PFNVIDSEQUENCECALLBACK : 0: fail, 1: succeeded, > 1: override dpb size of parser (set by CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces |
| 427 | //! while creating parser) |
| 428 | //! PFNVIDDECODECALLBACK : 0: fail, >=1: succeeded |
| 429 | //! PFNVIDDISPLAYCALLBACK : 0: fail, >=1: succeeded |
| 430 | //! PFNVIDOPPOINTCALLBACK : <0: fail, >=0: succeeded (bit 0-9: OperatingPoint, bit 10-10: outputAllLayers, bit 11-30: reserved) |
| 431 | //! PFNVIDSEIMSGCALLBACK : 0: fail, >=1: succeeded |
| 432 | /***********************************************************************************************************************/ |
| 433 | typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *); |
| 434 | typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *); |
| 435 | typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *); |
| 436 | typedef int (CUDAAPI *PFNVIDOPPOINTCALLBACK)(void *, CUVIDOPERATINGPOINTINFO*); |
| 437 | typedef int (CUDAAPI *PFNVIDSEIMSGCALLBACK) (void *, CUVIDSEIMESSAGEINFO *); |
| 438 | |
| 439 | /**************************************/ |
| 440 | //! \ingroup STRUCTS |
| 441 | //! \struct CUVIDPARSERPARAMS |
| 442 | //! Used in cuvidCreateVideoParser API |
| 443 | /**************************************/ |
| 444 | typedef struct _CUVIDPARSERPARAMS |
| 445 | { |
| 446 | cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */ |
| 447 | unsigned int ulMaxNumDecodeSurfaces; /**< IN: Max # of decode surfaces (parser will cycle through these) */ |
| 448 | unsigned int ulClockRate; /**< IN: Timestamp units in Hz (0=default=10000000Hz) */ |
| 449 | unsigned int ulErrorThreshold; /**< IN: % Error threshold (0-100) for calling pfnDecodePicture (100=always |
| 450 | IN: call pfnDecodePicture even if picture bitstream is fully corrupted) */ |
| 451 | unsigned int ulMaxDisplayDelay; /**< IN: Max display queue delay (improves pipelining of decode with display) |
| 452 | 0=no delay (recommended values: 2..4) */ |
| 453 | unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */ |
| 454 | unsigned int uReserved : 31; /**< Reserved for future use - set to zero */ |
| 455 | unsigned int uReserved1[4]; /**< IN: Reserved for future use - set to 0 */ |
| 456 | void *pUserData; /**< IN: User data for callbacks */ |
| 457 | PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */ |
| 458 | PFNVIDDECODECALLBACK pfnDecodePicture; /**< IN: Called when a picture is ready to be decoded (decode order) */ |
| 459 | PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< IN: Called whenever a picture is ready to be displayed (display order) */ |
| 460 | PFNVIDOPPOINTCALLBACK pfnGetOperatingPoint; /**< IN: Called from AV1 sequence header to get operating point of a AV1 |
| 461 | scalable bitstream */ |
| 462 | PFNVIDSEIMSGCALLBACK pfnGetSEIMsg; /**< IN: Called when all SEI messages are parsed for particular frame */ |
| 463 | void *pvReserved2[5]; /**< Reserved for future use - set to NULL */ |
| 464 | CUVIDEOFORMATEX *pExtVideoInfo; /**< IN: [Optional] sequence header data from system layer */ |
| 465 | } CUVIDPARSERPARAMS; |
| 466 | |
| 467 | /************************************************************************************************/ |
| 468 | //! \ingroup FUNCTS |
| 469 | //! \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams) |
| 470 | //! Create video parser object and initialize |
| 471 | /************************************************************************************************/ |
| 472 | CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams); |
| 473 | |
| 474 | /************************************************************************************************/ |
| 475 | //! \ingroup FUNCTS |
| 476 | //! \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket) |
| 477 | //! Parse the video data from source data packet in pPacket |
| 478 | //! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and |
| 479 | //! calls back pfnDecodePicture with CUVIDPICPARAMS data for kicking of HW decoding |
| 480 | //! calls back pfnSequenceCallback with CUVIDEOFORMAT data for initial sequence header or when |
| 481 | //! the decoder encounters a video format change |
| 482 | //! calls back pfnDisplayPicture with CUVIDPARSERDISPINFO data to display a video frame |
| 483 | /************************************************************************************************/ |
| 484 | CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket); |
| 485 | |
| 486 | /************************************************************************************************/ |
| 487 | //! \ingroup FUNCTS |
| 488 | //! \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj) |
| 489 | //! Destroy the video parser |
| 490 | /************************************************************************************************/ |
| 491 | CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj); |
| 492 | |
| 493 | /**********************************************************************************************/ |
| 494 | |
| 495 | #if defined(__cplusplus) |
| 496 | } |
| 497 | #endif /* __cplusplus */ |
| 498 | |
| 499 | #endif // __NVCUVID_H__ |
| 500 | |
| 501 | |