FFmpeg
Data Structures | Macros | Functions | Variables
vf_noise.c File Reference
#include "libavutil/emms.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/lfg.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "vf_noise.h"
#include "video.h"

Go to the source code of this file.

Data Structures

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

Macros

#define OFFSET(x)   offsetof(NoiseContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define NOISE_PARAMS(name, x, param)
 
#define RAND_N(range)   ((int) ((double) range * av_lfg_get(lfg) / (UINT_MAX + 1.0)))
 

Functions

 AVFILTER_DEFINE_CLASS (noise)
 
static av_cold int init_noise (NoiseContext *n, int comp)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int config_input (AVFilterLink *inlink)
 
void ff_line_noise_c (uint8_t *dst, const uint8_t *src, const int8_t *noise, int len, int shift)
 
void ff_line_noise_avg_c (uint8_t *dst, const uint8_t *src, int len, const int8_t *const *shift)
 
static void noise (uint8_t *dst, const uint8_t *src, int dst_linesize, int src_linesize, int width, int start, int end, NoiseContext *n, int comp)
 
static int filter_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *inpicref)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption noise_options []
 
static const int8_t patt [4] = { -1, 0, 1, 0 }
 
static const AVFilterPad noise_inputs []
 
const AVFilter ff_vf_noise
 

Detailed Description

noise generator

Definition in file vf_noise.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 43 of file vf_noise.c.

◆ FLAGS

Definition at line 44 of file vf_noise.c.

◆ NOISE_PARAMS

#define NOISE_PARAMS (   name,
  x,
  param 
)
Value:
{#name"_seed", "set component #"#x" noise seed", OFFSET(param.seed), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS}, \
{#name"_strength", "set component #"#x" strength", OFFSET(param.strength), AV_OPT_TYPE_INT, {.i64=0}, 0, 100, FLAGS}, \
{#name"s", "set component #"#x" strength", OFFSET(param.strength), AV_OPT_TYPE_INT, {.i64=0}, 0, 100, FLAGS}, \
{#name"_flags", "set component #"#x" flags", OFFSET(param.flags), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, .unit = #name"_flags"}, \
{#name"f", "set component #"#x" flags", OFFSET(param.flags), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, .unit = #name"_flags"}, \
{"a", "averaged noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_AVERAGED}, 0, 0, FLAGS, .unit = #name"_flags"}, \
{"p", "(semi)regular pattern", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_PATTERN}, 0, 0, FLAGS, .unit = #name"_flags"}, \
{"t", "temporal noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_TEMPORAL}, 0, 0, FLAGS, .unit = #name"_flags"}, \
{"u", "uniform noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_UNIFORM}, 0, 0, FLAGS, .unit = #name"_flags"},

Definition at line 46 of file vf_noise.c.

◆ RAND_N

#define RAND_N (   range)    ((int) ((double) range * av_lfg_get(lfg) / (UINT_MAX + 1.0)))

Definition at line 70 of file vf_noise.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( noise  )

◆ init_noise()

static av_cold int init_noise ( NoiseContext n,
int  comp 
)
static

Definition at line 71 of file vf_noise.c.

Referenced by init().

◆ query_formats()

static int query_formats ( const AVFilterContext ctx,
AVFilterFormatsConfig **  cfg_in,
AVFilterFormatsConfig **  cfg_out 
)
static

Definition at line 134 of file vf_noise.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 151 of file vf_noise.c.

◆ ff_line_noise_c()

void ff_line_noise_c ( uint8_t *  dst,
const uint8_t *  src,
const int8_t *  noise,
int  len,
int  shift 
)

Definition at line 168 of file vf_noise.c.

Referenced by init().

◆ ff_line_noise_avg_c()

void ff_line_noise_avg_c ( uint8_t *  dst,
const uint8_t *  src,
int  len,
const int8_t *const *  shift 
)

Definition at line 181 of file vf_noise.c.

Referenced by init().

◆ noise()

static void noise ( uint8_t *  dst,
const uint8_t *  src,
int  dst_linesize,
int  src_linesize,
int  width,
int  start,
int  end,
NoiseContext n,
int  comp 
)
static

Definition at line 193 of file vf_noise.c.

Referenced by ff_line_noise_c(), filter_slice(), and init_noise().

◆ filter_slice()

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

Definition at line 227 of file vf_noise.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame inpicref 
)
static

Definition at line 245 of file vf_noise.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 287 of file vf_noise.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 318 of file vf_noise.c.

Variable Documentation

◆ noise_options

const AVOption noise_options[]
static
Initial value:
= {
NOISE_PARAMS(c3, 3, param[3])
{NULL}
}

Definition at line 57 of file vf_noise.c.

◆ patt

const int8_t patt[4] = { -1, 0, 1, 0 }
static

Definition at line 68 of file vf_noise.c.

Referenced by filter_frame(), get_rdelta(), and init_noise().

◆ noise_inputs

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

Definition at line 327 of file vf_noise.c.

◆ ff_vf_noise

const AVFilter ff_vf_noise
Initial value:

Definition at line 336 of file vf_noise.c.

uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_noise.c:318
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
noise_class
static const AVClass noise_class
Definition: noise.c:222
NOISE_PATTERN
#define NOISE_PATTERN
Definition: vf_noise.h:35
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_noise.c:151
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_noise.c:287
NoiseContext
Definition: noise.c:63
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:37
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: vf_noise.c:134
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_noise.c:44
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
noise_inputs
static const AVFilterPad noise_inputs[]
Definition: vf_noise.c:327
NOISE_PARAMS
#define NOISE_PARAMS(name, x, param)
Definition: vf_noise.c:46
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
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
NOISE_AVERAGED
#define NOISE_AVERAGED
Definition: vf_noise.h:34
NOISE_UNIFORM
#define NOISE_UNIFORM
Definition: vf_noise.h:32
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
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
OFFSET
#define OFFSET(x)
Definition: vf_noise.c:43
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
Definition: vf_noise.c:245
NOISE_TEMPORAL
#define NOISE_TEMPORAL
Definition: vf_noise.h:33
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299