mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 02:39:48 +00:00
![Thomas Gleixner](/assets/img/avatar_default.png)
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program 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 general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 675 mass ave cambridge ma 02139 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 441 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190520071858.739733335@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
51 lines
977 B
C
51 lines
977 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* SpanDSP - a series of DSP components for telephony
|
|
*
|
|
* biquad.h - General telephony bi-quad section routines (currently this just
|
|
* handles canonic/type 2 form)
|
|
*
|
|
* Written by Steve Underwood <steveu@coppice.org>
|
|
*
|
|
* Copyright (C) 2001 Steve Underwood
|
|
*
|
|
* All rights reserved.
|
|
*/
|
|
|
|
struct biquad2_state {
|
|
int32_t gain;
|
|
int32_t a1;
|
|
int32_t a2;
|
|
int32_t b1;
|
|
int32_t b2;
|
|
|
|
int32_t z1;
|
|
int32_t z2;
|
|
};
|
|
|
|
static inline void biquad2_init(struct biquad2_state *bq,
|
|
int32_t gain, int32_t a1, int32_t a2, int32_t b1, int32_t b2)
|
|
{
|
|
bq->gain = gain;
|
|
bq->a1 = a1;
|
|
bq->a2 = a2;
|
|
bq->b1 = b1;
|
|
bq->b2 = b2;
|
|
|
|
bq->z1 = 0;
|
|
bq->z2 = 0;
|
|
}
|
|
|
|
static inline int16_t biquad2(struct biquad2_state *bq, int16_t sample)
|
|
{
|
|
int32_t y;
|
|
int32_t z0;
|
|
|
|
z0 = sample * bq->gain + bq->z1 * bq->a1 + bq->z2 * bq->a2;
|
|
y = z0 + bq->z1 * bq->b1 + bq->z2 * bq->b2;
|
|
|
|
bq->z2 = bq->z1;
|
|
bq->z1 = z0 >> 15;
|
|
y >>= 15;
|
|
return y;
|
|
}
|