torchcodec 0.7.0__cp313-cp313-win_amd64.whl → 0.8.1__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of torchcodec might be problematic. Click here for more details.

Files changed (66) hide show
  1. torchcodec/_core/AVIOTensorContext.cpp +23 -16
  2. torchcodec/_core/AVIOTensorContext.h +2 -1
  3. torchcodec/_core/BetaCudaDeviceInterface.cpp +718 -0
  4. torchcodec/_core/BetaCudaDeviceInterface.h +193 -0
  5. torchcodec/_core/CMakeLists.txt +18 -3
  6. torchcodec/_core/CUDACommon.cpp +330 -0
  7. torchcodec/_core/CUDACommon.h +51 -0
  8. torchcodec/_core/Cache.h +6 -20
  9. torchcodec/_core/CpuDeviceInterface.cpp +195 -108
  10. torchcodec/_core/CpuDeviceInterface.h +84 -19
  11. torchcodec/_core/CudaDeviceInterface.cpp +227 -376
  12. torchcodec/_core/CudaDeviceInterface.h +38 -6
  13. torchcodec/_core/DeviceInterface.cpp +57 -19
  14. torchcodec/_core/DeviceInterface.h +97 -16
  15. torchcodec/_core/Encoder.cpp +346 -9
  16. torchcodec/_core/Encoder.h +62 -1
  17. torchcodec/_core/FFMPEGCommon.cpp +190 -3
  18. torchcodec/_core/FFMPEGCommon.h +27 -1
  19. torchcodec/_core/FilterGraph.cpp +30 -22
  20. torchcodec/_core/FilterGraph.h +15 -1
  21. torchcodec/_core/Frame.cpp +22 -7
  22. torchcodec/_core/Frame.h +15 -61
  23. torchcodec/_core/Metadata.h +2 -2
  24. torchcodec/_core/NVCUVIDRuntimeLoader.cpp +320 -0
  25. torchcodec/_core/NVCUVIDRuntimeLoader.h +14 -0
  26. torchcodec/_core/NVDECCache.cpp +60 -0
  27. torchcodec/_core/NVDECCache.h +102 -0
  28. torchcodec/_core/SingleStreamDecoder.cpp +196 -201
  29. torchcodec/_core/SingleStreamDecoder.h +42 -15
  30. torchcodec/_core/StreamOptions.h +16 -6
  31. torchcodec/_core/Transform.cpp +87 -0
  32. torchcodec/_core/Transform.h +84 -0
  33. torchcodec/_core/__init__.py +4 -0
  34. torchcodec/_core/custom_ops.cpp +257 -32
  35. torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake +61 -1
  36. torchcodec/_core/nvcuvid_include/cuviddec.h +1374 -0
  37. torchcodec/_core/nvcuvid_include/nvcuvid.h +610 -0
  38. torchcodec/_core/ops.py +147 -44
  39. torchcodec/_core/pybind_ops.cpp +22 -59
  40. torchcodec/_samplers/video_clip_sampler.py +7 -19
  41. torchcodec/decoders/__init__.py +1 -0
  42. torchcodec/decoders/_decoder_utils.py +61 -1
  43. torchcodec/decoders/_video_decoder.py +46 -20
  44. torchcodec/libtorchcodec_core4.dll +0 -0
  45. torchcodec/libtorchcodec_core5.dll +0 -0
  46. torchcodec/libtorchcodec_core6.dll +0 -0
  47. torchcodec/libtorchcodec_core7.dll +0 -0
  48. torchcodec/libtorchcodec_core8.dll +0 -0
  49. torchcodec/libtorchcodec_custom_ops4.dll +0 -0
  50. torchcodec/libtorchcodec_custom_ops5.dll +0 -0
  51. torchcodec/libtorchcodec_custom_ops6.dll +0 -0
  52. torchcodec/libtorchcodec_custom_ops7.dll +0 -0
  53. torchcodec/libtorchcodec_custom_ops8.dll +0 -0
  54. torchcodec/libtorchcodec_pybind_ops4.pyd +0 -0
  55. torchcodec/libtorchcodec_pybind_ops5.pyd +0 -0
  56. torchcodec/libtorchcodec_pybind_ops6.pyd +0 -0
  57. torchcodec/libtorchcodec_pybind_ops7.pyd +0 -0
  58. torchcodec/libtorchcodec_pybind_ops8.pyd +0 -0
  59. torchcodec/samplers/_time_based.py +8 -0
  60. torchcodec/version.py +1 -1
  61. {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/METADATA +29 -16
  62. torchcodec-0.8.1.dist-info/RECORD +82 -0
  63. {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/WHEEL +1 -1
  64. torchcodec-0.7.0.dist-info/RECORD +0 -67
  65. {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/licenses/LICENSE +0 -0
  66. {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,610 @@
1
+ /*
2
+ * This copyright notice applies to this header file only:
3
+ *
4
+ * Copyright (c) 2010-2024 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-2024
32
+ //! This file contains the interface constants, structure definitions and
33
+ //! function prototypes.
34
+ /********************************************************************************************************************/
35
+
36
+ #if !defined(__NVCUVID_H__)
37
+ #define __NVCUVID_H__
38
+
39
+ #include "cuviddec.h"
40
+
41
+ #if defined(__cplusplus)
42
+ extern "C" {
43
+ #endif /* __cplusplus */
44
+
45
+ #define MAX_CLOCK_TS 3
46
+
47
+ /***********************************************/
48
+ //!
49
+ //! High-level helper APIs for video sources
50
+ //!
51
+ /***********************************************/
52
+
53
+ typedef void* CUvideosource;
54
+ typedef void* CUvideoparser;
55
+ typedef long long CUvideotimestamp;
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 =
65
+ 0, /**< Source is stopped (or reached end-of-stream) */
66
+ cudaVideoState_Started = 1 /**< Source is running and delivering data */
67
+ } cudaVideoState;
68
+
69
+ /************************************************************************/
70
+ //! \enum cudaAudioCodec
71
+ //! Audio compression enums
72
+ //! Used in CUAUDIOFORMAT structure
73
+ /************************************************************************/
74
+ typedef enum {
75
+ cudaAudioCodec_MPEG1 = 0, /**< MPEG-1 Audio */
76
+ cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */
77
+ cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */
78
+ cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */
79
+ cudaAudioCodec_LPCM, /**< PCM Audio */
80
+ cudaAudioCodec_AAC, /**< AAC Audio */
81
+ } cudaAudioCodec;
82
+
83
+ /************************************************************************/
84
+ //! \ingroup STRUCTS
85
+ //! \struct TIMECODESET
86
+ //! Used to store Time code set extracted from H264 and HEVC codecs
87
+ /************************************************************************/
88
+ typedef struct _TIMECODESET {
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
+ } TIMECODESET;
106
+
107
+ /************************************************************************/
108
+ //! \ingroup STRUCTS
109
+ //! \struct TIMECODE
110
+ //! Used to extract Time code in H264 and HEVC codecs
111
+ /************************************************************************/
112
+ typedef struct _TIMECODE {
113
+ TIMECODESET time_code_set[MAX_CLOCK_TS];
114
+ unsigned char num_clock_ts;
115
+ } TIMECODE;
116
+
117
+ /**********************************************************************************/
118
+ //! \ingroup STRUCTS
119
+ //! \struct SEIMASTERINGDISPLAYINFO
120
+ //! Used to extract mastering display color volume SEI in H264 and HEVC codecs
121
+ /**********************************************************************************/
122
+ typedef struct _SEIMASTERINGDISPLAYINFO {
123
+ unsigned short display_primaries_x[3];
124
+ unsigned short display_primaries_y[3];
125
+ unsigned short white_point_x;
126
+ unsigned short white_point_y;
127
+ unsigned int max_display_mastering_luminance;
128
+ unsigned int min_display_mastering_luminance;
129
+ } SEIMASTERINGDISPLAYINFO;
130
+
131
+ /**********************************************************************************/
132
+ //! \ingroup STRUCTS
133
+ //! \struct SEICONTENTLIGHTLEVELINFO
134
+ //! Used to extract content light level info SEI in H264 and HEVC codecs
135
+ /**********************************************************************************/
136
+ typedef struct _SEICONTENTLIGHTLEVELINFO {
137
+ unsigned short max_content_light_level;
138
+ unsigned short max_pic_average_light_level;
139
+ unsigned int reserved;
140
+ } SEICONTENTLIGHTLEVELINFO;
141
+
142
+ /**********************************************************************************/
143
+ //! \ingroup STRUCTS
144
+ //! \struct TIMECODEMPEG2
145
+ //! Used to extract Time code in MPEG2 codec
146
+ /**********************************************************************************/
147
+ typedef struct _TIMECODEMPEG2 {
148
+ unsigned char drop_frame_flag;
149
+ unsigned char time_code_hours;
150
+ unsigned char time_code_minutes;
151
+ unsigned char marker_bit;
152
+ unsigned char time_code_seconds;
153
+ unsigned char time_code_pictures;
154
+ } TIMECODEMPEG2;
155
+
156
+ /**********************************************************************************/
157
+ //! \ingroup STRUCTS
158
+ //! \struct SEIALTERNATIVETRANSFERCHARACTERISTICS
159
+ //! Used to extract alternative transfer characteristics SEI in H264 and HEVC
160
+ //! codecs
161
+ /**********************************************************************************/
162
+ typedef struct _SEIALTERNATIVETRANSFERCHARACTERISTICS {
163
+ unsigned char preferred_transfer_characteristics;
164
+ } SEIALTERNATIVETRANSFERCHARACTERISTICS;
165
+
166
+ /**********************************************************************************/
167
+ //! \ingroup STRUCTS
168
+ //! \struct CUSEIMESSAGE;
169
+ //! Used in CUVIDSEIMESSAGEINFO structure
170
+ /**********************************************************************************/
171
+ typedef struct _CUSEIMESSAGE {
172
+ unsigned char sei_message_type; /**< OUT: SEI Message Type */
173
+ unsigned char reserved[3];
174
+ unsigned int sei_message_size; /**< OUT: SEI Message Size */
175
+ } CUSEIMESSAGE;
176
+
177
+ /************************************************************************************************/
178
+ //! \ingroup STRUCTS
179
+ //! \struct CUVIDEOFORMAT
180
+ //! Video format
181
+ //! Used in cuvidGetSourceVideoFormat API
182
+ /************************************************************************************************/
183
+ typedef struct {
184
+ cudaVideoCodec codec; /**< OUT: Compression format */
185
+
186
+ /**
187
+ * OUT: frame rate = numerator / denominator (for example: 30000/1001)
188
+ */
189
+ struct {
190
+ /**< OUT: frame rate numerator (0 = unspecified or variable frame rate) */
191
+ unsigned int numerator;
192
+ /**< OUT: frame rate denominator (0 = unspecified or variable frame rate) */
193
+ unsigned int denominator;
194
+ } frame_rate;
195
+
196
+ unsigned char progressive_sequence; /**< OUT: 0=interlaced, 1=progressive */
197
+ unsigned char bit_depth_luma_minus8; /**< OUT: high bit depth luma. E.g, 2 for
198
+ 10-bitdepth, 4 for 12-bitdepth */
199
+ unsigned char
200
+ bit_depth_chroma_minus8; /**< OUT: high bit depth chroma. E.g, 2 for
201
+ 10-bitdepth, 4 for 12-bitdepth */
202
+ unsigned char
203
+ min_num_decode_surfaces; /**< OUT: Minimum number of decode surfaces to be
204
+ allocated for correct decoding. The client can
205
+ send this value in ulNumDecodeSurfaces (in
206
+ CUVIDDECODECREATEINFO structure). This
207
+ guarantees correct functionality and optimal
208
+ video memory usage but not necessarily the
209
+ best performance, which depends on the design
210
+ of the overall application. The optimal number
211
+ of decode surfaces (in terms of performance
212
+ and memory utilization) should be decided by
213
+ experimentation for each application, but it
214
+ cannot go below
215
+ min_num_decode_surfaces. If this value is used
216
+ for ulNumDecodeSurfaces then it must be
217
+ returned to parser during sequence
218
+ callback. */
219
+ unsigned int coded_width; /**< OUT: coded frame width in pixels */
220
+ unsigned int coded_height; /**< OUT: coded frame height in pixels */
221
+
222
+ /**
223
+ * area of the frame that should be displayed
224
+ * typical example:
225
+ * coded_width = 1920, coded_height = 1088
226
+ * display_area = { 0,0,1920,1080 }
227
+ */
228
+ struct {
229
+ int left; /**< OUT: left position of display rect */
230
+ int top; /**< OUT: top position of display rect */
231
+ int right; /**< OUT: right position of display rect */
232
+ int bottom; /**< OUT: bottom position of display rect */
233
+ } display_area;
234
+
235
+ cudaVideoChromaFormat chroma_format; /**< OUT: Chroma format */
236
+ unsigned int bitrate; /**< OUT: video bitrate (bps, 0=unknown) */
237
+
238
+ /**
239
+ * OUT: Display Aspect Ratio = x:y (4:3, 16:9, etc)
240
+ */
241
+ struct {
242
+ int x;
243
+ int y;
244
+ } display_aspect_ratio;
245
+
246
+ /**
247
+ * Video Signal Description
248
+ * Refer section E.2.1 (VUI parameters semantics) of H264 spec file
249
+ */
250
+ struct {
251
+ unsigned char video_format : 3; /**< OUT: 0-Component, 1-PAL, 2-NTSC,
252
+ 3-SECAM, 4-MAC, 5-Unspecified */
253
+ unsigned char video_full_range_flag : 1; /**< OUT: indicates the black level
254
+ and luma and chroma range */
255
+ unsigned char reserved_zero_bits : 4; /**< Reserved bits */
256
+ unsigned char color_primaries; /**< OUT: chromaticity coordinates of source
257
+ primaries */
258
+ unsigned char
259
+ transfer_characteristics; /**< OUT: opto-electronic transfer
260
+ characteristic of the source picture */
261
+ unsigned char matrix_coefficients; /**< OUT: used in deriving luma and
262
+ chroma signals from RGB primaries */
263
+ } video_signal_description;
264
+
265
+ unsigned int seqhdr_data_length; /**< OUT: Additional bytes following
266
+ (CUVIDEOFORMATEX) */
267
+ } CUVIDEOFORMAT;
268
+
269
+ /****************************************************************/
270
+ //! \ingroup STRUCTS
271
+ //! \struct CUVIDOPERATINGPOINTINFO
272
+ //! Operating point information of scalable bitstream
273
+ /****************************************************************/
274
+ typedef struct {
275
+ cudaVideoCodec codec;
276
+
277
+ union {
278
+ struct {
279
+ unsigned char operating_points_cnt;
280
+ unsigned char reserved24_bits[3];
281
+ unsigned short operating_points_idc[32];
282
+ } av1;
283
+
284
+ unsigned char CodecReserved[1024];
285
+ };
286
+ } CUVIDOPERATINGPOINTINFO;
287
+
288
+ /**********************************************************************************/
289
+ //! \ingroup STRUCTS
290
+ //! \struct CUVIDSEIMESSAGEINFO
291
+ //! Used in cuvidParseVideoData API with PFNVIDSEIMSGCALLBACK pfnGetSEIMsg
292
+ /**********************************************************************************/
293
+ typedef struct _CUVIDSEIMESSAGEINFO {
294
+ void* pSEIData; /**< OUT: SEI Message Data */
295
+ CUSEIMESSAGE* pSEIMessage; /**< OUT: SEI Message Info */
296
+ unsigned int sei_message_count; /**< OUT: SEI Message Count */
297
+ unsigned int picIdx; /**< OUT: SEI Message Pic Index */
298
+ } CUVIDSEIMESSAGEINFO;
299
+
300
+ /****************************************************************/
301
+ //! \ingroup STRUCTS
302
+ //! \struct CUVIDAV1SEQHDR
303
+ //! AV1 specific sequence header information
304
+ /****************************************************************/
305
+ typedef struct {
306
+ unsigned int max_width;
307
+ unsigned int max_height;
308
+ unsigned char reserved[1016];
309
+ } CUVIDAV1SEQHDR;
310
+
311
+ /****************************************************************/
312
+ //! \ingroup STRUCTS
313
+ //! \struct CUVIDEOFORMATEX
314
+ //! Video format including raw sequence header information
315
+ //! Used in cuvidGetSourceVideoFormat API
316
+ /****************************************************************/
317
+ typedef struct {
318
+ CUVIDEOFORMAT format; /**< OUT: CUVIDEOFORMAT structure */
319
+
320
+ union {
321
+ CUVIDAV1SEQHDR av1;
322
+ unsigned char raw_seqhdr_data[1024]; /**< OUT: Sequence header data */
323
+ };
324
+ } CUVIDEOFORMATEX;
325
+
326
+ /****************************************************************/
327
+ //! \ingroup STRUCTS
328
+ //! \struct CUAUDIOFORMAT
329
+ //! Audio formats
330
+ //! Used in cuvidGetSourceAudioFormat API
331
+ /****************************************************************/
332
+ typedef struct {
333
+ cudaAudioCodec codec; /**< OUT: Compression format */
334
+ unsigned int channels; /**< OUT: number of audio channels */
335
+ unsigned int samplespersec; /**< OUT: sampling frequency */
336
+ unsigned int bitrate; /**< OUT: For uncompressed, can also be used to
337
+ determine bits per sample */
338
+ unsigned int reserved1; /**< Reserved for future use */
339
+ unsigned int reserved2; /**< Reserved for future use */
340
+ } CUAUDIOFORMAT;
341
+
342
+ /***************************************************************/
343
+ //! \enum CUvideopacketflags
344
+ //! Data packet flags
345
+ //! Used in CUVIDSOURCEDATAPACKET structure
346
+ /***************************************************************/
347
+ typedef enum {
348
+ CUVID_PKT_ENDOFSTREAM =
349
+ 0x01, /**< Set when this is the last packet for this stream */
350
+ CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */
351
+ CUVID_PKT_DISCONTINUITY =
352
+ 0x04, /**< Set when a discontinuity has to be signalled */
353
+ CUVID_PKT_ENDOFPICTURE =
354
+ 0x08, /**< Set when the packet contains exactly one frame or one field */
355
+ CUVID_PKT_NOTIFY_EOS =
356
+ 0x10, /**< If this flag is set along with CUVID_PKT_ENDOFSTREAM, an
357
+ additional (dummy) display callback will be invoked with null
358
+ value of CUVIDPARSERDISPINFO which should be interpreted as end
359
+ of the stream. */
360
+ } CUvideopacketflags;
361
+
362
+ /*****************************************************************************/
363
+ //! \ingroup STRUCTS
364
+ //! \struct CUVIDSOURCEDATAPACKET
365
+ //! Data Packet
366
+ //! Used in cuvidParseVideoData API
367
+ //! IN for cuvidParseVideoData
368
+ /*****************************************************************************/
369
+ typedef struct _CUVIDSOURCEDATAPACKET {
370
+ unsigned long flags; /**< IN: Combination of CUVID_PKT_XXX flags */
371
+ unsigned long payload_size; /**< IN: number of bytes in the payload (may be
372
+ zero if EOS flag is set) */
373
+ const unsigned char* payload; /**< IN: Pointer to packet payload data (may be
374
+ NULL if EOS flag is set) */
375
+ CUvideotimestamp
376
+ timestamp; /**< IN: Presentation time stamp (10MHz clock), only valid if
377
+ CUVID_PKT_TIMESTAMP flag is set */
378
+ } CUVIDSOURCEDATAPACKET;
379
+
380
+ // Callback for packet delivery
381
+ typedef int(CUDAAPI* PFNVIDSOURCECALLBACK)(void*, CUVIDSOURCEDATAPACKET*);
382
+
383
+ /**************************************************************************************************************************/
384
+ //! \ingroup STRUCTS
385
+ //! \struct CUVIDSOURCEPARAMS
386
+ //! Describes parameters needed in cuvidCreateVideoSource API
387
+ //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource
388
+ //! doesn't have audio demuxer for all supported containers. It's recommended to
389
+ //! clients to use their own or third party demuxer if audio support is needed.
390
+ /**************************************************************************************************************************/
391
+ typedef struct _CUVIDSOURCEPARAMS {
392
+ unsigned int
393
+ ulClockRate; /**< IN: Time stamp units in Hz (0=default=10000000Hz) */
394
+ unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */
395
+ unsigned int uReserved : 31; /**< Reserved for future use - set to zero */
396
+ unsigned int uReserved1[6]; /**< Reserved for future use - set to zero */
397
+ void* pUserData; /**< IN: User private data passed in to the data handlers */
398
+ PFNVIDSOURCECALLBACK
399
+ pfnVideoDataHandler; /**< IN: Called to deliver video packets */
400
+ PFNVIDSOURCECALLBACK
401
+ pfnAudioDataHandler; /**< IN: Called to deliver audio packets. */
402
+ void* pvReserved2[8]; /**< Reserved for future use - set to NULL */
403
+ } CUVIDSOURCEPARAMS;
404
+
405
+ /**********************************************/
406
+ //! \ingroup ENUMS
407
+ //! \enum CUvideosourceformat_flags
408
+ //! CUvideosourceformat_flags
409
+ //! Used in cuvidGetSourceVideoFormat API
410
+ /**********************************************/
411
+ typedef enum {
412
+ CUVID_FMT_EXTFORMATINFO =
413
+ 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */
414
+ } CUvideosourceformat_flags;
415
+
416
+ #if !defined(__APPLE__)
417
+ /***************************************************************************************************************************/
418
+ //! \ingroup FUNCTS
419
+ //! \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char
420
+ //! *pszFileName, CUVIDSOURCEPARAMS *pParams) Create CUvideosource object.
421
+ //! CUvideosource spawns demultiplexer thread that provides two callbacks:
422
+ //! pfnVideoDataHandler() and pfnAudioDataHandler()
423
+ //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource
424
+ //! doesn't have audio demuxer for all supported containers. It's recommended to
425
+ //! clients to use their own or third party demuxer if audio support is needed.
426
+ /***************************************************************************************************************************/
427
+ CUresult CUDAAPI cuvidCreateVideoSource(
428
+ CUvideosource* pObj,
429
+ const char* pszFileName,
430
+ CUVIDSOURCEPARAMS* pParams);
431
+
432
+ /***************************************************************************************************************************/
433
+ //! \ingroup FUNCTS
434
+ //! \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const
435
+ //! wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams) Create video source
436
+ /***************************************************************************************************************************/
437
+ CUresult CUDAAPI cuvidCreateVideoSourceW(
438
+ CUvideosource* pObj,
439
+ const wchar_t* pwszFileName,
440
+ CUVIDSOURCEPARAMS* pParams);
441
+
442
+ /********************************************************************/
443
+ //! \ingroup FUNCTS
444
+ //! \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj)
445
+ //! Destroy video source
446
+ /********************************************************************/
447
+ CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj);
448
+
449
+ /******************************************************************************************/
450
+ //! \ingroup FUNCTS
451
+ //! \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj,
452
+ //! cudaVideoState state) Set video source state to: cudaVideoState_Started - to
453
+ //! signal the source to run and deliver data cudaVideoState_Stopped - to stop
454
+ //! the source from delivering the data cudaVideoState_Error - invalid source
455
+ /******************************************************************************************/
456
+ CUresult CUDAAPI
457
+ cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state);
458
+
459
+ /******************************************************************************************/
460
+ //! \ingroup FUNCTS
461
+ //! \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj)
462
+ //! Get video source state
463
+ //! Returns:
464
+ //! cudaVideoState_Started - if Source is running and delivering data
465
+ //! cudaVideoState_Stopped - if Source is stopped or reached end-of-stream
466
+ //! cudaVideoState_Error - if Source is in error state
467
+ /******************************************************************************************/
468
+ cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj);
469
+
470
+ /******************************************************************************************************************/
471
+ //! \ingroup FUNCTS
472
+ //! \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj,
473
+ //! CUVIDEOFORMAT *pvidfmt, unsigned int flags) Gets video source format in
474
+ //! pvidfmt, flags is set to combination of CUvideosourceformat_flags as per
475
+ //! requirement
476
+ /******************************************************************************************************************/
477
+ CUresult CUDAAPI cuvidGetSourceVideoFormat(
478
+ CUvideosource obj,
479
+ CUVIDEOFORMAT* pvidfmt,
480
+ unsigned int flags);
481
+
482
+ /**************************************************************************************************************************/
483
+ //! \ingroup FUNCTS
484
+ //! \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj,
485
+ //! CUAUDIOFORMAT *paudfmt, unsigned int flags) Get audio source format NVDECODE
486
+ //! API is intended for HW accelerated video decoding so CUvideosource doesn't
487
+ //! have audio demuxer for all supported containers. It's recommended to clients
488
+ //! to use their own or third party demuxer if audio support is needed.
489
+ /**************************************************************************************************************************/
490
+ CUresult CUDAAPI cuvidGetSourceAudioFormat(
491
+ CUvideosource obj,
492
+ CUAUDIOFORMAT* paudfmt,
493
+ unsigned int flags);
494
+
495
+ #endif
496
+ /**********************************************************************************/
497
+ //! \ingroup STRUCTS
498
+ //! \struct CUVIDPARSERDISPINFO
499
+ //! Used in cuvidParseVideoData API with PFNVIDDISPLAYCALLBACK pfnDisplayPicture
500
+ /**********************************************************************************/
501
+ typedef struct _CUVIDPARSERDISPINFO {
502
+ int picture_index; /**< OUT: Index of the current picture */
503
+ int progressive_frame; /**< OUT: 1 if progressive frame; 0 otherwise */
504
+ int top_field_first; /**< OUT: 1 if top field is displayed first; 0 otherwise
505
+ */
506
+ int repeat_first_field; /**< OUT: Number of additional fields (1=ivtc, 2=frame
507
+ doubling, 4=frame tripling, -1=unpaired field) */
508
+ CUvideotimestamp timestamp; /**< OUT: Presentation time stamp */
509
+ } CUVIDPARSERDISPINFO;
510
+
511
+ /***********************************************************************************************************************/
512
+ //! Parser callbacks
513
+ //! The parser will call these synchronously from within cuvidParseVideoData(),
514
+ //! whenever there is sequence change or a picture is ready to be decoded and/or
515
+ //! displayed. First argument in functions is "void *pUserData" member of
516
+ //! structure CUVIDSOURCEPARAMS Return values from these callbacks are
517
+ //! interpreted as below. If the callbacks return failure, it will be propagated
518
+ //! by cuvidParseVideoData() to the application. Parser picks default operating
519
+ //! point as 0 and outputAllLayers flag as 0 if PFNVIDOPPOINTCALLBACK is not set
520
+ //! or return value is -1 or invalid operating point. PFNVIDSEQUENCECALLBACK :
521
+ //! 0: fail, 1: succeeded, > 1: override dpb size of parser (set by
522
+ //! CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces while creating parser)
523
+ //! PFNVIDDECODECALLBACK : 0: fail, >=1: succeeded
524
+ //! PFNVIDDISPLAYCALLBACK : 0: fail, >=1: succeeded
525
+ //! PFNVIDOPPOINTCALLBACK : <0: fail, >=0: succeeded (bit 0-9: OperatingPoint,
526
+ //! bit 10-10: outputAllLayers, bit 11-30: reserved) PFNVIDSEIMSGCALLBACK : 0:
527
+ //! fail, >=1: succeeded
528
+ /***********************************************************************************************************************/
529
+ typedef int(CUDAAPI* PFNVIDSEQUENCECALLBACK)(void*, CUVIDEOFORMAT*);
530
+ typedef int(CUDAAPI* PFNVIDDECODECALLBACK)(void*, CUVIDPICPARAMS*);
531
+ typedef int(CUDAAPI* PFNVIDDISPLAYCALLBACK)(void*, CUVIDPARSERDISPINFO*);
532
+ typedef int(CUDAAPI* PFNVIDOPPOINTCALLBACK)(void*, CUVIDOPERATINGPOINTINFO*);
533
+ typedef int(CUDAAPI* PFNVIDSEIMSGCALLBACK)(void*, CUVIDSEIMESSAGEINFO*);
534
+
535
+ /**************************************/
536
+ //! \ingroup STRUCTS
537
+ //! \struct CUVIDPARSERPARAMS
538
+ //! Used in cuvidCreateVideoParser API
539
+ /**************************************/
540
+ typedef struct _CUVIDPARSERPARAMS {
541
+ cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */
542
+ unsigned int ulMaxNumDecodeSurfaces; /**< IN: Max # of decode surfaces (parser
543
+ will cycle through these) */
544
+ unsigned int
545
+ ulClockRate; /**< IN: Timestamp units in Hz (0=default=10000000Hz) */
546
+ unsigned int ulErrorThreshold; /**< IN: % Error threshold (0-100) for calling
547
+ pfnDecodePicture (100=always IN: call
548
+ pfnDecodePicture even if picture bitstream
549
+ is fully corrupted) */
550
+ unsigned int ulMaxDisplayDelay; /**< IN: Max display queue delay (improves
551
+ pipelining of decode with display) 0=no
552
+ delay (recommended values: 2..4) */
553
+ unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */
554
+ unsigned int uReserved : 31; /**< Reserved for future use - set to zero */
555
+ unsigned int uReserved1[4]; /**< IN: Reserved for future use - set to 0 */
556
+ void* pUserData; /**< IN: User data for callbacks */
557
+ PFNVIDSEQUENCECALLBACK
558
+ pfnSequenceCallback; /**< IN: Called before decoding frames and/or
559
+ whenever there is a fmt change */
560
+ PFNVIDDECODECALLBACK pfnDecodePicture; /**< IN: Called when a picture is ready
561
+ to be decoded (decode order) */
562
+ PFNVIDDISPLAYCALLBACK
563
+ pfnDisplayPicture; /**< IN: Called whenever a picture is ready to be
564
+ displayed (display order) */
565
+ PFNVIDOPPOINTCALLBACK
566
+ pfnGetOperatingPoint; /**< IN: Called from AV1 sequence header to get
567
+ operating point of a AV1 scalable bitstream */
568
+ PFNVIDSEIMSGCALLBACK pfnGetSEIMsg; /**< IN: Called when all SEI messages are
569
+ parsed for particular frame */
570
+ void* pvReserved2[5]; /**< Reserved for future use - set to NULL */
571
+ CUVIDEOFORMATEX* pExtVideoInfo; /**< IN: [Optional] sequence header data from
572
+ system layer */
573
+ } CUVIDPARSERPARAMS;
574
+
575
+ /************************************************************************************************/
576
+ //! \ingroup FUNCTS
577
+ //! \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj,
578
+ //! CUVIDPARSERPARAMS *pParams) Create video parser object and initialize
579
+ /************************************************************************************************/
580
+ CUresult CUDAAPI
581
+ cuvidCreateVideoParser(CUvideoparser* pObj, CUVIDPARSERPARAMS* pParams);
582
+
583
+ /************************************************************************************************/
584
+ //! \ingroup FUNCTS
585
+ //! \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj,
586
+ //! CUVIDSOURCEDATAPACKET *pPacket) Parse the video data from source data packet
587
+ //! in pPacket Extracts parameter sets like SPS, PPS, bitstream etc. from
588
+ //! pPacket and calls back pfnDecodePicture with CUVIDPICPARAMS data for kicking
589
+ //! of HW decoding calls back pfnSequenceCallback with CUVIDEOFORMAT data for
590
+ //! initial sequence header or when the decoder encounters a video format change
591
+ //! calls back pfnDisplayPicture with CUVIDPARSERDISPINFO data to display a
592
+ //! video frame
593
+ /************************************************************************************************/
594
+ CUresult CUDAAPI
595
+ cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET* pPacket);
596
+
597
+ /************************************************************************************************/
598
+ //! \ingroup FUNCTS
599
+ //! \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj)
600
+ //! Destroy the video parser
601
+ /************************************************************************************************/
602
+ CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj);
603
+
604
+ /**********************************************************************************************/
605
+
606
+ #if defined(__cplusplus)
607
+ }
608
+ #endif /* __cplusplus */
609
+
610
+ #endif // __NVCUVID_H__