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 typedef void *CUvideodecoder; 49 typedef struct _CUcontextlock_st *CUvideoctxlock; 50 51 /** 52 * \addtogroup VIDEO_DECODER Video Decoder 53 * @{ 54 */ 55 56 /*! 57 * \enum cudaVideoCodec 58 * Video Codec Enums 59 */ 60 typedef enum cudaVideoCodec_enum { 61 cudaVideoCodec_MPEG1=0, /**< MPEG1 */ 62 cudaVideoCodec_MPEG2, /**< MPEG2 */ 63 cudaVideoCodec_MPEG4, /**< MPEG4 */ 64 cudaVideoCodec_VC1, /**< VC1 */ 65 cudaVideoCodec_H264, /**< H264 */ 66 cudaVideoCodec_JPEG, /**< JPEG */ 67 cudaVideoCodec_H264_SVC, /**< H264-SVC */ 68 cudaVideoCodec_H264_MVC, /**< H264-MVC */ 69 cudaVideoCodec_HEVC, /**< HEVC */ 70 cudaVideoCodec_VP8, /**< VP8 */ 71 cudaVideoCodec_VP9, /**< VP9 */ 72 cudaVideoCodec_NumCodecs, /**< Max COdecs */ 73 // Uncompressed YUV 74 cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), /**< Y,U,V (4:2:0) */ 75 cudaVideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,V,U (4:2:0) */ 76 cudaVideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,UV (4:2:0) */ 77 cudaVideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), /**< YUYV/YUY2 (4:2:2) */ 78 cudaVideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) /**< UYVY (4:2:2) */ 79 } cudaVideoCodec; 80 81 /*! 82 * \enum cudaVideoSurfaceFormat 83 * Video Surface Formats Enums 84 */ 85 typedef enum cudaVideoSurfaceFormat_enum { 86 cudaVideoSurfaceFormat_NV12=0, /**< NV12 */ 87 cudaVideoSurfaceFormat_P016=1 /**< P016 */ 88 } cudaVideoSurfaceFormat; 89 90 /*! 91 * \enum cudaVideoDeinterlaceMode 92 * Deinterlacing Modes Enums 93 */ 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; 99 100 /*! 101 * \enum cudaVideoChromaFormat 102 * Chroma Formats Enums 103 */ 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; 110 111 /*! 112 * \enum cudaVideoCreateFlags 113 * Decoder Flags Enums 114 */ 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; 121 122 /*! 123 * \struct CUVIDDECODECREATEINFO 124 * Struct used in create decoder 125 */ 126 typedef struct _CUVIDDECODECREATEINFO 127 { 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 */ 136 /** 137 * area of the frame that should be displayed 138 */ 139 struct { 140 short left; 141 short top; 142 short right; 143 short bottom; 144 } display_area; 145 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 */ 152 /** 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 155 */ 156 struct { 157 short left; 158 short top; 159 short right; 160 short bottom; 161 } target_rect; 162 unsigned long Reserved2[5]; /**< Reserved for future use - set to zero */ 163 } CUVIDDECODECREATEINFO; 164 165 /*! 166 * \struct CUVIDH264DPBENTRY 167 * H.264 DPB Entry 168 */ 169 typedef struct _CUVIDH264DPBENTRY 170 { 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 */ 177 } CUVIDH264DPBENTRY; 178 179 /*! 180 * \struct CUVIDH264MVCEXT 181 * H.264 MVC Picture Parameters Ext 182 */ 183 typedef struct _CUVIDH264MVCEXT 184 { 185 int num_views_minus1; 186 int view_id; 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]; 193 } CUVIDH264MVCEXT; 194 195 /*! 196 * \struct CUVIDH264SVCEXT 197 * H.264 SVC Picture Parameters Ext 198 */ 199 typedef struct _CUVIDH264SVCEXT 200 { 201 unsigned char profile_idc; 202 unsigned char level_idc; 203 unsigned char DQId; 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; 209 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; 217 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 */ 234 } CUVIDH264SVCEXT; 235 236 /*! 237 * \struct CUVIDH264PICPARAMS 238 * H.264 Picture Parameters 239 */ 240 typedef struct _CUVIDH264PICPARAMS 241 { 242 // SPS 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; 254 // PPS 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; 265 int MbaffFrameFlag; 266 int constrained_intra_pred_flag; 267 int chroma_qp_index_offset; 268 int second_chroma_qp_index_offset; 269 int ref_pic_flag; 270 int frame_num; 271 int CurrFieldOrderCnt[2]; 272 // DPB 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]; 277 // FMO/ASO 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; 283 union 284 { 285 unsigned long long slice_group_map_addr; 286 const unsigned char *pMb2SliceGroupMap; 287 } fmo; 288 unsigned int Reserved[12]; 289 // SVC/MVC 290 union 291 { 292 CUVIDH264MVCEXT mvcext; 293 CUVIDH264SVCEXT svcext; 294 } svcmvc; 295 } CUVIDH264PICPARAMS; 296 297 298 /*! 299 * \struct CUVIDMPEG2PICPARAMS 300 * MPEG-2 Picture Parameters 301 */ 302 typedef struct _CUVIDMPEG2PICPARAMS 303 { 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; 309 int f_code[2][2]; 310 int intra_dc_precision; 311 int frame_pred_frame_dct; 312 int concealment_motion_vectors; 313 int q_scale_type; 314 int intra_vlc_format; 315 int alternate_scan; 316 int top_field_first; 317 // Quantization matrices (raster order) 318 unsigned char QuantMatrixIntra[64]; 319 unsigned char QuantMatrixInter[64]; 320 } CUVIDMPEG2PICPARAMS; 321 322 //////////////////////////////////////////////////////////////////////////////////////////////// 323 // 324 // MPEG-4 Picture Parameters 325 // 326 327 // MPEG-4 has VOP types instead of Picture types 328 #define I_VOP 0 329 #define P_VOP 1 330 #define B_VOP 2 331 #define S_VOP 3 332 333 /*! 334 * \struct CUVIDMPEG4PICPARAMS 335 * MPEG-4 Picture Parameters 336 */ 337 typedef struct _CUVIDMPEG4PICPARAMS 338 { 339 int ForwardRefIdx; // Picture index of forward reference (P/B-frames) 340 int BackwardRefIdx; // Picture index of backward reference (B-frames) 341 // VOL 342 int video_object_layer_width; 343 int video_object_layer_height; 344 int vop_time_increment_bitcount; 345 int top_field_first; 346 int resync_marker_disable; 347 int quant_type; 348 int quarter_sample; 349 int short_video_header; 350 int divx_flags; 351 // VOP 352 int vop_coding_type; 353 int vop_coded; 354 int vop_rounding_type; 355 int alternate_vertical_scan_flag; 356 int interlaced; 357 int vop_fcode_forward; 358 int vop_fcode_backward; 359 int trd[2]; 360 int trb[2]; 361 // Quantization matrices (raster order) 362 unsigned char QuantMatrixIntra[64]; 363 unsigned char QuantMatrixInter[64]; 364 int gmc_enabled; 365 } CUVIDMPEG4PICPARAMS; 366 367 /*! 368 * \struct CUVIDVC1PICPARAMS 369 * VC1 Picture Parameters 370 */ 371 typedef struct _CUVIDVC1PICPARAMS 372 { 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 */ 377 // PICTURE 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 */ 381 // SEQUENCE 382 int profile; 383 int postprocflag; 384 int pulldown; 385 int interlace; 386 int tfcntrflag; 387 int finterpflag; 388 int psf; 389 int multires; 390 int syncmarker; 391 int rangered; 392 int maxbframes; 393 // ENTRYPOINT 394 int panscan_flag; 395 int refdist_flag; 396 int extended_mv; 397 int dquant; 398 int vstransform; 399 int loopfilter; 400 int fastuvmc; 401 int overlap; 402 int quantizer; 403 int extended_dmv; 404 int range_mapy_flag; 405 int range_mapy; 406 int range_mapuv_flag; 407 int range_mapuv; 408 int rangeredfrm; // range reduction state 409 } CUVIDVC1PICPARAMS; 410 411 /*! 412 * \struct CUVIDJPEGPICPARAMS 413 * JPEG Picture Parameters 414 */ 415 typedef struct _CUVIDJPEGPICPARAMS 416 { 417 int Reserved; 418 } CUVIDJPEGPICPARAMS; 419 420 421 /*! 422 * \struct CUVIDHEVCPICPARAMS 423 * HEVC Picture Parameters 424 */ 425 typedef struct _CUVIDHEVCPICPARAMS 426 { 427 // sps 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; 438 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; 447 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; 456 457 unsigned char bit_depth_luma_minus8; 458 unsigned char bit_depth_chroma_minus8; 459 unsigned char reserved1[14]; 460 461 // pps 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; 470 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; 479 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; 488 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; 497 498 unsigned short column_width_minus1[21]; 499 unsigned short row_height_minus1[21]; 500 unsigned int reserved3[15]; 501 502 // RefPicSets 503 int NumBitsForShortTermRPSInSlice; 504 int NumDeltaPocsOfRefRpsIdx; 505 int NumPocTotalCurr; 506 int NumPocStCurrBefore; 507 int NumPocStCurrAfter; 508 int NumPocLtCurr; 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]; 519 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; 528 529 530 /*! 531 * \struct CUVIDVP8PICPARAMS 532 * VP8 Picture Parameters 533 */ 534 typedef struct _CUVIDVP8PICPARAMS 535 { 536 int width; 537 int height; 538 unsigned int first_partition_size; 539 //Frame Indexes 540 unsigned char LastRefIdx; 541 unsigned char GoldenRefIdx; 542 unsigned char AltRefIdx; 543 union { 544 struct { 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; 550 }; 551 unsigned char wFrameTagFlags; 552 } tagflags; 553 unsigned char Reserved1[4]; 554 unsigned int Reserved2[3]; 555 } CUVIDVP8PICPARAMS; 556 557 /*! 558 * \struct CUVIDVP9PICPARAMS 559 * VP9 Picture Parameters 560 */ 561 typedef struct _CUVIDVP9PICPARAMS 562 { 563 unsigned int width; 564 unsigned int height; 565 566 //Frame Indices 567 unsigned char LastRefIdx; 568 unsigned char GoldenRefIdx; 569 unsigned char AltRefIdx; 570 unsigned char colorSpace; 571 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; 584 585 unsigned short reserved16Bits; 586 587 unsigned char refFrameSignBias[4]; 588 589 unsigned char bitDepthMinus8Luma; 590 unsigned char bitDepthMinus8Chroma; 591 unsigned char loopFilterLevel; 592 unsigned char loopFilterSharpness; 593 594 unsigned char modeRefLfEnabled; 595 unsigned char log2_tile_columns; 596 unsigned char log2_tile_rows; 597 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; 603 604 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]; 610 611 int qpYAc; 612 int qpYDc; 613 int qpChDc; 614 int qpChAc; 615 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]; 624 625 } CUVIDVP9PICPARAMS; 626 627 628 /*! 629 * \struct CUVIDPICPARAMS 630 * Picture Parameters for Decoding 631 */ 632 typedef struct _CUVIDPICPARAMS 633 { 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 */ 640 // Bitstream data 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 649 union { 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]; 659 } CodecSpecific; 660 } CUVIDPICPARAMS; 661 662 663 /*! 664 * \struct CUVIDPROCPARAMS 665 * Picture Parameters for Postprocessing 666 */ 667 typedef struct _CUVIDPROCPARAMS 668 { 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]; 682 void *Reserved3[3]; 683 } CUVIDPROCPARAMS; 684 685 686 /** 687 * 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. 690 * 691 * Overall data flow: 692 * - cuvidCreateDecoder(...) 693 * For each picture: 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) 700 * ... 701 * - cuvidDestroyDecoder(...) 702 * 703 * NOTE: 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 709 */ 710 711 /** 712 * 713 * Context-locking: to facilitate multi-threaded implementations, the following 4 functions 714 * provide a simple mutex-style host synchronization. If a non-NULL context is specified 715 * in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given 716 * context before making any cuda calls. 717 * A multi-threaded application could create a lock associated with a context handle so that 718 * multiple threads can safely share the same cuda context: 719 * - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context 720 * that can be passed to cuvidCtxLockCreate. 721 * - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section. 722 * 723 * NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video 724 * decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls). 725 */ 726 /** @} */ /* End VIDEO_DECODER */ 727 728 #if defined(__cplusplus) 729 } 730 #endif /* __cplusplus */ 731 732 #endif // __CUDA_VIDEO_H__ 733