merge master

This commit is contained in:
4DBug committed 2026-11-03 01:25:32 -06:00
commit 62fcfa7e93
8 files changed
+1449 -1345

No files matched your search

+89 -44
View File
@@ -677,10 +677,6 @@ local Bytes = __include("core/Bytes")
local Input = __include("core/Input")
local Types = __include("Types")
local Registry = __include("Registry")
local Video = __include("codecs/video/Video")
local AudioWrap = __include("containers/AudioWrap")
local Rbx = __include("codecs/model/Rbx")
local ImageOps = __include("ops/ImageOps")
local host = __include("host")
local F = {}
@@ -689,7 +685,6 @@ F.version = "0.1.0"
F.Err = Err
F.Types = Types
F.Bytes = Bytes
F.Rbx = Rbx
F.null = Types.null
F.host = host
F.plugins = {}
@@ -1008,7 +1003,7 @@ end
-- api hooks (a format never requires another format): opts.decodeImage / encodeImage, opts.plugins, opts.decodeModule,
-- opts.openAudio (containers/AudioWrap: PCM -> WAV, Opus / Vorbis -> Ogg, AAC -> ADTS, MP3 / FLAC / AC-3 as they are)
local function openAudio(demuxer, track, sbr)
local buf, fmt, err = AudioWrap.wrap(demuxer, track)
local buf, fmt, err = __include("containers/AudioWrap").wrap(demuxer, track)
if not buf then
return nil, err
end
@@ -1020,7 +1015,7 @@ local buf, fmt, err = AudioWrap.wrap(demuxer, track)
local skip = (type(track.codecDelay) == "number" and track.codecDelay > 0 and{(math.floor(track.codecDelay * dec.sampleRate + 0.5) )}or{0
})[1] local length = (type(track.playDuration) == "number" and track.playDuration > 0 and{(math.floor(track.playDuration * dec.sampleRate + 0.5) )}or{nil
})[1] if skip > 0 or length then
dec = AudioWrap.trim(dec, skip, length)
dec = __include("containers/AudioWrap").trim(dec, skip, length)
end
end
return dec, oerr
@@ -1200,7 +1195,7 @@ if type(v.nextFrame) ~= "function" or type(v.toRGBA) ~= "function" then
if #images == 0 then
return nil, Err.new(Err.ARG, "save: the video has no frames")
end
local img, ierr = ImageOps.fromFrames(images, delays)
local img, ierr = __include("ops/ImageOps").fromFrames(images, delays)
if not img then
return nil, ierr
end
@@ -1486,7 +1481,7 @@ if type(img) ~= "table" or img.kind ~= "image" then
end
local frames, delays = { img }, { 0.1 }
if type(img.frames) == "table" and #img.frames > 0 then
local list, cerr = ImageOps.coalesce(img)
local list, cerr = __include("ops/ImageOps").coalesce(img)
if not list then
return nil, cerr
end
@@ -1496,19 +1491,18 @@ if type(img) ~= "table" or img.kind ~= "image" then
delays[i] = (type(f.delay) == "number" and f.delay > 0 and{f.delay }or{0.1
})[1] end
elseif img.format ~= "rgba8" and img.format ~= "yuv420p" then
local c, cerr = ImageOps.convert(img, "rgba8")
local c, cerr = __include("ops/ImageOps").convert(img, "rgba8")
if not c then
return nil, cerr
end
frames = { c }
end
local src = type(img.meta) == "table" and img.meta.source
return Video.fromFrames(frames, delays, { format = type(src) == "table" and src.format or "image", loops = img.loops, meta = img.meta })
return __include("codecs/video/Video").fromFrames(frames, delays, { format = type(src) == "table" and src.format or "image", loops = img.loops, meta = img.meta })
end
F.video.fromFrames = function(images, delays, opts)
return Video.fromFrames(images, delays, opts)
return __include("codecs/video/Video").fromFrames(images, delays, opts)
end
F.video.codecs = Video
F.model.loadTextures = function(scene, opts)
local errs= {}
@@ -1537,7 +1531,7 @@ end
local OPS= {
image = function()
return ImageOps
return __include("ops/ImageOps")
end,
mesh = function()
return __include("ops/MeshOps")
@@ -1581,6 +1575,28 @@ local make = OPS[k]
return m
end,
}) )
-- F.Rbx (codecs/model/Rbx), F.video.codecs (codecs/video/Video): required on first use
setmetatable(F, {
__index = function(t, k)
if k == "Rbx" then
local m = __include("codecs/model/Rbx")
rawset(t, k, m)
return m
end
return nil
end,
})
setmetatable(F.video, {
__index = function(t, k)
if k == "codecs" then
local m = __include("codecs/video/Video")
rawset(t, k, m)
return m
end
return nil
end,
})
return F
end
@@ -4223,7 +4239,7 @@ end
local P_audio_mp3_Tags= {}
do -- audio/mp3/Tags: id3v2Size
local Tags = P_audio_mp3_Tags
local Tags = {}
local band, bor, lshift = bit32.band, bit32.bor, bit32.lshift
local ru8 = buffer.readu8
local function syncsafe(b, o)
@@ -4247,11 +4263,12 @@ if len - o < 10 or buffer.readstring(b, o, 3) ~= "ID3" then
end
return size
end
P_audio_mp3_Tags.id3v2Size = Tags.id3v2Size
end
local P_codecs_audio_Aac= {}
do -- codecs/audio/Aac: adts
local Aac = P_codecs_audio_Aac
local Aac = {}
local Bits = __include("core/Bits")
Aac.RATES = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 }
local function objectType(br)
@@ -4300,11 +4317,12 @@ if o < 0 or o + 7 > limit or o + 7 > buffer.len(b) then
protected = protected,
}
end
P_codecs_audio_Aac.adts = Aac.adts
end
local P_codecs_audio_Ac3_Tables= {}
do -- codecs/audio/Ac3/Tables: BITRATES, RATES, frameWords
local T = P_codecs_audio_Ac3_Tables
local T = {}
T.BITRATES = { 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640 }
T.RATES = { 48000, 44100, 32000 }
function T.frameWords(fscod, frmsizecod)
@@ -4319,11 +4337,14 @@ local kbps = T.BITRATES[math.floor(frmsizecod / 2 )+ 1]
end
return math.floor(kbps * 1536000 / 705600 )+ frmsizecod % 2
end
P_codecs_audio_Ac3_Tables.BITRATES = T.BITRATES
P_codecs_audio_Ac3_Tables.RATES = T.RATES
P_codecs_audio_Ac3_Tables.frameWords = T.frameWords
end
local P_codecs_audio_Ac3= {}
do -- codecs/audio/Ac3: header
local Ac3 = P_codecs_audio_Ac3
local Ac3 = {}
local T = P_codecs_audio_Ac3_Tables
local readu8 = buffer.readu8
local NFCHANS = { [0] = 2, 1, 2, 3, 3, 4, 4, 5 }
@@ -4392,22 +4413,24 @@ if o < 0 or o + 8 > limit or o + 8 > buffer.len(b) then
bsid = bsid,
}
end
P_codecs_audio_Ac3.header = Ac3.header
end
local P_codecs_audio_Mpa_Tables= {}
do -- codecs/audio/Mpa/Tables: halfrate
local T = P_codecs_audio_Mpa_Tables
local T = {}
T.halfrate = { [0] = 0,
4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64, 72, 80, 0, 4, 8, 12, 16, 20, 24, 28, 32, 40,
48, 56, 64, 72, 80, 0, 16, 24, 28, 32, 40, 48, 56, 64, 72, 80, 88, 96, 112, 128, 0, 16, 20, 24,
28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 0, 16, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128,
160, 192, 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224,
}
P_codecs_audio_Mpa_Tables.halfrate = T.halfrate
end
local P_codecs_audio_Mpa_Header= {}
do -- codecs/audio/Mpa/Header: compare, frameBytes, padding, valid
local H = P_codecs_audio_Mpa_Header
local H = {}
local T = P_codecs_audio_Mpa_Tables
local band, bxor, rshift = bit32.band, bit32.bxor, bit32.rshift
local ru8 = buffer.readu8
@@ -4475,11 +4498,15 @@ if band(ru8(b, o + 2), 2) == 0 then
end
return band(ru8(b, o + 1), 6) == 6 and 4 or 1
end
P_codecs_audio_Mpa_Header.compare = H.compare
P_codecs_audio_Mpa_Header.frameBytes = H.frameBytes
P_codecs_audio_Mpa_Header.padding = H.padding
P_codecs_audio_Mpa_Header.valid = H.valid
end
local P_codecs_audio_Musepack= {}
do -- codecs/audio/Musepack: magic
local Musepack = P_codecs_audio_Musepack
local Musepack = {}
function Musepack.magic(buf, p, limit)
if p + 4 > limit then
return 0
@@ -4493,15 +4520,17 @@ if p + 4 > limit then
end
return 0
end
P_codecs_audio_Musepack.magic = Musepack.magic
end
local P_codecs_audio_SoundFont= {}
do -- codecs/audio/SoundFont: sniff
local SoundFont = P_codecs_audio_SoundFont
local SoundFont = {}
local Bytes = __include("core/Bytes")
function SoundFont.sniff(r)
return r:peek(4) == "RIFF" and r:peek(4, 8) == "sfbk"
end
P_codecs_audio_SoundFont.sniff = SoundFont.sniff
end
local P_codecs_compress_Brotli = lazy(function()
@@ -4514,7 +4543,7 @@ end)
local P_codecs_compress_Deflate= {}
do -- codecs/compress/Deflate: peek
local Deflate = P_codecs_compress_Deflate
local Deflate = {}
local Err = __include("core/Err")
local Bytes = __include("core/Bytes")
local Inflate = P_codecs_compress_Deflate_Inflate
@@ -4587,6 +4616,7 @@ local b, o, l, aerr = args("Deflate.peek", buf, offset, length)
end
return shrink(out, k), nil
end
P_codecs_compress_Deflate.peek = Deflate.peek
end
local P_codecs_compress_Zstd_Decode = lazy(function()
@@ -4595,7 +4625,7 @@ end)
local P_codecs_compress_Zstd= {}
do -- codecs/compress/Zstd: MAGIC, decompress
local Zstd = P_codecs_compress_Zstd
local Zstd = {}
local Err = __include("core/Err")
local Bytes = __include("core/Bytes")
local Decode = P_codecs_compress_Zstd_Decode
@@ -4625,11 +4655,13 @@ local b, o, l, aerr = Bytes.span("Zstd.decompress", buf, offset, length)
end
return out, consumed
end
P_codecs_compress_Zstd.MAGIC = Zstd.MAGIC
P_codecs_compress_Zstd.decompress = Zstd.decompress
end
local P_codecs_text_KeyValues_Binary= {}
do -- codecs/text/KeyValues/Binary: sniff
local Binary = P_codecs_text_KeyValues_Binary
local Binary = {}
local readu8, readu32, readi32, readf32 = buffer.readu8, buffer.readu32, buffer.readi32, buffer.readf32
function Binary.sniff(b, o, n)
if n < 3 then
@@ -4649,18 +4681,20 @@ if n < 3 then
end
return false
end
P_codecs_text_KeyValues_Binary.sniff = Binary.sniff
end
local P_codecs_text_KeyValues= {}
do -- codecs/text/KeyValues: isBinary
local KeyValues = P_codecs_text_KeyValues
local KeyValues = {}
local Binary = P_codecs_text_KeyValues_Binary
KeyValues.isBinary = Binary.sniff
P_codecs_text_KeyValues.isBinary = KeyValues.isBinary
end
local P_codecs_text_Nbt_Value= {}
do -- codecs/text/Nbt/Value: NAMES
local Value = P_codecs_text_Nbt_Value
local Value = {}
Value.NAMES = {
[0] = "end",
"byte",
@@ -4680,11 +4714,12 @@ Value.IDS = {}
for id = 0, 12 do
Value.IDS[Value.NAMES[id] ] = id
end
P_codecs_text_Nbt_Value.NAMES = Value.NAMES
end
local P_codecs_text_Nbt= {}
do -- codecs/text/Nbt: peek
local Nbt = P_codecs_text_Nbt
local Nbt = {}
local Deflate = P_codecs_compress_Deflate
local Value = P_codecs_text_Nbt_Value
@@ -4772,11 +4807,12 @@ local a, b = buffer.readu8(head, q), buffer.readu8(head, q + 1)
end
return at(0, "big", false) or at(0, "little", false)
end
P_codecs_text_Nbt.peek = Nbt.peek
end
local P_codecs_text_Text= {}
do -- codecs/text/Text: toUtf8, trim, utf16
local Text = P_codecs_text_Text
local Text = {}
function Text.utf8char(c)
local char = string.char
if c < 0x80 then
@@ -4844,11 +4880,14 @@ if string.sub(text, 1, 3) == "\239\187\191" then
end
return table.concat(out)
end
P_codecs_text_Text.toUtf8 = Text.toUtf8
P_codecs_text_Text.trim = Text.trim
P_codecs_text_Text.utf16 = Text.utf16
end
local P_containers_Fat= {}
do -- containers/Fat: open
local Fat = P_containers_Fat
local Fat = {}
local readu8, readu16, readu32 = buffer.readu8, buffer.readu16, buffer.readu32
@@ -4970,11 +5009,12 @@ local o= opts or {}
end
return nil, (o.partition and(("no partition " .. o.partition ))or("no FAT partition"
))end
P_containers_Fat.open = Fat.open
end
local P_containers_IsoBmff= {}
do -- containers/IsoBmff: sniff
local IsoBmff = P_containers_IsoBmff
local IsoBmff = {}
local Bytes = __include("core/Bytes")
local TOP= {
ftyp = true, moov = true, mdat = true, free = true, skip = true, wide = true, pnot = true, moof = true,
@@ -4997,11 +5037,12 @@ local head = r:peek(12)
end
return nil
end
P_containers_IsoBmff.sniff = IsoBmff.sniff
end
local P_containers_Riff= {}
do -- containers/Riff: sniff
local Riff = P_containers_Riff
local Riff = {}
function Riff.sniff(r)
local magic = r:peek(4)
if magic ~= "RIFF" and magic ~= "RIFX" and magic ~= "RF64" and magic ~= "BW64" then
@@ -5010,11 +5051,12 @@ local magic = r:peek(4)
local form = r:peek(4, 8)
return (#form == 4 and{form }or{nil
})[1]end
P_containers_Riff.sniff = Riff.sniff
end
local P_containers_Tar= {}
do -- containers/Tar: valid
local Tar = P_containers_Tar
local Tar = {}
local BLOCK = 512
local function zeros(b, o)
for i = 0, BLOCK - 1, 4 do
@@ -5057,19 +5099,22 @@ if o + BLOCK > buffer.len(b) or zeros(b, o) then
local u, s = checksum(b, o)
return want == u or want == s
end
P_containers_Tar.valid = Tar.valid
end
local P_model_fbx_Binary= {}
do -- model/fbx/Binary: MAGIC
local Binary = P_model_fbx_Binary
local Binary = {}
local MAGIC = "Kaydara FBX Binary \0"
Binary.MAGIC = MAGIC
P_model_fbx_Binary.MAGIC = Binary.MAGIC
end
local P_model_ms3d_Read= {}
do -- model/ms3d/Read: MAGIC
local Read = P_model_ms3d_Read
local Read = {}
Read.MAGIC = "MS3D000000"
P_model_ms3d_Read.MAGIC = Read.MAGIC
end
do -- image/ani
@@ -64254,13 +64299,12 @@ __DARKLUA_CONTINUE_26=true break
end
local ws = w
if wl > 0 then
if dict == nil then
dict = S.dictionary()
if dict == nil then
return nil, NO_DICTIONARY
end
local d = dict or S.dictionary()
if d == nil then
return nil, NO_DICTIONARY
end
bcopy(WORD, w, dict, wo, wl)
dict = d
bcopy(WORD, w, d, wo, wl)
w =w+ wl
end
if ttype == 10 then
@@ -165172,10 +165216,11 @@ end
-- RNA path 'kind["name"].rest': name ends at the first unescaped '"]', rest may hold more subscripts
function Anim.split(path)
local kind, at = string.match(path, '^(%w[%w_%.]-)%["()')
local kind, pos = string.match(path, '^(%w[%w_%.]-)%["()')
if kind then
local i = at
while true do
local at= pos
local i = at
while true do
local q = string.find(path, '"', i, true)
if not q then
break