FFmpeg
Data Structures | Macros | Functions | Variables
vf_colorlevels.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "preserve_color.h"

Go to the source code of this file.

Data Structures

struct  Range
 
struct  ColorLevelsContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define R   0
 
#define G   1
 
#define B   2
 
#define A   3
 
#define OFFSET(x)   offsetof(ColorLevelsContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define DO_COMMON(type, clip, preserve, planar)
 
#define CLIP8(x, depth)   av_clip_uint8(x)
 
#define CLIP16(x, depth)   av_clip_uint16(x)
 

Functions

 AVFILTER_DEFINE_CLASS (colorlevels)
 
static int colorlevels_slice_8 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_slice_16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_8 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_slice_8_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_slice_9_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_slice_10_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_slice_12_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_slice_14_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_slice_16_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_8_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_9_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_10_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_12_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_14_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int colorlevels_preserve_slice_16_planar (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const AVOption colorlevels_options []
 
static const AVFilterPad colorlevels_inputs []
 
static const AVFilterPad colorlevels_outputs []
 
const AVFilter ff_vf_colorlevels
 

Macro Definition Documentation

◆ R

#define R   0

Definition at line 31 of file vf_colorlevels.c.

◆ G

#define G   1

Definition at line 32 of file vf_colorlevels.c.

◆ B

#define B   2

Definition at line 33 of file vf_colorlevels.c.

◆ A

#define A   3

Definition at line 34 of file vf_colorlevels.c.

◆ OFFSET

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

Definition at line 58 of file vf_colorlevels.c.

◆ FLAGS

Definition at line 59 of file vf_colorlevels.c.

◆ DO_COMMON

#define DO_COMMON (   type,
  clip,
  preserve,
  planar 
)

Definition at line 104 of file vf_colorlevels.c.

◆ CLIP8

#define CLIP8 (   x,
  depth 
)    av_clip_uint8(x)

Definition at line 181 of file vf_colorlevels.c.

◆ CLIP16

#define CLIP16 (   x,
  depth 
)    av_clip_uint16(x)

Definition at line 182 of file vf_colorlevels.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( colorlevels  )

◆ colorlevels_slice_8()

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

Definition at line 184 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_16()

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

Definition at line 191 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_8()

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

Definition at line 198 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_16()

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

Definition at line 205 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_8_planar()

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

Definition at line 212 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_9_planar()

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

Definition at line 219 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_10_planar()

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

Definition at line 227 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_12_planar()

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

Definition at line 235 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_14_planar()

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

Definition at line 243 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_16_planar()

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

Definition at line 251 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_8_planar()

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

Definition at line 258 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_9_planar()

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

Definition at line 265 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_10_planar()

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

Definition at line 273 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_12_planar()

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

Definition at line 281 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_14_planar()

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

Definition at line 289 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_16_planar()

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

Definition at line 297 of file vf_colorlevels.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 304 of file vf_colorlevels.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 358 of file vf_colorlevels.c.

Variable Documentation

◆ colorlevels_options

const AVOption colorlevels_options[]
static
Initial value:
= {
{ "rimin", "set input red black point", OFFSET(range[R].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
{ "gimin", "set input green black point", OFFSET(range[G].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
{ "bimin", "set input blue black point", OFFSET(range[B].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
{ "aimin", "set input alpha black point", OFFSET(range[A].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
{ "rimax", "set input red white point", OFFSET(range[R].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
{ "gimax", "set input green white point", OFFSET(range[G].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
{ "bimax", "set input blue white point", OFFSET(range[B].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
{ "aimax", "set input alpha white point", OFFSET(range[A].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
{ "romin", "set output red black point", OFFSET(range[R].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
{ "gomin", "set output green black point", OFFSET(range[G].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
{ "bomin", "set output blue black point", OFFSET(range[B].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
{ "aomin", "set output alpha black point", OFFSET(range[A].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
{ "romax", "set output red white point", OFFSET(range[R].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
{ "gomax", "set output green white point", OFFSET(range[G].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
{ "bomax", "set output blue white point", OFFSET(range[B].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
{ "aomax", "set output alpha white point", OFFSET(range[A].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
{ "preserve", "set preserve color mode", OFFSET(preserve_color), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_PRESERVE-1, FLAGS, "preserve" },
{ "none", "disabled", 0, AV_OPT_TYPE_CONST, {.i64=P_NONE}, 0, 0, FLAGS, "preserve" },
{ "lum", "luminance", 0, AV_OPT_TYPE_CONST, {.i64=P_LUM}, 0, 0, FLAGS, "preserve" },
{ "max", "max", 0, AV_OPT_TYPE_CONST, {.i64=P_MAX}, 0, 0, FLAGS, "preserve" },
{ "avg", "average", 0, AV_OPT_TYPE_CONST, {.i64=P_AVG}, 0, 0, FLAGS, "preserve" },
{ "sum", "sum", 0, AV_OPT_TYPE_CONST, {.i64=P_SUM}, 0, 0, FLAGS, "preserve" },
{ "nrm", "norm", 0, AV_OPT_TYPE_CONST, {.i64=P_NRM}, 0, 0, FLAGS, "preserve" },
{ "pwr", "power", 0, AV_OPT_TYPE_CONST, {.i64=P_PWR}, 0, 0, FLAGS, "preserve" },
{ NULL }
}

Definition at line 60 of file vf_colorlevels.c.

◆ colorlevels_inputs

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

Definition at line 492 of file vf_colorlevels.c.

◆ colorlevels_outputs

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

Definition at line 501 of file vf_colorlevels.c.

◆ ff_vf_colorlevels

const AVFilter ff_vf_colorlevels
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:481
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_colorlevels.c:358
colorlevels_inputs
static const AVFilterPad colorlevels_inputs[]
Definition: vf_colorlevels.c:492
preserve_color
static void preserve_color(int preserve_color, float ir, float ig, float ib, float r, float g, float b, float max, float *icolor, float *ocolor)
Definition: preserve_color.h:53
P_AVG
@ P_AVG
Definition: preserve_color.h:30
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_colorlevels.c:304
A
#define A
Definition: vf_colorlevels.c:34
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:477
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:475
ColorLevelsContext
Definition: vf_colorlevels.c:41
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:479
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:480
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:478
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:449
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:450
NULL
#define NULL
Definition: coverity.c:32
P_PWR
@ P_PWR
Definition: preserve_color.h:33
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:258
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:474
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
P_LUM
@ P_LUM
Definition: preserve_color.h:28
G
#define G
Definition: vf_colorlevels.c:32
OFFSET
#define OFFSET(x)
Definition: vf_colorlevels.c:58
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
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:115
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: internal.h:176
NB_PRESERVE
@ NB_PRESERVE
Definition: preserve_color.h:34
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:445
P_NONE
@ P_NONE
Definition: preserve_color.h:27
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:873
B
#define B
Definition: vf_colorlevels.c:33
P_NRM
@ P_NRM
Definition: preserve_color.h:32
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:256
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:152
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:454
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:476
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:257
colorlevels_outputs
static const AVFilterPad colorlevels_outputs[]
Definition: vf_colorlevels.c:501
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
P_MAX
@ P_MAX
Definition: preserve_color.h:29
FLAGS
#define FLAGS
Definition: vf_colorlevels.c:59
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
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:127
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:255
P_SUM
@ P_SUM
Definition: preserve_color.h:31
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
R
#define R
Definition: vf_colorlevels.c:31