/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1992-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <memory.h>
#include <stddef.h>
#include <Fir.h>
extern "C" {
char *bcopy(char *, char *, int);
char *memmove(char *, char *, int);
}
/*
* convolve()
* returns the convolution of coef[length] and in_buf[length]:
*
* convolution = coef[0] * in_buf[length - 1] +
* coef[1] * in_buf[length - 2] +
* ...
* coef[length - 1] * in_buf[0]
*/
double
double *coefs,
double *in_buf,
int length)
{
if (length <= 0)
return (0.0);
else {
while (length--)
return (sum);
}
}
void // convert short to double
double *out,
short *in,
int size)
{
while (size-- > 0)
}
short
{
if (in <= -32768.0)
return (-32768);
else if (in >= 32767.0)
return (32767);
else
return ((short)in);
}
void Fir:: // update state with data[size]
double *data,
int size)
{
else {
old * sizeof (double));
}
}
void Fir::
short *in,
int size)
{
delete in_buf;
}
void Fir::
{
for (int i = 0; i < order; i++)
state[i] = 0.0;
}
Fir::
Fir(void)
{
}
Fir::
{
resetState();
}
Fir::
~Fir() // destruct Fir object
{
delete coef;
delete state;
}
int Fir::
{
return (order);
}
int Fir::
{
return (order + 1);
}
void Fir::
{
}
void Fir::
{
}
int Fir:: // filter in[size], and updates the state.
short *in,
int size,
short *out)
{
if (size <= 0)
return (0);
int i;
// the first "order" outputs need state in convolution
for (i = 1; i <= init_size; i++)
// starting from "order + 1"th output, state is no longer needed
while (i++ <= size)
*out_ptr++ =
delete in_buf;
}
int Fir::
getFlushSize(void)
{
}
int Fir::
{
if (num > 0) {
delete in;
}
return (num);
}
/*
* filter() filters in[size] with filter delay adjusted to 0
*
* All FIR filters introduce a delay of "order" samples between input and
* output sequences. Most FIR filters are symmetric filters to keep the
* linear phase responses. For those FIR fitlers the group delay is
* "(order + 1) / 2". So filter_nodelay adjusts the group delay in the
* output sequence such that the output is aligned with the input and
* direct comparison between them is possible.
*
* The first call of filter returns "size - group_delay" output samples.
* After all the input samples have been filtered, filter() needs
* to be called with size = 0 to get the residual output samples to make
* the output sequence the same length as the input.
*
*/
int Fir::
short *in,
int size,
short *out)
{
else if (delay <= 0)
return (0);
} else {
delay = 0;
}
}