Mercurial > mplayer.hg
changeset 18157:2c7219c38e56
bug fixes: left-over mode variable used uninitialized,
initialize sh->audio_out_minsize to maximum decoded size
author | reimar |
---|---|
date | Wed, 19 Apr 2006 22:30:31 +0000 |
parents | 2898ee5573d9 |
children | 5b44c460d0c0 |
files | libmpcodecs/ad_speex.c |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/ad_speex.c Wed Apr 19 22:04:05 2006 +0000 +++ b/libmpcodecs/ad_speex.c Wed Apr 19 22:30:31 2006 +0000 @@ -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);