Don't recreate decoders if only fps changes

This commit is contained in:
Patrick Nicolas
2025-01-07 20:07:10 +01:00
parent ad9300f842
commit da14e8450d
2 changed files with 32 additions and 14 deletions
+31 -12
View File
@@ -935,6 +935,37 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
{
std::unique_lock lock(decoder_mutex);
if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
try
{
session.set_refresh_rate(description.fps);
}
catch (std::exception & e)
{
spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what());
}
}
if (std::ranges::equal(description.items, video_stream_description->items, [](const auto & a, const auto & b) {
// clang-format off
return a.width == b.width
and a.height == b.height
and a.video_width == b.video_width
and a.offset_x == b.offset_x
and a.offset_y == b.offset_y
and a.codec == b.codec
and a.channels == b.channels
and a.subsampling == b.subsampling
and a.range == b.range
and a.color_model == b.color_model;
//clang-format on
}))
{
video_stream_description = description;
return;
}
decoders.clear();
if (description.items.empty())
@@ -1048,18 +1079,6 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
});
}
if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
try
{
session.set_refresh_rate(description.fps);
}
catch (std::exception & e)
{
spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what());
}
}
for (const auto & [stream_index, item]: utils::enumerate(description.items))
{
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);