Commit 31c5f26a authored by Clément Bœsch's avatar Clément Bœsch

avfilter/palette{gen,use}: add palette utils

These color management helpers will be shared by palettegen and
paletteuse in the following commits.

Note that it probably makes sense to share at least the sRGB/linear
functions with other filters at some point.

More information on OkLab can be found here: https://bottosson.github.io/posts/oklab/

For the arithmetic integer version, see:
http://blog.pkh.me/p/38-porting-oklab-colorspace-to-integer-arithmetic.html
and https://github.com/ubitux/oklab-int
parent 7bc054e6
This diff is collapsed.
/*
* Copyright (c) 2020 Björn Ottosson
* Copyright (c) 2022 Clément Bœsch <u pkh me>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFILTER_PALETTE_H
#define AVFILTER_PALETTE_H
#include <math.h>
#include <stdint.h>
#include "libavutil/attributes.h"
struct Lab {
int32_t L, a, b;
};
/**
* Map sRGB 8-bit color component to a 16-bit linear value (gamma
* expand from electrical to optical value).
*/
int32_t ff_srgb_u8_to_linear_int(uint8_t x);
/**
* Map a 16-bit linear value to a sRGB 8-bit color component (gamma
* compressed from optical to electrical value).
*/
uint8_t ff_linear_int_to_srgb_u8(int32_t x);
/**
* sRGB (non-linear) to OkLab conversion
* @see https://bottosson.github.io/posts/oklab/
*/
struct Lab ff_srgb_u8_to_oklab_int(uint32_t srgb);
/**
* OkLab to sRGB (non-linear) conversion
* @see https://bottosson.github.io/posts/oklab/
*/
uint32_t ff_oklab_int_to_srgb_u8(struct Lab c);
#endif /* AVFILTER_PALETTE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment