Commit 163e737c authored by Paul B Mahol's avatar Paul B Mahol

avfilter/af_afir: add support for double sample format

parent e6f0cec8
......@@ -1655,6 +1655,22 @@ Allowed range is from @var{1} to @var{32}. Default is @var{1}.
Set IR stream which will be used for convolution, starting from @var{0}, should always be
lower than supplied value by @code{nbirs} option. Default is @var{0}.
This option can be changed at runtime via @ref{commands}.
@item precision
Set which precision to use when processing samples.
@table @option
@item auto
Auto pick internal sample format depending on other filters.
@item float
Always use single-floating point precision sample format.
@item double
Always use double-floating point precision sample format.
@end table
Default value is auto.
@end table
@subsection Examples
......
This diff is collapsed.
/*
* Copyright (c) 2017 Paul B Mahol
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFILTER_AFIR_H
#define AVFILTER_AFIR_H
#include "libavutil/float_dsp.h"
#include "libavutil/frame.h"
#include "libavutil/rational.h"
#include "libavutil/tx.h"
#include "avfilter.h"
#include "af_afirdsp.h"
typedef struct AudioFIRSegment {
int nb_partitions;
int part_size;
int block_size;
int fft_length;
int coeff_size;
int input_size;
int input_offset;
int *output_offset;
int *part_index;
AVFrame *sumin;
AVFrame *sumout;
AVFrame *blockin;
AVFrame *blockout;
AVFrame *buffer;
AVFrame *coeff;
AVFrame *input;
AVFrame *output;
AVTXContext **tx, **itx;
av_tx_fn tx_fn, itx_fn;
} AudioFIRSegment;
typedef struct AudioFIRContext {
const AVClass *class;
float wet_gain;
float dry_gain;
float length;
int gtype;
float ir_gain;
int ir_format;
float max_ir_len;
int response;
int w, h;
AVRational frame_rate;
int ir_channel;
int minp;
int maxp;
int nb_irs;
int selir;
int precision;
int format;
double gain;
int eof_coeffs[32];
int have_coeffs;
int nb_taps;
int nb_channels;
int nb_coef_channels;
int one2many;
AudioFIRSegment seg[1024];
int nb_segments;
AVFrame *in;
AVFrame *ir[32];
AVFrame *video;
int min_part_size;
int64_t pts;
AudioFIRDSPContext afirdsp;
AVFloatDSPContext *fdsp;
} AudioFIRContext;
#endif /* AVFILTER_AFIR_H */
......@@ -29,6 +29,8 @@
typedef struct AudioFIRDSPContext {
void (*fcmul_add)(float *sum, const float *t, const float *c,
ptrdiff_t len);
void (*dcmul_add)(double *sum, const double *t, const double *c,
ptrdiff_t len);
} AudioFIRDSPContext;
void ff_afir_init_x86(AudioFIRDSPContext *s);
......@@ -50,9 +52,27 @@ static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t le
sum[2 * n] += t[2 * n] * c[2 * n];
}
static void dcmul_add_c(double *sum, const double *t, const double *c, ptrdiff_t len)
{
int n;
for (n = 0; n < len; n++) {
const double cre = c[2 * n ];
const double cim = c[2 * n + 1];
const double tre = t[2 * n ];
const double tim = t[2 * n + 1];
sum[2 * n ] += tre * cre - tim * cim;
sum[2 * n + 1] += tre * cim + tim * cre;
}
sum[2 * n] += t[2 * n] * c[2 * n];
}
static av_unused void ff_afir_init(AudioFIRDSPContext *dsp)
{
dsp->fcmul_add = fcmul_add_c;
dsp->dcmul_add = dcmul_add_c;
if (ARCH_X86)
ff_afir_init_x86(dsp);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment