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

+2 -2
View File
@@ -350,7 +350,7 @@ local function source(r: Bytes.Reader, p: Parsed): (Source?, Err.Err?)
return nil, Err.new(Err.CORRUPT, "compressed CAF without a packet table")
end
end
local offsets = table.create(#sizes, 0)
local offsets = table.create(#(sizes :: { number }), 0)
local o = p.dataStart
for i, s in sizes :: { number } do
offsets[i] = o
@@ -585,7 +585,7 @@ end
-- encode(audio | decoder, opts?) -> buffer | nil, Err
function Caf.encode(value: any, opts: EncodeOptions?): (buffer?, Err.Err?)
local o = opts or {}
local o: EncodeOptions = opts or {}
if type(value) ~= "table" or type(value.sampleRate) ~= "number" or type(value.channels) ~= "number" then
return nil, Err.new(Err.ARG, "expected an Audio or a Decoder")
end
+4 -4
View File
@@ -121,7 +121,7 @@ end
-- open(r, opts?) -> Types.Decoder | nil, Err
function M4a.open(r: Bytes.Reader, opts: DecodeOptions?): (Types.Decoder?, Err.Err?)
local o = opts or {}
local o: DecodeOptions = opts or {}
local movie, err = IsoBmff.parse(r, { maxSamples = o.maxSamples })
if not movie then
return nil, err
@@ -169,9 +169,9 @@ function M4a.open(r: Bytes.Reader, opts: DecodeOptions?): (Types.Decoder?, Err.E
-- iTunes gapless info (fdkaac, iTunes) when there is no edit list: " 0 <priming> <padding> <samples> ..." (hex)
local smpb = tags.iTunSMPB
if gapless and not t.edits and smpb then
local f = {}
local f: { number } = {}
for w in string.gmatch(smpb, "%x+") do
table.insert(f, tonumber(w, 16))
table.insert(f, tonumber(w, 16) :: number)
end
if #f >= 4 and f[2] and f[4] and f[4] > 0 and f[2] + f[4] <= total then
skip = f[2]
@@ -337,7 +337,7 @@ end
-- ------------------------------------------------------------------------------------------------ encode
-- encode(audio | decoder, opts?) -> buffer | nil, Err: an ALAC M4A
function M4a.encode(value: any, opts: EncodeOptions?): (buffer?, Err.Err?)
local o = opts or {}
local o: EncodeOptions = opts or {}
if type(value) ~= "table" or type(value.sampleRate) ~= "number" or type(value.channels) ~= "number" then
return nil, Err.new(Err.ARG, "expected an Audio or a Decoder")
end
+14 -5
View File
@@ -561,7 +561,8 @@ local function intensityStereo(h1: number, h3: number, gr: number)
kr = 1
end
end
kl, kr = f32(kl * s), f32(kr * s)
kl = f32(kl * s)
kr = f32(kr * s)
for k = left * 4, (left + n - 1) * 4, 4 do
local v = rf(GRBUF, k)
wf(GRBUF, k + 2304, v * kr)
@@ -1183,8 +1184,14 @@ local function synth(xl: number, dstl: number, nch: number, lins: number)
a3 += z3 * w0 - y3 * w1
vz -= 256
vy += 256
z0, z1, z2, z3 = rf(SYN, vz), rf(SYN, vz + 4), rf(SYN, vz + 8), rf(SYN, vz + 12)
y0, y1, y2, y3 = rf(SYN, vy), rf(SYN, vy + 4), rf(SYN, vy + 8), rf(SYN, vy + 12)
z0 = rf(SYN, vz)
z1 = rf(SYN, vz + 4)
z2 = rf(SYN, vz + 8)
z3 = rf(SYN, vz + 12)
y0 = rf(SYN, vy)
y1 = rf(SYN, vy + 4)
y2 = rf(SYN, vy + 8)
y3 = rf(SYN, vy + 12)
b0 += z0 * w3 + y0 * w2
b1 += z1 * w3 + y1 * w2
b2 += z2 * w3 + y2 * w2
@@ -1212,8 +1219,10 @@ local function synth(xl: number, dstl: number, nch: number, lins: number)
a2 += z2 * w0 - y2 * w1
vz -= 256
vy += 256
z0, z2 = rf(SYN, vz), rf(SYN, vz + 8)
y0, y2 = rf(SYN, vy), rf(SYN, vy + 8)
z0 = rf(SYN, vz)
z2 = rf(SYN, vz + 8)
y0 = rf(SYN, vy)
y2 = rf(SYN, vy + 8)
b0 += z0 * w3 + y0 * w2
b2 += z2 * w3 + y2 * w2
a0 += y0 * w3 - z0 * w2
+3 -1
View File
@@ -375,7 +375,9 @@ function Encode2.encode(src: Source, opts: Options): (buffer?, string?)
local q = floor((x * inv + 1) * L / 2)
return if q < 0 then 0 elseif q > L - 1 then L - 1 else q
end
q0, q1, q2 = quant(sb[o + 1]), quant(sb[o + 2]), quant(sb[o + 3])
q0 = quant(sb[o + 1])
q1 = quant(sb[o + 2])
q2 = quant(sb[o + 3])
end
if ba >= 17 then
put(w, q0 + L * (q1 + L * q2), tripleBits(ba))
+5 -3
View File
@@ -179,7 +179,8 @@ local function parseV2(b: buffer, o: number, size: number, tags: any)
local p, e = o + 10, bodyEnd
if band(flags, 0x80) ~= 0 and ver < 4 then
body = deunsync(b, p, e)
p, e = 0, buffer.len(body)
p = 0
e = buffer.len(body)
end
if band(flags, 0x40) ~= 0 and ver >= 3 and p + 4 <= e then
-- extended header: v2.3 size excludes its own 4 bytes, v2.4 includes them (syncsafe)
@@ -216,7 +217,8 @@ local function parseV2(b: buffer, o: number, size: number, tags: any)
end
if not skip and band(fflags, 0x0002) ~= 0 and fs < fe then
fb = deunsync(body, fs, fe)
fs, fe = 0, buffer.len(fb)
fs = 0
fe = buffer.len(fb)
end
end
if not skip and fs < fe then
@@ -273,7 +275,7 @@ function Tags.parse(b: buffer): (any, number, number)
if size >= 128 and buffer.readstring(b, start + size - 128, 3) == "TAG" then
local o = start + size - 128
tags.id3v1 = true
local v1 = {
local v1: { [string]: any } = {
title = v1String(b, o + 3, 30),
artist = v1String(b, o + 33, 30),
album = v1String(b, o + 63, 30),