Lines Matching +full:8 +full:- +full:channel
2 * Rate conversion Plug-In
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define R_MASK (BITS-1)
55 unsigned int channel; in rate_init() local
56 struct rate_priv *data = (struct rate_priv *)plugin->extra_data; in rate_init()
57 data->pos = 0; in rate_init()
58 for (channel = 0; channel < plugin->src_format.channels; channel++) { in rate_init()
59 data->channels[channel].last_S1 = 0; in rate_init()
60 data->channels[channel].last_S2 = 0; in rate_init()
73 unsigned int channel; in resample_expand() local
76 struct rate_priv *data = (struct rate_priv *)plugin->extra_data; in resample_expand()
77 struct rate_channel *rchannels = data->channels; in resample_expand()
79 for (channel = 0; channel < plugin->src_format.channels; channel++) { in resample_expand()
80 pos = data->pos; in resample_expand()
81 S1 = rchannels->last_S1; in resample_expand()
82 S2 = rchannels->last_S2; in resample_expand()
83 if (!src_channels[channel].enabled) { in resample_expand()
84 if (dst_channels[channel].wanted) in resample_expand()
85 snd_pcm_area_silence(&dst_channels[channel].area, 0, dst_frames, plugin->dst_format.format); in resample_expand()
86 dst_channels[channel].enabled = 0; in resample_expand()
89 dst_channels[channel].enabled = 1; in resample_expand()
90 src = (signed short *)src_channels[channel].area.addr + in resample_expand()
91 src_channels[channel].area.first / 8 / 2; in resample_expand()
92 dst = (signed short *)dst_channels[channel].area.addr + in resample_expand()
93 dst_channels[channel].area.first / 8 / 2; in resample_expand()
94 src_step = src_channels[channel].area.step / 8 / 2; in resample_expand()
95 dst_step = dst_channels[channel].area.step / 8 / 2; in resample_expand()
98 while (dst_frames1-- > 0) { in resample_expand()
102 if (src_frames1-- > 0) { in resample_expand()
107 val = S1 + ((S2 - S1) * (signed int)pos) / BITS; in resample_expand()
108 if (val < -32768) in resample_expand()
109 val = -32768; in resample_expand()
114 pos += data->pitch; in resample_expand()
116 rchannels->last_S1 = S1; in resample_expand()
117 rchannels->last_S2 = S2; in resample_expand()
120 data->pos = pos; in resample_expand()
132 unsigned int channel; in resample_shrink() local
135 struct rate_priv *data = (struct rate_priv *)plugin->extra_data; in resample_shrink()
136 struct rate_channel *rchannels = data->channels; in resample_shrink()
138 for (channel = 0; channel < plugin->src_format.channels; ++channel) { in resample_shrink()
139 pos = data->pos; in resample_shrink()
140 S1 = rchannels->last_S1; in resample_shrink()
141 S2 = rchannels->last_S2; in resample_shrink()
142 if (!src_channels[channel].enabled) { in resample_shrink()
143 if (dst_channels[channel].wanted) in resample_shrink()
144 snd_pcm_area_silence(&dst_channels[channel].area, 0, dst_frames, plugin->dst_format.format); in resample_shrink()
145 dst_channels[channel].enabled = 0; in resample_shrink()
148 dst_channels[channel].enabled = 1; in resample_shrink()
149 src = (signed short *)src_channels[channel].area.addr + in resample_shrink()
150 src_channels[channel].area.first / 8 / 2; in resample_shrink()
151 dst = (signed short *)dst_channels[channel].area.addr + in resample_shrink()
152 dst_channels[channel].area.first / 8 / 2; in resample_shrink()
153 src_step = src_channels[channel].area.step / 8 / 2; in resample_shrink()
154 dst_step = dst_channels[channel].area.step / 8 / 2; in resample_shrink()
159 if (src_frames1-- > 0) { in resample_shrink()
165 val = S1 + ((S2 - S1) * (signed int)pos) / BITS; in resample_shrink()
166 if (val < -32768) in resample_shrink()
167 val = -32768; in resample_shrink()
172 dst_frames1--; in resample_shrink()
174 pos += data->pitch; in resample_shrink()
176 rchannels->last_S1 = S1; in resample_shrink()
177 rchannels->last_S2 = S2; in resample_shrink()
180 data->pos = pos; in resample_shrink()
189 return -ENXIO; in rate_src_frames()
192 data = (struct rate_priv *)plugin->extra_data; in rate_src_frames()
193 if (plugin->src_format.rate < plugin->dst_format.rate) { in rate_src_frames()
194 res = (((frames * data->pitch) + (BITS/2)) >> SHIFT); in rate_src_frames()
196 res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch); in rate_src_frames()
198 if (data->old_src_frames > 0) { in rate_src_frames()
199 snd_pcm_sframes_t frames1 = frames, res1 = data->old_dst_frames; in rate_src_frames()
200 while (data->old_src_frames < frames1) { in rate_src_frames()
204 while (data->old_src_frames > frames1) { in rate_src_frames()
208 if (data->old_src_frames == frames1) in rate_src_frames()
211 data->old_src_frames = frames; in rate_src_frames()
212 data->old_dst_frames = res; in rate_src_frames()
222 return -ENXIO; in rate_dst_frames()
225 data = (struct rate_priv *)plugin->extra_data; in rate_dst_frames()
226 if (plugin->src_format.rate < plugin->dst_format.rate) { in rate_dst_frames()
227 res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch); in rate_dst_frames()
229 res = (((frames * data->pitch) + (BITS/2)) >> SHIFT); in rate_dst_frames()
231 if (data->old_dst_frames > 0) { in rate_dst_frames()
232 snd_pcm_sframes_t frames1 = frames, res1 = data->old_src_frames; in rate_dst_frames()
233 while (data->old_dst_frames < frames1) { in rate_dst_frames()
237 while (data->old_dst_frames > frames1) { in rate_dst_frames()
241 if (data->old_dst_frames == frames1) in rate_dst_frames()
244 data->old_dst_frames = frames; in rate_dst_frames()
245 data->old_src_frames = res; in rate_dst_frames()
258 return -ENXIO; in rate_transfer()
263 unsigned int channel; in rate_transfer() local
264 for (channel = 0; channel < plugin->src_format.channels; channel++) { in rate_transfer()
265 if (snd_BUG_ON(src_channels[channel].area.first % 8 || in rate_transfer()
266 src_channels[channel].area.step % 8)) in rate_transfer()
267 return -ENXIO; in rate_transfer()
268 if (snd_BUG_ON(dst_channels[channel].area.first % 8 || in rate_transfer()
269 dst_channels[channel].area.step % 8)) in rate_transfer()
270 return -ENXIO; in rate_transfer()
278 data = (struct rate_priv *)plugin->extra_data; in rate_transfer()
279 data->func(plugin, src_channels, dst_channels, frames, dst_frames); in rate_transfer()
288 return -ENXIO; in rate_action()
310 return -ENXIO; in snd_pcm_plugin_build_rate()
313 if (snd_BUG_ON(src_format->channels != dst_format->channels)) in snd_pcm_plugin_build_rate()
314 return -ENXIO; in snd_pcm_plugin_build_rate()
315 if (snd_BUG_ON(src_format->channels <= 0)) in snd_pcm_plugin_build_rate()
316 return -ENXIO; in snd_pcm_plugin_build_rate()
317 if (snd_BUG_ON(src_format->format != SNDRV_PCM_FORMAT_S16)) in snd_pcm_plugin_build_rate()
318 return -ENXIO; in snd_pcm_plugin_build_rate()
319 if (snd_BUG_ON(dst_format->format != SNDRV_PCM_FORMAT_S16)) in snd_pcm_plugin_build_rate()
320 return -ENXIO; in snd_pcm_plugin_build_rate()
321 if (snd_BUG_ON(src_format->rate == dst_format->rate)) in snd_pcm_plugin_build_rate()
322 return -ENXIO; in snd_pcm_plugin_build_rate()
327 src_format->channels), in snd_pcm_plugin_build_rate()
331 data = (struct rate_priv *)plugin->extra_data; in snd_pcm_plugin_build_rate()
332 if (src_format->rate < dst_format->rate) { in snd_pcm_plugin_build_rate()
333 data->pitch = ((src_format->rate << SHIFT) + (dst_format->rate >> 1)) / dst_format->rate; in snd_pcm_plugin_build_rate()
334 data->func = resample_expand; in snd_pcm_plugin_build_rate()
336 data->pitch = ((dst_format->rate << SHIFT) + (src_format->rate >> 1)) / src_format->rate; in snd_pcm_plugin_build_rate()
337 data->func = resample_shrink; in snd_pcm_plugin_build_rate()
339 data->pos = 0; in snd_pcm_plugin_build_rate()
341 data->old_src_frames = data->old_dst_frames = 0; in snd_pcm_plugin_build_rate()
342 plugin->transfer = rate_transfer; in snd_pcm_plugin_build_rate()
343 plugin->src_frames = rate_src_frames; in snd_pcm_plugin_build_rate()
344 plugin->dst_frames = rate_dst_frames; in snd_pcm_plugin_build_rate()
345 plugin->action = rate_action; in snd_pcm_plugin_build_rate()