FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dynlink_cuviddec.h
Go to the documentation of this file.
1 /*
2  * This copyright notice applies to this header file only:
3  *
4  * Copyright (c) 2010-2016 NVIDIA Corporation
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use,
10  * copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the software, and to permit persons to whom the
12  * software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 /**
29  * \file cuviddec.h
30  * NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
31  * \date 2015-2016
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 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
39 #if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020))
40 #define __CUVID_DEVPTR64
41 #endif
42 #endif
43 
44 #if defined(__cplusplus)
45 extern "C" {
46 #endif /* __cplusplus */
47 
48 #if defined(__CYGWIN__)
49 typedef unsigned int tcu_ulong;
50 #else
51 typedef unsigned long tcu_ulong;
52 #endif
53 
54 typedef void *CUvideodecoder;
55 typedef struct _CUcontextlock_st *CUvideoctxlock;
56 
57 /**
58  * \addtogroup VIDEO_DECODER Video Decoder
59  * @{
60  */
61 
62 /*!
63  * \enum cudaVideoCodec
64  * Video Codec Enums
65  */
66 typedef enum cudaVideoCodec_enum {
67  cudaVideoCodec_MPEG1=0, /**< MPEG1 */
68  cudaVideoCodec_MPEG2, /**< MPEG2 */
69  cudaVideoCodec_MPEG4, /**< MPEG4 */
70  cudaVideoCodec_VC1, /**< VC1 */
71  cudaVideoCodec_H264, /**< H264 */
72  cudaVideoCodec_JPEG, /**< JPEG */
73  cudaVideoCodec_H264_SVC, /**< H264-SVC */
74  cudaVideoCodec_H264_MVC, /**< H264-MVC */
75  cudaVideoCodec_HEVC, /**< HEVC */
76  cudaVideoCodec_VP8, /**< VP8 */
77  cudaVideoCodec_VP9, /**< VP9 */
78  cudaVideoCodec_NumCodecs, /**< Max COdecs */
79  // Uncompressed YUV
80  cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), /**< Y,U,V (4:2:0) */
81  cudaVideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,V,U (4:2:0) */
82  cudaVideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,UV (4:2:0) */
83  cudaVideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), /**< YUYV/YUY2 (4:2:2) */
84  cudaVideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) /**< UYVY (4:2:2) */
86 
87 /*!
88  * \enum cudaVideoSurfaceFormat
89  * Video Surface Formats Enums
90  */
91 typedef enum cudaVideoSurfaceFormat_enum {
95 
96 /*!
97  * \enum cudaVideoDeinterlaceMode
98  * Deinterlacing Modes Enums
99  */
100 typedef enum cudaVideoDeinterlaceMode_enum {
101  cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */
102  cudaVideoDeinterlaceMode_Bob, /**< Drop one field */
103  cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */
105 
106 /*!
107  * \enum cudaVideoChromaFormat
108  * Chroma Formats Enums
109  */
110 typedef enum cudaVideoChromaFormat_enum {
111  cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */
116 
117 /*!
118  * \enum cudaVideoCreateFlags
119  * Decoder Flags Enums
120  */
121 typedef enum cudaVideoCreateFlags_enum {
122  cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */
123  cudaVideoCreate_PreferCUDA = 0x01, /**< Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-threading) */
124  cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */
125  cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */
127 
128 /*!
129  * \struct CUVIDDECODECREATEINFO
130  * Struct used in create decoder
131  */
132 typedef struct _CUVIDDECODECREATEINFO
133 {
134  tcu_ulong ulWidth; /**< Coded Sequence Width */
135  tcu_ulong ulHeight; /**< Coded Sequence Height */
136  tcu_ulong ulNumDecodeSurfaces; /**< Maximum number of internal decode surfaces */
137  cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
138  cudaVideoChromaFormat ChromaFormat; /**< cudaVideoChromaFormat_XXX (only 4:2:0 is currently supported) */
139  tcu_ulong ulCreationFlags; /**< Decoder creation flags (cudaVideoCreateFlags_XXX) */
140  tcu_ulong bitDepthMinus8;
141  tcu_ulong Reserved1[4]; /**< Reserved for future use - set to zero */
142  /**
143  * area of the frame that should be displayed
144  */
145  struct {
146  short left;
147  short top;
148  short right;
149  short bottom;
150  } display_area;
151 
152  cudaVideoSurfaceFormat OutputFormat; /**< cudaVideoSurfaceFormat_XXX */
153  cudaVideoDeinterlaceMode DeinterlaceMode; /**< cudaVideoDeinterlaceMode_XXX */
154  tcu_ulong ulTargetWidth; /**< Post-processed Output Width (Should be aligned to 2) */
155  tcu_ulong ulTargetHeight; /**< Post-processed Output Height (Should be aligbed to 2) */
156  tcu_ulong ulNumOutputSurfaces; /**< Maximum number of output surfaces simultaneously mapped */
157  CUvideoctxlock vidLock; /**< If non-NULL, context lock used for synchronizing ownership of the cuda context */
158  /**
159  * target rectangle in the output frame (for aspect ratio conversion)
160  * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
161  */
162  struct {
163  short left;
164  short top;
165  short right;
166  short bottom;
167  } target_rect;
168  tcu_ulong Reserved2[5]; /**< Reserved for future use - set to zero */
170 
171 /*!
172  * \struct CUVIDH264DPBENTRY
173  * H.264 DPB Entry
174  */
175 typedef struct _CUVIDH264DPBENTRY
176 {
177  int PicIdx; /**< picture index of reference frame */
178  int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */
179  int is_long_term; /**< 0=short term reference, 1=long term reference */
180  int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
181  int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */
182  int FieldOrderCnt[2]; /**< field order count of top and bottom fields */
184 
185 /*!
186  * \struct CUVIDH264MVCEXT
187  * H.264 MVC Picture Parameters Ext
188  */
189 typedef struct _CUVIDH264MVCEXT
190 {
192  int view_id;
193  unsigned char inter_view_flag;
194  unsigned char num_inter_view_refs_l0;
195  unsigned char num_inter_view_refs_l1;
196  unsigned char MVCReserved8Bits;
197  int InterViewRefsL0[16];
198  int InterViewRefsL1[16];
200 
201 /*!
202  * \struct CUVIDH264SVCEXT
203  * H.264 SVC Picture Parameters Ext
204  */
205 typedef struct _CUVIDH264SVCEXT
206 {
207  unsigned char profile_idc;
208  unsigned char level_idc;
209  unsigned char DQId;
210  unsigned char DQIdMax;
215 
216  unsigned short DPBEntryValidFlag;
222  unsigned char chroma_phase_y_plus1;
223 
227  unsigned char store_ref_base_pic_flag;
228  unsigned char Reserved8BitsA;
229  unsigned char Reserved8BitsB;
230  // For the 4 scaled_ref_layer_XX fields below,
231  // if (extended_spatial_scalability_idc == 1), SPS field, G.7.3.2.1.4, add prefix "seq_"
232  // if (extended_spatial_scalability_idc == 2), SLH field, G.7.3.3.4,
237  unsigned short Reserved16Bits;
238  struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded. Linked list ends at the target layer. */
239  int bRefBaseLayer; /**< whether to store ref base pic */
241 
242 /*!
243  * \struct CUVIDH264PICPARAMS
244  * H.264 Picture Parameters
245  */
246 typedef struct _CUVIDH264PICPARAMS
247 {
248  // SPS
255  int num_ref_frames; // NOTE: shall meet level 4.1 restrictions
257  unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported)
258  unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)
260  // PPS
277  int CurrFieldOrderCnt[2];
278  // DPB
279  CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB
280  // Quantization Matrices (raster-order)
281  unsigned char WeightScale4x4[6][16];
282  unsigned char WeightScale8x8[2][64];
283  // FMO/ASO
284  unsigned char fmo_aso_enable;
285  unsigned char num_slice_groups_minus1;
286  unsigned char slice_group_map_type;
287  signed char pic_init_qs_minus26;
289  union
290  {
291  unsigned long long slice_group_map_addr;
292  const unsigned char *pMb2SliceGroupMap;
293  } fmo;
294  unsigned int Reserved[12];
295  // SVC/MVC
296  union
297  {
300  } svcmvc;
302 
303 
304 /*!
305  * \struct CUVIDMPEG2PICPARAMS
306  * MPEG-2 Picture Parameters
307  */
308 typedef struct _CUVIDMPEG2PICPARAMS
309 {
310  int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
311  int BackwardRefIdx; // Picture index of backward reference (B-frames)
315  int f_code[2][2];
323  // Quantization matrices (raster order)
324  unsigned char QuantMatrixIntra[64];
325  unsigned char QuantMatrixInter[64];
327 
328 ////////////////////////////////////////////////////////////////////////////////////////////////
329 //
330 // MPEG-4 Picture Parameters
331 //
332 
333 // MPEG-4 has VOP types instead of Picture types
334 #define I_VOP 0
335 #define P_VOP 1
336 #define B_VOP 2
337 #define S_VOP 3
338 
339 /*!
340  * \struct CUVIDMPEG4PICPARAMS
341  * MPEG-4 Picture Parameters
342  */
343 typedef struct _CUVIDMPEG4PICPARAMS
344 {
345  int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
346  int BackwardRefIdx; // Picture index of backward reference (B-frames)
347  // VOL
357  // VOP
365  int trd[2];
366  int trb[2];
367  // Quantization matrices (raster order)
368  unsigned char QuantMatrixIntra[64];
369  unsigned char QuantMatrixInter[64];
372 
373 /*!
374  * \struct CUVIDVC1PICPARAMS
375  * VC1 Picture Parameters
376  */
377 typedef struct _CUVIDVC1PICPARAMS
378 {
379  int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */
380  int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */
381  int FrameWidth; /**< Actual frame width */
382  int FrameHeight; /**< Actual frame height */
383  // PICTURE
384  int intra_pic_flag; /**< Set to 1 for I,BI frames */
385  int ref_pic_flag; /**< Set to 1 for I,P frames */
386  int progressive_fcm; /**< Progressive frame */
387  // SEQUENCE
388  int profile;
390  int pulldown;
394  int psf;
395  int multires;
397  int rangered;
399  // ENTRYPOINT
403  int dquant;
406  int fastuvmc;
407  int overlap;
414  int rangeredfrm; // range reduction state
416 
417 /*!
418  * \struct CUVIDJPEGPICPARAMS
419  * JPEG Picture Parameters
420  */
421 typedef struct _CUVIDJPEGPICPARAMS
422 {
423  int Reserved;
425 
426 
427  /*!
428  * \struct CUVIDHEVCPICPARAMS
429  * HEVC Picture Parameters
430  */
431 typedef struct _CUVIDHEVCPICPARAMS
432 {
433  // sps
440  unsigned char pcm_enabled_flag;
444 
450  unsigned char amp_enabled_flag;
453 
460  unsigned char IrapPicFlag;
461  unsigned char IdrPicFlag;
462 
463  unsigned char bit_depth_luma_minus8;
464  unsigned char bit_depth_chroma_minus8;
465  unsigned char reserved1[14];
466 
467  // pps
472  unsigned char diff_cu_qp_delta_depth;
473  signed char init_qp_minus26;
474  signed char pps_cb_qp_offset;
475  signed char pps_cr_qp_offset;
476 
478  unsigned char weighted_pred_flag;
479  unsigned char weighted_bipred_flag;
485 
492  unsigned char cabac_init_present_flag;
494 
497  signed char pps_beta_offset_div2;
498  signed char pps_tc_offset_div2;
499  unsigned char tiles_enabled_flag;
500  unsigned char uniform_spacing_flag;
501  unsigned char num_tile_columns_minus1;
502  unsigned char num_tile_rows_minus1;
503 
504  unsigned short column_width_minus1[21];
505  unsigned short row_height_minus1[21];
506  unsigned int reserved3[15];
507 
508  // RefPicSets
516  int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference)
517  int PicOrderCntVal[16]; // [refpic]
518  unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference
519  unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
520  unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15)
521  unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15)
522  unsigned char RefPicSetInterLayer0[8];
523  unsigned char RefPicSetInterLayer1[8];
524  unsigned int reserved4[12];
525 
526  // scaling lists (diag order)
527  unsigned char ScalingList4x4[6][16]; // [matrixId][i]
528  unsigned char ScalingList8x8[6][64]; // [matrixId][i]
529  unsigned char ScalingList16x16[6][64]; // [matrixId][i]
530  unsigned char ScalingList32x32[2][64]; // [matrixId][i]
531  unsigned char ScalingListDCCoeff16x16[6]; // [matrixId]
532  unsigned char ScalingListDCCoeff32x32[2]; // [matrixId]
534 
535 
536 /*!
537  * \struct CUVIDVP8PICPARAMS
538  * VP8 Picture Parameters
539  */
540 typedef struct _CUVIDVP8PICPARAMS
541 {
542  int width;
543  int height;
544  unsigned int first_partition_size;
545  //Frame Indexes
546  unsigned char LastRefIdx;
547  unsigned char GoldenRefIdx;
548  unsigned char AltRefIdx;
549  union {
550  struct {
551  unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */
552  unsigned char version : 3;
553  unsigned char show_frame : 1;
554  unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */
555  unsigned char Reserved2Bits : 2;
556  };
557  unsigned char wFrameTagFlags;
558  } tagflags;
559  unsigned char Reserved1[4];
560  unsigned int Reserved2[3];
562 
563 /*!
564  * \struct CUVIDVP9PICPARAMS
565  * VP9 Picture Parameters
566  */
567 typedef struct _CUVIDVP9PICPARAMS
568 {
569  unsigned int width;
570  unsigned int height;
571 
572  //Frame Indices
573  unsigned char LastRefIdx;
574  unsigned char GoldenRefIdx;
575  unsigned char AltRefIdx;
576  unsigned char colorSpace;
577 
578  unsigned short profile : 3;
579  unsigned short frameContextIdx : 2;
580  unsigned short frameType : 1;
581  unsigned short showFrame : 1;
582  unsigned short errorResilient : 1;
583  unsigned short frameParallelDecoding : 1;
584  unsigned short subSamplingX : 1;
585  unsigned short subSamplingY : 1;
586  unsigned short intraOnly : 1;
587  unsigned short allow_high_precision_mv : 1;
588  unsigned short refreshEntropyProbs : 1;
589  unsigned short reserved2Bits : 2;
590 
591  unsigned short reserved16Bits;
592 
593  unsigned char refFrameSignBias[4];
594 
595  unsigned char bitDepthMinus8Luma;
596  unsigned char bitDepthMinus8Chroma;
597  unsigned char loopFilterLevel;
598  unsigned char loopFilterSharpness;
599 
600  unsigned char modeRefLfEnabled;
601  unsigned char log2_tile_columns;
602  unsigned char log2_tile_rows;
603 
604  unsigned char segmentEnabled : 1;
605  unsigned char segmentMapUpdate : 1;
606  unsigned char segmentMapTemporalUpdate : 1;
607  unsigned char segmentFeatureMode : 1;
608  unsigned char reserved4Bits : 4;
609 
610 
611  unsigned char segmentFeatureEnable[8][4];
612  short segmentFeatureData[8][4];
613  unsigned char mb_segment_tree_probs[7];
614  unsigned char segment_pred_probs[3];
615  unsigned char reservedSegment16Bits[2];
616 
617  int qpYAc;
618  int qpYDc;
619  int qpChDc;
620  int qpChAc;
621 
622  unsigned int activeRefIdx[3];
623  unsigned int resetFrameContext;
624  unsigned int mcomp_filter_type;
625  unsigned int mbRefLfDelta[4];
626  unsigned int mbModeLfDelta[2];
627  unsigned int frameTagSize;
628  unsigned int offsetToDctParts;
629  unsigned int reserved128Bits[4];
630 
632 
633 
634 /*!
635  * \struct CUVIDPICPARAMS
636  * Picture Parameters for Decoding
637  */
638 typedef struct _CUVIDPICPARAMS
639 {
640  int PicWidthInMbs; /**< Coded Frame Size */
641  int FrameHeightInMbs; /**< Coded Frame Height */
642  int CurrPicIdx; /**< Output index of the current picture */
643  int field_pic_flag; /**< 0=frame picture, 1=field picture */
644  int bottom_field_flag; /**< 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
645  int second_field; /**< Second field of a complementary field pair */
646  // Bitstream data
647  unsigned int nBitstreamDataLen; /**< Number of bytes in bitstream data buffer */
648  const unsigned char *pBitstreamData; /**< Ptr to bitstream data for this picture (slice-layer) */
649  unsigned int nNumSlices; /**< Number of slices in this picture */
650  const unsigned int *pSliceDataOffsets; /**< nNumSlices entries, contains offset of each slice within the bitstream data buffer */
651  int ref_pic_flag; /**< This picture is a reference picture */
652  int intra_pic_flag; /**< This picture is entirely intra coded */
653  unsigned int Reserved[30]; /**< Reserved for future use */
654  // Codec-specific data
655  union {
656  CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */
664  unsigned int CodecReserved[1024];
665  } CodecSpecific;
667 
668 
669 /*!
670  * \struct CUVIDPROCPARAMS
671  * Picture Parameters for Postprocessing
672  */
673 typedef struct _CUVIDPROCPARAMS
674 {
675  int progressive_frame; /**< Input is progressive (deinterlace_mode will be ignored) */
676  int second_field; /**< Output the second field (ignored if deinterlace mode is Weave) */
677  int top_field_first; /**< Input frame is top field first (1st field is top, 2nd field is bottom) */
678  int unpaired_field; /**< Input only contains one field (2nd field is invalid) */
679  // The fields below are used for raw YUV input
680  unsigned int reserved_flags; /**< Reserved for future use (set to zero) */
681  unsigned int reserved_zero; /**< Reserved (set to zero) */
682  unsigned long long raw_input_dptr; /**< Input CUdeviceptr for raw YUV extensions */
683  unsigned int raw_input_pitch; /**< pitch in bytes of raw YUV input (should be aligned appropriately) */
684  unsigned int raw_input_format; /**< Reserved for future use (set to zero) */
685  unsigned long long raw_output_dptr; /**< Reserved for future use (set to zero) */
686  unsigned int raw_output_pitch; /**< Reserved for future use (set to zero) */
687  unsigned int Reserved[48];
688  void *Reserved3[3];
690 
691 
692 /**
693  *
694  * In order to minimize decode latencies, there should be always at least 2 pictures in the decode
695  * queue at any time, in order to make sure that all decode engines are always busy.
696  *
697  * Overall data flow:
698  * - cuvidCreateDecoder(...)
699  * For each picture:
700  * - cuvidDecodePicture(N)
701  * - cuvidMapVideoFrame(N-4)
702  * - do some processing in cuda
703  * - cuvidUnmapVideoFrame(N-4)
704  * - cuvidDecodePicture(N+1)
705  * - cuvidMapVideoFrame(N-3)
706  * ...
707  * - cuvidDestroyDecoder(...)
708  *
709  * NOTE:
710  * - When the cuda context is created from a D3D device, the D3D device must also be created
711  * with the D3DCREATE_MULTITHREADED flag.
712  * - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
713  * - cuVidDecodePicture may block the calling thread if there are too many pictures pending
714  * in the decode queue
715  */
716 
717 /**
718  * \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
719  * Create the decoder object
720  */
721 typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
722 
723 /**
724  * \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
725  * Destroy the decoder object
726  */
727 typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder);
728 
729 /**
730  * \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
731  * Decode a single picture (field or frame)
732  */
733 typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
734 
735 
736 #if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
737 /**
738  * \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
739  * Post-process and map a video frame for use in cuda
740  */
741 typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
742  unsigned int *pDevPtr, unsigned int *pPitch,
743  CUVIDPROCPARAMS *pVPP);
744 
745 /**
746  * \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
747  * Unmap a previously mapped video frame
748  */
749 typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
750 #endif
751 
752 #if defined(WIN64) || defined(_WIN64) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
753 /**
754  * \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
755  * map a video frame
756  */
757 typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
758  unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
759 
760 /**
761  * \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
762  * Unmap a previously mapped video frame
763  */
764 typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
765 
766 #if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
767 #define tcuvidMapVideoFrame tcuvidMapVideoFrame64
768 #define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64
769 #endif
770 #endif
771 
772 
773 /**
774  *
775  * Context-locking: to facilitate multi-threaded implementations, the following 4 functions
776  * provide a simple mutex-style host synchronization. If a non-NULL context is specified
777  * in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
778  * context before making any cuda calls.
779  * A multi-threaded application could create a lock associated with a context handle so that
780  * multiple threads can safely share the same cuda context:
781  * - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
782  * that can be passed to cuvidCtxLockCreate.
783  * - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
784  *
785  * NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
786  * decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
787 */
788 
789 /**
790  * \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
791  */
792 typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
793 
794 /**
795  * \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
796  */
797 typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck);
798 
799 /**
800  * \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
801  */
802 typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
803 
804 /**
805  * \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
806  */
807 typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
808 
809 /** @} */ /* End VIDEO_DECODER */
810 
811 #if defined(__cplusplus)
812 }
813 #endif /* __cplusplus */
814 
815 #endif // __CUDA_VIDEO_H__
short scaled_ref_layer_bottom_offset
unsigned char loop_filter_across_tiles_enabled_flag
int ref_pic_flag
Set to 1 for I,P frames.
int PicWidthInMbs
Coded Frame Size.
unsigned char bitDepthMinus8Luma
unsigned char deblocking_filter_override_enabled_flag
short scaled_ref_layer_right_offset
int unpaired_field
Input only contains one field (2nd field is invalid)
signed char pps_tc_offset_div2
unsigned int raw_input_format
Reserved for future use (set to zero)
tcu_ulong ulNumOutputSurfaces
Maximum number of output surfaces simultaneously mapped.
unsigned char num_tile_columns_minus1
short scaled_ref_layer_top_offset
unsigned char log2_max_pic_order_cnt_lsb_minus4
unsigned char uniform_spacing_flag
unsigned char num_ref_idx_l0_default_active_minus1
cudaVideoSurfaceFormat
unsigned char bit_depth_chroma_minus8
CUVIDH264SVCEXT svcext
unsigned char diff_cu_qp_delta_depth
unsigned char num_long_term_ref_pics_sps
int is_long_term
0=short term reference, 1=long term reference
unsigned short Reserved16Bits
unsigned char pcm_enabled_flag
struct _CUVIDPICPARAMS * pNextLayer
Points to the picparams for the next layer to be decoded.
unsigned char IrapPicFlag
unsigned char inter_view_flag
int FrameIdx
frame_num(short-term) or LongTermFrameIdx(long-term)
int version
Definition: avisynth_c.h:766
unsigned char dependent_slice_segments_enabled_flag
int field_pic_flag
0=frame picture, 1=field picture
static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, AVFormatContext *fmt_ctx)
Definition: ffprobe.c:2082
unsigned char chroma_phase_y_plus1
unsigned char residual_colour_transform_flag
unsigned char GoldenRefIdx
CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
Use dedicated video engines directly.
unsigned char LastRefIdx
const unsigned char * pMb2SliceGroupMap
unsigned char loop_filter_across_slices_enabled_flag
unsigned char wFrameTagFlags
unsigned char pcm_sample_bit_depth_luma_minus1
CUVIDH264MVCEXT mvcext
cudaVideoDeinterlaceMode DeinterlaceMode
cudaVideoDeinterlaceMode_XXX
unsigned char bit_depth_luma_minus8
signed char pps_cr_qp_offset
unsigned char log2_min_luma_coding_block_size_minus3
CUVIDH264PICPARAMS h264
unsigned char tcoeff_level_prediction_flag
cudaVideoCodec CodecType
cudaVideoCodec_XXX
unsigned char bit_depth_chroma_minus8
unsigned char modeRefLfEnabled
cudaVideoSurfaceFormat OutputFormat
cudaVideoSurfaceFormat_XXX
unsigned char constrained_intra_pred_flag
int ForwardRefIdx
Picture index of forward reference (P/B-frames)
int BackwardRefIdx
Picture index of backward reference (B-frames)
unsigned char AltRefIdx
tcu_ulong ulTargetWidth
Post-processed Output Width (Should be aligned to 2)
int PicIdx
picture index of reference frame
int intra_pic_flag
Set to 1 for I,BI frames.
unsigned char store_ref_base_pic_flag
signed char pic_init_qs_minus26
unsigned char num_inter_view_refs_l1
unsigned char pcm_loop_filter_disabled_flag
unsigned int first_partition_size
CUvideoctxlock vidLock
If non-NULL, context lock used for synchronizing ownership of the cuda context.
unsigned char log2_tile_columns
unsigned char num_ref_idx_l1_default_active_minus1
unsigned char slice_group_map_type
cudaVideoChromaFormat
unsigned char fmo_aso_enable
unsigned long long slice_group_map_addr
unsigned int frameTagSize
int bRefBaseLayer
whether to store ref base pic
unsigned int raw_output_pitch
Reserved for future use (set to zero)
unsigned char log2_parallel_merge_level_minus2
unsigned char LastRefIdx
Weave both fields (no deinterlacing)
int not_existing
non-existing reference frame (corresponding PicIdx should be set to -1)
int deblocking_filter_control_present_flag
unsigned char MVCReserved8Bits
int CurrPicIdx
Output index of the current picture.
unsigned char sample_adaptive_offset_enabled_flag
CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP)
unsigned char weighted_pred_flag
unsigned char colorSpace
unsigned char pcm_sample_bit_depth_chroma_minus1
Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-...
unsigned char long_term_ref_pics_present_flag
unsigned char extended_spatial_scalability_idc
unsigned char profile_idc
unsigned char transform_skip_enabled_flag
unsigned int nNumSlices
Number of slices in this picture.
int FrameHeightInMbs
Coded Frame Height.
unsigned short reserved16Bits
cudaVideoCreateFlags
unsigned char separate_colour_plane_flag
CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
unsigned char entropy_coding_sync_enabled_flag
unsigned char loopFilterLevel
int intra_pic_flag
This picture is entirely intra coded.
unsigned char bitDepthMinus8Chroma
int progressive_frame
Input is progressive (deinterlace_mode will be ignored)
unsigned char scaling_list_enable_flag
int FrameHeight
Actual frame height.
tcu_ulong ulCreationFlags
Decoder creation flags (cudaVideoCreateFlags_XXX)
int second_field
Output the second field (ignored if deinterlace mode is Weave)
unsigned int mcomp_filter_type
unsigned char log2_diff_max_min_pcm_luma_coding_block_size
Default operation mode: use dedicated video engines.
unsigned char num_tile_rows_minus1
unsigned int reserved_zero
Reserved (set to zero)
unsigned char IdrPicFlag
int ref_pic_flag
This picture is a reference picture.
signed char pps_beta_offset_div2
int top_field_first
Input frame is top field first (1st field is top, 2nd field is bottom)
int progressive_fcm
Progressive frame.
AVFormatContext * ctx
Definition: movenc.c:48
const unsigned int * pSliceDataOffsets
nNumSlices entries, contains offset of each slice within the bitstream data buffer ...
unsigned short DPBEntryValidFlag
int bottom_field_flag
0=top field, 1=bottom field (ignored if field_pic_flag=0)
unsigned char slice_header_restriction_flag
unsigned long long raw_output_dptr
Reserved for future use (set to zero)
unsigned char num_extra_slice_header_bits
unsigned char tiles_enabled_flag
short scaled_ref_layer_left_offset
unsigned char log2_min_pcm_luma_coding_block_size_minus3
unsigned char qpprime_y_zero_transform_bypass_flag
tcu_ulong ulNumDecodeSurfaces
Maximum number of internal decode surfaces.
unsigned char inter_layer_deblocking_filter_control_present_flag
CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
signed char inter_layer_slice_alpha_c0_offset_div2
CUVIDVC1PICPARAMS vc1
CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
CUVIDVP9PICPARAMS vp9
unsigned int resetFrameContext
CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck)
unsigned char slice_segment_header_extension_present_flag
unsigned char pps_deblocking_filter_disabled_flag
unsigned char Reserved8BitsA
unsigned char amp_enabled_flag
unsigned char sps_temporal_mvp_enabled_flag
const unsigned char * pBitstreamData
Ptr to bitstream data for this picture (slice-layer)
unsigned int slice_group_change_rate_minus1
unsigned char log2_tile_rows
unsigned char loopFilterSharpness
unsigned char lists_modification_present_flag
unsigned char log2_diff_max_min_transform_block_size
unsigned char Reserved8BitsB
CUVIDVP8PICPARAMS vp8
unsigned char num_inter_view_refs_l0
unsigned char level_idc
YUYV/YUY2 (4:2:2)
unsigned char DQIdMax
unsigned char max_transform_hierarchy_depth_inter
unsigned char pps_slice_chroma_qp_offsets_present_flag
tcu_ulong ulWidth
Coded Sequence Width.
mfxU16 profile
Definition: qsvenc.c:44
unsigned char num_slice_groups_minus1
CUVIDJPEGPICPARAMS jpeg
unsigned char output_flag_present_flag
signed char pps_cb_qp_offset
CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder)
CUVIDMPEG2PICPARAMS mpeg2
Also used for MPEG-1.
int used_for_reference
0=unused, 1=top_field, 2=bottom_field, 3=both_fields
unsigned char bit_depth_luma_minus8
signed char init_qp_minus26
unsigned char weighted_bipred_flag
unsigned int offsetToDctParts
unsigned char adaptive_tcoeff_level_prediction_flag
unsigned char chroma_phase_x_plus1_flag
CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
Go through DXVA internally if possible (requires D3D9 interop)
unsigned char transquant_bypass_enabled_flag
CUVIDMPEG4PICPARAMS mpeg4
unsigned char AltRefIdx
unsigned int reserved_flags
Reserved for future use (set to zero)
unsigned char log2_diff_max_min_luma_coding_block_size
tcu_ulong ulHeight
Coded Sequence Height.
unsigned char cabac_init_present_flag
unsigned char cu_qp_delta_enabled_flag
unsigned char max_transform_hierarchy_depth_intra
cudaVideoChromaFormat ChromaFormat
cudaVideoChromaFormat_XXX (only 4:2:0 is currently supported)
tcu_ulong ulTargetHeight
Post-processed Output Height (Should be aligbed to 2)
unsigned char GoldenRefIdx
unsigned char disable_inter_layer_deblocking_filter_idc
int second_field
Second field of a complementary field pair.
unsigned char sign_data_hiding_enabled_flag
cudaVideoCodec
unsigned char strong_intra_smoothing_enabled_flag
unsigned long long raw_input_dptr
Input CUdeviceptr for raw YUV extensions.
CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
CUVIDHEVCPICPARAMS hevc
cudaVideoDeinterlaceMode
unsigned char ref_layer_chroma_phase_y_plus1
int FrameWidth
Actual frame width.
unsigned int nBitstreamDataLen
Number of bytes in bitstream data buffer.
unsigned char DQId
unsigned char log2_min_transform_block_size_minus2
unsigned char ref_layer_chroma_phase_x_plus1_flag
unsigned char constrained_intra_resampling_flag
unsigned char num_short_term_ref_pic_sets
signed char inter_layer_slice_beta_offset_div2
unsigned int raw_input_pitch
pitch in bytes of raw YUV input (should be aligned appropriately)