From ec31984c45d9b3dd272ec3ecb9a5270a00494699 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 21 Feb 2007 14:23:25 +0000 Subject: Add SBC helper includes --- sbc/sbc_math.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 sbc/sbc_math.h (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h new file mode 100644 index 00000000..c427bee3 --- /dev/null +++ b/sbc/sbc_math.h @@ -0,0 +1,65 @@ +/* + * + * Bluetooth low-complexity, subband codec (SBC) library + * + * Copyright (C) 2004-2007 Marcel Holtmann + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#define fabs(x) ((x) < 0 ? -(x) : (x)) + +/* C does not provide an explicit arithmetic shift right but this will + always be correct and every compiler *should* generate optimal code */ +#define ASR(val, bits) ((-2 >> 1 == -1) ? \ + ((int32_t) (val)) >> (bits) : ((int32_t) (val)) / (1 << (bits))) + +#define SCALE_PROTO4_TBL 15 +#define SCALE_ANA4_TBL 16 +#define SCALE_PROTO8_TBL 15 +#define SCALE_ANA8_TBL 16 +#define SCALE_SPROTO4_TBL 16 +#define SCALE_SPROTO8_TBL 16 +#define SCALE_NPROTO4_TBL 10 +#define SCALE_NPROTO8_TBL 12 +#define SCALE_SAMPLES 14 +#define SCALE4_STAGE1_BITS 16 +#define SCALE4_STAGE2_BITS 18 +#define SCALE4_STAGED1_BITS 15 +#define SCALE4_STAGED2_BITS 15 +#define SCALE8_STAGE1_BITS 16 +#define SCALE8_STAGE2_BITS 18 +#define SCALE8_STAGED1_BITS 15 +#define SCALE8_STAGED2_BITS 15 + +typedef int32_t sbc_fixed_t; + +#define SCALE4_STAGE1(src) ASR(src, SCALE4_STAGE1_BITS) +#define SCALE4_STAGE2(src) ASR(src, SCALE4_STAGE2_BITS) +#define SCALE4_STAGED1(src) ASR(src, SCALE4_STAGED1_BITS) +#define SCALE4_STAGED2(src) ASR(src, SCALE4_STAGED2_BITS) +#define SCALE8_STAGE1(src) ASR(src, SCALE8_STAGE1_BITS) +#define SCALE8_STAGE2(src) ASR(src, SCALE8_STAGE2_BITS) +#define SCALE8_STAGED1(src) ASR(src, SCALE8_STAGED1_BITS) +#define SCALE8_STAGED2(src) ASR(src, SCALE8_STAGED2_BITS) + +#define SBC_FIXED_0(val) { val = 0; } +#define ADD(dst, src) { dst += src; } +#define SUB(dst, src) { dst -= src; } +#define MUL(dst, a, b) { dst = (sbc_fixed_t) a * b; } +#define MULA(dst, a, b) { dst += (sbc_fixed_t) a * b; } +#define DIV2(dst, src) { dst = ASR(src, 1); } -- cgit From ad868bd4137e86fbf141175f411898796287ff2a Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Sat, 17 Mar 2007 13:37:31 +0000 Subject: update the sbc encoder from the working fixed-point code in the sbc project I also tagged the sbc project with "copied-to-bluez-utils" at the same time. We will do sbc work under bluez and sync it with the old sbc project if necessary. --- sbc/sbc_math.h | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index c427bee3..f6247ef8 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -2,7 +2,9 @@ * * Bluetooth low-complexity, subband codec (SBC) library * - * Copyright (C) 2004-2007 Marcel Holtmann + * Copyright (C) 2004-2006 Marcel Holtmann + * Copyright (C) 2004-2005 Henryk Ploetz + * Copyright (C) 2005-2006 Brad Midgley * * * This library is free software; you can redistribute it and/or @@ -22,11 +24,12 @@ */ #define fabs(x) ((x) < 0 ? -(x) : (x)) - /* C does not provide an explicit arithmetic shift right but this will always be correct and every compiler *should* generate optimal code */ #define ASR(val, bits) ((-2 >> 1 == -1) ? \ - ((int32_t) (val)) >> (bits) : ((int32_t) (val)) / (1 << (bits))) + ((int32_t)(val)) >> (bits) : ((int32_t) (val)) / (1 << (bits))) +#define ASR_64(val, bits) ((-2 >> 1 == -1) ? \ + ((long long)(val)) >> (bits) : ((long long) (val)) / (1 << (bits))) #define SCALE_PROTO4_TBL 15 #define SCALE_ANA4_TBL 16 @@ -37,29 +40,30 @@ #define SCALE_NPROTO4_TBL 10 #define SCALE_NPROTO8_TBL 12 #define SCALE_SAMPLES 14 -#define SCALE4_STAGE1_BITS 16 -#define SCALE4_STAGE2_BITS 18 -#define SCALE4_STAGED1_BITS 15 -#define SCALE4_STAGED2_BITS 15 -#define SCALE8_STAGE1_BITS 16 -#define SCALE8_STAGE2_BITS 18 -#define SCALE8_STAGED1_BITS 15 -#define SCALE8_STAGED2_BITS 15 +#define SCALE4_STAGE1_BITS 10 +#define SCALE4_STAGE2_BITS 21 +#define SCALE4_STAGED1_BITS 18 +#define SCALE4_STAGED2_BITS 23 +#define SCALE8_STAGE1_BITS 8 +#define SCALE8_STAGE2_BITS 24 +#define SCALE8_STAGED1_BITS 18 +#define SCALE8_STAGED2_BITS 23 typedef int32_t sbc_fixed_t; +typedef long long sbc_extended_t; -#define SCALE4_STAGE1(src) ASR(src, SCALE4_STAGE1_BITS) -#define SCALE4_STAGE2(src) ASR(src, SCALE4_STAGE2_BITS) -#define SCALE4_STAGED1(src) ASR(src, SCALE4_STAGED1_BITS) -#define SCALE4_STAGED2(src) ASR(src, SCALE4_STAGED2_BITS) -#define SCALE8_STAGE1(src) ASR(src, SCALE8_STAGE1_BITS) -#define SCALE8_STAGE2(src) ASR(src, SCALE8_STAGE2_BITS) -#define SCALE8_STAGED1(src) ASR(src, SCALE8_STAGED1_BITS) -#define SCALE8_STAGED2(src) ASR(src, SCALE8_STAGED2_BITS) +#define SCALE4_STAGE1(src) ASR_64(src, SCALE4_STAGE1_BITS) +#define SCALE4_STAGE2(src) ASR_64(src, SCALE4_STAGE2_BITS) +#define SCALE4_STAGED1(src) ASR_64(src, SCALE4_STAGED1_BITS) +#define SCALE4_STAGED2(src) ASR_64(src, SCALE4_STAGED2_BITS) +#define SCALE8_STAGE1(src) ASR_64(src, SCALE8_STAGE1_BITS) +#define SCALE8_STAGE2(src) ASR_64(src, SCALE8_STAGE2_BITS) +#define SCALE8_STAGED1(src) ASR_64(src, SCALE8_STAGED1_BITS) +#define SCALE8_STAGED2(src) ASR_64(src, SCALE8_STAGED2_BITS) #define SBC_FIXED_0(val) { val = 0; } #define ADD(dst, src) { dst += src; } #define SUB(dst, src) { dst -= src; } #define MUL(dst, a, b) { dst = (sbc_fixed_t) a * b; } -#define MULA(dst, a, b) { dst += (sbc_fixed_t) a * b; } +#define MULA(dst, a, b) { dst += (sbc_extended_t) a * b; } #define DIV2(dst, src) { dst = ASR(src, 1); } -- cgit From 5689ce1423a12a2c20aef9e48146282e978c4adb Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 25 Aug 2007 13:23:51 +0000 Subject: Update copyright information --- sbc/sbc_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index f6247ef8..d01799c9 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -2,7 +2,7 @@ * * Bluetooth low-complexity, subband codec (SBC) library * - * Copyright (C) 2004-2006 Marcel Holtmann + * Copyright (C) 2004-2007 Marcel Holtmann * Copyright (C) 2004-2005 Henryk Ploetz * Copyright (C) 2005-2006 Brad Midgley * -- cgit From 99b92496ace832a5c75776a55126d731ee42df43 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Fri, 5 Oct 2007 05:42:55 +0000 Subject: fix MUL* macros with () factor more multiplies in 4-subband encoder --- sbc/sbc_math.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index d01799c9..e4f82bce 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -64,6 +64,6 @@ typedef long long sbc_extended_t; #define SBC_FIXED_0(val) { val = 0; } #define ADD(dst, src) { dst += src; } #define SUB(dst, src) { dst -= src; } -#define MUL(dst, a, b) { dst = (sbc_fixed_t) a * b; } -#define MULA(dst, a, b) { dst += (sbc_extended_t) a * b; } +#define MUL(dst, a, b) { dst = (sbc_fixed_t) (a) * (b); } +#define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } #define DIV2(dst, src) { dst = ASR(src, 1); } -- cgit From a4bc7122fb5c7e4545cf8055cf71d1e88515998f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 1 Nov 2007 15:29:21 +0000 Subject: Some more whitespace fixes --- sbc/sbc_math.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index e4f82bce..97389c29 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -40,14 +40,14 @@ #define SCALE_NPROTO4_TBL 10 #define SCALE_NPROTO8_TBL 12 #define SCALE_SAMPLES 14 -#define SCALE4_STAGE1_BITS 10 -#define SCALE4_STAGE2_BITS 21 +#define SCALE4_STAGE1_BITS 10 +#define SCALE4_STAGE2_BITS 21 #define SCALE4_STAGED1_BITS 18 #define SCALE4_STAGED2_BITS 23 #define SCALE8_STAGE1_BITS 8 -#define SCALE8_STAGE2_BITS 24 +#define SCALE8_STAGE2_BITS 24 #define SCALE8_STAGED1_BITS 18 -#define SCALE8_STAGED2_BITS 23 +#define SCALE8_STAGED2_BITS 23 typedef int32_t sbc_fixed_t; typedef long long sbc_extended_t; -- cgit From f6dd2c738c08de510d8eb2d2f81c1c9f10521cd2 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Thu, 17 Jan 2008 04:35:14 +0000 Subject: codec has been using 32-bit (MUL) and 64-bit (MULA) multiplies straighten things out so MUL/MULA are both 64 bit create MUL32/MULA32 for anyone who really needs a 32-bit product --- sbc/sbc_math.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 97389c29..fae2a0c5 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -64,6 +64,8 @@ typedef long long sbc_extended_t; #define SBC_FIXED_0(val) { val = 0; } #define ADD(dst, src) { dst += src; } #define SUB(dst, src) { dst -= src; } -#define MUL(dst, a, b) { dst = (sbc_fixed_t) (a) * (b); } +#define MUL32(dst, a, b) { dst = (sbc_fixed_t) (a) * (b); } +#define MULA32(dst, a, b) { dst += (sbc_fixed_t) (a) * (b); } +#define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } #define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } #define DIV2(dst, src) { dst = ASR(src, 1); } -- cgit From 66fe637352aeb2b5d376bff7095a7a5fd209a426 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Sat, 19 Jan 2008 15:56:52 +0000 Subject: update copyrights --- sbc/sbc_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index fae2a0c5..f5879fbf 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -4,7 +4,7 @@ * * Copyright (C) 2004-2007 Marcel Holtmann * Copyright (C) 2004-2005 Henryk Ploetz - * Copyright (C) 2005-2006 Brad Midgley + * Copyright (C) 2005-2008 Brad Midgley * * * This library is free software; you can redistribute it and/or -- cgit From c9b510105937825c04c729b4bb02b87596b795fb Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Sat, 26 Jan 2008 19:45:54 +0000 Subject: shorten the encoder tables to 16 bits, take out mula32/mul32 for now for simplicity --- sbc/sbc_math.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index f5879fbf..5aeddac1 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -31,20 +31,20 @@ #define ASR_64(val, bits) ((-2 >> 1 == -1) ? \ ((long long)(val)) >> (bits) : ((long long) (val)) / (1 << (bits))) -#define SCALE_PROTO4_TBL 15 +#define SCALE_PROTO4_TBL 16 #define SCALE_ANA4_TBL 16 -#define SCALE_PROTO8_TBL 15 +#define SCALE_PROTO8_TBL 16 #define SCALE_ANA8_TBL 16 #define SCALE_SPROTO4_TBL 16 #define SCALE_SPROTO8_TBL 16 #define SCALE_NPROTO4_TBL 10 #define SCALE_NPROTO8_TBL 12 #define SCALE_SAMPLES 14 -#define SCALE4_STAGE1_BITS 10 +#define SCALE4_STAGE1_BITS 9 #define SCALE4_STAGE2_BITS 21 #define SCALE4_STAGED1_BITS 18 #define SCALE4_STAGED2_BITS 23 -#define SCALE8_STAGE1_BITS 8 +#define SCALE8_STAGE1_BITS 7 #define SCALE8_STAGE2_BITS 24 #define SCALE8_STAGED1_BITS 18 #define SCALE8_STAGED2_BITS 23 @@ -64,8 +64,6 @@ typedef long long sbc_extended_t; #define SBC_FIXED_0(val) { val = 0; } #define ADD(dst, src) { dst += src; } #define SUB(dst, src) { dst -= src; } -#define MUL32(dst, a, b) { dst = (sbc_fixed_t) (a) * (b); } -#define MULA32(dst, a, b) { dst += (sbc_fixed_t) (a) * (b); } #define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } #define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } #define DIV2(dst, src) { dst = ASR(src, 1); } -- cgit From c2ce7c2d410cfb0e67c1635ebf60fc06ae864f33 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Sun, 27 Jan 2008 03:35:53 +0000 Subject: get 32-bit products whenever we're sure the multiplicands are both 16 bits --- sbc/sbc_math.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 5aeddac1..c8c72c75 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -64,6 +64,8 @@ typedef long long sbc_extended_t; #define SBC_FIXED_0(val) { val = 0; } #define ADD(dst, src) { dst += src; } #define SUB(dst, src) { dst -= src; } +#define MUL32(dst, a, b) { dst = (sbc_fixed_t) (a) * (b); } +#define MULA32(dst, a, b) { dst += (sbc_fixed_t) (a) * (b); } #define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } #define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } #define DIV2(dst, src) { dst = ASR(src, 1); } -- cgit From 38158dc5dd8e7c62ad2decfec395e3ec2c7e280b Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Mon, 28 Jan 2008 17:26:22 +0000 Subject: remove 16x16 mult optimization--gcc actually generates more costly code --- sbc/sbc_math.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index c8c72c75..625d4dd0 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -31,20 +31,20 @@ #define ASR_64(val, bits) ((-2 >> 1 == -1) ? \ ((long long)(val)) >> (bits) : ((long long) (val)) / (1 << (bits))) -#define SCALE_PROTO4_TBL 16 +#define SCALE_PROTO4_TBL 15 #define SCALE_ANA4_TBL 16 -#define SCALE_PROTO8_TBL 16 +#define SCALE_PROTO8_TBL 15 #define SCALE_ANA8_TBL 16 #define SCALE_SPROTO4_TBL 16 #define SCALE_SPROTO8_TBL 16 #define SCALE_NPROTO4_TBL 10 #define SCALE_NPROTO8_TBL 12 #define SCALE_SAMPLES 14 -#define SCALE4_STAGE1_BITS 9 +#define SCALE4_STAGE1_BITS 10 #define SCALE4_STAGE2_BITS 21 #define SCALE4_STAGED1_BITS 18 #define SCALE4_STAGED2_BITS 23 -#define SCALE8_STAGE1_BITS 7 +#define SCALE8_STAGE1_BITS 8 #define SCALE8_STAGE2_BITS 24 #define SCALE8_STAGED1_BITS 18 #define SCALE8_STAGED2_BITS 23 @@ -64,8 +64,6 @@ typedef long long sbc_extended_t; #define SBC_FIXED_0(val) { val = 0; } #define ADD(dst, src) { dst += src; } #define SUB(dst, src) { dst -= src; } -#define MUL32(dst, a, b) { dst = (sbc_fixed_t) (a) * (b); } -#define MULA32(dst, a, b) { dst += (sbc_fixed_t) (a) * (b); } #define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } #define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } #define DIV2(dst, src) { dst = ASR(src, 1); } -- cgit From 05a6e1afb3b0111e8fafcb8ca2d1ca8674390c11 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Mon, 28 Jan 2008 17:32:36 +0000 Subject: arm-assembly from cidoca for MULA --- sbc/sbc_math.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 625d4dd0..68b0f197 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -65,5 +65,13 @@ typedef long long sbc_extended_t; #define ADD(dst, src) { dst += src; } #define SUB(dst, src) { dst -= src; } #define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } -#define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } #define DIV2(dst, src) { dst = ASR(src, 1); } + +#ifdef __arm__ +#define MULA(res, a, b) __asm__( \ + "smlal %Q0, %R0, %2, %3" \ + : "=&r" (res) \ + : "0" (res), "r" (a), "r" (b)); +#else +#define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } +#endif -- cgit From 6d205fda030a21d99ea5064b9501d58a11b6efa5 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Mon, 28 Jan 2008 18:00:51 +0000 Subject: revert arm conditional code --- sbc/sbc_math.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 68b0f197..8c5ec3a7 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -66,12 +66,4 @@ typedef long long sbc_extended_t; #define SUB(dst, src) { dst -= src; } #define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } #define DIV2(dst, src) { dst = ASR(src, 1); } - -#ifdef __arm__ -#define MULA(res, a, b) __asm__( \ - "smlal %Q0, %R0, %2, %3" \ - : "=&r" (res) \ - : "0" (res), "r" (a), "r" (b)); -#else #define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } -#endif -- cgit From 7f760a2f3624f26ac0569ed70405e11498aad308 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Wed, 30 Jan 2008 20:29:24 +0000 Subject: remove unused macros --- sbc/sbc_math.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 8c5ec3a7..2229d605 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -62,8 +62,5 @@ typedef long long sbc_extended_t; #define SCALE8_STAGED2(src) ASR_64(src, SCALE8_STAGED2_BITS) #define SBC_FIXED_0(val) { val = 0; } -#define ADD(dst, src) { dst += src; } -#define SUB(dst, src) { dst -= src; } #define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } -#define DIV2(dst, src) { dst = ASR(src, 1); } #define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } -- cgit From 82540ead6bfe7d0398256b48500e6fbecb0e28e1 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Wed, 30 Jan 2008 20:37:49 +0000 Subject: change MUL/MULA semantics --- sbc/sbc_math.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 2229d605..9aa8c366 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -62,5 +62,5 @@ typedef long long sbc_extended_t; #define SCALE8_STAGED2(src) ASR_64(src, SCALE8_STAGED2_BITS) #define SBC_FIXED_0(val) { val = 0; } -#define MUL(dst, a, b) { dst = (sbc_extended_t) (a) * (b); } -#define MULA(dst, a, b) { dst += (sbc_extended_t) (a) * (b); } +#define MUL(a, b) ((sbc_extended_t)(a) * (b)) +#define MULA(a, b, res) ((sbc_extended_t)(a) * (b) + (res)) -- cgit From e51de7f6fb5385c9df62842ce9cf92f9fd33f040 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Wed, 30 Jan 2008 20:39:33 +0000 Subject: arm assembly version of MULA --- sbc/sbc_math.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 9aa8c366..8db67ca8 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -63,4 +63,14 @@ typedef long long sbc_extended_t; #define SBC_FIXED_0(val) { val = 0; } #define MUL(a, b) ((sbc_extended_t)(a) * (b)) +#ifdef __arm__ +#define MULA(a, b, res) ({ \ + long long tmp = res; \ + __asm__( \ + "smlal %Q0, %R0, %2, %3" \ + : "=&r" (tmp) \ + : "0" (tmp), "r" (a), "r" (b)); \ + tmp; }) +#else #define MULA(a, b, res) ((sbc_extended_t)(a) * (b) + (res)) +#endif -- cgit From e823c15e43a6f924779e466d434c51157002d9ee Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 2 Feb 2008 03:37:05 +0000 Subject: Update copyright information --- sbc/sbc_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 8db67ca8..007a1e9c 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -2,7 +2,7 @@ * * Bluetooth low-complexity, subband codec (SBC) library * - * Copyright (C) 2004-2007 Marcel Holtmann + * Copyright (C) 2004-2008 Marcel Holtmann * Copyright (C) 2004-2005 Henryk Ploetz * Copyright (C) 2005-2008 Brad Midgley * -- cgit From ff51f4b0b2724754184baa08b09a47cad7b7b4d5 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Fri, 15 Feb 2008 18:06:32 +0000 Subject: fix for decoder noise at high bitpools --- sbc/sbc_math.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 007a1e9c..6c3fe2f2 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -40,14 +40,14 @@ #define SCALE_NPROTO4_TBL 10 #define SCALE_NPROTO8_TBL 12 #define SCALE_SAMPLES 14 -#define SCALE4_STAGE1_BITS 10 -#define SCALE4_STAGE2_BITS 21 -#define SCALE4_STAGED1_BITS 18 -#define SCALE4_STAGED2_BITS 23 -#define SCALE8_STAGE1_BITS 8 -#define SCALE8_STAGE2_BITS 24 -#define SCALE8_STAGED1_BITS 18 -#define SCALE8_STAGED2_BITS 23 +#define SCALE4_STAGE1_BITS 16 +#define SCALE4_STAGE2_BITS 16 +#define SCALE4_STAGED1_BITS 14 +#define SCALE4_STAGED2_BITS 14 +#define SCALE8_STAGE1_BITS 16 +#define SCALE8_STAGE2_BITS 16 +#define SCALE8_STAGED1_BITS 14 +#define SCALE8_STAGED2_BITS 14 typedef int32_t sbc_fixed_t; typedef long long sbc_extended_t; -- cgit From 4170955ad1f97eb8b7bf4f96025a654dab531571 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 22 Feb 2008 13:41:02 +0000 Subject: Replace 64bits multiplies by 32bits to further optimize the code --- sbc/sbc_math.h | 54 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 6c3fe2f2..5d3da8d9 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -28,49 +28,45 @@ always be correct and every compiler *should* generate optimal code */ #define ASR(val, bits) ((-2 >> 1 == -1) ? \ ((int32_t)(val)) >> (bits) : ((int32_t) (val)) / (1 << (bits))) -#define ASR_64(val, bits) ((-2 >> 1 == -1) ? \ - ((long long)(val)) >> (bits) : ((long long) (val)) / (1 << (bits))) #define SCALE_PROTO4_TBL 15 #define SCALE_ANA4_TBL 16 -#define SCALE_PROTO8_TBL 15 -#define SCALE_ANA8_TBL 16 -#define SCALE_SPROTO4_TBL 16 -#define SCALE_SPROTO8_TBL 16 -#define SCALE_NPROTO4_TBL 10 -#define SCALE_NPROTO8_TBL 12 -#define SCALE_SAMPLES 14 +#define SCALE_PROTO8_TBL 16 +#define SCALE_ANA8_TBL 17 +#define SCALE_SPROTO4_TBL 15 +#define SCALE_SPROTO8_TBL 14 +#define SCALE_NPROTO4_TBL 13 +#define SCALE_NPROTO8_TBL 11 #define SCALE4_STAGE1_BITS 16 -#define SCALE4_STAGE2_BITS 16 -#define SCALE4_STAGED1_BITS 14 -#define SCALE4_STAGED2_BITS 14 -#define SCALE8_STAGE1_BITS 16 -#define SCALE8_STAGE2_BITS 16 -#define SCALE8_STAGED1_BITS 14 -#define SCALE8_STAGED2_BITS 14 +#define SCALE4_STAGE2_BITS 15 +#define SCALE4_STAGED1_BITS 12 +#define SCALE4_STAGED2_BITS 16 +#define SCALE8_STAGE1_BITS 15 +#define SCALE8_STAGE2_BITS 15 +#define SCALE8_STAGED1_BITS 15 +#define SCALE8_STAGED2_BITS 16 typedef int32_t sbc_fixed_t; -typedef long long sbc_extended_t; -#define SCALE4_STAGE1(src) ASR_64(src, SCALE4_STAGE1_BITS) -#define SCALE4_STAGE2(src) ASR_64(src, SCALE4_STAGE2_BITS) -#define SCALE4_STAGED1(src) ASR_64(src, SCALE4_STAGED1_BITS) -#define SCALE4_STAGED2(src) ASR_64(src, SCALE4_STAGED2_BITS) -#define SCALE8_STAGE1(src) ASR_64(src, SCALE8_STAGE1_BITS) -#define SCALE8_STAGE2(src) ASR_64(src, SCALE8_STAGE2_BITS) -#define SCALE8_STAGED1(src) ASR_64(src, SCALE8_STAGED1_BITS) -#define SCALE8_STAGED2(src) ASR_64(src, SCALE8_STAGED2_BITS) +#define SCALE4_STAGE1(src) ASR(src, SCALE4_STAGE1_BITS) +#define SCALE4_STAGE2(src) ASR(src, SCALE4_STAGE2_BITS) +#define SCALE4_STAGED1(src) ASR(src, SCALE4_STAGED1_BITS) +#define SCALE4_STAGED2(src) ASR(src, SCALE4_STAGED2_BITS) +#define SCALE8_STAGE1(src) ASR(src, SCALE8_STAGE1_BITS) +#define SCALE8_STAGE2(src) ASR(src, SCALE8_STAGE2_BITS) +#define SCALE8_STAGED1(src) ASR(src, SCALE8_STAGED1_BITS) +#define SCALE8_STAGED2(src) ASR(src, SCALE8_STAGED2_BITS) #define SBC_FIXED_0(val) { val = 0; } -#define MUL(a, b) ((sbc_extended_t)(a) * (b)) +#define MUL(a, b) ((a) * (b)) #ifdef __arm__ #define MULA(a, b, res) ({ \ - long long tmp = res; \ + int tmp = res; \ __asm__( \ - "smlal %Q0, %R0, %2, %3" \ + "mla %0, %2, %3, %0" \ : "=&r" (tmp) \ : "0" (tmp), "r" (a), "r" (b)); \ tmp; }) #else -#define MULA(a, b, res) ((sbc_extended_t)(a) * (b) + (res)) +#define MULA(a, b, res) ((a) * (b) + (res)) #endif -- cgit From 7a68b05beaed5944dcd88f23002c9f55a2f74ba6 Mon Sep 17 00:00:00 2001 From: Brad Midgley Date: Fri, 29 Feb 2008 03:56:22 +0000 Subject: Cidorvan's 4-subband overflow fixes --- sbc/sbc_math.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sbc/sbc_math.h') diff --git a/sbc/sbc_math.h b/sbc/sbc_math.h index 5d3da8d9..b3d87a62 100644 --- a/sbc/sbc_math.h +++ b/sbc/sbc_math.h @@ -30,16 +30,16 @@ ((int32_t)(val)) >> (bits) : ((int32_t) (val)) / (1 << (bits))) #define SCALE_PROTO4_TBL 15 -#define SCALE_ANA4_TBL 16 +#define SCALE_ANA4_TBL 17 #define SCALE_PROTO8_TBL 16 #define SCALE_ANA8_TBL 17 -#define SCALE_SPROTO4_TBL 15 +#define SCALE_SPROTO4_TBL 12 #define SCALE_SPROTO8_TBL 14 -#define SCALE_NPROTO4_TBL 13 +#define SCALE_NPROTO4_TBL 11 #define SCALE_NPROTO8_TBL 11 -#define SCALE4_STAGE1_BITS 16 -#define SCALE4_STAGE2_BITS 15 -#define SCALE4_STAGED1_BITS 12 +#define SCALE4_STAGE1_BITS 15 +#define SCALE4_STAGE2_BITS 16 +#define SCALE4_STAGED1_BITS 15 #define SCALE4_STAGED2_BITS 16 #define SCALE8_STAGE1_BITS 15 #define SCALE8_STAGE2_BITS 15 -- cgit