[MPlayer-dev-eng] [PATCH] Add size based support for -endpos in MPlayer

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jun 11 17:21:21 CEST 2011


On Sat, Jun 11, 2011 at 05:09:39PM +0200, Clément Bœsch wrote:
> On Sat, Jun 11, 2011 at 04:45:00PM +0200, Clément Bœsch wrote:
> > On Sat, Jun 11, 2011 at 04:21:32PM +0200, Clément Bœsch wrote:
> > > On Wed, Jan 05, 2011 at 04:22:12PM +0100, Reimar Döffinger wrote:
> > > [...]
> > > 
> > > > > -
> > > > > -// FIXME: add size based support for -endpos
> > > > > - if (end_at.type == END_AT_TIME &&
> > > > > -         !frame_time_remaining && end_at.pos <= mpctx->sh_video->pts)
> > > > > + if (!frame_time_remaining &&
> > > > > +     ((end_at.type == END_AT_TIME &&       mpctx->sh_video->pts >= end_at.pos) ||
> > > > > +      (end_at.type == END_AT_SIZE && stream_tell(mpctx->stream) >= end_at.pos)))
> > > > 
> > > > In principle fine, but maybe it's time to factor out this duplicated
> > > > code?
> > > > E.g. (not valid C, too lazy to look up the types)
> > > > static int is_at_end(&end_at, mpctx) {
> > > >     switch (end_at->type)
> > > >     {
> > > >     case END_AT_TIME:
> > > >         return mpctx->sh_video->pts >= end_at->pos;
> > > >     ...
> > > >     }
> > > >     return 0;
> > > > }
> > > > 
> > > > Particularly when extending this the switch is far more readable than
> > > > the if, too.
> > > 
> > > Patch attached. I'll apply it in 3 days.
> > > 
> > 
> > New patch attached, fixing pts for audio only files.
> > 
> 
> Alternate version attached to avoid recomputing audio pts.

I think that one's really nice.
Not sure if it will stay so in the long run, but I'd say go ahead.


More information about the MPlayer-dev-eng mailing list