Add some more device properties to the sink properties list
[pulseaudio-mirror.git] / src / modules / bt-sbc_math.h
blobb3d87a62ae81403a66b4e827fd809e3d6b10aa6a
1 /*
3 * Bluetooth low-complexity, subband codec (SBC) library
5 * Copyright (C) 2004-2008 Marcel Holtmann <marcel@holtmann.org>
6 * Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
7 * Copyright (C) 2005-2008 Brad Midgley <bmidgley@xmission.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #define fabs(x) ((x) < 0 ? -(x) : (x))
27 /* C does not provide an explicit arithmetic shift right but this will
28 always be correct and every compiler *should* generate optimal code */
29 #define ASR(val, bits) ((-2 >> 1 == -1) ? \
30 ((int32_t)(val)) >> (bits) : ((int32_t) (val)) / (1 << (bits)))
32 #define SCALE_PROTO4_TBL 15
33 #define SCALE_ANA4_TBL 17
34 #define SCALE_PROTO8_TBL 16
35 #define SCALE_ANA8_TBL 17
36 #define SCALE_SPROTO4_TBL 12
37 #define SCALE_SPROTO8_TBL 14
38 #define SCALE_NPROTO4_TBL 11
39 #define SCALE_NPROTO8_TBL 11
40 #define SCALE4_STAGE1_BITS 15
41 #define SCALE4_STAGE2_BITS 16
42 #define SCALE4_STAGED1_BITS 15
43 #define SCALE4_STAGED2_BITS 16
44 #define SCALE8_STAGE1_BITS 15
45 #define SCALE8_STAGE2_BITS 15
46 #define SCALE8_STAGED1_BITS 15
47 #define SCALE8_STAGED2_BITS 16
49 typedef int32_t sbc_fixed_t;
51 #define SCALE4_STAGE1(src) ASR(src, SCALE4_STAGE1_BITS)
52 #define SCALE4_STAGE2(src) ASR(src, SCALE4_STAGE2_BITS)
53 #define SCALE4_STAGED1(src) ASR(src, SCALE4_STAGED1_BITS)
54 #define SCALE4_STAGED2(src) ASR(src, SCALE4_STAGED2_BITS)
55 #define SCALE8_STAGE1(src) ASR(src, SCALE8_STAGE1_BITS)
56 #define SCALE8_STAGE2(src) ASR(src, SCALE8_STAGE2_BITS)
57 #define SCALE8_STAGED1(src) ASR(src, SCALE8_STAGED1_BITS)
58 #define SCALE8_STAGED2(src) ASR(src, SCALE8_STAGED2_BITS)
60 #define SBC_FIXED_0(val) { val = 0; }
61 #define MUL(a, b) ((a) * (b))
62 #ifdef __arm__
63 #define MULA(a, b, res) ({ \
64 int tmp = res; \
65 __asm__( \
66 "mla %0, %2, %3, %0" \
67 : "=&r" (tmp) \
68 : "0" (tmp), "r" (a), "r" (b)); \
69 tmp; })
70 #else
71 #define MULA(a, b, res) ((a) * (b) + (res))
72 #endif