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