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] = [
23 "color_range",23 "color_range",
24 ];24 ];
25 25
26-fn config() -> EncoderConfig {26+fn config(profile: H264Profile) -> EncoderConfig {
27 EncoderConfig {27 EncoderConfig {
28 bitrate: BITRATE,28 bitrate: BITRATE,
29 framerate: (FPS, 1),29 framerate: (FPS, 1),
@@ -31,7 +31,7 @@ fn config() -> EncoderConfig {
31 rate_control: RateControlMode::ConstantBitrate,31 rate_control: RateControlMode::ConstantBitrate,
32 ..EncoderConfig::new(EncCodec::H264, WIDTH, HEIGHT)32 ..EncoderConfig::new(EncCodec::H264, WIDTH, HEIGHT)
33 }33 }
34- .h264_profile(H264Profile::Main)34+ .h264_profile(profile)
35 .colour(6, 6, 6, true)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> {53+fn encode(dir: &Path, name: &str, profile: H264Profile, backend: Backend) -> Option<PathBuf> {
54- let mut encoder = match HwEncoder::open(config(), Some(backend)) {54+ let mut encoder = match HwEncoder::open(config(profile), Some(backend)) {
55 Ok(encoder) => encoder,55 Ok(encoder) => encoder,
56 Err(e) => {56 Err(e) => {
57 println!("{name}: {e}");57 println!("{name}: {e}");
@@ -117,10 +117,16 @@ fn value(info: &[(String, String)], key: &str) -> String {
117 117
118 fn main() {118 fn main() {
119 let dir = PathBuf::from(std::env::args().nth(1).expect("scratch dir argument"));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 return;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 return;130 return;
125 };131 };
126 let (vk_info, va_info) = (probe(&vk), probe(&va));132 let (vk_info, va_info) = (probe(&vk), probe(&va));
@@ -135,5 +141,5 @@ fn main() {
135 same &= kv == ka;141 same &= kv == ka;
136 let list = |k: &[usize]| k.iter().map(usize::to_string).collect::<Vec<_>>().join(",");142 let list = |k: &[usize]| k.iter().map(usize::to_string).collect::<Vec<_>>().join(",");
137 println!("{:<16}{:<16}{:<16}", "keyframes", list(&kv), list(&ka));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 /// Capabilities of every codec, profile and direction the device supports.367 /// Capabilities of every codec, profile and direction the device supports.
368 pub fn caps(&self) -> Vec<CodecCaps> {368 pub fn caps(&self) -> Vec<CodecCaps> {
369 [369 [
370+ (Codec::H264, Direction::Encode, CodecProfile::H264ConstrainedBaseline),
370 (Codec::H264, Direction::Encode, CodecProfile::H264Main),371 (Codec::H264, Direction::Encode, CodecProfile::H264Main),
371 (Codec::H264, Direction::Encode, CodecProfile::H264High),372 (Codec::H264, Direction::Encode, CodecProfile::H264High),
372 (Codec::H264, Direction::Decode, CodecProfile::H264ConstrainedBaseline),373 (Codec::H264, Direction::Decode, CodecProfile::H264ConstrainedBaseline),