[MPlayer-dev-eng] reading beyond EOF in some demuxers
Dmitry Baryshkov
mitya at school.ioffe.ru
Thu Sep 11 15:46:58 CEST 2003
On Wed, 2003-09-10 at 18:49, Dmitry Baryshkov wrote:
> Hello!
> While trying to add FLAC decoding support, I found, that some demuxers
> (audio(WAV part), rawaudio, and even ds_read_packet from demuxer.c)
> didn't check, how many bytes stream_read returned, thus providing to
> decoders ability to read after EOF :). Attached patch (hopefully) fixes
> it. Is it OK to commit? Or realloc'ing in resize_demux_packet isn't good
> and it is better to simply change dp->len ?
> --
> With best wishes
> Dmitry Baryshkov
P.S. If no one objects, I'll commitit at Monday.
>
>
>
> ----
>
> diff -Naur main/libmpdemux/demux_audio.c main.correct_read/libmpdemux/demux_audio.c
> --- main/libmpdemux/demux_audio.c 2003-06-04 14:52:58.000000000 +0400
> +++ main.correct_read/libmpdemux/demux_audio.c 2003-09-09 23:58:04.000000000 +0400
> @@ -265,7 +265,8 @@
> case WAV : {
> int l = sh_audio->wf->nAvgBytesPerSec;
> demux_packet_t* dp = new_demux_packet(l);
> - stream_read(s,dp->buffer,l);
> + l = stream_read(s,dp->buffer,l);
> + resize_demux_packet(dp, l);
> priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps;
> ds->pts = priv->last_pts - (ds_tell_pts(demux->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
> ds_add_packet(ds,dp);
> diff -Naur main/libmpdemux/demuxer.c main.correct_read/libmpdemux/demuxer.c
> --- main/libmpdemux/demuxer.c 2003-09-02 15:31:25.000000000 +0400
> +++ main.correct_read/libmpdemux/demuxer.c 2003-09-09 23:59:25.000000000 +0400
> @@ -265,7 +265,8 @@
>
> void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags){
> demux_packet_t* dp=new_demux_packet(len);
> - stream_read(stream,dp->buffer,len);
> + len = stream_read(stream,dp->buffer,len);
> + resize_demux_packet(dp, len);
> dp->pts=pts; //(float)pts/90000.0f;
> dp->pos=pos;
> dp->flags=flags;
> diff -Naur main/libmpdemux/demux_rawaudio.c main.correct_read/libmpdemux/demux_rawaudio.c
> --- main/libmpdemux/demux_rawaudio.c 2003-08-13 20:29:31.000000000 +0400
> +++ main.correct_read/libmpdemux/demux_rawaudio.c 2003-09-10 00:04:05.000000000 +0400
> @@ -68,7 +68,8 @@
> dp->pts = (spos - demuxer->movi_start) / (float)(sh_audio->wf->nAvgBytesPerSec);
> dp->pos = (spos - demuxer->movi_start);
>
> - stream_read(demuxer->stream,dp->buffer,l);
> + l = stream_read(demuxer->stream,dp->buffer,l);
> + resize_demux_packet(dp, l);
> ds_add_packet(ds,dp);
>
> return 1;
> ----
>
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
More information about the MPlayer-dev-eng
mailing list