Remove the 3-front-channel layout from the list of channel layout
[FFMpeg-mirror/lagarith.git] / libavcodec / celp_filters.c
blobb2094a164a66d885bdf1098e0a3bb71a3597887c
1 /*
2 * various filters for ACELP-based codecs
4 * Copyright (c) 2008 Vladimir Voroshilov
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <inttypes.h>
25 #include "avcodec.h"
26 #include "celp_filters.h"
28 void ff_celp_convolve_circ(
29 int16_t* fc_out,
30 const int16_t* fc_in,
31 const int16_t* filter,
32 int len)
34 int i, k;
36 memset(fc_out, 0, len * sizeof(int16_t));
38 /* Since there are few pulses over an entire subframe (i.e. almost
39 all fc_in[i] are zero) it is faster to loop over fc_in first. */
40 for(i=0; i<len; i++)
42 if(fc_in[i])
44 for(k=0; k<i; k++)
45 fc_out[k] += (fc_in[i] * filter[len + k - i]) >> 15;
47 for(k=i; k<len; k++)
48 fc_out[k] += (fc_in[i] * filter[ k - i]) >> 15;
53 int ff_celp_lp_synthesis_filter(
54 int16_t *out,
55 const int16_t* filter_coeffs,
56 const int16_t* in,
57 int buffer_length,
58 int filter_length,
59 int stop_on_overflow,
60 int rounder)
62 int i,n;
64 // Avoids a +1 in the inner loop.
65 filter_length++;
67 for(n=0; n<buffer_length; n++)
69 int sum = rounder;
70 for(i=1; i<filter_length; i++)
71 sum -= filter_coeffs[i-1] * out[n-i];
73 sum = (sum >> 12) + in[n];
75 if(sum + 0x8000 > 0xFFFFU)
77 if(stop_on_overflow)
78 return 1;
79 sum = (sum >> 31) ^ 32767;
81 out[n] = sum;
84 return 0;
87 void ff_celp_lp_synthesis_filterf(
88 float *out,
89 const float* filter_coeffs,
90 const float* in,
91 int buffer_length,
92 int filter_length)
94 int i,n;
96 // Avoids a +1 in the inner loop.
97 filter_length++;
99 for(n=0; n<buffer_length; n++)
101 out[n] = in[n];
102 for(i=1; i<filter_length; i++)
103 out[n] -= filter_coeffs[i-1] * out[n-i];
107 void ff_celp_lp_zero_synthesis_filterf(
108 float *out,
109 const float* filter_coeffs,
110 const float* in,
111 int buffer_length,
112 int filter_length)
114 int i,n;
116 // Avoids a +1 in the inner loop.
117 filter_length++;
119 for(n=0; n<buffer_length; n++)
121 out[n] = in[n];
122 for(i=1; i<filter_length; i++)
123 out[n] -= filter_coeffs[i-1] * in[n-i];