2 * This copyright notice applies to this header file only:
4 * Copyright (c) 2010-2016 NVIDIA Corporation
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
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
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.
30 * NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
32 * This file contains constants, structure definitions and function prototypes used for decoding.
35 #if !defined(__CUDA_VIDEO_H__)
36 #define __CUDA_VIDEO_H__
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
44 #if defined(__cplusplus)
46 #endif /* __cplusplus */
48 typedef void *CUvideodecoder;
49 typedef struct _CUcontextlock_st *CUvideoctxlock;
52 * \addtogroup VIDEO_DECODER Video Decoder
57 * \enum cudaVideoCodec
60 typedef enum cudaVideoCodec_enum {
61 cudaVideoCodec_MPEG1=0, /**< MPEG1 */
62 cudaVideoCodec_MPEG2, /**< MPEG2 */
63 cudaVideoCodec_MPEG4, /**< MPEG4 */
64 cudaVideoCodec_VC1, /**< VC1 */
65 cudaVideoCodec_H264, /**< H264 */
66 cudaVideoCodec_JPEG, /**< JPEG */
67 cudaVideoCodec_H264_SVC, /**< H264-SVC */
68 cudaVideoCodec_H264_MVC, /**< H264-MVC */
69 cudaVideoCodec_HEVC, /**< HEVC */
70 cudaVideoCodec_VP8, /**< VP8 */
71 cudaVideoCodec_VP9, /**< VP9 */
72 cudaVideoCodec_NumCodecs, /**< Max COdecs */
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) */
82 * \enum cudaVideoSurfaceFormat
83 * Video Surface Formats Enums
85 typedef enum cudaVideoSurfaceFormat_enum {
86 cudaVideoSurfaceFormat_NV12=0, /**< NV12 */
87 cudaVideoSurfaceFormat_P016=1 /**< P016 */
88 } cudaVideoSurfaceFormat;
91 * \enum cudaVideoDeinterlaceMode
92 * Deinterlacing Modes Enums
94 typedef enum cudaVideoDeinterlaceMode_enum {
95 cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */
96 cudaVideoDeinterlaceMode_Bob, /**< Drop one field */
97 cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */
98 } cudaVideoDeinterlaceMode;
101 * \enum cudaVideoChromaFormat
102 * Chroma Formats Enums
104 typedef enum cudaVideoChromaFormat_enum {
105 cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */
106 cudaVideoChromaFormat_420, /**< 4:2:0 */
107 cudaVideoChromaFormat_422, /**< 4:2:2 */
108 cudaVideoChromaFormat_444 /**< 4:4:4 */
109 } cudaVideoChromaFormat;
112 * \enum cudaVideoCreateFlags
113 * Decoder Flags Enums
115 typedef enum cudaVideoCreateFlags_enum {
116 cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */
117 cudaVideoCreate_PreferCUDA = 0x01, /**< Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-threading) */
118 cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */
119 cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */
120 } cudaVideoCreateFlags;
123 * \struct CUVIDDECODECREATEINFO
124 * Struct used in create decoder
126 typedef struct _CUVIDDECODECREATEINFO
128 unsigned long ulWidth; /**< Coded Sequence Width */
129 unsigned long ulHeight; /**< Coded Sequence Height */
130 unsigned long ulNumDecodeSurfaces; /**< Maximum number of internal decode surfaces */
131 cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
132 cudaVideoChromaFormat ChromaFormat; /**< cudaVideoChromaFormat_XXX (only 4:2:0 is currently supported) */
133 unsigned long ulCreationFlags; /**< Decoder creation flags (cudaVideoCreateFlags_XXX) */
134 unsigned long bitDepthMinus8;
135 unsigned long Reserved1[4]; /**< Reserved for future use - set to zero */
137 * area of the frame that should be displayed
146 cudaVideoSurfaceFormat OutputFormat; /**< cudaVideoSurfaceFormat_XXX */
147 cudaVideoDeinterlaceMode DeinterlaceMode; /**< cudaVideoDeinterlaceMode_XXX */
148 unsigned long ulTargetWidth; /**< Post-processed Output Width (Should be aligned to 2) */
149 unsigned long ulTargetHeight; /**< Post-processed Output Height (Should be aligbed to 2) */
150 unsigned long ulNumOutputSurfaces; /**< Maximum number of output surfaces simultaneously mapped */
151 CUvideoctxlock vidLock; /**< If non-NULL, context lock used for synchronizing ownership of the cuda context */
153 * target rectangle in the output frame (for aspect ratio conversion)
154 * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
162 unsigned long Reserved2[5]; /**< Reserved for future use - set to zero */
163 } CUVIDDECODECREATEINFO;
166 * \struct CUVIDH264DPBENTRY
169 typedef struct _CUVIDH264DPBENTRY
171 int PicIdx; /**< picture index of reference frame */
172 int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */
173 int is_long_term; /**< 0=short term reference, 1=long term reference */
174 int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
175 int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */
176 int FieldOrderCnt[2]; /**< field order count of top and bottom fields */
180 * \struct CUVIDH264MVCEXT
181 * H.264 MVC Picture Parameters Ext
183 typedef struct _CUVIDH264MVCEXT
185 int num_views_minus1;
187 unsigned char inter_view_flag;
188 unsigned char num_inter_view_refs_l0;
189 unsigned char num_inter_view_refs_l1;
190 unsigned char MVCReserved8Bits;
191 int InterViewRefsL0[16];
192 int InterViewRefsL1[16];
196 * \struct CUVIDH264SVCEXT
197 * H.264 SVC Picture Parameters Ext
199 typedef struct _CUVIDH264SVCEXT
201 unsigned char profile_idc;
202 unsigned char level_idc;
204 unsigned char DQIdMax;
205 unsigned char disable_inter_layer_deblocking_filter_idc;
206 unsigned char ref_layer_chroma_phase_y_plus1;
207 signed char inter_layer_slice_alpha_c0_offset_div2;
208 signed char inter_layer_slice_beta_offset_div2;
210 unsigned short DPBEntryValidFlag;
211 unsigned char inter_layer_deblocking_filter_control_present_flag;
212 unsigned char extended_spatial_scalability_idc;
213 unsigned char adaptive_tcoeff_level_prediction_flag;
214 unsigned char slice_header_restriction_flag;
215 unsigned char chroma_phase_x_plus1_flag;
216 unsigned char chroma_phase_y_plus1;
218 unsigned char tcoeff_level_prediction_flag;
219 unsigned char constrained_intra_resampling_flag;
220 unsigned char ref_layer_chroma_phase_x_plus1_flag;
221 unsigned char store_ref_base_pic_flag;
222 unsigned char Reserved8BitsA;
223 unsigned char Reserved8BitsB;
224 // For the 4 scaled_ref_layer_XX fields below,
225 // if (extended_spatial_scalability_idc == 1), SPS field, G.7.3.2.1.4, add prefix "seq_"
226 // if (extended_spatial_scalability_idc == 2), SLH field, G.7.3.3.4,
227 short scaled_ref_layer_left_offset;
228 short scaled_ref_layer_top_offset;
229 short scaled_ref_layer_right_offset;
230 short scaled_ref_layer_bottom_offset;
231 unsigned short Reserved16Bits;
232 struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded. Linked list ends at the target layer. */
233 int bRefBaseLayer; /**< whether to store ref base pic */
237 * \struct CUVIDH264PICPARAMS
238 * H.264 Picture Parameters
240 typedef struct _CUVIDH264PICPARAMS
243 int log2_max_frame_num_minus4;
244 int pic_order_cnt_type;
245 int log2_max_pic_order_cnt_lsb_minus4;
246 int delta_pic_order_always_zero_flag;
247 int frame_mbs_only_flag;
248 int direct_8x8_inference_flag;
249 int num_ref_frames; // NOTE: shall meet level 4.1 restrictions
250 unsigned char residual_colour_transform_flag;
251 unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported)
252 unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)
253 unsigned char qpprime_y_zero_transform_bypass_flag;
255 int entropy_coding_mode_flag;
256 int pic_order_present_flag;
257 int num_ref_idx_l0_active_minus1;
258 int num_ref_idx_l1_active_minus1;
259 int weighted_pred_flag;
260 int weighted_bipred_idc;
261 int pic_init_qp_minus26;
262 int deblocking_filter_control_present_flag;
263 int redundant_pic_cnt_present_flag;
264 int transform_8x8_mode_flag;
266 int constrained_intra_pred_flag;
267 int chroma_qp_index_offset;
268 int second_chroma_qp_index_offset;
271 int CurrFieldOrderCnt[2];
273 CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB
274 // Quantization Matrices (raster-order)
275 unsigned char WeightScale4x4[6][16];
276 unsigned char WeightScale8x8[2][64];
278 unsigned char fmo_aso_enable;
279 unsigned char num_slice_groups_minus1;
280 unsigned char slice_group_map_type;
281 signed char pic_init_qs_minus26;
282 unsigned int slice_group_change_rate_minus1;
285 unsigned long long slice_group_map_addr;
286 const unsigned char *pMb2SliceGroupMap;
288 unsigned int Reserved[12];
292 CUVIDH264MVCEXT mvcext;
293 CUVIDH264SVCEXT svcext;
295 } CUVIDH264PICPARAMS;
299 * \struct CUVIDMPEG2PICPARAMS
300 * MPEG-2 Picture Parameters
302 typedef struct _CUVIDMPEG2PICPARAMS
304 int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
305 int BackwardRefIdx; // Picture index of backward reference (B-frames)
306 int picture_coding_type;
307 int full_pel_forward_vector;
308 int full_pel_backward_vector;
310 int intra_dc_precision;
311 int frame_pred_frame_dct;
312 int concealment_motion_vectors;
314 int intra_vlc_format;
317 // Quantization matrices (raster order)
318 unsigned char QuantMatrixIntra[64];
319 unsigned char QuantMatrixInter[64];
320 } CUVIDMPEG2PICPARAMS;
322 ////////////////////////////////////////////////////////////////////////////////////////////////
324 // MPEG-4 Picture Parameters
327 // MPEG-4 has VOP types instead of Picture types
334 * \struct CUVIDMPEG4PICPARAMS
335 * MPEG-4 Picture Parameters
337 typedef struct _CUVIDMPEG4PICPARAMS
339 int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
340 int BackwardRefIdx; // Picture index of backward reference (B-frames)
342 int video_object_layer_width;
343 int video_object_layer_height;
344 int vop_time_increment_bitcount;
346 int resync_marker_disable;
349 int short_video_header;
354 int vop_rounding_type;
355 int alternate_vertical_scan_flag;
357 int vop_fcode_forward;
358 int vop_fcode_backward;
361 // Quantization matrices (raster order)
362 unsigned char QuantMatrixIntra[64];
363 unsigned char QuantMatrixInter[64];
365 } CUVIDMPEG4PICPARAMS;
368 * \struct CUVIDVC1PICPARAMS
369 * VC1 Picture Parameters
371 typedef struct _CUVIDVC1PICPARAMS
373 int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */
374 int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */
375 int FrameWidth; /**< Actual frame width */
376 int FrameHeight; /**< Actual frame height */
378 int intra_pic_flag; /**< Set to 1 for I,BI frames */
379 int ref_pic_flag; /**< Set to 1 for I,P frames */
380 int progressive_fcm; /**< Progressive frame */
406 int range_mapuv_flag;
408 int rangeredfrm; // range reduction state
412 * \struct CUVIDJPEGPICPARAMS
413 * JPEG Picture Parameters
415 typedef struct _CUVIDJPEGPICPARAMS
418 } CUVIDJPEGPICPARAMS;
422 * \struct CUVIDHEVCPICPARAMS
423 * HEVC Picture Parameters
425 typedef struct _CUVIDHEVCPICPARAMS
428 int pic_width_in_luma_samples;
429 int pic_height_in_luma_samples;
430 unsigned char log2_min_luma_coding_block_size_minus3;
431 unsigned char log2_diff_max_min_luma_coding_block_size;
432 unsigned char log2_min_transform_block_size_minus2;
433 unsigned char log2_diff_max_min_transform_block_size;
434 unsigned char pcm_enabled_flag;
435 unsigned char log2_min_pcm_luma_coding_block_size_minus3;
436 unsigned char log2_diff_max_min_pcm_luma_coding_block_size;
437 unsigned char pcm_sample_bit_depth_luma_minus1;
439 unsigned char pcm_sample_bit_depth_chroma_minus1;
440 unsigned char pcm_loop_filter_disabled_flag;
441 unsigned char strong_intra_smoothing_enabled_flag;
442 unsigned char max_transform_hierarchy_depth_intra;
443 unsigned char max_transform_hierarchy_depth_inter;
444 unsigned char amp_enabled_flag;
445 unsigned char separate_colour_plane_flag;
446 unsigned char log2_max_pic_order_cnt_lsb_minus4;
448 unsigned char num_short_term_ref_pic_sets;
449 unsigned char long_term_ref_pics_present_flag;
450 unsigned char num_long_term_ref_pics_sps;
451 unsigned char sps_temporal_mvp_enabled_flag;
452 unsigned char sample_adaptive_offset_enabled_flag;
453 unsigned char scaling_list_enable_flag;
454 unsigned char IrapPicFlag;
455 unsigned char IdrPicFlag;
457 unsigned char bit_depth_luma_minus8;
458 unsigned char bit_depth_chroma_minus8;
459 unsigned char reserved1[14];
462 unsigned char dependent_slice_segments_enabled_flag;
463 unsigned char slice_segment_header_extension_present_flag;
464 unsigned char sign_data_hiding_enabled_flag;
465 unsigned char cu_qp_delta_enabled_flag;
466 unsigned char diff_cu_qp_delta_depth;
467 signed char init_qp_minus26;
468 signed char pps_cb_qp_offset;
469 signed char pps_cr_qp_offset;
471 unsigned char constrained_intra_pred_flag;
472 unsigned char weighted_pred_flag;
473 unsigned char weighted_bipred_flag;
474 unsigned char transform_skip_enabled_flag;
475 unsigned char transquant_bypass_enabled_flag;
476 unsigned char entropy_coding_sync_enabled_flag;
477 unsigned char log2_parallel_merge_level_minus2;
478 unsigned char num_extra_slice_header_bits;
480 unsigned char loop_filter_across_tiles_enabled_flag;
481 unsigned char loop_filter_across_slices_enabled_flag;
482 unsigned char output_flag_present_flag;
483 unsigned char num_ref_idx_l0_default_active_minus1;
484 unsigned char num_ref_idx_l1_default_active_minus1;
485 unsigned char lists_modification_present_flag;
486 unsigned char cabac_init_present_flag;
487 unsigned char pps_slice_chroma_qp_offsets_present_flag;
489 unsigned char deblocking_filter_override_enabled_flag;
490 unsigned char pps_deblocking_filter_disabled_flag;
491 signed char pps_beta_offset_div2;
492 signed char pps_tc_offset_div2;
493 unsigned char tiles_enabled_flag;
494 unsigned char uniform_spacing_flag;
495 unsigned char num_tile_columns_minus1;
496 unsigned char num_tile_rows_minus1;
498 unsigned short column_width_minus1[21];
499 unsigned short row_height_minus1[21];
500 unsigned int reserved3[15];
503 int NumBitsForShortTermRPSInSlice;
504 int NumDeltaPocsOfRefRpsIdx;
506 int NumPocStCurrBefore;
507 int NumPocStCurrAfter;
509 int CurrPicOrderCntVal;
510 int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference)
511 int PicOrderCntVal[16]; // [refpic]
512 unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference
513 unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
514 unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15)
515 unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15)
516 unsigned char RefPicSetInterLayer0[8];
517 unsigned char RefPicSetInterLayer1[8];
518 unsigned int reserved4[12];
520 // scaling lists (diag order)
521 unsigned char ScalingList4x4[6][16]; // [matrixId][i]
522 unsigned char ScalingList8x8[6][64]; // [matrixId][i]
523 unsigned char ScalingList16x16[6][64]; // [matrixId][i]
524 unsigned char ScalingList32x32[2][64]; // [matrixId][i]
525 unsigned char ScalingListDCCoeff16x16[6]; // [matrixId]
526 unsigned char ScalingListDCCoeff32x32[2]; // [matrixId]
527 } CUVIDHEVCPICPARAMS;
531 * \struct CUVIDVP8PICPARAMS
532 * VP8 Picture Parameters
534 typedef struct _CUVIDVP8PICPARAMS
538 unsigned int first_partition_size;
540 unsigned char LastRefIdx;
541 unsigned char GoldenRefIdx;
542 unsigned char AltRefIdx;
545 unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */
546 unsigned char version : 3;
547 unsigned char show_frame : 1;
548 unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */
549 unsigned char Reserved2Bits : 2;
551 unsigned char wFrameTagFlags;
553 unsigned char Reserved1[4];
554 unsigned int Reserved2[3];
558 * \struct CUVIDVP9PICPARAMS
559 * VP9 Picture Parameters
561 typedef struct _CUVIDVP9PICPARAMS
567 unsigned char LastRefIdx;
568 unsigned char GoldenRefIdx;
569 unsigned char AltRefIdx;
570 unsigned char colorSpace;
572 unsigned short profile : 3;
573 unsigned short frameContextIdx : 2;
574 unsigned short frameType : 1;
575 unsigned short showFrame : 1;
576 unsigned short errorResilient : 1;
577 unsigned short frameParallelDecoding : 1;
578 unsigned short subSamplingX : 1;
579 unsigned short subSamplingY : 1;
580 unsigned short intraOnly : 1;
581 unsigned short allow_high_precision_mv : 1;
582 unsigned short refreshEntropyProbs : 1;
583 unsigned short reserved2Bits : 2;
585 unsigned short reserved16Bits;
587 unsigned char refFrameSignBias[4];
589 unsigned char bitDepthMinus8Luma;
590 unsigned char bitDepthMinus8Chroma;
591 unsigned char loopFilterLevel;
592 unsigned char loopFilterSharpness;
594 unsigned char modeRefLfEnabled;
595 unsigned char log2_tile_columns;
596 unsigned char log2_tile_rows;
598 unsigned char segmentEnabled : 1;
599 unsigned char segmentMapUpdate : 1;
600 unsigned char segmentMapTemporalUpdate : 1;
601 unsigned char segmentFeatureMode : 1;
602 unsigned char reserved4Bits : 4;
605 unsigned char segmentFeatureEnable[8][4];
606 short segmentFeatureData[8][4];
607 unsigned char mb_segment_tree_probs[7];
608 unsigned char segment_pred_probs[3];
609 unsigned char reservedSegment16Bits[2];
616 unsigned int activeRefIdx[3];
617 unsigned int resetFrameContext;
618 unsigned int mcomp_filter_type;
619 unsigned int mbRefLfDelta[4];
620 unsigned int mbModeLfDelta[2];
621 unsigned int frameTagSize;
622 unsigned int offsetToDctParts;
623 unsigned int reserved128Bits[4];
629 * \struct CUVIDPICPARAMS
630 * Picture Parameters for Decoding
632 typedef struct _CUVIDPICPARAMS
634 int PicWidthInMbs; /**< Coded Frame Size */
635 int FrameHeightInMbs; /**< Coded Frame Height */
636 int CurrPicIdx; /**< Output index of the current picture */
637 int field_pic_flag; /**< 0=frame picture, 1=field picture */
638 int bottom_field_flag; /**< 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
639 int second_field; /**< Second field of a complementary field pair */
641 unsigned int nBitstreamDataLen; /**< Number of bytes in bitstream data buffer */
642 const unsigned char *pBitstreamData; /**< Ptr to bitstream data for this picture (slice-layer) */
643 unsigned int nNumSlices; /**< Number of slices in this picture */
644 const unsigned int *pSliceDataOffsets; /**< nNumSlices entries, contains offset of each slice within the bitstream data buffer */
645 int ref_pic_flag; /**< This picture is a reference picture */
646 int intra_pic_flag; /**< This picture is entirely intra coded */
647 unsigned int Reserved[30]; /**< Reserved for future use */
648 // Codec-specific data
650 CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */
651 CUVIDH264PICPARAMS h264;
652 CUVIDVC1PICPARAMS vc1;
653 CUVIDMPEG4PICPARAMS mpeg4;
654 CUVIDJPEGPICPARAMS jpeg;
655 CUVIDHEVCPICPARAMS hevc;
656 CUVIDVP8PICPARAMS vp8;
657 CUVIDVP9PICPARAMS vp9;
658 unsigned int CodecReserved[1024];
664 * \struct CUVIDPROCPARAMS
665 * Picture Parameters for Postprocessing
667 typedef struct _CUVIDPROCPARAMS
669 int progressive_frame; /**< Input is progressive (deinterlace_mode will be ignored) */
670 int second_field; /**< Output the second field (ignored if deinterlace mode is Weave) */
671 int top_field_first; /**< Input frame is top field first (1st field is top, 2nd field is bottom) */
672 int unpaired_field; /**< Input only contains one field (2nd field is invalid) */
673 // The fields below are used for raw YUV input
674 unsigned int reserved_flags; /**< Reserved for future use (set to zero) */
675 unsigned int reserved_zero; /**< Reserved (set to zero) */
676 unsigned long long raw_input_dptr; /**< Input CUdeviceptr for raw YUV extensions */
677 unsigned int raw_input_pitch; /**< pitch in bytes of raw YUV input (should be aligned appropriately) */
678 unsigned int raw_input_format; /**< Reserved for future use (set to zero) */
679 unsigned long long raw_output_dptr; /**< Reserved for future use (set to zero) */
680 unsigned int raw_output_pitch; /**< Reserved for future use (set to zero) */
681 unsigned int Reserved[48];
688 * In order to minimize decode latencies, there should be always at least 2 pictures in the decode
689 * queue at any time, in order to make sure that all decode engines are always busy.
692 * - cuvidCreateDecoder(...)
694 * - cuvidDecodePicture(N)
695 * - cuvidMapVideoFrame(N-4)
696 * - do some processing in cuda
697 * - cuvidUnmapVideoFrame(N-4)
698 * - cuvidDecodePicture(N+1)
699 * - cuvidMapVideoFrame(N-3)
701 * - cuvidDestroyDecoder(...)
704 * - When the cuda context is created from a D3D device, the D3D device must also be created
705 * with the D3DCREATE_MULTITHREADED flag.
706 * - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
707 * - cuVidDecodePicture may block the calling thread if there are too many pictures pending
708 * in the decode queue
712 * \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
713 * Create the decoder object
715 typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
718 * \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
719 * Destroy the decoder object
721 typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder);
724 * \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
725 * Decode a single picture (field or frame)
727 typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
730 #if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
732 * \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
733 * Post-process and map a video frame for use in cuda
735 typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
736 unsigned int *pDevPtr, unsigned int *pPitch,
737 CUVIDPROCPARAMS *pVPP);
740 * \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
741 * Unmap a previously mapped video frame
743 typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
746 #if defined(WIN64) || defined(_WIN64) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
748 * \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
751 typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
752 unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
755 * \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
756 * Unmap a previously mapped video frame
758 typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
760 #if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
761 #define tcuvidMapVideoFrame tcuvidMapVideoFrame64
762 #define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64
769 * Context-locking: to facilitate multi-threaded implementations, the following 4 functions
770 * provide a simple mutex-style host synchronization. If a non-NULL context is specified
771 * in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
772 * context before making any cuda calls.
773 * A multi-threaded application could create a lock associated with a context handle so that
774 * multiple threads can safely share the same cuda context:
775 * - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
776 * that can be passed to cuvidCtxLockCreate.
777 * - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
779 * NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
780 * decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
784 * \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
786 typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
789 * \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
791 typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck);
794 * \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
796 typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
799 * \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
801 typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
803 /** @} */ /* End VIDEO_DECODER */
805 #if defined(__cplusplus)
807 #endif /* __cplusplus */
809 #endif // __CUDA_VIDEO_H__