ws-webp: codec tests (vp8, vp8l), bench lines, type fixes

This commit is contained in:
4DBug committed 2026-10-31 08:58:17 -05:00
1 parent 7c3d4b75ec
commit 5977b60df6
7 files changed
+226 -5

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@ function Vp8L.encode(rgba: buffer, width: number, height: number, opts: EncodeOp
if buffer.len(rgba) < width * height * 4 then
return nil, Err.new(Err.ARG, "encode: pixel buffer too small")
end
local o = opts or {}
local o: EncodeOptions = opts or {} :: EncodeOptions
local effort = o.effort or 5
if type(effort) ~= "number" or effort < 0 or effort > 9 then
return nil, Err.new(Err.ARG, "encode: effort must be 0..9")
+2 -1
View File
@@ -64,7 +64,8 @@ function Alpha.decode(buf: buffer, off: number, len: number, w: number, h: numbe
else
local d, err = Vp8L.decodeAlpha(buf, off + 1, len - 1, w, h)
if not d then
return nil, if err.code == "TRUNCATED" then "truncated: alpha " .. err.message else "alpha: " .. err.message
local e = err :: any
return nil, if e.code == "TRUNCATED" then "truncated: alpha " .. e.message else "alpha: " .. e.message
end
a = d
end
+1 -1
View File
@@ -420,7 +420,7 @@ function Webp.encode(img: Types.Image, opts: EncodeOptions?): (buffer?, Err.Err?
if type(effort) ~= "number" or effort < 0 or effort > 9 then
return nil, Err.new(Err.ARG, "effort must be 0..9")
end
local vopts = { effort = effort, exact = o.exact }
local vopts: Vp8L.EncodeOptions = { effort = effort, exact = o.exact }
local w, h = img.width, img.height
local icc, exif, xmp = metaChunk(img.meta, "icc"), metaChunk(img.meta, "exif"), metaChunk(img.meta, "xmp")
local frames = img.frames