chunked build: one chunk per unit (no neighbour packing: host/Roblox alone, PNG no longer pulls Blend / Cpio); H.264 entropy coders in chunks of their own (Decoder requires CABAC or CAVLC on the first slice; Cabac / Cavlc tables out of Tables); Brotli dictionary in Brotli/Dictionary (its own chunk, on the first dictionary reference); load check: unknown detect, PNG load, H.264 CAVLC / CABAC open each require exactly their chunks
This commit is contained in:
1 parent
8fd5a4c3f2
commit
05a44e1193
18 files changed
+5986
-3906
No files matched your search
+19
-9
@@ -1,13 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
# Brotli static data generator (python3 -I tools/brotli_static.py [brotli-source-dir]): writes
|
||||
# src/Rosetta/codecs/compress/Brotli/Static.luau from the official brotli C sources (MIT; licenses/brotli-LICENSE.txt):
|
||||
# the 122784-byte RFC 7932 static dictionary (c/common/dictionary_inc.h, stored deflated + base64), the context
|
||||
# lookup table (c/common/context.c) and the 121 word transforms (c/common/transform.c).
|
||||
# src/Rosetta/codecs/compress/Brotli/Dictionary.luau and Static.luau from the official brotli C sources (MIT;
|
||||
# licenses/brotli-LICENSE.txt): the 122784-byte RFC 7932 static dictionary (c/common/dictionary_inc.h, stored
|
||||
# deflated + base64; a module of its own, loaded on the first dictionary reference), and its size and CRC-32, the
|
||||
# context lookup table (c/common/context.c) and the 121 word transforms (c/common/transform.c).
|
||||
# Without an argument the source comes from `nix build nixpkgs#brotli.src`.
|
||||
import base64, os, re, subprocess, sys, zlib
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
OUT = os.path.join(ROOT, "src", "Rosetta", "codecs", "Brotli", "Static.luau")
|
||||
OUT = os.path.join(ROOT, "src", "Rosetta", "codecs", "compress", "Brotli", "Static.luau")
|
||||
OUT_DICT = os.path.join(ROOT, "src", "Rosetta", "codecs", "compress", "Brotli", "Dictionary.luau")
|
||||
|
||||
|
||||
def c_array(text, name):
|
||||
@@ -49,18 +51,26 @@ def main():
|
||||
trans = c_array(tr_text, "kTransformsData")
|
||||
assert len(psmap) == 50 and len(trans) == 363
|
||||
z = zlib.compress(dictionary, 9)
|
||||
dlines = [
|
||||
"--!strict",
|
||||
"-- codecs/compress/Brotli/Dictionary: GENERATED by tools/brotli_static.py from the brotli C sources (MIT, Google; see",
|
||||
"-- licenses/brotli-LICENSE.txt) - do not edit. The RFC 7932 static dictionary (122784 bytes, deflated, base64).",
|
||||
"return {",
|
||||
"\tdictionary = {",
|
||||
]
|
||||
dlines += ['\t\t"%s",' % c for c in b64_chunks(z)] + ["\t},", "}", ""]
|
||||
with open(OUT_DICT, "w") as f:
|
||||
f.write("\n".join(dlines))
|
||||
lines = [
|
||||
"--!strict",
|
||||
"-- codecs/compress/Brotli/Static: GENERATED by tools/brotli_static.py from the brotli C sources (MIT, Google; see",
|
||||
"-- licenses/brotli-LICENSE.txt) - do not edit. The RFC 7932 static dictionary (122784 bytes, deflated, base64),",
|
||||
"-- the context lookup table (Appendix B, 4 modes x 512) and the 121 word transforms (Appendix B).",
|
||||
"-- licenses/brotli-LICENSE.txt) - do not edit. The RFC 7932 static dictionary's size and CRC-32 (the dictionary is in",
|
||||
"-- Brotli/Dictionary), the context lookup table (Appendix B, 4 modes x 512) and the 121 word transforms (Appendix B).",
|
||||
"return {",
|
||||
"\tdictionarySize = %d," % len(dictionary),
|
||||
"\tdictionaryCrc = %d," % zlib.crc32(dictionary),
|
||||
"\tdictionary = {",
|
||||
]
|
||||
lines += ['\t\t"%s",' % c for c in b64_chunks(z)]
|
||||
lines += ["\t},", "\tcontext = {"]
|
||||
lines += ["\tcontext = {"]
|
||||
lines += ['\t\t"%s",' % c for c in b64_chunks(ctx)]
|
||||
lines += ["\t},"]
|
||||
lines += ['\tprefixSuffix = "%s",' % base64.b64encode(ps).decode()]
|
||||
|
||||
Reference in new issue
Block a user