diff --git a/plugins/avplug/avaudio.c b/plugins/avplug/avaudio.c index 78fe83892..0cbff74b8 100644 --- a/plugins/avplug/avaudio.c +++ b/plugins/avplug/avaudio.c @@ -127,6 +127,7 @@ static void S_AV_ReadFrame(struct avaudioctx *ctx) auddatasize/=2; width = 2; } + break; case AV_SAMPLE_FMT_DBLP: auddatasize /= channels; diff --git a/plugins/avplug/avdecode.c b/plugins/avplug/avdecode.c index 1b4536b64..1a67e5823 100644 --- a/plugins/avplug/avdecode.c +++ b/plugins/avplug/avdecode.c @@ -374,8 +374,31 @@ static qboolean VARGS AVDec_DisplayFrame(void *vctx, qboolean nosound, qboolean break; case AV_SAMPLE_FMT_FLTP: - auddatasize /= channels; - channels = 1; + //FIXME: support float audio internally. + { + float *in[2] = {(float*)ctx->pAFrame->data[0],(float*)ctx->pAFrame->data[1]}; + signed short *out = (void*)auddata; + int v; + unsigned int i, c; + unsigned int frames = ctx->pAFrame->nb_samples; + if (channels > 2) + channels = 2; + for (i = 0; i < frames; i++) + { + for (c = 0; c < channels; c++) + { + v = (short)(in[c][i]*32767); + if (v < -32767) + v = -32767; + else if (v > 32767) + v = 32767; + *out++ = v; + } + } + width = sizeof(*out); + auddatasize = frames*width*channels; + } + break; case AV_SAMPLE_FMT_FLT: //FIXME: support float audio internally. { @@ -395,6 +418,7 @@ static qboolean VARGS AVDec_DisplayFrame(void *vctx, qboolean nosound, qboolean auddatasize/=2; width = 2; } + break; case AV_SAMPLE_FMT_DBLP: auddatasize /= channels;