The as-shot white balance of TICO RAW frames, as red and blue multipliers relative to green, and the 3x3 matrix from white balanced camera RGB to CIE XYZ (D65). Nikon cameras write both with every frame.
A codec specific struct follows the precedent of the Panasonic RW2 parameters (e7420679a3, "lavu/raw_color_params: add Panasonic RW2 parameters") and of the ProRes RAW parameters. The matrix is applied after white balance and debayering. There is no gain field, because the Nikon metadata has no counterpart of the ProRes RAW gain: the matrix output is the final linear XYZ value. Signed-off-by: Alper Kagan AVCI <[email protected]> --- doc/APIchanges | 3 +++ libavutil/raw_color_params.h | 42 ++++++++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index dff8be3369..060ce41b8d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2026-06-23. API changes, most recent first: +2026-11-xx - xxxxxxxxxx - lavu 61.21.100 - raw_color_params.h + Add AV_RAW_COLOR_PARAMS_TICO_RAW and AVTicoRawColorParams. + 2026-11-xx - xxxxxxxxxx - lavc 63.29.100 - codec_id.h Add AV_CODEC_ID_TICO_RAW. diff --git a/libavutil/raw_color_params.h b/libavutil/raw_color_params.h index 8b3f5f2049..bb23295330 100644 --- a/libavutil/raw_color_params.h +++ b/libavutil/raw_color_params.h @@ -41,6 +41,11 @@ enum AVRawColorParamsType { * (codec.rw2). */ AV_RAW_COLOR_PARAMS_RW2, + /** + * The union is valid when interpreted as AVTicoRawColorParams + * (codec.tico_raw). + */ + AV_RAW_COLOR_PARAMS_TICO_RAW, }; /** @@ -109,6 +114,42 @@ typedef struct AVRW2RawColorParams { AVRational wb_blue; } AVRW2RawColorParams; +/** + * TICO RAW (Nikon N-RAW and R3D NE) as-shot color transform, from the + * metadata that the camera stores with every frame. + * + * The correct rendering pipeline is: + * -> (sample - black_level) / (white_level - black_level) + * -> per-channel white balance (wb_red, 1.0 for G, wb_blue) pre-debayer + * -> debayer + * -> color_matrix (white balanced camera RGB -> CIE 1931 XYZ relative to D65) + * + * Black/white levels live on the outer AVRawColorParams. The samples are + * linear sensor values, so the pipeline needs no linearization step. + * + * @note The struct must be allocated as part of AVRawColorParams using + * av_raw_color_params_alloc(). Its size is not a part of the public ABI. + */ +typedef struct AVTicoRawColorParams { + /** + * White balance multiplier for the red channel, applied pre-debayer. + */ + AVRational wb_red; + + /** + * White balance multiplier for the blue channel, applied pre-debayer. + * The green channel is implicitly 1.0. + */ + AVRational wb_blue; + + /** + * 3x3 row-major color matrix from white balanced camera RGB to linear-light + * CIE 1931 XYZ relative to the D65 illuminant, applied post-debayer. + * out[i] = sum_j color_matrix[i][j] * in[j]. + */ + AVRational color_matrix[3][3]; +} AVTicoRawColorParams; + /** * Per-frame color information for a RAW camera codec. Carried as side data of * type AV_FRAME_DATA_RAW_COLOR_PARAMS. @@ -155,6 +196,7 @@ typedef struct AVRawColorParams { union { AVProResRawColorParams prores_raw; AVRW2RawColorParams rw2; + AVTicoRawColorParams tico_raw; } codec; } AVRawColorParams; diff --git a/libavutil/version.h b/libavutil/version.h index cbdd0ad029..3a39a0b47c 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 61 -#define LIBAVUTIL_VERSION_MINOR 20 +#define LIBAVUTIL_VERSION_MINOR 21 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.56.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
