Go to the documentation of this file.
42 #define OFFSET(x) offsetof(NoiseContext, x)
43 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
45 #define NOISE_PARAMS(name, x, param) \
46 {#name"_seed", "set component #"#x" noise seed", OFFSET(param.seed), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, FLAGS}, \
47 {#name"_strength", "set component #"#x" strength", OFFSET(param.strength), AV_OPT_TYPE_INT, {.i64=0}, 0, 100, FLAGS}, \
48 {#name"s", "set component #"#x" strength", OFFSET(param.strength), AV_OPT_TYPE_INT, {.i64=0}, 0, 100, FLAGS}, \
49 {#name"_flags", "set component #"#x" flags", OFFSET(param.flags), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, #name"_flags"}, \
50 {#name"f", "set component #"#x" flags", OFFSET(param.flags), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, 31, FLAGS, #name"_flags"}, \
51 {"a", "averaged noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_AVERAGED}, 0, 0, FLAGS, #name"_flags"}, \
52 {"p", "(semi)regular pattern", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_PATTERN}, 0, 0, FLAGS, #name"_flags"}, \
53 {"t", "temporal noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_TEMPORAL}, 0, 0, FLAGS, #name"_flags"}, \
54 {"u", "uniform noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_UNIFORM}, 0, 0, FLAGS, #name"_flags"},
67 static const int8_t
patt[4] = { -1, 0, 1, 0 };
69 #define RAND_N(range) ((int) ((double) range * av_lfg_get(lfg) / (UINT_MAX + 1.0)))
75 int strength =
fp->strength;
89 +
patt[j % 4] * strength * 0.25 / 3;
96 +
patt[j % 4] * strength * 0.25;
102 double x1, x2,
w, y1;
104 x1 = 2.0 *
av_lfg_get(lfg) / (float)UINT_MAX - 1.0;
105 x2 = 2.0 *
av_lfg_get(lfg) / (float)UINT_MAX - 1.0;
106 w = x1 * x1 + x2 * x2;
109 w = sqrt((-2.0 * log(
w)) /
w);
111 y1 *= strength / sqrt(3.0);
114 y1 +=
patt[j % 4] * strength * 0.35;
126 for (j = 0; j < 3; j++)
171 for (
i = 0;
i <
len;
i++) {
179 int len,
const int8_t *
const *
shift)
182 const int8_t *src2 = (
const int8_t*)
src;
184 for (
i = 0;
i <
len;
i++) {
186 dst[
i] = src2[
i] + ((n * src2[
i]) >> 7);
190 static void noise(uint8_t *dst,
const uint8_t *
src,
191 int dst_linesize,
int src_linesize,
205 for (y = start; y < end; y++) {
206 const int ix = y & (
MAX_RES - 1);
230 for (plane = 0; plane <
s->nb_planes; plane++) {
231 const int height =
s->height[plane];
232 const int start = (
height * jobnr ) / nb_jobs;
233 const int end = (
height * (jobnr+1)) / nb_jobs;
234 noise(
td->out->data[plane] + start *
td->out->linesize[plane],
235 td->in->data[plane] + start *
td->in->linesize[plane],
236 td->out->linesize[plane],
td->in->linesize[plane],
237 s->bytewidth[plane], start, end,
s, plane);
270 fp->rand_shift_init = 1;
274 td.in = inpicref;
td.out =
out;
289 for (
i = 0;
i < 4;
i++) {
300 for (
i = 0;
i < 4;
i++) {
319 for (
i = 0;
i < 4;
i++)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static av_cold void uninit(AVFilterContext *ctx)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static int config_input(AVFilterLink *inlink)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
#define FILTER_QUERY_FUNC(func)
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)
const char * name
Filter name.
A link between two filters.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
static av_cold int init(AVFilterContext *ctx)
A filter pad used for either input or output.
static av_cold int init_noise(NoiseContext *n, int comp)
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
#define AV_CEIL_RSHIFT(a, b)
#define FILTER_INPUTS(array)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void(* line_noise)(uint8_t *dst, const uint8_t *src, const int8_t *noise, int len, int shift)
const AVFilter ff_vf_noise
av_cold void ff_noise_init_x86(NoiseContext *n)
Context structure for the Lagged Fibonacci PRNG.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int8_t * prev_shift[MAX_RES][3]
static const AVFilterPad noise_outputs[]
static const AVFilterPad noise_inputs[]
#define NOISE_PARAMS(name, x, param)
AVFILTER_DEFINE_CLASS(noise)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define i(width, name, range_min, range_max)
int w
agreed upon image width
void ff_line_noise_avg_c(uint8_t *dst, const uint8_t *src, int len, const int8_t *const *shift)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
const char * name
Pad name.
void ff_line_noise_c(uint8_t *dst, const uint8_t *src, const int8_t *noise, int len, int shift)
int h
agreed upon image height
static const int8_t patt[4]
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
void(* line_noise_avg)(uint8_t *dst, const uint8_t *src, int len, const int8_t *const *shift)
static int shift(int a, int b)
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
#define flags(name, subs,...)
static const AVOption noise_options[]
static int query_formats(AVFilterContext *ctx)
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
static const AVClass noise_class