Web lists-archives.org

Re: [MPlayer-dev-eng] [PATCH] compute correct length for theora videos




Am Montag, 12. Mai 2008 02:28:19 schrieb The Wanderer:
> Julian Kniephoff wrote:
> > Hello,
> >
> > this is a patch to let mplayer compute the correct duration of a
> > theora video when libtheora support is compiled in (especially when
> > running in "-identify mode"). To not repeat myself I'll just post
> > links to the important posts of the bug report in the mplayer-users
> > list. The baisc concept of the patch is also explained there:
> >
> > http://lists.mplayerhq.hu/pipermail/mplayer-users/2007-December/070943.ht
> >ml http://lists.mplayerhq.hu/pipermail/mplayer-users/2008-May/072933.html
> >
> > If this doesn't suffice, please ask for further clarification.
> >
> > The patch is written against the current SVN version (Revision 26728
> > according to "svn update", "mplayer" identifies itself as "MPlayer
> > 1.0rc2-4.2.3")
>
> This is not consistent; an MPlayer version which had been compiled from
> SVN sources would identify itself as "MPlayer dev-SVN-r#####-X.Y.Z",
> giving the revision number and the compiler version.
>
OK sorry, dumb fault on my site >.<. The mplayer compiled from the svn is 
MPlayer dev-SVN-r26728-4.2.3. I attached another patch, this time created 
with "svn diff" after another "svn update". The differences however didn't 
change i think...

Concerning the other two ansers: Yea, sorry for that, too. I only tested 
the "-identify-case" because thats the one that brought me to this bug (it is 
used in devede to calculate the size of the final DVD).

I also saw, that actually the values for the calculation are corrected 
somewhere and it confused me, too - however the result speaks for itself: The 
resulting length is incorrect and my patch fixes that.

I have to take a look at the code again because I don't understand it 
completely, yet. However concerning the seek bar, I think the problem 
directly lies under the lines I changed: There the "wrong" final_granulepos 
value is also used without correction to calculate the current "position".

Regards,
Julian.
Index: libmpdemux/demux_ogg.c
===================================================================
--- libmpdemux/demux_ogg.c	(Revision 26748)
+++ libmpdemux/demux_ogg.c	(Arbeitskopie)
@@ -113,6 +113,8 @@
   vorbis_info      vi;
   int vi_initialized;
 
+  int gshift;
+
   void *ogg_d;
 } ogg_stream_t;
 
@@ -881,6 +883,7 @@
 				      sh_v->bih->biWidth*sh_v->bih->biHeight);
 	    ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps;
 	    ogg_d->subs[ogg_d->num_sub].theora = 1;
+	    ogg_d->subs[ogg_d->num_sub].gshift = theora_granule_shift (&inf);
 	    ogg_d->subs[ogg_d->num_sub].id = n_video;
 	    n_video++;
 	    mp_msg(MSGT_DEMUX,MSGL_INFO,
@@ -1548,7 +1551,17 @@
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
 	    if (ogg_d->final_granulepos<=0) return DEMUXER_CTRL_DONTKNOW;
-	    *(double *)arg=(double)ogg_d->final_granulepos / rate;
+	    if (os->theora)
+            {
+                int64_t pos = ogg_d->final_granulepos >> os->gshift;
+                int64_t iframemask = (1 << os->gshift) - 1;
+                pos += ogg_d->final_granulepos & iframemask;
+                *(double *)arg=(double)pos / rate;
+            }
+            else
+            {
+                *(double *)arg=(double)ogg_d->final_granulepos / rate;
+            }
 	    return DEMUXER_CTRL_GUESS;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng