FFmpeg  4.0
Data Structures | Macros | Enumerations | Functions | Variables
vf_fftfilt.c File Reference

FFT domain filtering. More...

#include "libavfilter/internal.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavcodec/avfft.h"
#include "libavutil/eval.h"

Go to the source code of this file.

Data Structures

struct  FFTFILTContext
 

Macros

#define MAX_PLANES   4
 
#define OFFSET(x)   offsetof(FFTFILTContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Enumerations

enum  EvalMode {
  EVAL_MODE_ONCE, EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT,
  EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME,
  EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB,
  EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT,
  EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME,
  EVAL_MODE_NB
}
 
enum  {
  VAR_X, VAR_Y, VAR_W, VAR_H,
  VAR_N, VAR_VARS_NB
}
 
enum  { Y = 0, U, V }
 

Functions

 AVFILTER_DEFINE_CLASS (fftfilt)
 
static double lum (void *priv, double x, double y, int plane)
 
static double weight_Y (void *priv, double x, double y)
 
static double weight_U (void *priv, double x, double y)
 
static double weight_V (void *priv, double x, double y)
 
static void copy_rev (FFTSample *dest, int w, int w2)
 
static void rdft_horizontal8 (FFTFILTContext *s, AVFrame *in, int w, int h, int plane)
 
static void rdft_horizontal16 (FFTFILTContext *s, AVFrame *in, int w, int h, int plane)
 
static void rdft_vertical (FFTFILTContext *s, int h, int plane)
 
static void irdft_vertical (FFTFILTContext *s, int h, int plane)
 
static void irdft_horizontal8 (FFTFILTContext *s, AVFrame *out, int w, int h, int plane)
 
static void irdft_horizontal16 (FFTFILTContext *s, AVFrame *out, int w, int h, int plane)
 
static av_cold int initialize (AVFilterContext *ctx)
 
static void do_eval (FFTFILTContext *s, AVFilterLink *inlink, int plane)
 
static int config_props (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 

Variables

static const char *const var_names [] = { "X", "Y", "W", "H", "N", NULL }
 
static const AVOption fftfilt_options []
 
static const AVFilterPad fftfilt_inputs []
 
static const AVFilterPad fftfilt_outputs []
 
AVFilter ff_vf_fftfilt
 

Detailed Description

FFT domain filtering.

Definition in file vf_fftfilt.c.

Macro Definition Documentation

◆ MAX_PLANES

#define MAX_PLANES   4

Definition at line 35 of file vf_fftfilt.c.

Referenced by uninit().

◆ OFFSET

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

Definition at line 77 of file vf_fftfilt.c.

◆ FLAGS

Definition at line 78 of file vf_fftfilt.c.

Enumeration Type Documentation

◆ EvalMode

enum EvalMode
Enumerator
EVAL_MODE_ONCE 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 

Definition at line 37 of file vf_fftfilt.c.

◆ anonymous enum

anonymous enum
Enumerator
VAR_X 
VAR_Y 
VAR_W 
VAR_H 
VAR_N 
VAR_VARS_NB 

Definition at line 73 of file vf_fftfilt.c.

◆ anonymous enum

anonymous enum
Enumerator

Definition at line 75 of file vf_fftfilt.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( fftfilt  )

◆ lum()

static double lum ( void priv,
double  x,
double  y,
int  plane 
)
inlinestatic

Definition at line 95 of file vf_fftfilt.c.

Referenced by weight_U(), weight_V(), and weight_Y().

◆ weight_Y()

static double weight_Y ( void priv,
double  x,
double  y 
)
static

Definition at line 101 of file vf_fftfilt.c.

Referenced by initialize().

◆ weight_U()

static double weight_U ( void priv,
double  x,
double  y 
)
static

Definition at line 102 of file vf_fftfilt.c.

Referenced by initialize().

◆ weight_V()

static double weight_V ( void priv,
double  x,
double  y 
)
static

Definition at line 103 of file vf_fftfilt.c.

Referenced by initialize().

◆ copy_rev()

static void copy_rev ( FFTSample dest,
int  w,
int  w2 
)
static

Definition at line 105 of file vf_fftfilt.c.

Referenced by rdft_horizontal16(), rdft_horizontal8(), and rdft_vertical().

◆ rdft_horizontal8()

static void rdft_horizontal8 ( FFTFILTContext s,
AVFrame in,
int  w,
int  h,
int  plane 
)
static

Definition at line 117 of file vf_fftfilt.c.

Referenced by config_props().

◆ rdft_horizontal16()

static void rdft_horizontal16 ( FFTFILTContext s,
AVFrame in,
int  w,
int  h,
int  plane 
)
static

Definition at line 132 of file vf_fftfilt.c.

Referenced by config_props().

◆ rdft_vertical()

static void rdft_vertical ( FFTFILTContext s,
int  h,
int  plane 
)
static

Definition at line 150 of file vf_fftfilt.c.

Referenced by filter_frame().

◆ irdft_vertical()

static void irdft_vertical ( FFTFILTContext s,
int  h,
int  plane 
)
static

Definition at line 165 of file vf_fftfilt.c.

Referenced by filter_frame().

◆ irdft_horizontal8()

static void irdft_horizontal8 ( FFTFILTContext s,
AVFrame out,
int  w,
int  h,
int  plane 
)
static

Definition at line 179 of file vf_fftfilt.c.

Referenced by config_props().

◆ irdft_horizontal16()

static void irdft_horizontal16 ( FFTFILTContext s,
AVFrame out,
int  w,
int  h,
int  plane 
)
static

Definition at line 194 of file vf_fftfilt.c.

Referenced by config_props().

◆ initialize()

static av_cold int initialize ( AVFilterContext ctx)
static

Definition at line 212 of file vf_fftfilt.c.

◆ do_eval()

static void do_eval ( FFTFILTContext s,
AVFilterLink inlink,
int  plane 
)
static

Definition at line 246 of file vf_fftfilt.c.

Referenced by config_props(), and filter_frame().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 265 of file vf_fftfilt.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 330 of file vf_fftfilt.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 372 of file vf_fftfilt.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 388 of file vf_fftfilt.c.

Variable Documentation

◆ var_names

const char* const var_names[] = { "X", "Y", "W", "H", "N", NULL }
static

Definition at line 72 of file vf_fftfilt.c.

Referenced by initialize().

◆ fftfilt_options

const AVOption fftfilt_options[]
static
Initial value:
= {
{ "dc_Y", "adjust gain in Y plane", OFFSET(dc[Y]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
{ "dc_U", "adjust gain in U plane", OFFSET(dc[U]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
{ "dc_V", "adjust gain in V plane", OFFSET(dc[V]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
{ "weight_Y", "set luminance expression in Y plane", OFFSET(weight_str[Y]), AV_OPT_TYPE_STRING, {.str = "1"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "weight_U", "set chrominance expression in U plane", OFFSET(weight_str[U]), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "weight_V", "set chrominance expression in V plane", OFFSET(weight_str[V]), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
{ "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
{ "frame", "eval expressions per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
{NULL},
}
#define NULL
Definition: coverity.c:32
Definition: vf_fftfilt.c:75
Definition: vf_fftfilt.c:75
#define OFFSET(x)
Definition: vf_fftfilt.c:77
#define FLAGS
Definition: vf_fftfilt.c:78
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
Definition: vf_fftfilt.c:75

Definition at line 80 of file vf_fftfilt.c.

◆ fftfilt_inputs

const AVFilterPad fftfilt_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_props(AVFilterLink *inlink)
Definition: vf_fftfilt.c:265
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_fftfilt.c:330

Definition at line 413 of file vf_fftfilt.c.

◆ fftfilt_outputs

const AVFilterPad fftfilt_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 423 of file vf_fftfilt.c.

◆ ff_vf_fftfilt

AVFilter ff_vf_fftfilt
Initial value:
= {
.name = "fftfilt",
.description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to pixels in frequency domain."),
.priv_size = sizeof(FFTFILTContext),
.priv_class = &fftfilt_class,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#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:125
static int flags
Definition: log.c:55
static const AVFilterPad fftfilt_inputs[]
Definition: vf_fftfilt.c:413
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static int query_formats(AVFilterContext *ctx)
Definition: vf_fftfilt.c:388
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_fftfilt.c:372
static const AVFilterPad fftfilt_outputs[]
Definition: vf_fftfilt.c:423
static av_cold int initialize(AVFilterContext *ctx)
Definition: vf_fftfilt.c:212

Definition at line 431 of file vf_fftfilt.c.