[vlc-commits] Deal with saturation correctly for S16N volume
Rémi Denis-Courmont
git at videolan.org
Mon Sep 26 22:57:49 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Sep 26 23:55:52 2011 +0300| [44207900df2418b2ac4d05f1cc9624ea36e46f4b] | committer: Rémi Denis-Courmont
Deal with saturation correctly for S16N volume
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=44207900df2418b2ac4d05f1cc9624ea36e46f4b
---
modules/audio_mixer/fixed32.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/modules/audio_mixer/fixed32.c b/modules/audio_mixer/fixed32.c
index ee50d6f..7a9c875 100644
--- a/modules/audio_mixer/fixed32.c
+++ b/modules/audio_mixer/fixed32.c
@@ -78,17 +78,31 @@ static void FilterFI32 (audio_mixer_t *mixer, block_t *block, float volume)
static void FilterS16N (audio_mixer_t *mixer, block_t *block, float volume)
{
- const int32_t mult = volume * 0x10000;
+ int32_t mult = volume * 0x1.p16;
if (mult == 0x10000)
return;
int16_t *p = (int16_t *)block->p_buffer;
- for (size_t n = block->i_buffer / sizeof (*p); n > 0; n--)
+ if (mult < 0x10000)
{
- *p = (*p * mult) >> 16;
- p++;
+ for (size_t n = block->i_buffer / sizeof (*p); n > 0; n--)
+ {
+ *p = (*p * mult) >> 16;
+ p++;
+ }
+ }
+ else
+ {
+ mult >>= 4;
+ for (size_t n = block->i_buffer / sizeof (*p); n > 0; n--)
+ {
+ int32_t v = (*p * mult) >> 12;
+ if (abs (v) > 0x7fff)
+ v = 0x8000;
+ *(p++) = v;
+ }
}
(void) mixer;
More information about the vlc-commits
mailing list