Implement backwards compatibility for NVENC APIs back to Video Codec SDK v11.0

This allows NVENC on drivers 456.71 (October 2020) and later.
This commit is contained in:
Cameron Gutman
2024-02-14 23:28:32 -06:00
parent 56da68c863
commit d1a635809a
3 changed files with 65 additions and 14 deletions
+12
View File
@@ -45,6 +45,17 @@ namespace nvenc {
bool
nvenc_failed(NVENCSTATUS status);
/**
* @brief This function returns the corresponding struct version for the minimum API required by the codec.
* @details Reducing the struct versions maximizes driver compatibility by avoiding needless API breaks.
* @param version The raw structure version from `NVENCAPI_STRUCT_VERSION()`.
* @param v11_struct_version Optionally specifies the struct version to use with v11 SDK major versions.
* @param v12_struct_version Optionally specifies the struct version to use with v12 SDK major versions.
* @return A suitable struct version for the active codec.
*/
uint32_t
min_struct_version(uint32_t version, uint32_t v11_struct_version = 0, uint32_t v12_struct_version = 0);
const NV_ENC_DEVICE_TYPE device_type;
void *const device;
@@ -68,6 +79,7 @@ namespace nvenc {
private:
NV_ENC_OUTPUT_PTR output_bitstream = nullptr;
uint32_t minimum_api_version = 0;
struct {
uint64_t last_encoded_frame_index = 0;