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