FFmpeg
Data Structures | Macros | Functions | Variables
vf_colortemperature.c File Reference
#include <float.h>
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  ColorTemperatureContext
 

Macros

#define R   0
 
#define G   1
 
#define B   2
 
#define PROCESS()
 
#define OFFSET(x)   offsetof(ColorTemperatureContext, x)
 
#define VF   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

static float saturate (float input)
 
static void kelvin2rgb (float k, float *rgb)
 
static float lerpf (float v0, float v1, float f)
 
static int temperature_slice8 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int temperature_slice16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int temperature_slice8p (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int temperature_slice16p (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static av_cold int query_formats (AVFilterContext *ctx)
 
static av_cold int config_input (AVFilterLink *inlink)
 
 AVFILTER_DEFINE_CLASS (colortemperature)
 

Variables

static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
static const AVOption colortemperature_options []
 
AVFilter ff_vf_colortemperature
 

Macro Definition Documentation

◆ R

#define R   0

Definition at line 31 of file vf_colortemperature.c.

◆ G

#define G   1

Definition at line 32 of file vf_colortemperature.c.

◆ B

#define B   2

Definition at line 33 of file vf_colortemperature.c.

◆ PROCESS

#define PROCESS ( )
Value:
nr = r * color[0]; \
ng = g * color[1]; \
nb = b * color[2]; \
\
nr = lerpf(r, nr, mix); \
ng = lerpf(g, ng, mix); \
nb = lerpf(b, nb, mix); \
\
l0 = (FFMAX3(r, g, b) + FFMIN3(r, g, b)) + FLT_EPSILON; \
l1 = (FFMAX3(nr, ng, nb) + FFMIN3(nr, ng, nb)) + FLT_EPSILON; \
l = l0 / l1; \
\
r = nr * l; \
g = ng * l; \
b = nb * l; \
\
nr = lerpf(nr, r, preserve); \
ng = lerpf(ng, g, preserve); \
nb = lerpf(nb, b, preserve);

Definition at line 83 of file vf_colortemperature.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(ColorTemperatureContext, x)

Definition at line 348 of file vf_colortemperature.c.

◆ VF

Definition at line 349 of file vf_colortemperature.c.

Function Documentation

◆ saturate()

static float saturate ( float  input)
static

Definition at line 52 of file vf_colortemperature.c.

Referenced by kelvin2rgb().

◆ kelvin2rgb()

static void kelvin2rgb ( float  k,
float *  rgb 
)
static

Definition at line 57 of file vf_colortemperature.c.

Referenced by filter_frame().

◆ lerpf()

static float lerpf ( float  v0,
float  v1,
float  f 
)
static

Definition at line 78 of file vf_colortemperature.c.

◆ temperature_slice8()

static int temperature_slice8 ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 104 of file vf_colortemperature.c.

Referenced by config_input().

◆ temperature_slice16()

static int temperature_slice16 ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 145 of file vf_colortemperature.c.

Referenced by config_input().

◆ temperature_slice8p()

static int temperature_slice8p ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 187 of file vf_colortemperature.c.

Referenced by config_input().

◆ temperature_slice16p()

static int temperature_slice16p ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 226 of file vf_colortemperature.c.

Referenced by config_input().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 266 of file vf_colortemperature.c.

◆ query_formats()

static av_cold int query_formats ( AVFilterContext ctx)
static

Definition at line 279 of file vf_colortemperature.c.

◆ config_input()

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 305 of file vf_colortemperature.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( colortemperature  )

Variable Documentation

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
.needs_writable = 1,
},
{ NULL }
}

Definition at line 329 of file vf_colortemperature.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 340 of file vf_colortemperature.c.

◆ colortemperature_options

const AVOption colortemperature_options[]
static
Initial value:
= {
{ "temperature", "set the temperature in Kelvin", OFFSET(temperature), AV_OPT_TYPE_FLOAT, {.dbl=6500}, 1000, 40000, VF },
{ "mix", "set the mix with filtered output", OFFSET(mix), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, VF },
{ "pl", "set the amount of preserving lightness", OFFSET(preserve), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 1, VF },
{ NULL }
}

Definition at line 351 of file vf_colortemperature.c.

◆ ff_vf_colortemperature

AVFilter ff_vf_colortemperature
Initial value:
= {
.name = "colortemperature",
.description = NULL_IF_CONFIG_SMALL("Adjust color temperature of video."),
.priv_size = sizeof(ColorTemperatureContext),
.priv_class = &colortemperature_class,
}

Definition at line 360 of file vf_colortemperature.c.

mix
static int mix(int c0, int c1)
Definition: 4xm.c:715
r
const char * r
Definition: vf_curves.c:116
lerpf
static float lerpf(float v0, float v1, float f)
Definition: vf_colortemperature.c:78
color
Definition: vf_paletteuse.c:583
b
#define b
Definition: input.c:41
query_formats
static av_cold int query_formats(AVFilterContext *ctx)
Definition: vf_colortemperature.c:279
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_colortemperature.c:266
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_colortemperature.c:305
outputs
static const AVFilterPad outputs[]
Definition: vf_colortemperature.c:340
FFMIN3
#define FFMIN3(a, b, c)
Definition: common.h:106
VF
#define VF
Definition: vf_colortemperature.c:349
FFMAX3
#define FFMAX3(a, b, c)
Definition: common.h:104
g
const char * g
Definition: vf_curves.c:117
inputs
static const AVFilterPad inputs[]
Definition: vf_colortemperature.c:329
NULL
#define NULL
Definition: coverity.c:32
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_acrusher.c:336
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:882
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:126
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
OFFSET
#define OFFSET(x)
Definition: vf_colortemperature.c:348
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
ColorTemperatureContext
Definition: vf_colortemperature.c:35