https://github.com/gen2brain/jpegn
Baseline JPEG decoder with SIMD optimizations
https://github.com/gen2brain/jpegn
Last synced: 10 months ago
JSON representation
Baseline JPEG decoder with SIMD optimizations
- Host: GitHub
- URL: https://github.com/gen2brain/jpegn
- Owner: gen2brain
- License: mit
- Created: 2025-08-28T20:21:48.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-28T20:33:05.000Z (10 months ago)
- Last Synced: 2025-08-29T02:06:47.512Z (10 months ago)
- Language: Go
- Size: 401 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## jpegn
[](https://github.com/gen2brain/jpegn/actions)
[](https://pkg.go.dev/github.com/gen2brain/jpegn)
Baseline JPEG decoder with SIMD optimizations. It is based on [NanoJPEG](https://keyj.emphy.de/nanojpeg/).
For unsupported formats, such as progressive or CMYK JPEGs, it gracefully falls back to the standard `image/jpeg`.
### Benchmark
Compared to the standard library:
```
BenchmarkDecode420-8 1062 1222948 ns/op 426839 B/op 6 allocs/op
BenchmarkDecode420StdLib-8 542 2156193 ns/op 407088 B/op 5 allocs/op
BenchmarkDecodeConfig-8 1442437 859.4 ns/op 53 B/op 1 allocs/op
BenchmarkDecodeConfigStdLib-8 758470 1369 ns/op 13616 B/op 2 allocs/op
BenchmarkDecodeToRGBANearestNeighbor-8 517 2353340 ns/op 1999821 B/op 10 allocs/op
BenchmarkDecodeToRGBACatmullRom-8 546 2180485 ns/op 2263200 B/op 13 allocs/op
BenchmarkDecodeToRGBAStdLib-8 414 2903516 ns/op 1455734 B/op 7 allocs/op
```
Difference with assembly optimizations:
```
benchmark old ns/op new ns/op delta
BenchmarkDecode420-8 1621872 1068240 -34.14%
BenchmarkDecodeConfig-8 824 754 -8.46%
BenchmarkDecodeToRGBANearestNeighbor-8 2726279 2071692 -24.01%
BenchmarkDecodeToRGBACatmullRom-8 4068463 2156728 -46.99%
BenchmarkIdct-8 135 40.7 -69.93%
BenchmarkUpsampleNearestNeighbor-8 318541 124015 -61.07%
BenchmarkUpsampleCatmullRom-8 3548015 411422 -88.40%
```
### Build tags
* `noasm` - do not use SIMD optimizations