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 (currently the only supported output format) */
87 } cudaVideoSurfaceFormat;
90 * \enum cudaVideoDeinterlaceMode
91 * Deinterlacing Modes Enums
93 typedef enum cudaVideoDeinterlaceMode_enum {
94 cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */
95 cudaVideoDeinterlaceMode_Bob, /**< Drop one field */
96 cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */
97 } cudaVideoDeinterlaceMode;
100 * \enum cudaVideoChromaFormat
101 * Chroma Formats Enums
103 typedef enum cudaVideoChromaFormat_enum {
104 cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */
105 cudaVideoChromaFormat_420, /**< 4:2:0 */
106 cudaVideoChromaFormat_422, /**< 4:2:2 */
107 cudaVideoChromaFormat_444 /**< 4:4:4 */
108 } cudaVideoChromaFormat;
111 * \enum cudaVideoCreateFlags
112 * Decoder Flags Enums
114 typedef enum cudaVideoCreateFlags_enum {
115 cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */
116 cudaVideoCreate_PreferCUDA = 0x01, /**< Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-threading) */
117 cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */
118 cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */
119 } cudaVideoCreateFlags;
122 * \struct CUVIDDECODECREATEINFO
123 * Struct used in create decoder
125 typedef struct _CUVIDDECODECREATEINFO
127 unsigned long ulWidth; /**< Coded Sequence Width */
128 unsigned long ulHeight; /**< Coded Sequence Height */
129 unsigned long ulNumDecodeSurfaces; /**< Maximum number of internal decode surfaces */
130 cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
131 cudaVideoChromaFormat ChromaFormat; /**< cudaVideoChromaFormat_XXX (only 4:2:0 is currently supported) */
132 unsigned long ulCreationFlags; /**< Decoder creation flags (cudaVideoCreateFlags_XXX) */
133 unsigned long bitDepthMinus8;
134 unsigned long Reserved1[4]; /**< Reserved for future use - set to zero */
136 * area of the frame that should be displayed
145 cudaVideoSurfaceFormat OutputFormat; /**< cudaVideoSurfaceFormat_XXX */
146 cudaVideoDeinterlaceMode DeinterlaceMode; /**< cudaVideoDeinterlaceMode_XXX */
147 unsigned long ulTargetWidth; /**< Post-processed Output Width (Should be aligned to 2) */
148 unsigned long ulTargetHeight; /**< Post-processed Output Height (Should be aligbed to 2) */
149 unsigned long ulNumOutputSurfaces; /**< Maximum number of output surfaces simultaneously mapped */
150 CUvideoctxlock vidLock; /**< If non-NULL, context lock used for synchronizing ownership of the cuda context */
152 * target rectangle in the output frame (for aspect ratio conversion)
153 * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
161 unsigned long Reserved2[5]; /**< Reserved for future use - set to zero */
162 } CUVIDDECODECREATEINFO;
165 * \struct CUVIDH264DPBENTRY
168 typedef struct _CUVIDH264DPBENTRY
170 int PicIdx; /**< picture index of reference frame */
171 int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */
172 int is_long_term; /**< 0=short term reference, 1=long term reference */
173 int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
174 int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */
175 int FieldOrderCnt[2]; /**< field order count of top and bottom fields */
179 * \struct CUVIDH264MVCEXT
180 * H.264 MVC Picture Parameters Ext
182 typedef struct _CUVIDH264MVCEXT
184 int num_views_minus1;
186 unsigned char inter_view_flag;
187 unsigned char num_inter_view_refs_l0;
188 unsigned char num_inter_view_refs_l1;
189 unsigned char MVCReserved8Bits;
190 int InterViewRefsL0[16];
191 int InterViewRefsL1[16];
195 * \struct CUVIDH264SVCEXT
196 * H.264 SVC Picture Parameters Ext
198 typedef struct _CUVIDH264SVCEXT
200 unsigned char profile_idc;
201 unsigned char level_idc;
203 unsigned char DQIdMax;
204 unsigned char disable_inter_layer_deblocking_filter_idc;
205 unsigned char ref_layer_chroma_phase_y_plus1;
206 signed char inter_layer_slice_alpha_c0_offset_div2;
207 signed char inter_layer_slice_beta_offset_div2;
209 unsigned short DPBEntryValidFlag;
210 unsigned char inter_layer_deblocking_filter_control_present_flag;
211 unsigned char extended_spatial_scalability_idc;
212 unsigned char adaptive_tcoeff_level_prediction_flag;
213 unsigned char slice_header_restriction_flag;
214 unsigned char chroma_phase_x_plus1_flag;
215 unsigned char chroma_phase_y_plus1;
217 unsigned char tcoeff_level_prediction_flag;
218 unsigned char constrained_intra_resampling_flag;
219 unsigned char ref_layer_chroma_phase_x_plus1_flag;
220 unsigned char store_ref_base_pic_flag;
221 unsigned char Reserved8BitsA;
222 unsigned char Reserved8BitsB;
223 // For the 4 scaled_ref_layer_XX fields below,
224 // if (extended_spatial_scalability_idc == 1), SPS field, G.7.3.2.1.4, add prefix "seq_"
225 // if (extended_spatial_scalability_idc == 2), SLH field, G.7.3.3.4,
226 short scaled_ref_layer_left_offset;
227 short scaled_ref_layer_top_offset;
228 short scaled_ref_layer_right_offset;
229 short scaled_ref_layer_bottom_offset;
230 unsigned short Reserved16Bits;
231 struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded. Linked list ends at the target layer. */
232 int bRefBaseLayer; /**< whether to store ref base pic */
236 * \struct CUVIDH264PICPARAMS
237 * H.264 Picture Parameters
239 typedef struct _CUVIDH264PICPARAMS
242 int log2_max_frame_num_minus4;
243 int pic_order_cnt_type;
244 int log2_max_pic_order_cnt_lsb_minus4;
245 int delta_pic_order_always_zero_flag;
246 int frame_mbs_only_flag;
247 int direct_8x8_inference_flag;
248 int num_ref_frames; // NOTE: shall meet level 4.1 restrictions
249 unsigned char residual_colour_transform_flag;
250 unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported)
251 unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)
252 unsigned char qpprime_y_zero_transform_bypass_flag;
254 int entropy_coding_mode_flag;
255 int pic_order_present_flag;
256 int num_ref_idx_l0_active_minus1;
257 int num_ref_idx_l1_active_minus1;
258 int weighted_pred_flag;
259 int weighted_bipred_idc;
260 int pic_init_qp_minus26;
261 int deblocking_filter_control_present_flag;
262 int redundant_pic_cnt_present_flag;
263 int transform_8x8_mode_flag;
265 int constrained_intra_pred_flag;
266 int chroma_qp_index_offset;
267 int second_chroma_qp_index_offset;
270 int CurrFieldOrderCnt[2];
272 CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB
273 // Quantization Matrices (raster-order)
274 unsigned char WeightScale4x4[6][16];
275 unsigned char WeightScale8x8[2][64];
277 unsigned char fmo_aso_enable;
278 unsigned char num_slice_groups_minus1;
279 unsigned char slice_group_map_type;
280 signed char pic_init_qs_minus26;
281 unsigned int slice_group_change_rate_minus1;
284 unsigned long long slice_group_map_addr;
285 const unsigned char *pMb2SliceGroupMap;
287 unsigned int Reserved[12];
291 CUVIDH264MVCEXT mvcext;
292 CUVIDH264SVCEXT svcext;
294 } CUVIDH264PICPARAMS;
298 * \struct CUVIDMPEG2PICPARAMS
299 * MPEG-2 Picture Parameters
301 typedef struct _CUVIDMPEG2PICPARAMS
303 int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
304 int BackwardRefIdx; // Picture index of backward reference (B-frames)
305 int picture_coding_type;
306 int full_pel_forward_vector;
307 int full_pel_backward_vector;
309 int intra_dc_precision;
310 int frame_pred_frame_dct;
311 int concealment_motion_vectors;
313 int intra_vlc_format;
316 // Quantization matrices (raster order)
317 unsigned char QuantMatrixIntra[64];
318 unsigned char QuantMatrixInter[64];
319 } CUVIDMPEG2PICPARAMS;
321 ////////////////////////////////////////////////////////////////////////////////////////////////
323 // MPEG-4 Picture Parameters
326 // MPEG-4 has VOP types instead of Picture types
333 * \struct CUVIDMPEG4PICPARAMS
334 * MPEG-4 Picture Parameters
336 typedef struct _CUVIDMPEG4PICPARAMS
338 int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
339 int BackwardRefIdx; // Picture index of backward reference (B-frames)
341 int video_object_layer_width;
342 int video_object_layer_height;
343 int vop_time_increment_bitcount;
345 int resync_marker_disable;
348 int short_video_header;
353 int vop_rounding_type;
354 int alternate_vertical_scan_flag;
356 int vop_fcode_forward;
357 int vop_fcode_backward;
360 // Quantization matrices (raster order)
361 unsigned char QuantMatrixIntra[64];
362 unsigned char QuantMatrixInter[64];
364 } CUVIDMPEG4PICPARAMS;
367 * \struct CUVIDVC1PICPARAMS
368 * VC1 Picture Parameters
370 typedef struct _CUVIDVC1PICPARAMS
372 int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */
373 int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */
374 int FrameWidth; /**< Actual frame width */
375 int FrameHeight; /**< Actual frame height */
377 int intra_pic_flag; /**< Set to 1 for I,BI frames */
378 int ref_pic_flag; /**< Set to 1 for I,P frames */
379 int progressive_fcm; /**< Progressive frame */
405 int range_mapuv_flag;
407 int rangeredfrm; // range reduction state
411 * \struct CUVIDJPEGPICPARAMS
412 * JPEG Picture Parameters
414 typedef struct _CUVIDJPEGPICPARAMS
417 } CUVIDJPEGPICPARAMS;
421 * \struct CUVIDHEVCPICPARAMS
422 * HEVC Picture Parameters
424 typedef struct _CUVIDHEVCPICPARAMS
427 int pic_width_in_luma_samples;
428 int pic_height_in_luma_samples;
429 unsigned char log2_min_luma_coding_block_size_minus3;
430 unsigned char log2_diff_max_min_luma_coding_block_size;
431 unsigned char log2_min_transform_block_size_minus2;
432 unsigned char log2_diff_max_min_transform_block_size;
433 unsigned char pcm_enabled_flag;
434 unsigned char log2_min_pcm_luma_coding_block_size_minus3;
435 unsigned char log2_diff_max_min_pcm_luma_coding_block_size;
436 unsigned char pcm_sample_bit_depth_luma_minus1;
438 unsigned char pcm_sample_bit_depth_chroma_minus1;
439 unsigned char pcm_loop_filter_disabled_flag;
440 unsigned char strong_intra_smoothing_enabled_flag;
441 unsigned char max_transform_hierarchy_depth_intra;
442 unsigned char max_transform_hierarchy_depth_inter;
443 unsigned char amp_enabled_flag;
444 unsigned char separate_colour_plane_flag;
445 unsigned char log2_max_pic_order_cnt_lsb_minus4;
447 unsigned char num_short_term_ref_pic_sets;
448 unsigned char long_term_ref_pics_present_flag;
449 unsigned char num_long_term_ref_pics_sps;
450 unsigned char sps_temporal_mvp_enabled_flag;
451 unsigned char sample_adaptive_offset_enabled_flag;
452 unsigned char scaling_list_enable_flag;
453 unsigned char IrapPicFlag;
454 unsigned char IdrPicFlag;
456 unsigned char bit_depth_luma_minus8;
457 unsigned char bit_depth_chroma_minus8;
458 unsigned char reserved1[14];
461 unsigned char dependent_slice_segments_enabled_flag;
462 unsigned char slice_segment_header_extension_present_flag;
463 unsigned char sign_data_hiding_enabled_flag;
464 unsigned char cu_qp_delta_enabled_flag;
465 unsigned char diff_cu_qp_delta_depth;
466 signed char init_qp_minus26;
467 signed char pps_cb_qp_offset;
468 signed char pps_cr_qp_offset;
470 unsigned char constrained_intra_pred_flag;
471 unsigned char weighted_pred_flag;
472 unsigned char weighted_bipred_flag;
473 unsigned char transform_skip_enabled_flag;
474 unsigned char transquant_bypass_enabled_flag;
475 unsigned char entropy_coding_sync_enabled_flag;
476 unsigned char log2_parallel_merge_level_minus2;
477 unsigned char num_extra_slice_header_bits;
479 unsigned char loop_filter_across_tiles_enabled_flag;
480 unsigned char loop_filter_across_slices_enabled_flag;
481 unsigned char output_flag_present_flag;
482 unsigned char num_ref_idx_l0_default_active_minus1;
483 unsigned char num_ref_idx_l1_default_active_minus1;
484 unsigned char lists_modification_present_flag;
485 unsigned char cabac_init_present_flag;
486 unsigned char pps_slice_chroma_qp_offsets_present_flag;
488 unsigned char deblocking_filter_override_enabled_flag;
489 unsigned char pps_deblocking_filter_disabled_flag;
490 signed char pps_beta_offset_div2;
491 signed char pps_tc_offset_div2;
492 unsigned char tiles_enabled_flag;
493 unsigned char uniform_spacing_flag;
494 unsigned char num_tile_columns_minus1;
495 unsigned char num_tile_rows_minus1;
497 unsigned short column_width_minus1[21];
498 unsigned short row_height_minus1[21];
499 unsigned int reserved3[15];
502 int NumBitsForShortTermRPSInSlice;
503 int NumDeltaPocsOfRefRpsIdx;
505 int NumPocStCurrBefore;
506 int NumPocStCurrAfter;
508 int CurrPicOrderCntVal;
509 int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference)
510 int PicOrderCntVal[16]; // [refpic]
511 unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference
512 unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
513 unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15)
514 unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15)
515 unsigned char RefPicSetInterLayer0[8];
516 unsigned char RefPicSetInterLayer1[8];
517 unsigned int reserved4[12];
519 // scaling lists (diag order)
520 unsigned char ScalingList4x4[6][16]; // [matrixId][i]
521 unsigned char ScalingList8x8[6][64]; // [matrixId][i]
522 unsigned char ScalingList16x16[6][64]; // [matrixId][i]
523 unsigned char ScalingList32x32[2][64]; // [matrixId][i]
524 unsigned char ScalingListDCCoeff16x16[6]; // [matrixId]
525 unsigned char ScalingListDCCoeff32x32[2]; // [matrixId]
526 } CUVIDHEVCPICPARAMS;
530 * \struct CUVIDVP8PICPARAMS
531 * VP8 Picture Parameters
533 typedef struct _CUVIDVP8PICPARAMS
537 unsigned int first_partition_size;
539 unsigned char LastRefIdx;
540 unsigned char GoldenRefIdx;
541 unsigned char AltRefIdx;
544 unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */
545 unsigned char version : 3;
546 unsigned char show_frame : 1;
547 unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */
548 unsigned char Reserved2Bits : 2;
550 unsigned char wFrameTagFlags;
552 unsigned char Reserved1[4];
553 unsigned int Reserved2[3];
557 * \struct CUVIDVP9PICPARAMS
558 * VP9 Picture Parameters
560 typedef struct _CUVIDVP9PICPARAMS
566 unsigned char LastRefIdx;
567 unsigned char GoldenRefIdx;
568 unsigned char AltRefIdx;
569 unsigned char colorSpace;
571 unsigned short profile : 3;
572 unsigned short frameContextIdx : 2;
573 unsigned short frameType : 1;
574 unsigned short showFrame : 1;
575 unsigned short errorResilient : 1;
576 unsigned short frameParallelDecoding : 1;
577 unsigned short subSamplingX : 1;
578 unsigned short subSamplingY : 1;
579 unsigned short intraOnly : 1;
580 unsigned short allow_high_precision_mv : 1;
581 unsigned short refreshEntropyProbs : 1;
582 unsigned short reserved2Bits : 2;
584 unsigned short reserved16Bits;
586 unsigned char refFrameSignBias[4];
588 unsigned char bitDepthMinus8Luma;
589 unsigned char bitDepthMinus8Chroma;
590 unsigned char loopFilterLevel;
591 unsigned char loopFilterSharpness;
593 unsigned char modeRefLfEnabled;
594 unsigned char log2_tile_columns;
595 unsigned char log2_tile_rows;
597 unsigned char segmentEnabled : 1;
598 unsigned char segmentMapUpdate : 1;
599 unsigned char segmentMapTemporalUpdate : 1;
600 unsigned char segmentFeatureMode : 1;
601 unsigned char reserved4Bits : 4;
604 unsigned char segmentFeatureEnable[8][4];
605 short segmentFeatureData[8][4];
606 unsigned char mb_segment_tree_probs[7];
607 unsigned char segment_pred_probs[3];
608 unsigned char reservedSegment16Bits[2];
615 unsigned int activeRefIdx[3];
616 unsigned int resetFrameContext;
617 unsigned int mcomp_filter_type;
618 unsigned int mbRefLfDelta[4];
619 unsigned int mbModeLfDelta[2];
620 unsigned int frameTagSize;
621 unsigned int offsetToDctParts;
622 unsigned int reserved128Bits[4];
628 * \struct CUVIDPICPARAMS
629 * Picture Parameters for Decoding
631 typedef struct _CUVIDPICPARAMS
633 int PicWidthInMbs; /**< Coded Frame Size */
634 int FrameHeightInMbs; /**< Coded Frame Height */
635 int CurrPicIdx; /**< Output index of the current picture */
636 int field_pic_flag; /**< 0=frame picture, 1=field picture */
637 int bottom_field_flag; /**< 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
638 int second_field; /**< Second field of a complementary field pair */
640 unsigned int nBitstreamDataLen; /**< Number of bytes in bitstream data buffer */
641 const unsigned char *pBitstreamData; /**< Ptr to bitstream data for this picture (slice-layer) */
642 unsigned int nNumSlices; /**< Number of slices in this picture */
643 const unsigned int *pSliceDataOffsets; /**< nNumSlices entries, contains offset of each slice within the bitstream data buffer */
644 int ref_pic_flag; /**< This picture is a reference picture */
645 int intra_pic_flag; /**< This picture is entirely intra coded */
646 unsigned int Reserved[30]; /**< Reserved for future use */
647 // Codec-specific data
649 CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */
650 CUVIDH264PICPARAMS h264;
651 CUVIDVC1PICPARAMS vc1;
652 CUVIDMPEG4PICPARAMS mpeg4;
653 CUVIDJPEGPICPARAMS jpeg;
654 CUVIDHEVCPICPARAMS hevc;
655 CUVIDVP8PICPARAMS vp8;
656 CUVIDVP9PICPARAMS vp9;
657 unsigned int CodecReserved[1024];
663 * \struct CUVIDPROCPARAMS
664 * Picture Parameters for Postprocessing
666 typedef struct _CUVIDPROCPARAMS
668 int progressive_frame; /**< Input is progressive (deinterlace_mode will be ignored) */
669 int second_field; /**< Output the second field (ignored if deinterlace mode is Weave) */
670 int top_field_first; /**< Input frame is top field first (1st field is top, 2nd field is bottom) */
671 int unpaired_field; /**< Input only contains one field (2nd field is invalid) */
672 // The fields below are used for raw YUV input
673 unsigned int reserved_flags; /**< Reserved for future use (set to zero) */
674 unsigned int reserved_zero; /**< Reserved (set to zero) */
675 unsigned long long raw_input_dptr; /**< Input CUdeviceptr for raw YUV extensions */
676 unsigned int raw_input_pitch; /**< pitch in bytes of raw YUV input (should be aligned appropriately) */
677 unsigned int raw_input_format; /**< Reserved for future use (set to zero) */
678 unsigned long long raw_output_dptr; /**< Reserved for future use (set to zero) */
679 unsigned int raw_output_pitch; /**< Reserved for future use (set to zero) */
680 unsigned int Reserved[48];
687 * In order to minimize decode latencies, there should be always at least 2 pictures in the decode
688 * queue at any time, in order to make sure that all decode engines are always busy.
691 * - cuvidCreateDecoder(...)
693 * - cuvidDecodePicture(N)
694 * - cuvidMapVideoFrame(N-4)
695 * - do some processing in cuda
696 * - cuvidUnmapVideoFrame(N-4)
697 * - cuvidDecodePicture(N+1)
698 * - cuvidMapVideoFrame(N-3)
700 * - cuvidDestroyDecoder(...)
703 * - When the cuda context is created from a D3D device, the D3D device must also be created
704 * with the D3DCREATE_MULTITHREADED flag.
705 * - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
706 * - cuVidDecodePicture may block the calling thread if there are too many pictures pending
707 * in the decode queue
711 * \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
712 * Create the decoder object
714 typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
717 * \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
718 * Destroy the decoder object
720 typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder);
723 * \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
724 * Decode a single picture (field or frame)
726 typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
729 #if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
731 * \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
732 * Post-process and map a video frame for use in cuda
734 typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
735 unsigned int *pDevPtr, unsigned int *pPitch,
736 CUVIDPROCPARAMS *pVPP);
739 * \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
740 * Unmap a previously mapped video frame
742 typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
745 #if defined(WIN64) || defined(_WIN64) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
747 * \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
750 typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
751 unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
754 * \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
755 * Unmap a previously mapped video frame
757 typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
759 #if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
760 #define tcuvidMapVideoFrame tcuvidMapVideoFrame64
761 #define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64
768 * Context-locking: to facilitate multi-threaded implementations, the following 4 functions
769 * provide a simple mutex-style host synchronization. If a non-NULL context is specified
770 * in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
771 * context before making any cuda calls.
772 * A multi-threaded application could create a lock associated with a context handle so that
773 * multiple threads can safely share the same cuda context:
774 * - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
775 * that can be passed to cuvidCtxLockCreate.
776 * - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
778 * NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
779 * decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
783 * \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
785 typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
788 * \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
790 typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck);
793 * \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
795 typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
798 * \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
800 typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
802 /** @} */ /* End VIDEO_DECODER */
804 #if defined(__cplusplus)
806 #endif /* __cplusplus */
808 #endif // __CUDA_VIDEO_H__