1 # This file is part of PulseAudio.
3 # Copyright 2010 Lennart Poettering
4 # Copyright 2010 Wim Taymans <wim.taymans@collabora.co.uk>
5 # Copyright 2010 Arun Raghavan <arun.raghavan@collabora.co.uk>
7 # PulseAudio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser General Public License as published
9 # by the Free Software Foundation; either version 2.1 of the License,
10 # or (at your option) any later version.
12 # PulseAudio is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with PulseAudio; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 # S16NE 1- and 2-channel volume scaling work as follows:
24 # params: samples s (signed 16-bit), volume v (signed 32-bit < 2^31)
26 # 32 16 0 (type of operation)
27 # sample = | sample | (signed)
28 # s = | 0 | sample | (unsigned)
31 # signc = | 0 | 0xffff | (unsigned)
33 # signc = | 0 | 0 | (unsgined)
36 # ml = | 0 | -((s*vl) >> 16) | (unsgined)
38 # ml = | 0 | (s*vl) >> 16 | (unsgined)
40 # vh = | v >> 16 | (signed, but value is always signed
41 # since PA_VOLUME_MAX is 0x0fffffff)
42 # mh = | (s * vh) >> 16 | (signed)
43 # ml = | ml + mh | (signed)
44 # sample = | (ml >> 16) | (signed, saturated)
46 .function pa_volume_s16ne_orc_1ch
47 .dest 2 samples int16_t
56 x2 cmpgtsw signc, 0, s
57 x2 andw signc, signc, v
61 mulswl mh, samples, vh
65 .function pa_volume_s16ne_orc_2ch
66 .dest 4 samples int16_t
77 x4 cmpgtsw signc, 0, s
78 x4 andw signc, signc, v
82 x2 mulswl mh, samples, vh
84 x2 convssslw samples, ml