[pulseaudio-discuss] [PATCH 3/6 v3] core: Add stereo to mono special case remapping
Arun Raghavan
arun.raghavan at collabora.co.uk
Mon Oct 15 22:38:08 PDT 2012
On Tue, 2012-07-24 at 10:20 +0200, Peter Meerwald wrote:
> From: Peter Meerwald <p.meerwald at bct-electronic.com>
>
> add special-case C code for stereo-to-mone remapping
[...]
> +static void remap_stereo_to_mono_c(pa_remap_t *m, void *dst, const void *src, unsigned n) {
> + unsigned i;
> +
> + switch (*m->format) {
> + case PA_SAMPLE_FLOAT32NE:
> + {
> + float *d = (float *) dst, *s = (float *) src;
> +
> + for (i = n >> 2; i > 0; i--) {
> + d[0] = s[0] + s[1];
> + d[1] = s[2] + s[3];
> + d[2] = s[4] + s[5];
> + d[3] = s[6] + s[7];
> + s += 8;
> + d += 4;
> + }
> + for (i = n & 3; i; i--) {
Shouldn't this (and the next case) be (n & 2)?
> + d[0] = s[0] + s[1];
> + s += 2;
> + d += 1;
> + }
> + break;
> + }
> + case PA_SAMPLE_S16NE:
> + {
> + int16_t *d = (int16_t *) dst, *s = (int16_t *) src;
> +
> + for (i = n >> 2; i > 0; i--) {
> + *d++ += s[0] + s[1];
> + *d++ += s[2] + s[3];
> + *d++ += s[4] + s[5];
> + *d++ += s[6] + s[7];
> + s += 8;
> + }
Out of curiosity, is there a reason that you index d in the first case
and increment it in the second?
> + for (i = n & 3; i; i--) {
> + *d++ += s[0] + s[1];
> + s += 2;
> + }
> + break;
> + }
> + default:
> + pa_assert_not_reached();
> + }
> +}
Regards,
Arun
More information about the pulseaudio-discuss
mailing list