ws-cleanup-types: archive, audio, data, font, image, layered, music, playlist, subtitle, vector, video: annotations, casts, one value per re-assignment where the solver loses the type

This commit is contained in:
4DBug committed 2026-10-31 11:00:25 -05:00
1 parent dc98aec2ec
commit f459b2dcdf
44 files changed
+172 -119

No files matched your search

+6 -2
View File
@@ -384,7 +384,9 @@ function Pixels.convert(P: Params)
r, g, bl = 0, 0, 0
end
elseif photo == 2 then
r, g, bl = norm(0, x, y), norm(1, x, y), norm(2, x, y)
r = norm(0, x, y)
g = norm(1, x, y)
bl = norm(2, x, y)
elseif photo == 5 then
local c, m, ye, k = norm(0, x, y), norm(1, x, y), norm(2, x, y), norm(3, x, y)
r, g, bl = (1 - c) * (1 - k), (1 - m) * (1 - k), (1 - ye) * (1 - k)
@@ -399,7 +401,9 @@ function Pixels.convert(P: Params)
a = norm(alpha, x, y)
if assoc then
if a > 0 then
r, g, bl = math.min(r / a, 1), math.min(g / a, 1), math.min(bl / a, 1)
r = math.min(r / a, 1)
g = math.min(g / a, 1)
bl = math.min(bl / a, 1)
else
r, g, bl = 0, 0, 0
end
+4 -4
View File
@@ -322,7 +322,7 @@ local function decodePage(c: Ctx, t: { [number]: Entry }, opts: DecodeOptions?):
if not offs or #offs < perPlane * nplanes then
return nil, Err.new(Err.CORRUPT, "missing or short strip / tile offsets")
end
local planes = table.create(nplanes)
local planes: { buffer } = table.create(nplanes) :: { buffer }
for i = 1, nplanes do
planes[i] = buffer.create(rb * h + 8)
end
@@ -583,7 +583,7 @@ function Tiff.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Image?, Err.
end
local img, perr = decodePage(c, t, opts)
if img then
img.meta.source.pages = #list
(img.meta.source :: { [string]: any }).pages = #list
end
return img, perr
end
@@ -608,7 +608,7 @@ function Tiff.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Image?, Err.
table.insert(frames, { image = img, delay = 0, x = 0, y = 0, dispose = "none", blend = "source" })
end
local img = first :: Types.Image
img.meta.source.pages = #frames
(img.meta.source :: { [string]: any }).pages = #frames
if #frames > 1 then
img.frames = frames :: any
end
@@ -722,7 +722,7 @@ local function encodePage(img: Types.Image, o: EncodeOptions, comp: number): ({
end
local text = img.meta and img.meta.text
if type(text) == "table" then
for key, tag in { description = 270, software = 305, datetime = 306, artist = 315, copyright = 33432 } do
for key, tag in { description = 270, software = 305, datetime = 306, artist = 315, copyright = 33432 } :: { [string]: number } do
if type(text[key]) == "string" then
table.insert(tags, { tag = tag, typ = 2, data = buffer.fromstring(text[key] .. "\0") })
end