]> code.delx.au - pulseaudio/blob - src/pulsecore/svolume.orc
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / svolume.orc
1 # This file is part of PulseAudio.
2 #
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>
6 #
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.
11 #
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.
16 #
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
20 # USA.
21
22 # S16NE 1- and 2-channel volume scaling work as follows:
23 #
24 # params: samples s (signed 16-bit), volume v (signed 32-bit < 2^31)
25 #
26 # 32 16 0 (type of operation)
27 # sample = | sample | (signed)
28 # s = | 0 | sample | (unsigned)
29 #
30 # if (sample < 0)
31 # signc = | 0 | 0xffff | (unsigned)
32 # else
33 # signc = | 0 | 0 | (unsigned)
34 #
35 # if (sample < 0)
36 # ml = | 0 | -((s*vl) >> 16) | (unsigned)
37 # else
38 # ml = | 0 | (s*vl) >> 16 | (unsigned)
39 #
40 # vh = | v >> 16 | (signed, but sign bit is always zero
41 # since PA_VOLUME_MAX is 0x0fffffff)
42 # mh = | (s * vh) >> 16 | (signed)
43 # ml = | ml + mh | (signed)
44 # sample = | (ml >> 16) | (signed, saturated)
45
46 .function pa_volume_s16ne_orc_1ch
47 .dest 2 samples int16_t
48 .param 4 v int32_t
49 .temp 2 vh
50 .temp 4 s
51 .temp 4 mh
52 .temp 4 ml
53 .temp 4 signc
54
55 convuwl s, samples
56 x2 cmpgtsw signc, 0, s
57 x2 andw signc, signc, v
58 x2 mulhuw ml, s, v
59 subl ml, ml, signc
60 convhlw vh, v
61 mulswl mh, samples, vh
62 addl ml, ml, mh
63 convssslw samples, ml
64
65 .function pa_volume_s16ne_orc_2ch
66 .dest 4 samples int16_t
67 .longparam 8 vols
68 .temp 8 v
69 .temp 4 vh
70 .temp 8 s
71 .temp 8 mh
72 .temp 8 ml
73 .temp 8 signc
74
75 loadpq v, vols
76 x2 convuwl s, samples
77 x4 cmpgtsw signc, 0, s
78 x4 andw signc, signc, v
79 x4 mulhuw ml, s, v
80 x2 subl ml, ml, signc
81 x2 convhlw vh, v
82 x2 mulswl mh, samples, vh
83 x2 addl ml, ml, mh
84 x2 convssslw samples, ml