Use alloca for temp space decoding/encoding IMA4 blocks
This commit is contained in:
@@ -314,6 +314,7 @@ CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(pri
|
||||
int main() {return 0;}" HAVE_GCC_FORMAT)
|
||||
|
||||
CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
|
||||
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
|
||||
CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
|
||||
CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
|
||||
CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
|
||||
@@ -337,6 +338,19 @@ CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
|
||||
CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
|
||||
CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
|
||||
CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
|
||||
IF(HAVE_ALLOCA_H)
|
||||
CHECK_SYMBOL_EXISTS(alloca alloca.h HAVE_ALLOCA)
|
||||
ELSEIF(HAVE_MALLOC_H)
|
||||
CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
|
||||
ENDIF()
|
||||
IF(NOT HAVE_ALLOCA)
|
||||
CHECK_SYMBOL_EXISTS(_alloca malloc.h HAVE__ALLOCA)
|
||||
IF(NOT HAVE__ALLOCA)
|
||||
MESSAGE(FATAL_ERROR "No alloca function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dalloca=_alloca)
|
||||
ENDIF()
|
||||
|
||||
IF(HAVE_FLOAT_H)
|
||||
CHECK_SYMBOL_EXISTS(_controlfp float.h HAVE__CONTROLFP)
|
||||
|
||||
+11
-4
@@ -24,6 +24,12 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alu.h"
|
||||
@@ -1598,11 +1604,11 @@ DECL_TEMPLATE2(ALubyte3)
|
||||
static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALuint numchans, \
|
||||
ALuint len) \
|
||||
{ \
|
||||
ALshort tmp[65*MAX_INPUT_CHANNELS]; /* Max samples an IMA4 frame can be */\
|
||||
ALuint i, j, k; \
|
||||
ALshort *tmp; \
|
||||
\
|
||||
i = 0; \
|
||||
while(i < len) \
|
||||
tmp = alloca(65*numchans); \
|
||||
for(i = 0;i < len;) \
|
||||
{ \
|
||||
DecodeIMA4Block(tmp, src, numchans); \
|
||||
src += 36*numchans; \
|
||||
@@ -1634,11 +1640,12 @@ DECL_TEMPLATE(ALubyte3)
|
||||
static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALuint numchans, \
|
||||
ALuint len) \
|
||||
{ \
|
||||
ALshort tmp[65*MAX_INPUT_CHANNELS]; /* Max samples an IMA4 frame can be */\
|
||||
ALint sample[MaxChannels] = {0,0,0,0,0,0,0,0}; \
|
||||
ALint index[MaxChannels] = {0,0,0,0,0,0,0,0}; \
|
||||
ALshort *tmp; \
|
||||
ALuint i, j; \
|
||||
\
|
||||
tmp = alloca(65*numchans); \
|
||||
for(i = 0;i < len;i += 65) \
|
||||
{ \
|
||||
for(j = 0;j < 65*numchans;j++) \
|
||||
|
||||
@@ -116,6 +116,9 @@
|
||||
/* Define if we have malloc.h */
|
||||
#cmakedefine HAVE_MALLOC_H
|
||||
|
||||
/* Define if we have alloca.h */
|
||||
#cmakedefine HAVE_ALLOCA_H
|
||||
|
||||
/* Define if we have strings.h */
|
||||
#cmakedefine HAVE_STRINGS_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user