Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
cuviddec.h1210 linesDownload Raw Back to Interface
1/*
2 * This copyright notice applies to this header file only:
3 *
4 * Copyright (c) 2010-2024 NVIDIA Corporation
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the software, and to permit persons to whom the
12 * software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28/*****************************************************************************************************/
29//! \file cuviddec.h
30//! NVDECODE API provides video decoding interface to NVIDIA GPU devices.
31//! This file contains constants, structure definitions and function prototypes used for decoding.
32/*****************************************************************************************************/
33
34#if !defined(__CUDA_VIDEO_H__)
35#define __CUDA_VIDEO_H__
36
37#ifndef __cuda_cuda_h__
38#include <cuda.h>
39#endif // __cuda_cuda_h__
40
41#if defined(_WIN64) || defined(__LP64__) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
42#if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020))
43#define __CUVID_DEVPTR64
44#endif
45#endif
46
47#if defined(__cplusplus)
48extern "C" {
49#endif /* __cplusplus */
50
51typedef void *CUvideodecoder;
52typedef struct _CUcontextlock_st *CUvideoctxlock;
53
54/*********************************************************************************/
55//! \enum cudaVideoCodec
56//! Video codec enums
57//! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures
58/*********************************************************************************/
59typedef enum cudaVideoCodec_enum {
60    cudaVideoCodec_MPEG1=0,                                         /**<  MPEG1             */
61    cudaVideoCodec_MPEG2,                                           /**<  MPEG2             */
62    cudaVideoCodec_MPEG4,                                           /**<  MPEG4             */
63    cudaVideoCodec_VC1,                                             /**<  VC1               */
64    cudaVideoCodec_H264,                                            /**<  H264              */
65    cudaVideoCodec_JPEG,                                            /**<  JPEG              */
66    cudaVideoCodec_H264_SVC,                                        /**<  H264-SVC          */
67    cudaVideoCodec_H264_MVC,                                        /**<  H264-MVC          */
68    cudaVideoCodec_HEVC,                                            /**<  HEVC              */
69    cudaVideoCodec_VP8,                                             /**<  VP8               */
70    cudaVideoCodec_VP9,                                             /**<  VP9               */
71    cudaVideoCodec_AV1,                                             /**<  AV1               */
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/*********************************************************************************/
86typedef 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_NV16=4,          /**< Semi-Planar YUV 422 [Y plane followed by interleaved UV plane] */
94    cudaVideoSurfaceFormat_P216=5           /**< 16 bit Semi-Planar YUV 422[Y plane followed by interleaved UV plane].
95                                                 Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0)      */
96} cudaVideoSurfaceFormat;
97
98/******************************************************************************************************************/
99//! \enum cudaVideoDeinterlaceMode
100//! Deinterlacing mode enums
101//! These enums are used in CUVIDDECODECREATEINFO structure
102//! Use cudaVideoDeinterlaceMode_Weave for progressive content and for content that doesn't need deinterlacing
103//! cudaVideoDeinterlaceMode_Adaptive needs more video memory than other DImodes
104/******************************************************************************************************************/
105typedef enum cudaVideoDeinterlaceMode_enum {
106    cudaVideoDeinterlaceMode_Weave=0,   /**< Weave both fields (no deinterlacing) */
107    cudaVideoDeinterlaceMode_Bob,       /**< Drop one field                       */
108    cudaVideoDeinterlaceMode_Adaptive   /**< Adaptive deinterlacing               */
109} cudaVideoDeinterlaceMode;
110
111/**************************************************************************************************************/
112//! \enum cudaVideoChromaFormat
113//! Chroma format enums
114//! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures
115/**************************************************************************************************************/
116typedef enum cudaVideoChromaFormat_enum {
117    cudaVideoChromaFormat_Monochrome=0,  /**< MonoChrome */
118    cudaVideoChromaFormat_420,           /**< YUV 4:2:0  */
119    cudaVideoChromaFormat_422,           /**< YUV 4:2:2  */
120    cudaVideoChromaFormat_444            /**< YUV 4:4:4  */
121} cudaVideoChromaFormat;
122
123/*************************************************************************************************************/
124//! \enum cudaVideoCreateFlags
125//! Decoder flag enums to select preferred decode path
126//! cudaVideoCreate_Default and cudaVideoCreate_PreferCUVID are most optimized, use these whenever possible
127/*************************************************************************************************************/
128typedef enum cudaVideoCreateFlags_enum {
129    cudaVideoCreate_Default     = 0x00,     /**< Default operation mode: use dedicated video engines                        */
130    cudaVideoCreate_PreferCUDA  = 0x01,     /**< Use CUDA-based decoder (requires valid vidLock object for multi-threading) */
131    cudaVideoCreate_PreferDXVA  = 0x02,     /**< Go through DXVA internally if possible (requires D3D9 interop)             */
132    cudaVideoCreate_PreferCUVID = 0x04      /**< Use dedicated video engines directly                                       */
133} cudaVideoCreateFlags;
134
135
136/*************************************************************************/
137//! \enum cuvidDecodeStatus
138//! Decode status enums
139//! These enums are used in CUVIDGETDECODESTATUS structure
140/*************************************************************************/
141typedef enum cuvidDecodeStatus_enum
142{
143    cuvidDecodeStatus_Invalid         = 0,   // Decode status is not valid
144    cuvidDecodeStatus_InProgress      = 1,   // Decode is in progress
145    cuvidDecodeStatus_Success         = 2,   // Decode is completed without any errors
146    // 3 to 7 enums are reserved for future use
147    cuvidDecodeStatus_Error           = 8,   // Decode is completed with an error (error is not concealed)
148    cuvidDecodeStatus_Error_Concealed = 9,   // Decode is completed with an error and error is concealed
149} cuvidDecodeStatus;
150
151/**************************************************************************************************************/
152//! \struct CUVIDDECODECAPS;
153//! This structure is used in cuvidGetDecoderCaps API
154/**************************************************************************************************************/
155typedef struct _CUVIDDECODECAPS
156{
157    cudaVideoCodec          eCodecType;                 /**< IN: cudaVideoCodec_XXX                                             */
158    cudaVideoChromaFormat   eChromaFormat;              /**< IN: cudaVideoChromaFormat_XXX                                      */
159    unsigned int            nBitDepthMinus8;            /**< IN: The Value "BitDepth minus 8"                                   */
160    unsigned int            reserved1[3];               /**< Reserved for future use - set to zero                              */
161
162    unsigned char           bIsSupported;               /**< OUT: 1 if codec supported, 0 if not supported                      */
163    unsigned char           nNumNVDECs;                 /**< OUT: Number of NVDECs that can support IN params                   */
164    unsigned short          nOutputFormatMask;          /**< OUT: each bit represents corresponding cudaVideoSurfaceFormat enum */
165    unsigned int            nMaxWidth;                  /**< OUT: Max supported coded width in pixels                           */
166    unsigned int            nMaxHeight;                 /**< OUT: Max supported coded height in pixels                          */
167    unsigned int            nMaxMBCount;                /**< OUT: Max supported macroblock count
168                                                                  CodedWidth*CodedHeight/256 must be <= nMaxMBCount             */
169    unsigned short          nMinWidth;                  /**< OUT: Min supported coded width in pixels                           */
170    unsigned short          nMinHeight;                 /**< OUT: Min supported coded height in pixels                          */
171    unsigned char           bIsHistogramSupported;      /**< OUT: 1 if Y component histogram output is supported, 0 if not
172                                                                  Note: histogram is computed on original picture data before
173                                                                  any post-processing like scaling, cropping, etc. is applied   */
174    unsigned char           nCounterBitDepth;           /**< OUT: histogram counter bit depth                                   */
175    unsigned short          nMaxHistogramBins;          /**< OUT: Max number of histogram bins                                  */
176    unsigned int            reserved3[10];              /**< Reserved for future use - set to zero                              */
177} CUVIDDECODECAPS;
178
179/**************************************************************************************************************/
180//! \struct CUVIDDECODECREATEINFO
181//! This structure is used in cuvidCreateDecoder API
182/**************************************************************************************************************/
183typedef struct _CUVIDDECODECREATEINFO
184{
185    unsigned long ulWidth;              /**< IN: Coded sequence width in pixels                                             */
186    unsigned long ulHeight;             /**< IN: Coded sequence height in pixels                                            */
187    unsigned long ulNumDecodeSurfaces;  /**< IN: Maximum number of internal decode surfaces                                 */
188    cudaVideoCodec CodecType;           /**< IN: cudaVideoCodec_XXX                                                         */
189    cudaVideoChromaFormat ChromaFormat; /**< IN: cudaVideoChromaFormat_XXX                                                  */
190    unsigned long ulCreationFlags;      /**< IN: Decoder creation flags (cudaVideoCreateFlags_XXX)                          */
191    unsigned long bitDepthMinus8;       /**< IN: The value "BitDepth minus 8"                                               */
192    unsigned long ulIntraDecodeOnly;    /**< IN: Set 1 only if video has all intra frames (default value is 0). This will
193                                             optimize video memory for Intra frames only decoding. The support is limited
194                                             to specific codecs - H264, HEVC, VP9, the flag will be ignored for codecs which
195                                             are not supported. However decoding might fail if the flag is enabled in case
196                                             of supported codecs for regular bit streams having P and/or B frames.          */
197    unsigned long ulMaxWidth;           /**< IN: Coded sequence max width in pixels used with reconfigure Decoder           */
198    unsigned long ulMaxHeight;          /**< IN: Coded sequence max height in pixels used with reconfigure Decoder          */
199    unsigned long Reserved1;            /**< Reserved for future use - set to zero                                          */
200    /**
201    * IN: area of the frame that should be displayed
202    */
203    struct {
204        short left;
205        short top;
206        short right;
207        short bottom;
208    } display_area;
209
210    cudaVideoSurfaceFormat OutputFormat;       /**< IN: cudaVideoSurfaceFormat_XXX                                     */
211    cudaVideoDeinterlaceMode DeinterlaceMode;  /**< IN: cudaVideoDeinterlaceMode_XXX                                   */
212    unsigned long ulTargetWidth;               /**< IN: Post-processed output width (Should be aligned to 2)           */
213    unsigned long ulTargetHeight;              /**< IN: Post-processed output height (Should be aligned to 2)          */
214    unsigned long ulNumOutputSurfaces;         /**< IN: Maximum number of output surfaces simultaneously mapped        */
215    CUvideoctxlock vidLock;                    /**< IN: If non-NULL, context lock used for synchronizing ownership of
216                                                    the cuda context. Needed for cudaVideoCreate_PreferCUDA decode     */
217    /**
218    * IN: target rectangle in the output frame (for aspect ratio conversion)
219    * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
220    */
221    struct {
222        short left;
223        short top;
224        short right;
225        short bottom;
226    } target_rect;
227
228    unsigned long enableHistogram;             /**< IN: enable histogram output, if supported */
229    unsigned long Reserved2[4];                /**< Reserved for future use - set to zero */
230} CUVIDDECODECREATEINFO;
231
232/*********************************************************/
233//! \struct CUVIDH264DPBENTRY
234//! H.264 DPB entry
235//! This structure is used in CUVIDH264PICPARAMS structure
236/*********************************************************/
237typedef struct _CUVIDH264DPBENTRY
238{
239    int PicIdx;                 /**< picture index of reference frame                                        */
240    int FrameIdx;               /**< frame_num(short-term) or LongTermFrameIdx(long-term)                    */
241    int is_long_term;           /**< 0=short term reference, 1=long term reference                           */
242    int not_existing;           /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
243    int used_for_reference;     /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields                    */
244    int FieldOrderCnt[2];       /**< field order count of top and bottom fields                              */
245} CUVIDH264DPBENTRY;
246
247/************************************************************/
248//! \struct CUVIDH264MVCEXT
249//! H.264 MVC picture parameters ext
250//! This structure is used in CUVIDH264PICPARAMS structure
251/************************************************************/
252typedef struct _CUVIDH264MVCEXT
253{
254    int num_views_minus1;                  /**< Max number of coded views minus 1 in video : Range - 0 to 1023              */
255    int view_id;                           /**< view identifier                                                             */
256    unsigned char inter_view_flag;         /**< 1 if used for inter-view prediction, 0 if not                               */
257    unsigned char num_inter_view_refs_l0;  /**< number of inter-view ref pics in RefPicList0                                */
258    unsigned char num_inter_view_refs_l1;  /**< number of inter-view ref pics in RefPicList1                                */
259    unsigned char MVCReserved8Bits;        /**< Reserved bits                                                               */
260    int InterViewRefsL0[16];               /**< view id of the i-th view component for inter-view prediction in RefPicList0 */
261    int InterViewRefsL1[16];               /**< view id of the i-th view component for inter-view prediction in RefPicList1 */
262} CUVIDH264MVCEXT;
263
264/*********************************************************/
265//! \struct CUVIDH264SVCEXT
266//! H.264 SVC picture parameters ext
267//! This structure is used in CUVIDH264PICPARAMS structure
268/*********************************************************/
269typedef struct _CUVIDH264SVCEXT
270{
271    unsigned char profile_idc;
272    unsigned char level_idc;
273    unsigned char DQId;
274    unsigned char DQIdMax;
275    unsigned char disable_inter_layer_deblocking_filter_idc;
276    unsigned char ref_layer_chroma_phase_y_plus1;
277    signed char   inter_layer_slice_alpha_c0_offset_div2;
278    signed char   inter_layer_slice_beta_offset_div2;
279
280    unsigned short DPBEntryValidFlag;
281    unsigned char inter_layer_deblocking_filter_control_present_flag;
282    unsigned char extended_spatial_scalability_idc;
283    unsigned char adaptive_tcoeff_level_prediction_flag;
284    unsigned char slice_header_restriction_flag;
285    unsigned char chroma_phase_x_plus1_flag;
286    unsigned char chroma_phase_y_plus1;
287
288    unsigned char tcoeff_level_prediction_flag;
289    unsigned char constrained_intra_resampling_flag;
290    unsigned char ref_layer_chroma_phase_x_plus1_flag;
291    unsigned char store_ref_base_pic_flag;
292    unsigned char Reserved8BitsA;
293    unsigned char Reserved8BitsB;
294
295    short scaled_ref_layer_left_offset;
296    short scaled_ref_layer_top_offset;
297    short scaled_ref_layer_right_offset;
298    short scaled_ref_layer_bottom_offset;
299    unsigned short Reserved16Bits;
300    struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded.
301                                             Linked list ends at the target layer. */
302    int bRefBaseLayer;                  /**< whether to store ref base pic */
303} CUVIDH264SVCEXT;
304
305/******************************************************/
306//! \struct CUVIDH264PICPARAMS
307//! H.264 picture parameters
308//! This structure is used in CUVIDPICPARAMS structure
309/******************************************************/
310typedef struct _CUVIDH264PICPARAMS
311{
312    // SPS
313    int log2_max_frame_num_minus4;
314    int pic_order_cnt_type;
315    int log2_max_pic_order_cnt_lsb_minus4;
316    int delta_pic_order_always_zero_flag;
317    int frame_mbs_only_flag;
318    int direct_8x8_inference_flag;
319    int num_ref_frames;
320    unsigned char residual_colour_transform_flag;
321    unsigned char bit_depth_luma_minus8;
322    unsigned char bit_depth_chroma_minus8;
323    unsigned char qpprime_y_zero_transform_bypass_flag;
324    // PPS
325    int entropy_coding_mode_flag;
326    int pic_order_present_flag;
327    int num_ref_idx_l0_active_minus1;
328    int num_ref_idx_l1_active_minus1;
329    int weighted_pred_flag;
330    int weighted_bipred_idc;
331    int pic_init_qp_minus26;
332    int deblocking_filter_control_present_flag;
333    int redundant_pic_cnt_present_flag;
334    int transform_8x8_mode_flag;
335    int MbaffFrameFlag;
336    int constrained_intra_pred_flag;
337    int chroma_qp_index_offset;
338    int second_chroma_qp_index_offset;
339    int ref_pic_flag;
340    int frame_num;
341    int CurrFieldOrderCnt[2];
342    // DPB
343    CUVIDH264DPBENTRY dpb[16];                      // List of reference frames within the DPB
344    // Quantization Matrices (raster-order)
345    unsigned char WeightScale4x4[6][16];
346    unsigned char WeightScale8x8[2][64];
347    // FMO/ASO
348    unsigned char fmo_aso_enable;
349    unsigned char num_slice_groups_minus1;
350    unsigned char slice_group_map_type;
351    signed char pic_init_qs_minus26;
352    unsigned int slice_group_change_rate_minus1;
353    union
354    {
355        unsigned long long slice_group_map_addr;
356        const unsigned char *pMb2SliceGroupMap;
357    } fmo;
358    unsigned int mb_adaptive_frame_field_flag : 2;  // bit 0 represent SPS flag mb_adaptive_frame_field_flag
359                                                    // if bit 1 is not set, flag is ignored. Bit 1 is set to maintain backward compatibility
360    unsigned int Reserved1 : 30;
361    unsigned int  Reserved[11];
362    // SVC/MVC
363    union
364    {
365        CUVIDH264MVCEXT mvcext;
366        CUVIDH264SVCEXT svcext;
367    };
368} CUVIDH264PICPARAMS;
369
370
371/********************************************************/
372//! \struct CUVIDMPEG2PICPARAMS
373//! MPEG-2 picture parameters
374//! This structure is used in CUVIDPICPARAMS structure
375/********************************************************/
376typedef struct _CUVIDMPEG2PICPARAMS
377{
378    int ForwardRefIdx;          // Picture index of forward reference (P/B-frames)
379    int BackwardRefIdx;         // Picture index of backward reference (B-frames)
380    int picture_coding_type;
381    int full_pel_forward_vector;
382    int full_pel_backward_vector;
383    int f_code[2][2];
384    int intra_dc_precision;
385    int frame_pred_frame_dct;
386    int concealment_motion_vectors;
387    int q_scale_type;
388    int intra_vlc_format;
389    int alternate_scan;
390    int top_field_first;
391    // Quantization matrices (raster order)
392    unsigned char QuantMatrixIntra[64];
393    unsigned char QuantMatrixInter[64];
394} CUVIDMPEG2PICPARAMS;
395
396// MPEG-4 has VOP types instead of Picture types
397#define I_VOP 0
398#define P_VOP 1
399#define B_VOP 2
400#define S_VOP 3
401
402/*******************************************************/
403//! \struct CUVIDMPEG4PICPARAMS
404//! MPEG-4 picture parameters
405//! This structure is used in CUVIDPICPARAMS structure
406/*******************************************************/
407typedef struct _CUVIDMPEG4PICPARAMS
408{
409    int ForwardRefIdx;          // Picture index of forward reference (P/B-frames)
410    int BackwardRefIdx;         // Picture index of backward reference (B-frames)
411    // VOL
412    int video_object_layer_width;
413    int video_object_layer_height;
414    int vop_time_increment_bitcount;
415    int top_field_first;
416    int resync_marker_disable;
417    int quant_type;
418    int quarter_sample;
419    int short_video_header;
420    int divx_flags;
421    // VOP
422    int vop_coding_type;
423    int vop_coded;
424    int vop_rounding_type;
425    int alternate_vertical_scan_flag;
426    int interlaced;
427    int vop_fcode_forward;
428    int vop_fcode_backward;
429    int trd[2];
430    int trb[2];
431    // Quantization matrices (raster order)
432    unsigned char QuantMatrixIntra[64];
433    unsigned char QuantMatrixInter[64];
434    int gmc_enabled;
435} CUVIDMPEG4PICPARAMS;
436
437/********************************************************/
438//! \struct CUVIDVC1PICPARAMS
439//! VC1 picture parameters
440//! This structure is used in CUVIDPICPARAMS structure
441/********************************************************/
442typedef struct _CUVIDVC1PICPARAMS
443{
444    int ForwardRefIdx;      /**< Picture index of forward reference (P/B-frames) */
445    int BackwardRefIdx;     /**< Picture index of backward reference (B-frames)  */
446    int FrameWidth;         /**< Actual frame width                              */
447    int FrameHeight;        /**< Actual frame height                             */
448    // PICTURE
449    int intra_pic_flag;     /**< Set to 1 for I,BI frames */
450    int ref_pic_flag;       /**< Set to 1 for I,P frames  */
451    int progressive_fcm;    /**< Progressive frame        */
452    // SEQUENCE
453    int profile;
454    int postprocflag;
455    int pulldown;
456    int interlace;
457    int tfcntrflag;
458    int finterpflag;
459    int psf;
460    int multires;
461    int syncmarker;
462    int rangered;
463    int maxbframes;
464    // ENTRYPOINT
465    int panscan_flag;
466    int refdist_flag;
467    int extended_mv;
468    int dquant;
469    int vstransform;
470    int loopfilter;
471    int fastuvmc;
472    int overlap;
473    int quantizer;
474    int extended_dmv;
475    int range_mapy_flag;
476    int range_mapy;
477    int range_mapuv_flag;
478    int range_mapuv;
479    int rangeredfrm;    // range reduction state
480} CUVIDVC1PICPARAMS;
481
482/***********************************************************/
483//! \struct CUVIDJPEGPICPARAMS
484//! JPEG picture parameters
485//! This structure is used in CUVIDPICPARAMS structure
486/***********************************************************/
487typedef struct _CUVIDJPEGPICPARAMS
488{
489    unsigned char numComponents;
490    unsigned char bitDepth;
491    unsigned char quantizationTableSelector[4];
492    unsigned int scanOffset[4];
493    unsigned int scanSize[4];
494
495    unsigned short restartInterval;
496    unsigned char componentIdentifier[4];
497
498    unsigned char hasQMatrix;
499    unsigned char hasHuffman;
500    unsigned short quantvals[4][64];
501
502    unsigned char bits_ac[4][16];
503    unsigned char table_ac[4][256]; // there can only be max of 162 ac symbols
504
505    unsigned char bits_dc[4][16];
506    unsigned char table_dc[4][256];  // there can only be max of 12 dc symbols
507} CUVIDJPEGPICPARAMS;
508
509
510/*******************************************************/
511//! \struct CUVIDHEVCPICPARAMS
512//! HEVC picture parameters
513//! This structure is used in CUVIDPICPARAMS structure
514/*******************************************************/
515typedef struct _CUVIDHEVCPICPARAMS
516{
517    // sps
518    int pic_width_in_luma_samples;
519    int pic_height_in_luma_samples;
520    unsigned char log2_min_luma_coding_block_size_minus3;
521    unsigned char log2_diff_max_min_luma_coding_block_size;
522    unsigned char log2_min_transform_block_size_minus2;
523    unsigned char log2_diff_max_min_transform_block_size;
524    unsigned char pcm_enabled_flag;
525    unsigned char log2_min_pcm_luma_coding_block_size_minus3;
526    unsigned char log2_diff_max_min_pcm_luma_coding_block_size;
527    unsigned char pcm_sample_bit_depth_luma_minus1;
528
529    unsigned char pcm_sample_bit_depth_chroma_minus1;
530    unsigned char pcm_loop_filter_disabled_flag;
531    unsigned char strong_intra_smoothing_enabled_flag;
532    unsigned char max_transform_hierarchy_depth_intra;
533    unsigned char max_transform_hierarchy_depth_inter;
534    unsigned char amp_enabled_flag;
535    unsigned char separate_colour_plane_flag;
536    unsigned char log2_max_pic_order_cnt_lsb_minus4;
537
538    unsigned char num_short_term_ref_pic_sets;
539    unsigned char long_term_ref_pics_present_flag;
540    unsigned char num_long_term_ref_pics_sps;
541    unsigned char sps_temporal_mvp_enabled_flag;
542    unsigned char sample_adaptive_offset_enabled_flag;
543    unsigned char scaling_list_enable_flag;
544    unsigned char IrapPicFlag;
545    unsigned char IdrPicFlag;
546
547    unsigned char bit_depth_luma_minus8;
548    unsigned char bit_depth_chroma_minus8;
549    //sps/pps extension fields
550    unsigned char log2_max_transform_skip_block_size_minus2;
551    unsigned char log2_sao_offset_scale_luma;
552    unsigned char log2_sao_offset_scale_chroma;
553    unsigned char high_precision_offsets_enabled_flag;
554    unsigned char reserved1[10];
555
556    // pps
557    unsigned char dependent_slice_segments_enabled_flag;
558    unsigned char slice_segment_header_extension_present_flag;
559    unsigned char sign_data_hiding_enabled_flag;
560    unsigned char cu_qp_delta_enabled_flag;
561    unsigned char diff_cu_qp_delta_depth;
562    signed char init_qp_minus26;
563    signed char pps_cb_qp_offset;
564    signed char pps_cr_qp_offset;
565
566    unsigned char constrained_intra_pred_flag;
567    unsigned char weighted_pred_flag;
568    unsigned char weighted_bipred_flag;
569    unsigned char transform_skip_enabled_flag;
570    unsigned char transquant_bypass_enabled_flag;
571    unsigned char entropy_coding_sync_enabled_flag;
572    unsigned char log2_parallel_merge_level_minus2;
573    unsigned char num_extra_slice_header_bits;
574
575    unsigned char loop_filter_across_tiles_enabled_flag;
576    unsigned char loop_filter_across_slices_enabled_flag;
577    unsigned char output_flag_present_flag;
578    unsigned char num_ref_idx_l0_default_active_minus1;
579    unsigned char num_ref_idx_l1_default_active_minus1;
580    unsigned char lists_modification_present_flag;
581    unsigned char cabac_init_present_flag;
582    unsigned char pps_slice_chroma_qp_offsets_present_flag;
583
584    unsigned char deblocking_filter_override_enabled_flag;
585    unsigned char pps_deblocking_filter_disabled_flag;
586    signed char   pps_beta_offset_div2;
587    signed char   pps_tc_offset_div2;
588    unsigned char tiles_enabled_flag;
589    unsigned char uniform_spacing_flag;
590    unsigned char num_tile_columns_minus1;
591    unsigned char num_tile_rows_minus1;
592
593    unsigned short column_width_minus1[21];
594    unsigned short row_height_minus1[21];
595
596    // sps and pps extension HEVC-main 444
597    unsigned char sps_range_extension_flag;
598    unsigned char transform_skip_rotation_enabled_flag;
599    unsigned char transform_skip_context_enabled_flag;
600    unsigned char implicit_rdpcm_enabled_flag;
601
602    unsigned char explicit_rdpcm_enabled_flag;
603    unsigned char extended_precision_processing_flag;
604    unsigned char intra_smoothing_disabled_flag;
605    unsigned char persistent_rice_adaptation_enabled_flag;
606
607    unsigned char cabac_bypass_alignment_enabled_flag;
608    unsigned char pps_range_extension_flag;
609    unsigned char cross_component_prediction_enabled_flag;
610    unsigned char chroma_qp_offset_list_enabled_flag;
611
612    unsigned char diff_cu_chroma_qp_offset_depth;
613    unsigned char chroma_qp_offset_list_len_minus1;
614    signed char cb_qp_offset_list[6];
615
616    signed char cr_qp_offset_list[6];
617    unsigned char reserved2[2];
618
619    unsigned int   reserved3[8];
620
621    // RefPicSets
622    int NumBitsForShortTermRPSInSlice;
623    int NumDeltaPocsOfRefRpsIdx;
624    int NumPocTotalCurr;
625    int NumPocStCurrBefore;
626    int NumPocStCurrAfter;
627    int NumPocLtCurr;
628    int CurrPicOrderCntVal;
629    int RefPicIdx[16];                      // [refpic] Indices of valid reference pictures (-1 if unused for reference)
630    int PicOrderCntVal[16];                 // [refpic]
631    unsigned char IsLongTerm[16];           // [refpic] 0=not a long-term reference, 1=long-term reference
632    unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
633    unsigned char RefPicSetStCurrAfter[8];  // [0..NumPocStCurrAfter-1] -> refpic (0..15)
634    unsigned char RefPicSetLtCurr[8];       // [0..NumPocLtCurr-1] -> refpic (0..15)
635    unsigned char RefPicSetInterLayer0[8];
636    unsigned char RefPicSetInterLayer1[8];
637    unsigned int  reserved4[12];
638
639    // scaling lists (diag order)
640    unsigned char ScalingList4x4[6][16];       // [matrixId][i]
641    unsigned char ScalingList8x8[6][64];       // [matrixId][i]
642    unsigned char ScalingList16x16[6][64];     // [matrixId][i]
643    unsigned char ScalingList32x32[2][64];     // [matrixId][i]
644    unsigned char ScalingListDCCoeff16x16[6];  // [matrixId]
645    unsigned char ScalingListDCCoeff32x32[2];  // [matrixId]
646} CUVIDHEVCPICPARAMS;
647
648
649/***********************************************************/
650//! \struct CUVIDVP8PICPARAMS
651//! VP8 picture parameters
652//! This structure is used in CUVIDPICPARAMS structure
653/***********************************************************/
654typedef struct _CUVIDVP8PICPARAMS
655{
656    int width;
657    int height;
658    unsigned int first_partition_size;
659    //Frame Indexes
660    unsigned char LastRefIdx;
661    unsigned char GoldenRefIdx;
662    unsigned char AltRefIdx;
663    union {
664        struct {
665            unsigned char frame_type : 1;    /**< 0 = KEYFRAME, 1 = INTERFRAME  */
666            unsigned char version : 3;
667            unsigned char show_frame : 1;
668            unsigned char update_mb_segmentation_data : 1;    /**< Must be 0 if segmentation is not enabled */
669            unsigned char Reserved2Bits : 2;
670        }vp8_frame_tag;
671        unsigned char wFrameTagFlags;
672    };
673    unsigned char Reserved1[4];
674    unsigned int  Reserved2[3];
675} CUVIDVP8PICPARAMS;
676
677/***********************************************************/
678//! \struct CUVIDVP9PICPARAMS
679//! VP9 picture parameters
680//! This structure is used in CUVIDPICPARAMS structure
681/***********************************************************/
682typedef struct _CUVIDVP9PICPARAMS
683{
684    unsigned int width;
685    unsigned int height;
686
687    //Frame Indices
688    unsigned char LastRefIdx;
689    unsigned char GoldenRefIdx;
690    unsigned char AltRefIdx;
691    unsigned char colorSpace;
692
693    unsigned short profile : 3;
694    unsigned short frameContextIdx : 2;
695    unsigned short frameType : 1;
696    unsigned short showFrame : 1;
697    unsigned short errorResilient : 1;
698    unsigned short frameParallelDecoding : 1;
699    unsigned short subSamplingX : 1;
700    unsigned short subSamplingY : 1;
701    unsigned short intraOnly : 1;
702    unsigned short allow_high_precision_mv : 1;
703    unsigned short refreshEntropyProbs : 1;
704    unsigned short reserved2Bits : 2;
705
706    unsigned short reserved16Bits;
707
708    unsigned char  refFrameSignBias[4];
709
710    unsigned char bitDepthMinus8Luma;
711    unsigned char bitDepthMinus8Chroma;
712    unsigned char loopFilterLevel;
713    unsigned char loopFilterSharpness;
714
715    unsigned char modeRefLfEnabled;
716    unsigned char log2_tile_columns;
717    unsigned char log2_tile_rows;
718
719    unsigned char segmentEnabled : 1;
720    unsigned char segmentMapUpdate : 1;
721    unsigned char segmentMapTemporalUpdate : 1;
722    unsigned char segmentFeatureMode : 1;
723    unsigned char reserved4Bits : 4;
724
725
726    unsigned char segmentFeatureEnable[8][4];
727    short         segmentFeatureData[8][4];
728    unsigned char mb_segment_tree_probs[7];
729    unsigned char segment_pred_probs[3];
730    unsigned char reservedSegment16Bits[2];
731
732    int qpYAc;
733    int qpYDc;
734    int qpChDc;
735    int qpChAc;
736
737    unsigned int activeRefIdx[3];
738    unsigned int resetFrameContext;
739    unsigned int mcomp_filter_type;
740    unsigned int mbRefLfDelta[4];
741    unsigned int mbModeLfDelta[2];
742    unsigned int frameTagSize;
743    unsigned int offsetToDctParts;
744    unsigned int reserved128Bits[4];
745
746} CUVIDVP9PICPARAMS;
747
748/***********************************************************/
749//! \struct CUVIDAV1PICPARAMS
750//! AV1 picture parameters
751//! This structure is used in CUVIDPICPARAMS structure
752/***********************************************************/
753typedef struct _CUVIDAV1PICPARAMS
754{
755    unsigned int   width;                               // coded width, if superres enabled then it is upscaled width
756    unsigned int   height;                              // coded height
757    unsigned int   frame_offset;                        // defined as order_hint in AV1 specification
758    int            decodePicIdx;                        // decoded output pic index, if film grain enabled, it will keep decoded (without film grain) output
759                                                        // It can be used as reference frame for future frames
760
761    // sequence header
762    unsigned int   profile : 3;                         // 0 = profile0, 1 = profile1, 2 = profile2
763    unsigned int   use_128x128_superblock : 1;          // superblock size 0:64x64, 1: 128x128
764    unsigned int   subsampling_x : 1;                   // (subsampling_x, _y) 1,1 = 420, 1,0 = 422, 0,0 = 444
765    unsigned int   subsampling_y : 1;
766    unsigned int   mono_chrome : 1;                     // for monochrome content, mono_chrome = 1 and (subsampling_x, _y) should be 1,1
767    unsigned int   bit_depth_minus8 : 4;                // bit depth minus 8
768    unsigned int   enable_filter_intra : 1;             // tool enable in seq level, 0 : disable 1: frame header control
769    unsigned int   enable_intra_edge_filter : 1;        // intra edge filtering process, 0 : disable 1: enabled
770    unsigned int   enable_interintra_compound : 1;      // interintra, 0 : not present 1: present
771    unsigned int   enable_masked_compound : 1;          // 1: mode info for inter blocks may contain the syntax element compound_type.
772                                                        // 0: syntax element compound_type will not be present
773    unsigned int   enable_dual_filter : 1;              // vertical and horiz filter selection, 1: enable and 0: disable
774    unsigned int   enable_order_hint : 1;               // order hint, and related tools, 1: enable and 0: disable
775    unsigned int   order_hint_bits_minus1 : 3;          // is used to compute OrderHintBits
776    unsigned int   enable_jnt_comp : 1;                 // joint compound modes, 1: enable and 0: disable
777    unsigned int   enable_superres : 1;                 // superres in seq level, 0 : disable 1: frame level control
778    unsigned int   enable_cdef : 1;                     // cdef filtering in seq level, 0 : disable 1: frame level control
779    unsigned int   enable_restoration : 1;              // loop restoration filtering in seq level, 0 : disable 1: frame level control
780    unsigned int   enable_fgs : 1;                      // defined as film_grain_params_present in AV1 specification
781    unsigned int   reserved0_7bits : 7;                 // reserved bits; must be set to 0
782
783    // frame header
784    unsigned int   frame_type : 2 ;                     // 0:Key frame, 1:Inter frame, 2:intra only, 3:s-frame
785    unsigned int   show_frame : 1 ;                     // show_frame = 1 implies that frame should be immediately output once decoded
786    unsigned int   disable_cdf_update : 1;              // CDF update during symbol decoding, 1: disabled, 0: enabled
787    unsigned int   allow_screen_content_tools : 1;      // 1: intra blocks may use palette encoding, 0: palette encoding is never used
788    unsigned int   force_integer_mv : 1;                // 1: motion vectors will always be integers, 0: can contain fractional bits
789    unsigned int   coded_denom : 3;                     // coded_denom of the superres scale as specified in AV1 specification
790    unsigned int   allow_intrabc : 1;                   // 1: intra block copy may be used, 0: intra block copy is not allowed
791    unsigned int   allow_high_precision_mv : 1;         // 1/8 precision mv enable
792    unsigned int   interp_filter : 3;                   // interpolation filter. Refer to section 6.8.9 of the AV1 specification Version 1.0.0 with Errata 1
793    unsigned int   switchable_motion_mode : 1;          // defined as is_motion_mode_switchable in AV1 specification
794    unsigned int   use_ref_frame_mvs : 1;               // 1: current frame can use the previous frame mv information, 0: will not use.
795    unsigned int   disable_frame_end_update_cdf : 1;    // 1: indicates that the end of frame CDF update is disabled
796    unsigned int   delta_q_present : 1;                 // quantizer index delta values are present in the block level
797    unsigned int   delta_q_res : 2;                     // left shift which should be applied to decoded quantizer index delta values
798    unsigned int   using_qmatrix : 1;                   // 1: quantizer matrix will be used to compute quantizers
799    unsigned int   coded_lossless : 1;                  // 1: all segments use lossless coding
800    unsigned int   use_superres : 1;                    // 1: superres enabled for frame
801    unsigned int   tx_mode : 2;                         // 0: ONLY4x4,1:LARGEST,2:SELECT
802    unsigned int   reference_mode : 1;                  // 0: SINGLE, 1: SELECT
803    unsigned int   allow_warped_motion : 1;             // 1: allow_warped_motion may be present, 0: allow_warped_motion will not be present
804    unsigned int   reduced_tx_set : 1;                  // 1: frame is restricted to subset of the full set of transform types, 0: no such restriction
805    unsigned int   skip_mode : 1;                       // 1: most of the mode info is skipped, 0: mode info is not skipped
806    unsigned int   reserved1_3bits : 3;                 // reserved bits; must be set to 0
807
808    // tiling info
809    unsigned int   num_tile_cols : 8;                   // number of tiles across the frame., max is 64
810    unsigned int   num_tile_rows : 8;                   // number of tiles down the frame., max is 64
811    unsigned int   context_update_tile_id : 16;         // specifies which tile to use for the CDF update
812    unsigned short tile_widths[64];                     // Width of each column in superblocks
813    unsigned short tile_heights[64];                    // height of each row in superblocks
814
815    // CDEF - refer to section 6.10.14 of the AV1 specification Version 1.0.0 with Errata 1
816    unsigned char  cdef_damping_minus_3 : 2;            // controls the amount of damping in the deringing filter
817    unsigned char  cdef_bits : 2;                       // the number of bits needed to specify which CDEF filter to apply
818    unsigned char  reserved2_4bits : 4;                 // reserved bits; must be set to 0
819    unsigned char  cdef_y_strength[8];                  // 0-3 bits: y_pri_strength, 4-7 bits y_sec_strength
820    unsigned char  cdef_uv_strength[8];                 // 0-3 bits: uv_pri_strength, 4-7 bits uv_sec_strength
821
822    // SkipModeFrames
823    unsigned char   SkipModeFrame0 : 4;                 // specifies the frames to use for compound prediction when skip_mode is equal to 1.
824    unsigned char   SkipModeFrame1 : 4;
825
826    // qp information - refer to section 6.8.11 of the AV1 specification Version 1.0.0 with Errata 1
827    unsigned char  base_qindex;                         // indicates the base frame qindex. Defined as base_q_idx in AV1 specification
828    char           qp_y_dc_delta_q;                     // indicates the Y DC quantizer relative to base_q_idx. Defined as DeltaQYDc in AV1 specification
829    char           qp_u_dc_delta_q;                     // indicates the U DC quantizer relative to base_q_idx. Defined as DeltaQUDc in AV1 specification
830    char           qp_v_dc_delta_q;                     // indicates the V DC quantizer relative to base_q_idx. Defined as DeltaQVDc in AV1 specification
831    char           qp_u_ac_delta_q;                     // indicates the U AC quantizer relative to base_q_idx. Defined as DeltaQUAc in AV1 specification
832    char           qp_v_ac_delta_q;                     // indicates the V AC quantizer relative to base_q_idx. Defined as DeltaQVAc in AV1 specification
833    unsigned char  qm_y;                                // specifies the level in the quantizer matrix that should be used for luma plane decoding
834    unsigned char  qm_u;                                // specifies the level in the quantizer matrix that should be used for chroma U plane decoding
835    unsigned char  qm_v;                                // specifies the level in the quantizer matrix that should be used for chroma V plane decoding
836
837    // segmentation - refer to section 6.8.13 of the AV1 specification Version 1.0.0 with Errata 1
838    unsigned char segmentation_enabled : 1;             // 1 indicates that this frame makes use of the segmentation tool
839    unsigned char segmentation_update_map : 1;          // 1 indicates that the segmentation map are updated during the decoding of this frame
840    unsigned char segmentation_update_data : 1;         // 1 indicates that new parameters are about to be specified for each segment
841    unsigned char segmentation_temporal_update : 1;     // 1 indicates that the updates to the segmentation map are coded relative to the existing segmentation map
842    unsigned char reserved3_4bits : 4;                  // reserved bits; must be set to 0
843    short         segmentation_feature_data[8][8];      // specifies the feature data for a segment feature
844    unsigned char segmentation_feature_mask[8];         // indicates that the corresponding feature is unused or feature value is coded
845
846    // loopfilter - refer to section 6.8.10 of the AV1 specification Version 1.0.0 with Errata 1
847    unsigned char  loop_filter_level[2];                // contains loop filter strength values
848    unsigned char  loop_filter_level_u;                 // loop filter strength value of U plane
849    unsigned char  loop_filter_level_v;                 // loop filter strength value of V plane
850    unsigned char  loop_filter_sharpness;               // indicates the sharpness level
851    char           loop_filter_ref_deltas[8];           // contains the adjustment needed for the filter level based on the chosen reference frame
852    char           loop_filter_mode_deltas[2];          // contains the adjustment needed for the filter level based on the chosen mode
853    unsigned char  loop_filter_delta_enabled : 1;       // indicates that the filter level depends on the mode and reference frame used to predict a block
854    unsigned char  loop_filter_delta_update : 1;        // indicates that additional syntax elements are present that specify which mode and
855                                                        // reference frame deltas are to be updated
856    unsigned char  delta_lf_present : 1;                // specifies whether loop filter delta values are present in the block level
857    unsigned char  delta_lf_res : 2;                    // specifies the left shift to apply to the decoded loop filter values
858    unsigned char  delta_lf_multi  : 1;                 // separate loop filter deltas for Hy,Vy,U,V edges
859    unsigned char  reserved4_2bits : 2;                 // reserved bits; must be set to 0
860
861    // restoration - refer to section 6.10.15 of the AV1 specification Version 1.0.0 with Errata 1
862    unsigned char lr_unit_size[3];                     // specifies the size of loop restoration units: 0: 32, 1: 64, 2: 128, 3: 256
863    unsigned char lr_type[3] ;                         // used to compute FrameRestorationType
864
865    // reference frames
866    unsigned char primary_ref_frame;                    // specifies which reference frame contains the CDF values and other state that should be
867                                                        // loaded at the start of the frame
868    unsigned char ref_frame_map[8];                     // frames in dpb that can be used as reference for current or future frames
869
870    unsigned char temporal_layer_id : 4;                // temporal layer id
871    unsigned char spatial_layer_id : 4;                 // spatial layer id
872
873    unsigned char reserved5_32bits[4];                  // reserved bits; must be set to 0
874
875    // ref frame list
876    struct
877    {
878        unsigned int   width;
879        unsigned int   height;
880        unsigned char  index;
881        unsigned char  reserved24Bits[3];               // reserved bits; must be set to 0
882    } ref_frame[7];                                     // frames used as reference frame for current frame.
883
884    // global motion
885    struct {
886        unsigned char invalid : 1;
887        unsigned char wmtype : 2;                       // defined as GmType in AV1 specification
888        unsigned char reserved5Bits : 5;                // reserved bits; must be set to 0
889        char          reserved24Bits[3];                // reserved bits; must be set to 0
890        int           wmmat[6];                         // defined as gm_params[] in AV1 specification
891    } global_motion[7];                                 // global motion params for reference frames
892
893    // film grain params - refer to section 6.8.20 of the AV1 specification Version 1.0.0 with Errata 1
894    unsigned short apply_grain : 1;
895    unsigned short overlap_flag : 1;
896    unsigned short scaling_shift_minus8 : 2;
897    unsigned short chroma_scaling_from_luma : 1;
898    unsigned short ar_coeff_lag : 2;
899    unsigned short ar_coeff_shift_minus6 : 2;
900    unsigned short grain_scale_shift : 2;
901    unsigned short clip_to_restricted_range : 1;
902    unsigned short reserved6_4bits : 4;                 // reserved bits; must be set to 0
903    unsigned char  num_y_points;
904    unsigned char  scaling_points_y[14][2];
905    unsigned char  num_cb_points;
906    unsigned char  scaling_points_cb[10][2];
907    unsigned char  num_cr_points;
908    unsigned char  scaling_points_cr[10][2];
909    unsigned char  reserved7_8bits;                     // reserved bits; must be set to 0
910    unsigned short random_seed;
911    short          ar_coeffs_y[24];
912    short          ar_coeffs_cb[25];
913    short          ar_coeffs_cr[25];
914    unsigned char  cb_mult;
915    unsigned char  cb_luma_mult;
916    short          cb_offset;
917    unsigned char  cr_mult;
918    unsigned char  cr_luma_mult;
919    short          cr_offset;
920
921    int            reserved[7];                       // reserved bits; must be set to 0
922} CUVIDAV1PICPARAMS;
923
924/******************************************************************************************/
925//! \struct CUVIDPICPARAMS
926//! Picture parameters for decoding
927//! This structure is used in cuvidDecodePicture API
928//! IN  for cuvidDecodePicture
929/******************************************************************************************/
930typedef struct _CUVIDPICPARAMS
931{
932    int PicWidthInMbs;                     /**< IN: Coded frame size in macroblocks                           */
933    int FrameHeightInMbs;                  /**< IN: Coded frame height in macroblocks                         */
934    int CurrPicIdx;                        /**< IN: Output index of the current picture                       */
935    int field_pic_flag;                    /**< IN: 0=frame picture, 1=field picture                          */
936    int bottom_field_flag;                 /**< IN: 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
937    int second_field;                      /**< IN: Second field of a complementary field pair                */
938    // Bitstream data
939    unsigned int nBitstreamDataLen;        /**< IN: Number of bytes in bitstream data buffer                  */
940    const unsigned char *pBitstreamData;   /**< IN: Ptr to bitstream data for this picture (slice-layer)      */
941    unsigned int nNumSlices;               /**< IN: Number of slices in this picture                          */
942    const unsigned int *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within
943                                                        the bitstream data buffer                             */
944    int ref_pic_flag;                      /**< IN: This picture is a reference picture                       */
945    int intra_pic_flag;                    /**< IN: This picture is entirely intra coded                      */
946    unsigned int Reserved[30];             /**< Reserved for future use                                       */
947    // IN: Codec-specific data
948    union {
949        CUVIDMPEG2PICPARAMS mpeg2;         /**< Also used for MPEG-1 */
950        CUVIDH264PICPARAMS  h264;
951        CUVIDVC1PICPARAMS   vc1;
952        CUVIDMPEG4PICPARAMS mpeg4;
953        CUVIDJPEGPICPARAMS  jpeg;
954        CUVIDHEVCPICPARAMS  hevc;
955        CUVIDVP8PICPARAMS   vp8;
956        CUVIDVP9PICPARAMS   vp9;
957        CUVIDAV1PICPARAMS   av1;
958        unsigned int CodecReserved[1024];
959    } CodecSpecific;
960} CUVIDPICPARAMS;
961
962
963/******************************************************/
964//! \struct CUVIDPROCPARAMS
965//! Picture parameters for postprocessing
966//! This structure is used in cuvidMapVideoFrame API
967/******************************************************/
968typedef struct _CUVIDPROCPARAMS
969{
970    int progressive_frame;                        /**< IN: Input is progressive (deinterlace_mode will be ignored)                */
971    int second_field;                             /**< IN: Output the second field (ignored if deinterlace mode is Weave)         */
972    int top_field_first;                          /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */
973    int unpaired_field;                           /**< IN: Input only contains one field (2nd field is invalid)                   */
974    // The fields below are used for raw YUV input
975    unsigned int reserved_flags;                  /**< Reserved for future use (set to zero)                                      */
976    unsigned int reserved_zero;                   /**< Reserved (set to zero)                                                     */
977    unsigned long long raw_input_dptr;            /**< IN: Input CUdeviceptr for raw YUV extensions                               */
978    unsigned int raw_input_pitch;                 /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately)      */
979    unsigned int raw_input_format;                /**< IN: Input YUV format (cudaVideoCodec_enum)                                 */
980    unsigned long long raw_output_dptr;           /**< IN: Output CUdeviceptr for raw YUV extensions                              */
981    unsigned int raw_output_pitch;                /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately)     */
982    unsigned int Reserved1;                       /**< Reserved for future use (set to zero)                                      */
983    CUstream output_stream;                       /**< IN: stream object used by cuvidMapVideoFrame                               */
984    unsigned int Reserved[46];                    /**< Reserved for future use (set to zero)                                      */
985    unsigned long long *histogram_dptr;           /**< OUT: Output CUdeviceptr for histogram extensions                           */
986    void *Reserved2[1];                           /**< Reserved for future use (set to zero)                                      */
987} CUVIDPROCPARAMS;
988
989/*********************************************************************************************************/
990//! \struct CUVIDGETDECODESTATUS
991//! Struct for reporting decode status.
992//! This structure is used in cuvidGetDecodeStatus API.
993/*********************************************************************************************************/
994typedef struct _CUVIDGETDECODESTATUS
995{
996    cuvidDecodeStatus decodeStatus;
997    unsigned int reserved[31];
998    void *pReserved[8];
999} CUVIDGETDECODESTATUS;
1000
1001/****************************************************/
1002//! \struct CUVIDRECONFIGUREDECODERINFO
1003//! Struct for decoder reset
1004//! This structure is used in cuvidReconfigureDecoder() API
1005/****************************************************/
1006typedef struct _CUVIDRECONFIGUREDECODERINFO
1007{
1008    unsigned int ulWidth;             /**< IN: Coded sequence width in pixels, MUST be < = ulMaxWidth defined at CUVIDDECODECREATEINFO  */
1009    unsigned int ulHeight;            /**< IN: Coded sequence height in pixels, MUST be < = ulMaxHeight defined at CUVIDDECODECREATEINFO  */
1010    unsigned int ulTargetWidth;       /**< IN: Post processed output width */
1011    unsigned int ulTargetHeight;      /**< IN: Post Processed output height */
1012    unsigned int ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */
1013    unsigned int reserved1[12];       /**< Reserved for future use. Set to Zero */
1014    /**
1015    * IN: Area of frame to be displayed. Use-case : Source Cropping
1016    */
1017    struct {
1018        short left;
1019        short top;
1020        short right;
1021        short bottom;
1022    } display_area;
1023    /**
1024    * IN: Target Rectangle in the OutputFrame. Use-case : Aspect ratio Conversion
1025    */
1026    struct {
1027        short left;
1028        short top;
1029        short right;
1030        short bottom;
1031    } target_rect;
1032    unsigned int reserved2[11]; /**< Reserved for future use. Set to Zero */
1033} CUVIDRECONFIGUREDECODERINFO;
1034
1035
1036/***********************************************************************************************************/
1037//! VIDEO_DECODER
1038//!
1039//! In order to minimize decode latencies, there should be always at least 2 pictures in the decode
1040//! queue at any time, in order to make sure that all decode engines are always busy.
1041//!
1042//! Overall data flow:
1043//!  - cuvidGetDecoderCaps(...)
1044//!  - cuvidCreateDecoder(...)
1045//!  - For each picture:
1046//!    + cuvidDecodePicture(N)
1047//!    + cuvidMapVideoFrame(N-4)
1048//!    + do some processing in cuda
1049//!    + cuvidUnmapVideoFrame(N-4)
1050//!    + cuvidDecodePicture(N+1)
1051//!    + cuvidMapVideoFrame(N-3)
1052//!    + ...
1053//!  - cuvidDestroyDecoder(...)
1054//!
1055//! NOTE:
1056//! - When the cuda context is created from a D3D device, the D3D device must also be created
1057//!   with the D3DCREATE_MULTITHREADED flag.
1058//! - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
1059//! - cuvidDecodePicture may block the calling thread if there are too many pictures pending
1060//!   in the decode queue
1061/***********************************************************************************************************/
1062
1063
1064/**********************************************************************************************************************/
1065//! \fn CUresult CUDAAPI cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc)
1066//! Queries decode capabilities of NVDEC-HW based on CodecType, ChromaFormat and BitDepthMinus8 parameters.
1067//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of CUVIDDECODECAPS structure
1068//! 2. On calling cuvidGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported
1069//!    If IN parameters passed to the driver are not supported by NVDEC-HW, then all OUT params are set to 0.
1070//! E.g. on Geforce GTX 960:
1071//!   App fills - eCodecType = cudaVideoCodec_H264; eChromaFormat = cudaVideoChromaFormat_420; nBitDepthMinus8 = 0;
1072//!   Given IN parameters are supported, hence driver fills: bIsSupported = 1; nMinWidth   = 48; nMinHeight  = 16;
1073//!   nMaxWidth = 4096; nMaxHeight = 4096; nMaxMBCount = 65536;
1074//! CodedWidth*CodedHeight/256 must be less than or equal to nMaxMBCount
1075/**********************************************************************************************************************/
1076extern CUresult CUDAAPI cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc);
1077
1078/*****************************************************************************************************/
1079//! \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
1080//! Create the decoder object based on pdci. A handle to the created decoder is returned
1081/*****************************************************************************************************/
1082extern CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
1083
1084/*****************************************************************************************************/
1085//! \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
1086//! Destroy the decoder object
1087/*****************************************************************************************************/
1088extern CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder);
1089
1090/*****************************************************************************************************/
1091//! \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
1092//! Decode a single picture (field or frame)
1093//! Kicks off HW decoding
1094/*****************************************************************************************************/
1095extern CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
1096
1097/************************************************************************************************************/
1098//! \fn CUresult CUDAAPI cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx);
1099//! Get the decode status for frame corresponding to nPicIdx
1100//! API is supported for Maxwell and above generation GPUs.
1101//! API is currently supported for HEVC, H264 and JPEG codecs.
1102//! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec.
1103/************************************************************************************************************/
1104extern CUresult CUDAAPI cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx, CUVIDGETDECODESTATUS* pDecodeStatus);
1105
1106/*********************************************************************************************************/
1107//! \fn CUresult CUDAAPI cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams)
1108//! Used to reuse single decoder for multiple clips. Currently supports resolution change, resize params, display area
1109//! params, target area params change for same codec. Must be called during CUVIDPARSERPARAMS::pfnSequenceCallback
1110/*********************************************************************************************************/
1111extern CUresult CUDAAPI cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams);
1112
1113
1114#if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
1115/************************************************************************************************************************/
1116//! \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr,
1117//!                                         unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
1118//! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated
1119//! pitch of the video frame
1120/************************************************************************************************************************/
1121extern CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
1122                                           unsigned int *pDevPtr, unsigned int *pPitch,
1123                                           CUVIDPROCPARAMS *pVPP);
1124
1125/*****************************************************************************************************/
1126//! \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
1127//! Unmap a previously mapped video frame
1128/*****************************************************************************************************/
1129extern CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
1130#endif
1131
1132/****************************************************************************************************************************/
1133//! \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
1134//!                                           unsigned int * pPitch, CUVIDPROCPARAMS *pVPP);
1135//! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated
1136//! pitch of the video frame
1137/****************************************************************************************************************************/
1138extern CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
1139                                             unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
1140
1141/**************************************************************************************************/
1142//! \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
1143//! Unmap a previously mapped video frame
1144/**************************************************************************************************/
1145extern CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
1146
1147#if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
1148#define cuvidMapVideoFrame      cuvidMapVideoFrame64
1149#define cuvidUnmapVideoFrame    cuvidUnmapVideoFrame64
1150#endif
1151
1152
1153
1154/********************************************************************************************************************/
1155//!
1156//! Context-locking: to facilitate multi-threaded implementations, the following 4 functions
1157//! provide a simple mutex-style host synchronization. If a non-NULL context is specified
1158//! in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
1159//! context before making any cuda calls.
1160//! A multi-threaded application could create a lock associated with a context handle so that
1161//! multiple threads can safely share the same cuda context:
1162//!  - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
1163//!    that can be passed to cuvidCtxLockCreate.
1164//!  - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
1165//!
1166//! NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
1167//! decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
1168/********************************************************************************************************************/
1169
1170/********************************************************************************************************************/
1171//! \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
1172//! This API is used to create CtxLock object
1173/********************************************************************************************************************/
1174extern CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
1175
1176/********************************************************************************************************************/
1177//! \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
1178//! This API is used to free CtxLock object
1179/********************************************************************************************************************/
1180extern CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck);
1181
1182/********************************************************************************************************************/
1183//! \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
1184//! This API is used to acquire ctxlock
1185/********************************************************************************************************************/
1186extern CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
1187
1188/********************************************************************************************************************/
1189//! \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
1190//! This API is used to release ctxlock
1191/********************************************************************************************************************/
1192extern CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
1193
1194/**********************************************************************************************/
1195
1196#if defined(__cplusplus)
1197}
1198// Auto-lock helper for C++ applications
1199class CCtxAutoLock
1200{

Showing the first 1,200 of 1210 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai