libjpeg-turbo+libwebp: 5-MOAD scan; libjpeg-turbo-0001 CWE-407, libwebp CLEAN

libjpeg-turbo-0001: rdcolmap.c add_map_entry() O(P*C) linear color dedup.
For each pixel in a PPM colormap file, a linear scan checks the palette
(up to 256 entries). With large images (JPEG_MAX_DIMENSION=65500) and a
saturated palette, cost reaches O(W*H*256). Fix: open-addressing hash set
resets once per _read_color_map() call, giving O(1) average per pixel.
Measured 128-131x speedup. 7/7 unit tests PASS.

libwebp: CLEAN on all 5 MOADs. GetColorPalette uses open-addressing hash,
backward references use hash chains, palette sort O(N^2) bounded to N<=256
once per image, DSP init uses mutex-protected lazy initialization.
This commit is contained in:
russell@unturf.com 2026-03-31 22:36:56 -04:00
parent 7dce7a73c5
commit 8a3fc56b23
5 changed files with 505 additions and 1 deletions

View file

@ -91,6 +91,7 @@ SUPPORT_ALL := support/TarjanAlgorithm.java \
unit-nim-0001 unit-nim-0002 \
unit-nomad unit-consul \
unit-ray unit-celery unit-prefect \
unit-libjpeg-turbo-0001 \
bench-mc-server bench-max bench-gumyum bench-everything bench-loadsim bench-elytra \
bench-unpatched bench-mitigated bench-enriched bench-three-tier \
play-unpatched play-mitigated play-enriched \
@ -140,7 +141,8 @@ unit: unit-tarjan unit-findnode unit-closure unit-toposort unit-deplist unit-bou
unit-elixir-0001 \
unit-nim-0001 unit-nim-0002 \
unit-nomad unit-consul \
unit-ray unit-celery unit-prefect
unit-ray unit-celery unit-prefect \
unit-libjpeg-turbo-0001
unit-tarjan: unit/TarjanComplexityTest.class
@echo ""
@ -1165,6 +1167,16 @@ workbench-verify: workbench/Workbench.class
@$(JAVA) $(PATCH_FLAG) $(WB_EXPORTS) -cp . workbench.PatchVerifier; \
if [ $$? -eq 0 ]; then echo "STATUS: PATCHED"; else echo "STATUS: UNPATCHED"; fi
# ── libjpeg-turbo ─────────────────────────────────────────────────────────────
unit-libjpeg-turbo-0001: unit/LibjpegTurbo0001Test.class
@echo ""
@echo "=== libjpeg-turbo-0001: rdcolmap add_map_entry O(P*C) -> O(P) ==="
$(JAVA) -ea -cp . unit.LibjpegTurbo0001Test
unit/LibjpegTurbo0001Test.class: ../defects/libjpeg-turbo-0001/unit/LibjpegTurbo0001Test.java
$(JAVAC) -cp . -d . ../defects/libjpeg-turbo-0001/unit/LibjpegTurbo0001Test.java
# ── Clean ─────────────────────────────────────────────────────────────────────
clean: