Adding ability to override webp benchmark value

This commit is contained in:
Rodwin Spruel 2025-04-22 11:22:20 +00:00
parent dc75e98344
commit 60f015b199
5 changed files with 19 additions and 3 deletions

View File

@ -395,7 +395,7 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,
screenArea = pb->getRect().width() * pb->getRect().height(); screenArea = pb->getRect().width() * pb->getRect().height();
screenArea *= 1024; screenArea *= 1024;
screenArea /= 256 * 256; screenArea /= 256 * 256;
screenArea *= webpBenchResult; screenArea *= screenArea *= Server::webpEncodingTime > 0 ? Server::webpEncodingTime : webpBenchResult;
// Encoding the entire screen would take this many 1024*msecs, worst case // Encoding the entire screen would take this many 1024*msecs, worst case
// Calculate how many us we can send webp for, before switching to jpeg // Calculate how many us we can send webp for, before switching to jpeg

View File

@ -287,3 +287,8 @@ rfb::PresetParameter rfb::Server::preferBandwidth
("PreferBandwidth", ("PreferBandwidth",
"Set various options for lower bandwidth use. The default is off, aka to prefer quality.", "Set various options for lower bandwidth use. The default is off, aka to prefer quality.",
false, bandwidthPreset); false, bandwidthPreset);
rfb::IntParameter rfb::Server::webpEncodingTime
("udpPort",
"Sets the benchmak WebP encoding time in KasmVNC. Default is calculated in TightWEBPEncoder benchmark function",
0, 0, 10000);

View File

@ -91,6 +91,7 @@ namespace rfb {
static BoolParameter ignoreClientSettingsKasm; static BoolParameter ignoreClientSettingsKasm;
static BoolParameter selfBench; static BoolParameter selfBench;
static PresetParameter preferBandwidth; static PresetParameter preferBandwidth;
static IntParameter webpEncodingTime;
}; };
}; };

View File

@ -259,13 +259,14 @@ void TightWEBPEncoder::writeRect(const PixelBuffer* pb, const Palette& palette)
WebPMemoryWriterClear(&wrt); WebPMemoryWriterClear(&wrt);
} }
// How many milliseconds would it take to encode a 256x256 block at quality 8 // How many milliseconds would it take to encode a 256x256 block at quality 5
rdr::U32 TightWEBPEncoder::benchmark() const rdr::U32 TightWEBPEncoder::benchmark() const
{ {
rdr::U8* buffer; rdr::U8* buffer;
struct timeval start; struct timeval start;
int stride, i; int stride, i;
const uint8_t quality = 8, method = 2; // the minimum WebP quality settings used in KasmVNC
const uint8_t quality = 5, method = 0;
WebPConfig cfg; WebPConfig cfg;
WebPPicture pic; WebPPicture pic;
WebPMemoryWriter wrt; WebPMemoryWriter wrt;

View File

@ -2068,6 +2068,15 @@ sub DefineConfigToCLIConversion {
$value; $value;
} }
}), }),
KasmVNC::CliOption->new({
name => 'webpEncodingTime',
configKeys => [
KasmVNC::ConfigKey->new({
name => "encoding.video_encoding_mode.webp_encoding_time",
type => KasmVNC::ConfigKey::INT
})
]
}),
KasmVNC::CliOption->new({ KasmVNC::CliOption->new({
name => 'CompareFB', name => 'CompareFB',
configKeys => [ configKeys => [