forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/w0-s1' into simplify/w0

Browse files at this commit

b8a94617b9d7f6d5fc274249084a1fc91b58c99aAhmet Kaan GümüşParent: f5daf6f131405c
crates/ec-image/fuzz/seed.shmodified+3 -4
@@ -1,7 +1,7 @@
11 #!/usr/bin/env bash
22 # seed.sh: fill fuzz/corpus/<target>/ from the repo's still-image fixtures.
33 #
4-# Every file under fixtures/stills (PNG, JPEG, WebP, GIF, BMP, TIFF) seeds the whole-file targets:
4+# Every file under tests/data/stills (PNG, JPEG, WebP, GIF, BMP, TIFF) seeds the whole-file targets:
55 # decode, decode_with_limits, info, probe, decode_animation. Each format target gets only the files of its
66 # own format, so its corpus starts on the right signature. The VP8 frames under fixtures/vp8 are
77 # VP8 bitstreams, not stills, and are not used here.
@@ -10,9 +10,8 @@
1010 set -euo pipefail
1111
1212 FUZZ_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
13-ROOT=$(cd -- "$FUZZ_DIR/../../.." && pwd)
14-STILLS="$ROOT/fixtures/stills"
15-[ -d "$STILLS" ] || { echo "seed.sh: $STILLS missing; run scripts/link-fixtures.sh" >&2; exit 2; }
13+STILLS="$FUZZ_DIR/../tests/data/stills"
14+[ -d "$STILLS" ] || { echo "seed.sh: $STILLS missing" >&2; exit 2; }
1615
1716 CORPUS="$FUZZ_DIR/corpus"
1817 mkdir -p "$CORPUS"/{decode,decode_with_limits,info,probe,decode_animation,bmp,gif,jpeg,png,tiff,webp}
scripts/gen-still-fixtures.sh → crates/ec-image/tests/data/gen-stills.shrenamed+20 -18
@@ -8,15 +8,17 @@
88 # JPEG variants, ffmpeg the WebP ones.
99 set -euo pipefail
1010
11-root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
12-out="$root/fixtures/stills"
11+root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+out="$root/stills"
1313 mkdir -p "$out"
1414
1515 need() {
1616 command -v "$1" >/dev/null || { echo "missing: $1" >&2; exit 1; }
1717 }
1818 need magick
19-need ffmpeg
19+FF=${EC_FFMPEG:-$HOME/.cache/ec-ffmpeg/ffmpeg}
20+[ -x "$FF" ] || { echo "missing pinned ffmpeg: $FF (set EC_FFMPEG)" >&2; exit 1; }
21+[[ $("$FF" -version) == "ffmpeg version 9.0.2 "* ]] || { echo "ffmpeg is not the pinned 9.0.2" >&2; exit 1; }
2022
2123 # Source pictures: one with smooth and hard content at even dimensions, one at
2224 # odd dimensions (chroma subsampling and Adam7 both round there), and one with
@@ -70,22 +72,22 @@ magick "$out/source-odd.png" -quality 90 -sampling-factor 2x2 "$out/odd-420.jpg"
7072 magick "$out/source-odd.png" -quality 90 -sampling-factor 2x1 "$out/odd-422.jpg"
7173
7274 # --- WebP: lossy and lossless, with and without alpha ----------------------
73-ffmpeg -loglevel error -y -i "$out/source.png" -c:v libwebp -lossless 0 -quality 80 \
75+"$FF" -loglevel error -y -i "$out/source.png" -c:v libwebp -lossless 0 -quality 80 \
7476 "$out/lossy.webp"
75-ffmpeg -loglevel error -y -i "$out/source.png" -c:v libwebp -lossless 0 -quality 40 \
77+"$FF" -loglevel error -y -i "$out/source.png" -c:v libwebp -lossless 0 -quality 40 \
7678 "$out/lossy-q40.webp"
77-ffmpeg -loglevel error -y -i "$out/source.png" -c:v libwebp -lossless 1 "$out/lossless.webp"
78-ffmpeg -loglevel error -y -i "$out/source-alpha.png" -c:v libwebp -lossless 1 \
79+"$FF" -loglevel error -y -i "$out/source.png" -c:v libwebp -lossless 1 "$out/lossless.webp"
80+"$FF" -loglevel error -y -i "$out/source-alpha.png" -c:v libwebp -lossless 1 \
7981 "$out/lossless-alpha.webp"
80-ffmpeg -loglevel error -y -i "$out/source-alpha.png" -c:v libwebp -lossless 0 -quality 80 \
82+"$FF" -loglevel error -y -i "$out/source-alpha.png" -c:v libwebp -lossless 0 -quality 80 \
8183 "$out/lossy-alpha.webp"
82-ffmpeg -loglevel error -y -i "$out/source-odd.png" -c:v libwebp -lossless 0 -quality 80 \
84+"$FF" -loglevel error -y -i "$out/source-odd.png" -c:v libwebp -lossless 0 -quality 80 \
8385 "$out/odd-lossy.webp"
84-ffmpeg -loglevel error -y -i "$out/source-odd.png" -c:v libwebp -lossless 1 "$out/odd-lossless.webp"
86+"$FF" -loglevel error -y -i "$out/source-odd.png" -c:v libwebp -lossless 1 "$out/odd-lossless.webp"
8587 # A palette-friendly picture, so the lossless colour-indexing transform is
8688 # exercised rather than only the predictor one.
8789 magick "$out/source.png" -colors 8 "$out/source-flat.png"
88-ffmpeg -loglevel error -y -i "$out/source-flat.png" -c:v libwebp -lossless 1 \
90+"$FF" -loglevel error -y -i "$out/source-flat.png" -c:v libwebp -lossless 1 \
8991 "$out/lossless-palette.webp"
9092 # An animation, which the decoder must refuse by name rather than decode.
9193 # ffmpeg's libwebp_anim silently writes a single still here, so ImageMagick
@@ -108,8 +110,8 @@ rm -f "$out/anim-a.png" "$out/anim-b.png" "$out/anim-c.png"
108110 # libwebp's own composited frames, through Pillow, as the reference for that
109111 # animation: the `image` crate ignores the dispose-to-background flag, so it
110112 # cannot be the oracle for the frame that follows a disposal.
111-if python3 -c "import PIL" 2>/dev/null; then
112- python3 - "$out" <<'PILLOW'
113+if python3 -I -c "import PIL" 2>/dev/null; then
114+ python3 -I - "$out" <<'PILLOW'
113115 import sys
114116 from PIL import Image
115117
@@ -158,7 +160,7 @@ magick "$out/bmp-source.png" rgba:"$out/bmp-source.rgba"
158160 magick "$out/bmp-source-alpha.png" rgba:"$out/bmp-source-alpha.rgba"
159161 magick "$out/bmp-source.png" "$out/bmp-embed.png"
160162 magick "$out/bmp-source.png" -quality 85 "$out/bmp-embed.jpg"
161-python3 "$(dirname "$0")/lib/gen-bmp-shapes.py" "$out" "$out/bmp-source.rgba" 64 48 \
163+python3 -I "$(dirname "$0")/lib/gen-bmp-shapes.py" "$out" "$out/bmp-source.rgba" 64 48 \
162164 "$out/bmp-source-alpha.rgba" "$out/bmp-embed.png" "$out/bmp-embed.jpg"
163165 rm -f "$out/bmp-source.png" "$out/bmp-source-alpha.png" "$out/bmp-source.rgba" \
164166 "$out/bmp-source-alpha.rgba" "$out/bmp-embed.png" "$out/bmp-embed.jpg"
@@ -194,7 +196,7 @@ magick "$out/tiff-source.png" -colors 16 -type palette -depth 4 -compress None \
194196 "$out/palette4.tiff"
195197 # The incumbent refuses a 4-bit palette outright, so ffmpeg -- which reads it --
196198 # writes the reference picture for that one fixture.
197-ffmpeg -loglevel error -y -i "$out/palette4.tiff" "$out/palette4-golden.png"
199+"$FF" -loglevel error -y -i "$out/palette4.tiff" "$out/palette4-golden.png"
198200 # -alpha off, or ImageMagick attaches an alpha channel to a grey picture that
199201 # has none, and a two-sample grey file is a shape the incumbent refuses.
200202 magick "$out/tiff-source.png" -colorspace gray -alpha off -depth 8 -compress None \
@@ -206,7 +208,7 @@ magick "$out/tiff-source.png" -depth 16 -compress Zip "$out/rgb16.tiff"
206208 # the straight and the premultiplied tagging, neither of which ImageMagick will
207209 # write on request.
208210 magick "$out/tiff-source-alpha.png" rgba:"$out/tiff-source-alpha.rgba"
209-python3 "$(dirname "$0")/lib/gen-tiff-shapes.py" "$out" "$out/tiff-source-alpha.rgba" 64 48
211+python3 -I "$(dirname "$0")/lib/gen-tiff-shapes.py" "$out" "$out/tiff-source-alpha.rgba" 64 48
210212 rm -f "$out/tiff-source.png" "$out/tiff-source-alpha.png" \
211213 "$out/tiff-source-alpha.rgba"
212214
@@ -214,9 +216,9 @@ rm -f "$out/tiff-source.png" "$out/tiff-source-alpha.png" \
214216 # per format is only affordable on a picture that decodes in microseconds.
215217 magick "$out/source.png" -resize 32x24! "$out/tiny.png"
216218 magick "$out/tiny.png" -quality 80 -sampling-factor 2x2 "$out/tiny.jpg"
217-ffmpeg -loglevel error -y -i "$out/tiny.png" -c:v libwebp -lossless 0 -quality 75 \
219+"$FF" -loglevel error -y -i "$out/tiny.png" -c:v libwebp -lossless 0 -quality 75 \
218220 "$out/tiny-lossy.webp"
219-ffmpeg -loglevel error -y -i "$out/tiny.png" -c:v libwebp -lossless 1 "$out/tiny-lossless.webp"
221+"$FF" -loglevel error -y -i "$out/tiny.png" -c:v libwebp -lossless 1 "$out/tiny-lossless.webp"
220222 magick "$out/tiny.png" -colors 64 "$out/tiny.gif"
221223 magick "$out/tiny.png" -colors 64 -type palette -compress None BMP3:"$out/tiny.bmp"
222224 magick "$out/tiny.png" -depth 8 -compress LZW "$out/tiny.tiff"
scripts/lib/gen-bmp-shapes.py → crates/ec-image/tests/data/lib/gen-bmp-shapes.pyrenamed+0 -0
scripts/lib/gen-tiff-shapes.py → crates/ec-image/tests/data/lib/gen-tiff-shapes.pyrenamed+0 -0
crates/ec-image/tests/data/stills/alpha32.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/anim-alpha-f0.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/anim-alpha-f1.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/anim-alpha-f2.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/anim-alpha.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/animated.gifadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/animated.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/baseline-420-q50.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/baseline-420.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/baseline-422.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/baseline-444.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/bf565.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/bilevel.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/embedded-jpeg.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/embedded-png.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray1.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray16.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray16.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray2.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray4.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray8.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/gray8.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/graya8.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/interlaced-palette.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/interlaced-rgb8.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/interlaced-rgba16.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/interlaced.gifadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/lossless-alpha.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/lossless-palette.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/lossless.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/lossy-alpha.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/lossy-q40.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/lossy.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/mono.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd-420.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd-422.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd-interlaced.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd-lossless.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd-lossy.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd-rgb8.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd.gifadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/odd24.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/os2v1.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/os2v2.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/pal4.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/pal8.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/palette1.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/palette2.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/palette4-golden.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/palette4.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/palette4.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/palette8.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/progressive-420.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/progressive-444.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/restart-420.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb16.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb16.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb24.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb555.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-be.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-lzw-pred.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-lzw.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-packbits.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-planar.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-tiled.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-zip-pred.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8-zip.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgb8.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgba16.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgba8-assoc.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgba8.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rgba8.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rle4.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/rle8.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/source-alpha.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/source-flat.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/source-odd.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/source.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/still.gifadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/tiny-lossless.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/tiny-lossy.webpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/tiny.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/tiny.gifadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/tiny.jpgadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/tiny.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/tiny.tiffadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/topdown24.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/trns-gray.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/trns-palette.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/trns-rgb.pngadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/trns.gifadded+0 -0

Binary file changed

crates/ec-image/tests/data/stills/v5alpha.bmpadded+0 -0

Binary file changed

crates/ec-image/tests/fuzz.rsmodified+4 -4
@@ -114,7 +114,7 @@ fn budget_limits() -> ec_image::Limits {
114114 const ROUNDS: usize = 10_000;
115115
116116 fn fixtures() -> PathBuf {
117- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/stills")
117+ Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/stills")
118118 }
119119
120120 /// xorshift64*, so every run mutates the same way.
@@ -191,7 +191,7 @@ fn sweep(name: &str, seed_file: &str) {
191191 // Mutated headers can claim canvases up to the budget, so a sweep is heavy too.
192192 let _heavy = heavy();
193193 let Ok(seed) = std::fs::read(fixtures().join(seed_file)) else {
194- eprintln!("skipped: fixtures/stills not generated; run scripts/gen-still-fixtures.sh");
194+ eprintln!("skipped: tests/data/stills missing");
195195 return;
196196 };
197197 let mut rng = Rng(0x2545_f491_4f6c_dd1d ^ name.len() as u64);
@@ -264,7 +264,7 @@ fn single_seed_sweeps_survive_mutation() {
264264 #[test]
265265 fn a_gif_animation_survives_mutation() {
266266 let Ok(seed) = std::fs::read(fixtures().join("animated.gif")) else {
267- eprintln!("skipped: fixtures/stills not generated; run scripts/gen-still-fixtures.sh");
267+ eprintln!("skipped: tests/data/stills missing");
268268 return;
269269 };
270270 let _heavy = heavy();
@@ -293,7 +293,7 @@ fn a_gif_animation_survives_mutation() {
293293 #[test]
294294 fn an_animated_webp_survives_mutation() {
295295 let Ok(seed) = std::fs::read(fixtures().join("anim-alpha.webp")) else {
296- eprintln!("skipped: fixtures/stills not generated; run scripts/gen-still-fixtures.sh");
296+ eprintln!("skipped: tests/data/stills missing");
297297 return;
298298 };
299299 let _heavy = heavy();
crates/ec-image/tests/it/differential.rsmodified+2 -2
@@ -21,7 +21,7 @@ fn name_of(p: &std::path::Path) -> String {
2121 }
2222
2323 fn fixtures() -> PathBuf {
24- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/stills")
24+ Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/stills")
2525 }
2626
2727 /// Every fixture with one of these extensions, sorted for a stable report.
@@ -43,7 +43,7 @@ fn corpus(extension: &str) -> Vec<PathBuf> {
4343 }
4444
4545 fn skip(what: &str) -> bool {
46- eprintln!("skipped: fixtures/stills not generated ({what}); run scripts/gen-still-fixtures.sh");
46+ eprintln!("skipped: tests/data/stills missing ({what})");
4747 true
4848 }
4949
crates/ec-image/tests/it/gaps.rsmodified+1 -1
@@ -365,7 +365,7 @@ fn png_encoder_round_trips_bit_exact_and_matches_image_decode() {
365365 #[test]
366366 fn png_encoder_size_against_image_on_the_still_fixture() {
367367 let path =
368- std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/stills/source.png");
368+ std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/stills/source.png");
369369 let Ok(bytes) = std::fs::read(&path) else {
370370 eprintln!("skipped: {} not generated", path.display());
371371 return;
tools/ec-bench/src/main.rsmodified+3 -2
@@ -1088,7 +1088,8 @@ fn bench_container_demux(rows: &mut Vec<Row>) {
10881088
10891089 fn bench_image_decode(rows: &mut Vec<Row>) {
10901090 let mut candidates: Vec<PathBuf> = Vec::new();
1091- if let Ok(entries) = std::fs::read_dir(fixtures().join("stills")) {
1091+ let stills = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../crates/ec-image/tests/data/stills");
1092+ if let Ok(entries) = std::fs::read_dir(stills) {
10921093 candidates.extend(
10931094 entries
10941095 .flatten()
@@ -1139,7 +1140,7 @@ fn bench_image_decode(rows: &mut Vec<Row>) {
11391140
11401141 fn bench_inflate(rows: &mut Vec<Row>) {
11411142 let Some(png) = [
1142- fixtures().join("stills/gray16.png"),
1143+ Path::new(env!("CARGO_MANIFEST_DIR")).join("../../crates/ec-image/tests/data/stills/gray16.png"),
11431144 home().join("Downloads/drawing-1.png"),
11441145 ]
11451146 .into_iter()