* 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 */
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;
} else {
memcpy(output, buftmp, nb_samples * sizeof(short));
}
+ free(buf1);
return nb_samples;
}
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 */
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];
stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
}
+ free(bufin[0]);
+ free(bufin[1]);
+
+ free(bufout[0]);
+ free(bufout[1]);
return nb_samples1;
}