1 /***
2 This file is part of PulseAudio.
3
4 Copyright 2004-2006 Lennart Poettering
5 Copyright 2009 Wim Taymans <wim.taymans@collabora.co.uk>
6 Copyright 2010 Arun Raghavan <arun.raghavan@collabora.co.uk>
7
8 PulseAudio is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published
10 by the Free Software Foundation; either version 2.1 of the License,
11 or (at your option) any later version.
12
13 PulseAudio is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "cpu-orc.h"
27 #include <pulse/rtclock.h>
28 #include <pulsecore/sample-util.h>
29 #include <pulsecore/random.h>
30 #include <pulsecore/svolume-orc-gen.h>
31
32 pa_do_volume_func_t fallback;
33
34 static void
pa_volume_s16ne_orc(int16_t * samples,const int32_t * volumes,unsigned channels,unsigned length)35 pa_volume_s16ne_orc(int16_t *samples, const int32_t *volumes, unsigned channels, unsigned length) {
36 if (channels == 2) {
37 int64_t v = (int64_t)volumes[1] << 32 | volumes[0];
38 pa_volume_s16ne_orc_2ch (samples, v, ((length / (sizeof(int16_t))) / 2));
39 } else if (channels == 1)
40 pa_volume_s16ne_orc_1ch (samples, volumes[0], length / (sizeof(int16_t)));
41 else
42 fallback(samples, volumes, channels, length);
43 }
44
pa_volume_func_init_orc(void)45 void pa_volume_func_init_orc(void) {
46 pa_log_info("Initialising ORC optimized volume functions.");
47
48 fallback = pa_get_volume_func(PA_SAMPLE_S16NE);
49 pa_set_volume_func(PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_orc);
50 }
51