[MPlayer-dev-eng] [Patch] get_total_time for ogg

Moritz Bunkus moritz at bunkus.org
Mon Nov 10 10:24:52 CET 2003


Hi,

> +  int64_t final_granulepos;

If final_granulepos is 64bits wide then don't use %d later.

>        if(flags || (os->vorbis && op.granulepos >= 0)) {
> +        if(index_mode == 2) {
>  	ogg_d->syncpoints = (ogg_syncpoint_t*)realloc(ogg_d->syncpoints,(ogg_d->num_syncpoint+1)*sizeof(ogg_syncpoint_t));
>  	ogg_d->syncpoints[ogg_d->num_syncpoint].granulepos = op.granulepos;
>  	ogg_d->syncpoints[ogg_d->num_syncpoint].page_pos = (ogg_page_continued(page) && p == 0) ? last_pos : pos;
>  	ogg_d->num_syncpoint++;
>        }
> +        ogg_d->final_granulepos = op.granulepos;
> +      }

Storing only the granulepos and using later some rate in order to
calculate the time is fishy, IMHO. You should store the biggest
timestamp instead, because at this place you know which stream the
granulepos belongs to (and by which rate you have to divide it).

> +	case DEMUXER_CTRL_GET_PERCENT_POS:
> +	    if (ogg_d->final_granulepos<=0) return DEMUXER_CTRL_DONTKNOW;
> +	    *((int *)arg)=(int)( (os->lastpos*100) / ogg_d->final_granulepos);
> +	    return DEMUXER_CTRL_OK;

Ok, you do need the granulepos. Then store both.

I'll have to test this patch later.

-- 
 ==> Ciao, Mosu (Moritz Bunkus)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20031110/f8b423fe/attachment.pgp>


More information about the MPlayer-dev-eng mailing list