FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dynlink_nvcuvid.h
Go to the documentation of this file.
1 /*
2  * This copyright notice applies to this header file only:
3  *
4  * Copyright (c) 2010-2016 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  * NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
31  * \date 2015-2015
32  * This file contains the interface constants, structure definitions and function prototypes.
33  */
34 
35 #if !defined(__NVCUVID_H__)
36 #define __NVCUVID_H__
37 
39 
40 #if defined(__cplusplus)
41 extern "C" {
42 #endif /* __cplusplus */
43 
44 ////////////////////////////////////////////////////////////////////////////////////////////////
45 //
46 // High-level helper APIs for video sources
47 //
48 
49 typedef void *CUvideosource;
50 typedef void *CUvideoparser;
51 typedef long long CUvideotimestamp;
52 
53 /**
54  * \addtogroup VIDEO_PARSER Video Parser
55  * @{
56  */
57 
58 /*!
59  * \enum cudaVideoState
60  * Video Source State
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 */
67 
68 /*!
69  * \enum cudaAudioCodec
70  * Audio compression
71  */
72 typedef enum {
73  cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */
74  cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */
75  cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */
76  cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */
77  cudaAudioCodec_LPCM /**< PCM Audio */
79 
80 /*!
81  * \struct CUVIDEOFORMAT
82  * Video format
83  */
84 typedef struct
85 {
86  cudaVideoCodec codec; /**< Compression format */
87  /**
88  * frame rate = numerator / denominator (for example: 30000/1001)
89  */
90  struct {
91  unsigned int numerator; /**< frame rate numerator (0 = unspecified or variable frame rate) */
92  unsigned int denominator; /**< frame rate denominator (0 = unspecified or variable frame rate) */
93  } frame_rate;
94  unsigned char progressive_sequence; /**< 0=interlaced, 1=progressive */
95  unsigned char bit_depth_luma_minus8; /**< high bit depth Luma */
96  unsigned char bit_depth_chroma_minus8; /**< high bit depth Chroma */
97  unsigned char reserved1; /**< Reserved for future use */
98  unsigned int coded_width; /**< coded frame width */
99  unsigned int coded_height; /**< coded frame height */
100  /**
101  * area of the frame that should be displayed
102  * typical example:
103  * coded_width = 1920, coded_height = 1088
104  * display_area = { 0,0,1920,1080 }
105  */
106  struct {
107  int left; /**< left position of display rect */
108  int top; /**< top position of display rect */
109  int right; /**< right position of display rect */
110  int bottom; /**< bottom position of display rect */
111  } display_area;
112  cudaVideoChromaFormat chroma_format; /**< Chroma format */
113  unsigned int bitrate; /**< video bitrate (bps, 0=unknown) */
114  /**
115  * Display Aspect Ratio = x:y (4:3, 16:9, etc)
116  */
117  struct {
118  int x;
119  int y;
120  } display_aspect_ratio;
121  /**
122  * Video Signal Description
123  */
124  struct {
125  unsigned char video_format : 3;
126  unsigned char video_full_range_flag : 1;
127  unsigned char reserved_zero_bits : 4;
128  unsigned char color_primaries;
130  unsigned char matrix_coefficients;
131  } video_signal_description;
132  unsigned int seqhdr_data_length; /**< Additional bytes following (CUVIDEOFORMATEX) */
133 } CUVIDEOFORMAT;
134 
135 /*!
136  * \struct CUVIDEOFORMATEX
137  * Video format including raw sequence header information
138  */
139 typedef struct
140 {
142  unsigned char raw_seqhdr_data[1024];
144 
145 /*!
146  * \struct CUAUDIOFORMAT
147  * Audio Formats
148  */
149 typedef struct
150 {
151  cudaAudioCodec codec; /**< Compression format */
152  unsigned int channels; /**< number of audio channels */
153  unsigned int samplespersec; /**< sampling frequency */
154  unsigned int bitrate; /**< For uncompressed, can also be used to determine bits per sample */
155  unsigned int reserved1; /**< Reserved for future use */
156  unsigned int reserved2; /**< Reserved for future use */
157 } CUAUDIOFORMAT;
158 
159 
160 /*!
161  * \enum CUvideopacketflags
162  * Data packet flags
163  */
164 typedef enum {
165  CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */
166  CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */
167  CUVID_PKT_DISCONTINUITY = 0x04 /**< Set when a discontinuity has to be signalled */
169 
170 /*!
171  * \struct CUVIDSOURCEDATAPACKET
172  * Data Packet
173  */
174 typedef struct _CUVIDSOURCEDATAPACKET
175 {
176  tcu_ulong flags; /**< Combination of CUVID_PKT_XXX flags */
177  tcu_ulong payload_size; /**< number of bytes in the payload (may be zero if EOS flag is set) */
178  const unsigned char *payload; /**< Pointer to packet payload data (may be NULL if EOS flag is set) */
179  CUvideotimestamp timestamp; /**< Presentation timestamp (10MHz clock), only valid if CUVID_PKT_TIMESTAMP flag is set */
181 
182 // Callback for packet delivery
184 
185 /*!
186  * \struct CUVIDSOURCEPARAMS
187  * Source Params
188  */
189 typedef struct _CUVIDSOURCEPARAMS
190 {
191  unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
192  unsigned int uReserved1[7]; /**< Reserved for future use - set to zero */
193  void *pUserData; /**< Parameter passed in to the data handlers */
194  PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< Called to deliver audio packets */
195  PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< Called to deliver video packets */
196  void *pvReserved2[8]; /**< Reserved for future use - set to NULL */
198 
199 /*!
200  * \enum CUvideosourceformat_flags
201  * CUvideosourceformat_flags
202  */
203 typedef enum {
204  CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */
206 
207 #if !defined(__APPLE__)
208 /**
209  * \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
210  * Create Video Source
211  */
212 typedef CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams);
213 
214 /**
215  * \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
216  * Create Video Source
217  */
218 typedef CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams);
219 
220 /**
221  * \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj)
222  * Destroy Video Source
223  */
224 typedef CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj);
225 
226 /**
227  * \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
228  * Set Video Source state
229  */
231 
232 /**
233  * \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj)
234  * Get Video Source state
235  */
237 
238 /**
239  * \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
240  * Get Video Source Format
241  */
242 typedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags);
243 
244 /**
245  * \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
246  * Set Video Source state
247  */
248 typedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags);
249 
250 #endif
251 
252 /**
253  * \struct CUVIDPARSERDISPINFO
254  */
255 typedef struct _CUVIDPARSERDISPINFO
256 {
257  int picture_index; /**< */
258  int progressive_frame; /**< */
259  int top_field_first; /**< */
260  int repeat_first_field; /**< Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, -1=unpaired field) */
261  CUvideotimestamp timestamp; /**< */
263 
264 //
265 // Parser callbacks
266 // The parser will call these synchronously from within cuvidParseVideoData(), whenever a picture is ready to
267 // be decoded and/or displayed.
268 //
272 
273 /**
274  * \struct CUVIDPARSERPARAMS
275  */
276 typedef struct _CUVIDPARSERPARAMS
277 {
278  cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
279  unsigned int ulMaxNumDecodeSurfaces; /**< Max # of decode surfaces (parser will cycle through these) */
280  unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
281  unsigned int ulErrorThreshold; /**< % Error threshold (0-100) for calling pfnDecodePicture (100=always call pfnDecodePicture even if picture bitstream is fully corrupted) */
282  unsigned int ulMaxDisplayDelay; /**< Max display queue delay (improves pipelining of decode with display) - 0=no delay (recommended values: 2..4) */
283  unsigned int uReserved1[5]; /**< Reserved for future use - set to 0 */
284  void *pUserData; /**< User data for callbacks */
285  PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< Called before decoding frames and/or whenever there is a format change */
286  PFNVIDDECODECALLBACK pfnDecodePicture; /**< Called when a picture is ready to be decoded (decode order) */
287  PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< Called whenever a picture is ready to be displayed (display order) */
288  void *pvReserved2[7]; /**< Reserved for future use - set to NULL */
289  CUVIDEOFORMATEX *pExtVideoInfo; /**< [Optional] sequence header data from system layer */
291 
292 /**
293  * \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
294  */
295 typedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams);
296 
297 /**
298  * \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
299  */
300 typedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket);
301 
302 /**
303  * \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj)
304  */
305 typedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj);
306 
307 /** @} */ /* END VIDEO_PARSER */
308 ////////////////////////////////////////////////////////////////////////////////////////////////
309 
310 #if defined(__cplusplus)
311 }
312 #endif /* __cplusplus */
313 
314 #endif // __NVCUVID_H__
315 
316 
int top
top position of display rect
CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj)
tcu_ulong payload_size
number of bytes in the payload (may be zero if EOS flag is set)
CUvideopacketflags
unsigned char reserved1
Reserved for future use.
int right
right position of display rect
unsigned char bit_depth_chroma_minus8
high bit depth Chroma
unsigned int reserved2
Reserved for future use.
tcu_ulong flags
Combination of CUVID_PKT_XXX flags.
unsigned int seqhdr_data_length
Additional bytes following (CUVIDEOFORMATEX)
CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
void * pUserData
Parameter passed in to the data handlers.
PFNVIDSOURCECALLBACK pfnAudioDataHandler
Called to deliver video packets.
Set when this is the last packet for this stream.
unsigned int samplespersec
sampling frequency
CUvideosourceformat_flags
unsigned int numerator
frame rate numerator (0 = unspecified or variable frame rate)
cudaVideoState
unsigned char color_primaries
unsigned int bitrate
For uncompressed, can also be used to determine bits per sample.
CUVIDEOFORMATEX * pExtVideoInfo
[Optional] sequence header data from system layer
static int flags
Definition: log.c:57
int left
left position of display rect
cudaVideoChromaFormat
unsigned char transfer_characteristics
CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
unsigned char bit_depth_luma_minus8
high bit depth Luma
CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
unsigned int reserved1
Reserved for future use.
Source is running and delivering data.
static struct @253 state
CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
int(CUDAAPI * PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *)
Set when a discontinuity has to be signalled.
Source is stopped (or reached end-of-stream)
int bottom
bottom position of display rect
cudaAudioCodec
unsigned int ulClockRate
Timestamp units in Hz (0=default=10000000Hz)
CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
cudaVideoCodec codec
Compression format.
unsigned int coded_width
coded frame width
unsigned int denominator
frame rate denominator (0 = unspecified or variable frame rate)
Return extended format structure (CUVIDEOFORMATEX)
int(CUDAAPI * PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *)
unsigned int ulClockRate
Timestamp units in Hz (0=default=10000000Hz)
unsigned char progressive_sequence
0=interlaced, 1=progressive
CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
unsigned char matrix_coefficients
PFNVIDSEQUENCECALLBACK pfnSequenceCallback
Called before decoding frames and/or whenever there is a format change.
PFNVIDSOURCECALLBACK pfnVideoDataHandler
Called to deliver audio packets.
int(CUDAAPI * PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *)
const unsigned char * payload
Pointer to packet payload data (may be NULL if EOS flag is set)
CUvideotimestamp timestamp
CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj)
unsigned int coded_height
coded frame height
cudaVideoCodec CodecType
cudaVideoCodec_XXX
CUvideotimestamp timestamp
Presentation timestamp (10MHz clock), only valid if CUVID_PKT_TIMESTAMP flag is set.
unsigned int channels
number of audio channels
cudaAudioCodec codec
Compression format.
CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
int
PFNVIDDECODECALLBACK pfnDecodePicture
Called when a picture is ready to be decoded (decode order)
void * pUserData
User data for callbacks.
cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj)
CUVIDEOFORMAT format
unsigned int ulMaxNumDecodeSurfaces
Max # of decode surfaces (parser will cycle through these)
unsigned int bitrate
video bitrate (bps, 0=unknown)
int repeat_first_field
Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, -1=unpaired field) ...
PFNVIDDISPLAYCALLBACK pfnDisplayPicture
Called whenever a picture is ready to be displayed (display order)
unsigned int ulErrorThreshold
% Error threshold (0-100) for calling pfnDecodePicture (100=always call pfnDecodePicture even if pict...
int(CUDAAPI * PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *)
cudaVideoCodec
Error state (invalid source)
unsigned int ulMaxDisplayDelay
Max display queue delay (improves pipelining of decode with display) - 0=no delay (recommended values...
Dolby Digital (AC3) Audio.
cudaVideoChromaFormat chroma_format
Chroma format.
Timestamp is valid.
MPEG-1 Layer III Audio.