FFmpeg 9.0
Loading...
Searching...
No Matches
raw_color_params.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Lynne <dev@lynne.ee>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVUTIL_RAW_COLOR_PARAMS_H
22#define AVUTIL_RAW_COLOR_PARAMS_H
23
24#include <stddef.h>
25#include <stdint.h>
26
27#include "frame.h"
28#include "rational.h"
29
32
33 /**
34 * The union is valid when interpreted as AVProResRawColorParams
35 * (codec.prores_raw).
36 */
38};
39
40/**
41 * ProRes RAW per-frame color transform, parsed from the prrf frame header.
42 *
43 * The correct rendering pipeline is:
44 * -> (sample - black_level) / (white_level - black_level)
45 * -> per-channel white balance (wb_red, 1.0 for G, wb_blue) pre-debayer
46 * -> debayer
47 * -> color_matrix (camera RGB -> CIE 1931 XYZ relative to D65)
48 * -> gain (scene-linear scale)
49 *
50 * Black/white levels live on the outer AVRawColorParams. The matrix output
51 * is linear-light CIE XYZ D65; convert to a working RGB space downstream.
52 *
53 * @note The struct must be allocated as part of AVRawColorParams using
54 * av_raw_color_params_alloc(). Its size is not a part of the public ABI.
55 */
56typedef struct AVProResRawColorParams {
57 /**
58 * White balance multiplier for the red channel, applied pre-debayer.
59 */
61
62 /**
63 * White balance multiplier for the blue channel, applied pre-debayer.
64 * (The green channel is implicit 1.0 for ProRes RAW)
65 */
67
68 /**
69 * 3x3 row-major color matrix from camera RGB to linear-light CIE 1931
70 * XYZ relative to the D65 illuminant, applied post-debayer.
71 * out[i] = sum_j color_matrix[i][j] * in[j].
72 */
74
75 /**
76 * Post-matrix scene-linear scaling factor. Encodes highlight headroom the
77 * encoder reserved; multiply the matrixed values by this to recover
78 * scene-linear light.
79 */
82
83/**
84 * Per-frame color information for a RAW camera codec. Carried as side data of
85 * type AV_FRAME_DATA_RAW_COLOR_PARAMS.
86 *
87 * The outer struct carries the fields every RAW codec exposes: the sensor's
88 * valid sample range and the white-balance correlated color temperature.
89 * The codec union holds the codec-specific transform parameters; `type`
90 * selects which member of the union is valid.
91 *
92 * The codec-specific transform (color_matrix or equivalent) always lands in
93 * linear-light CIE 1931 XYZ relative to the D65 illuminant, cameras don't
94 * have standard primaries, so XYZ is the only common target.
95 *
96 * @note The struct must be allocated using av_raw_color_params_alloc() or
97 * av_raw_color_params_create_side_data(). Its size is not a part of the
98 * public ABI.
99 */
100typedef struct AVRawColorParams {
101 /**
102 * Selects which member of `codec` is valid.
103 */
105
106 /**
107 * Lowest valid raw sample code (sensor black point)
108 */
110
111 /**
112 * Highest valid raw sample code (sensor white point)
113 */
115
116 /**
117 * Color temperature in Kelvin from with the camera's white balance.
118 * Informational; the math uses the codec-specific white-balance fields.
119 * 0 if not signaled.
120 */
121 uint32_t wb_cct;
122
123 /**
124 * Additional codec-specific fields.
125 */
126 union {
130
131/**
132 * Allocate an AVRawColorParams structure and zero-initialize it.
133 *
134 * @param size if non-NULL, set to sizeof(AVRawColorParams)
135 * @return the newly allocated struct or NULL on failure
136 */
138
139/**
140 * Allocate and add an AVRawColorParams structure to an existing AVFrame as
141 * AV_FRAME_DATA_RAW_COLOR_PARAMS side data.
142 *
143 * @return the newly allocated struct, or NULL on failure
144 */
146
147#endif /* AVUTIL_RAW_COLOR_PARAMS_H */
static AVFrame * frame
reference-counted frame API
Utilities for rational number calculation.
AVRawColorParamsType
@ AV_RAW_COLOR_PARAMS_NONE
@ AV_RAW_COLOR_PARAMS_PRORES_RAW
The union is valid when interpreted as AVProResRawColorParams (codec.prores_raw).
AVRawColorParams * av_raw_color_params_create_side_data(AVFrame *frame)
Allocate and add an AVRawColorParams structure to an existing AVFrame as AV_FRAME_DATA_RAW_COLOR_PARA...
AVRawColorParams * av_raw_color_params_alloc(size_t *size)
Allocate an AVRawColorParams structure and zero-initialize it.
This structure describes decoded (raw) audio or video data.
Definition frame.h:466
ProRes RAW per-frame color transform, parsed from the prrf frame header.
AVRational wb_red
White balance multiplier for the red channel, applied pre-debayer.
AVRational color_matrix[3][3]
3x3 row-major color matrix from camera RGB to linear-light CIE 1931 XYZ relative to the D65 illuminan...
AVRational wb_blue
White balance multiplier for the blue channel, applied pre-debayer.
AVRational gain
Post-matrix scene-linear scaling factor.
Rational number (pair of numerator and denominator).
Definition rational.h:58
Per-frame color information for a RAW camera codec.
AVProResRawColorParams prores_raw
AVRational black_level
Lowest valid raw sample code (sensor black point).
enum AVRawColorParamsType type
Selects which member of codec is valid.
union AVRawColorParams::@064000052037250306123267111255172234366153040136 codec
Additional codec-specific fields.
AVRational white_level
Highest valid raw sample code (sensor white point).
uint32_t wb_cct
Color temperature in Kelvin from with the camera's white balance.