Allow encoders to change their settings
This commit is contained in:
@@ -202,8 +202,12 @@ struct video_stream_description
|
||||
{
|
||||
struct item
|
||||
{
|
||||
// useful dimensions of the video stream
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
// dimensions of the video, may include padding at the end
|
||||
uint16_t video_width;
|
||||
uint16_t video_height;
|
||||
uint16_t offset_x;
|
||||
uint16_t offset_y;
|
||||
video_codec codec;
|
||||
|
||||
@@ -96,6 +96,8 @@ std::vector<encoder_settings> xrt::drivers::wivrn::get_encoder_settings(vk_bundl
|
||||
settings.encoder_name = encoder.name;
|
||||
settings.width = std::ceil(encoder.width.value_or(1) * width);
|
||||
settings.height = std::ceil(encoder.height.value_or(1) * height);
|
||||
settings.video_width = settings.width;
|
||||
settings.video_height = settings.height;
|
||||
settings.offset_x = std::ceil(encoder.offset_x.value_or(0) * width);
|
||||
settings.offset_y = std::ceil(encoder.offset_y.value_or(0) * height);
|
||||
settings.bitrate = encoder.bitrate.value_or(default_bitrate);
|
||||
|
||||
@@ -95,18 +95,23 @@ VideoEncoderX264::VideoEncoderX264(
|
||||
}
|
||||
|
||||
// encoder requires width and height to be even
|
||||
settings.width += settings.width % 2;
|
||||
settings.height += settings.height % 2;
|
||||
settings.video_width += settings.video_width % 2;
|
||||
settings.video_height += settings.video_height % 2;
|
||||
|
||||
converter =
|
||||
std::make_unique<YuvConverter>(vk, VkExtent3D{uint32_t(settings.width), uint32_t(settings.height), 1}, settings.offset_x, settings.offset_y, input_width, input_height);
|
||||
converter = std::make_unique<YuvConverter>(
|
||||
vk,
|
||||
VkExtent3D{uint32_t(settings.video_width), uint32_t(settings.video_height), 1},
|
||||
settings.offset_x,
|
||||
settings.offset_y,
|
||||
input_width,
|
||||
input_height);
|
||||
|
||||
x264_param_default_preset(¶m, "ultrafast", "zerolatency");
|
||||
param.nalu_process = &ProcessCb;
|
||||
// param.i_slice_max_size = 1300;
|
||||
param.i_slice_count = 32;
|
||||
param.i_width = settings.width;
|
||||
param.i_height = settings.height;
|
||||
param.i_width = settings.video_width;
|
||||
param.i_height = settings.video_height;
|
||||
param.i_log_level = X264_LOG_WARNING;
|
||||
param.i_fps_num = fps * 1'000'000;
|
||||
param.i_fps_den = 1'000'000;
|
||||
|
||||
@@ -150,10 +150,10 @@ static void create_encoders(wivrn_comp_target * cn, std::vector<encoder_settings
|
||||
|
||||
for (auto & settings: _settings)
|
||||
{
|
||||
desc.items.push_back(settings);
|
||||
uint8_t stream_index = cn->encoders.size();
|
||||
auto & encoder = cn->encoders.emplace_back(
|
||||
VideoEncoder::Create(vk, settings, stream_index, desc.width, desc.height, desc.fps));
|
||||
desc.items.push_back(settings);
|
||||
|
||||
std::vector<VkImage> images(cn->image_count);
|
||||
std::vector<VkDeviceMemory> memory(cn->image_count);
|
||||
|
||||
Reference in New Issue
Block a user