jpegsuite, validate uses masters/diffs/rendered independently
2
.gitignore
vendored
|
@ -15,4 +15,4 @@ bindings/generated
|
|||
*.dSYM
|
||||
dump.txt
|
||||
tests/fileformats/jpeg/generated
|
||||
tests/fileformats/jpeg/diff
|
||||
tests/fileformats/jpeg/diffs
|
||||
|
|
|
@ -1,46 +1,6 @@
|
|||
import benchy, pixie/fileformats/jpg
|
||||
import benchy, pixie/fileformats/jpg, jpegsuite
|
||||
|
||||
var files = @[
|
||||
"tests/fileformats/jpeg/master/red.jpg",
|
||||
"tests/fileformats/jpeg/master/green.jpg",
|
||||
"tests/fileformats/jpeg/master/blue.jpg",
|
||||
"tests/fileformats/jpeg/master/white.jpg",
|
||||
"tests/fileformats/jpeg/master/black.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/8x8.jpg",
|
||||
"tests/fileformats/jpeg/master/8x8_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/16x16.jpg",
|
||||
"tests/fileformats/jpeg/master/16x16_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/quality_01.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_10.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_25.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_50.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_100.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_2.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_1_1.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/mandrill.jpg",
|
||||
"tests/fileformats/jpeg/master/exif_overrun.jpg",
|
||||
"tests/fileformats/jpeg/master/grayscale_test.jpg",
|
||||
"tests/fileformats/jpeg/master/progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/testimg.jpg",
|
||||
"tests/fileformats/jpeg/master/testimgp.jpg",
|
||||
"tests/fileformats/jpeg/master/testorig.jpg",
|
||||
"tests/fileformats/jpeg/master/testprog.jpg",
|
||||
]
|
||||
|
||||
for file in files:
|
||||
for file in jpegSuiteFiles:
|
||||
let data = readFile(file)
|
||||
timeIt "jpeg " & $(len(data) div 1024) & "k decode":
|
||||
discard decodeJpg(data)
|
||||
|
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 626 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 589 B After Width: | Height: | Size: 589 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 636 B After Width: | Height: | Size: 636 B |
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 285 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 634 B |
|
@ -1,57 +1,15 @@
|
|||
import pixie/common, pixie/fileformats/jpg, random, strformat
|
||||
import pixie/common, pixie/fileformats/jpg, random, strformat, jpegsuite
|
||||
|
||||
randomize()
|
||||
|
||||
var files = @[
|
||||
"tests/fileformats/jpeg/master/red.jpg",
|
||||
"tests/fileformats/jpeg/master/green.jpg",
|
||||
"tests/fileformats/jpeg/master/blue.jpg",
|
||||
"tests/fileformats/jpeg/master/white.jpg",
|
||||
"tests/fileformats/jpeg/master/black.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/8x8.jpg",
|
||||
"tests/fileformats/jpeg/master/8x8_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/16x16.jpg",
|
||||
"tests/fileformats/jpeg/master/16x16_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/quality_01.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_10.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_25.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_50.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_100.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_2.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_1_1.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/mandrill.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/exif_overrun.jpg",
|
||||
"tests/fileformats/jpeg/master/grayscale_test.jpg",
|
||||
"tests/fileformats/jpeg/master/progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/testimg.jpg",
|
||||
"tests/fileformats/jpeg/master/testimgp.jpg",
|
||||
"tests/fileformats/jpeg/master/testorig.jpg",
|
||||
"tests/fileformats/jpeg/master/testprog.jpg",
|
||||
]
|
||||
|
||||
for i in 0 ..< 10_000:
|
||||
let original = readFile(sample(files))
|
||||
|
||||
var data = original
|
||||
let file = sample(jpegSuiteFiles)
|
||||
var data = readFile(file)
|
||||
let
|
||||
pos = rand(0 ..< data.len)
|
||||
value = rand(255).uint8
|
||||
data[pos] = value.char
|
||||
echo &"{i} {pos} {value}"
|
||||
echo &"{i} {file} {pos} {value}"
|
||||
|
||||
try:
|
||||
let img = decodeJpg(data)
|
||||
|
|
39
tests/jpegsuite.nim
Normal file
|
@ -0,0 +1,39 @@
|
|||
const jpegSuiteFiles* = [
|
||||
"tests/fileformats/jpeg/masters/red.jpg",
|
||||
"tests/fileformats/jpeg/masters/green.jpg",
|
||||
"tests/fileformats/jpeg/masters/blue.jpg",
|
||||
"tests/fileformats/jpeg/masters/white.jpg",
|
||||
"tests/fileformats/jpeg/masters/black.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/masters/8x8.jpg",
|
||||
"tests/fileformats/jpeg/masters/8x8_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/masters/16x16.jpg",
|
||||
"tests/fileformats/jpeg/masters/16x16_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/masters/quality_01.jpg",
|
||||
"tests/fileformats/jpeg/masters/quality_10.jpg",
|
||||
"tests/fileformats/jpeg/masters/quality_25.jpg",
|
||||
"tests/fileformats/jpeg/masters/quality_50.jpg",
|
||||
"tests/fileformats/jpeg/masters/quality_100.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/masters/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_4_2_2.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_4_2_0.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_4_1_1.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_4_2_0_progressive.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_4_4_4_progressive.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_restart_markers_5.jpg",
|
||||
"tests/fileformats/jpeg/masters/cat_restart_markers_5_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/masters/mandrill.jpg",
|
||||
"tests/fileformats/jpeg/masters/exif_overrun.jpg",
|
||||
"tests/fileformats/jpeg/masters/grayscale_test.jpg",
|
||||
"tests/fileformats/jpeg/masters/progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/masters/testimg.jpg",
|
||||
"tests/fileformats/jpeg/masters/testimgp.jpg",
|
||||
"tests/fileformats/jpeg/masters/testorig.jpg",
|
||||
"tests/fileformats/jpeg/masters/testprog.jpg",
|
||||
]
|
|
@ -1,47 +1,4 @@
|
|||
import pixie, strutils
|
||||
import pixie, jpegsuite
|
||||
|
||||
import pixie/fileformats/jpg
|
||||
|
||||
var files = @[
|
||||
"tests/fileformats/jpeg/master/red.jpg",
|
||||
"tests/fileformats/jpeg/master/green.jpg",
|
||||
"tests/fileformats/jpeg/master/blue.jpg",
|
||||
"tests/fileformats/jpeg/master/white.jpg",
|
||||
"tests/fileformats/jpeg/master/black.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/8x8.jpg",
|
||||
"tests/fileformats/jpeg/master/8x8_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/16x16.jpg",
|
||||
"tests/fileformats/jpeg/master/16x16_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/quality_01.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_10.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_25.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_50.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_100.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_2.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_1_1.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/mandrill.jpg",
|
||||
"tests/fileformats/jpeg/master/exif_overrun.jpg",
|
||||
"tests/fileformats/jpeg/master/grayscale_test.jpg",
|
||||
"tests/fileformats/jpeg/master/progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/testimg.jpg",
|
||||
"tests/fileformats/jpeg/master/testimgp.jpg",
|
||||
"tests/fileformats/jpeg/master/testorig.jpg",
|
||||
"tests/fileformats/jpeg/master/testprog.jpg",
|
||||
]
|
||||
|
||||
for file in files:
|
||||
var img = decodeJpg(readFile(file))
|
||||
# img.writeFile(file.replace("master", "generated").replace(".jpg", ".jpeg.png"))
|
||||
for file in jpegSuiteFiles:
|
||||
let img = readImage(file)
|
||||
|
|
|
@ -1,58 +1,21 @@
|
|||
import pixie, strutils, os, strformat
|
||||
import pixie, strutils, os, strformat, jpegsuite
|
||||
|
||||
import pixie/fileformats/jpg
|
||||
createDir("tests/fileformats/jpeg/generated")
|
||||
createDir("tests/fileformats/jpeg/diffs")
|
||||
|
||||
var files = @[
|
||||
"tests/fileformats/jpeg/master/red.jpg",
|
||||
"tests/fileformats/jpeg/master/green.jpg",
|
||||
"tests/fileformats/jpeg/master/blue.jpg",
|
||||
"tests/fileformats/jpeg/master/white.jpg",
|
||||
"tests/fileformats/jpeg/master/black.jpg",
|
||||
for file in jpegSuiteFiles:
|
||||
let img = readImage(file)
|
||||
|
||||
"tests/fileformats/jpeg/master/8x8.jpg",
|
||||
"tests/fileformats/jpeg/master/8x8_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/16x16.jpg",
|
||||
"tests/fileformats/jpeg/master/16x16_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/quality_01.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_10.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_25.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_50.jpg",
|
||||
"tests/fileformats/jpeg/master/quality_100.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_2.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_1_1.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_2_0_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_4_4_4_progressive.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5.jpg",
|
||||
"tests/fileformats/jpeg/master/cat_restart_markers_5_progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/mandrill.jpg",
|
||||
"tests/fileformats/jpeg/master/exif_overrun.jpg",
|
||||
"tests/fileformats/jpeg/master/grayscale_test.jpg",
|
||||
"tests/fileformats/jpeg/master/progressive.jpg",
|
||||
|
||||
"tests/fileformats/jpeg/master/testimg.jpg",
|
||||
"tests/fileformats/jpeg/master/testimgp.jpg",
|
||||
"tests/fileformats/jpeg/master/testorig.jpg",
|
||||
"tests/fileformats/jpeg/master/testprog.jpg",
|
||||
]
|
||||
|
||||
for file in files:
|
||||
var img = decodeJpg(readFile(file))
|
||||
|
||||
let genFile = file.replace("master", "generated").replace(".jpg", ".png")
|
||||
let diffFile = file.replace("master", "diff").replace(".jpg", ".png")
|
||||
let genFile = file.replace("masters", "generated").replace(".jpg", ".png")
|
||||
img.writeFile(genFile)
|
||||
|
||||
if execShellCmd(&"convert {file} {genFile}") != 0:
|
||||
echo "fail"
|
||||
|
||||
var img2 = readImage(genFile)
|
||||
let (score, diff) = img2.diff(img)
|
||||
|
||||
let diffFile = file.replace("master", "diff").replace(".jpg", ".png")
|
||||
diff.writeFile(diffFile)
|
||||
|
||||
if score > 1:
|
||||
|
|