mmastrac 4 days ago

Rust allows for manual struct layout with #[repr(C)] (with some limits, but rav1d uses it heavily - https://github.com/search?q=repo%3Amemorysafety%2Frav1d%20%2...), so some of this could likely be ported over to rav1d as well. I believe there's an occasional re-sync with the dav1d code, so it's entirely possible this ends up making both projects faster.

You can see the struct the author of this PR modified here: https://github.com/memorysafety/rav1d/blob/main/include/dav1...

Interesting tool linked by the author: https://linux.die.net/man/1/pahole

1
tialaramex 4 days ago

It makes sense that rav1d would need a bunch of repr(C) because the initial conversion is just mindlessly derived from the C, so if there's C which just bit-copies part of a data structure this cannot possibly work in Rust unless we explicitly say "This structure needs to be laid out the same as in C".

It also sounds as though at least some of this "speed up" was assuming dav1d doesn't need big integers where actually it does, but only for larger images. I can well imagine that DVD resolution works fine with 16-bit variables where the Ultra HD blows up nastily.