Skip to content
Snippets Groups Projects
Commit d07b6650 authored by Jens Koenen's avatar Jens Koenen
Browse files

The encoder nw runs on the latest version of the vulkan video extension....

The encoder nw runs on the latest version of the vulkan video extension. Besides that fixed some bugs and added sliders for i-frame and p-frame quality.
parent f0a22e42
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "vr_application.hpp" #include "vr_application.hpp"
#include <imgui.h> #include <imgui.h>
#include <glm/gtx/string_cast.hpp>
RemoteHeadset::RemoteHeadset() RemoteHeadset::RemoteHeadset()
{ {
this->controller_states.fill(CONTROLLER_STATE_DETACHED); this->controller_states.fill(CONTROLLER_STATE_DETACHED);
...@@ -129,9 +131,9 @@ bool RemoteHeadset::on_interface() ...@@ -129,9 +131,9 @@ bool RemoteHeadset::on_interface()
} }
} }
ImGui::SliderInt("Input-Rate (Fps)", (int32_t*) &this->encoder_input_rate, 1, 90); ImGui::SliderInt("Input-Rate (Fps)", (int32_t*) &this->encoder_input_rate, 1, 180);
if (ImGui::SliderInt("Key-Rate (Kps)", (int32_t*)&this->encoder_key_rate, 90, 900)) if (ImGui::SliderInt("Key-Rate (Frames)", (int32_t*)&this->encoder_key_rate, 1, 180))
{ {
for (Encoder::Ptr encoder : this->encoders) for (Encoder::Ptr encoder : this->encoders)
{ {
...@@ -149,7 +151,7 @@ bool RemoteHeadset::on_interface() ...@@ -149,7 +151,7 @@ bool RemoteHeadset::on_interface()
} }
} }
if (ImGui::SliderInt("Frame-Rate (Fps)", (int32_t*)&this->encoder_frame_rate, 10, 120)) if (ImGui::SliderInt("Frame-Rate (Fps)", (int32_t*)&this->encoder_frame_rate, 1, 180))
{ {
for (Encoder::Ptr encoder : this->encoders) for (Encoder::Ptr encoder : this->encoders)
{ {
...@@ -160,11 +162,19 @@ bool RemoteHeadset::on_interface() ...@@ -160,11 +162,19 @@ bool RemoteHeadset::on_interface()
else if (this->encoder_mode == ENCODER_MODE_CONSTANT_QUALITY) else if (this->encoder_mode == ENCODER_MODE_CONSTANT_QUALITY)
{ {
if (ImGui::SliderInt("Quality", (int32_t*)&this->encoder_quality, 1, 51)) if (ImGui::SliderInt("Quality I-Frame", (int32_t*)&this->encoder_quality_iframe, 1, 51))
{ {
for (Encoder::Ptr encoder : this->encoders) for (Encoder::Ptr encoder : this->encoders)
{ {
encoder->set_quality(this->encoder_quality); encoder->set_quality_iframe(this->encoder_quality_iframe);
}
}
if (ImGui::SliderInt("Quality P-Frame", (int32_t*)&this->encoder_quality_pframe, 1, 51))
{
for (Encoder::Ptr encoder : this->encoders)
{
encoder->set_quality_pframe(this->encoder_quality_pframe);
} }
} }
} }
...@@ -212,12 +222,12 @@ bool RemoteHeadset::on_update(lava::delta delta_time) ...@@ -212,12 +222,12 @@ bool RemoteHeadset::on_update(lava::delta delta_time)
this->update_bitrates(); this->update_bitrates();
this->update_stage(delta_time); this->update_stage(delta_time);
this->frame_number++;
this->encoder_last_submit += delta_time; this->encoder_last_submit += delta_time;
this->encoder_enable_submit = false; this->encoder_enable_submit = false;
if (this->encoder_last_submit > (1.0 / (float)this->encoder_input_rate)) if (this->encoder_last_submit > (1.0 / (float)this->encoder_input_rate))
{ {
this->frame_number++;
this->encoder_enable_submit = true; this->encoder_enable_submit = true;
this->encoder_last_submit = 0.0f; this->encoder_last_submit = 0.0f;
} }
...@@ -451,7 +461,8 @@ bool RemoteHeadset::create_encoders() ...@@ -451,7 +461,8 @@ bool RemoteHeadset::create_encoders()
encoder->set_key_rate(this->encoder_key_rate); encoder->set_key_rate(this->encoder_key_rate);
encoder->set_bit_rate(this->encoder_bit_rate); encoder->set_bit_rate(this->encoder_bit_rate);
encoder->set_frame_rate(this->encoder_frame_rate); encoder->set_frame_rate(this->encoder_frame_rate);
encoder->set_quality(this->encoder_quality); encoder->set_quality_iframe(this->encoder_quality_iframe);
encoder->set_quality_pframe(this->encoder_quality_pframe);
this->encoders[index] = encoder; this->encoders[index] = encoder;
} }
...@@ -554,7 +565,7 @@ void RemoteHeadset::on_head_transform(PacketTransformId transform_id, const glm: ...@@ -554,7 +565,7 @@ void RemoteHeadset::on_head_transform(PacketTransformId transform_id, const glm:
void RemoteHeadset::on_controller_transform(PacketControllerId controller_id, const glm::mat4& controller_transform) void RemoteHeadset::on_controller_transform(PacketControllerId controller_id, const glm::mat4& controller_transform)
{ {
std::unique_lock<std::mutex> lock(this->transport_mutex); std::unique_lock<std::mutex> lock(this->transport_mutex);
this->controller_matrices[controller_id] = controller_transform; this->controller_transforms[controller_id] = controller_transform;
lock.unlock(); lock.unlock();
} }
......
...@@ -114,10 +114,11 @@ private: ...@@ -114,10 +114,11 @@ private:
std::vector<Encoder::Ptr> encoders; std::vector<Encoder::Ptr> encoders;
uint32_t encoder_mode = ENCODER_MODE_CONSTANT_QUALITY; uint32_t encoder_mode = ENCODER_MODE_CONSTANT_QUALITY;
uint32_t encoder_input_rate = 90; uint32_t encoder_input_rate = 90;
uint32_t encoder_key_rate = 120; uint32_t encoder_key_rate = 90;
uint32_t encoder_frame_rate = 90; uint32_t encoder_frame_rate = 90;
uint32_t encoder_quality = 51; uint32_t encoder_quality_iframe = 45;
float encoder_bit_rate = 6.0; //NOTE: Bitrate in Mbit per seconds uint32_t encoder_quality_pframe = 45;
float encoder_bit_rate = 8.0; //NOTE: Bitrate in Mbit per seconds
float encoder_last_submit = 0.0f; float encoder_last_submit = 0.0f;
bool encoder_enable_submit = true; bool encoder_enable_submit = true;
......
This diff is collapsed.
...@@ -120,8 +120,10 @@ public: ...@@ -120,8 +120,10 @@ public:
void set_bit_rate(double bit_rate); void set_bit_rate(double bit_rate);
//NOTE: The frame rate in frames per second. //NOTE: The frame rate in frames per second.
void set_frame_rate(uint32_t frame_rate); void set_frame_rate(uint32_t frame_rate);
//NOTE: The quality in range from 0 to 51, where 0 means a lowest compression and 51 means highest compression. //NOTE: The quality of i-frames in range from 0 to 51, where 0 means a lowest compression and 51 means highest compression.
void set_quality(uint32_t quality); void set_quality_iframe(uint32_t quality);
//NOTE: The quality of p-frames in range from 0 to 51, where 0 means a lowest compression and 51 means highest compression.
void set_quality_pframe(uint32_t quality);
bool encode_frame(VkCommandBuffer command_buffer, lava::renderer& renderer, lava::image::ptr image, VkImageLayout image_layout, EncoderCallback callback); bool encode_frame(VkCommandBuffer command_buffer, lava::renderer& renderer, lava::image::ptr image, VkImageLayout image_layout, EncoderCallback callback);
...@@ -195,7 +197,8 @@ private: ...@@ -195,7 +197,8 @@ private:
uint32_t setting_key_rate = 120; uint32_t setting_key_rate = 120;
double setting_bit_rate = 2.0; //NOTE: Bitrate in Mbit per seconds double setting_bit_rate = 2.0; //NOTE: Bitrate in Mbit per seconds
uint32_t setting_frame_rate = 90; uint32_t setting_frame_rate = 90;
uint32_t setting_quality = 51; uint32_t setting_quality_iframe = 51;
uint32_t setting_quality_pframe = 51;
uint32_t setting_reference_frames = 1; uint32_t setting_reference_frames = 1;
......
...@@ -231,13 +231,37 @@ bool PassTimer::evaluate_wating_passes(lava::device_ptr device, lava::index fram ...@@ -231,13 +231,37 @@ bool PassTimer::evaluate_wating_passes(lava::device_ptr device, lava::index fram
if (!found) if (!found)
{ {
this->pass_statistcs.erase(this->pass_statistcs.begin() + index); bool inactive = true;
for (int32_t index = 1; index < glm::min((uint32_t)PASS_TIMER_STATISTIC_INACTIVE_FRAMES, (uint32_t)this->frame_statistics.size()); index++)
{
uint32_t old_index = (this->frame_statistics.size() - 1) - index;
FrameStatistic old_statistic = this->frame_statistics[old_index];
for (const PassStatistic& pass_statistic : old_statistic)
{
if (statistic->get_name() == pass_statistic.name)
{
inactive = false;
break;
}
} }
else if (!inactive)
{ {
index++; break;
}
} }
if (inactive)
{
this->pass_statistcs.erase(this->pass_statistcs.begin() + index);
continue;
}
}
index++;
} }
for (const PassStatistic& pass_statistic : frame_statistic) for (const PassStatistic& pass_statistic : frame_statistic)
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "utility/statistic.hpp" #include "utility/statistic.hpp"
#define PASS_TIMER_STATISTIC_INACTIVE_FRAMES 128
struct PassWaitInfo struct PassWaitInfo
{ {
std::string name; std::string name;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment