- codecs/Dct: jpeg-luau's islow / reduced IDCTs + a forward islow DCT with jcdctmgr.c's quantiser; tests/codecs/dct.luau - image/jpeg: Decode (marker parser, absorbed + reader ranges, SOF9/SOF10 + DAC, EXIF / ICC / COM / JFIF density), Scan + Color (absorbed), Arith (jdarith.c port), Encode (baseline / optimised / progressive, 444/422/420, restarts, APP1/APP2/COM from meta), Tables (annex K) - tests: 115 cjpeg/jpegtran/Pillow files, 444 decodes bit-exact with djpeg at 1, 1/2, 1/4, 1/8 (104 arithmetic), 38 encodes byte-identical to cjpeg (so djpeg decodes them), orientation, meta, truncation, fuzz - licenses: libjpeg-turbo LICENSE + README.ijg, NOTICE rows - tools/bench.luau: jpeg block; tools/bench.sh runs every fixture generator (bench blocks read their outputs)
26 lines
803 B
Luau
26 lines
803 B
Luau
local Jpeg = require("@formats/image/jpeg")
|
|
local Types = require("@formats/Types")
|
|
local Enc = require("@tests/gen/jpeg_enc")
|
|
for _, c in Enc do
|
|
if c.name == "photo_444_prog" then
|
|
local img = Types.Image.new(c.width, c.height, c.format)
|
|
buffer.writestring(img.pixels, 0, c.pixels)
|
|
local out = buffer.tostring(Jpeg.encode(img, c.opts))
|
|
-- list SOS offsets in both
|
|
for _, s in { out, c.want } do
|
|
local marks = {}
|
|
local i = 1
|
|
while i < #s do
|
|
if s:byte(i) == 255 and s:byte(i+1) ~= 0 and s:byte(i+1) ~= 255 then
|
|
table.insert(marks, string.format("%x@%d", s:byte(i+1), i - 1))
|
|
end
|
|
i += 1
|
|
end
|
|
print(table.concat(marks, " "))
|
|
end
|
|
local diffs = 0
|
|
for i = 1, #out do if out:byte(i) ~= c.want:byte(i) then diffs += 1 end end
|
|
print("diff bytes", diffs)
|
|
end
|
|
end
|