[FFmpeg-devel] [PATCH] First shot at AVCHD seeking via new seeking API

Ivan Schreter schreter
Sat Aug 15 15:03:26 CEST 2009

Michael Niedermayer wrote:
> On Sun, Aug 09, 2009 at 09:48:18AM +0200, Ivan Schreter wrote:
>> Hi Michael,
>> Michael Niedermayer wrote:
>>> [...]
>>> ive not checked to the code so i possibly miss somethng but timestamp
>>> code must be exact, that is for example if you compare 2 timestamps
>>> from 2 streams these must not be rescaled to AV_TIME_BASE but rather
>>> the compare must be done exactly
>> But what if the streams have different st->time_base? Then it's impossible 
>> to compare directly, but it has to be rescaled to a common time base.
>> Since normally streams have siginificantly less resolution than 
>> AV_TIME_BASE, comparison with values rescaled to AV_TIME_BASE is as exact 
>> as with timestamps directly, but it takes into account the possibility of 
>> different time bases for each stream. Right?
> no
> ill copy & paste from the nut spec on how to compare timestamps exactly
> for more elaborate explanation see the spec yourself
>     if (convert_ts(a, a_timebase, b_timebase) < b) return -1;
>     if (convert_ts(b, b_timebase, a_timebase) < a) return  1;
>     return 0;
> (convert_ts here must round down and be exact, the nut spec also
>  explains how to do this in C but we already have a fitting function for
>  it)
Yes, I can do it this way.

BUT: This makes the code more complex and marginally slower, as I have 
to keep track of which time base was used for which timestamp, as not 
only comparisons of timestamps are done, but also computation of minimal 
distance with timestamps involving various streams. Especially for the 
computation of minimal distance, I have to create a synthetic time base 
as the product of two time bases used for two timestamps to subtract, to 
exactly represent the distance without loss of precision.

Is that OK for you?

Thanks & regards,


More information about the ffmpeg-devel mailing list