X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sound%2Fcore%2Foss%2Frate.c;h=14dfb3175d84548f9ef1ccdcde84517cb137a635;hb=HEAD;hp=4854cef6fb4f69014c910eedeee9177810cec7ca;hpb=f9c5d0451b406a6bd0d0bf1fdd63c7777af6ebc6;p=linux-2.6 diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c index 4854cef6fb..14dfb3175d 100644 --- a/sound/core/oss/rate.c +++ b/sound/core/oss/rate.c @@ -1,6 +1,6 @@ /* * Rate conversion Plug-In - * Copyright (c) 1999 by Jaroslav Kysela + * Copyright (c) 1999 by Jaroslav Kysela * * * This library is free software; you can redistribute it and/or modify @@ -19,7 +19,6 @@ * */ -#include #include #include #include @@ -47,7 +46,6 @@ struct rate_priv { unsigned int pitch; unsigned int pos; rate_f func; - int get, put; snd_pcm_sframes_t old_src_frames, old_dst_frames; struct rate_channel channels[0]; }; @@ -71,21 +69,12 @@ static void resample_expand(struct snd_pcm_plugin *plugin, unsigned int pos = 0; signed int val; signed short S1, S2; - char *src, *dst; + signed short *src, *dst; unsigned int channel; int src_step, dst_step; int src_frames1, dst_frames1; struct rate_priv *data = (struct rate_priv *)plugin->extra_data; struct rate_channel *rchannels = data->channels; - -#define GET_S16_LABELS -#define PUT_S16_LABELS -#include "plugin_ops.h" -#undef GET_S16_LABELS -#undef PUT_S16_LABELS - void *get = get_s16_labels[data->get]; - void *put = put_s16_labels[data->put]; - signed short sample = 0; for (channel = 0; channel < plugin->src_format.channels; channel++) { pos = data->pos; @@ -98,10 +87,12 @@ static void resample_expand(struct snd_pcm_plugin *plugin, continue; } dst_channels[channel].enabled = 1; - src = (char *)src_channels[channel].area.addr + src_channels[channel].area.first / 8; - dst = (char *)dst_channels[channel].area.addr + dst_channels[channel].area.first / 8; - src_step = src_channels[channel].area.step / 8; - dst_step = dst_channels[channel].area.step / 8; + src = (signed short *)src_channels[channel].area.addr + + src_channels[channel].area.first / 8 / 2; + dst = (signed short *)dst_channels[channel].area.addr + + dst_channels[channel].area.first / 8 / 2; + src_step = src_channels[channel].area.step / 8 / 2; + dst_step = dst_channels[channel].area.step / 8 / 2; src_frames1 = src_frames; dst_frames1 = dst_frames; while (dst_frames1-- > 0) { @@ -109,12 +100,7 @@ static void resample_expand(struct snd_pcm_plugin *plugin, pos &= R_MASK; S1 = S2; if (src_frames1-- > 0) { - goto *get; -#define GET_S16_END after_get -#include "plugin_ops.h" -#undef GET_S16_END - after_get: - S2 = sample; + S2 = *src; src += src_step; } } @@ -123,12 +109,7 @@ static void resample_expand(struct snd_pcm_plugin *plugin, val = -32768; else if (val > 32767) val = 32767; - sample = val; - goto *put; -#define PUT_S16_END after_put -#include "plugin_ops.h" -#undef PUT_S16_END - after_put: + *dst = val; dst += dst_step; pos += data->pitch; } @@ -147,21 +128,12 @@ static void resample_shrink(struct snd_pcm_plugin *plugin, unsigned int pos = 0; signed int val; signed short S1, S2; - char *src, *dst; + signed short *src, *dst; unsigned int channel; int src_step, dst_step; int src_frames1, dst_frames1; struct rate_priv *data = (struct rate_priv *)plugin->extra_data; struct rate_channel *rchannels = data->channels; - -#define GET_S16_LABELS -#define PUT_S16_LABELS -#include "plugin_ops.h" -#undef GET_S16_LABELS -#undef PUT_S16_LABELS - void *get = get_s16_labels[data->get]; - void *put = put_s16_labels[data->put]; - signed short sample = 0; for (channel = 0; channel < plugin->src_format.channels; ++channel) { pos = data->pos; @@ -174,21 +146,18 @@ static void resample_shrink(struct snd_pcm_plugin *plugin, continue; } dst_channels[channel].enabled = 1; - src = (char *)src_channels[channel].area.addr + src_channels[channel].area.first / 8; - dst = (char *)dst_channels[channel].area.addr + dst_channels[channel].area.first / 8; - src_step = src_channels[channel].area.step / 8; - dst_step = dst_channels[channel].area.step / 8; + src = (signed short *)src_channels[channel].area.addr + + src_channels[channel].area.first / 8 / 2; + dst = (signed short *)dst_channels[channel].area.addr + + dst_channels[channel].area.first / 8 / 2; + src_step = src_channels[channel].area.step / 8 / 2; + dst_step = dst_channels[channel].area.step / 8 / 2; src_frames1 = src_frames; dst_frames1 = dst_frames; while (dst_frames1 > 0) { S1 = S2; if (src_frames1-- > 0) { - goto *get; -#define GET_S16_END after_get -#include "plugin_ops.h" -#undef GET_S16_END - after_get: - S2 = sample; + S1 = *src; src += src_step; } if (pos & ~R_MASK) { @@ -198,12 +167,7 @@ static void resample_shrink(struct snd_pcm_plugin *plugin, val = -32768; else if (val > 32767) val = 32767; - sample = val; - goto *put; -#define PUT_S16_END after_put -#include "plugin_ops.h" -#undef PUT_S16_END - after_put: + *dst = val; dst += dst_step; dst_frames1--; } @@ -343,8 +307,8 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug, snd_assert(src_format->channels == dst_format->channels, return -ENXIO); snd_assert(src_format->channels > 0, return -ENXIO); - snd_assert(snd_pcm_format_linear(src_format->format) != 0, return -ENXIO); - snd_assert(snd_pcm_format_linear(dst_format->format) != 0, return -ENXIO); + snd_assert(src_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); + snd_assert(dst_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); snd_assert(src_format->rate != dst_format->rate, return -ENXIO); err = snd_pcm_plugin_build(plug, "rate conversion", @@ -355,11 +319,6 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug, if (err < 0) return err; data = (struct rate_priv *)plugin->extra_data; - data->get = getput_index(src_format->format); - snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL); - data->put = getput_index(dst_format->format); - snd_assert(data->put >= 0 && data->put < 4*2*2, return -EINVAL); - if (src_format->rate < dst_format->rate) { data->pitch = ((src_format->rate << SHIFT) + (dst_format->rate >> 1)) / dst_format->rate; data->func = resample_expand;