Re: [MPlayer-dev-eng] [PATCH] compute correct length for theora videos
- Date: Mon, 12 May 2008 20:06:09 +0200
- From: Julian Kniephoff <Julian.Kniephoff@xxxxxx>
- Subject: Re: [MPlayer-dev-eng] [PATCH] compute correct length for theora videos
Am Montag, 12. Mai 2008 15:56:01 schrieb Julian Kniephoff:
>
> 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".
>
Lucky hunch ;). Changing the DEMUXER_CTRL_GET_PERCENT_POS case of
demux_ogg_control analogous to the original patch fixes the seek bar on my
system. Still the patch does not reuse code so I'll have yet another look
into it.
I hope I'm not getting annoying...
Thanks and regards,
Julian.
Index: libmpdemux/demux_ogg.c
===================================================================
--- libmpdemux/demux_ogg.c (Revision 26751)
+++ 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,12 +1551,32 @@
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:
if (ogg_d->final_granulepos<=0) return DEMUXER_CTRL_DONTKNOW;
- *(int *)arg=(os->lastpos*100) / ogg_d->final_granulepos;
+ 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;
+ *(int *)arg=(os->lastpos*100) / pos;
+ }
+ else
+ {
+ *(int *)arg=(os->lastpos*100) / ogg_d->final_granulepos;
+ }
return DEMUXER_CTRL_OK;
default:
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng