clang-format
This commit is contained in:
@@ -43,10 +43,10 @@ static bool is_nvidia(vk::PhysicalDevice physical_device)
|
||||
return props.vendorID == 0x10DE;
|
||||
}
|
||||
|
||||
static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> &encoders, uint64_t bitrate)
|
||||
static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> & encoders, uint64_t bitrate)
|
||||
{
|
||||
double total_weight = 0;
|
||||
for (auto& encoder: encoders)
|
||||
for (auto & encoder: encoders)
|
||||
{
|
||||
double w = encoder.width * encoder.height;
|
||||
switch (encoder.codec)
|
||||
@@ -61,7 +61,7 @@ static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> &en
|
||||
total_weight += w;
|
||||
}
|
||||
|
||||
for (auto& encoder: encoders)
|
||||
for (auto & encoder: encoders)
|
||||
{
|
||||
encoder.bitrate = encoder.bitrate * bitrate / total_weight;
|
||||
}
|
||||
@@ -94,21 +94,21 @@ static std::vector<xrt::drivers::wivrn::encoder_settings> get_encoder_default_se
|
||||
else
|
||||
{
|
||||
#ifdef WIVRN_USE_VAAPI
|
||||
/* Split in 3 parts:
|
||||
* +--------+--------+
|
||||
* | | |
|
||||
* | | |
|
||||
* +--------+ |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* +--------+--------+
|
||||
* All 3 are encoded sequentially, so that the smallest is ready earlier.
|
||||
* Decoder can start work as fast as possible, reducing idle time.
|
||||
*
|
||||
*/
|
||||
/* Split in 3 parts:
|
||||
* +--------+--------+
|
||||
* | | |
|
||||
* | | |
|
||||
* +--------+ |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* +--------+--------+
|
||||
* All 3 are encoded sequentially, so that the smallest is ready earlier.
|
||||
* Decoder can start work as fast as possible, reducing idle time.
|
||||
*
|
||||
*/
|
||||
settings.encoder_name = encoder_vaapi;
|
||||
settings.width = std::ceil(width * 0.5);
|
||||
std::vector<xrt::drivers::wivrn::encoder_settings> encoders(3, settings);
|
||||
@@ -133,9 +133,9 @@ static std::vector<xrt::drivers::wivrn::encoder_settings> get_encoder_default_se
|
||||
return {settings};
|
||||
}
|
||||
|
||||
static void make_even(uint16_t& value, uint16_t max)
|
||||
static void make_even(uint16_t & value, uint16_t max)
|
||||
{
|
||||
value += value %2;
|
||||
value += value % 2;
|
||||
value = std::min(value, max);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ get_render_device(vk::raii::PhysicalDevice & physical_device)
|
||||
return path;
|
||||
}
|
||||
|
||||
av_buffer_ptr make_drm_hw_ctx(vk::raii::PhysicalDevice & physical_device, const std::optional<std::string>& device)
|
||||
av_buffer_ptr make_drm_hw_ctx(vk::raii::PhysicalDevice & physical_device, const std::optional<std::string> & device)
|
||||
{
|
||||
const auto render_device = device ? *device : get_render_device(physical_device);
|
||||
AVBufferRef * hw_ctx;
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "video_encoder_ffmpeg.h"
|
||||
#include "ffmpeg_helper.h"
|
||||
#include "utils/wivrn_vk_bundle.h"
|
||||
#include "video_encoder_ffmpeg.h"
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
namespace xrt::drivers::wivrn
|
||||
@@ -40,7 +40,7 @@ class video_encoder_va : public VideoEncoderFFMPEG
|
||||
std::vector<vk::raii::DeviceMemory> mem;
|
||||
|
||||
public:
|
||||
video_encoder_va(wivrn_vk_bundle&, xrt::drivers::wivrn::encoder_settings & settings, float fps);
|
||||
video_encoder_va(wivrn_vk_bundle &, xrt::drivers::wivrn::encoder_settings & settings, float fps);
|
||||
|
||||
void PresentImage(yuv_converter & src_yuv, vk::raii::CommandBuffer & cmd_buf) override;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ std::unique_ptr<VideoEncoder> VideoEncoder::Create(
|
||||
throw std::runtime_error("Failed to create encoder " + settings.encoder_name);
|
||||
res->stream_idx = stream_idx;
|
||||
|
||||
auto wivrn_dump_video= std::getenv("WIVRN_DUMP_VIDEO");
|
||||
auto wivrn_dump_video = std::getenv("WIVRN_DUMP_VIDEO");
|
||||
if (wivrn_dump_video)
|
||||
{
|
||||
std::string file(wivrn_dump_video);
|
||||
@@ -124,7 +124,7 @@ void VideoEncoder::SendData(std::span<uint8_t> data, bool end_of_frame)
|
||||
if (end_of_frame)
|
||||
timing_info.send_end = clock.to_headset(os_monotonic_get_ns());
|
||||
if (video_dump)
|
||||
video_dump.write((char*)data.data(), data.size());
|
||||
video_dump.write((char *)data.data(), data.size());
|
||||
if (shard.shard_idx == 0)
|
||||
{
|
||||
cnx->dump_time("send_begin", shard.frame_idx, os_monotonic_get_ns(), stream_idx);
|
||||
|
||||
@@ -287,7 +287,7 @@ void VideoEncoderNvenc::PresentImage(yuv_converter & src_yuv, vk::raii::CommandB
|
||||
*yuv_buffer,
|
||||
vk::BufferImageCopy{
|
||||
.bufferOffset = pitch * rect.extent.height,
|
||||
.bufferRowLength = uint32_t(pitch/2),
|
||||
.bufferRowLength = uint32_t(pitch / 2),
|
||||
.imageSubresource = {
|
||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.layerCount = 1,
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace xrt::drivers::wivrn
|
||||
|
||||
class VideoEncoderNvenc : public VideoEncoder
|
||||
{
|
||||
wivrn_vk_bundle& vk;
|
||||
wivrn_vk_bundle & vk;
|
||||
// relevant part of the input image to encode
|
||||
vk::Rect2D rect;
|
||||
|
||||
@@ -51,10 +51,10 @@ class VideoEncoderNvenc : public VideoEncoder
|
||||
int bitrate;
|
||||
|
||||
public:
|
||||
VideoEncoderNvenc(wivrn_vk_bundle& vk, const encoder_settings & settings, float fps);
|
||||
VideoEncoderNvenc(wivrn_vk_bundle & vk, const encoder_settings & settings, float fps);
|
||||
|
||||
void PresentImage(yuv_converter & src_yuv, vk::raii::CommandBuffer & cmd_buf) override;
|
||||
void Encode( bool idr, std::chrono::steady_clock::time_point pts) override;
|
||||
void Encode(bool idr, std::chrono::steady_clock::time_point pts) override;
|
||||
};
|
||||
|
||||
} // namespace xrt::drivers::wivrn
|
||||
|
||||
@@ -57,7 +57,7 @@ class VideoEncoderX264 : public VideoEncoder
|
||||
std::list<pending_nal> pending_nals;
|
||||
|
||||
public:
|
||||
VideoEncoderX264(wivrn_vk_bundle& vk, encoder_settings & settings, float fps);
|
||||
VideoEncoderX264(wivrn_vk_bundle & vk, encoder_settings & settings, float fps);
|
||||
|
||||
void PresentImage(yuv_converter & src_yuv, vk::raii::CommandBuffer & cmd_buf) override;
|
||||
|
||||
|
||||
@@ -28,9 +28,11 @@ class yuv_converter
|
||||
vk::Extent2D extent;
|
||||
|
||||
vk::Image rgb;
|
||||
|
||||
public:
|
||||
image_allocation luma;
|
||||
image_allocation chroma;
|
||||
|
||||
private:
|
||||
vk::raii::ImageView view_rgb = nullptr;
|
||||
vk::raii::ImageView view_luma = nullptr;
|
||||
@@ -44,13 +46,13 @@ private:
|
||||
|
||||
std::vector<vk::raii::DeviceMemory> mem;
|
||||
|
||||
public:
|
||||
public:
|
||||
yuv_converter();
|
||||
yuv_converter(vk::PhysicalDevice, vk::raii::Device& device, vk::Image rgb, vk::Format format, vk::Extent2D extent);
|
||||
yuv_converter(vk::PhysicalDevice, vk::raii::Device & device, vk::Image rgb, vk::Format format, vk::Extent2D extent);
|
||||
|
||||
// Converts the given image to yuv, stored in luma and chroma images.
|
||||
// The output images will be in transfer src optimal layout
|
||||
void record_draw_commands(vk::raii::CommandBuffer& cmd_buf);
|
||||
void record_draw_commands(vk::raii::CommandBuffer & cmd_buf);
|
||||
|
||||
void assemble_planes(vk::Rect2D, vk::raii::CommandBuffer&, vk::Image target);
|
||||
void assemble_planes(vk::Rect2D, vk::raii::CommandBuffer &, vk::Image target);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user