Go to the documentation of this file.
29 #define RDFT_BITS_MIN 4
30 #define RDFT_BITS_MAX 16
54 #define NB_GAIN_ENTRY_MAX 4096
113 #define OFFSET(x) offsetof(FIREqualizerContext, x)
114 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
115 #define TFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
159 s->analysis_rdft =
s->analysis_irdft =
s->rdft =
s->irdft =
NULL;
161 s->cepstrum_rdft =
NULL;
162 s->cepstrum_irdft =
NULL;
215 if (nsamples <= s->nsamples_max) {
216 float *buf = conv_buf + idx->buf_idx *
s->rdft_len;
217 float *obuf = conv_buf + !idx->buf_idx *
s->rdft_len + idx->overlap_idx;
218 int center =
s->fir_len/2;
221 memset(buf, 0, center *
sizeof(*
data));
222 memcpy(buf + center,
data, nsamples *
sizeof(*
data));
223 memset(buf + center + nsamples, 0, (
s->rdft_len - nsamples - center) *
sizeof(*
data));
226 buf[0] *= kernel_buf[0];
227 buf[1] *= kernel_buf[
s->rdft_len/2];
228 for (k = 1; k <
s->rdft_len/2; k++) {
229 buf[2*k] *= kernel_buf[k];
230 buf[2*k+1] *= kernel_buf[k];
234 for (k = 0; k <
s->rdft_len - idx->overlap_idx; k++)
236 memcpy(
data, buf, nsamples *
sizeof(*
data));
237 idx->buf_idx = !idx->buf_idx;
238 idx->overlap_idx = nsamples;
240 while (nsamples >
s->nsamples_max * 2) {
242 data +=
s->nsamples_max;
243 nsamples -=
s->nsamples_max;
254 if (nsamples <= s->nsamples_max) {
255 float *buf = conv_buf + idx->buf_idx *
s->rdft_len;
256 float *obuf = conv_buf + !idx->buf_idx *
s->rdft_len + idx->overlap_idx;
259 memcpy(buf,
data, nsamples *
sizeof(*
data));
260 memset(buf + nsamples, 0, (
s->rdft_len - nsamples) *
sizeof(*
data));
263 buf[0] *= kernel_buf[0];
264 buf[1] *= kernel_buf[1];
265 for (k = 2; k <
s->rdft_len; k += 2) {
267 re = buf[k] * kernel_buf[k] - buf[k+1] * kernel_buf[k+1];
268 im = buf[k] * kernel_buf[k+1] + buf[k+1] * kernel_buf[k];
274 for (k = 0; k <
s->rdft_len - idx->overlap_idx; k++)
276 memcpy(
data, buf, nsamples *
sizeof(*
data));
277 idx->buf_idx = !idx->buf_idx;
278 idx->overlap_idx = nsamples;
280 while (nsamples >
s->nsamples_max * 2) {
282 data +=
s->nsamples_max;
283 nsamples -=
s->nsamples_max;
293 if (nsamples <= s->nsamples_max) {
294 FFTComplex *buf = conv_buf + idx->buf_idx *
s->rdft_len;
295 FFTComplex *obuf = conv_buf + !idx->buf_idx *
s->rdft_len + idx->overlap_idx;
296 int center =
s->fir_len/2;
300 memset(buf, 0, center *
sizeof(*buf));
301 for (k = 0; k < nsamples; k++) {
302 buf[center+k].
re = data0[k];
303 buf[center+k].
im = data1[k];
305 memset(buf + center + nsamples, 0, (
s->rdft_len - nsamples - center) *
sizeof(*buf));
312 buf[0].
re = 0.5f * kernel_buf[0] * buf[0].
im;
313 buf[0].
im = 0.5f * kernel_buf[0] *
tmp;
314 for (k = 1; k <
s->rdft_len/2; k++) {
315 int m =
s->rdft_len - k;
317 buf[k].
re = 0.5f * kernel_buf[k] * buf[k].
im;
318 buf[k].
im = 0.5f * kernel_buf[k] *
tmp;
320 buf[m].
re = 0.5f * kernel_buf[k] * buf[m].
im;
321 buf[m].
im = 0.5f * kernel_buf[k] *
tmp;
324 buf[k].
re = 0.5f * kernel_buf[k] * buf[k].
im;
325 buf[k].
im = 0.5f * kernel_buf[k] *
tmp;
330 for (k = 0; k <
s->rdft_len - idx->overlap_idx; k++) {
331 buf[k].
re += obuf[k].
re;
332 buf[k].
im += obuf[k].
im;
336 for (k = 0; k < nsamples; k++) {
337 data0[k] = buf[k].
im;
338 data1[k] = buf[k].
re;
340 idx->buf_idx = !idx->buf_idx;
341 idx->overlap_idx = nsamples;
343 while (nsamples >
s->nsamples_max * 2) {
345 data0 +=
s->nsamples_max;
346 data1 +=
s->nsamples_max;
347 nsamples -=
s->nsamples_max;
350 fast_convolute2(
s, kernel_buf, conv_buf, idx, data0 + nsamples/2, data1 + nsamples/2, nsamples - nsamples/2);
357 int rate =
ctx->inputs[0]->sample_rate;
361 int center =
s->fir_len / 2;
362 double delay =
s->zero_phase ? 0.0 : (double) center / rate;
366 s->analysis_buf[0] *=
s->rdft_len/2;
367 for (
x = 1;
x <= center;
x++) {
368 s->analysis_buf[
x] *=
s->rdft_len/2;
369 s->analysis_buf[
s->analysis_rdft_len -
x] *=
s->rdft_len/2;
372 for (
x = 0;
x <
s->fir_len;
x++)
373 s->analysis_buf[
x] *=
s->rdft_len/2;
379 fprintf(
fp,
"# time[%d] (time amplitude)\n",
ch);
382 for (
x = center;
x > 0;
x--)
383 fprintf(
fp,
"%15.10f %15.10f\n", delay - (
double)
x / rate, (
double)
s->analysis_buf[
s->analysis_rdft_len -
x]);
385 for (
x = 0;
x <= center;
x++)
386 fprintf(
fp,
"%15.10f %15.10f\n", delay + (
double)
x / rate , (
double)
s->analysis_buf[
x]);
388 for (
x = 0;
x <
s->fir_len;
x++)
389 fprintf(
fp,
"%15.10f %15.10f\n", (
double)
x / rate, (
double)
s->analysis_buf[
x]);
394 fprintf(
fp,
"\n\n# freq[%d] (frequency desired_gain actual_gain)\n",
ch);
396 for (
x = 0;
x <=
s->analysis_rdft_len/2;
x++) {
397 int i = (
x ==
s->analysis_rdft_len/2) ? 1 : 2 *
x;
398 vx = (double)
x * rate /
s->analysis_rdft_len;
402 yb =
s->min_phase && (
i > 1) ? hypotf(
s->analysis_buf[
i],
s->analysis_buf[
i+1]) :
s->analysis_buf[
i];
406 ya = 20.0 * log10(fabs(ya));
407 yb = 20.0 * log10(fabs(yb));
409 fprintf(
fp,
"%17.10f %17.10f %17.10f\n", vx, ya, yb);
420 s->gain_entry_err =
AVERROR(EINVAL);
426 s->gain_entry_err =
AVERROR(EINVAL);
430 if (
s->nb_gain_entry > 0 && freq <= s->gain_entry_tbl[
s->nb_gain_entry - 1].freq) {
432 s->gain_entry_err =
AVERROR(EINVAL);
436 s->gain_entry_tbl[
s->nb_gain_entry].freq = freq;
437 s->gain_entry_tbl[
s->nb_gain_entry].gain = gain;
444 const double *freq =
key;
447 if (*freq < entry[0].freq)
449 if (*freq > entry[1].freq)
464 if (!
s->nb_gain_entry)
467 if (freq <= s->gain_entry_tbl[0].freq)
468 return s->gain_entry_tbl[0].gain;
470 if (freq >=
s->gain_entry_tbl[
s->nb_gain_entry-1].freq)
471 return s->gain_entry_tbl[
s->nb_gain_entry-1].gain;
473 res = bsearch(&freq, &
s->gain_entry_tbl,
s->nb_gain_entry - 1,
sizeof(*res),
gain_entry_compare);
477 d0 = freq - res[0].
freq;
478 d1 = res[1].
freq - freq;
481 return (d0 * res[1].gain + d1 * res[0].gain) / d;
496 double m0, m1, m2, msum, unit;
498 if (!
s->nb_gain_entry)
501 if (freq <= s->gain_entry_tbl[0].freq)
502 return s->gain_entry_tbl[0].gain;
504 if (freq >=
s->gain_entry_tbl[
s->nb_gain_entry-1].freq)
505 return s->gain_entry_tbl[
s->nb_gain_entry-1].gain;
507 res = bsearch(&freq, &
s->gain_entry_tbl,
s->nb_gain_entry - 1,
sizeof(*res),
gain_entry_compare);
511 m0 = res !=
s->gain_entry_tbl ?
512 unit * (res[0].
gain - res[-1].
gain) / (res[0].freq - res[-1].freq) : 0;
514 m2 = res !=
s->gain_entry_tbl +
s->nb_gain_entry - 2 ?
515 unit * (res[2].
gain - res[1].
gain) / (res[2].freq - res[1].freq) : 0;
517 msum = fabs(m0) + fabs(m1);
518 m0 = msum > 0 ? (fabs(m0) * m1 + fabs(m1) * m0) / msum : 0;
519 msum = fabs(m1) + fabs(m2);
520 m1 = msum > 0 ? (fabs(m1) * m2 + fabs(m2) * m1) / msum : 0;
524 b = 3 * res[1].
gain - m1 - 2 *
c - 3 * d;
527 x = (freq - res[0].
freq) / unit;
531 return a * x3 +
b * x2 +
c *
x + d;
556 int k, cepstrum_len =
s->cepstrum_len, rdft_len =
s->rdft_len;
557 double norm = 2.0 / cepstrum_len;
558 double minval = 1e-7 / rdft_len;
560 memset(
s->cepstrum_buf, 0, cepstrum_len *
sizeof(*
s->cepstrum_buf));
561 memcpy(
s->cepstrum_buf, rdft_buf, rdft_len/2 *
sizeof(*rdft_buf));
562 memcpy(
s->cepstrum_buf + cepstrum_len - rdft_len/2, rdft_buf + rdft_len/2, rdft_len/2 *
sizeof(*rdft_buf));
566 s->cepstrum_buf[0] = log(
FFMAX(
s->cepstrum_buf[0], minval));
567 s->cepstrum_buf[1] = log(
FFMAX(
s->cepstrum_buf[1], minval));
569 for (k = 2; k < cepstrum_len; k += 2) {
570 s->cepstrum_buf[k] = log(
FFMAX(
s->cepstrum_buf[k], minval));
571 s->cepstrum_buf[k+1] = 0;
576 memset(
s->cepstrum_buf + cepstrum_len/2 + 1, 0, (cepstrum_len/2 - 1) *
sizeof(*
s->cepstrum_buf));
577 for (k = 1; k < cepstrum_len/2; k++)
578 s->cepstrum_buf[k] *= 2;
582 s->cepstrum_buf[0] =
exp(
s->cepstrum_buf[0] * norm) * norm;
583 s->cepstrum_buf[1] =
exp(
s->cepstrum_buf[1] * norm) * norm;
584 for (k = 2; k < cepstrum_len; k += 2) {
585 double mag =
exp(
s->cepstrum_buf[k] * norm) * norm;
586 double ph =
s->cepstrum_buf[k+1] * norm;
587 s->cepstrum_buf[k] = mag * cos(ph);
588 s->cepstrum_buf[k+1] = mag * sin(ph);
592 memset(rdft_buf, 0,
s->rdft_len *
sizeof(*rdft_buf));
593 memcpy(rdft_buf,
s->cepstrum_buf,
s->fir_len *
sizeof(*rdft_buf));
596 memset(
s->analysis_buf, 0,
s->analysis_rdft_len *
sizeof(*
s->analysis_buf));
597 memcpy(
s->analysis_buf,
s->cepstrum_buf,
s->fir_len *
sizeof(*
s->analysis_buf));
606 const char *gain_entry_func_names[] = {
"entry",
NULL };
607 const char *gain_func_names[] = {
"gain_interpolate",
"cubic_interpolate",
NULL };
608 double (*gain_entry_funcs[])(
void *, double, double) = {
entry_func,
NULL };
612 int ret, k, center,
ch;
615 FILE *dump_fp =
NULL;
617 s->nb_gain_entry = 0;
618 s->gain_entry_err = 0;
622 gain_entry_func_names, gain_entry_funcs,
ctx, 0,
ctx);
625 if (
s->gain_entry_err < 0)
626 return s->gain_entry_err;
636 if (
s->dumpfile && (!
s->dump_buf || !
s->analysis_rdft || !(dump_fp = fopen(
s->dumpfile,
"w"))))
643 float *rdft_buf =
s->kernel_tmp_buf +
ch *
s->rdft_len;
651 s->analysis_buf[0] = ylog ? pow(10.0, 0.05 *
result) :
result;
657 s->analysis_buf[1] = ylog ? pow(10.0, 0.05 *
result) :
result;
659 for (k = 1; k <
s->analysis_rdft_len/2; k++) {
660 vars[
VAR_F] = k * ((double)
inlink->sample_rate /(
double)
s->analysis_rdft_len);
665 s->analysis_buf[2*k+1] = 0.0;
669 memcpy(
s->dump_buf,
s->analysis_buf,
s->analysis_rdft_len *
sizeof(*
s->analysis_buf));
672 center =
s->fir_len / 2;
674 for (k = 0; k <= center; k++) {
675 double u = k * (
M_PI/center);
682 win = 0.5 + 0.5 * cos(
u);
685 win = 0.53836 + 0.46164 * cos(
u);
688 win = 0.42 + 0.5 * cos(
u) + 0.08 * cos(2*
u);
691 win = 0.40897 + 0.5 * cos(
u) + 0.09103 * cos(2*
u);
694 win = 0.4243801 + 0.4973406 * cos(
u) + 0.0782793 * cos(2*
u);
697 win = 0.355768 + 0.487396 * cos(
u) + 0.144232 * cos(2*
u) + 0.012604 * cos(3*
u);
700 win = 0.3635819 + 0.4891775 * cos(
u) + 0.1365995 * cos(2*
u) + 0.0106411 * cos(3*
u);
703 win = 0.35875 + 0.48829 * cos(
u) + 0.14128 * cos(2*
u) + 0.01168 * cos(3*
u);
706 win = (
u <= 0.5 *
M_PI) ? 1.0 : (0.5 + 0.5 * cos(2*
u -
M_PI));
711 s->analysis_buf[k] *= (2.0/
s->analysis_rdft_len) * (2.0/
s->rdft_len) *
win;
713 s->analysis_buf[
s->analysis_rdft_len - k] =
s->analysis_buf[k];
716 memset(
s->analysis_buf + center + 1, 0, (
s->analysis_rdft_len -
s->fir_len) *
sizeof(*
s->analysis_buf));
717 memcpy(rdft_buf,
s->analysis_buf,
s->rdft_len/2 *
sizeof(*
s->analysis_buf));
718 memcpy(rdft_buf +
s->rdft_len/2,
s->analysis_buf +
s->analysis_rdft_len -
s->rdft_len/2,
s->rdft_len/2 *
sizeof(*
s->analysis_buf));
723 for (k = 0; k <
s->rdft_len; k++) {
724 if (
isnan(rdft_buf[k]) ||
isinf(rdft_buf[k])) {
734 rdft_buf[
s->rdft_len-1] = rdft_buf[1];
735 for (k = 0; k <
s->rdft_len/2; k++)
736 rdft_buf[k] = rdft_buf[2*k];
737 rdft_buf[
s->rdft_len/2] = rdft_buf[
s->rdft_len-1];
747 memcpy(
s->kernel_buf,
s->kernel_tmp_buf, (
s->multi ?
inlink->channels : 1) *
s->rdft_len *
sizeof(*
s->kernel_buf));
754 #define SELECT_GAIN(s) (s->gain_cmd ? s->gain_cmd : s->gain)
755 #define SELECT_GAIN_ENTRY(s) (s->gain_entry_cmd ? s->gain_entry_cmd : s->gain_entry)
766 s->frame_nsamples_max = 0;
768 s->fir_len =
FFMAX(2 * (
int)(
inlink->sample_rate *
s->delay) + 1, 3);
769 s->remaining =
s->fir_len - 1;
772 s->rdft_len = 1 << rdft_bits;
773 s->nsamples_max =
s->rdft_len -
s->fir_len + 1;
774 if (
s->nsamples_max * 2 >=
s->fir_len)
790 int cepstrum_bits = rdft_bits + 2;
799 if (!
s->cepstrum_rdft || !
s->cepstrum_irdft)
802 s->cepstrum_len = 1 << cepstrum_bits;
804 if (!
s->cepstrum_buf)
809 s->analysis_rdft_len = 1 << rdft_bits;
810 if (
inlink->sample_rate <=
s->accuracy *
s->analysis_rdft_len)
832 if (!
s->analysis_buf || !
s->kernel_tmp_buf || !
s->kernel_buf || !
s->conv_buf || !
s->conv_idx)
835 av_log(
ctx,
AV_LOG_DEBUG,
"sample_rate = %d, channels = %d, analysis_rdft_len = %d, rdft_len = %d, fir_len = %d, nsamples_max = %d.\n",
836 inlink->sample_rate,
inlink->channels,
s->analysis_rdft_len,
s->rdft_len,
s->fir_len,
s->nsamples_max);
851 for (
ch = 0;
ch + 1 <
inlink->channels &&
s->fft_ctx;
ch += 2) {
853 s->conv_idx +
ch, (
float *)
frame->extended_data[
ch],
854 (
float *)
frame->extended_data[
ch+1],
frame->nb_samples);
859 s->conv_buf + 2 *
ch *
s->rdft_len,
s->conv_idx +
ch,
865 s->conv_buf + 2 *
ch *
s->rdft_len,
s->conv_idx +
ch,
873 if (
s->zero_phase && !
s->min_phase)
876 s->frame_nsamples_max =
FFMAX(
s->frame_nsamples_max,
frame->nb_samples);
895 s->remaining -=
frame->nb_samples;
903 char *res,
int res_len,
int flags)
908 if (!strcmp(cmd,
"gain")) {
923 s->gain_cmd = gain_cmd;
927 }
else if (!strcmp(cmd,
"gain_entry")) {
928 char *gain_entry_cmd;
942 s->gain_entry_cmd = gain_entry_cmd;
972 .
name =
"firequalizer",
980 .priv_class = &firequalizer_class,
av_cold void av_fft_end(FFTContext *s)
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
A list of supported channel layouts.
#define AV_LOG_WARNING
Something somehow does not look correct.
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
static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *gain_entry)
#define u(width, name, range_min, range_max)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static enum AVSampleFormat sample_fmts[]
enum MovChannelLayoutTag * layouts
#define AVERROR_EOF
End of file.
static void fft2(FFTComplex *z)
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 double gain_interpolate_func(void *p, double freq)
RDFTContext * analysis_irdft
This structure describes decoded (raw) audio or video data.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
const char * name
Filter name.
static int query_formats(AVFilterContext *ctx)
A link between two filters.
int channels
Number of channels.
RDFTContext * cepstrum_irdft
#define SELECT_GAIN_ENTRY(s)
static float win(SuperEqualizerContext *s, float n, int N)
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
#define NB_GAIN_ENTRY_MAX
static void generate_min_phase_kernel(FIREqualizerContext *s, float *rdft_buf)
static const AVFilterPad firequalizer_outputs[]
static const AVFilterPad firequalizer_inputs[]
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
static int request_frame(AVFilterLink *outlink)
static double cubic_interpolate_func(void *p, double freq)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
AVFilter ff_af_firequalizer
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold void uninit(AVFilterContext *ctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const AVFilterPad outputs[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void av_rdft_calc(RDFTContext *s, FFTSample *data)
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
static const uint8_t vars[2][12]
static double entry_func(void *p, double freq, double gain)
AVFILTER_DEFINE_CLASS(firequalizer)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
static const char *const var_names[]
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
RDFTContext * av_rdft_init(int nbits, enum RDFTransformType trans)
Set up a real FFT.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
static void fast_convolute2(FIREqualizerContext *av_restrict s, const float *av_restrict kernel_buf, FFTComplex *av_restrict conv_buf, OverlapIndex *av_restrict idx, float *av_restrict data0, float *av_restrict data1, int nsamples)
static AVRational av_make_q(int num, int den)
Create an AVRational.
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVFilterContext * src
source filter
static const AVOption firequalizer_options[]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
RDFTContext * cepstrum_rdft
#define i(width, name, range_min, range_max)
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
Get the channel with the given index in channel_layout.
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
GainEntry gain_entry_tbl[NB_GAIN_ENTRY_MAX]
const char * name
Pad name.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static void fast_convolute(FIREqualizerContext *av_restrict s, const float *av_restrict kernel_buf, float *av_restrict conv_buf, OverlapIndex *av_restrict idx, float *av_restrict data, int nsamples)
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
FFTContext * av_fft_init(int nbits, int inverse)
Set up a complex FFT.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
static void common_uninit(FIREqualizerContext *s)
char * av_strdup(const char *s)
Duplicate a string.
static void fast_convolute_nonlinear(FIREqualizerContext *av_restrict s, const float *av_restrict kernel_buf, float *av_restrict conv_buf, OverlapIndex *av_restrict idx, float *av_restrict data, int nsamples)
static int gain_entry_compare(const void *key, const void *memb)
RDFTContext * analysis_rdft
#define fixed(width, name, value)
#define flags(name, subs,...)
void av_rdft_end(RDFTContext *s)
static int config_input(AVFilterLink *inlink)
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
static void dump_fir(AVFilterContext *ctx, FILE *fp, int ch)