Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-develop

Source of release 0.1.0

0.1.0 / src / looks.lucb

## Looks: the film process of particular pictures, as their makers documented
## it (research_notes/Film stocks and chemistry/iconic_films.md has each one's
## sources: American Cinematographer, Kodak, the labs and timers). A look is a
## mode (recipe.lucb: the chain of stages) and the settings that make it this
## picture: the stock, the format, the development, the silver kept on the
## negative or the print (as the labs' infrared reading), flashing, the filter,
## printer lights. Where a stock is not here, the nearest one stands in, and
## where the record is silent, the setting is an inference; both are said below.
##
## Release prints went through duplicates: an interpositive and an internegative
## (two generations), and for Super 35 an optical squeeze to anamorphic; The
## Godfather's dye-transfer prints were struck from the cut camera negative.
import interop
from luce_std.collections import Buffer
import settings
import recipe
from parameters import Parameter, parameters, parameter_count

## A look: its name, the mode it starts from (recipe.mode_names), its settings
## over the mode's, and whether its recipe has a Lens.
struct Look:
    var name: str
    var mode: i64
    var settings: str
    var lens: bool = false

## Stocks are film_stock values (film_stocks.lucb's order, from 1): 1 EXR 500T
## 5298, 2 EXR 200T 5293, 3 Vision 500T 5279, 8 Vision3 200T 5213, 9 Vision3 250D
## 5207, 16 Ektachrome E100, 20 Double-X 5222, 22 Eastman Color Negative 5251,
## 23 5254. Formats: 1 Super 35, 2 16 mm, 3 65 mm, 4 Super 16, 5 IMAX 15/70. Modes: 0
## Television, 1 Cinema, 3 Black & White, 4 Super Panavision 70, 5 Digital
## Intermediate.
pub let look_count: usize = 20
let looks: Look[20] = [
    # NBC, 1994–2004: tungsten negative telecined to tape, timed to the broadcast's
    # stills: EXR 500T early, Vision 500T later.
    Look(name = "Friends, Seasons 1–5", mode = 0, settings = "film_stock=Kodak EXR 500T 5298;film_warmth=12;film_tint=7;film_contrast=-12;film_black=75;film_grain=110"),
    Look(name = "Friends, Seasons 6–10", mode = 0, settings = "film_stock=Kodak Vision 500T 5279;film_warmth=21;film_tint=2;film_black=60;film_grain=85"),
    # Kamiński: 5279 (and 5293, Fuji F-series: not here), Super 35, printed on 2383
    # with ENR at IR 65–75 on every release print.
    Look(name = "Munich (2005)", mode = 1, settings = "film_stock=Kodak Vision 500T 5279;film_format=Super 35;print_silver=0.7;print_generations=2;print_optical=1"),
    # Its bypassed scenes: the negative's bleach skipped and the negative pulled
    # 1½ stops (ECN-2 pull 1 is 2:30; 1½ stops extrapolated, about 2:10).
    Look(name = "Munich (2005), bypassed negative", mode = 1, settings = "film_stock=Kodak Vision 500T 5279;film_format=Super 35;develop_silver=100;develop_time=2.17;print_silver=0.7;print_generations=2;print_optical=1"),
    # EXR 200T 5293 pushed a stop (3:40), ½ Coral in place of the 85, 15 % flash
    # (Panaflasher), ENR on the prints that the lab ran at IR 1.00, and lenses
    # with their coatings stripped by Panavision.
    Look(name = "Saving Private Ryan (1998)", mode = 1, lens = true,
         settings = "film_stock=Kodak EXR 200T 5293;develop_time=3.67;film_filter=½ Coral;film_flash=15;print_silver=1.0;lens_coating=Uncoated;print_generations=2"),
    # Khondji: interiors on 5293 at box speed, Super 35; Deluxe CCE on release
    # prints (IR about 1.85).
    Look(name = "Se7en (1995)", mode = 1, settings = "film_stock=Kodak EXR 200T 5293;film_format=Super 35;print_silver=1.85;print_generations=2;print_optical=1"),
    # Cronenweth: Vision 500T 5279 at box speed for interiors and nights, Super
    # 35; ENR at IR 0.80 on a number of prints.
    Look(name = "Fight Club (1999)", mode = 1, settings = "film_stock=Kodak Vision 500T 5279;film_format=Super 35;print_silver=0.8;print_generations=2;print_optical=1"),
    # Willis: Eastman Color Negative (5254) rated 250 and pushed a stop, "a
    # half-stop underexposure"; ECN-1's push time an inference (12 → 16 min);
    # printed warm on one light: brassy yellow (the lights an inference), as
    # Technicolor dye transfer, the matrices made from the cut camera negative.
    Look(name = "The Godfather (1972)", mode = 1, settings = "film_stock=Eastman Color Negative 5254;exposure=-0.5;develop_time=16;print_blue=3;print_green=1;print_material=Technicolor dye transfer"),
    # Alcott: 5254, the whole film pushed a stop; no 85 on exteriors, the blue
    # timed out in printing (so balanced here); a Tiffen Low Contrast No. 3 on
    # every shot.
    Look(name = "Barry Lyndon (1975)", mode = 1, lens = true, settings = "film_stock=Eastman Color Negative 5254;develop_time=16;lens_diffusion=Low Contrast 3"),
    # Almendros: 5247 (not here: EXR 200T stands in), magic hour pushed a stop
    # with the 85 pulled; blown up optically to 70 mm.
    Look(name = "Days of Heaven (1978)", mode = 1, settings = "film_stock=Kodak EXR 200T 5293;develop_time=3.67;film_filter=None;print_optical=1"),
    # Super Panavision 70 on 65 mm Eastman Color: 5250 (5251, its successor at the
    # same speed, stands in), an 85 in the desert, ECN-1, 70 mm prints.
    Look(name = "Lawrence of Arabia (1962)", mode = 4, settings = "film_stock=Eastman Color Negative 5251;film_format=65 mm 5-perf;film_filter=85 (daylight)"),
    Look(name = "2001: A Space Odyssey (1968)", mode = 4, settings = "film_stock=Eastman Color Negative 5251;film_format=65 mm 5-perf"),
    # Sigel: the opening on Kodak daylight negative skip-bleached (Vision 250D
    # 5246 inferred; Vision3 250D stands in) ...
    Look(name = "Three Kings (1999), the base", mode = 1, settings = "film_stock=Kodak Vision3 250D 5207;develop_silver=100;print_generations=2"),
    # ... the rest on Ektachrome cross-processed in negative chemistry.
    Look(name = "Three Kings (1999), cross-processed", mode = 1, settings = "film_stock=Kodak Ektachrome E100;develop_process=C-41;print_generations=2"),
    # Deakins: bleach bypass on all the prints (Kays): a full bypass, IR 2.40. The
    # negative is not documented: EXR 200T stands in.
    Look(name = "Nineteen Eighty-Four (1984)", mode = 1, settings = "film_stock=Kodak EXR 200T 5293;print_silver=2.4;print_generations=2"),
    # Deakins and Cinesite: 5279 and 5293, Super 35, then the first full digital
    # intermediate: greens turned toward dry yellow and brown, color drained,
    # recorded to film and printed. The grade is an inference from their account
    # (secondary hue shifts).
    Look(name = "O Brother, Where Art Thou? (2000)", mode = 5, settings = "film_stock=Kodak Vision 500T 5279;film_format=Super 35;green_hue=-100;aqua_hue=-50;green_saturation=-35;yellow_saturation=-15;saturation=-10;film_warmth=10"),
    # Yeoman: Vision3 200T 7213 in Super 16, every frame, no 85 even in daylight;
    # the DI warmer and more saturated (his words; the amounts inferred).
    Look(name = "Moonrise Kingdom (2012)", mode = 0, settings = "film_stock=Kodak Vision3 200T 5213;film_format=Super 16;film_warmth=15;saturation=12"),
    # The French Dispatch's black and white: Double-X 5222 on Super 35, normal
    # processing.
    Look(name = "The French Dispatch (2021), black and white", mode = 3, settings = "film_stock=Eastman Double-X 5222;film_format=Super 35"),
    # Van Hoytema: IMAX 15-perf 65 mm (and System 65), Vision3 250D for day color
    # ("Fission"), printed on film.
    Look(name = "Oppenheimer (2023), color", mode = 1, settings = "film_stock=Kodak Vision3 250D 5207;film_format=IMAX 15/70"),
    # "Fusion": Double-X 5222 made in 65 mm for the film (its processing and
    # prints unpublished).
    Look(name = "Oppenheimer (2023), black and white", mode = 3, settings = "film_stock=Eastman Double-X 5222;film_format=IMAX 15/70")]

## How many looks there are, and look `at`'s name.
pub func count() -> i64:
    return (i64)look_count
pub func name(at: i64) -> str:
    return looks[(usize)at].name

## The sections a look sets whole: the film process, from the lens to the
## print. The light on set, exposure, the grade and the framing stay the photo's.
let process_sections: str[6] = ["Lens", "Filter", "Film", "Develop", "Scan", "Print"]

## Look `at` as settings text to stack on a photo: its mode's recipe (with a Lens
## put in if it wants one), its settings over the mode's, and every other
## process parameter at its default, so a look never keeps another's.
pub func text(at: i64) -> interop.Owned[str]!:
    let look = looks[(usize)at]
    let start = try settings.mode_text(look.mode)
    defer start.release()
    var made = settings.parse(start.value)
    settings.parse_into(&made, look.settings)
    let base = settings.defaults()
    if look.lens:
        made.recipe.lens = true
    var out: Buffer
    defer out.destroy()
    try settings.text_of(&made, &out)
    for index in 0..<parameter_count:
        let parameter = parameters[index]
        var process = false
        for section in process_sections:
            process = process or parameter.section == section
        let which = (Parameter)(u8)index
        if process and made.get(which) == base.get(which):
            if out.length() > 0:
                try out.put_byte(';')
            try out.put_text(parameter.name)
            try out.put_byte('=')
            try settings.put_value(&out, which, base.get(which))
    # The default recipe is not written: name it, so the look replaces a photo's.
    let usual = recipe.default_recipe()
    if made.recipe.equals(&usual):
        try out.put_text(";recipe=")
        try recipe.text_of(&made.recipe, &out)
    return try interop.copy_text(out.text())

test "every look reads back, its stock and mode as it says":
    for at in 0..<look_count:
        let written = text((i64)at) catch failure:
            assert(false)
            return
        defer written.release()
        let read = settings.parse(written.value)
        assert(read.get(.film_stock) >= 1.0)
        if looks[at].mode == 1:
            assert(read.recipe.has((i64)recipe.Stage.print) and read.recipe.has((i64)recipe.Stage.project))
    let munich = text(2) catch failure:
        assert(false)
        return
    defer munich.release()
    let read = settings.parse(munich.value)
    assert(read.get(.print_silver) == 0.7 and read.get(.film_stock) == 3.0)

test "a look with a lens puts one in its chain":
    let ryan = text(4) catch failure:
        assert(false)
        return
    defer ryan.release()
    let read = settings.parse(ryan.value)
    assert(read.recipe.has((i64)recipe.Stage.lens) and read.get(.lens_coating) == 2.0)