From 96c898c4a8f6d5033b1e2e9990817dcba4ee48f1 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 19 Nov 2010 12:23:03 +0000 Subject: [PATCH] optimize prologic inversion, it was really showing up in profiles git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10610 d7cf8633-e32d-0410-b094-e92efae38249 --- snd_mix.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/snd_mix.c b/snd_mix.c index 74a13671..9094ce6c 100644 --- a/snd_mix.c +++ b/snd_mix.c @@ -257,12 +257,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint, samples += 2; } } + else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1) + { + for (i = 0;i < count;i++) + { + paint[i].sample[0] += (samples[0] * vol[0]) >> 8; + paint[i].sample[1] -= (samples[1] * vol[1]) >> 8; + samples += 2; + } + } else if (vol[0] + vol[1] > 0) { for (i = 0;i < count;i++) { paint[i].sample[0] += (samples[0] * vol[0]) >> 8; - paint[i].sample[1] += (samples[1] * vol[1] * ch->prologic_invert) >> 8; + paint[i].sample[1] += (samples[1] * vol[1]) >> 8; samples += 2; } } @@ -308,12 +317,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint, samples += 1; } } + else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1) + { + for (i = 0;i < count;i++) + { + paint[i].sample[0] += (samples[0] * vol[0]) >> 8; + paint[i].sample[1] -= (samples[0] * vol[1]) >> 8; + samples += 1; + } + } else if (vol[0] + vol[1] > 0) { for (i = 0;i < count;i++) { paint[i].sample[0] += (samples[0] * vol[0]) >> 8; - paint[i].sample[1] += (samples[0] * vol[1] * ch->prologic_invert) >> 8; + paint[i].sample[1] += (samples[0] * vol[1]) >> 8; samples += 1; } } @@ -367,12 +385,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint, samples += 2; } } + else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1) + { + for (i = 0;i < count;i++) + { + paint[i].sample[0] += (samples[0] * vol[0]) >> 16; + paint[i].sample[1] -= (samples[1] * vol[1]) >> 16; + samples += 2; + } + } else if (vol[0] + vol[1] > 0) { for (i = 0;i < count;i++) { paint[i].sample[0] += (samples[0] * vol[0]) >> 16; - paint[i].sample[1] += (samples[1] * vol[1] * ch->prologic_invert) >> 16; + paint[i].sample[1] += (samples[1] * vol[1]) >> 16; samples += 2; } } @@ -418,12 +445,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint, samples += 1; } } + else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1) + { + for (i = 0;i < count;i++) + { + paint[i].sample[0] += (samples[0] * vol[0]) >> 16; + paint[i].sample[1] -= (samples[0] * vol[1]) >> 16; + samples += 1; + } + } else if (vol[0] + vol[1] > 0) { for (i = 0;i < count;i++) { paint[i].sample[0] += (samples[0] * vol[0]) >> 16; - paint[i].sample[1] += (samples[0] * vol[1] * ch->prologic_invert) >> 16; + paint[i].sample[1] += (samples[0] * vol[1]) >> 16; samples += 1; } } -- 2.39.2