Smarter encoder group selection

This commit is contained in:
Patrick Nicolas
2024-10-09 19:27:58 +02:00
parent b54108bb4c
commit 66aa729fbc
2 changed files with 21 additions and 3 deletions
+2 -1
View File
@@ -49,9 +49,10 @@ Default values: full image (`width` = 1, `height` = 1, `offset_x` = 0, `offset_y
Specifies the portion of the video to encode: all values are in 0, 1 range. Left eye image ranges from x 0 to x 0.5 and y 0 to 1, Rigth eye is x from 0.5 to 1 and y 0 to 1.
### `group` (very advanced)
Default value: First unused group identifier, if omitted on all encoders, they are executed concurrently.
Default value: One value for each encoder type (nvenc, vaapi, x264).
Identifier (number) of the encoder group. Encoders with the same identifier are executed sequentially, in the order they are defined in the configuration. Encoders with different identifiers are executed concurrently.
Default setting will have all encoders of a given type execute sequentially, and different types in parallel.
### Examples
1. Simple encoder
+19 -2
View File
@@ -292,7 +292,17 @@ std::vector<encoder_settings> get_encoder_settings(wivrn_vk_bundle & bundle, uin
height += height % 2;
std::vector<wivrn::encoder_settings> res;
std::unordered_map<std::string, int> groups;
int next_group = 0;
for (const auto & encoder: config.encoders)
{
if (encoder.group)
{
groups[encoder.name] = *encoder.group;
next_group = std::max(next_group, *encoder.group + 1);
}
}
for (const auto & encoder: config.encoders)
{
wivrn::encoder_settings settings{};
@@ -306,11 +316,18 @@ std::vector<encoder_settings> get_encoder_settings(wivrn_vk_bundle & bundle, uin
make_even(settings.width, width - settings.offset_x);
make_even(settings.height, height - settings.offset_y);
settings.codec = *encoder.codec;
settings.group = encoder.group.value_or(next_group);
if (encoder.group)
settings.group = *encoder.group;
else
{
auto [it, inserted] = groups.emplace(encoder.name, next_group);
settings.group = it->second;
if (inserted)
++next_group;
}
settings.options = encoder.options;
settings.device = encoder.device;
next_group = std::max(next_group, settings.group + 1);
res.push_back(settings);
}
split_bitrate(res, bitrate);