[MPlayer-dev-eng] [PATCH] libmpdemux/demux_audio: Fix audio time length.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri May 18 19:03:17 CEST 2012


On Tue, Jan 17, 2012 at 07:45:02PM +0100, Benoît Thébaudeau wrote:
> Reimar,
> 
> > > diff -Nrdup mplayer.orig/libmpdemux/demux_audio.c
> > > mplayer/libmpdemux/demux_audio.c
> > > --- mplayer.orig/libmpdemux/demux_audio.c	2012-01-17
> > > 15:03:29.757246846 +0100
> > > +++ mplayer/libmpdemux/demux_audio.c	2012-01-17 15:11:47.549260678
> > > +0100
> > > @@ -787,7 +787,9 @@ static void demux_close_audio(demuxer_t*
> > >
> > >  static int demux_audio_control(demuxer_t *demuxer,int cmd, void
> > >  *arg){
> > >      sh_audio_t *sh_audio=demuxer->audio->sh;
> > > -    int audio_length = sh_audio->i_bps ? demuxer->movi_end /
> > > sh_audio->i_bps : 0;
> > > +    off_t movi_size = (demuxer->movi_end > demuxer->movi_start) ?
> > > +                      demuxer->movi_end - demuxer->movi_start :
> > > demuxer->movi_end;
> > > +    int audio_length = sh_audio->i_bps ? movi_size /
> > > sh_audio->i_bps : 0;
> >
> > Hm, is there much point/sense in falling back to just movi_end?
> > I would have suggest something like e.g.
> > int audio_length = sh_audio->i_bps && demuxer->movi_end >
> > demuxer->movi_start ? ... : 0;
> 
> I don't know. I just put that because it was the previous code, and because
> it might be a better length indication than 0 even if not accurate.
> 
> I attach the patch with your suggestion.
> 
> Can someone also take a look at these?
> http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2012-January/069820.html
> http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2012-January/069821.html
> 
> Benoît

> diff -Nrdup mplayer.orig/libmpdemux/demux_audio.c mplayer/libmpdemux/demux_audio.c
> --- mplayer.orig/libmpdemux/demux_audio.c	2012-01-17 15:03:29.757246846 +0100
> +++ mplayer/libmpdemux/demux_audio.c	2012-01-17 19:31:57.477694450 +0100
> @@ -787,7 +787,8 @@ static void demux_close_audio(demuxer_t*
>  
>  static int demux_audio_control(demuxer_t *demuxer,int cmd, void *arg){
>      sh_audio_t *sh_audio=demuxer->audio->sh;
> -    int audio_length = sh_audio->i_bps ? demuxer->movi_end / sh_audio->i_bps : 0;
> +    int audio_length = sh_audio->i_bps && demuxer->movi_end > demuxer->movi_start ?
> +                       (demuxer->movi_end - demuxer->movi_start) / sh_audio->i_bps : 0;
>      da_priv_t* priv = demuxer->priv;
>  
>      switch(cmd) {

Thanks, finally committed.


More information about the MPlayer-dev-eng mailing list