wip: set bitrate at runtime

This commit is contained in:
galister
2025-02-07 19:00:34 +01:00
committed by xytovl
parent f24d51334b
commit e9f4b52b50
20 changed files with 170 additions and 10 deletions
@@ -68,6 +68,14 @@ bool video_encoder_ffmpeg::once = set_log_level();
std::optional<wivrn::video_encoder::data> video_encoder_ffmpeg::encode(bool idr, std::chrono::steady_clock::time_point target_timestamp, uint8_t slot)
{
if (auto bitrate = pending_bitrate.exchange(BITRATE_UNCHANGED))
{
U_LOG_E("Reconfigure FFMPEG encoder");
idr = true;
encoder_ctx->bit_rate = bitrate;
encoder_ctx->rc_max_rate = bitrate;
}
push_frame(idr, target_timestamp, slot);
std::shared_ptr<AVPacket> enc_pkt(av_packet_alloc(), [](AVPacket * d) { av_packet_free(&d); });
int err = avcodec_receive_packet(encoder_ctx.get(), enc_pkt.get());
+2 -2
View File
@@ -38,8 +38,8 @@ public:
};
protected:
video_encoder_ffmpeg(uint8_t stream_idx, to_headset::video_stream_description::channels_t channels) :
wivrn::video_encoder(stream_idx, channels, true) {}
video_encoder_ffmpeg(uint8_t stream_idx, to_headset::video_stream_description::channels_t channels, double bitrate_multiplier) :
wivrn::video_encoder(stream_idx, channels, bitrate_multiplier, true) {}
virtual void push_frame(bool idr, std::chrono::steady_clock::time_point pts, uint8_t slot) = 0;
+1 -1
View File
@@ -135,7 +135,7 @@ video_encoder_va::video_encoder_va(wivrn_vk_bundle & vk,
wivrn::encoder_settings & settings,
float fps,
uint8_t stream_idx) :
video_encoder_ffmpeg(stream_idx, settings.channels),
video_encoder_ffmpeg(stream_idx, settings.channels, settings.bitrate_multiplier),
synchronization2(vk.vk.features.synchronization_2)
{
auto drm_hw_ctx = make_drm_hw_ctx(vk.physical_device, settings.device);