|
| | gentable.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| |
| | gentable.DCT_ROOT = os.environ.get('BSDEC_DCT_ROOT') |
| |
| | gentable.SRC = os.path.join(DCT_ROOT, 'src', 'supportpsx', 'dct.cc') |
| |
| | gentable.OUT = os.path.join(ROOT, 'bsdec', 'bsdec-vlc.h') |
| |
| | gentable.src = open(SRC).read() |
| |
| | gentable.m = re.search(r'c_vlcMaxLevel\[32\]\s*=\s*\{([^}]*)\}', src) |
| |
| list | gentable.maxlvl = [int(x) for x in m.group(1).split(',')] |
| |
| | gentable.pairs = re.findall(r'\{\s*(0x[0-9a-fA-F]+|0)\s*,\s*(\d+)\s*\}', m.group(1)) |
| |
| | gentable.EOB = one(r'c_vlcEob\s*=\s*\{\s*(0x[0-9a-fA-F]+)\s*,\s*(\d+)\s*\}', 'eob') |
| |
| | gentable.ESC = one(r'c_vlcEsc\s*=\s*\{\s*(0x[0-9a-fA-F]+)\s*,\s*(\d+)\s*\}', 'esc') |
| |
| list | gentable.syms = [] |
| |
| | gentable.c |
| |
| | gentable.b |
| |
| list | gentable.codes = [s[0] for s in syms] |
| |
| | gentable.MAXNZ = max(len(c) - len(c.lstrip('0')) for c in codes) |
| |
| list | gentable.groups = [[] for _ in range(MAXNZ + 1)] |
| |
| | gentable.n = len(c) - len(c.lstrip('0')) |
| |
| list | gentable.widths = [max(len(c) - n - 1 for c, _, _, _ in g) for n, g in enumerate(groups)] |
| |
| list | gentable.tables = [] |
| |
| list | gentable.offsets = [] |
| |
| int | gentable.total = 0 |
| |
| list | gentable.w = widths[n] |
| |
| list | gentable.slots = [None] * (1 << w) |
| |
| | gentable.suf = c[n + 1:] |
| |
| | gentable.nbits = len(suf) |
| |
| int | gentable.base = int(suf, 2) if nbits else 0 |
| |
| tuple | gentable.idx = (base << (w - nbits)) | extra |
| |
| int | gentable.INVALID = 0 |
| |
| | gentable.holes = sum(1 for t in tables for e in t if e is None) |
| |
| int | gentable.pad = 32 - len(widths) |
| |
| str | gentable.line = ' ' |
| |
| str | gentable.tok = ' 0x%08x,' % pack(e) |
| |
| | gentable.luma = dcbook('c_dcSizeLuma') |
| |
| | gentable.chroma = dcbook('c_dcSizeChroma') |
| |
| list | gentable.pats = [format(c, '0%db' % b) for c, b in bk] |
| |