Repository navigation
Commit 4bf2c55
AVIF: decode in worker threads
From 4 megapixels on (by the item's ispe), threads start before the AV1
image is decoded, so they load meanwhile, and convert it to RGB in bands
of 64 rows (planes and tables in shared memory, the pixels copied out);
grids decode their tiles in parallel (at least 4 tiles per thread: each
one warms the whole AV1 decoder up), the tiles' data in one shared
buffer. avif.decode is async now and takes threads. A row function for
4:2:0/4:2:2 colors with the weighted chroma samples as tables (the same
Float32 values) converts about 7% faster on one thread.
The same pixels on 368 files (tests, av1-avif, libavif, Pillow and
PureJsImage corpora) with 1 and 4 threads; two fixtures above the
threshold (2048x2048, a 3x2 grid of 1024x704 tiles) with libavif's
pixels. Ryzen 7 5800X, 8 threads: 3840x2160 4:2:0 466 -> 355 ms,
6400x2880 grid of 20 tiles 2.68 -> 1.12 s; 4:4:4 and 1080p unchanged
(the AV1 decode dominates).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BsU2GAqbnFSNaYDBGD1Km21 parent e8888eb commit 4bf2c55
8 files changed
Lines changed: 214 additions & 82 deletions
File tree
- scripts
- src
- codecs
- util
- tests
- avif
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
297 | 308 | | |
298 | 309 | | |
299 | 310 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
2262 | 2263 | | |
2263 | 2264 | | |
2264 | 2265 | | |
2265 | | - | |
| 2266 | + | |
2266 | 2267 | | |
2267 | 2268 | | |
2268 | 2269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
Binary file not shown.
Binary file not shown.
0 commit comments