FFmpeg
Data Structures | Macros | Functions | Variables
vf_noise.c File Reference
#include "libavutil/emms.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/lfg.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.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 (AVFilterContext *ctx)
 
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 ( AVFilterContext ctx)
static

Definition at line 134 of file vf_noise.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 149 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 166 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 179 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 191 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 225 of file vf_noise.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame inpicref 
)
static

Definition at line 243 of file vf_noise.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 285 of file vf_noise.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 316 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 325 of file vf_noise.c.

◆ ff_vf_noise

const AVFilter ff_vf_noise
Initial value:

Definition at line 334 of file vf_noise.c.

uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_noise.c:316
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:221
NOISE_PATTERN
#define NOISE_PATTERN
Definition: vf_noise.h:35
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_noise.c:149
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_noise.c:285
NoiseContext
Definition: noise.c:62
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
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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:106
noise_inputs
static const AVFilterPad noise_inputs[]
Definition: vf_noise.c:325
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:147
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
Definition: opt.h:235
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
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
OFFSET
#define OFFSET(x)
Definition: vf_noise.c:43
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:234
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_noise.c:134
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
Definition: vf_noise.c:243
NOISE_TEMPORAL
#define NOISE_TEMPORAL
Definition: vf_noise.h:33
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244