FFmpeg
Data Structures | Macros | Functions | Variables
vf_colortemperature.c File Reference
#include <float.h>
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.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_slice32 (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 config_input (AVFilterLink *inlink)
 
 AVFILTER_DEFINE_CLASS (colortemperature)
 

Variables

static enum AVPixelFormat pixel_fmts []
 
static const AVFilterPad inputs []
 
static const AVOption colortemperature_options []
 
const AVFilter ff_vf_colortemperature
 

Macro Definition Documentation

◆ R

#define R   0

Definition at line 30 of file vf_colortemperature.c.

◆ G

#define G   1

Definition at line 31 of file vf_colortemperature.c.

◆ B

#define B   2

Definition at line 32 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 82 of file vf_colortemperature.c.

◆ OFFSET

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

Definition at line 371 of file vf_colortemperature.c.

◆ VF

Definition at line 372 of file vf_colortemperature.c.

Function Documentation

◆ saturate()

static float saturate ( float  input)
static

Definition at line 51 of file vf_colortemperature.c.

Referenced by kelvin2rgb().

◆ kelvin2rgb()

static void kelvin2rgb ( float  k,
float rgb 
)
static

Definition at line 56 of file vf_colortemperature.c.

Referenced by filter_frame().

◆ lerpf()

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

Definition at line 77 of file vf_colortemperature.c.

◆ temperature_slice8()

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

Definition at line 103 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 144 of file vf_colortemperature.c.

Referenced by config_input().

◆ temperature_slice32()

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

Definition at line 186 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 227 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 266 of file vf_colortemperature.c.

Referenced by config_input().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 306 of file vf_colortemperature.c.

◆ config_input()

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 335 of file vf_colortemperature.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( colortemperature  )

Variable Documentation

◆ pixel_fmts

enum AVPixelFormat pixel_fmts[]
static

◆ inputs

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

Definition at line 361 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 374 of file vf_colortemperature.c.

◆ ff_vf_colortemperature

const 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,
.process_command = ff_filter_process_command,
}

Definition at line 383 of file vf_colortemperature.c.

AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:501
mix
static int mix(int c0, int c1)
Definition: 4xm.c:715
r
const char * r
Definition: vf_curves.c:126
lerpf
static float lerpf(float v0, float v1, float f)
Definition: vf_colortemperature.c:77
color
Definition: vf_paletteuse.c:511
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
b
#define b
Definition: input.c:41
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_colortemperature.c:306
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_colortemperature.c:335
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:496
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:494
VF
#define VF
Definition: vf_colortemperature.c:372
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:37
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:498
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:499
g
const char * g
Definition: vf_curves.c:127
inputs
static const AVFilterPad inputs[]
Definition: vf_colortemperature.c:361
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:497
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:468
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:469
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:493
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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:106
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:508
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:464
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:890
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
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:147
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:473
FFMIN3
#define FFMIN3(a, b, c)
Definition: macros.h:50
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:495
OFFSET
#define OFFSET(x)
Definition: vf_colortemperature.c:371
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:509
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
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
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
FFMAX3
#define FFMAX3(a, b, c)
Definition: macros.h:48
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
ColorTemperatureContext
Definition: vf_colortemperature.c:34
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_colortemperature.c:319
AVFILTERPAD_FLAG_NEEDS_WRITABLE
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition: internal.h:52