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 "filters.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 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 enum AVPixelFormat pix_fmts []
 
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 28 of file vf_colorbalance.c.

◆ G

#define G   1

Definition at line 29 of file vf_colorbalance.c.

◆ B

#define B   2

Definition at line 30 of file vf_colorbalance.c.

◆ A

#define A   3

Definition at line 31 of file vf_colorbalance.c.

◆ OFFSET

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

Definition at line 58 of file vf_colorbalance.c.

◆ FLAGS

Definition at line 59 of file vf_colorbalance.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( colorbalance  )

◆ 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 109 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 150 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 203 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 257 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 308 of file vf_colorbalance.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 360 of file vf_colorbalance.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 388 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 60 of file vf_colorbalance.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ colorbalance_inputs

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

Definition at line 417 of file vf_colorbalance.c.

◆ colorbalance_outputs

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

Definition at line 425 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,
.process_command = ff_filter_process_command,
}

Definition at line 433 of file vf_colorbalance.c.

AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:525
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_colorbalance.c:388
colorbalance_outputs
static const AVFilterPad colorbalance_outputs[]
Definition: vf_colorbalance.c:425
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
colorbalance_inputs
static const AVFilterPad colorbalance_inputs[]
Definition: vf_colorbalance.c:417
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
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
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:520
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:518
ColorBalanceContext
Definition: vf_colorbalance.c:43
FLAGS
#define FLAGS
Definition: vf_colorbalance.c:59
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:522
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:523
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:521
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:492
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:493
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:517
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:94
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:488
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:900
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_colorbalance.c:76
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:182
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
Underlying C type is float.
Definition: opt.h:271
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_colorbalance.c:360
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:497
OFFSET
#define OFFSET(x)
Definition: vf_colorbalance.c:58
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:519
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_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:152
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262