From 50d9a4cb1ec671f8ca1da5ad4262fb6e77a924fd Mon Sep 17 00:00:00 2001 From: Raghu Gandham Date: Tue, 10 Jul 2012 17:34:45 -0700 Subject: GCC 4.4 and later cannot handle h constructs. Fix to replace the assembly constructs. Change-Id: I47509c20ee32f04ce42105563d2d4013910da531 --- libFDK/include/mips/cplx_mul.h | 28 ++++------------------------ libFDK/include/mips/fixmul_mips.h | 8 +------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/libFDK/include/mips/cplx_mul.h b/libFDK/include/mips/cplx_mul.h index e0781dd..4e8f26f 100644 --- a/libFDK/include/mips/cplx_mul.h +++ b/libFDK/include/mips/cplx_mul.h @@ -108,20 +108,9 @@ inline void cplxMultDiv2( FIXP_DBL *c_Re, FIXP_DBL b_Im) { INT result; - - __asm__ ("mult %[a_Re], %[b_Re];\n" - "msub %[a_Im], %[b_Im];\n" - : "=hi"(result) - : [a_Re]"r"(a_Re), [b_Re]"r"(b_Re), [a_Im]"r"(a_Im), [b_Im]"r"(b_Im) - : "lo"); - + result = (((long long)a_Re * b_Re) - ((long long) a_Im * b_Im)) >> 32; *c_Re = result; - - __asm__ ("mult %[a_Re], %[b_Im];\n" - "madd %[a_Im], %[b_Re];\n" - : "=hi"(result) - : [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re) - : "lo"); + result = (((long long)a_Re * b_Im) - ((long long) a_Im * b_Re)) >> 32; *c_Im = result; } #endif @@ -135,18 +124,9 @@ inline void cplxMult( FIXP_DBL *c_Re, FIXP_DBL b_Im) { INT result; - __asm__ ("mult %[a_Re], %[b_Re];\n" - "msub %[a_Im], %[b_Im];\n" - : "=hi"(result) - : [a_Re]"r"(a_Re), [b_Re]"r"(b_Re), [a_Im]"r"(a_Im), [b_Im]"r"(b_Im) - : "lo"); + result = (((long long)a_Re * b_Re) - ((long long) a_Im * b_Im)) >> 32; *c_Re = result<<1; - - __asm__ ("mult %[a_Re], %[b_Im];\n" - "madd %[a_Im], %[b_Re];\n" - : "=hi"(result) - : [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re) - : "lo"); + result = (((long long)a_Re * b_Im) - ((long long) a_Im * b_Re)) >> 32; *c_Im = result<<1; } #endif diff --git a/libFDK/include/mips/fixmul_mips.h b/libFDK/include/mips/fixmul_mips.h index 4fb72f7..0e7af0d 100644 --- a/libFDK/include/mips/fixmul_mips.h +++ b/libFDK/include/mips/fixmul_mips.h @@ -100,14 +100,8 @@ amm-info@iis.fraunhofer.de inline INT fixmuldiv2_DD (const INT a, const INT b) { - INT result ; - asm ("mult %1,%2;\n" - : "=hi" (result) - : "d" (a), "r" (b) - : "lo"); - - return result ; + return ((long long) a * b) >> 32; } #endif /* (__GNUC__) && defined(__mips__) */ -- cgit v1.2.3 From 65745694963cc601a2403d071311261f200d6cb9 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 10 Aug 2012 10:57:24 +0300 Subject: Don't try to shift more bits than the variable length Shifting by more than (or equal to) the variable length is undefined in C. This caused the quantized spectrum values to go out of range, triggering asserts later. Change-Id: If81b6c8caa7b9c75941ad9d280b686d2069c968c --- libAACenc/src/quantize.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libAACenc/src/quantize.cpp b/libAACenc/src/quantize.cpp index 9694901..dc85a6d 100644 --- a/libAACenc/src/quantize.cpp +++ b/libAACenc/src/quantize.cpp @@ -127,7 +127,10 @@ static void FDKaacEnc_quantizeLines(INT gain, accu = fMultDiv2(FDKaacEnc_mTab_3_4[tabIndex],FDKaacEnc_quantTableE[totalShift&3]); totalShift = (16-4)-(3*(totalShift>>2)); FDK_ASSERT(totalShift >=0); /* MAX_QUANT_VIOLATION */ - accu>>=totalShift; + if (totalShift < 32) + accu>>=totalShift; + else + accu = 0; quaSpectrum[line] = (SHORT)(-((LONG)(k + accu) >> (DFRACT_BITS-1-16))); } else if(accu > FL2FXCONST_DBL(0.0f)) @@ -140,7 +143,10 @@ static void FDKaacEnc_quantizeLines(INT gain, accu = fMultDiv2(FDKaacEnc_mTab_3_4[tabIndex],FDKaacEnc_quantTableE[totalShift&3]); totalShift = (16-4)-(3*(totalShift>>2)); FDK_ASSERT(totalShift >=0); /* MAX_QUANT_VIOLATION */ - accu>>=totalShift; + if (totalShift < 32) + accu>>=totalShift; + else + accu = 0; quaSpectrum[line] = (SHORT)((LONG)(k + accu) >> (DFRACT_BITS-1-16)); } else -- cgit v1.2.3 From ad749575b4520b2a6f946d54647b0b2bca945b42 Mon Sep 17 00:00:00 2001 From: Irina Tirdea Date: Fri, 31 Aug 2012 16:53:51 +0300 Subject: Remove workaround in aac for broken toolchain aac project forces the system not to include sys/types.h by defining _SYS_TYPES_H_. This is a workaround for broken android toolchain. This is no longer needed in latest android version and can be safely removed. This will also lead to more errors if changes in bionic headers are needed. Change-Id: Icb76c207d6b47e811eacff9f9403177629bfb451 Signed-off-by: Irina Tirdea --- libSYS/include/genericStds.h | 2 -- libSYS/src/cmdl_parser.cpp | 3 --- 2 files changed, 5 deletions(-) diff --git a/libSYS/include/genericStds.h b/libSYS/include/genericStds.h index 2d6eea6..756935b 100644 --- a/libSYS/include/genericStds.h +++ b/libSYS/include/genericStds.h @@ -96,8 +96,6 @@ amm-info@iis.fraunhofer.de #include "machine_type.h" -/* Work around for broken android toolchain: sys/types.h:137: error: 'uint64_t' does not name a type */ -#define _SYS_TYPES_H_ /* Always increase verbosity of memory allocation in case of a debug built. DEBUG is defined globally in that case. */ diff --git a/libSYS/src/cmdl_parser.cpp b/libSYS/src/cmdl_parser.cpp index a93a2f4..bf020ee 100644 --- a/libSYS/src/cmdl_parser.cpp +++ b/libSYS/src/cmdl_parser.cpp @@ -92,9 +92,6 @@ amm-info@iis.fraunhofer.de #define _CRT_SECURE_NO_WARNINGS -/* Work around for broken android toolchain: sys/types.h:137: error: 'uint64_t' does not name a type */ -#define _SYS_TYPES_H_ - #include #include #include -- cgit v1.2.3