forge
Explore
Log in

Don't you dare go Hollow

vk-video-ffi: report H.264 Constrained Baseline encode; hw_config checks Main and CB vs VA

Browse files at this commit

42021c7b90668570b007ebf18eebcbba5699c485Ahmet Kaan GümüşParent: a63faef
crates/ec-hw/examples/hw_config.rsmodified+13 -7
@@ -23,7 +23,7 @@ const FIELDS: [&str; 7] = [
2323 "color_range",
2424 ];
2525
26-fn config() -> EncoderConfig {
26+fn config(profile: H264Profile) -> EncoderConfig {
2727 EncoderConfig {
2828 bitrate: BITRATE,
2929 framerate: (FPS, 1),
@@ -31,7 +31,7 @@ fn config() -> EncoderConfig {
3131 rate_control: RateControlMode::ConstantBitrate,
3232 ..EncoderConfig::new(EncCodec::H264, WIDTH, HEIGHT)
3333 }
34- .h264_profile(H264Profile::Main)
34+ .h264_profile(profile)
3535 .colour(6, 6, 6, true)
3636 }
3737
@@ -50,8 +50,8 @@ fn frame(t: usize) -> I420 {
5050 }
5151 }
5252
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)) {
5555 Ok(encoder) => encoder,
5656 Err(e) => {
5757 println!("{name}: {e}");
@@ -117,10 +117,16 @@ fn value(info: &[(String, String)], key: &str) -> String {
117117
118118 fn main() {
119119 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 {
121127 return;
122128 };
123- let Some(va) = encode(&dir, "va", Backend::Va) else {
129+ let Some(va) = encode(dir, &format!("va_{label}"), profile, Backend::Va) else {
124130 return;
125131 };
126132 let (vk_info, va_info) = (probe(&vk), probe(&va));
@@ -135,5 +141,5 @@ fn main() {
135141 same &= kv == ka;
136142 let list = |k: &[usize]| k.iter().map(usize::to_string).collect::<Vec<_>>().join(",");
137143 println!("{:<16}{:<16}{:<16}", "keyframes", list(&kv), list(&ka));
138- println!("match: {same}");
144+ println!("{label} match: {same}");
139145 }
shims/vk-video-ffi/src/lib.rsmodified+1 -0
@@ -367,6 +367,7 @@ impl Gpu {
367367 /// Capabilities of every codec, profile and direction the device supports.
368368 pub fn caps(&self) -> Vec<CodecCaps> {
369369 [
370+ (Codec::H264, Direction::Encode, CodecProfile::H264ConstrainedBaseline),
370371 (Codec::H264, Direction::Encode, CodecProfile::H264Main),
371372 (Codec::H264, Direction::Encode, CodecProfile::H264High),
372373 (Codec::H264, Direction::Decode, CodecProfile::H264ConstrainedBaseline),