avcodec/jpegxl_parse{,r}: fix integer overflow for some malformed files
[FFMpeg-mirror.git] / libavfilter / palette.h
blobd3acc854ba0dff2cf1cad8c6556572fb31fe2378
1 /*
2 * Copyright (c) 2020 Björn Ottosson
3 * Copyright (c) 2022 Clément Bœsch <u pkh me>
5 * This file is part of FFmpeg.
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.
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.
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
22 #ifndef AVFILTER_PALETTE_H
23 #define AVFILTER_PALETTE_H
25 #include <math.h>
26 #include <stdint.h>
28 #include "libavutil/attributes.h"
30 struct Lab {
31 int32_t L, a, b;
34 /**
35 * Map sRGB 8-bit color component to a 16-bit linear value (gamma
36 * expand from electrical to optical value).
38 int32_t ff_srgb_u8_to_linear_int(uint8_t x);
40 /**
41 * Map a 16-bit linear value to a sRGB 8-bit color component (gamma
42 * compressed from optical to electrical value).
44 uint8_t ff_linear_int_to_srgb_u8(int32_t x);
46 /**
47 * sRGB (non-linear) to OkLab conversion
48 * @see https://bottosson.github.io/posts/oklab/
50 struct Lab ff_srgb_u8_to_oklab_int(uint32_t srgb);
52 /**
53 * OkLab to sRGB (non-linear) conversion
54 * @see https://bottosson.github.io/posts/oklab/
56 uint32_t ff_oklab_int_to_srgb_u8(struct Lab c);
59 * lowbias32 hashing from https://nullprogram.com/blog/2018/07/31/
61 uint32_t ff_lowbias32(uint32_t x);
63 #endif /* AVFILTER_PALETTE_H */