FFmpeg
9.0.2
Toggle main menu visibility
Loading...
Searching...
No Matches
libavutil
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
30
enum
AVRawColorParamsType
{
31
AV_RAW_COLOR_PARAMS_NONE
= 0,
32
33
/**
34
* The union is valid when interpreted as AVProResRawColorParams
35
* (codec.prores_raw).
36
*/
37
AV_RAW_COLOR_PARAMS_PRORES_RAW
,
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
*/
56
typedef
struct
AVProResRawColorParams
{
57
/**
58
* White balance multiplier for the red channel, applied pre-debayer.
59
*/
60
AVRational
wb_red
;
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
*/
66
AVRational
wb_blue
;
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
*/
73
AVRational
color_matrix
[3][3];
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
*/
80
AVRational
gain
;
81
}
AVProResRawColorParams
;
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
*/
100
typedef
struct
AVRawColorParams
{
101
/**
102
* Selects which member of `codec` is valid.
103
*/
104
enum
AVRawColorParamsType
type
;
105
106
/**
107
* Lowest valid raw sample code (sensor black point)
108
*/
109
AVRational
black_level
;
110
111
/**
112
* Highest valid raw sample code (sensor white point)
113
*/
114
AVRational
white_level
;
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
{
127
AVProResRawColorParams
prores_raw
;
128
}
codec
;
129
}
AVRawColorParams
;
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
*/
137
AVRawColorParams
*
av_raw_color_params_alloc
(
size_t
*size);
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
*/
145
AVRawColorParams
*
av_raw_color_params_create_side_data
(
AVFrame
*
frame
);
146
147
#endif
/* AVUTIL_RAW_COLOR_PARAMS_H */
frame
static AVFrame * frame
Definition
demux_decode.c:54
frame.h
reference-counted frame API
rational.h
Utilities for rational number calculation.
AVRawColorParamsType
AVRawColorParamsType
Definition
raw_color_params.h:30
AV_RAW_COLOR_PARAMS_NONE
@ AV_RAW_COLOR_PARAMS_NONE
Definition
raw_color_params.h:31
AV_RAW_COLOR_PARAMS_PRORES_RAW
@ AV_RAW_COLOR_PARAMS_PRORES_RAW
The union is valid when interpreted as AVProResRawColorParams (codec.prores_raw).
Definition
raw_color_params.h:37
av_raw_color_params_create_side_data
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...
av_raw_color_params_alloc
AVRawColorParams * av_raw_color_params_alloc(size_t *size)
Allocate an AVRawColorParams structure and zero-initialize it.
AVFrame
This structure describes decoded (raw) audio or video data.
Definition
frame.h:466
AVProResRawColorParams
ProRes RAW per-frame color transform, parsed from the prrf frame header.
Definition
raw_color_params.h:56
AVProResRawColorParams::wb_red
AVRational wb_red
White balance multiplier for the red channel, applied pre-debayer.
Definition
raw_color_params.h:60
AVProResRawColorParams::color_matrix
AVRational color_matrix[3][3]
3x3 row-major color matrix from camera RGB to linear-light CIE 1931 XYZ relative to the D65 illuminan...
Definition
raw_color_params.h:73
AVProResRawColorParams::wb_blue
AVRational wb_blue
White balance multiplier for the blue channel, applied pre-debayer.
Definition
raw_color_params.h:66
AVProResRawColorParams::gain
AVRational gain
Post-matrix scene-linear scaling factor.
Definition
raw_color_params.h:80
AVRational
Rational number (pair of numerator and denominator).
Definition
rational.h:58
AVRawColorParams
Per-frame color information for a RAW camera codec.
Definition
raw_color_params.h:100
AVRawColorParams::prores_raw
AVProResRawColorParams prores_raw
Definition
raw_color_params.h:127
AVRawColorParams::black_level
AVRational black_level
Lowest valid raw sample code (sensor black point).
Definition
raw_color_params.h:109
AVRawColorParams::type
enum AVRawColorParamsType type
Selects which member of codec is valid.
Definition
raw_color_params.h:104
AVRawColorParams::codec
union AVRawColorParams::@064000052037250306123267111255172234366153040136 codec
Additional codec-specific fields.
AVRawColorParams::white_level
AVRational white_level
Highest valid raw sample code (sensor white point).
Definition
raw_color_params.h:114
AVRawColorParams::wb_cct
uint32_t wb_cct
Color temperature in Kelvin from with the camera's white balance.
Definition
raw_color_params.h:121
Generated by
1.17.0