FFmpeg
Data Structures | Macros | Functions | Variables
vf_colorlevels.c File Reference
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.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, ptype, clip, preserve, planar)
 
#define CLIP8(x, depth)   av_clip_uint8(x)
 
#define CLIP16(x, depth)   av_clip_uint16(x)
 
#define NOCLIP(x, depth)   (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_slice_32_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 colorlevels_preserve_slice_32_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 []
 
const AVFilter ff_vf_colorlevels
 

Macro Definition Documentation

◆ R

#define R   0

Definition at line 29 of file vf_colorlevels.c.

◆ G

#define G   1

Definition at line 30 of file vf_colorlevels.c.

◆ B

#define B   2

Definition at line 31 of file vf_colorlevels.c.

◆ A

#define A   3

Definition at line 32 of file vf_colorlevels.c.

◆ OFFSET

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

Definition at line 56 of file vf_colorlevels.c.

◆ FLAGS

Definition at line 57 of file vf_colorlevels.c.

◆ DO_COMMON

#define DO_COMMON (   type,
  ptype,
  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.

◆ NOCLIP

#define NOCLIP (   x,
  depth 
)    (x)

Definition at line 183 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 185 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 192 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 199 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 206 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 213 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 220 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 228 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 236 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 244 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 252 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_slice_32_planar()

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

Definition at line 259 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 266 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 273 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 281 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 289 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 297 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 305 of file vf_colorlevels.c.

Referenced by config_input().

◆ colorlevels_preserve_slice_32_planar()

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

Definition at line 312 of file vf_colorlevels.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 319 of file vf_colorlevels.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 377 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 58 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 551 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:491
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_colorlevels.c:377
colorlevels_inputs
static const AVFilterPad colorlevels_inputs[]
Definition: vf_colorlevels.c:551
P_MAX
@ P_MAX
Definition: preserve_color.h:29
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
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:319
A
#define A
Definition: vf_colorlevels.c:32
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:486
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:484
ColorLevelsContext
Definition: vf_colorlevels.c:39
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:36
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:488
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:489
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
P_NONE
@ P_NONE
Definition: preserve_color.h:27
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:192
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
P_AVG
@ P_AVG
Definition: preserve_color.h:30
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:487
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:458
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:459
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:258
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:483
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
G
#define G
Definition: vf_colorlevels.c:30
OFFSET
#define OFFSET(x)
Definition: vf_colorlevels.c:56
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:106
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: internal.h:178
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:498
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:454
range
enum AVColorRange range
Definition: mediacodec_wrapper.c:2646
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:851
B
#define B
Definition: vf_colorlevels.c:31
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:147
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:463
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:485
P_SUM
@ P_SUM
Definition: preserve_color.h:31
P_NRM
@ P_NRM
Definition: preserve_color.h:32
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:257
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:499
FLAGS
#define FLAGS
Definition: vf_colorlevels.c:57
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:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
P_PWR
@ P_PWR
Definition: preserve_color.h:33
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:255
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
NB_PRESERVE
@ NB_PRESERVE
Definition: preserve_color.h:34
P_LUM
@ P_LUM
Definition: preserve_color.h:28
R
#define R
Definition: vf_colorlevels.c:29