diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2001-08-13 21:48:05 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2001-08-13 21:48:05 +0000 |
commit | 1a56543279a6fd146c8616781b4160e207bb4f6d (patch) | |
tree | 4ca37977d896e803a3990e8491f75d02edf49dfd /libavcodec/resample.c | |
parent | d95ecd058e6256b6deacad8b09fbe58b52f07430 (diff) | |
download | ffmpeg-1a56543279a6fd146c8616781b4160e207bb4f6d.tar.gz |
win32 fixes
Originally committed as revision 84 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/resample.c')
-rw-r--r-- | libavcodec/resample.c | 32 |
1 files changed, 22 insertions, 10 deletions
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 <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> #include "avcodec.h" - -#define NDEBUG -#include <assert.h> +#include <math.h> 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; } |