[MPlayer-cvslog] CVS: main/libmpcodecs ad_speex.c,1.2,1.3
Reimar Döffinger CVS
syncmail at mplayerhq.hu
Thu Apr 20 00:30:33 CEST 2006
CVS change done by Reimar Döffinger CVS
Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv14054
Modified Files:
ad_speex.c
Log Message:
bug fixes: left-over mode variable used uninitialized,
initialize sh->audio_out_minsize to maximum decoded size
Index: ad_speex.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_speex.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ad_speex.c 19 Jan 2006 20:26:34 -0000 1.2
+++ ad_speex.c 19 Apr 2006 22:30:31 -0000 1.3
@@ -5,6 +5,7 @@
* becomes part of the FFmpeg project (ffmpeg.org)
*/
#include "config.h"
+#include <stdlib.h>
#include <speex/speex.h>
#include <speex/speex_stereo.h>
#include <speex/speex_header.h>
@@ -27,7 +28,10 @@
SpeexHeader *hdr;
} context_t;
+#define MAX_FRAMES_PER_PACKET 100
+
static int preinit(sh_audio_t *sh) {
+ sh->audio_out_minsize = 2 * 320 * MAX_FRAMES_PER_PACKET * 2 * sizeof(short);
return 1;
}
@@ -35,7 +39,6 @@
context_t *ctx = (context_t *)calloc(1, sizeof(context_t));
const SpeexMode *spx_mode;
const SpeexStereoState st_st = SPEEX_STEREO_STATE_INIT; // hack
- int mode;
if (!sh->wf || sh->wf->cbSize < 80) {
mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Missing extradata!\n");
return 0;
@@ -46,6 +49,11 @@
"assuming mono\n", ctx->hdr->nb_channels);
ctx->hdr->nb_channels = 1;
}
+ if (ctx->hdr->frames_per_packet > MAX_FRAMES_PER_PACKET) {
+ mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Invalid number of frames per packet (%i), "
+ "assuming 1\n", ctx->hdr->frames_per_packet);
+ ctx->hdr->frames_per_packet = 1;
+ }
switch (ctx->hdr->mode) {
case 0:
spx_mode = &speex_nb_mode; break;
@@ -54,7 +62,7 @@
case 2:
spx_mode = &speex_uwb_mode; break;
default:
- mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Unknown speex mode (%i)\n", mode);
+ mp_msg(MSGT_DECAUDIO, MSGL_WARN, "Unknown speex mode (%i)\n", ctx->hdr->mode);
spx_mode = &speex_nb_mode;
}
ctx->dec_context = speex_decoder_init(spx_mode);
More information about the MPlayer-cvslog
mailing list