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

Clément Bœsch ubitux at gmail.com
Sat Jun 11 17:09:39 CEST 2011


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.

-- 
Clément B.
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 33579)
+++ mplayer.c	(working copy)
@@ -1801,6 +1801,15 @@
            audio_out->get_delay();
 }
 
+static int is_at_end(MPContext *mpctx, m_time_size_t *end_at, double pts)
+{
+    switch (end_at->type) {
+    case END_AT_TIME: return end_at->pos <= pts;
+    case END_AT_SIZE: return end_at->pos <= stream_tell(mpctx->stream);
+    }
+    return 0;
+}
+
 static int check_framedrop(double frame_time)
 {
     // check for frame-drop:
@@ -3802,8 +3811,7 @@
                 if (!quiet)
                     print_status(a_pos, 0, 0);
 
-                if (end_at.type == END_AT_TIME && end_at.pos < a_pos ||
-                    end_at.type == END_AT_SIZE && end_at.pos < stream_tell(mpctx->stream))
+                if (is_at_end(mpctx, &end_at, a_pos))
                     mpctx->eof = PT_NEXT_ENTRY;
                 update_subtitles(NULL, a_pos, mpctx->d_sub, 0);
                 update_osd_msg();
@@ -3923,9 +3931,8 @@
                         mpctx->eof = PT_NEXT_ENTRY;
                 }
 
-                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)))
+                if (!frame_time_remaining && is_at_end(mpctx, &end_at,
+                                                       mpctx->sh_video->pts))
                     mpctx->eof = PT_NEXT_ENTRY;
             } // end if(mpctx->sh_video)
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20110611/0f4d63d2/attachment.asc>


More information about the MPlayer-dev-eng mailing list