[MPlayer-dev-eng] [PATCH] compute correct length for theora videos
- Date: Sun, 11 May 2008 01:01:25 +0200
- From: Julian Kniephoff <Julian.Kniephoff@xxxxxx>
- Subject: [MPlayer-dev-eng] [PATCH] compute correct length for theora videos
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.html
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") and
tested on my system (Kernel 2.6.24.16, 32 bit linux but running on a 64 bit
amd cpu; libtheora is version 1.0~beta2-2 from the Ubuntu repositories, if
this is important).
Thanks in advance,
Julian.
--- mplayer.orig/libmpdemux/demux_ogg.c 2008-05-11 00:03:09.000000000 +0200
+++ mplayer/libmpdemux/demux_ogg.c 2008-05-11 00:12:19.000000000 +0200
@@ -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