from math import *

TABLE_SIZE = 64
QUANT_STEP_SIZE = 8

def rnd_clip(x, threshold=0):
    x = int(x + 0.5)
    if x < threshold: return 0
    if x > 255: return 255
    return x

def maketab(f, threshold=0):
    return [rnd_clip(f(float(i)), threshold) for i in xrange(TABLE_SIZE)]

print "a:", maketab(lambda iA: 51 * pow(2, iA / QUANT_STEP_SIZE - 6) - 1, threshold=4)
print "b:", maketab(lambda iB: 0.5 * (iB * 6 / QUANT_STEP_SIZE) - 7.25)
print "tC0:", maketab(lambda iA: 6 * pow(2, iA / QUANT_STEP_SIZE - 7))
