This source file includes following definitions.
- ff_iir_filter_flt_mips
- ff_iir_filter_init_mips
#include "libavcodec/iirfilter.h"
#if HAVE_INLINE_ASM
typedef struct FFIIRFilterCoeffs {
int order;
float gain;
int *cx;
float *cy;
} FFIIRFilterCoeffs;
typedef struct FFIIRFilterState {
float x[1];
} FFIIRFilterState;
static void ff_iir_filter_flt_mips(const struct FFIIRFilterCoeffs *c,
struct FFIIRFilterState *s, int size,
const float *src, int sstep, float *dst, int dstep)
{
if (c->order == 2) {
int i;
const float *src0 = src;
float *dst0 = dst;
for (i = 0; i < size; i++) {
float in = *src0 * c->gain + s->x[0] * c->cy[0] + s->x[1] * c->cy[1];
*dst0 = s->x[0] + in + s->x[1] * c->cx[1];
s->x[0] = s->x[1];
s->x[1] = in;
src0 += sstep;
dst0 += dstep;
}
} else if (c->order == 4) {
int i;
const float *src0 = src;
float *dst0 = dst;
float four = 4.0;
float six = 6.0;
for (i = 0; i < size; i += 4) {
float in1, in2, in3, in4;
float res1, res2, res3, res4;
float *x = s->x;
float *cy = c->cy;
float gain = c->gain;
float src0_0 = src0[0 ];
float src0_1 = src0[sstep ];
float src0_2 = src0[2*sstep];
float src0_3 = src0[3*sstep];
__asm__ volatile (
"lwc1 $f0, 0(%[cy]) \n\t"
"lwc1 $f4, 0(%[x]) \n\t"
"lwc1 $f5, 4(%[x]) \n\t"
"lwc1 $f6, 8(%[x]) \n\t"
"lwc1 $f7, 12(%[x]) \n\t"
"mul.s %[in1], %[src0_0], %[gain] \n\t"
"mul.s %[in2], %[src0_1], %[gain] \n\t"
"mul.s %[in3], %[src0_2], %[gain] \n\t"
"mul.s %[in4], %[src0_3], %[gain] \n\t"
"lwc1 $f1, 4(%[cy]) \n\t"
"madd.s %[in1], %[in1], $f0, $f4 \n\t"
"madd.s %[in2], %[in2], $f0, $f5 \n\t"
"madd.s %[in3], %[in3], $f0, $f6 \n\t"
"madd.s %[in4], %[in4], $f0, $f7 \n\t"
"lwc1 $f2, 8(%[cy]) \n\t"
"madd.s %[in1], %[in1], $f1, $f5 \n\t"
"madd.s %[in2], %[in2], $f1, $f6 \n\t"
"madd.s %[in3], %[in3], $f1, $f7 \n\t"
"lwc1 $f3, 12(%[cy]) \n\t"
"add.s $f8, $f5, $f7 \n\t"
"madd.s %[in1], %[in1], $f2, $f6 \n\t"
"madd.s %[in2], %[in2], $f2, $f7 \n\t"
"mul.s $f9, $f6, %[six] \n\t"
"mul.s $f10, $f7, %[six] \n\t"
"madd.s %[in1], %[in1], $f3, $f7 \n\t"
"madd.s %[in2], %[in2], $f3, %[in1] \n\t"
"madd.s %[in3], %[in3], $f2, %[in1] \n\t"
"madd.s %[in4], %[in4], $f1, %[in1] \n\t"
"add.s %[res1], $f4, %[in1] \n\t"
"swc1 %[in1], 0(%[x]) \n\t"
"add.s $f0, $f6, %[in1] \n\t"
"madd.s %[in3], %[in3], $f3, %[in2] \n\t"
"madd.s %[in4], %[in4], $f2, %[in2] \n\t"
"add.s %[res2], $f5, %[in2] \n\t"
"madd.s %[res1], %[res1], $f8, %[four] \n\t"
"add.s $f8, $f7, %[in2] \n\t"
"swc1 %[in2], 4(%[x]) \n\t"
"madd.s %[in4], %[in4], $f3, %[in3] \n\t"
"add.s %[res3], $f6, %[in3] \n\t"
"add.s %[res1], %[res1], $f9 \n\t"
"madd.s %[res2], %[res2], $f0, %[four] \n\t"
"swc1 %[in3], 8(%[x]) \n\t"
"add.s %[res4], $f7, %[in4] \n\t"
"madd.s %[res3], %[res3], $f8, %[four] \n\t"
"swc1 %[in4], 12(%[x]) \n\t"
"add.s %[res2], %[res2], $f10 \n\t"
"add.s $f8, %[in1], %[in3] \n\t"
"madd.s %[res3], %[res3], %[in1], %[six] \n\t"
"madd.s %[res4], %[res4], $f8, %[four] \n\t"
"madd.s %[res4], %[res4], %[in2], %[six] \n\t"
: [in1]"=&f"(in1), [in2]"=&f"(in2),
[in3]"=&f"(in3), [in4]"=&f"(in4),
[res1]"=&f"(res1), [res2]"=&f"(res2),
[res3]"=&f"(res3), [res4]"=&f"(res4)
: [src0_0]"f"(src0_0), [src0_1]"f"(src0_1),
[src0_2]"f"(src0_2), [src0_3]"f"(src0_3),
[gain]"f"(gain), [x]"r"(x), [cy]"r"(cy),
[four]"f"(four), [six]"f"(six)
: "$f0", "$f1", "$f2", "$f3",
"$f4", "$f5", "$f6", "$f7",
"$f8", "$f9", "$f10",
"memory"
);
dst0[0 ] = res1;
dst0[sstep ] = res2;
dst0[2*sstep] = res3;
dst0[3*sstep] = res4;
src0 += 4*sstep;
dst0 += 4*dstep;
}
} else {
int i;
const float *src0 = src;
float *dst0 = dst;
for (i = 0; i < size; i++) {
int j;
float in, res;
in = *src0 * c->gain;
for(j = 0; j < c->order; j++)
in += c->cy[j] * s->x[j];
res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1];
for(j = 1; j < c->order >> 1; j++)
res += (s->x[j] + s->x[c->order - j]) * c->cx[j];
for(j = 0; j < c->order - 1; j++)
s->x[j] = s->x[j + 1];
*dst0 = res;
s->x[c->order - 1] = in;
src0 += sstep;
dst0 += dstep;
}
}
}
#endif
void ff_iir_filter_init_mips(FFIIRFilterContext *f) {
#if HAVE_INLINE_ASM
f->filter_flt = ff_iir_filter_flt_mips;
#endif
}