mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-16 03:50:05 +01:00
win32 fixes
Originally committed as revision 84 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user