Skip to content

Commit

Permalink
Update SDK version
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliamVadocz committed May 29, 2023
1 parent c4d0d18 commit e88fb70
Show file tree
Hide file tree
Showing 9 changed files with 4,727 additions and 3,979 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NVIDIA Video Codec SDK Rust

Rust bindings for NVIDIA Video Codec SDK 12.0.16.
Rust bindings for NVIDIA Video Codec SDK 12.1.14.
CUDA version 12.1.
12 changes: 12 additions & 0 deletions src/safe/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::sys::nvEncodeAPI::{
NV_ENC_INPUT_PTR,
NV_ENC_LOCK_BITSTREAM,
NV_ENC_LOCK_INPUT_BUFFER,
NV_ENC_LOOKAHEAD_PIC_PARAMS,
NV_ENC_MAP_INPUT_RESOURCE,
NV_ENC_MEONLY_PARAMS,
NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS,
Expand All @@ -31,6 +32,7 @@ use crate::sys::nvEncodeAPI::{
NV_ENC_RECONFIGURE_PARAMS,
NV_ENC_REGISTERED_PTR,
NV_ENC_REGISTER_RESOURCE,
NV_ENC_RESTORE_ENCODER_STATE_PARAMS,
NV_ENC_SEQUENCE_PARAM_PAYLOAD,
NV_ENC_STAT,
NV_ENC_TUNING_INFO,
Expand Down Expand Up @@ -121,6 +123,10 @@ type GetSequenceParamEx = unsafe extern "C" fn(
*mut NV_ENC_INITIALIZE_PARAMS,
*mut NV_ENC_SEQUENCE_PARAM_PAYLOAD,
) -> NVENCSTATUS;
type RestoreEncoderState =
unsafe extern "C" fn(*mut c_void, *mut NV_ENC_RESTORE_ENCODER_STATE_PARAMS) -> NVENCSTATUS;
type LookaheadPicture =
unsafe extern "C" fn(*mut c_void, *mut NV_ENC_LOOKAHEAD_PIC_PARAMS) -> NVENCSTATUS;

/// An instance of the `NvEncodeAPI` interface, containing function pointers
/// which should be used to interface with the rest of the Encoder API.
Expand Down Expand Up @@ -207,6 +213,10 @@ pub struct EncodeAPI {
pub get_last_error_string: GetLastErrorString,
#[doc(alias = "NvEncSetIOCudaStreams")]
pub set_io_cuda_streams: SetIOCudaStreams,
#[doc(alias = "NvEncRestoreEncoderState")]
pub restore_encoder_state: RestoreEncoderState,
#[doc(alias = "NvEncLookaheadPicture")]
pub lookahead_picture: LookaheadPicture,
}

fn assert_versions_match(max_supported_version: u32) {
Expand Down Expand Up @@ -281,6 +291,8 @@ impl EncodeAPI {
run_motion_estimation_only: function_list.nvEncRunMotionEstimationOnly.expect(MSG),
get_last_error_string: function_list.nvEncGetLastErrorString.expect(MSG),
set_io_cuda_streams: function_list.nvEncSetIOCudaStreams.expect(MSG),
restore_encoder_state: function_list.nvEncRestoreEncoderState.expect(MSG),
lookahead_picture: function_list.nvEncLookaheadPicture.expect(MSG),
}
}
}
13 changes: 13 additions & 0 deletions src/safe/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ pub enum ErrorKind {
/// The client is attempting to unmap a resource
/// that has not been successfully mapped.
ResourceNotMapped = 25,
/// The encode driver requires more output buffers to write an
/// output bitstream. If this error is returned from
/// [`EncodeAPI.restore_encoder_state`], this is not a fatal error. If the
/// client is encoding with B frames then,
/// [`EncodeAPI.restore_encoder_state`] API might be requiring the extra
/// output buffer for accommodating overlay frame output in a separate
/// buffer, for AV1 codec. In this case, the client must call
/// [`EncodeAPI.restore_encoder_state`] API again with
/// an output bitstream as input along with the parameters in the previous
/// call. When operating in asynchronous mode of encoding, client must
/// also specify the completion event.
NeedMoreOutput = 26,
}

/// Wrapper struct around [`NVENCSTATUS`].
Expand Down Expand Up @@ -162,6 +174,7 @@ impl From<NVENCSTATUS> for ErrorKind {
NVENCSTATUS::NV_ENC_ERR_RESOURCE_REGISTER_FAILED => ErrorKind::ResourceRegisterFailed,
NVENCSTATUS::NV_ENC_ERR_RESOURCE_NOT_REGISTERED => ErrorKind::ResourceNotRegistered,
NVENCSTATUS::NV_ENC_ERR_RESOURCE_NOT_MAPPED => ErrorKind::ResourceNotMapped,
NVENCSTATUS::NV_ENC_ERR_NEED_MORE_OUTPUT => ErrorKind::NeedMoreOutput,
}
}
}
Expand Down
98 changes: 5 additions & 93 deletions src/sys/guid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use super::nvEncodeAPI::GUID;

// Search for `//.*\nstatic const\s+GUID\s+NV_ENC_\w+_GUID\s+=\n\{.*\};`

// =========================================================================================
// Encode Codec GUIDS supported by the NvEncodeAPI interface.
// =========================================================================================
Expand Down Expand Up @@ -137,10 +139,6 @@ pub const NV_ENC_HEVC_PROFILE_FREXT_GUID: GUID = GUID {
Data4: [0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41],
};

// =========================================================================================
// * Preset GUIDS supported by the NvEncodeAPI interface.
// =========================================================================================

/// GUID for the AV1 main encoding preset.
/// {5f2a39f5-f14e-4f95-9a9e-b76d568fcf97}
pub const NV_ENC_AV1_PROFILE_MAIN_GUID: GUID = GUID {
Expand All @@ -150,95 +148,9 @@ pub const NV_ENC_AV1_PROFILE_MAIN_GUID: GUID = GUID {
Data4: [0x9a, 0x9e, 0xb7, 0x6d, 0x56, 0x8f, 0xcf, 0x97],
};

/// GUID for the default encoding preset.
/// {B2DFB705-4EBD-4C49-9B5F-24A777D3E587}
#[deprecated]
pub const NV_ENC_PRESET_DEFAULT_GUID: GUID = GUID {
Data1: 0xb2df_b705,
Data2: 0x4ebd,
Data3: 0x4c49,
Data4: [0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87],
};

/// GUID for the high performance encoding preset.
/// {60E4C59F-E846-4484-A56D-CD45BE9FDDF6}
#[deprecated]
pub const NV_ENC_PRESET_HP_GUID: GUID = GUID {
Data1: 0x60e4_c59f,
Data2: 0xe846,
Data3: 0x4484,
Data4: [0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6],
};

/// GUID for the high quality encoding preset.
/// {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012}
#[deprecated]
pub const NV_ENC_PRESET_HQ_GUID: GUID = GUID {
Data1: 0x34db_a71d,
Data2: 0xa77b,
Data3: 0x4b8f,
Data4: [0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12],
};

/// GUID for the Blu-ray-compatible encoding preset.
/// {82E3E450-BDBB-4e40-989C-82A90DF9EF32}
#[deprecated]
pub const NV_ENC_PRESET_BD_GUID: GUID = GUID {
Data1: 0x82e3_e450,
Data2: 0xbdbb,
Data3: 0x4e40,
Data4: [0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32],
};

/// GUID for the low latency encoding preset.
/// {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726}
#[deprecated]
pub const NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID: GUID = GUID {
Data1: 0x49df_21c5,
Data2: 0x6dfa,
Data3: 0x4feb,
Data4: [0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26],
};

/// GUID for the low latency, high quality encoding preset.
/// {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105}
#[deprecated]
pub const NV_ENC_PRESET_LOW_LATENCY_HQ_GUID: GUID = GUID {
Data1: 0xc5f7_33b9,
Data2: 0xea97,
Data3: 0x4cf9,
Data4: [0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5],
};

/// GUID for the low latency, high performance encoding preset.
/// {67082A44-4BAD-48FA-98EA-93056D150A58}
#[deprecated]
pub const NV_ENC_PRESET_LOW_LATENCY_HP_GUID: GUID = GUID {
Data1: 0x6708_2a44,
Data2: 0x4bad,
Data3: 0x48fa,
Data4: [0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58],
};

/// GUID for the lossless encoding preset.
/// {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC}
#[deprecated]
pub const NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID: GUID = GUID {
Data1: 0xd5bf_b716,
Data2: 0xc604,
Data3: 0x44e7,
Data4: [0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac],
};

/// GUID for the lossless, high performance encoding preset.
/// {149998E7-2364-411d-82EF-179888093409}
#[deprecated]
pub const NV_ENC_PRESET_LOSSLESS_HP_GUID: GUID = GUID {
Data1: 0x1499_98e7,
Data2: 0x2364,
Data3: 0x411d,
Data4: [0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9],
};
// =========================================================================================
// * Preset GUIDS supported by the NvEncodeAPI interface.
// =========================================================================================

// Performance degrades and quality improves as we move from P1 to P7. Presets
// P3 to P7 for H264 and Presets P2 to P7 for HEVC have B frames enabled by
Expand Down
2 changes: 1 addition & 1 deletion src/sys/headers/cuviddec.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This copyright notice applies to this header file only:
*
* Copyright (c) 2010-2022 NVIDIA Corporation
* Copyright (c) 2010-2023 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down
Loading

0 comments on commit e88fb70

Please sign in to comment.