wip: set bitrate at runtime
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user