| Valkka
    1.6.1
    OpenSource Video Management | 
Notation convention for handling presentation timestamps (PTS)
The underscore "_" tags "stream time". Stream timestamps are timestamps on each recorded frame: they can be far in the past or in the future.
The following equation holds:
(t_-t_0) = (t-t0)
where:
| Symbol | Explanation | 
|---|---|
| t_ | the file stream time | 
| t | the wallclock time | 
| t0_ | file stream reference time | 
| t0 | wallclock reference time | 
t0 is measured at the time instant when t0_ is set. This is done at seek.
We define a "reference time":
reftime = (t0 - t0_)
The we get a frame's wallclock time like this:
t = t_ + reftime
Where t_ is the frame's timestamp in the stream. You can think it as we're correcting a recorded frame's timestamp to present time.
[ check: t = t_ + reftime <=> t = t_ + t0 - t0_ <=> t - t0 <=> t_ - t0_ ]
Different actions for file streams
For file streams, a target_time_ is set. Frames are consumed until t_>=target_time_
| Action | What it does | 
|---|---|
| open | Open file, do seek(0_) | 
| seek | set target_time_, once t_>=target_time_, stop | 
| play | set target_time_, keep consuming frames with t_>=target_time_. Update target_time_. | 
| stop | Stop | 
| close | Deregister file | 
| Symbol | Explanation | 
|---|---|
| t_ | frame's timestamp | 
| t | the wallclock time | 
| tb | buffering time | 
Define "relative timestamp" :
trel = t_ - t + tb = t_ - (t-tb) = t_ - delta
* [fifo] * => in => out * [young old] * * absolute timestamps * 90 80 70 60 50 40 30 20 10 * * relative timestamps trel: * .. with delta=(t-tb)=45 * | * 45 35 25 15 05 -15 -25 -35 -35 * * negative values == older frames, positive values == younger frames *
extreme cases: