• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This copyright notice applies to this header file only:
3  *
4  * Copyright (c) 2010-2019 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 cuviddec.h
30 //! NVDECODE API provides video decoding interface to NVIDIA GPU devices.
31 //! \date 2015-2019
32 //! This file contains constants, structure definitions and function prototypes used for decoding.
33 /*****************************************************************************************************/
34 
35 #if !defined(__CUDA_VIDEO_H__)
36 #define __CUDA_VIDEO_H__
37 
38 #ifndef __cuda_cuda_h__
39 #include <cuda.h>
40 #endif // __cuda_cuda_h__
41 
42 #if defined(_WIN64) || defined(__LP64__) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
43 #if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020))
44 #define __CUVID_DEVPTR64
45 #endif
46 #endif
47 
48 #if defined(__cplusplus)
49 extern "C" {
50 #endif /* __cplusplus */
51 
52 typedef void *CUvideodecoder;
53 typedef struct _CUcontextlock_st *CUvideoctxlock;
54 
55 /*********************************************************************************/
56 //! \enum cudaVideoCodec
57 //! Video codec enums
58 //! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures
59 /*********************************************************************************/
60 typedef enum cudaVideoCodec_enum {
61     cudaVideoCodec_MPEG1=0,                                         /**<  MPEG1             */
62     cudaVideoCodec_MPEG2,                                           /**<  MPEG2             */
63     cudaVideoCodec_MPEG4,                                           /**<  MPEG4             */
64     cudaVideoCodec_VC1,                                             /**<  VC1               */
65     cudaVideoCodec_H264,                                            /**<  H264              */
66     cudaVideoCodec_JPEG,                                            /**<  JPEG              */
67     cudaVideoCodec_H264_SVC,                                        /**<  H264-SVC          */
68     cudaVideoCodec_H264_MVC,                                        /**<  H264-MVC          */
69     cudaVideoCodec_HEVC,                                            /**<  HEVC              */
70     cudaVideoCodec_VP8,                                             /**<  VP8               */
71     cudaVideoCodec_VP9,                                             /**<  VP9               */
72     cudaVideoCodec_NumCodecs,                                       /**<  Max codecs        */
73     // Uncompressed YUV
74     cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')),   /**< Y,U,V (4:2:0)      */
75     cudaVideoCodec_YV12   = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')),   /**< Y,V,U (4:2:0)      */
76     cudaVideoCodec_NV12   = (('N'<<24)|('V'<<16)|('1'<<8)|('2')),   /**< Y,UV  (4:2:0)      */
77     cudaVideoCodec_YUYV   = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')),   /**< YUYV/YUY2 (4:2:2)  */
78     cudaVideoCodec_UYVY   = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y'))    /**< UYVY (4:2:2)       */
79 } cudaVideoCodec;
80 
81 /*********************************************************************************/
82 //! \enum cudaVideoSurfaceFormat
83 //! Video surface format enums used for output format of decoded output
84 //! These enums are used in CUVIDDECODECREATEINFO structure
85 /*********************************************************************************/
86 typedef enum cudaVideoSurfaceFormat_enum {
87     cudaVideoSurfaceFormat_NV12=0,          /**< Semi-Planar YUV [Y plane followed by interleaved UV plane]     */
88     cudaVideoSurfaceFormat_P016=1,          /**< 16 bit Semi-Planar YUV [Y plane followed by interleaved UV plane].
89                                                  Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0)      */
90     cudaVideoSurfaceFormat_YUV444=2,        /**< Planar YUV [Y plane followed by U and V planes]                */
91     cudaVideoSurfaceFormat_YUV444_16Bit=3,  /**< 16 bit Planar YUV [Y plane followed by U and V planes].
92                                                  Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0)      */
93 } cudaVideoSurfaceFormat;
94 
95 /******************************************************************************************************************/
96 //! \enum cudaVideoDeinterlaceMode
97 //! Deinterlacing mode enums
98 //! These enums are used in CUVIDDECODECREATEINFO structure
99 //! Use cudaVideoDeinterlaceMode_Weave for progressive content and for content that doesn't need deinterlacing
100 //! cudaVideoDeinterlaceMode_Adaptive needs more video memory than other DImodes
101 /******************************************************************************************************************/
102 typedef enum cudaVideoDeinterlaceMode_enum {
103     cudaVideoDeinterlaceMode_Weave=0,   /**< Weave both fields (no deinterlacing) */
104     cudaVideoDeinterlaceMode_Bob,       /**< Drop one field                       */
105     cudaVideoDeinterlaceMode_Adaptive   /**< Adaptive deinterlacing               */
106 } cudaVideoDeinterlaceMode;
107 
108 /**************************************************************************************************************/
109 //! \enum cudaVideoChromaFormat
110 //! Chroma format enums
111 //! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures
112 /**************************************************************************************************************/
113 typedef enum cudaVideoChromaFormat_enum {
114     cudaVideoChromaFormat_Monochrome=0,  /**< MonoChrome */
115     cudaVideoChromaFormat_420,           /**< YUV 4:2:0  */
116     cudaVideoChromaFormat_422,           /**< YUV 4:2:2  */
117     cudaVideoChromaFormat_444            /**< YUV 4:4:4  */
118 } cudaVideoChromaFormat;
119 
120 /*************************************************************************************************************/
121 //! \enum cudaVideoCreateFlags
122 //! Decoder flag enums to select preferred decode path
123 //! cudaVideoCreate_Default and cudaVideoCreate_PreferCUVID are most optimized, use these whenever possible
124 /*************************************************************************************************************/
125 typedef enum cudaVideoCreateFlags_enum {
126     cudaVideoCreate_Default     = 0x00,     /**< Default operation mode: use dedicated video engines                        */
127     cudaVideoCreate_PreferCUDA  = 0x01,     /**< Use CUDA-based decoder (requires valid vidLock object for multi-threading) */
128     cudaVideoCreate_PreferDXVA  = 0x02,     /**< Go through DXVA internally if possible (requires D3D9 interop)             */
129     cudaVideoCreate_PreferCUVID = 0x04      /**< Use dedicated video engines directly                                       */
130 } cudaVideoCreateFlags;
131 
132 
133 /*************************************************************************/
134 //! \enum cuvidDecodeStatus
135 //! Decode status enums
136 //! These enums are used in CUVIDGETDECODESTATUS structure
137 /*************************************************************************/
138 typedef enum cuvidDecodeStatus_enum
139 {
140     cuvidDecodeStatus_Invalid         = 0,   // Decode status is not valid
141     cuvidDecodeStatus_InProgress      = 1,   // Decode is in progress
142     cuvidDecodeStatus_Success         = 2,   // Decode is completed without any errors
143     // 3 to 7 enums are reserved for future use
144     cuvidDecodeStatus_Error           = 8,   // Decode is completed with an error (error is not concealed)
145     cuvidDecodeStatus_Error_Concealed = 9,   // Decode is completed with an error and error is concealed
146 } cuvidDecodeStatus;
147 
148 /**************************************************************************************************************/
149 //! \struct CUVIDDECODECAPS;
150 //! This structure is used in cuvidGetDecoderCaps API
151 /**************************************************************************************************************/
152 typedef struct _CUVIDDECODECAPS
153 {
154     cudaVideoCodec          eCodecType;                 /**< IN: cudaVideoCodec_XXX                                             */
155     cudaVideoChromaFormat   eChromaFormat;              /**< IN: cudaVideoChromaFormat_XXX                                      */
156     unsigned int            nBitDepthMinus8;            /**< IN: The Value "BitDepth minus 8"                                   */
157     unsigned int            reserved1[3];               /**< Reserved for future use - set to zero                              */
158 
159     unsigned char           bIsSupported;               /**< OUT: 1 if codec supported, 0 if not supported                      */
160     unsigned char           reserved2;                  /**< Reserved for future use - set to zero                              */
161     unsigned short          nOutputFormatMask;          /**< OUT: each bit represents corresponding cudaVideoSurfaceFormat enum */
162     unsigned int            nMaxWidth;                  /**< OUT: Max supported coded width in pixels                           */
163     unsigned int            nMaxHeight;                 /**< OUT: Max supported coded height in pixels                          */
164     unsigned int            nMaxMBCount;                /**< OUT: Max supported macroblock count
165                                                                   CodedWidth*CodedHeight/256 must be <= nMaxMBCount             */
166     unsigned short          nMinWidth;                  /**< OUT: Min supported coded width in pixels                           */
167     unsigned short          nMinHeight;                 /**< OUT: Min supported coded height in pixels                          */
168     unsigned int            reserved3[11];              /**< Reserved for future use - set to zero                              */
169 } CUVIDDECODECAPS;
170 
171 /**************************************************************************************************************/
172 //! \struct CUVIDDECODECREATEINFO
173 //! This structure is used in cuvidCreateDecoder API
174 /**************************************************************************************************************/
175 typedef struct _CUVIDDECODECREATEINFO
176 {
177     unsigned long ulWidth;              /**< IN: Coded sequence width in pixels                                             */
178     unsigned long ulHeight;             /**< IN: Coded sequence height in pixels                                            */
179     unsigned long ulNumDecodeSurfaces;  /**< IN: Maximum number of internal decode surfaces                                 */
180     cudaVideoCodec CodecType;           /**< IN: cudaVideoCodec_XXX                                                         */
181     cudaVideoChromaFormat ChromaFormat; /**< IN: cudaVideoChromaFormat_XXX                                                  */
182     unsigned long ulCreationFlags;      /**< IN: Decoder creation flags (cudaVideoCreateFlags_XXX)                          */
183     unsigned long bitDepthMinus8;       /**< IN: The value "BitDepth minus 8"                                               */
184     unsigned long ulIntraDecodeOnly;    /**< IN: Set 1 only if video has all intra frames (default value is 0). This will
185                                              optimize video memory for Intra frames only decoding. The support is limited
186                                              to specific codecs - H264, HEVC, VP9, the flag will be ignored for codecs which
187                                              are not supported. However decoding might fail if the flag is enabled in case
188                                              of supported codecs for regular bit streams having P and/or B frames.          */
189     unsigned long ulMaxWidth;           /**< IN: Coded sequence max width in pixels used with reconfigure Decoder           */
190     unsigned long ulMaxHeight;          /**< IN: Coded sequence max height in pixels used with reconfigure Decoder          */
191     unsigned long Reserved1;            /**< Reserved for future use - set to zero                                          */
192     /**
193     * IN: area of the frame that should be displayed
194     */
195     struct {
196         short left;
197         short top;
198         short right;
199         short bottom;
200     } display_area;
201 
202     cudaVideoSurfaceFormat OutputFormat;       /**< IN: cudaVideoSurfaceFormat_XXX                                     */
203     cudaVideoDeinterlaceMode DeinterlaceMode;  /**< IN: cudaVideoDeinterlaceMode_XXX                                   */
204     unsigned long ulTargetWidth;               /**< IN: Post-processed output width (Should be aligned to 2)           */
205     unsigned long ulTargetHeight;              /**< IN: Post-processed output height (Should be aligned to 2)          */
206     unsigned long ulNumOutputSurfaces;         /**< IN: Maximum number of output surfaces simultaneously mapped        */
207     CUvideoctxlock vidLock;                    /**< IN: If non-NULL, context lock used for synchronizing ownership of
208                                                     the cuda context. Needed for cudaVideoCreate_PreferCUDA decode     */
209     /**
210     * IN: target rectangle in the output frame (for aspect ratio conversion)
211     * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
212     */
213     struct {
214         short left;
215         short top;
216         short right;
217         short bottom;
218     } target_rect;
219     unsigned long Reserved2[5];                /**< Reserved for future use - set to zero */
220 } CUVIDDECODECREATEINFO;
221 
222 /*********************************************************/
223 //! \struct CUVIDH264DPBENTRY
224 //! H.264 DPB entry
225 //! This structure is used in CUVIDH264PICPARAMS structure
226 /*********************************************************/
227 typedef struct _CUVIDH264DPBENTRY
228 {
229     int PicIdx;                 /**< picture index of reference frame                                        */
230     int FrameIdx;               /**< frame_num(short-term) or LongTermFrameIdx(long-term)                    */
231     int is_long_term;           /**< 0=short term reference, 1=long term reference                           */
232     int not_existing;           /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
233     int used_for_reference;     /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields                    */
234     int FieldOrderCnt[2];       /**< field order count of top and bottom fields                              */
235 } CUVIDH264DPBENTRY;
236 
237 /************************************************************/
238 //! \struct CUVIDH264MVCEXT
239 //! H.264 MVC picture parameters ext
240 //! This structure is used in CUVIDH264PICPARAMS structure
241 /************************************************************/
242 typedef struct _CUVIDH264MVCEXT
243 {
244     int num_views_minus1;                  /**< Max number of coded views minus 1 in video : Range - 0 to 1023              */
245     int view_id;                           /**< view identifier                                                             */
246     unsigned char inter_view_flag;         /**< 1 if used for inter-view prediction, 0 if not                               */
247     unsigned char num_inter_view_refs_l0;  /**< number of inter-view ref pics in RefPicList0                                */
248     unsigned char num_inter_view_refs_l1;  /**< number of inter-view ref pics in RefPicList1                                */
249     unsigned char MVCReserved8Bits;        /**< Reserved bits                                                               */
250     int InterViewRefsL0[16];               /**< view id of the i-th view component for inter-view prediction in RefPicList0 */
251     int InterViewRefsL1[16];               /**< view id of the i-th view component for inter-view prediction in RefPicList1 */
252 } CUVIDH264MVCEXT;
253 
254 /*********************************************************/
255 //! \struct CUVIDH264SVCEXT
256 //! H.264 SVC picture parameters ext
257 //! This structure is used in CUVIDH264PICPARAMS structure
258 /*********************************************************/
259 typedef struct _CUVIDH264SVCEXT
260 {
261     unsigned char profile_idc;
262     unsigned char level_idc;
263     unsigned char DQId;
264     unsigned char DQIdMax;
265     unsigned char disable_inter_layer_deblocking_filter_idc;
266     unsigned char ref_layer_chroma_phase_y_plus1;
267     signed char   inter_layer_slice_alpha_c0_offset_div2;
268     signed char   inter_layer_slice_beta_offset_div2;
269 
270     unsigned short DPBEntryValidFlag;
271     unsigned char inter_layer_deblocking_filter_control_present_flag;
272     unsigned char extended_spatial_scalability_idc;
273     unsigned char adaptive_tcoeff_level_prediction_flag;
274     unsigned char slice_header_restriction_flag;
275     unsigned char chroma_phase_x_plus1_flag;
276     unsigned char chroma_phase_y_plus1;
277 
278     unsigned char tcoeff_level_prediction_flag;
279     unsigned char constrained_intra_resampling_flag;
280     unsigned char ref_layer_chroma_phase_x_plus1_flag;
281     unsigned char store_ref_base_pic_flag;
282     unsigned char Reserved8BitsA;
283     unsigned char Reserved8BitsB;
284 
285     short scaled_ref_layer_left_offset;
286     short scaled_ref_layer_top_offset;
287     short scaled_ref_layer_right_offset;
288     short scaled_ref_layer_bottom_offset;
289     unsigned short Reserved16Bits;
290     struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded.
291                                              Linked list ends at the target layer. */
292     int bRefBaseLayer;                  /**< whether to store ref base pic */
293 } CUVIDH264SVCEXT;
294 
295 /******************************************************/
296 //! \struct CUVIDH264PICPARAMS
297 //! H.264 picture parameters
298 //! This structure is used in CUVIDPICPARAMS structure
299 /******************************************************/
300 typedef struct _CUVIDH264PICPARAMS
301 {
302     // SPS
303     int log2_max_frame_num_minus4;
304     int pic_order_cnt_type;
305     int log2_max_pic_order_cnt_lsb_minus4;
306     int delta_pic_order_always_zero_flag;
307     int frame_mbs_only_flag;
308     int direct_8x8_inference_flag;
309     int num_ref_frames;             // NOTE: shall meet level 4.1 restrictions
310     unsigned char residual_colour_transform_flag;
311     unsigned char bit_depth_luma_minus8;    // Must be 0 (only 8-bit supported)
312     unsigned char bit_depth_chroma_minus8;  // Must be 0 (only 8-bit supported)
313     unsigned char qpprime_y_zero_transform_bypass_flag;
314     // PPS
315     int entropy_coding_mode_flag;
316     int pic_order_present_flag;
317     int num_ref_idx_l0_active_minus1;
318     int num_ref_idx_l1_active_minus1;
319     int weighted_pred_flag;
320     int weighted_bipred_idc;
321     int pic_init_qp_minus26;
322     int deblocking_filter_control_present_flag;
323     int redundant_pic_cnt_present_flag;
324     int transform_8x8_mode_flag;
325     int MbaffFrameFlag;
326     int constrained_intra_pred_flag;
327     int chroma_qp_index_offset;
328     int second_chroma_qp_index_offset;
329     int ref_pic_flag;
330     int frame_num;
331     int CurrFieldOrderCnt[2];
332     // DPB
333     CUVIDH264DPBENTRY dpb[16];          // List of reference frames within the DPB
334     // Quantization Matrices (raster-order)
335     unsigned char WeightScale4x4[6][16];
336     unsigned char WeightScale8x8[2][64];
337     // FMO/ASO
338     unsigned char fmo_aso_enable;
339     unsigned char num_slice_groups_minus1;
340     unsigned char slice_group_map_type;
341     signed char pic_init_qs_minus26;
342     unsigned int slice_group_change_rate_minus1;
343     union
344     {
345         unsigned long long slice_group_map_addr;
346         const unsigned char *pMb2SliceGroupMap;
347     } fmo;
348     unsigned int  Reserved[12];
349     // SVC/MVC
350     union
351     {
352         CUVIDH264MVCEXT mvcext;
353         CUVIDH264SVCEXT svcext;
354     };
355 } CUVIDH264PICPARAMS;
356 
357 
358 /********************************************************/
359 //! \struct CUVIDMPEG2PICPARAMS
360 //! MPEG-2 picture parameters
361 //! This structure is used in CUVIDPICPARAMS structure
362 /********************************************************/
363 typedef struct _CUVIDMPEG2PICPARAMS
364 {
365     int ForwardRefIdx;          // Picture index of forward reference (P/B-frames)
366     int BackwardRefIdx;         // Picture index of backward reference (B-frames)
367     int picture_coding_type;
368     int full_pel_forward_vector;
369     int full_pel_backward_vector;
370     int f_code[2][2];
371     int intra_dc_precision;
372     int frame_pred_frame_dct;
373     int concealment_motion_vectors;
374     int q_scale_type;
375     int intra_vlc_format;
376     int alternate_scan;
377     int top_field_first;
378     // Quantization matrices (raster order)
379     unsigned char QuantMatrixIntra[64];
380     unsigned char QuantMatrixInter[64];
381 } CUVIDMPEG2PICPARAMS;
382 
383 // MPEG-4 has VOP types instead of Picture types
384 #define I_VOP 0
385 #define P_VOP 1
386 #define B_VOP 2
387 #define S_VOP 3
388 
389 /*******************************************************/
390 //! \struct CUVIDMPEG4PICPARAMS
391 //! MPEG-4 picture parameters
392 //! This structure is used in CUVIDPICPARAMS structure
393 /*******************************************************/
394 typedef struct _CUVIDMPEG4PICPARAMS
395 {
396     int ForwardRefIdx;          // Picture index of forward reference (P/B-frames)
397     int BackwardRefIdx;         // Picture index of backward reference (B-frames)
398     // VOL
399     int video_object_layer_width;
400     int video_object_layer_height;
401     int vop_time_increment_bitcount;
402     int top_field_first;
403     int resync_marker_disable;
404     int quant_type;
405     int quarter_sample;
406     int short_video_header;
407     int divx_flags;
408     // VOP
409     int vop_coding_type;
410     int vop_coded;
411     int vop_rounding_type;
412     int alternate_vertical_scan_flag;
413     int interlaced;
414     int vop_fcode_forward;
415     int vop_fcode_backward;
416     int trd[2];
417     int trb[2];
418     // Quantization matrices (raster order)
419     unsigned char QuantMatrixIntra[64];
420     unsigned char QuantMatrixInter[64];
421     int gmc_enabled;
422 } CUVIDMPEG4PICPARAMS;
423 
424 /********************************************************/
425 //! \struct CUVIDVC1PICPARAMS
426 //! VC1 picture parameters
427 //! This structure is used in CUVIDPICPARAMS structure
428 /********************************************************/
429 typedef struct _CUVIDVC1PICPARAMS
430 {
431     int ForwardRefIdx;      /**< Picture index of forward reference (P/B-frames) */
432     int BackwardRefIdx;     /**< Picture index of backward reference (B-frames)  */
433     int FrameWidth;         /**< Actual frame width                              */
434     int FrameHeight;        /**< Actual frame height                             */
435     // PICTURE
436     int intra_pic_flag;     /**< Set to 1 for I,BI frames */
437     int ref_pic_flag;       /**< Set to 1 for I,P frames  */
438     int progressive_fcm;    /**< Progressive frame        */
439     // SEQUENCE
440     int profile;
441     int postprocflag;
442     int pulldown;
443     int interlace;
444     int tfcntrflag;
445     int finterpflag;
446     int psf;
447     int multires;
448     int syncmarker;
449     int rangered;
450     int maxbframes;
451     // ENTRYPOINT
452     int panscan_flag;
453     int refdist_flag;
454     int extended_mv;
455     int dquant;
456     int vstransform;
457     int loopfilter;
458     int fastuvmc;
459     int overlap;
460     int quantizer;
461     int extended_dmv;
462     int range_mapy_flag;
463     int range_mapy;
464     int range_mapuv_flag;
465     int range_mapuv;
466     int rangeredfrm;    // range reduction state
467 } CUVIDVC1PICPARAMS;
468 
469 /***********************************************************/
470 //! \struct CUVIDJPEGPICPARAMS
471 //! JPEG picture parameters
472 //! This structure is used in CUVIDPICPARAMS structure
473 /***********************************************************/
474 typedef struct _CUVIDJPEGPICPARAMS
475 {
476     int Reserved;
477 } CUVIDJPEGPICPARAMS;
478 
479 
480 /*******************************************************/
481 //! \struct CUVIDHEVCPICPARAMS
482 //! HEVC picture parameters
483 //! This structure is used in CUVIDPICPARAMS structure
484 /*******************************************************/
485 typedef struct _CUVIDHEVCPICPARAMS
486 {
487     // sps
488     int pic_width_in_luma_samples;
489     int pic_height_in_luma_samples;
490     unsigned char log2_min_luma_coding_block_size_minus3;
491     unsigned char log2_diff_max_min_luma_coding_block_size;
492     unsigned char log2_min_transform_block_size_minus2;
493     unsigned char log2_diff_max_min_transform_block_size;
494     unsigned char pcm_enabled_flag;
495     unsigned char log2_min_pcm_luma_coding_block_size_minus3;
496     unsigned char log2_diff_max_min_pcm_luma_coding_block_size;
497     unsigned char pcm_sample_bit_depth_luma_minus1;
498 
499     unsigned char pcm_sample_bit_depth_chroma_minus1;
500     unsigned char pcm_loop_filter_disabled_flag;
501     unsigned char strong_intra_smoothing_enabled_flag;
502     unsigned char max_transform_hierarchy_depth_intra;
503     unsigned char max_transform_hierarchy_depth_inter;
504     unsigned char amp_enabled_flag;
505     unsigned char separate_colour_plane_flag;
506     unsigned char log2_max_pic_order_cnt_lsb_minus4;
507 
508     unsigned char num_short_term_ref_pic_sets;
509     unsigned char long_term_ref_pics_present_flag;
510     unsigned char num_long_term_ref_pics_sps;
511     unsigned char sps_temporal_mvp_enabled_flag;
512     unsigned char sample_adaptive_offset_enabled_flag;
513     unsigned char scaling_list_enable_flag;
514     unsigned char IrapPicFlag;
515     unsigned char IdrPicFlag;
516 
517     unsigned char bit_depth_luma_minus8;
518     unsigned char bit_depth_chroma_minus8;
519     //sps/pps extension fields
520     unsigned char log2_max_transform_skip_block_size_minus2;
521     unsigned char log2_sao_offset_scale_luma;
522     unsigned char log2_sao_offset_scale_chroma;
523     unsigned char high_precision_offsets_enabled_flag;
524     unsigned char reserved1[10];
525 
526     // pps
527     unsigned char dependent_slice_segments_enabled_flag;
528     unsigned char slice_segment_header_extension_present_flag;
529     unsigned char sign_data_hiding_enabled_flag;
530     unsigned char cu_qp_delta_enabled_flag;
531     unsigned char diff_cu_qp_delta_depth;
532     signed char init_qp_minus26;
533     signed char pps_cb_qp_offset;
534     signed char pps_cr_qp_offset;
535 
536     unsigned char constrained_intra_pred_flag;
537     unsigned char weighted_pred_flag;
538     unsigned char weighted_bipred_flag;
539     unsigned char transform_skip_enabled_flag;
540     unsigned char transquant_bypass_enabled_flag;
541     unsigned char entropy_coding_sync_enabled_flag;
542     unsigned char log2_parallel_merge_level_minus2;
543     unsigned char num_extra_slice_header_bits;
544 
545     unsigned char loop_filter_across_tiles_enabled_flag;
546     unsigned char loop_filter_across_slices_enabled_flag;
547     unsigned char output_flag_present_flag;
548     unsigned char num_ref_idx_l0_default_active_minus1;
549     unsigned char num_ref_idx_l1_default_active_minus1;
550     unsigned char lists_modification_present_flag;
551     unsigned char cabac_init_present_flag;
552     unsigned char pps_slice_chroma_qp_offsets_present_flag;
553 
554     unsigned char deblocking_filter_override_enabled_flag;
555     unsigned char pps_deblocking_filter_disabled_flag;
556     signed char   pps_beta_offset_div2;
557     signed char   pps_tc_offset_div2;
558     unsigned char tiles_enabled_flag;
559     unsigned char uniform_spacing_flag;
560     unsigned char num_tile_columns_minus1;
561     unsigned char num_tile_rows_minus1;
562 
563     unsigned short column_width_minus1[21];
564     unsigned short row_height_minus1[21];
565 
566     // sps and pps extension HEVC-main 444
567     unsigned char sps_range_extension_flag;
568     unsigned char transform_skip_rotation_enabled_flag;
569     unsigned char transform_skip_context_enabled_flag;
570     unsigned char implicit_rdpcm_enabled_flag;
571 
572     unsigned char explicit_rdpcm_enabled_flag;
573     unsigned char extended_precision_processing_flag;
574     unsigned char intra_smoothing_disabled_flag;
575     unsigned char persistent_rice_adaptation_enabled_flag;
576 
577     unsigned char cabac_bypass_alignment_enabled_flag;
578     unsigned char pps_range_extension_flag;
579     unsigned char cross_component_prediction_enabled_flag;
580     unsigned char chroma_qp_offset_list_enabled_flag;
581 
582     unsigned char diff_cu_chroma_qp_offset_depth;
583     unsigned char chroma_qp_offset_list_len_minus1;
584     signed char cb_qp_offset_list[6];
585 
586     signed char cr_qp_offset_list[6];
587     unsigned char reserved2[2];
588 
589     unsigned int   reserved3[8];
590 
591     // RefPicSets
592     int NumBitsForShortTermRPSInSlice;
593     int NumDeltaPocsOfRefRpsIdx;
594     int NumPocTotalCurr;
595     int NumPocStCurrBefore;
596     int NumPocStCurrAfter;
597     int NumPocLtCurr;
598     int CurrPicOrderCntVal;
599     int RefPicIdx[16];                      // [refpic] Indices of valid reference pictures (-1 if unused for reference)
600     int PicOrderCntVal[16];                 // [refpic]
601     unsigned char IsLongTerm[16];           // [refpic] 0=not a long-term reference, 1=long-term reference
602     unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
603     unsigned char RefPicSetStCurrAfter[8];  // [0..NumPocStCurrAfter-1] -> refpic (0..15)
604     unsigned char RefPicSetLtCurr[8];       // [0..NumPocLtCurr-1] -> refpic (0..15)
605     unsigned char RefPicSetInterLayer0[8];
606     unsigned char RefPicSetInterLayer1[8];
607     unsigned int  reserved4[12];
608 
609     // scaling lists (diag order)
610     unsigned char ScalingList4x4[6][16];       // [matrixId][i]
611     unsigned char ScalingList8x8[6][64];       // [matrixId][i]
612     unsigned char ScalingList16x16[6][64];     // [matrixId][i]
613     unsigned char ScalingList32x32[2][64];     // [matrixId][i]
614     unsigned char ScalingListDCCoeff16x16[6];  // [matrixId]
615     unsigned char ScalingListDCCoeff32x32[2];  // [matrixId]
616 } CUVIDHEVCPICPARAMS;
617 
618 
619 /***********************************************************/
620 //! \struct CUVIDVP8PICPARAMS
621 //! VP8 picture parameters
622 //! This structure is used in CUVIDPICPARAMS structure
623 /***********************************************************/
624 typedef struct _CUVIDVP8PICPARAMS
625 {
626     int width;
627     int height;
628     unsigned int first_partition_size;
629     //Frame Indexes
630     unsigned char LastRefIdx;
631     unsigned char GoldenRefIdx;
632     unsigned char AltRefIdx;
633     union {
634         struct {
635             unsigned char frame_type : 1;    /**< 0 = KEYFRAME, 1 = INTERFRAME  */
636             unsigned char version : 3;
637             unsigned char show_frame : 1;
638             unsigned char update_mb_segmentation_data : 1;    /**< Must be 0 if segmentation is not enabled */
639             unsigned char Reserved2Bits : 2;
640         }vp8_frame_tag;
641         unsigned char wFrameTagFlags;
642     };
643     unsigned char Reserved1[4];
644     unsigned int  Reserved2[3];
645 } CUVIDVP8PICPARAMS;
646 
647 /***********************************************************/
648 //! \struct CUVIDVP9PICPARAMS
649 //! VP9 picture parameters
650 //! This structure is used in CUVIDPICPARAMS structure
651 /***********************************************************/
652 typedef struct _CUVIDVP9PICPARAMS
653 {
654     unsigned int width;
655     unsigned int height;
656 
657     //Frame Indices
658     unsigned char LastRefIdx;
659     unsigned char GoldenRefIdx;
660     unsigned char AltRefIdx;
661     unsigned char colorSpace;
662 
663     unsigned short profile : 3;
664     unsigned short frameContextIdx : 2;
665     unsigned short frameType : 1;
666     unsigned short showFrame : 1;
667     unsigned short errorResilient : 1;
668     unsigned short frameParallelDecoding : 1;
669     unsigned short subSamplingX : 1;
670     unsigned short subSamplingY : 1;
671     unsigned short intraOnly : 1;
672     unsigned short allow_high_precision_mv : 1;
673     unsigned short refreshEntropyProbs : 1;
674     unsigned short reserved2Bits : 2;
675 
676     unsigned short reserved16Bits;
677 
678     unsigned char  refFrameSignBias[4];
679 
680     unsigned char bitDepthMinus8Luma;
681     unsigned char bitDepthMinus8Chroma;
682     unsigned char loopFilterLevel;
683     unsigned char loopFilterSharpness;
684 
685     unsigned char modeRefLfEnabled;
686     unsigned char log2_tile_columns;
687     unsigned char log2_tile_rows;
688 
689     unsigned char segmentEnabled : 1;
690     unsigned char segmentMapUpdate : 1;
691     unsigned char segmentMapTemporalUpdate : 1;
692     unsigned char segmentFeatureMode : 1;
693     unsigned char reserved4Bits : 4;
694 
695 
696     unsigned char segmentFeatureEnable[8][4];
697     short         segmentFeatureData[8][4];
698     unsigned char mb_segment_tree_probs[7];
699     unsigned char segment_pred_probs[3];
700     unsigned char reservedSegment16Bits[2];
701 
702     int qpYAc;
703     int qpYDc;
704     int qpChDc;
705     int qpChAc;
706 
707     unsigned int activeRefIdx[3];
708     unsigned int resetFrameContext;
709     unsigned int mcomp_filter_type;
710     unsigned int mbRefLfDelta[4];
711     unsigned int mbModeLfDelta[2];
712     unsigned int frameTagSize;
713     unsigned int offsetToDctParts;
714     unsigned int reserved128Bits[4];
715 
716 } CUVIDVP9PICPARAMS;
717 
718 
719 /******************************************************************************************/
720 //! \struct CUVIDPICPARAMS
721 //! Picture parameters for decoding
722 //! This structure is used in cuvidDecodePicture API
723 //! IN  for cuvidDecodePicture
724 /******************************************************************************************/
725 typedef struct _CUVIDPICPARAMS
726 {
727     int PicWidthInMbs;                     /**< IN: Coded frame size in macroblocks                           */
728     int FrameHeightInMbs;                  /**< IN: Coded frame height in macroblocks                         */
729     int CurrPicIdx;                        /**< IN: Output index of the current picture                       */
730     int field_pic_flag;                    /**< IN: 0=frame picture, 1=field picture                          */
731     int bottom_field_flag;                 /**< IN: 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
732     int second_field;                      /**< IN: Second field of a complementary field pair                */
733     // Bitstream data
734     unsigned int nBitstreamDataLen;        /**< IN: Number of bytes in bitstream data buffer                  */
735     const unsigned char *pBitstreamData;   /**< IN: Ptr to bitstream data for this picture (slice-layer)      */
736     unsigned int nNumSlices;               /**< IN: Number of slices in this picture                          */
737     const unsigned int *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within
738                                                         the bitstream data buffer                             */
739     int ref_pic_flag;                      /**< IN: This picture is a reference picture                       */
740     int intra_pic_flag;                    /**< IN: This picture is entirely intra coded                      */
741     unsigned int Reserved[30];             /**< Reserved for future use                                       */
742     // IN: Codec-specific data
743     union {
744         CUVIDMPEG2PICPARAMS mpeg2;         /**< Also used for MPEG-1 */
745         CUVIDH264PICPARAMS  h264;
746         CUVIDVC1PICPARAMS   vc1;
747         CUVIDMPEG4PICPARAMS mpeg4;
748         CUVIDJPEGPICPARAMS  jpeg;
749         CUVIDHEVCPICPARAMS  hevc;
750         CUVIDVP8PICPARAMS   vp8;
751         CUVIDVP9PICPARAMS   vp9;
752         unsigned int CodecReserved[1024];
753     } CodecSpecific;
754 } CUVIDPICPARAMS;
755 
756 
757 /******************************************************/
758 //! \struct CUVIDPROCPARAMS
759 //! Picture parameters for postprocessing
760 //! This structure is used in cuvidMapVideoFrame API
761 /******************************************************/
762 typedef struct _CUVIDPROCPARAMS
763 {
764     int progressive_frame;              /**< IN: Input is progressive (deinterlace_mode will be ignored)                */
765     int second_field;                   /**< IN: Output the second field (ignored if deinterlace mode is Weave)         */
766     int top_field_first;                /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */
767     int unpaired_field;                 /**< IN: Input only contains one field (2nd field is invalid)                   */
768     // The fields below are used for raw YUV input
769     unsigned int reserved_flags;        /**< Reserved for future use (set to zero)                                      */
770     unsigned int reserved_zero;         /**< Reserved (set to zero)                                                     */
771     unsigned long long raw_input_dptr;  /**< IN: Input CUdeviceptr for raw YUV extensions                               */
772     unsigned int raw_input_pitch;       /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately)      */
773     unsigned int raw_input_format;      /**< IN: Input YUV format (cudaVideoCodec_enum)                                 */
774     unsigned long long raw_output_dptr; /**< IN: Output CUdeviceptr for raw YUV extensions                              */
775     unsigned int raw_output_pitch;      /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately)     */
776     unsigned int Reserved1;             /**< Reserved for future use (set to zero)                                      */
777     CUstream output_stream;             /**< IN: stream object used by cuvidMapVideoFrame                               */
778     unsigned int Reserved[46];          /**< Reserved for future use (set to zero)                                      */
779     void *Reserved2[2];                 /**< Reserved for future use (set to zero)                                      */
780 } CUVIDPROCPARAMS;
781 
782 /*********************************************************************************************************/
783 //! \struct CUVIDGETDECODESTATUS
784 //! Struct for reporting decode status.
785 //! This structure is used in cuvidGetDecodeStatus API.
786 /*********************************************************************************************************/
787 typedef struct _CUVIDGETDECODESTATUS
788 {
789     cuvidDecodeStatus decodeStatus;
790     unsigned int reserved[31];
791     void *pReserved[8];
792 } CUVIDGETDECODESTATUS;
793 
794 /****************************************************/
795 //! \struct CUVIDRECONFIGUREDECODERINFO
796 //! Struct for decoder reset
797 //! This structure is used in cuvidReconfigureDecoder() API
798 /****************************************************/
799 typedef struct _CUVIDRECONFIGUREDECODERINFO
800 {
801     unsigned int ulWidth;             /**< IN: Coded sequence width in pixels, MUST be < = ulMaxWidth defined at CUVIDDECODECREATEINFO  */
802     unsigned int ulHeight;            /**< IN: Coded sequence height in pixels, MUST be < = ulMaxHeight defined at CUVIDDECODECREATEINFO  */
803     unsigned int ulTargetWidth;       /**< IN: Post processed output width */
804     unsigned int ulTargetHeight;      /**< IN: Post Processed output height */
805     unsigned int ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */
806     unsigned int reserved1[12];       /**< Reserved for future use. Set to Zero */
807     /**
808     * IN: Area of frame to be displayed. Use-case : Source Cropping
809     */
810     struct {
811         short left;
812         short top;
813         short right;
814         short bottom;
815     } display_area;
816     /**
817     * IN: Target Rectangle in the OutputFrame. Use-case : Aspect ratio Conversion
818     */
819     struct {
820         short left;
821         short top;
822         short right;
823         short bottom;
824     } target_rect;
825     unsigned int reserved2[11]; /**< Reserved for future use. Set to Zero */
826 } CUVIDRECONFIGUREDECODERINFO;
827 
828 
829 /***********************************************************************************************************/
830 //! VIDEO_DECODER
831 //!
832 //! In order to minimize decode latencies, there should be always at least 2 pictures in the decode
833 //! queue at any time, in order to make sure that all decode engines are always busy.
834 //!
835 //! Overall data flow:
836 //!  - cuvidGetDecoderCaps(...)
837 //!  - cuvidCreateDecoder(...)
838 //!  - For each picture:
839 //!    + cuvidDecodePicture(N)
840 //!    + cuvidMapVideoFrame(N-4)
841 //!    + do some processing in cuda
842 //!    + cuvidUnmapVideoFrame(N-4)
843 //!    + cuvidDecodePicture(N+1)
844 //!    + cuvidMapVideoFrame(N-3)
845 //!    + ...
846 //!  - cuvidDestroyDecoder(...)
847 //!
848 //! NOTE:
849 //! - When the cuda context is created from a D3D device, the D3D device must also be created
850 //!   with the D3DCREATE_MULTITHREADED flag.
851 //! - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
852 //! - cuvidDecodePicture may block the calling thread if there are too many pictures pending
853 //!   in the decode queue
854 /***********************************************************************************************************/
855 
856 
857 /**********************************************************************************************************************/
858 //! \fn CUresult CUDAAPI cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc)
859 //! Queries decode capabilities of NVDEC-HW based on CodecType, ChromaFormat and BitDepthMinus8 parameters.
860 //! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of CUVIDDECODECAPS structure
861 //! 2. On calling cuvidGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported
862 //!    If IN parameters passed to the driver are not supported by NVDEC-HW, then all OUT params are set to 0.
863 //! E.g. on Geforce GTX 960:
864 //!   App fills - eCodecType = cudaVideoCodec_H264; eChromaFormat = cudaVideoChromaFormat_420; nBitDepthMinus8 = 0;
865 //!   Given IN parameters are supported, hence driver fills: bIsSupported = 1; nMinWidth   = 48; nMinHeight  = 16;
866 //!   nMaxWidth = 4096; nMaxHeight = 4096; nMaxMBCount = 65536;
867 //! CodedWidth*CodedHeight/256 must be less than or equal to nMaxMBCount
868 /**********************************************************************************************************************/
869 extern CUresult CUDAAPI cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc);
870 
871 /*****************************************************************************************************/
872 //! \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
873 //! Create the decoder object based on pdci. A handle to the created decoder is returned
874 /*****************************************************************************************************/
875 extern CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
876 
877 /*****************************************************************************************************/
878 //! \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
879 //! Destroy the decoder object
880 /*****************************************************************************************************/
881 extern CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder);
882 
883 /*****************************************************************************************************/
884 //! \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
885 //! Decode a single picture (field or frame)
886 //! Kicks off HW decoding
887 /*****************************************************************************************************/
888 extern CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
889 
890 /************************************************************************************************************/
891 //! \fn CUresult CUDAAPI cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx);
892 //! Get the decode status for frame corresponding to nPicIdx
893 /************************************************************************************************************/
894 extern CUresult CUDAAPI cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx, CUVIDGETDECODESTATUS* pDecodeStatus);
895 
896 /*********************************************************************************************************/
897 //! \fn CUresult CUDAAPI cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams)
898 //! Used to reuse single decoder for multiple clips. Currently supports resolution change, resize params, display area
899 //! params, target area params change for same codec. Must be called during CUVIDPARSERPARAMS::pfnSequenceCallback
900 /*********************************************************************************************************/
901 extern CUresult CUDAAPI cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams);
902 
903 
904 #if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
905 /************************************************************************************************************************/
906 //! \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr,
907 //!                                         unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
908 //! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated
909 //! pitch of the video frame
910 /************************************************************************************************************************/
911 extern CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
912                                            unsigned int *pDevPtr, unsigned int *pPitch,
913                                            CUVIDPROCPARAMS *pVPP);
914 
915 /*****************************************************************************************************/
916 //! \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
917 //! Unmap a previously mapped video frame
918 /*****************************************************************************************************/
919 extern CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
920 #endif
921 
922 #if defined(_WIN64) || defined(__LP64__) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
923 /****************************************************************************************************************************/
924 //! \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
925 //!                                           unsigned int * pPitch, CUVIDPROCPARAMS *pVPP);
926 //! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated
927 //! pitch of the video frame
928 /****************************************************************************************************************************/
929 extern CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
930                                              unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
931 
932 /**************************************************************************************************/
933 //! \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
934 //! Unmap a previously mapped video frame
935 /**************************************************************************************************/
936 extern CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
937 
938 #if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
939 #define cuvidMapVideoFrame      cuvidMapVideoFrame64
940 #define cuvidUnmapVideoFrame    cuvidUnmapVideoFrame64
941 #endif
942 #endif
943 
944 
945 /********************************************************************************************************************/
946 //!
947 //! Context-locking: to facilitate multi-threaded implementations, the following 4 functions
948 //! provide a simple mutex-style host synchronization. If a non-NULL context is specified
949 //! in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
950 //! context before making any cuda calls.
951 //! A multi-threaded application could create a lock associated with a context handle so that
952 //! multiple threads can safely share the same cuda context:
953 //!  - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
954 //!    that can be passed to cuvidCtxLockCreate.
955 //!  - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
956 //!
957 //! NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
958 //! decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
959 /********************************************************************************************************************/
960 
961 /********************************************************************************************************************/
962 //! \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
963 //! This API is used to create CtxLock object
964 /********************************************************************************************************************/
965 extern CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
966 
967 /********************************************************************************************************************/
968 //! \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
969 //! This API is used to free CtxLock object
970 /********************************************************************************************************************/
971 extern CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck);
972 
973 /********************************************************************************************************************/
974 //! \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
975 //! This API is used to acquire ctxlock
976 /********************************************************************************************************************/
977 extern CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
978 
979 /********************************************************************************************************************/
980 //! \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
981 //! This API is used to release ctxlock
982 /********************************************************************************************************************/
983 extern CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
984 
985 /**********************************************************************************************/
986 
987 
988 #if defined(__cplusplus)
989 }
990 // Auto-lock helper for C++ applications
991 class CCtxAutoLock
992 {
993 private:
994     CUvideoctxlock m_ctx;
995 public:
CCtxAutoLock(CUvideoctxlock ctx)996     CCtxAutoLock(CUvideoctxlock ctx):m_ctx(ctx) { cuvidCtxLock(m_ctx,0); }
~CCtxAutoLock()997     ~CCtxAutoLock() { cuvidCtxUnlock(m_ctx,0); }
998 };
999 #endif /* __cplusplus */
1000 
1001 #endif // __CUDA_VIDEO_H__
1002 
1003