77#define DEF_EXPR_FIELDS(name) AVExpr *name##_pexpr; char *name##_expr; double name
92#define OFFSET(x) offsetof(VignetteContext, x)
93#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
109 {
"decimated",
"use a decimated wavelet transform, faster but lower quality",
OFFSET(decimated),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
FLAGS },
119#define PARSE_EXPR(name) do { \
120 int ret = av_expr_parse(&s->name##_pexpr, s->name##_expr, var_names, \
121 NULL, NULL, NULL, NULL, 0, ctx); \
123 av_log(ctx, AV_LOG_ERROR, "Unable to parse expression for '" \
124 AV_STRINGIFY(name) "'\n"); \
134 for (
int i = 0;
i < 2;
i++)
135 for (
int j = 0; j < 5; j++)
161 const int xx = (x -
s->x0) *
s->xscale;
162 const int yy = (y -
s->y0) *
s->yscale;
163 const double dnorm = hypot(xx, yy) /
s->dmax;
167 const double c = cos(
s->angle * dnorm);
176 float *
dst =
s->fmap;
177 int dst_linesize =
s->fmap_linesize;
193 if (isnan(
s->x0) || isnan(
s->y0) || isnan(
s->angle))
199 for (y = 0; y < inlink->
h; y++) {
200 for (x = 0; x < inlink->
w; x++) {
206 dst[x] =
f > 1. / 256 ? 1. /
f : 256;
211 for (y = 0; y < inlink->
h; y++) {
212 for (x = 0; x < inlink->
w; x++)
223 dv =
s->dither / (
double)(1LL<<32);
224 s->dither =
s->dither * 1664525 + 1013904223;
275 for (
int y = line0; y < line1; y++) {
276 for (
int x = 0; x < l.
w; x++) {
290 for (
int y = line0; y < line1; y++) {
291 for (
int x = 0; x < l.
w; x++) {
293 const float band = p->src[0][
i], var = p->src[1][
i];
295 p->dst[0][
i] = band * band / var;
296 p->dst[1][
i] = 1 / var;
307 for (
int y = line0; y < line1; y++) {
308 for (
int x = 0; x < l.
w; x++) {
310 const float signal =
FFMAX(p->src[0][
i] - threshold, 0) / p->src[1][
i];
312 p->dst[0][
i] *= signal / (signal + p->src[2][
i]);
321 const int line0 = l.
h * jobnr / nb_jobs;
322 const int line1 = l.
h * (jobnr + 1) / nb_jobs;
356 const double coeff[2][5],
int step,
Lattice lat)
362 p.src[0] =
temp[0]; p.dst[0] =
dst[0]; p.dst[1] =
dst[1];
364 p.src[0] =
temp[1]; p.dst[0] =
dst[2]; p.dst[1] =
dst[3];
374 p.dst[0] =
temp[1]; p.src[0] =
src[2]; p.src[1] =
src[3];
377 p.dst[0] =
dst; p.src[0] =
temp[0]; p.src[1] =
temp[1];
382 const double coeff[2][5],
Lattice lat)
388 p.dst[0] = plane; p.src[0] =
temp;
398 p.dst[0] = plane; p.src[0] =
temp;
408 p.dst[0] = plane; p.src[0] =
temp;
425 p.dst[0] = band; p.src[0] =
temp[0]; p.src[1] =
temp[1]; p.src[2] = var;
432 const size_t plane_size =
s->wplane_size;
433 float *next = var + plane_size;
434 float *
temp[2] = { var + 2 * plane_size, var + 3 * plane_size };
435 float *vbands[4] = { var + 4 * plane_size, var + 5 * plane_size,
436 var + 6 * plane_size, var + 7 * plane_size };
437 float *hbands = var + 8 * plane_size;
439 for (
int i = 0;
i < levels;
i++) {
440 float *
bands[4] = { next, hbands + 3 *
i * plane_size,
441 hbands + (3 *
i + 1) * plane_size, hbands + (3 *
i + 2) * plane_size };
442 float *scratch[3] = {
temp[0],
temp[1], cur };
446 for (
int j = 1; j < 4; j++)
448 FFSWAP(
float *, cur, next);
449 FFSWAP(
float *, var, vbands[0]);
452 for (
int i = levels - 1;
i >= 0;
i--) {
453 float *
bands[4] = { cur, hbands + 3 *
i * plane_size,
454 hbands + (3 *
i + 1) * plane_size, hbands + (3 *
i + 2) * plane_size };
457 FFSWAP(
float *, cur, next);
473 const size_t plane_size =
s->wplane_size;
474 float *
temp[3] = { var + plane_size, var + 2 * plane_size, var + 3 * plane_size };
476 for (
int i = 0;
i < levels;
i++) {
481 for (
int j = 1; j < 4; j++) {
484 (
level.w + !(j & 1)) / 2, (
level.h + !(j >> 1)) / 2 };
491 for (
int i = levels - 1;
i >= 0;
i--)
496 uint8_t *
dst,
int dst_linesize,
497 const uint8_t *
src,
int src_linesize,
int pixel_step,
501 const int linesize =
s->fmap_linesize;
502 const Lattice lat = { 1, linesize,
w,
h };
503 float *cur =
s->wplanes;
504 float *var = cur +
s->wplane_size;
506 for (
int y = 0; y <
h; y++) {
507 for (
int x = 0; x <
w; x++) {
508 const double a =
FFMAX(
s->fmap[(y << vsub) * linesize + (x <<
hsub)], 1e-6);
510 cur[y * linesize + x] =
av_clipd((
src[y * src_linesize + x * pixel_step] -
bias) /
a,
512 var[y * linesize + x] =
s->noise *
s->noise / (
a *
a);
521 for (
int y = 0; y <
h; y++)
522 for (
int x = 0; x <
w; x++)
523 dst[y * dst_linesize + x * pixel_step] =
532 for (
int c = 0;
c < 3;
c++)
539 for (
int plane = 0; plane < 4 && in->
data[plane] && in->
linesize[plane]; plane++) {
540 const int chroma = plane == 1 || plane == 2;
541 const int hsub =
chroma ?
s->desc->log2_chroma_w : 0;
542 const int vsub =
chroma ?
s->desc->log2_chroma_h : 0;
553 unsigned x, y, direct = 0;
577 uint8_t *
dst =
out->data[0];
578 const uint8_t *
src = in ->
data[0];
579 const float *fmap =
s->fmap;
580 const int dst_linesize =
out->linesize[0];
581 const int src_linesize = in ->
linesize[0];
582 const int fmap_linesize =
s->fmap_linesize;
584 for (y = 0; y < inlink->
h; y++) {
586 const uint8_t *srcp =
src;
588 for (x = 0; x < inlink->
w; x++, dstp += 3, srcp += 3) {
589 const float f = fmap[x];
597 fmap += fmap_linesize;
602 for (plane = 0; plane < 4 && in->
data[plane] && in->
linesize[plane]; plane++) {
603 uint8_t *
dst =
out->data[plane];
604 const uint8_t *
src = in ->
data[plane];
605 const float *fmap =
s->fmap;
606 const int dst_linesize =
out->linesize[plane];
607 const int src_linesize = in ->
linesize[plane];
608 const int fmap_linesize =
s->fmap_linesize;
609 const int chroma = plane == 1 || plane == 2;
610 const int hsub =
chroma ?
s->desc->log2_chroma_w : 0;
611 const int vsub =
chroma ?
s->desc->log2_chroma_h : 0;
615 for (y = 0; y <
h; y++) {
617 const uint8_t *srcp =
src;
619 for (x = 0; x <
w; x++) {
626 fmap += fmap_linesize << vsub;
644 s->var_values[
VAR_W] = inlink->
w;
645 s->var_values[
VAR_H] = inlink->
h;
659 s->dmax = hypot(inlink->
w / 2., inlink->
h / 2.);
661 s->xscale,
s->yscale,
s->dmax);
663 s->fmap_linesize =
FFALIGN(inlink->
w, 32);
669 s->wplane_size = (size_t)
s->fmap_linesize * inlink->
h;
691 .p.name =
"vignette",
693 .p.priv_class = &vignette_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const float bands[]
const FFFilter ff_vf_vignette
Mode
Frame type (Table 1a in 3GPP TS 26.101)
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
simple arithmetic expression evaluator
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#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 AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_always_inline av_const int avpriv_mirror(int x, int w)
static enum AVPixelFormat pix_fmts[]
#define FFSWAP(type, a, b)
Memory handling functions.
static int noise(AVBSFContext *ctx, AVPacket *pkt)
static const char *const var_names[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
static int config_props(AVBitStreamFilterLink *link)
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
Samples of a plane processed by a pass, sample x of line y is at y * ystride + x * xstride,...
const AVPixFmtDescriptor * desc
double var_values[VAR_NB]
One operation on the lines of a lattice, run in parallel over slices of lines.
#define av_malloc_array(a, b)
static int run_pass_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static void run_pass(AVFilterContext *ctx, WaveletPass *p)
static void filter_plane_wavelet(AVFilterContext *ctx, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int pixel_step, int w, int h, int hsub, int vsub, int bias)
static void transform_undecimated(AVFilterContext *ctx, float *cur, float *var, int levels, Lattice lat)
static void energy_lines(const WaveletPass *p, int line0, int line1)
static double get_dither_value(VignetteContext *s)
static void transform_decimated(AVFilterContext *ctx, float *cur, float *var, int levels, Lattice lat)
static int wavelet_levels(int w, int h)
static const AVFilterPad vignette_inputs[]
static void shrink_band(AVFilterContext *ctx, float *band, const float *var, float *temp[3], int step, Lattice lat)
Wiener shrinkage of a detail band toward 0, the signal variance is estimated from a box of coefficien...
static double get_natural_factor(const VignetteContext *s, int x, int y)
static void update_context(VignetteContext *s, AVFilterLink *inlink, AVFrame *frame)
static void compose(AVFilterContext *ctx, float *dst, float *const src[4], float *temp[2], int step, Lattice lat)
static const AVOption vignette_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void box_filter(AVFilterContext *ctx, float *plane, float *temp, int step, Lattice lat)
static void gain_lines(const WaveletPass *p, int line0, int line1)
static void box_lines(const WaveletPass *p, int line0, int line1)
static void decompose(AVFilterContext *ctx, float *dst[4], const float *src, float *temp[2], const double coeff[2][5], int step, Lattice lat)
static Lattice level_lattice(Lattice lat, int level)
Lattice of the lowpass coefficients of the given level of a decimated transform.
static int config_props(AVFilterLink *inlink)
static av_cold void uninit(AVFilterContext *ctx)
@ PASS_DECOMPOSE_DECIMATED
static void filter_frame_wavelet(AVFilterContext *ctx, AVFrame *out, const AVFrame *in)
static void decompose_decimated(AVFilterContext *ctx, float *plane, float *temp, const double coeff[2][5], Lattice lat)
static void compose_decimated(AVFilterContext *ctx, float *plane, float *temp, Lattice lat)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int bias(int x, int c)
void ff_wavelet97_decompose_decimated_lines(float *dst, const float *src, const double coeff[2][5], int xstride, int ystride, int len, int line0, int line1)
Decimated analysis of lines line0..line1-1 along one direction.
void ff_wavelet97_decompose_lines(float *dst_l, float *dst_h, const float *src, const double coeff[2][5], int xlinesize, int ylinesize, int step, int w, int line0, int line1)
Undecimated analysis of lines line0..line1-1 along one direction.
void ff_wavelet97_compose_lines(float *dst, const float *src_l, const float *src_h, int xlinesize, int ylinesize, int step, int w, int line0, int line1)
Inverse of ff_wavelet97_decompose_lines() with ff_wavelet97_coeff.
const double ff_wavelet97_coeff[2][5]
Undecimated 9/7 wavelet transform.
void ff_wavelet97_compose_decimated_lines(float *dst, const float *src, int xstride, int ystride, int len, int line0, int line1)
Inverse of ff_wavelet97_decompose_decimated_lines() with ff_wavelet97_coeff.