FFmpeg
Loading...
Searching...
No Matches
lut3d.c File Reference
#include <assert.h>
#include <string.h>
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/refstruct.h"
#include "cms.h"
#include "csputils.h"
#include "lut3d.h"

Go to the source code of this file.

Functions

SwsLut3Dff_sws_lut3d_alloc (void)
 Allocates a refstruct.
 
static av_always_inline v3u16_t barycentric (int shift, int x, int y, int z, v3u16_t v0, v3u16_t v1, v3u16_t v2, v3u16_t v3)
 v0 and v1 are 'black' and 'white' v2 and v3 are closest RGB/CMY vertices x >= y >= z are relative weights
 
static av_always_inline v3u16_t tetrahedral (const SwsLut3D *lut3d, int Rx, int Gx, int Bx, int Rf, int Gf, int Bf)
 
static av_always_inline v3u16_t lookup_input16 (const SwsLut3D *lut3d, v3u16_t rgb)
 
static av_always_inline v2u16_t lerp2u16 (v2u16_t a, v2u16_t b, int x, int shift)
 Note: These functions are scaled such that x == (1 << shift) corresponds to a value of 1.0.
 
static av_always_inline v3u16_t lerp3u16 (v3u16_t a, v3u16_t b, int x, int shift)
 
static av_always_inline v3u16_t lookup_output (const SwsLut3D *lut3d, v3u16_t ipt)
 
static av_always_inline v3u16_t apply_tone_map (const SwsLut3D *lut3d, v3u16_t ipt)
 
int ff_sws_lut3d_generate (SwsLut3D *lut3d, const SwsColorMap *map)
 Recalculate the (static) 3DLUT state with new settings.
 
void ff_sws_lut3d_update (SwsLut3D *lut3d, const SwsColor *new_src)
 Update the tone mapping state.
 
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.
 

Function Documentation

◆ ff_sws_lut3d_alloc()

SwsLut3D * ff_sws_lut3d_alloc ( void )

Allocates a refstruct.

Note that the LUT contents are not initialized.

Definition at line 33 of file lut3d.c.

Referenced by check_lut_3d(), generate_3dlut(), and sws_uops_macros_gen().

◆ barycentric()

static av_always_inline v3u16_t barycentric ( int shift,
int x,
int y,
int z,
v3u16_t v0,
v3u16_t v1,
v3u16_t v2,
v3u16_t v3 )
static

v0 and v1 are 'black' and 'white' v2 and v3 are closest RGB/CMY vertices x >= y >= z are relative weights

Definition at line 51 of file lut3d.c.

Referenced by tetrahedral().

◆ tetrahedral()

static av_always_inline v3u16_t tetrahedral ( const SwsLut3D * lut3d,
int Rx,
int Gx,
int Bx,
int Rf,
int Gf,
int Bf )
static

Definition at line 69 of file lut3d.c.

Referenced by lookup_input16().

◆ lookup_input16()

static av_always_inline v3u16_t lookup_input16 ( const SwsLut3D * lut3d,
v3u16_t rgb )
static

Definition at line 110 of file lut3d.c.

Referenced by ff_sws_lut3d_apply_rgba64().

◆ lerp2u16()

static av_always_inline v2u16_t lerp2u16 ( v2u16_t a,
v2u16_t b,
int x,
int shift )
static

Note: These functions are scaled such that x == (1 << shift) corresponds to a value of 1.0.

This makes them suitable for use when interpolation LUT entries with a fractional part that is just masked away from the index, since a fractional coordinate of e.g. 0xFFFF corresponds to a mix weight of just slightly less than 1.0.

Definition at line 129 of file lut3d.c.

Referenced by apply_tone_map().

◆ lerp3u16()

static av_always_inline v3u16_t lerp3u16 ( v3u16_t a,
v3u16_t b,
int x,
int shift )
static

Definition at line 138 of file lut3d.c.

Referenced by lookup_output().

◆ lookup_output()

static av_always_inline v3u16_t lookup_output ( const SwsLut3D * lut3d,
v3u16_t ipt )
static

Definition at line 148 of file lut3d.c.

Referenced by ff_sws_lut3d_apply_rgba64().

◆ apply_tone_map()

static av_always_inline v3u16_t apply_tone_map ( const SwsLut3D * lut3d,
v3u16_t ipt )
static

Definition at line 181 of file lut3d.c.

Referenced by ff_sws_lut3d_apply_rgba64().

◆ ff_sws_lut3d_generate()

int ff_sws_lut3d_generate ( SwsLut3D * lut3d,
const SwsColorMap * map )

Recalculate the (static) 3DLUT state with new settings.

This will recompute everything. To only update per-frame tone mapping state, instead call ff_sws_lut3d_update().

Returns 0 or a negative error code.

Definition at line 198 of file lut3d.c.

Referenced by generate_3dlut().

◆ ff_sws_lut3d_update()

void ff_sws_lut3d_update ( SwsLut3D * lut3d,
const SwsColor * new_src )

Update the tone mapping state.

This will only use per-frame metadata. The static metadata is ignored.

Definition at line 222 of file lut3d.c.

Referenced by ff_sws_graph_update_metadata(), and ff_sws_lut3d_generate().

◆ 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 at line 234 of file lut3d.c.

Referenced by run_legacy_lut3d().