## Reverse Engineering S-Cinetone

### The S-Cinetone Whitepaper

Sony published the S-Cinetone whitepaper. Page 4 of the whitepaper graphs of the transfer function, repeated here for clarity:  Looking at the blue line on the graph (which is the Rec 709 transfer function, and therefore we know what it is) it is clear that the y-axis is encoded value, and the x-axis is linear light. (And I guess we'll never know why it isn't labelled as such).

In principle, all that needs to be done is to fit a mathematical formula to the orange line in the graphs and we're done.

### Tracing and Scaling the Graph

The next step is sit done with a ruler and generate a set of coordinates of S-Cinetone transfer function (the orange line) from the white paper graphs. I've also scaled both axis so that the the graph goes through (0,0) and (1,1). This is simple to do, firstly setting the black and white level so the y-axis makes sense, and the choose the x-axis scaling that puts the graph through (1,1). The exact scaling used is:

• linear light = whitepaper x-axis / 211
• encoded = (whitepaper y-axis - (4/255)) / (251/255)

It is probably best to think of the y-axis magic numbers as resulting from the following black and white levels:

• black level = 4/255
• white level = 255/255

### Other Transfer Functions

When reverse engineering you often have to make educated guesses, so it always helps to have an idea as what might have influenced the design. In this case, it helps to have a look at the various other transfer functions in use to see what they do.

• DCI is a pure gamma curve (with gamma set to 2.6).
• Rec 709 is a mixture of a gamma curve (with a gamma of 2.22ish) and a linear bit for very dark colors.
• Sony S-Log3 is a mixture of a log curve and a linear bit for very dark colors.
• Rec 2100 HLG is a mixture a log curve and a gamma curve (with a gamma of 2) for the midtones and shadows.

From that quick overview it is clear that gamma curves and log curves seem to be common choices when someone designs a transfer function.

### Is S-Cinetone anything like a Log or a Gamma Curve?

#### Log Curve

The 'standard' formula for a log curve is something like:

• encoded = logbase(linear light × c1 + alpha) × c2 + c3

But this can be simplified. If you choose a different value for c1 and the base, you can get the exact same curve by choosing different values for alpha and c2. And, even better, when checking if the transfer function is anything like a log curve the values for c2 and c3 don't matter at all.

So, to see if any (or all) of the S-Cinetone transfer function is a log curve, I just plot a graph with the y-axis = encoded, and the x-axis = log10(linear light + alpha): For this graph I tweaked the value of alpha to get the graph with the straightest line. For this graph I used alpha = -0.14.

If S-Cinetone were a pure log function, then this graph would show a perfect straight blue line. Looking at the graph we can see that S-Cinetone isn't a pure log curve, but it does look like the upper part of the curve is a log curve. Which is the same idea as Rec 2100 HLG (where the lower part is a gamma curve) and S-Log3 (where the lower part of the curve is tiny and linear).

#### Gamma Curve

The 'standard' formula for a gamma curve is something like:

• encoded = (linear light(1/gamma)) × c1 + c2

As before the values of c1 and c2 don't matter when checking if the transfer function is anything like a gamma curve.

So, to see if any (or all) of the S-Cinetone transfer function is a gamma curve, I just plot a graph with the y-axis = encoded, and the x-axis = linear light(1/gamma): For this graph I tweaked the value of gamma to get the graph with the straightest line. For this graph I used gamma = 2.6, i.e the same gamma as DCI-P3.

If S-Cinetone were a pure gamma function, then this graph would show a perfect straight blue line (assuming the correct gamma value was used when plotting it). Looking at the graph we can see that S-Cinetone isn't a pure gamma curve, but it does look like the lower part of the curve is a gamma curve. Which is the same idea as Rec 2100 HLG.

### Designing and Fitting a Formula

Using the intuition gathered above, we can assume that the S-Cinetone transfer function looks something like this:

•  encoded = log10(linear light + c1) × c2 + c3 , when cut1 ≤ linear light = (linear lightc4) × c5 + c6 , when cut2 ≤ linear light < cut1 = linear light × c7 , otherwise where c3 and c6 are forced so that the curve is continuous

At this stage, I ran a optimiser to choose the values for the unforced coefficients (c1, c2, c4, c5, c7, cut1, and cut2) to best fit the graph from the white paper.

(I also tried a formula without the linear part, that fit really well except for the very low levels of light. So I added the linear part and re-ran the optimisation).

### S-Cinetone Transfer Function

The reverse engineered S-Cinetone transfer function definition is:

•  encoded = log10(linear light - 0.15158968) × 0.31147377 + 1.01719286 , when 0.24962451 ≤ linear light = (linear light0.37808537) × 1.53954886 - 0.20796195 , when 0.01762172 ≤ linear light < 0.24962451 = linear light × 7.17441439 , otherwise

Graphing this function (red) against the published S-Cinetone graphs looks like this: If we undo the scaling in the "Tracing and Scaling the Graph" section, then we can plot this function on the original graphs from the whitepaper:  • whitepaper x-axis = linear light × 211
• whitepaper y-axis = encoded × (251/255) + (4/255)

As mentioned in the "Tracing and Scaling the Graph" section, it is probably best to think of the y-axis magic numbers as resulting from black and white levels:

• black level = 4/255
• white level = 255/255