diff --git a/crates/ec-hw/examples/hw_config.rs b/crates/ec-hw/examples/hw_config.rs index 267c080c..eaeb49ed 100644 --- a/crates/ec-hw/examples/hw_config.rs +++ b/crates/ec-hw/examples/hw_config.rs @@ -23,7 +23,7 @@ const FIELDS: [&str; 7] = [ "color_range", ]; -fn config() -> EncoderConfig { +fn config(profile: H264Profile) -> EncoderConfig { EncoderConfig { bitrate: BITRATE, framerate: (FPS, 1), @@ -31,7 +31,7 @@ fn config() -> EncoderConfig { rate_control: RateControlMode::ConstantBitrate, ..EncoderConfig::new(EncCodec::H264, WIDTH, HEIGHT) } - .h264_profile(H264Profile::Main) + .h264_profile(profile) .colour(6, 6, 6, true) } @@ -50,8 +50,8 @@ fn frame(t: usize) -> I420 { } } -fn encode(dir: &Path, name: &str, backend: Backend) -> Option { - let mut encoder = match HwEncoder::open(config(), Some(backend)) { +fn encode(dir: &Path, name: &str, profile: H264Profile, backend: Backend) -> Option { + let mut encoder = match HwEncoder::open(config(profile), Some(backend)) { Ok(encoder) => encoder, Err(e) => { println!("{name}: {e}"); @@ -117,10 +117,16 @@ fn value(info: &[(String, String)], key: &str) -> String { fn main() { let dir = PathBuf::from(std::env::args().nth(1).expect("scratch dir argument")); - let Some(vk) = encode(&dir, "vk", Backend::Vk) else { + for (label, profile) in [("main", H264Profile::Main), ("cb", H264Profile::ConstrainedBaseline)] { + compare(&dir, label, profile); + } +} + +fn compare(dir: &Path, label: &str, profile: H264Profile) { + let Some(vk) = encode(dir, &format!("vk_{label}"), profile, Backend::Vk) else { return; }; - let Some(va) = encode(&dir, "va", Backend::Va) else { + let Some(va) = encode(dir, &format!("va_{label}"), profile, Backend::Va) else { return; }; let (vk_info, va_info) = (probe(&vk), probe(&va)); @@ -135,5 +141,5 @@ fn main() { same &= kv == ka; let list = |k: &[usize]| k.iter().map(usize::to_string).collect::>().join(","); println!("{:<16}{:<16}{:<16}", "keyframes", list(&kv), list(&ka)); - println!("match: {same}"); + println!("{label} match: {same}"); } diff --git a/shims/vk-video-ffi/src/lib.rs b/shims/vk-video-ffi/src/lib.rs index d912291e..32ecd5ed 100644 --- a/shims/vk-video-ffi/src/lib.rs +++ b/shims/vk-video-ffi/src/lib.rs @@ -367,6 +367,7 @@ impl Gpu { /// Capabilities of every codec, profile and direction the device supports. pub fn caps(&self) -> Vec { [ + (Codec::H264, Direction::Encode, CodecProfile::H264ConstrainedBaseline), (Codec::H264, Direction::Encode, CodecProfile::H264Main), (Codec::H264, Direction::Encode, CodecProfile::H264High), (Codec::H264, Direction::Decode, CodecProfile::H264ConstrainedBaseline),