FFmpeg
Data Structures | Macros | Functions | Variables
vf_colorbalance.c File Reference
#include "libavutil/opt.h"
#include "libavutil/pixdesc.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  ThreadData
 Used for passing data between threads. More...
 
struct  Range
 
struct  ColorBalanceContext
 

Macros

#define R   0
 
#define G   1
 
#define B   2
 
#define A   3
 
#define OFFSET(x)   offsetof(ColorBalanceContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (colorbalance)
 
static int query_formats (AVFilterContext *ctx)
 
static float get_component (float v, float l, float s, float m, float h)
 
static float hfun (float n, float h, float s, float l)
 
static void preservel (float *r, float *g, float *b, float l)
 
static int color_balance8_p (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int color_balance16_p (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int color_balance8 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int color_balance16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const AVOption colorbalance_options []
 
static const AVFilterPad colorbalance_inputs []
 
static const AVFilterPad colorbalance_outputs []
 
const AVFilter ff_vf_colorbalance
 

Macro Definition Documentation

◆ R

#define R   0

Definition at line 29 of file vf_colorbalance.c.

◆ G

#define G   1

Definition at line 30 of file vf_colorbalance.c.

◆ B

#define B   2

Definition at line 31 of file vf_colorbalance.c.

◆ A

#define A   3

Definition at line 32 of file vf_colorbalance.c.

◆ OFFSET

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

Definition at line 59 of file vf_colorbalance.c.

◆ FLAGS

Definition at line 60 of file vf_colorbalance.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( colorbalance  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 77 of file vf_colorbalance.c.

◆ get_component()

static float get_component ( float  v,
float  l,
float  s,
float  m,
float  h 
)
static

◆ hfun()

static float hfun ( float  n,
float  h,
float  s,
float  l 
)
static

Definition at line 117 of file vf_colorbalance.c.

Referenced by preservel().

◆ preservel()

static void preservel ( float *  r,
float *  g,
float *  b,
float  l 
)
static

◆ color_balance8_p()

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

Definition at line 158 of file vf_colorbalance.c.

Referenced by config_output().

◆ color_balance16_p()

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

Definition at line 211 of file vf_colorbalance.c.

Referenced by config_output().

◆ color_balance8()

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

Definition at line 265 of file vf_colorbalance.c.

Referenced by config_output().

◆ color_balance16()

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

Definition at line 316 of file vf_colorbalance.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 368 of file vf_colorbalance.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 396 of file vf_colorbalance.c.

Variable Documentation

◆ colorbalance_options

const AVOption colorbalance_options[]
static
Initial value:
= {
{ "rs", "set red shadows", OFFSET(cyan_red.shadows), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "gs", "set green shadows", OFFSET(magenta_green.shadows), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "bs", "set blue shadows", OFFSET(yellow_blue.shadows), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "rm", "set red midtones", OFFSET(cyan_red.midtones), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "gm", "set green midtones", OFFSET(magenta_green.midtones), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "bm", "set blue midtones", OFFSET(yellow_blue.midtones), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "rh", "set red highlights", OFFSET(cyan_red.highlights), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "gh", "set green highlights", OFFSET(magenta_green.highlights), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "bh", "set blue highlights", OFFSET(yellow_blue.highlights), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS },
{ "pl", "preserve lightness", OFFSET(preserve_lightness), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 61 of file vf_colorbalance.c.

◆ colorbalance_inputs

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

Definition at line 424 of file vf_colorbalance.c.

◆ colorbalance_outputs

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

Definition at line 433 of file vf_colorbalance.c.

◆ ff_vf_colorbalance

const AVFilter ff_vf_colorbalance
Initial value:
= {
.name = "colorbalance",
.description = NULL_IF_CONFIG_SMALL("Adjust the color balance."),
.priv_size = sizeof(ColorBalanceContext),
.priv_class = &colorbalance_class,
}

Definition at line 442 of file vf_colorbalance.c.

filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_colorbalance.c:396
colorbalance_outputs
static const AVFilterPad colorbalance_outputs[]
Definition: vf_colorbalance.c:433
colorbalance_inputs
static const AVFilterPad colorbalance_inputs[]
Definition: vf_colorbalance.c:424
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_colorbalance.c:77
ColorBalanceContext
Definition: vf_colorbalance.c:44
FLAGS
#define FLAGS
Definition: vf_colorbalance.c:60
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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:842
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
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_colorbalance.c:368
OFFSET
#define OFFSET(x)
Definition: vf_colorbalance.c:59
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
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561