From 56f67198d0d28f9192da341d863342e4d8be0445 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sun, 2 May 2004 12:32:11 +0000 Subject: Fix decoder init. CVS patchset: 6472 CVS date: 2004/05/02 12:32:11 --- src/demuxers/demux_asf.c | 19 ++++++++++++++++++- src/demuxers/demux_avi.c | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 7f894dfd1..ec856e8f8 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_asf.c,v 1.157 2004/04/24 13:56:40 tmattern Exp $ + * $Id: demux_asf.c,v 1.158 2004/05/02 12:32:12 tmattern Exp $ * * demultiplexer for asf streams * @@ -304,6 +304,15 @@ static void asf_send_audio_header (demux_asf_t *this, int stream) { return; buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + if (asf_stream->wavex_size > buf->max_size) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_asf: private decoder data length (%d) is greater than fifo buffer length (%d)\n", + asf_stream->wavex_size, buf->max_size); + buf->free_buffer(buf); + this->status = DEMUX_FINISHED; + return; + } + memcpy (buf->content, wavex, asf_stream->wavex_size); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, wavex->wFormatTag); @@ -335,6 +344,14 @@ static void asf_send_video_header (demux_asf_t *this, int stream) { _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_FOURCC, bih->biCompression); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + if (asf_stream->bih_size > buf->max_size) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_asf: private decoder data length (%d) is greater than fifo buffer length (%d)\n", + asf_stream->bih_size, buf->max_size); + buf->free_buffer(buf); + this->status = DEMUX_FINISHED; + return; + } buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAMERATE| BUF_FLAG_FRAME_END; diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index f74c38959..5c6111292 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -19,7 +19,7 @@ */ /* - * $Id: demux_avi.c,v 1.198 2004/04/25 16:23:19 tmattern Exp $ + * $Id: demux_avi.c,v 1.199 2004/05/02 12:32:11 tmattern Exp $ * * demultiplexer for avi streams * @@ -945,10 +945,10 @@ static avi_t *AVI_init(demux_avi_t *this) { this->AVI_errno = AVI_ERR_NO_MEM; return 0; } + memcpy (AVI->bih, hdrl_data+i, n); _x_bmiheader_le2me( AVI->bih ); - /* stream_read(demuxer->stream,(char*) &avi_header.bih,MIN(size2,sizeof(avi_header.bih))); */ AVI->width = AVI->bih->biWidth; AVI->height = AVI->bih->biHeight; @@ -964,6 +964,8 @@ static avi_t *AVI_init(demux_avi_t *this) { /* load the palette, if there is one */ AVI->palette_count = AVI->bih->biClrUsed; + + lprintf ("palette_count: %d\n", AVI->palette_count); if (AVI->palette_count > 256) { lprintf ("number of colors exceeded 256 (%d)", AVI->palette_count); AVI->palette_count = 256; @@ -1748,6 +1750,7 @@ static int demux_avi_next_streaming (demux_avi_t *this, int decoder_flags) { while (left > 0) { video_pts = get_video_pts (this, this->avi->video_posf); + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); /* read video */ @@ -1888,6 +1891,16 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { _x_demux_control_start (this->stream); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + + if (this->avi->bih->biSize > buf->max_size) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_avi: private decoder data length (%d) is greater than fifo buffer length (%d)\n", + this->avi->bih->biSize, buf->max_size); + buf->free_buffer(buf); + this->status = DEMUX_FINISHED; + return; + } + buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAMERATE| BUF_FLAG_FRAME_END; buf->decoder_info[0] = this->video_step; @@ -1928,19 +1941,26 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { if (this->audio_fifo) { for (i=0; iavi->n_audio; i++) { - int wavex_len; avi_audio_t *a = this->avi->audio[i]; buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - wavex_len = (a->wavex_len < buf->max_size) ? a->wavex_len : buf->max_size; + if (a->wavex_len > buf->max_size) { + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "demux_avi: private decoder data length (%d) is greater than fifo buffer length (%d)\n", + a->wavex_len, buf->max_size); + buf->free_buffer(buf); + this->status = DEMUX_FINISHED; + return; + } + buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END; - memcpy (buf->content, a->wavex, wavex_len); - buf->size = wavex_len; + memcpy (buf->content, a->wavex, a->wavex_len); + buf->size = a->wavex_len; buf->type = a->audio_type | i; - buf->decoder_info[0] = 0; /* first package, containing wavex */ - buf->decoder_info[1] = a->wavex->nSamplesPerSec; /* Audio Rate */ - buf->decoder_info[2] = a->wavex->wBitsPerSample; /* Audio bits */ - buf->decoder_info[3] = a->wavex->nChannels; /* Audio bits */ + buf->decoder_info[0] = 0; /* first package, containing wavex */ + buf->decoder_info[1] = a->wavex->nSamplesPerSec; /* Audio Rate */ + buf->decoder_info[2] = a->wavex->wBitsPerSample; /* Audio bits */ + buf->decoder_info[3] = a->wavex->nChannels; /* Audio channels */ this->audio_fifo->put (this->audio_fifo, buf); } -- cgit v1.2.3