5 # IT's annoying that the 1023,4 and 4095,16 almost, but dont exactly, cancel. UGH
6 # The intent is clearly to have the same mapping, but it's not done very well.
7 # Sony engineers and/or the Academy should pick one of these mappings for both.
10 return (math.pow(10.0,(((((x*1023.0)/4.0-16.0)/219.0)-0.616596-0.03)/0.432699))-0.037584)*0.9
13 if x < 0.030001222851889303:
14 return (x-0.030001222851889303 ) * 0.28258064516129
15 return (219.0*(math.pow(10.0, ((x-0.616596-0.03)/0.432699)) - 0.037584) /155.0)
18 for i in xrange(steps):
20 print x, SLog_to_lin(x), SLog2_to_lin(x)
22 def WriteSPI1D(filename, fromMin, fromMax, data):
23 f = file(filename,'w')
24 f.write("Version 1\n")
25 f.write("From %s %s\n" % (fromMin, fromMax))
26 f.write("Length %d\n" % len(data))
27 f.write("Components 1\n")
30 f.write(" %s\n" % value)
34 def Fit(value, fromMin, fromMax, toMin, toMax):
35 if fromMin == fromMax:
36 raise ValueError("fromMin == fromMax")
37 return (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin
42 ACESR = 0.8764457030 * Rraw + 0.0145411681 * Graw + 0.1090131290 * Braw;
43 ACESG = 0.0774075345 * Rraw + 0.9529571767 * Graw + -0.0303647111 * Braw;
44 ACESB = 0.0573564351 * Rraw + -0.1151066335 * Graw + 1.0577501984 * Braw;
48 ACESR = 1.0110238740 * Rraw + -0.1362526051 * Graw + 0.1252287310 * Braw;
49 ACESG = 0.1011994504 * Rraw + 0.9562196265 * Graw + -0.0574190769 * Braw;
50 ACESB = 0.0600766530 * Rraw + -0.1010185315 * Graw + 1.0409418785 * Braw;
55 RANGE = (-0.125, 1.125)
57 for i in xrange(NUM_SAMPLES):
58 x = i/(NUM_SAMPLES-1.0)
59 x = Fit(x, 0.0, 1.0, RANGE[0], RANGE[1])
60 data.append(SLog10_to_lin(x))
61 WriteSPI1D('slog2.spi1d', RANGE[0], RANGE[1], data)