vk-video-ffi: report H.264 Constrained Baseline encode; hw_config checks Main and CB vs VA
Browse files at this commit42021c7b90668570b007ebf18eebcbba5699c485Parent: a63faef2 changed files +14 -7
crates/ec-hw/examples/hw_config.rsmodified+13 -7
| @@ -23,7 +23,7 @@ const FIELDS: [&str; 7] = [ | ||
| 23 | 23 | "color_range", |
| 24 | 24 | ]; |
| 25 | 25 | |
| 26 | -fn config() -> EncoderConfig { | |
| 26 | +fn config(profile: H264Profile) -> EncoderConfig { | |
| 27 | 27 | EncoderConfig { |
| 28 | 28 | bitrate: BITRATE, |
| 29 | 29 | framerate: (FPS, 1), |
| @@ -31,7 +31,7 @@ fn config() -> EncoderConfig { | ||
| 31 | 31 | rate_control: RateControlMode::ConstantBitrate, |
| 32 | 32 | ..EncoderConfig::new(EncCodec::H264, WIDTH, HEIGHT) |
| 33 | 33 | } |
| 34 | - .h264_profile(H264Profile::Main) | |
| 34 | + .h264_profile(profile) | |
| 35 | 35 | .colour(6, 6, 6, true) |
| 36 | 36 | } |
| 37 | 37 | |
| @@ -50,8 +50,8 @@ fn frame(t: usize) -> I420 { | ||
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -fn encode(dir: &Path, name: &str, backend: Backend) -> Option<PathBuf> { | |
| 54 | - let mut encoder = match HwEncoder::open(config(), Some(backend)) { | |
| 53 | +fn encode(dir: &Path, name: &str, profile: H264Profile, backend: Backend) -> Option<PathBuf> { | |
| 54 | + let mut encoder = match HwEncoder::open(config(profile), Some(backend)) { | |
| 55 | 55 | Ok(encoder) => encoder, |
| 56 | 56 | Err(e) => { |
| 57 | 57 | println!("{name}: {e}"); |
| @@ -117,10 +117,16 @@ fn value(info: &[(String, String)], key: &str) -> String { | ||
| 117 | 117 | |
| 118 | 118 | fn main() { |
| 119 | 119 | let dir = PathBuf::from(std::env::args().nth(1).expect("scratch dir argument")); |
| 120 | - let Some(vk) = encode(&dir, "vk", Backend::Vk) else { | |
| 120 | + for (label, profile) in [("main", H264Profile::Main), ("cb", H264Profile::ConstrainedBaseline)] { | |
| 121 | + compare(&dir, label, profile); | |
| 122 | + } | |
| 123 | +} | |
| 124 | + | |
| 125 | +fn compare(dir: &Path, label: &str, profile: H264Profile) { | |
| 126 | + let Some(vk) = encode(dir, &format!("vk_{label}"), profile, Backend::Vk) else { | |
| 121 | 127 | return; |
| 122 | 128 | }; |
| 123 | - let Some(va) = encode(&dir, "va", Backend::Va) else { | |
| 129 | + let Some(va) = encode(dir, &format!("va_{label}"), profile, Backend::Va) else { | |
| 124 | 130 | return; |
| 125 | 131 | }; |
| 126 | 132 | let (vk_info, va_info) = (probe(&vk), probe(&va)); |
| @@ -135,5 +141,5 @@ fn main() { | ||
| 135 | 141 | same &= kv == ka; |
| 136 | 142 | let list = |k: &[usize]| k.iter().map(usize::to_string).collect::<Vec<_>>().join(","); |
| 137 | 143 | println!("{:<16}{:<16}{:<16}", "keyframes", list(&kv), list(&ka)); |
| 138 | - println!("match: {same}"); | |
| 144 | + println!("{label} match: {same}"); | |
| 139 | 145 | } |
shims/vk-video-ffi/src/lib.rsmodified+1 -0
| @@ -367,6 +367,7 @@ impl Gpu { | ||
| 367 | 367 | /// Capabilities of every codec, profile and direction the device supports. |
| 368 | 368 | pub fn caps(&self) -> Vec<CodecCaps> { |
| 369 | 369 | [ |
| 370 | + (Codec::H264, Direction::Encode, CodecProfile::H264ConstrainedBaseline), | |
| 370 | 371 | (Codec::H264, Direction::Encode, CodecProfile::H264Main), |
| 371 | 372 | (Codec::H264, Direction::Encode, CodecProfile::H264High), |
| 372 | 373 | (Codec::H264, Direction::Decode, CodecProfile::H264ConstrainedBaseline), |