Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up RemoteFX encoding #571

Merged
merged 11 commits into from
Nov 5, 2024
205 changes: 205 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ categories = ["network-programming"]
ironrdp-acceptor = { version = "0.1", path = "crates/ironrdp-acceptor" }
ironrdp-ainput = { version = "0.1", path = "crates/ironrdp-ainput" }
ironrdp-async = { version = "0.1", path = "crates/ironrdp-async" }
ironrdp-bench = { version = "0.1", path = "crates/ironrdp-bench" }
ironrdp-blocking = { version = "0.1", path = "crates/ironrdp-blocking" }
ironrdp-cliprdr = { version = "0.1", path = "crates/ironrdp-cliprdr" }
ironrdp-cliprdr-native = { version = "0.1", path = "crates/ironrdp-cliprdr-native" }
Expand Down
26 changes: 26 additions & 0 deletions crates/ironrdp-bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "ironrdp-bench"
version = "0.0.0"
description = "IronRDP benchmarks"
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
authors.workspace = true
keywords.workspace = true
categories.workspace = true
publish = false

[dev-dependencies]
criterion = "0.5"
ironrdp-graphics.workspace = true
ironrdp-pdu.workspace = true
ironrdp-server = { workspace = true, features = ["__bench"] }

[[bench]]
name = "bench"
path = "benches/bench.rs"
harness = false

[lints]
workspace = true
58 changes: 58 additions & 0 deletions crates/ironrdp-bench/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use std::num::NonZero;

use criterion::{criterion_group, criterion_main, Criterion};
use ironrdp_graphics::color_conversion::to_64x64_ycbcr_tile;
use ironrdp_pdu::codecs::rfx;
use ironrdp_server::{
bench::encoder::rfx::{rfx_enc, rfx_enc_tile},
BitmapUpdate,
};

pub fn rfx_enc_tile_bench(c: &mut Criterion) {
let quant = rfx::Quant::default();
let algo = rfx::EntropyAlgorithm::Rlgr3;
let bitmap = BitmapUpdate {
top: 0,
left: 0,
width: NonZero::new(64).unwrap(),
height: NonZero::new(64).unwrap(),
format: ironrdp_server::PixelFormat::ARgb32,
data: vec![0; 64 * 64 * 4],
order: ironrdp_server::PixelOrder::BottomToTop,
stride: 64 * 4,
};
c.bench_function("rfx_enc_tile", |b| b.iter(|| rfx_enc_tile(&bitmap, &quant, algo, 0, 0)));
}

pub fn rfx_enc_bench(c: &mut Criterion) {
let quant = rfx::Quant::default();
let algo = rfx::EntropyAlgorithm::Rlgr3;
let bitmap = BitmapUpdate {
top: 0,
left: 0,
width: NonZero::new(2048).unwrap(),
height: NonZero::new(2048).unwrap(),
format: ironrdp_server::PixelFormat::ARgb32,
data: vec![0; 2048 * 2048 * 4],
order: ironrdp_server::PixelOrder::BottomToTop,
stride: 64 * 4,
};
c.bench_function("rfx_enc", |b| b.iter(|| rfx_enc(&bitmap, &quant, algo)));
}

pub fn to_ycbcr_bench(c: &mut Criterion) {
const WIDTH: usize = 64;
const HEIGHT: usize = 64;
let input = vec![0; WIDTH * HEIGHT * 4];
let stride = WIDTH * 4;
let mut y = [0i16; WIDTH * HEIGHT];
let mut cb = [0i16; WIDTH * HEIGHT];
let mut cr = [0i16; WIDTH * HEIGHT];
let format = ironrdp_graphics::image_processing::PixelFormat::ARgb32;
c.bench_function("to_ycbcr", |b| {
b.iter(|| to_64x64_ycbcr_tile(&input, WIDTH, HEIGHT, stride, format, &mut y, &mut cb, &mut cr))
});
}

criterion_group!(benches, rfx_enc_tile_bench, rfx_enc_bench, to_ycbcr_bench);
criterion_main!(benches);
Loading