Skip to main content

Module dng_opcodes

Module dng_opcodes 

Source
Expand description

DNG opcode lists (OpcodeList1/2/3, DNG spec 1.3+ chapter 7).

Opcode lists carry processing steps the camera maker specifies: bad-pixel repair, lens-shading gain maps (ubiquitous in smartphone DNGs), linearisation tables and polynomials, per-row/column offsets and scales, and geometric corrections.

FlashRaw parses all lists and applies the pixel-value opcodes to f32 planes (the high-level API does so by default, each list in its own domain; lists of tables and bad-pixel repairs on stored integers run on the u16 samples directly, with the same result); geometric opcodes (WarpRectilinear, WarpFisheye, TrimBounds) are parsed and reported but not applied.

Structs§

OpcodeEntry
One opcode of a list with its header fields.
PlaneImage
A mutable image the opcodes operate on: a width x height window (rows stride pixels apart, planes interleaved samples per pixel) placed at (x0, y0) in the coordinate system of the whole image the list describes, which is full_width x full_height (GainMap positions are relative to it).
Region
Area/plane selector shared by most pixel opcodes.
RowOps
A list of row-local opcodes prepared for one window geometry, applied a row at a time (e.g. by a streaming pipeline that produces the rows band by band). For every row this gives exactly what apply gives on the whole window.

Enums§

Opcode
A parsed opcode.

Traits§

Sample
Sample types the opcodes run on: f32 for every opcode, u16 (stored integer values) for the lists apply_u16 accepts.

Functions§

apply
Apply pixel opcodes to img, whose samples are in the units the list expects (OpcodeList1: stored values; OpcodeList2: linear reference values in [0, 1]; OpcodeList3: demosaiced values). cfa_period is the CFA repeat (2 for Bayer) used by the bad-pixel opcodes; value_scale maps sample values to the 16-bit table/constant domain (1 for stored values, 65535 for normalised ones). Returns the names of opcodes that were not applied (geometric and unknown ones).
apply_u16
apply on stored integer samples (value scale 1), for lists made of tables and bad-pixel repairs: no f32 copy of the image is needed and the result is identical to the f32 pass rounded back to u16. Returns None (leaving img untouched) for lists it does not cover.
parse
Parse an opcode list (always big-endian, per the DNG spec).
parse_entries
parse keeping each opcode’s id and flags.
u16_exact
Whether apply_u16 gives exactly what apply gives on the same values converted to f32 (value scale 1) and rounded back: tables look up rounded values and repairs produce means that only a final rounding (or a table) reads afterwards.