Thursday, May 19, 2011

Curves - CineStyle and S-Log, a workflow choice.

The tweets have coming fast with lots of recent activity around shooting curves, particular with the release of Technicolor's CineStyle (tm) profile for Canon DSLRs. I'm all for specialized encoding curves as I once helped developed the Log-90 curve used in the SI-2K (helped by Jason Rodriguez.) What Technicolor has done for Canon was a harder task, to squeeze the most out of an 8-bit heavily compressed H.264 for the best post correct-ability. For the basics on what these curves are doing, please check out my ridiculously long post 10-bit Log vs 12-bit Linear, or for a briefer coverage there is good info on this at prolost.com. In this blog entry I discuss what it might mean for your color correction workflow.

The resulting images from a CineStyle capture are flat and perceptually desaturated, all due to a reverse S-curve that emphasizes shadow detail as if negative contrast is applied. Technicolor very nicely has provide the restoration S-curve LUT (Look Up Table) to normalize the image for video display. So the capture through presentation pipeline is this:

All this bending of the light backwards and forward is about reducing the distortion and noise where it would be most perceived, in the shadows. The sample path without the CineStyle camera profile (Standard or Neutral) would have the camera applying something close to the stand gamma curve. Somewhere in the image processing path you are likely to apply color correction; the two likely places are just before or just after the CineStyle to Gamma correction LUT. You may also color correct without using the technicolor restoration LUT, if you target output is for a video gamma you are producing some of this curves features manually (not a bad thing.)

Consequences of applying color correction after the LUT. First note, the sample LUT is only 8-bit so if you want to do high-precision color correction (10-bit or greater), let's hope the CC tool being used is interpolating values between entries (we do this in FirstLight.) The bigger issue is the LUT contains flat spots, for which no detail can be extracted later, deep interpolation will not help. In the restoration of display contrast some values are flatten to black or white levels, so that post correction can't reveal the lost data. I wouldn't recommend color correction after or on top of the LUT, other than for minor corrections.

Consequences of color correction before (or underneath) the LUT (or not using the LUT at all). While the 8-bit flat spotted output LUT would still seem bad, color correction and previewing the results through the LUT is still a fine solution. The 8-bit is not such an issue on final output, most displays and present formats are 8-bit -- you simply don't want to truncate to 8-bit before you have obtained the look your are after. A new issue arises, you are now color correcting upon a unknown (to most NLEs) non-standard curve. If your color tool has post corrections for exposure or white-balance (and some saturation tools) generally need to know what the source curve is, as these are linear light operations.

To help illustrate this issue, here is the math for one stop exposure correction : Lifting a linear light grey level of 20% up one stop should become 40%. Each stop up is times two, and each stop down you divide by two. Yet with a wrong curve applied (such as not removing a 2.2 gamma used in this example) the same one stop shift would move 20% grey to 93%. Things can get messed up. White balance is also a linear-light gain upon R, G, B channels, so don't expect that Kelvin temperature slider to work the same as source with different curves.

Now if you simply color correct until it looks good, who really cares if the math is wrong, after all this is a creative process not a lesson in the math of optics. To get an apparent exposure change will be tweaking gain and gamma control for approximately the same look. But if you want your color correction sliders to do what they say, and have a easier time in post, here is how CineForm does it in FirstLight and in the new (upcoming) GoPro CineForm Studio line of products.

FirstLight has a control panel you many have never used called "Workspace".

In the latest release of Mac and PC versions of Neo and Neo3D (v5.5.1) we have added CineStyle type curve ("CStyle") and Sony's S-Log curves for a current total of 12 different curve types. The defaults have the encode and decode curves set to "Video Gamma", this is correct for 99% of HD video source most users have been using. When you bring in a new CineStyle clip, default of Video Gamma is still set, but as this is only metadata you can change these parameters as you need. When changing both to "CStyle" the result is exactly as the source data looks, as shown in this screen grab.


Side note: You can also see that the picture profile information is stored within the Canon metadata (which FirstLight can display) -- these tests were performed using a Canon 7D.

While adding the metadata "CStyle" for encode and decode doesn't change the base image look, it now allows white-balance, exposure and saturation control to work correctly. There is no performance or quality impact to set this metadata correctly. As I'm sure you have many clips, and as this data is per clip information, you can simply copy and paste these metadata settings across all imported clips.

With your CStyle encode/decode set you can now freely color correct with or without the restoration LUT applied. The CStyleLUT is also provided under the Look metadata. The LUT is the last operation in the FirstLight color filter stack, so LUT flat spots will not impact the correct-ability of the source.

However we can avoid the LUT completely (useful if you intend further corrections outside of FirstLight) by setting the Output (decode) curve to Video Gamma (or Cineon or S-Log or whatever your workflow uses.) Now the CineStyle is developed to the target output curve*.

* this does not use the LUT, rather a continuous curve that models the look without flat spots or bit-depth limitations.

Revisiting the exposure example above, these images has been bumped up one stop (Exposure set to 2.0) resulting in two vastly different results.
Using CStyle vs ignoring the source curve.

Note: non-curve based exposure in FirstLight is simulated as producing this error is not standard operation in the tool. If I used the wrong encode curve, such at "Video Gamma" for a CineStyle source, the results are still wrong, but not quite as wrong as the right image shown here.

While I have used CineStyle for my testing here, the same benefits will be true for Sony's new F3 S-Log option -- I look forward to trying that out myself (hint hint, Sony.)

17 comments:

lordtangent said...

If understand it correctly, I could use Workspace to convert CineStyle to Linear Light?

Could I use it to create a chip chart (Lin to CineStyle) to create my own LUT externally?

David said...

That is correct. This is what I did to determine the curve in the first place. Shoot a chip with a neutral profile (assumed this was approximately 2.2 gamma) then converted that to linear. Switched to CineStyle and shot the same chart (locked down.) Then plotted the curve difference convert form linear to CineStyle, flipped the axis to determine CineStyle back to linear. I then modeled this curve for use in FirstLight.

Anonymous said...

So, this is the best of the a non-raw approach. The difference is, when operating with raw files, the bit depth is not altered. Here, applying sequentially the gamma curves decrease the bit depth?

David said...

No. If we where to apply a series of 8-bit LUTs for the curves, that would be bad, as less than 256 values would survive. All curves here are continuous math functions so all input levels are preserved, whether the source was 12-bit RAW or 8-bit H.264. In camera CineStyle selects the best range of 8-bit values (from deeper precision data) to maximize shadow detail without hurting tonal range.

Anonymous said...

Of course, got your point, thanks.

Ben Tolosa said...

Hi David,

I bought Cineform Neo last night. I used the Cinestyle picture profile on all my footage with my 7D. In FirstLight I did set Workspace>Decode As 2D, Encode Curve CStyle, Decode Curve CStyle. But under Look (3D LUT) > Look ; I cannot find the Cinestyle S-Curve or Look. It is just not on the list. The closest one (at least one that gives me a nice looking result) is called CF_FilmStyle_5279.

Do I need to download that particular Cinestyle 'Look' and somehow install it into FirstLight?

I have FirstLight Version 5.5.4.98 for Mac.

Please help.

Thanks VERY much David!!

Ben

David said...

Hi Ben,

We somewhat obsoleted the CineStyle Look if you set Encoder curve to CStyle and decode curve to Video Gamma 2.2. If you want to do it the way you describe, here is the Look file http://j.mp/iSidLT

Ben Tolosa said...

Excellent David. If I use this look, what should I pick for encode and decode?
Also, how can I install this file? Should I copy this look file into a certain folder? Which one? I am a Mac user.

Thanks VERY much for both present and future answers!!

Cheers :)

Anurag Agrawal said...

Dear Mr. David Newman,

I have been in touch with the Cineform products for a long time in past, when Mr. David Taylor was there. Now a days, I am learning 3D editing using Neo 3D and Adobe PP CS 5.5. Here is a request to you.

Is it possible to provide some such facility in Firstlight that may be used to convert a 2D video into 3D? Two eyes files are needed to produce a 3D video- Left and Right. If we treat a 2D video as Left eye file, is it possible to create a virtual Right eye file from this left eye file, using some kind of perspective manipulation and interpolation? i.e. if we have the left eye view then what would have been the right eye view, is we know that both eyes are 65mm apart?

Can I get your e-mail ID as well?

Kindly consider it..

David said...

They are many companies developing 2D to 3D conversion tool, but that is not in our plans (nor do I have recommendations.) You can use these external tools to generate right eye data, then use the CineForm 3D editing workflow.

Anonymous said...

I can't seem to get the Canon meta data to show up in First Light. I'm assuming it doesn't work the same with AVI files...

David said...

AVI files are no issue. When you convert from the Canon original MOVs, make sure the .THM files are in the same folder (they store the metadata.)

Crackjack said...

And when i try to add .mov to FirstLight? it says "There was a problem initilizing the player. Please try re-starting First Light"

David said...

Sound like a question for support.

Anonymous said...

I'm a newbie using Cineform and FCP 7. I have noticeable color shifts on my Toshiba passive display when switching between the two. Cineform has less contrast, milky and soft.

Gamma is set to 2.2 as well.

Any ideas?

David said...

Switching between the two? Source and CineForm? Depending of the camera type, CineForm conversions fixes some black and white level issues (Canon DSLR) so you get mode dynamic range. Increase dynamic range will be seen as reduced contrast / milkiness. If is not softer, yet perceived sharpness is related to contrast. So you are seeing good things, just takes a little getting used to -- the end result is better looking productions.

Voodooman said...

Can anyone please provide an exact one-line formula for programming purposes (coding a color correction shader for games and video player) for both converting linear color space to log, and converting log back to linear?