avcodec/iirfilter: Move ff_iir_filter() to lavc/tests/iirfilter.c

It is only used by the test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-06-16 14:06:28 +02:00
parent 2330e77c97
commit 2902ed25b5
3 changed files with 16 additions and 30 deletions

View File

@ -277,20 +277,6 @@ av_cold struct FFIIRFilterState *ff_iir_filter_init_state(int order)
} \
}
void ff_iir_filter(const struct FFIIRFilterCoeffs *c,
struct FFIIRFilterState *s, int size,
const int16_t *src, ptrdiff_t sstep,
int16_t *dst, ptrdiff_t dstep)
{
if (c->order == 2) {
FILTER_O2(int16_t, S16)
} else if (c->order == 4) {
FILTER_BW_O4(int16_t, S16)
} else {
FILTER_DIRECT_FORM_II(int16_t, S16)
}
}
/**
* Perform IIR filtering on floating-point input samples.
*

View File

@ -28,7 +28,6 @@
#define AVCODEC_IIRFILTER_H
#include <stddef.h>
#include <stdint.h>
struct FFIIRFilterCoeffs;
struct FFIIRFilterState;
@ -114,18 +113,4 @@ void ff_iir_filter_free_coeffsp(struct FFIIRFilterCoeffs **coeffs);
*/
void ff_iir_filter_free_statep(struct FFIIRFilterState **state);
/**
* Perform IIR filtering on signed 16-bit input samples.
*
* @param coeffs pointer to filter coefficients
* @param state pointer to filter state
* @param size input length
* @param src source samples
* @param sstep source stride
* @param dst filtered samples (destination may be the same as input)
* @param dstep destination stride
*/
void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state,
int size, const int16_t *src, ptrdiff_t sstep, int16_t *dst, ptrdiff_t dstep);
#endif /* AVCODEC_IIRFILTER_H */

View File

@ -23,10 +23,25 @@
#include "libavutil/libm.h"
#include "libavcodec/iirfilter.h"
#include "libavcodec/iirfilter.c"
#define FILT_ORDER 4
#define SIZE 1024
static void iir_filter_int16(const struct FFIIRFilterCoeffs *c,
struct FFIIRFilterState *s, int size,
const int16_t *src, ptrdiff_t sstep,
int16_t *dst, ptrdiff_t dstep)
{
if (c->order == 2) {
FILTER_O2(int16_t, S16)
} else if (c->order == 4) {
FILTER_BW_O4(int16_t, S16)
} else {
FILTER_DIRECT_FORM_II(int16_t, S16)
}
}
int main(void)
{
struct FFIIRFilterCoeffs *fcoeffs = NULL;
@ -43,7 +58,7 @@ int main(void)
for (i = 0; i < SIZE; i++)
x[i] = lrint(0.75 * INT16_MAX * sin(0.5 * M_PI * i * i / SIZE));
ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1);
iir_filter_int16(fcoeffs, fstate, SIZE, x, 1, y, 1);
for (i = 0; i < SIZE; i++)
printf("%6d %6d\n", x[i], y[i]);