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