From a6eb38ea7f89ae21d6621570a148aa3aed5edf54 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 3 Mar 2014 20:02:15 -0800 Subject: Use alloca for temp space decoding/encoding IMA4 blocks --- OpenAL32/alBuffer.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenAL32/alBuffer.c') diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 3e125327..bbc1da05 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -24,6 +24,12 @@ #include #include #include +#ifdef HAVE_ALLOCA_H +#include +#endif +#ifdef HAVE_MALLOC_H +#include +#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++) \ -- cgit v1.2.3