Go to the documentation of this file.
36 memset(fc_out, 0,
len *
sizeof(int16_t));
40 for (
i = 0;
i <
len;
i++) {
42 for (k = 0; k <
i; k++)
43 fc_out[k] += (fc_in[
i] *
filter[
len + k -
i]) >> 15;
45 for (k =
i; k <
len; k++)
46 fc_out[k] += (fc_in[
i] *
filter[ k -
i]) >> 15;
52 const float *lagged,
int lag,
float fac,
int n)
55 for (k = 0; k < lag; k++)
56 out[k] = in[k] + fac * lagged[n + k - lag];
58 out[k] = in[k] + fac * lagged[ k - lag];
62 const int16_t *in,
int buffer_length,
63 int filter_length,
int stop_on_overflow,
64 int shift,
int rounder)
68 for (n = 0; n < buffer_length; n++) {
69 int sum = rounder, sum1;
70 for (
i = 1;
i <= filter_length;
i++)
71 sum -= (
unsigned)(filter_coeffs[
i-1] *
out[n-
i]);
73 sum1 = ((sum >> 12) + in[n]) >>
shift;
76 if (stop_on_overflow && sum != sum1)
86 const float* in,
int buffer_length,
91 #if 0 // Unoptimized code path for improved readability
92 for (n = 0; n < buffer_length; n++) {
94 for (
i = 1;
i <= filter_length;
i++)
95 out[n] -= filter_coeffs[
i-1] *
out[n-
i];
98 float out0, out1, out2, out3;
99 float old_out0, old_out1, old_out2, old_out3;
102 a = filter_coeffs[0];
103 b = filter_coeffs[1];
104 c = filter_coeffs[2];
105 b -= filter_coeffs[0] * filter_coeffs[0];
106 c -= filter_coeffs[1] * filter_coeffs[0];
107 c -= filter_coeffs[0] *
b;
109 av_assert2((filter_length&1)==0 && filter_length>=4);
115 for (n = 0; n <= buffer_length - 4; n+=4) {
116 float tmp0,tmp1,tmp2;
124 out0 -= filter_coeffs[2] * old_out1;
125 out1 -= filter_coeffs[2] * old_out2;
126 out2 -= filter_coeffs[2] * old_out3;
128 out0 -= filter_coeffs[1] * old_out2;
129 out1 -= filter_coeffs[1] * old_out3;
131 out0 -= filter_coeffs[0] * old_out3;
133 val = filter_coeffs[3];
135 out0 -=
val * old_out0;
136 out1 -=
val * old_out1;
137 out2 -=
val * old_out2;
138 out3 -=
val * old_out3;
140 for (
i = 5;
i < filter_length;
i += 2) {
142 val = filter_coeffs[
i-1];
144 out0 -=
val * old_out3;
145 out1 -=
val * old_out0;
146 out2 -=
val * old_out1;
147 out3 -=
val * old_out2;
149 old_out2 =
out[-
i-1];
151 val = filter_coeffs[
i];
153 out0 -=
val * old_out2;
154 out1 -=
val * old_out3;
155 out2 -=
val * old_out0;
156 out3 -=
val * old_out1;
158 FFSWAP(
float, old_out0, old_out2);
192 for (; n < buffer_length; n++) {
194 for (
i = 1;
i <= filter_length;
i++)
195 out[n] -= filter_coeffs[
i-1] *
out[n-
i];
201 const float *in,
int buffer_length,
206 for (n = 0; n < buffer_length; n++) {
208 for (
i = 1;
i <= filter_length;
i++)
209 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.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
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
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
void ff_celp_filter_init(CELPFContext *c)
Initialize CELPFContext.
#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)
static int shift(int a, int b)