FFmpeg
Data Structures | Macros | Functions | Variables
vf_monochrome.c File Reference
#include <float.h>
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  MonochromeContext
 

Macros

#define PROCESS()
 
#define OFFSET(x)   offsetof(MonochromeContext, x)
 
#define VF   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

static float envelope (const float x)
 
static float filter (float b, float r, float u, float v, float size)
 
static int monochrome_slice8 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int monochrome_slice16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int clear_slice8 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int clear_slice16 (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static av_cold int query_formats (AVFilterContext *ctx)
 
static av_cold int config_input (AVFilterLink *inlink)
 
 AVFILTER_DEFINE_CLASS (monochrome)
 

Variables

static const AVFilterPad monochrome_inputs []
 
static const AVFilterPad monochrome_outputs []
 
static const AVOption monochrome_options []
 
const AVFilter ff_vf_monochrome
 

Macro Definition Documentation

◆ PROCESS

#define PROCESS ( )
Value:
const int cx = x >> subw; \
float y = yptr[x] * imax; \
float u = uptr[cx] * imax - .5f; \
float v = vptr[cx] * imax - .5f; \
float tt, t, ny; \
\
ny = filter(b, r, u, v, size); \
tt = envelope(y); \
t = tt + (1.f - tt) * ihigh; \
ny = (1.f - t) * y + t * ny * y;

Definition at line 68 of file vf_monochrome.c.

◆ OFFSET

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

Definition at line 291 of file vf_monochrome.c.

◆ VF

Definition at line 292 of file vf_monochrome.c.

Function Documentation

◆ envelope()

static float envelope ( const float  x)
static

Definition at line 46 of file vf_monochrome.c.

Referenced by amqp_proto_read(), and waves_synth().

◆ filter()

static float filter ( float  b,
float  r,
float  u,
float  v,
float  size 
)
static

Definition at line 61 of file vf_monochrome.c.

◆ monochrome_slice8()

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

Definition at line 80 of file vf_monochrome.c.

Referenced by config_input().

◆ monochrome_slice16()

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

Definition at line 119 of file vf_monochrome.c.

Referenced by config_input().

◆ clear_slice8()

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

Definition at line 158 of file vf_monochrome.c.

Referenced by config_input().

◆ clear_slice16()

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

Definition at line 184 of file vf_monochrome.c.

Referenced by config_input().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 212 of file vf_monochrome.c.

◆ query_formats()

static av_cold int query_formats ( AVFilterContext ctx)
static

Definition at line 225 of file vf_monochrome.c.

◆ config_input()

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 257 of file vf_monochrome.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( monochrome  )

Variable Documentation

◆ monochrome_inputs

const AVFilterPad monochrome_inputs[]
static
Initial value:
= {
{
.name = "default",
.needs_writable = 1,
.filter_frame = filter_frame,
.config_props = config_input,
},
{ NULL }
}

Definition at line 272 of file vf_monochrome.c.

◆ monochrome_outputs

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

Definition at line 283 of file vf_monochrome.c.

◆ monochrome_options

const AVOption monochrome_options[]
static
Initial value:
= {
{ "cb", "set the chroma blue spot", OFFSET(b), AV_OPT_TYPE_FLOAT, {.dbl=0},-1, 1, VF },
{ "cr", "set the chroma red spot", OFFSET(r), AV_OPT_TYPE_FLOAT, {.dbl=0},-1, 1, VF },
{ "size", "set the color filter size", OFFSET(size), AV_OPT_TYPE_FLOAT, {.dbl=1},.1,10, VF },
{ "high", "set the highlights strength", OFFSET(high), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 1, VF },
{ NULL }
}

Definition at line 294 of file vf_monochrome.c.

◆ ff_vf_monochrome

const AVFilter ff_vf_monochrome
Initial value:
= {
.name = "monochrome",
.description = NULL_IF_CONFIG_SMALL("Convert video to gray using custom color filter."),
.priv_size = sizeof(MonochromeContext),
.priv_class = &monochrome_class,
}

Definition at line 304 of file vf_monochrome.c.

monochrome_outputs
static const AVFilterPad monochrome_outputs[]
Definition: vf_monochrome.c:283
r
const char * r
Definition: vf_curves.c:116
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:264
b
#define b
Definition: input.c:41
query_formats
static av_cold int query_formats(AVFilterContext *ctx)
Definition: vf_monochrome.c:225
VF
#define VF
Definition: vf_monochrome.c:292
MonochromeContext
Definition: vf_monochrome.c:30
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
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_monochrome.c:212
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
size
int size
Definition: twinvq_data.h:10344
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
monochrome_inputs
static const AVFilterPad monochrome_inputs[]
Definition: vf_monochrome.c:272
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_monochrome.c:257
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
envelope
static float envelope(const float x)
Definition: vf_monochrome.c:46
filter
static float filter(float b, float r, float u, float v, float size)
Definition: vf_monochrome.c:61
OFFSET
#define OFFSET(x)
Definition: vf_monochrome.c:291
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
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561