FFmpeg
9.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libavutil
gain_map.h
Go to the documentation of this file.
1
/*
2
* This file is part of FFmpeg.
3
*
4
* FFmpeg is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* FFmpeg is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with FFmpeg; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
19
#ifndef AVUTIL_GAIN_MAP_H
20
#define AVUTIL_GAIN_MAP_H
21
22
#include <stddef.h>
23
24
#include "
rational.h
"
25
#include "
frame.h
"
26
27
#define AV_ISO21496_VERSION 0
28
#define AV_ISO21496_IDENTIFIER "urn:iso:std:iso:ts:21496:-1"
29
30
/**
31
* Parameters describing how to combine a gain map rendition with its base
32
* rendition to recover the alternate rendition, as defined by
33
* ISO 21496-1:2025 "Digital photography - Gain map metadata for image
34
* conversion".
35
*
36
* Note: sizeof(AVGainMapParams) is not part of the ABI. New fields may be
37
* added at the end of the struct.
38
*/
39
typedef
struct
AVGainMapParams
{
40
/**
41
* The version of this gain map struct. Reserved to allow future
42
* extensions of the struct. Must be <= AV_ISO21496_VERSION.
43
*/
44
int
version
;
45
46
/**
47
* If non-zero, the gain map is applied in the colour space of the base
48
* rendition; otherwise in that of the alternate rendition.
49
*/
50
int
use_base_color_space
;
51
52
/**
53
* log2 of the display headroom at which the base rendition is shown
54
* unmodified, and at which the map is applied in full.
55
*/
56
AVRational
base_hdr_headroom
;
57
AVRational
alternate_hdr_headroom
;
58
59
struct
AVGainMapChannel
{
60
/**
61
* log2-domain minimum and maximum gain applied by the map, i.e. the
62
* values the map's 0.0 and 1.0 endpoints decode to.
63
*/
64
AVRational
gain_map_min
;
65
AVRational
gain_map_max
;
66
67
/**
68
* Encoding gamma of the stored map values. Must be > 0.
69
*/
70
AVRational
gamma
;
71
72
/**
73
* Small constants added before the log-domain math to avoid a
74
* singularity at zero.
75
*/
76
AVRational
base_offset
;
77
AVRational
alternate_offset
;
78
}
channels
[3];
/* R, G, B */
79
80
/**
81
* Must be 1 or 3. If 1, all channels share the same set of parameters.
82
*/
83
int
nb_channels
;
84
}
AVGainMapParams
;
85
86
/**
87
* Parse the payload of an ISO 21496-1 gain map metadata blob.
88
*
89
* @param p struct to fill; overwritten on success, untouched on failure
90
* @param data payload, excluding container-specific identifiers
91
* @param size size of `data` in bytes
92
*
93
* @return >= 0 on success, or a negative AVERROR on failure
94
*/
95
int
av_gain_map_params_from_iso21496
(
AVGainMapParams
*p,
const
uint8_t *data,
96
size_t
size);
97
98
#define AV_GAIN_MAP_MAX_PAYLOAD_SIZE 141
/* = 5 + 2*8 + 3*5*8 */
99
100
/**
101
* Serialize an AVGainMapParams as an ISO 21496-1 gain map metadata blob.
102
*
103
* The output starts at the minimum_version field; the caller should prepend
104
* whatever identifier its container requires.
105
*
106
* @param p parameters to serialize
107
* @param buf Byte buffer to fill with the serialized data. Must contain at
108
* least AV_GAIN_MAP_MAX_PAYLOAD_SIZE bytes.
109
*
110
* @return Number of bytes written on success, or a negative AVERROR on failure
111
*
112
* @note Always succeeds if av_gain_map_params_validate() returns >= 0.
113
*/
114
int
av_gain_map_params_to_iso21496
(
const
AVGainMapParams
*p, uint8_t *buf);
115
116
/**
117
* Returns >= 0 if the given AVGainMapParams struct contains valid data;
118
* or a negative AVERROR otherwise.
119
*/
120
int
av_gain_map_params_validate
(
const
AVGainMapParams
*p);
121
122
/**
123
* Returns 1 if all channels of the gain map have identical parameters,
124
* 0 otherwise.
125
*/
126
int
av_gain_map_channels_identical
(
const
AVGainMapParams
*p);
127
128
/**
129
* Allocate an AVGainMapParams structure and initialize it to default values.
130
* The resulting pointer must be freed using av_free().
131
*
132
* @param size if non-NULL, set to sizeof(AVGainMapParams)
133
* @return the newly allocated struct, or NULL on failure
134
*/
135
AVGainMapParams
*
av_gain_map_params_alloc
(
size_t
*size);
136
137
/**
138
* Allocate and add an AVGainMapParams structure to an existing AVFrameSideData
139
* array as AV_FRAME_DATA_GAIN_MAP_PARAMS side data.
140
*
141
* @return the newly allocated struct, or NULL on failure
142
*/
143
AVGainMapParams
*
av_gain_map_params_create_side_data
(
AVFrameSideData
***sd,
int
*nb_sd);
144
145
#endif
/* AVUTIL_GAIN_MAP_H */
frame.h
reference-counted frame API
av_gain_map_params_validate
int av_gain_map_params_validate(const AVGainMapParams *p)
Returns >= 0 if the given AVGainMapParams struct contains valid data; or a negative AVERROR otherwise...
av_gain_map_params_to_iso21496
int av_gain_map_params_to_iso21496(const AVGainMapParams *p, uint8_t *buf)
Serialize an AVGainMapParams as an ISO 21496-1 gain map metadata blob.
av_gain_map_params_alloc
AVGainMapParams * av_gain_map_params_alloc(size_t *size)
Allocate an AVGainMapParams structure and initialize it to default values.
av_gain_map_params_create_side_data
AVGainMapParams * av_gain_map_params_create_side_data(AVFrameSideData ***sd, int *nb_sd)
Allocate and add an AVGainMapParams structure to an existing AVFrameSideData array as AV_FRAME_DATA_G...
av_gain_map_channels_identical
int av_gain_map_channels_identical(const AVGainMapParams *p)
Returns 1 if all channels of the gain map have identical parameters, 0 otherwise.
av_gain_map_params_from_iso21496
int av_gain_map_params_from_iso21496(AVGainMapParams *p, const uint8_t *data, size_t size)
Parse the payload of an ISO 21496-1 gain map metadata blob.
rational.h
Utilities for rational number calculation.
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition
frame.h:334
AVGainMapParams::AVGainMapChannel
Definition
gain_map.h:59
AVGainMapParams::AVGainMapChannel::gain_map_min
AVRational gain_map_min
log2-domain minimum and maximum gain applied by the map, i.e.
Definition
gain_map.h:64
AVGainMapParams::AVGainMapChannel::base_offset
AVRational base_offset
Small constants added before the log-domain math to avoid a singularity at zero.
Definition
gain_map.h:76
AVGainMapParams::AVGainMapChannel::gamma
AVRational gamma
Encoding gamma of the stored map values.
Definition
gain_map.h:70
AVGainMapParams::AVGainMapChannel::gain_map_max
AVRational gain_map_max
Definition
gain_map.h:65
AVGainMapParams::AVGainMapChannel::alternate_offset
AVRational alternate_offset
Definition
gain_map.h:77
AVGainMapParams
Parameters describing how to combine a gain map rendition with its base rendition to recover the alte...
Definition
gain_map.h:39
AVGainMapParams::alternate_hdr_headroom
AVRational alternate_hdr_headroom
Definition
gain_map.h:57
AVGainMapParams::channels
struct AVGainMapParams::AVGainMapChannel channels[3]
AVGainMapParams::version
int version
The version of this gain map struct.
Definition
gain_map.h:44
AVGainMapParams::nb_channels
int nb_channels
Must be 1 or 3.
Definition
gain_map.h:83
AVGainMapParams::use_base_color_space
int use_base_color_space
If non-zero, the gain map is applied in the colour space of the base rendition; otherwise in that of ...
Definition
gain_map.h:50
AVGainMapParams::base_hdr_headroom
AVRational base_hdr_headroom
log2 of the display headroom at which the base rendition is shown unmodified, and at which the map is...
Definition
gain_map.h:56
AVRational
Rational number (pair of numerator and denominator).
Definition
rational.h:58
Generated by
1.17.0