build: single-file bundles build/Rosetta.luau + build/rosetta.lua (tools/bundle.py), terse README with generated format / codec tables
- tools/bundle.py: every module a function in __FILES with a cached __include; requires become __include calls, so only the API and its load-time requires run on require. Rosetta._internal(path) includes any module by its src path. --!native modules get @native on each function (NATIVE re-checked on the bundle); linemaps map bundle lines back to sources (--where). LuaJIT bundle inlines the compat prelude. - tools/build.py: the multi-file trees move to build/_modules (gitignored); each target also writes its bundle. - tools/test.sh: api + docs/example tests also run against both bundles; fails when build/ is stale. - default.project.json mounts build/Rosetta.luau; examples/love loads build/rosetta.lua. - README: one line, install, quick start, doc links, generated format table and codec list (tools/gen_registry.py), licence TODO. DOCS lint checks the generated sections and the links.
This commit is contained in:
1 parent
0bd7b87d2b
commit
bcf6d46fb7
16 files changed
+399611
-210
No files matched your search
@@ -1,162 +1,249 @@
|
||||
# rosetta
|
||||
|
||||
Read, write and convert file formats in pure Luau, from one source tree that runs on **Roblox** (Luau, native code
|
||||
generation) and on **LuaJIT / LÖVE** (through `tools/build.py`). Every format of a category maps onto one standard type
|
||||
(`src/Rosetta/Types.luau`): a PNG and a WebP both load as an `Image`, every audio format opens as the same streaming
|
||||
`Decoder`, every model format loads as a `Scene`.
|
||||
|
||||
174 formats: images (25), audio (21), video (11), 3D models (32), CAD (1), fonts (11), archives (31), data (11),
|
||||
vector graphics and tile maps (2), layered images (3), subtitles (3), music (20) and playlists (3). See
|
||||
[docs/FORMATS.md](docs/FORMATS.md) (generated from the code) for the list and each format's capabilities,
|
||||
[docs/API.md](docs/API.md) for the whole API, and the guide ([docs/guide/README.md](docs/guide/README.md)) for
|
||||
walkthroughs. `tools/lint.sh` checks these counts against the registry.
|
||||
|
||||
```luau
|
||||
local F = require(Rosetta) -- LuaJIT: require("rosetta"); luau CLI: require("@rosetta")
|
||||
local img, err = F.load(src) -- src: buffer | string | path (hosts with files)
|
||||
if not img then print(tostring(err)) end -- errors are values: "png: CORRUPT at 0x21: bad filter type 7"
|
||||
local buf = F.save(img, nil, { format = "webp" }) -- a buffer; F.save(img, "out.webp") writes a file
|
||||
local out = F.convert(src, "png", { level = 9 })
|
||||
local small = F.ops.image.resize(img, 64, 64, "lanczos")
|
||||
```
|
||||
|
||||
Nothing throws on bad data or bad arguments: every call returns `nil, err` (`err.code` is one of the `F.Err` codes).
|
||||
Read, write and convert file formats in pure Luau, on Roblox, LuaJIT / LÖVE and the Luau CLI.
|
||||
|
||||
## Install
|
||||
|
||||
**Roblox (Rojo).** `python3 -I tools/build.py roblox` writes `build/roblox/Rosetta` (requires turned into instance
|
||||
paths); `default.project.json` mounts it, so `rojo build -o Rosetta.rbxm` (or `rojo serve`) gives a `Rosetta`
|
||||
ModuleScript to put in ReplicatedStorage: `local F = require(game.ReplicatedStorage.Rosetta)`. There is no file system:
|
||||
pass buffers or strings. `F.host.toEditableImage(img)` makes an EditableImage, `F.host.toEditableMesh(prim, page)` an
|
||||
EditableMesh (a merged triangle primitive split by `F.host.meshPages`).
|
||||
- **Roblox:** put [`build/Rosetta.luau`](build/Rosetta.luau) in a ModuleScript (e.g. ReplicatedStorage.Rosetta),
|
||||
or mount it with Rojo (`"Rosetta": { "$path": "rosetta/build/Rosetta.luau" }`; this repo's `default.project.json`
|
||||
does). Then `local F = require(ReplicatedStorage.Rosetta)`.
|
||||
- **LÖVE / LuaJIT:** copy [`build/rosetta.lua`](build/rosetta.lua). `local F = require("rosetta")` with its folder on
|
||||
`package.path`, or `local F = dofile("rosetta.lua")`.
|
||||
- **Luau CLI:** alias the sources in `.luaurc` (`"rosetta": "rosetta/src/Rosetta"`), then
|
||||
`local F = require("@rosetta")`.
|
||||
|
||||
**LuaJIT / LÖVE.** `python3 -I tools/build.py luajit` writes `build/luajit/rosetta/` (Lua 5.1 + LuaJIT FFI; the Luau
|
||||
standard library pieces come from `rosetta/_compat.lua`). Copy the `rosetta` folder into the game (or put
|
||||
`build/luajit/?.lua;build/luajit/?/init.lua` on `package.path`) and `local F = require("rosetta")`. Files load by path
|
||||
(`love.filesystem` under LÖVE, else `io.open`); `F.host.toImageData(img)`, `F.host.fromImageData(imageData)` and
|
||||
`F.host.toSoundData(audioOrDecoder)` bridge to LÖVE. `examples/love` is a runnable example and smoke test
|
||||
(`love examples/love` from the repo root after building).
|
||||
|
||||
**luau CLI.** `luau` with the `.luaurc` alias `@rosetta` runs `src/` directly (no file system).
|
||||
Internal modules are reachable as `F._internal("codecs/video/Mpeg1")` (bundles) or `require("@rosetta/codecs/video/Mpeg1")`
|
||||
(CLI).
|
||||
|
||||
## Quick start
|
||||
|
||||
```luau
|
||||
-- images: PNG / APNG, JPEG, WebP, GIF, BMP, TGA, QOI, TIFF, ICO, PNM, HDR, EXR, DDS, KTX, PCX, ... -> Image
|
||||
local img = F.image.load(pngBytes)
|
||||
print(img.width, img.height, #(img.frames or {}), img.loops) -- animations: frames; loops = play count, 0 forever
|
||||
local jpg = F.save(img, nil, { format = "jpeg", quality = 85 })
|
||||
|
||||
-- audio: WAV, FLAC, MP3 / MP2, Ogg Vorbis, Opus, AAC, M4A, AIFF, AU, CAF, VOC, WavPack, APE, TTA, Musepack, AC-3,
|
||||
-- QOA, ADPCM (ADX, VAG, BRSTM, ...) -> streaming Decoder or Audio
|
||||
local dec = F.audio.open(flacBytes) -- dec:read(n) -> interleaved f32 buffer, frames; dec:seek(s)
|
||||
local song = F.audio.load(mp3Bytes) -- Audio { sampleRate, channels, frames, samples, tags }
|
||||
local mono = F.ops.audio.downmix(song, 1) -- channels are in WAVE order; tags keys are lower case
|
||||
local opus = F.save(F.ops.audio.resample(mono, 48000), nil, { format = "opus", bitrate = 64000 })
|
||||
|
||||
-- video: MP4 / MOV, MKV / WebM, AVI, MPEG-TS / PS, Ogg Theora, FLV, FLI, Smacker, Y4M (+ animated images)
|
||||
-- -> VideoDecoder
|
||||
local v = F.video.open(mp4Bytes) -- v:nextFrame() -> frame (image yuv420p or rgba8, pts)
|
||||
|
||||
-- models: glTF / GLB (+ Draco), OBJ, STL, PLY, FBX, Collada, 3MF, USDA, OFF, VOX, 3DS, MS3D, LWO, .x, IQM, B3D,
|
||||
-- PMX / PMD, VRML, X3D, LDraw, MD2 / MD3 / MDL / MD5, BSP, SMD, Roblox (rbxm / rbxmx / .mesh),
|
||||
-- Minecraft (.schem, .mca), Qubicle -> Scene
|
||||
local scene = F.model.load(glbBytes)
|
||||
local prim = F.ops.mesh.merge(scene) -- one triangle primitive in world space
|
||||
|
||||
-- CAD, fonts, archives, data, vector, tile maps, layered, subtitles, music, playlists
|
||||
local font = F.font.load(ttfBytes) -- TTF / OTF, WOFF / WOFF2, BMFont, bitmap fonts: outlines, kerning
|
||||
local zip = F.archive.load(zipBytes) -- zip, tar, 7z, gzip, cab, iso, ...; saves zip / tar / gzip
|
||||
local t = F.data.load('{"a": [1, 2]}', { format = "json" }) -- JSON, XML, YAML, TOML, CSV, INI, plist, CBOR, NBT, ...
|
||||
local icon = F.ops.vector.rasterize(F.vector.load(svgText), 64, 64) -- SVG; Tiled maps load as a TileMap
|
||||
local flat = F.ops.layers.flatten(F.layered.load(psdBytes)) -- PSD, Aseprite, OpenRaster
|
||||
local subs = F.subtitle.load(srtText) -- SRT, WebVTT, ASS / SSA
|
||||
local tune = F.music.load(modBytes) -- MOD / S3M / XM / IT / AHX / MIDI, ...: rendered to audio
|
||||
local step = F.cad.load(stepText) -- STEP entity graph (B-rep through a plug-in)
|
||||
local list = F.playlist.load(m3uText) -- M3U / M3U8, PLS, XSPF
|
||||
local img, err = F.load(pngBytes) -- buffer | string | path; errors are values, nothing throws
|
||||
if not img then error(tostring(err)) end
|
||||
local small = F.ops.image.resize(img, 64, 64, "lanczos")
|
||||
local webp = F.save(small, nil, { format = "webp" }) -- a buffer
|
||||
local png = F.convert(jpegBytes, "png") -- load + save
|
||||
local dec = F.audio.open(flacBytes) -- streaming: dec:read(n) -> interleaved f32 buffer, frames
|
||||
local scene = F.model.load(glbBytes) -- every model format loads as a Scene
|
||||
local v = F.video.open(mp4Bytes) -- v:nextFrame() -> frame
|
||||
print(F.detect(webp), #F.formats()) -- "webp", the format list
|
||||
```
|
||||
|
||||
## The API in short
|
||||
## Docs
|
||||
|
||||
`F.load`, `F.open`, `F.save`, `F.saveString`, `F.convert`, `F.detect`, `F.formats`, `F.format(name)`; the category
|
||||
facades `F.image`, `F.audio`, `F.video`, `F.model`, `F.cad`, `F.font`, `F.archive`, `F.data`, `F.vector`,
|
||||
`F.layered`, `F.subtitle`, `F.music`, `F.playlist`; editing in `F.ops.image`, `F.ops.mesh`, `F.ops.layers`,
|
||||
`F.ops.audio`, `F.ops.music` (also `F.music.new` / `addPattern` / `setCell` / ...), `F.ops.vector.rasterize`; `F.host`, `F.plugins`, `F.Err`, `F.Types`. Options and the hooks the api
|
||||
hands to formats (decodeImage / encodeImage / openAudio / plugins): [docs/API.md](docs/API.md).
|
||||
- Guide: [overview, install, inputs, errors, options](docs/guide/README.md), [images](docs/guide/image.md),
|
||||
[audio](docs/guide/audio.md), [music](docs/guide/music.md), [video](docs/guide/video.md),
|
||||
[3D scenes](docs/guide/scene.md), [Roblox files](docs/guide/roblox.md), [CAD](docs/guide/cad.md),
|
||||
[fonts](docs/guide/font.md), [archives](docs/guide/archive.md), [data](docs/guide/data.md),
|
||||
[Minecraft and voxels](docs/guide/voxel.md), [vector](docs/guide/vector.md), [layered images](docs/guide/layered.md),
|
||||
[tile maps](docs/guide/tilemap.md), [subtitles](docs/guide/subtitles.md), [playlists](docs/guide/playlist.md),
|
||||
[recipes](docs/guide/recipes.md)
|
||||
- [docs/API.md](docs/API.md): the API reference
|
||||
- [docs/STYLE.md](docs/STYLE.md): code layout, rules and tooling (`bash tools/test.sh` runs everything)
|
||||
|
||||
## Host notes
|
||||
## Formats
|
||||
|
||||
| Host | Files | Bridges |
|
||||
|---|---|---|
|
||||
| Roblox | none: pass buffers / strings | `F.host.toEditableImage(img)`, `meshPages` / `toEditableMesh(prim, page)` |
|
||||
| LÖVE | `love.filesystem`, then `io` | `toImageData`, `fromImageData`, `toSoundData` |
|
||||
| LuaJIT | `io.open` | |
|
||||
| luau CLI | none | |
|
||||
<!-- formats:begin -->
|
||||
174 formats. Generated from the format contracts by `tools/gen_registry.py`; [docs/FORMATS.md](docs/FORMATS.md)
|
||||
adds each format's capabilities.
|
||||
|
||||
- **Paths.** A string is read as a path only on hosts with files, when it looks like one (short, no NUL / newline)
|
||||
and the file exists, or when `opts.path = true`; `opts.data = true` forces bytes. Files next to a loaded model
|
||||
(OBJ `.mtl`, glTF `.bin` and textures) are found through `opts.resolve`, which the api fills in for paths.
|
||||
- **LuaJIT trace tuning.** On load the host raises LuaJIT's trace limits (`jit.opt.start("maxtrace=8000",
|
||||
"maxmcode=65536")`): the big decoders (Opus CELT, VP8, H.264, MPEG-1) outgrow the defaults and fall back to the
|
||||
interpreter (2x or more slower). Set `_G.ROSETTA_NO_JIT_TUNE = true` before requiring the library to leave the
|
||||
JIT settings alone.
|
||||
| Category | Format | Extensions | Read | Write |
|
||||
|---|---|---|---|---|
|
||||
| Images | ani | .ani | yes | yes |
|
||||
| Images | blp | .blp | yes | yes |
|
||||
| Images | bmp | .bmp .dib | yes | yes |
|
||||
| Images | dds | .dds | yes | yes |
|
||||
| Images | exr | .exr | yes | yes |
|
||||
| Images | gif | .gif | yes | yes |
|
||||
| Images | hdr | .hdr .pic .rgbe | yes | yes |
|
||||
| Images | icns | .icns | yes | yes |
|
||||
| Images | ico | .ico .cur | yes | yes |
|
||||
| Images | ilbm | .iff .ilbm .lbm .pbm | yes | yes |
|
||||
| Images | jpeg | .jpg .jpeg .jpe .jfif | yes | yes |
|
||||
| Images | ktx | .ktx2 .ktx | yes | yes |
|
||||
| Images | pcx | .pcx .pcc .dcx | yes | yes |
|
||||
| Images | png | .png .apng | yes | yes |
|
||||
| Images | pnm | .pnm .pbm .pgm .ppm .pam .pfm | yes | yes |
|
||||
| Images | qoi | .qoi | yes | yes |
|
||||
| Images | sgi | .sgi .rgb .rgba .bw .int .inta | yes | yes |
|
||||
| Images | sunras | .ras .sun .rs .im1 .im8 .im24 .im32 | yes | yes |
|
||||
| Images | tga | .tga .icb .vda .vst .tpic | yes | yes |
|
||||
| Images | tiff | .tif .tiff | yes | yes |
|
||||
| Images | tim | .tim | yes | yes |
|
||||
| Images | vtf | .vtf | yes | - |
|
||||
| Images | webp | .webp | yes | yes |
|
||||
| Images | xbm | .xbm .bm | yes | yes |
|
||||
| Images | xpm | .xpm .pm | yes | yes |
|
||||
| Audio | aac | .aac .adts | yes | - |
|
||||
| Audio | ac3 | .ac3 .a52 | yes | - |
|
||||
| Audio | adpcm | .adpcm .ima | yes | yes |
|
||||
| Audio | adx | .adx | yes | yes |
|
||||
| Audio | aiff | .aiff .aif .aifc .afc | yes | yes |
|
||||
| Audio | ape | .ape | yes | - |
|
||||
| Audio | au | .au .snd | yes | yes |
|
||||
| Audio | brstm | .brstm .bcstm .bfstm | yes | - |
|
||||
| Audio | caf | .caf .caff | yes | yes |
|
||||
| Audio | flac | .flac .oga | yes | yes |
|
||||
| Audio | m4a | .m4a .m4b .m4r | yes | yes |
|
||||
| Audio | mp3 | .mp3 .mp2 .mp1 .mpga | yes | yes |
|
||||
| Audio | mpc | .mpc .mp+ .mpp | yes | - |
|
||||
| Audio | opus | .opus | yes | yes |
|
||||
| Audio | qoa | .qoa | yes | yes |
|
||||
| Audio | tta | .tta | yes | - |
|
||||
| Audio | vag | .vag | yes | yes |
|
||||
| Audio | voc | .voc | yes | yes |
|
||||
| Audio | vorbis | .ogg .oga | yes | yes |
|
||||
| Audio | wav | .wav .wave .rf64 .bw64 | yes | yes |
|
||||
| Audio | wavpack | .wv | yes | - |
|
||||
| Video | avi | .avi | yes | yes |
|
||||
| Video | fli | .fli .flc .flx | yes | - |
|
||||
| Video | flv | .flv | yes | yes |
|
||||
| Video | h264 | .h264 .264 .avc .jsv .26l .jvt | yes | yes |
|
||||
| Video | mkv | .mkv .webm .mka .mk3d | yes | yes |
|
||||
| Video | mp4 | .mp4 .m4v .mov .qt .3gp .3g2 .mj2 | yes | yes |
|
||||
| Video | mpegps | .mpg .mpeg .vob .m1v .mpv .dat | yes | - |
|
||||
| Video | mpegts | .ts .m2ts .mts .tsv | yes | - |
|
||||
| Video | ogv | .ogv .ogg | yes | yes |
|
||||
| Video | smk | .smk | yes | - |
|
||||
| Video | y4m | .y4m | yes | yes |
|
||||
| 3D models | 3ds | .3ds | yes | yes |
|
||||
| 3D models | 3mf | .3mf | yes | yes |
|
||||
| 3D models | b3d | .b3d | yes | - |
|
||||
| 3D models | bsp | .bsp | yes | - |
|
||||
| 3D models | dae | .dae .zae | yes | yes |
|
||||
| 3D models | fbx | .fbx | yes | yes |
|
||||
| 3D models | gltf | .gltf .glb | yes | yes |
|
||||
| 3D models | iqm | .iqm | yes | yes |
|
||||
| 3D models | ldraw | .ldr .mpd .dat | yes | - |
|
||||
| 3D models | lwo | .lwo .lxo | yes | - |
|
||||
| 3D models | mca | .mca .mcr | yes | - |
|
||||
| 3D models | md2 | .md2 | yes | - |
|
||||
| 3D models | md3 | .md3 | yes | - |
|
||||
| 3D models | md5 | .md5mesh .md5anim | yes | - |
|
||||
| 3D models | mdl | .mdl | yes | - |
|
||||
| 3D models | ms3d | .ms3d | yes | yes |
|
||||
| 3D models | obj | .obj | yes | yes |
|
||||
| 3D models | off | .off | yes | yes |
|
||||
| 3D models | ply | .ply | yes | yes |
|
||||
| 3D models | pmx | .pmx .pmd | yes | - |
|
||||
| 3D models | qb | .qb | yes | yes |
|
||||
| 3D models | rbxm | .rbxm .rbxl | yes | yes |
|
||||
| 3D models | rbxmx | .rbxmx .rbxlx | yes | yes |
|
||||
| 3D models | robloxmesh | .mesh | yes | yes |
|
||||
| 3D models | schematic | .schem .schematic .litematic | yes | yes |
|
||||
| 3D models | smd | .smd | yes | yes |
|
||||
| 3D models | stl | .stl | yes | yes |
|
||||
| 3D models | usda | .usda .usd .usdz | yes | yes |
|
||||
| 3D models | vox | .vox | yes | yes |
|
||||
| 3D models | vrml | .wrl .wrz .vrml | yes | yes |
|
||||
| 3D models | x | .x | yes | - |
|
||||
| 3D models | x3d | .x3d .x3dv .x3dz .x3dvz .x3db | yes | yes |
|
||||
| CAD | step | .step .stp .p21 | yes | yes |
|
||||
| Fonts | bdf | .bdf | yes | yes |
|
||||
| Fonts | bmfont | .fnt | yes | yes |
|
||||
| Fonts | eot | .eot | yes | yes |
|
||||
| Fonts | fon | .fon .fnt | yes | - |
|
||||
| Fonts | hershey | .jhf | yes | - |
|
||||
| Fonts | pcf | .pcf | yes | - |
|
||||
| Fonts | psf | .psf .psfu | yes | yes |
|
||||
| Fonts | ttf | .ttf .otf .ttc .otc | yes | - |
|
||||
| Fonts | type1 | .pfb .pfa .t1 | yes | - |
|
||||
| Fonts | woff | .woff | yes | - |
|
||||
| Fonts | woff2 | .woff2 | yes | - |
|
||||
| Archives | 7z | .7z | yes | - |
|
||||
| Archives | adf | .adf | yes | - |
|
||||
| Archives | applesingle | .as .applesingle .appledouble | yes | yes |
|
||||
| Archives | ar | .a .ar .deb .lib | yes | yes |
|
||||
| Archives | arj | .arj | yes | - |
|
||||
| Archives | binhex | .hqx .hcx | yes | yes |
|
||||
| Archives | br | .br | yes | - |
|
||||
| Archives | bz2 | .bz2 .tbz2 .tbz | yes | - |
|
||||
| Archives | cab | .cab | yes | yes |
|
||||
| Archives | cpio | .cpio | yes | yes |
|
||||
| Archives | d64 | .d64 .d71 .d81 | yes | yes |
|
||||
| Archives | fat | .img .ima .vfd .flp .fat | yes | yes |
|
||||
| Archives | grp | .grp | yes | yes |
|
||||
| Archives | gzip | .gz .tgz .gzip | yes | yes |
|
||||
| Archives | iso | .iso | yes | - |
|
||||
| Archives | lha | .lzh .lha .lzs | yes | yes |
|
||||
| Archives | lz4 | .lz4 .tlz4 | yes | yes |
|
||||
| Archives | macbinary | .bin .macbin | yes | yes |
|
||||
| Archives | mpq | .mpq .w3x .w3m .sc2map .sc2data .s2ma .scm .scx | yes | - |
|
||||
| Archives | pak | .pak .sin | yes | yes |
|
||||
| Archives | rpm | .rpm | yes | - |
|
||||
| Archives | tar | .tar | yes | yes |
|
||||
| Archives | uu | .uu .uue .xxe .b64 | yes | yes |
|
||||
| Archives | vpk | .vpk | yes | yes |
|
||||
| Archives | wad | .wad | yes | yes |
|
||||
| Archives | xz | .xz .txz .lzma | yes | - |
|
||||
| Archives | yenc | .yenc .ync | yes | yes |
|
||||
| Archives | z | .z .taz .tz | yes | yes |
|
||||
| Archives | zip | .zip .wsz | yes | yes |
|
||||
| Archives | zoo | .zoo | yes | - |
|
||||
| Archives | zst | .zst .tzst | yes | - |
|
||||
| Data | cbor | .cbor | yes | yes |
|
||||
| Data | csv | .csv .tsv | yes | yes |
|
||||
| Data | ini | .ini .cfg .conf .inf .desktop | yes | yes |
|
||||
| Data | json | .json .jsonl .ndjson .geojson | yes | yes |
|
||||
| Data | msgpack | .msgpack .mpk | yes | yes |
|
||||
| Data | nbt | .nbt .dat .mcstructure .dat_old | yes | yes |
|
||||
| Data | plist | .plist | yes | yes |
|
||||
| Data | snbt | .snbt | yes | yes |
|
||||
| Data | toml | .toml | yes | yes |
|
||||
| Data | xml | .xml .xsd .xsl .xslt .rss .atom .xhtml | yes | yes |
|
||||
| Data | yaml | .yaml .yml | yes | yes |
|
||||
| Vector graphics and tile maps | svg | .svg | yes | yes |
|
||||
| Vector graphics and tile maps | tiled | .tmx .tmj .tsx .tsj | yes | yes |
|
||||
| Layered images | aseprite | .aseprite .ase | yes | yes |
|
||||
| Layered images | ora | .ora | yes | yes |
|
||||
| Layered images | psd | .psd .psb | yes | yes |
|
||||
| Subtitles | ass | .ass .ssa | yes | yes |
|
||||
| Subtitles | srt | .srt | yes | yes |
|
||||
| Subtitles | vtt | .vtt .webvtt | yes | yes |
|
||||
| Music | 669 | .669 | yes | - |
|
||||
| Music | ahx | .ahx .thx | yes | - |
|
||||
| Music | far | .far | yes | - |
|
||||
| Music | hmp | .hmp .hmi | yes | - |
|
||||
| Music | hvl | .hvl | yes | - |
|
||||
| Music | it | .it | yes | - |
|
||||
| Music | med | .med .mmd0 .mmd1 .mmd2 .mmd3 .omed | yes | - |
|
||||
| Music | midi | .mid .midi .smf .kar .rmi | yes | yes |
|
||||
| Music | mod | .mod .m15 .stk .nst | yes | yes |
|
||||
| Music | mtm | .mtm | yes | - |
|
||||
| Music | mus | .mus | yes | - |
|
||||
| Music | okt | .okt .okta | yes | - |
|
||||
| Music | ptm | .ptm | yes | - |
|
||||
| Music | s3m | .s3m | yes | - |
|
||||
| Music | sf2 | .sf2 | yes | - |
|
||||
| Music | stm | .stm | yes | - |
|
||||
| Music | ult | .ult | yes | - |
|
||||
| Music | umx | .umx | yes | - |
|
||||
| Music | xm | .xm | yes | yes |
|
||||
| Music | xmi | .xmi .xmidi | yes | - |
|
||||
| Playlists | m3u | .m3u .m3u8 | yes | yes |
|
||||
| Playlists | pls | .pls | yes | yes |
|
||||
| Playlists | xspf | .xspf | yes | yes |
|
||||
<!-- formats:end -->
|
||||
|
||||
## Layout
|
||||
## Codecs and containers
|
||||
|
||||
```
|
||||
src/Rosetta/
|
||||
init.luau Registry.luau (generated) api: F.*
|
||||
ops/ editing on the standard types (ImageOps, MeshOps, LayerOps, AudioOps, ...)
|
||||
<category>/<fmt>/ formats: only what is specific to the format (parsing, mapping, writing)
|
||||
containers/ Archive AudioWrap Avi Chunks Cpio Demux Ebml Fat Iso9660 IsoBmff MacFile
|
||||
MpegEs MpegPs MpegTs Ogg Riff Tar Zip
|
||||
codecs/compress/ Brotli Bzip2 Deflate Explode Lz4 Lzh Lzma Lzw Lzx PackBits Quantum
|
||||
UnixCompress Xxh32 Zstd
|
||||
codecs/entropy/ Huffman RangeCoder
|
||||
codecs/image/ Bcn Blend Dct Etc Half Jpeg Pixels Quantize Raster Texel Texture Vp8 Vp8L Yuv
|
||||
codecs/audio/ Aac Ac3 Adpcm Alac Ape ApeTag Flac Hively Mdct MidiRender Mpa (MP1-3)
|
||||
Musepack Opus Pcm Qoa Resample SoundFont Stream Tracker Tta Vorbis
|
||||
VorbisComment WavPack
|
||||
codecs/video/ Dsp H263 H264 Legacy (FLI, Cinepak, MSV1, QT RLE, SMC, Smacker) Mpeg1 Mpeg2
|
||||
Theora Video (the codec registry)
|
||||
codecs/text/ Json Nbt Text Url Xml
|
||||
codecs/font/ Bitmap Cff GlyphNames TrueType
|
||||
codecs/model/ Draco Mat4 MeshFlatten Minecraft Polygon Rbx Rig Sampler Vrml
|
||||
host/ runtime adapters (only the api uses them)
|
||||
Types.luau the standard types + constructors
|
||||
core/ Adler32 Base64 Bits Bytes Crc16 Crc32 Err Input Md5 Sniff
|
||||
compat/luajit.lua tools/ tests/ (T.luau, <category>/<fmt>.luau, codecs/, containers/, gen/) docs/ licenses/
|
||||
examples/love/
|
||||
```
|
||||
<!-- codecs:begin -->
|
||||
Shared by the formats, not loadable on their own (`src/Rosetta/codecs/<domain>/`, `src/Rosetta/containers/`;
|
||||
[docs/FORMATS.md](docs/FORMATS.md) describes each). The bundles reach them as `F._internal("codecs/video/Mpeg1")`.
|
||||
|
||||
How the layers fit, the format contract, and what belongs in a format folder: [docs/STYLE.md](docs/STYLE.md).
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
bash tools/test.sh # fixtures, registry, build, every test under luau --codegen -O2 and LuaJIT, lint
|
||||
bash tools/test.sh png # one test (both runtimes), no lint
|
||||
bash tools/lint.sh # globals, types, headers, requires, native-throw, layers, deps, contract, DUP, docs
|
||||
bash tools/bench.sh # throughput on both runtimes (pin it: taskset -c 2 bash tools/bench.sh)
|
||||
python3 -I tools/build.py # build/roblox + build/luajit
|
||||
python3 -I tools/gen_registry.py # src/Rosetta/Registry.luau + docs/FORMATS.md from the format folders
|
||||
python3 -I tools/fixtures.py # tests/gen/*.luau from tools/fixtures/*.py (reference tools through nix)
|
||||
python3 -I tools/move.py codecs/image/Foo=codecs/video/Foo # move a module, rewriting every reference
|
||||
```
|
||||
|
||||
Tools: python3, and through nix: `luau` (+ `luau-analyze`), `luajit`, `darklua` 0.19, `rojo` (each script finds them
|
||||
on PATH or runs them with `nix shell nixpkgs#<tool>`); the fixture generators run ffmpeg, ImageMagick, libwebp, flac,
|
||||
lame, opus-tools, vorbis-tools, assimp, fontTools and others through nix.
|
||||
|
||||
The type checker's diagnostics may only go down: `tools/lint.sh` fails when their count passes
|
||||
`tools/lint_types_baseline.txt` (`LINT_TYPES=1` lists them, `LINT_TYPES_UPDATE=1` lowers the baseline).
|
||||
|
||||
## Performance
|
||||
|
||||
`tools/bench.luau` prints throughput per codec on both runtimes; run it pinned to one core
|
||||
(`taskset -c 2 bash tools/bench.sh`: on hybrid CPUs the core types differ 2x). LuaJIT numbers vary between runs (its
|
||||
trace recorder is randomised).
|
||||
| Domain | Modules |
|
||||
|---|---|
|
||||
| audio | Aac, Ac3, Adpcm, Alac, Ape, ApeTag, Flac, Hively, Mdct, MidiRender, Mpa, Musepack, Opus, Pcm, Qoa, Resample, SoundFont, Stream, Tracker, Tta, Vorbis, VorbisComment, WavPack |
|
||||
| compress | Brotli, Bzip2, Deflate, Explode, Lz4, Lzh, Lzma, Lzw, Lzx, PackBits, Quantum, UnixCompress, Xxh32, Zstd |
|
||||
| entropy | Huffman, RangeCoder |
|
||||
| font | Bitmap, Cff, GlyphNames, TrueType |
|
||||
| image | Bcn, Blend, Dct, Etc, Half, Jpeg, Pixels, Quantize, Raster, Texel, Texture, Vp8, Vp8L, Yuv |
|
||||
| model | Draco, Mat4, MeshFlatten, Minecraft, Polygon, Rbx, Rig, Sampler, Vrml |
|
||||
| text | Json, Nbt, Text, Url, Xml |
|
||||
| video | Dsp, H263, H264, Legacy, Mpeg1, Mpeg2, Theora, Video |
|
||||
| containers | Archive, AudioWrap, Avi, Chunks, Cpio, Demux, Ebml, Fat, Iso9660, IsoBmff, MacFile, MpegEs, MpegPs, MpegTs, Ogg, Riff, Tar, Zip |
|
||||
<!-- codecs:end -->
|
||||
|
||||
## Licence
|
||||
|
||||
See [licenses/NOTICE.md](licenses/NOTICE.md).
|
||||
TODO: no licence chosen yet. Third-party notices: [licenses/NOTICE.md](licenses/NOTICE.md).
|
||||
Reference in new issue
Block a user