6 releases (breaking)
| 0.4.0 | Jul 23, 2024 |
|---|---|
| 0.3.0 | Apr 30, 2024 |
| 0.2.0 | Mar 11, 2024 |
| 0.1.2 |
|
| 0.0.0 | Nov 7, 2023 |
#1391 in Images
385 downloads per month
1.5MB
3K
SLoC
WebGPU compute shader JPEG decoder.
Usage:
- Create a [
Gpu] context (either automatically viaGpu::openor from an existingwgpucontext viaGpu::from_wgpu). - Create a
Decoder(or multiple) viaDecoder::new. - For each JPEG image you want to decode, create an
ImageDataobject and pass it toDecoder::start_decode. - Access the output
TextureviaDecodeOp::texture.
This is an experiment to use WebGPU Compute Shaders to decode JPEG images. The main Purpose of this project is to learn how to write compute shaders.
It performs surprisingly well on my RX 6700 XT, with GPU times of around 1 ms at high GPU clocks (and 2ms spent doing preprocessing on the CPU) when decoding a 4k test image.
The approach used here is restricted to baseline JPEGs that make heavy use of restart intervals. These types of JPEGs are typically produced by hardware encoders in GPUs, phones and webcams.
Due to technical limitations, only YUV JPEGs that make use of 4:2:2 chroma subsampling are supported. In the future this restriction may be lifted.
Dependencies
~3–36MB
~481K SLoC