71#define OFFSET(x) offsetof(ACrusherContext, x)
72#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
109static double add_dc(
double s,
double dc,
double idc)
111 return s > 0 ?
s * dc :
s * idc;
116 return s > 0 ?
s * idc :
s * dc;
119static inline double factor(
double y,
double k,
double aa1,
double aa)
126 const double sqr =
s->sqr;
127 const double coeff =
s->coeff;
128 const double aa =
s->aa;
129 const double aa1 =
s->aa1;
158 if (k - aa1 <= y && y <= k + aa1) {
160 }
else if (y > k + aa1) {
174 }
else if (k - aa1 <= y && y <= k + aa1) {
176 }
else if (y > k + aa1) {
189 k += (in - k) *
s->mix;
205 val = sin((phs * 360.) *
M_PI / 180);
213 if (lfo->
phase >= 1.)
223 const double *
src = (
const double *)in->
data[0];
225 const double level_in =
s->level_in;
226 const double level_out =
s->level_out;
227 const double mix =
s->mix;
241 dst = (
double *)
out->data[0];
244 s->samples =
s->smin +
s->sdiff * (
lfo_get(&
s->lfo) + 0.5);
278 double rad, sunder, smax, sover;
281 s->coeff =
exp2(
s->bits) - 1;
282 s->sqr = sqrt(
s->coeff / 2);
283 s->aa1 = (1. -
s->aa) / 2.;
285 rad =
s->lforange / 2.;
286 s->smin =
FFMAX(
s->samples - rad, 1.);
287 sunder =
s->samples - rad -
s->smin;
288 smax =
FFMIN(
s->samples + rad, 250.);
289 sover =
s->samples + rad - smax;
292 s->sdiff = smax -
s->smin;
294 s->lfo.freq =
s->lforate;
308 char *res,
int res_len,
int flags)
330 .p.name =
"acrusher",
332 .p.priv_class = &acrusher_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
static int config_input(AVFilterLink *inlink)
static double lfo_get(LFOContext *lfo)
static int config_input(AVFilterLink *inlink)
static double remove_dc(double s, double dc, double idc)
const FFFilter ff_af_acrusher
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void lfo_advance(LFOContext *lfo, unsigned count)
static double add_dc(double s, double dc, double idc)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad avfilter_af_acrusher_inputs[]
static double samplereduction(ACrusherContext *s, SRContext *sr, double in)
static const AVOption acrusher_options[]
static double bitreduction(ACrusherContext *s, double in)
static double sqr(double in)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Main libavfilter public API header.
#define flags(name, subs,...)
static __device__ float fabs(float a)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
static const uint8_t bits[8]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ 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.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
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.
@ AV_SAMPLE_FMT_DBL
double
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int mix(int c0, int c1)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
static const int factor[16]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_always_inline av_const double round(double x)
static av_always_inline av_const float roundf(float x)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A link between two filters.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static AVFormatContext * ctx
static const double coeff[2][5]