Description
I'm writing a new client for Second Life/Open Simulator, using Rend3->WGPU->Vulkan, and need a fast JPEG 2000 decoder.
Demo videos:
- https://vimeo.com/553030168 [From 2021, rather slow]
- https://vimeo.com/user28693218 [From 2022, faster]
- https://video.hardlimit.com/w/peBesyAgtzfRWS5FnDQQtn [Latest video, faster with better rendering]
So now that things are starting to work, I have performance problems. A big bottleneck is JPEG 2000 decoding. All Second Life content is encoded with JPEG 2000, multi-resolution, highest resolution lossless. JPEG 2000 decoding is the major bottleneck on content loading, even with several CPUs working in parallel. (All the content comes from servers; it's a metaverse. The world is the size of Los Angeles, and you can drive or fly, so you do a lot of content decoding.)
There are several JPEG 2000 decoders available:
Free:
-
OpenJPEG - C, reference implementation, very slow. (I'm using that now). There are three Rust crates which link to this: jpeg2k, bevy-jpeg2k, and openjpeg.sys. The C code underneath is notorious for buffer overflows and has been the subject of three CERT security advisories.
-
JPEG 2000 on Github - pure Rust implementation, underway for a year, stalled, developer needs help. Read the issues for a status report. It's a promising start, but right now it just decodes the header.
Commercial:
-
Kakadu - C++, No Rust linkage yet, about 10x faster than OpenJPEG, very expensive to license. (The Firestorm viewer for Second Life uses it, and that license is their biggest expense.)
-
Grok - C++. either expensive to license or limited to Affero GPL use. About as fast as Kakadu. Open source, so you can look and see how they do it. Rust bindings in grokj2k-sys Currently won't build on Ubuntu 20.04 LTS due to a dependency that should be fixed in Ubuntu 22.04 LTS.
-
nvJPEG2000 - from NVidia. Requires an NVidia GPU. (of course).
-
https://www.j2k-codec.com/ - Commercial, opaque binary blob from Russia, Windows only.
So, if anyone is interested, the pure Rust implementation on Github needs developers. You can look at Grok and see how they do it.
Ideally, JPEG 2000 would be implemented as another codec for Rust's "image" crate.