FFmpeg
Loading...
Searching...
No Matches
cms.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2024 Niklas Haas
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 SWSCALE_CMS_H
22#define SWSCALE_CMS_H
23
24#include <stdbool.h>
25
26#include "libavutil/csp.h"
27
28#include "csputils.h"
29#include "swscale.h"
30#include "format.h"
31
32/* Minimum, maximum, and default knee point for perceptual tone mapping [0,1] */
33#define PERCEPTUAL_KNEE_MIN 0.10f
34#define PERCEPTUAL_KNEE_MAX 0.80f
35#define PERCEPTUAL_KNEE_DEF 0.40f
36
37/* Ratio between source average and target average. */
38#define PERCEPTUAL_ADAPTATION 0.40f
39
40/* (Relative) chromaticity protection zone for perceptual mapping [0,1] */
41#define PERCEPTUAL_DEADZONE 0.30f
42
43/* Contrast setting for perceptual tone mapping. [0,1.5] */
44#define PERCEPTUAL_CONTRAST 0.50f
45
46/* Tuning constants for overriding the contrast near extremes */
47#define SLOPE_TUNING 1.50f /* [0,10] */
48#define SLOPE_OFFSET 0.20f /* [0,1] */
49
50/* Strength of the perceptual saturation mapping component [0,1] */
51#define PERCEPTUAL_STRENGTH 0.80f
52
53/* Knee point to use for perceptual soft clipping [0,1] */
54#define SOFTCLIP_KNEE 0.70f
55
56/* I vs C curve gamma to use for colorimetric clipping [0,10] */
57#define COLORIMETRIC_GAMMA 1.80f
58
59/* Struct describing a color mapping operation */
65
66/**
67 * Returns true if the given color map is a semantic no-op - that is,
68 * the overall RGB end to end transform would an identity mapping.
69 */
71
72/**
73 * Generates a single end-to-end color mapping 3DLUT embedding a static tone
74 * mapping curve.
75 *
76 * Returns 0 on success, or a negative error code on failure.
77 */
79
80/**
81 * Generates a split pair of 3DLUTS, going to IPT and back, allowing an
82 * arbitrary dynamic EETF to be nestled in between these two operations.
83 *
84 * See ff_sws_tone_map_generate().
85 *
86 * Returns 0 on success, or a negative error code on failure.
87 */
89 int size_input, int size_I, int size_PT,
90 const SwsColorMap *map);
91
92/**
93 * Generate a 1D LUT of size `size` adapting intensity (I) levels from the
94 * source to the destination color space. The LUT is normalized to the
95 * relevant intensity range directly. The second channel of each entry returns
96 * the corresponding 15-bit scaling factor for the P/T channels. The scaling
97 * factor k may be applied as `(1 << 15) - k + (PT * k >> 15)`.
98 *
99 * This is designed to be used with sws_gamut_map_generate_dynamic().
100 *
101 * Returns 0 on success, or a negative error code on failure.
102 */
103void ff_sws_tone_map_generate(v2u16_t *lut, int size, const SwsColorMap *map);
104
105#endif // SWSCALE_GAMUT_MAPPING_H
int ff_sws_color_map_generate_static(v3u16_t *lut, int size, const SwsColorMap *map)
Generates a single end-to-end color mapping 3DLUT embedding a static tone mapping curve.
Definition cms.c:685
void ff_sws_tone_map_generate(v2u16_t *lut, int size, const SwsColorMap *map)
Generate a 1D LUT of size size adapting intensity (I) levels from the source to the destination color...
Definition cms.c:749
bool ff_sws_color_map_noop(const SwsColorMap *map)
Returns true if the given color map is a semantic no-op - that is, the overall RGB end to end transfo...
Definition cms.c:34
int ff_sws_color_map_generate_dynamic(v3u16_t *input, v3u16_t *output, int size_input, int size_I, int size_PT, const SwsColorMap *map)
Generates a split pair of 3DLUTS, going to IPT and back, allowing an arbitrary dynamic EETF to be nes...
Definition cms.c:690
Colorspace value utility functions for libavutil.
SwsIntent
Definition swscale.h:210
const VDPAUPixFmtMap * map
SwsIntent intent
Definition cms.h:63
SwsColor src
Definition cms.h:61
SwsColor dst
Definition cms.h:62
external API header
int size