30 struct encoder_session_t;
34 struct completion_event_t;
64 const ::nvenc::nvenc_config &config,
136 bool nvenc_failed(NVENCSTATUS status);
145 NV_ENC_BUFFER_FORMAT buffer_format = NV_ENC_BUFFER_FORMAT_UNDEFINED;
146 uint32_t ref_frames_in_dpb = 0;
153 std::variant<ID3D11Device *, CUctx_st *>
device {
static_cast<ID3D11Device *
>(
nullptr)};
154 std::shared_ptr<NV_ENCODE_API_FUNCTION_LIST>
nvenc;
169 int get_encoder_cap(
const GUID &encode_guid, NV_ENC_CAPS cap)
const;
178 bool validate_encoder_capabilities(
const GUID &encode_guid, NV_ENC_BUFFER_FORMAT buffer_format);
187 void configure_split_frame(
188 NV_ENC_INITIALIZE_PARAMS &init_params,
189 const ::nvenc::nvenc_config &config,
201 void configure_rate_control(
202 NV_ENC_CONFIG &enc_config,
203 const ::nvenc::nvenc_config &config,
205 const GUID &encode_guid
217 void configure_reference_frames(
218 std::uint32_t &ref_frames_option,
219 NV_ENC_NUM_REF_FRAMES &list0_option,
220 std::uint32_t default_count,
222 const GUID &encode_guid
235 template<
typename FormatConfig>
236 void configure_h264_hevc_metadata(
237 FormatConfig &format_config,
240 NV_ENC_BUFFER_FORMAT buffer_format,
241 const GUID &encode_guid
255 NV_ENC_CONFIG &enc_config,
256 const ::nvenc::nvenc_config &config,
259 NV_ENC_BUFFER_FORMAT buffer_format,
260 const GUID &encode_guid
274 NV_ENC_CONFIG &enc_config,
275 const ::nvenc::nvenc_config &config,
278 NV_ENC_BUFFER_FORMAT buffer_format,
279 const GUID &encode_guid
282#if NVENC_SDK_VERSION >= 1200
294 NV_ENC_CONFIG &enc_config,
295 const ::nvenc::nvenc_config &config,
298 NV_ENC_BUFFER_FORMAT buffer_format,
299 const GUID &encode_guid
313 void configure_codec(
314 NV_ENC_CONFIG &enc_config,
315 const ::nvenc::nvenc_config &config,
318 NV_ENC_BUFFER_FORMAT buffer_format,
319 const GUID &encode_guid
328 bool initialize_encoder_resources(NV_ENC_INITIALIZE_PARAMS &init_params);
339 void log_created_encoder(
340 const NV_ENC_INITIALIZE_PARAMS &init_params,
341 const NV_ENC_CONFIG &enc_config,
342 const ::nvenc::nvenc_config &config,
344 NV_ENC_BUFFER_FORMAT buffer_format
347 NV_ENC_OUTPUT_PTR output_bitstream =
nullptr;
350 uint64_t last_encoded_frame_index = 0;
351 bool rfi_needs_confirmation =
false;
352 std::pair<uint64_t, uint64_t> last_rfi_range;
A helper class for tracking and logging numerical values across a period of time.
Definition logging.h:163
std::string last_nvenc_error_string
Last NVENC error string.
Definition nvenc_base.h:150
bool invalidate_ref_frames(uint64_t first_frame, uint64_t last_frame) override
Perform reference frame invalidation (RFI) procedure.
Definition nvenc_base.cpp:799
bool create_encoder(const ::nvenc::nvenc_config &config, const video::config_t &client_config, const video::sunshine_colorspace_t &colorspace, platf::pix_fmt_e buffer_format) override
Create the encoder.
Definition nvenc_base.cpp:563
const NV_ENC_DEVICE_TYPE device_type
NVENC device backend used by this encoder instance.
Definition nvenc_base.h:138
NV_ENC_REGISTERED_PTR registered_input_buffer
Definition nvenc_base.h:156
encoder_session_t * encoder
Opaque NVENC encoder session handle returned by the driver.
Definition nvenc_base.h:140
completion_event_t * async_event_handle
Definition nvenc_base.h:158
virtual bool create_and_register_input_buffer()=0
Required. Used for creating outside-facing input surface, registering this surface with nvenc->nvEncR...
void destroy_encoder() override
Destroy the encoder. Derived classes classes call it in the destructor.
Definition nvenc_base.cpp:684
std::variant< ID3D11Device *, CUctx_st * > device
Native D3D11 device or CUDA context, set by the derived backend.
Definition nvenc_base.h:153
::nvenc::nvenc_encoded_frame encode_frame(uint64_t frame_index, bool force_idr) override
Encode the next frame using platform-specific input surface.
Definition nvenc_base.cpp:715
virtual bool wait_for_async_event(uint32_t timeout_ms)
Optional. Override if you want to create encoder in async mode. In this case must also set async_even...
Definition nvenc_base.h:126
~nvenc_base() override
Destroy the encoder wrapper; callers release the encoder session with destroy_encoder().
virtual bool init_library()=0
Required. Used for loading NvEnc library and setting nvenc variable with NvEncodeAPICreateInstance()....
nvenc_base(NV_ENC_DEVICE_TYPE device_type)
Definition nvenc_base.cpp:187
virtual bool synchronize_input_buffer()
Optional. Override if you must perform additional operations on the registered input surface in the b...
Definition nvenc_base.h:116
SDK-neutral standalone NVENC encoder interface.
Definition nvenc_encoder.h:28
pix_fmt_e
Enumerates supported pix fmt options.
Definition common.h:342
bl::sources::severity_logger< int > debug
Follow what is happening.
Definition logging.cpp:43
Declarations for logging related functions.
Standalone NVENC encoder.
Definition nvenc_base.cpp:185
Declarations for NVENC YUV colorspace.
Declarations for NVENC encoder configuration.
Declarations for NVENC encoded frame.
Declarations for the SDK-neutral NVENC encoder interface.
Imports one NVENC SDK into its version-specific implementation namespace.
#define NVENC_NAMESPACE
Namespace used for the documented NVENC implementation.
Definition nvenc_sdk.h:12
YUV colorspace and color range.
Definition nvenc_colorspace.h:15
Encoded NVENC output frame and metadata needed by the packetizer.
Definition nvenc_encoded_frame.h:16
Encoding configuration requested by a remote client.
Definition video.h:33
Sunshine colorimetry values derived from stream configuration.
Definition video_colorspace.h:36
Declarations for colorspace functions.