FFmpeg
Loading...
Searching...
No Matches
lut3d.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_LUT3D_H
22#define SWSCALE_LUT3D_H
23
24#include <stdint.h>
25
26#include "libavutil/csp.h"
27#include "libavutil/pixfmt.h"
28
29#include "cms.h"
30#include "csputils.h"
31#include "format.h"
32
33enum {
34 /* Input LUT size. This is only calculated once. */
36 INPUT_LUT_SIZE = (1 << INPUT_LUT_BITS) + 1, /* +1 to simplify interpolation */
37
38 /* Tone mapping LUT size. This is regenerated possibly per frame. */
41
42 /* Output LUT size (for dynamic tone mapping). This is only calculated once. */
45
48};
49
50typedef struct SwsLut3D {
52 bool dynamic;
53
54 /* Gamut mapping 3DLUT(s) */
57
58 /* Split tone mapping LUT (for dynamic tone mapping) */
59 v2u16_t tone_map[TONE_LUT_SIZE + 1]; /* new luma, desaturation */
60} SwsLut3D;
61
62/**
63 * Allocates a refstruct. Note that the LUT contents are not initialized.
64 */
66
67/**
68 * Recalculate the (static) 3DLUT state with new settings. This will recompute
69 * everything. To only update per-frame tone mapping state, instead call
70 * ff_sws_lut3d_update().
71 *
72 * Returns 0 or a negative error code.
73 */
75
76/**
77 * Update the tone mapping state. This will only use per-frame metadata. The
78 * static metadata is ignored.
79 */
80void ff_sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src);
81
82/**
83 * Applies a color transformation to a plane in RGBA64 format.
84 */
85void ff_sws_lut3d_apply_rgba64(const SwsLut3D *lut3d, const uint8_t *in,
86 int in_stride, uint8_t *out, int out_stride,
87 int w, int h);
88
89#endif /* SWSCALE_LUT3D_H */
static FILE * out
Colorspace value utility functions for libavutil.
const VDPAUPixFmtMap * map
@ TONE_LUT_SIZE
Definition lut3d.h:40
@ OUTPUT_LUT_SIZE_I
Definition lut3d.h:46
@ OUTPUT_LUT_BITS_PT
Definition lut3d.h:44
@ INPUT_LUT_BITS
Definition lut3d.h:35
@ INPUT_LUT_SIZE
Definition lut3d.h:36
@ OUTPUT_LUT_BITS_I
Definition lut3d.h:43
@ OUTPUT_LUT_SIZE_PT
Definition lut3d.h:47
@ TONE_LUT_BITS
Definition lut3d.h:39
SwsLut3D * ff_sws_lut3d_alloc(void)
Allocates a refstruct.
Definition lut3d.c:33
void ff_sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src)
Update the tone mapping state.
Definition lut3d.c:222
void ff_sws_lut3d_apply_rgba64(const SwsLut3D *lut3d, const uint8_t *in, int in_stride, uint8_t *out, int out_stride, int w, int h)
Applies a color transformation to a plane in RGBA64 format.
Definition lut3d.c:234
int ff_sws_lut3d_generate(SwsLut3D *lut3d, const SwsColorMap *map)
Recalculate the (static) 3DLUT state with new settings.
Definition lut3d.c:198
uint8_t w
Definition llvidencdsp.c:39
pixel format definitions
Append a set of operations for applying a gamut/tone mapping 3D LUT to the pixels.
Definition lut3d.h:50
v3u16_t output[OUTPUT_LUT_SIZE_PT][OUTPUT_LUT_SIZE_PT][OUTPUT_LUT_SIZE_I]
Definition lut3d.h:56
SwsColorMap map
Definition lut3d.h:51
v3u16_t input[INPUT_LUT_SIZE][INPUT_LUT_SIZE][INPUT_LUT_SIZE]
Definition lut3d.h:55
bool dynamic
Definition lut3d.h:52
v2u16_t tone_map[TONE_LUT_SIZE+1]
Definition lut3d.h:59