From 1a56543279a6fd146c8616781b4160e207bb4f6d Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Mon, 13 Aug 2001 21:48:05 +0000 Subject: win32 fixes Originally committed as revision 84 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/resample.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'libavcodec/resample.c') diff --git a/libavcodec/resample.c b/libavcodec/resample.c index 29445964f6..94e3a560e1 100644 --- a/libavcodec/resample.c +++ b/libavcodec/resample.c @@ -16,14 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#include -#include -#include #include "avcodec.h" - -#define NDEBUG -#include +#include typedef struct { /* fractional resampling */ @@ -196,9 +190,11 @@ static void stereo_mux(short *output, short *input1, short *input2, int n) static int mono_resample(ReSampleChannelContext *s, short *output, short *input, int nb_samples) { - short buf1[nb_samples]; + short *buf1; short *buftmp; + buf1= (short*) malloc( nb_samples * sizeof(short) ); + /* first downsample by an integer factor with averaging filter */ if (s->iratio > 1) { buftmp = buf1; @@ -213,6 +209,7 @@ static int mono_resample(ReSampleChannelContext *s, short *output, short *input, } else { memcpy(output, buftmp, nb_samples * sizeof(short)); } + free(buf1); return nb_samples; } @@ -251,9 +248,10 @@ ReSampleContext *audio_resample_init(int output_channels, int input_channels, int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples) { int i, nb_samples1; - short bufin[2][nb_samples]; - short bufout[2][(int)(nb_samples * s->ratio) + 16]; /* make some zoom to avoid round pb */ + short *bufin[2]; + short *bufout[2]; short *buftmp2[2], *buftmp3[2]; + int lenout; if (s->input_channels == s->output_channels && s->ratio == 1.0) { /* nothing to do */ @@ -261,6 +259,15 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl return nb_samples; } + /* XXX: move those malloc to resample init code */ + bufin[0]= (short*) malloc( nb_samples * sizeof(short) ); + bufin[1]= (short*) malloc( nb_samples * sizeof(short) ); + + /* make some zoom to avoid round pb */ + lenout= (int)(nb_samples * s->ratio) + 16; + bufout[0]= (short*) malloc( lenout * sizeof(short) ); + bufout[1]= (short*) malloc( lenout * sizeof(short) ); + if (s->input_channels == 2 && s->output_channels == 1) { buftmp2[0] = bufin[0]; @@ -292,6 +299,11 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1); } + free(bufin[0]); + free(bufin[1]); + + free(bufout[0]); + free(bufout[1]); return nb_samples1; } -- cgit v1.2.3