Go to the documentation of this file.
37 memset(fc_out, 0,
len *
sizeof(int16_t));
41 for (
i = 0;
i <
len;
i++) {
43 for (k = 0; k <
i; k++)
44 fc_out[k] += (fc_in[
i] *
filter[
len + k -
i]) >> 15;
46 for (k =
i; k <
len; k++)
47 fc_out[k] += (fc_in[
i] *
filter[ k -
i]) >> 15;
53 const float *lagged,
int lag,
float fac,
int n)
56 for (k = 0; k < lag; k++)
57 out[k] = in[k] + fac * lagged[n + k - lag];
59 out[k] = in[k] + fac * lagged[ k - lag];
63 const int16_t *in,
int buffer_length,
64 int filter_length,
int stop_on_overflow,
65 int shift,
int rounder)
69 for (n = 0; n < buffer_length; n++) {
70 int sum = rounder, sum1;
71 for (
i = 1;
i <= filter_length;
i++)
72 sum -= (
unsigned)(filter_coeffs[
i-1] *
out[n-
i]);
74 sum1 = ((sum >> 12) + in[n]) >>
shift;
77 if (stop_on_overflow && sum != sum1)
87 const float* in,
int buffer_length,
92 #if 0 // Unoptimized code path for improved readability
93 for (n = 0; n < buffer_length; n++) {
95 for (
i = 1;
i <= filter_length;
i++)
96 out[n] -= filter_coeffs[
i-1] *
out[n-
i];
99 float out0, out1, out2, out3;
100 float old_out0, old_out1, old_out2, old_out3;
103 a = filter_coeffs[0];
104 b = filter_coeffs[1];
105 c = filter_coeffs[2];
106 b -= filter_coeffs[0] * filter_coeffs[0];
107 c -= filter_coeffs[1] * filter_coeffs[0];
108 c -= filter_coeffs[0] *
b;
110 av_assert2((filter_length&1)==0 && filter_length>=4);
116 for (n = 0; n <= buffer_length - 4; n+=4) {
117 float tmp0,tmp1,tmp2;
125 out0 -= filter_coeffs[2] * old_out1;
126 out1 -= filter_coeffs[2] * old_out2;
127 out2 -= filter_coeffs[2] * old_out3;
129 out0 -= filter_coeffs[1] * old_out2;
130 out1 -= filter_coeffs[1] * old_out3;
132 out0 -= filter_coeffs[0] * old_out3;
134 val = filter_coeffs[3];
136 out0 -=
val * old_out0;
137 out1 -=
val * old_out1;
138 out2 -=
val * old_out2;
139 out3 -=
val * old_out3;
141 for (
i = 5;
i < filter_length;
i += 2) {
143 val = filter_coeffs[
i-1];
145 out0 -=
val * old_out3;
146 out1 -=
val * old_out0;
147 out2 -=
val * old_out1;
148 out3 -=
val * old_out2;
150 old_out2 =
out[-
i-1];
152 val = filter_coeffs[
i];
154 out0 -=
val * old_out2;
155 out1 -=
val * old_out3;
156 out2 -=
val * old_out0;
157 out3 -=
val * old_out1;
159 FFSWAP(
float, old_out0, old_out2);
193 for (; n < buffer_length; n++) {
195 for (
i = 1;
i <= filter_length;
i++)
196 out[n] -= filter_coeffs[
i-1] *
out[n-
i];
202 const float *in,
int buffer_length,
207 for (n = 0; n < buffer_length; n++) {
209 for (
i = 1;
i <= filter_length;
i++)
210 out[n] += filter_coeffs[
i-1] * in[n-
i];
int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, const int16_t *in, int buffer_length, int filter_length, int stop_on_overflow, int shift, int rounder)
LP synthesis filter.
void(* filter)(uint8_t *src, int stride, int qscale)
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
void av_cold ff_celp_filter_init(CELPFContext *c)
Initialize CELPFContext.
static double val(void *priv, double ch)
void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in, const int16_t *filter, int len)
Circularly convolve fixed vector with a phase dispersion impulse response filter (D....
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int shift(int a, int b)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define i(width, name, range_min, range_max)
#define FFSWAP(type, a, b)
void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP zero synthesis filter.
void ff_celp_circ_addf(float *out, const float *in, const float *lagged, int lag, float fac, int n)
Add an array to a rotated array.
void ff_celp_filter_init_mips(CELPFContext *c)