FFmpeg
palette.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Björn Ottosson
3  * Copyright (c) 2022 Clément Bœsch <u pkh me>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFILTER_PALETTE_H
23 #define AVFILTER_PALETTE_H
24 
25 #include <math.h>
26 #include <stdint.h>
27 
28 #include "libavutil/attributes.h"
29 
30 struct Lab {
31  int32_t L, a, b;
32 };
33 
34 /**
35  * Map sRGB 8-bit color component to a 16-bit linear value (gamma
36  * expand from electrical to optical value).
37  */
39 
40 /**
41  * Map a 16-bit linear value to a sRGB 8-bit color component (gamma
42  * compressed from optical to electrical value).
43  */
45 
46 /**
47  * sRGB (non-linear) to OkLab conversion
48  * @see https://bottosson.github.io/posts/oklab/
49  */
50 struct Lab ff_srgb_u8_to_oklab_int(uint32_t srgb);
51 
52 /**
53  * OkLab to sRGB (non-linear) conversion
54  * @see https://bottosson.github.io/posts/oklab/
55  */
56 uint32_t ff_oklab_int_to_srgb_u8(struct Lab c);
57 
58 /*
59  * lowbias32 hashing from https://nullprogram.com/blog/2018/07/31/
60  */
61 uint32_t ff_lowbias32(uint32_t x);
62 
63 #endif /* AVFILTER_PALETTE_H */
ff_linear_int_to_srgb_u8
uint8_t ff_linear_int_to_srgb_u8(int32_t x)
Map a 16-bit linear value to a sRGB 8-bit color component (gamma compressed from optical to electrica...
Definition: palette.c:118
Lab::a
int32_t a
Definition: palette.h:31
Lab::b
int32_t b
Definition: palette.h:31
ff_oklab_int_to_srgb_u8
uint32_t ff_oklab_int_to_srgb_u8(struct Lab c)
OkLab to sRGB (non-linear) conversion.
Definition: palette.c:194
ff_srgb_u8_to_linear_int
int32_t ff_srgb_u8_to_linear_int(uint8_t x)
Map sRGB 8-bit color component to a 16-bit linear value (gamma expand from electrical to optical valu...
Definition: palette.c:113
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ff_lowbias32
uint32_t ff_lowbias32(uint32_t x)
Definition: palette.c:211
Lab
Definition: palette.h:30
attributes.h
ff_srgb_u8_to_oklab_int
struct Lab ff_srgb_u8_to_oklab_int(uint32_t srgb)
sRGB (non-linear) to OkLab conversion
Definition: palette.c:170
int32_t
int32_t
Definition: audioconvert.c:56
Lab::L
int32_t L
Definition: palette.h:31