daemon: add nice value in service file to improve performance
[platform/upstream/pulseaudio.git] / 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, see <http://www.gnu.org/licenses/>.
19
20 # S16NE 1- and 2-channel volume scaling work as follows:
21 #
22 #     params: samples s (signed 16-bit), volume v (signed 32-bit < 2^31)
23 #
24 #                  32           16                 0 (type of operation)
25 #         sample =               |      sample     | (signed)
26 #              s = |      0      |      sample     | (unsigned)
27 #
28 #     if (sample < 0)
29 #          signc = |      0      |      0xffff     | (unsigned)
30 #     else
31 #          signc = |      0      |        0        | (unsigned)
32 #
33 #     if (sample < 0)
34 #             ml = |      0      | -((s*vl) >> 16) | (unsigned)
35 #     else
36 #             ml = |      0      |   (s*vl) >> 16  | (unsigned)
37 #
38 #             vh =               |      v >> 16    | (signed, but sign bit is always zero
39 #                                                     since PA_VOLUME_MAX is 0x0fffffff)
40 #             mh = |         (s * vh) >> 16        | (signed)
41 #             ml = |           ml + mh             | (signed)
42 #         sample =               |    (ml >> 16)   | (signed, saturated)
43
44 .function pa_volume_s16ne_orc_1ch
45 .dest 2 samples int16_t
46 .param 4 vols int32_t
47 .temp 4 v
48 .temp 2 vh
49 .temp 4 s
50 .temp 4 mh
51 .temp 4 ml
52 .temp 4 signc
53
54 loadpl v, vols
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