FFmpeg
libswscale
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
33
enum
{
34
/* Input LUT size. This is only calculated once. */
35
INPUT_LUT_BITS
= 6,
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. */
39
TONE_LUT_BITS
= 8,
40
TONE_LUT_SIZE
= (1 <<
TONE_LUT_BITS
) + 1,
41
42
/* Output LUT size (for dynamic tone mapping). This is only calculated once. */
43
OUTPUT_LUT_BITS_I
= 6,
44
OUTPUT_LUT_BITS_PT
= 7,
45
46
OUTPUT_LUT_SIZE_I
= (1 <<
OUTPUT_LUT_BITS_I
) + 1,
47
OUTPUT_LUT_SIZE_PT
= (1 <<
OUTPUT_LUT_BITS_PT
) + 1,
48
};
49
50
typedef
struct
SwsLut3D
{
51
SwsColorMap
map
;
52
bool
dynamic
;
53
54
/* Gamut mapping 3DLUT(s) */
55
v3u16_t
input
[
INPUT_LUT_SIZE
][
INPUT_LUT_SIZE
][
INPUT_LUT_SIZE
];
56
v3u16_t
output
[
OUTPUT_LUT_SIZE_PT
][
OUTPUT_LUT_SIZE_PT
][
OUTPUT_LUT_SIZE_I
];
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
*/
65
SwsLut3D
*
ff_sws_lut3d_alloc
(
void
);
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
*/
74
int
ff_sws_lut3d_generate
(
SwsLut3D
*lut3d,
const
SwsColorMap
*
map
);
75
76
/**
77
* Update the tone mapping state. This will only use per-frame metadata. The
78
* static metadata is ignored.
79
*/
80
void
ff_sws_lut3d_update
(
SwsLut3D
*lut3d,
const
SwsColor
*new_src);
81
82
/**
83
* Applies a color transformation to a plane in RGBA64 format.
84
*/
85
void
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 */
SwsLut3D::dynamic
bool dynamic
Definition:
lut3d.h:52
ff_sws_lut3d_update
void ff_sws_lut3d_update(SwsLut3D *lut3d, const SwsColor *new_src)
Update the tone mapping state.
Definition:
lut3d.c:222
out
static FILE * out
Definition:
movenc.c:55
OUTPUT_LUT_SIZE_I
@ OUTPUT_LUT_SIZE_I
Definition:
lut3d.h:46
v3u16_t
Definition:
csputils.h:72
SwsLut3D::output
v3u16_t output[OUTPUT_LUT_SIZE_PT][OUTPUT_LUT_SIZE_PT][OUTPUT_LUT_SIZE_I]
Definition:
lut3d.h:56
OUTPUT_LUT_BITS_PT
@ OUTPUT_LUT_BITS_PT
Definition:
lut3d.h:44
TONE_LUT_SIZE
@ TONE_LUT_SIZE
Definition:
lut3d.h:40
format.h
TONE_LUT_BITS
@ TONE_LUT_BITS
Definition:
lut3d.h:39
SwsColorMap
Definition:
cms.h:60
v2u16_t
Definition:
csputils.h:68
SwsLut3D::tone_map
v2u16_t tone_map[TONE_LUT_SIZE+1]
Definition:
lut3d.h:59
ff_sws_lut3d_alloc
SwsLut3D * ff_sws_lut3d_alloc(void)
Allocates a refstruct.
Definition:
lut3d.c:33
SwsLut3D::input
v3u16_t input[INPUT_LUT_SIZE][INPUT_LUT_SIZE][INPUT_LUT_SIZE]
Definition:
lut3d.h:55
csp.h
SwsColor
Definition:
format.h:60
OUTPUT_LUT_BITS_I
@ OUTPUT_LUT_BITS_I
Definition:
lut3d.h:43
ff_sws_lut3d_apply_rgba64
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
SwsLut3D::map
SwsColorMap map
Definition:
lut3d.h:51
OUTPUT_LUT_SIZE_PT
@ OUTPUT_LUT_SIZE_PT
Definition:
lut3d.h:47
SwsLut3D
Append a set of operations for applying a gamut/tone mapping 3D LUT to the pixels.
Definition:
lut3d.h:50
ff_sws_lut3d_generate
int ff_sws_lut3d_generate(SwsLut3D *lut3d, const SwsColorMap *map)
Recalculate the (static) 3DLUT state with new settings.
Definition:
lut3d.c:198
pixfmt.h
INPUT_LUT_BITS
@ INPUT_LUT_BITS
Definition:
lut3d.h:35
cms.h
w
uint8_t w
Definition:
llvidencdsp.c:39
map
const VDPAUPixFmtMap * map
Definition:
hwcontext_vdpau.c:71
h
h
Definition:
vp9dsp_template.c:2070
INPUT_LUT_SIZE
@ INPUT_LUT_SIZE
Definition:
lut3d.h:36
csputils.h
Generated on Thu Aug 6 2026 19:22:57 for FFmpeg by
1.8.17