[DVDnav-discuss] [PATCH] "dvdnav_jump_to_sector" as an alternative to "dvdnav_time_search" (REV 5: combined args to structs)
gnosygnu at gmail.com
Thu Apr 19 06:37:40 CEST 2012
> I would like to see a API change before this goes in. A parameter
> saying if you want closest time before or after the passed time.
> Reason for this is that if you are skipping back, you don't want the
> situation where you end up after the current location even if you ask
> for a skip back by one millisecond. Similar but opposite occurs in the
> forward case.
> It also applies if you try to do a poor mans reverse playback. By
> doing seeks and decoding one frame. You need to get to previous
> keyframe. A keyframe after current location is no good.
Thanks for the reply. The request is reasonable, however my method
doesn't know *exactly* what time gets chosen. I know this sounds
strange, but from what I know (and what I know may very well be
wrong), there is no way to get an exact time with the IFOs only.
For example, let's say you want to jump to the 15 second mark. In
simplified form, my patch does the following.
- find out where 15 seconds is on the time map.
If there is a time map with a 4 second interval, it is between time
map entries 3 (12 seconds) and 4 (16 seconds)
- find out the corresponding VOBUs for the time map entries
Let's say that entry 3 is at VOBU 21, and entry 4 is at VOBU 29.
- interpolate the VOBU based on the time
The 15 second mark is .75 between 12 seconds and 16 seconds
.75 of the distance between VOBU 21 and VOBU 29 is VOBU 27
- jump to the sector for VOBU 27
Unfortunately, VOBU 27 has no specifically defined time. Generally it
is around 15.0 seconds, but since all VOBUs are not the same duration
it could be 15.0 or 14.9 or 15.1. Without knowing whether or not VOBU
27 is 14.9 (before) or 15.1 (after), there's no way to adjust for the
What we really need is a VOBU to time map. Unfortunately, the IFOs
don't provide this data. They only provide a VOBU to sector map and a
TimeInterval to sector map (with TimeInterval usually being defined in
large 4 second blocks). Note that the TimeInterval map is not precise
either, so that when it says that time 4 seconds is at sector 876, it
doesn't mean that sector 876 is exactly at time 4.00, but somewhere
near time 4.00.
In short, I only see two ways of implementing the extra parameter.
Neither are really good.
1) Open up the VOB to find out the exact timestamp for VOBU 27.
Unfortunately this would require even more code on top of what I
wrote. I looked at this last year, and I don't think there is code in
dvdread to easily extract the timestamp for a VOBU from a VOB.
Also, I would think that there is a performance hit in doing a
disc-read of VOBU 27 to get its timestamp. An earlier version of my
patch was incorrectly reading the IFO on each jump, and this extra
"read" was noticeable to Roger.
2) Create another method called
"dvdnav_jump_to_sector_by_time_precise". This would try to use the
parameter by doing the following:
- call "dvdnav_jump_to_sector_by_time" for the given time. For
example, this will jump to VOBU 27
- call "dvdnav_get_position" to get the time for VOBU 27. For example,
let's say it finds out the time is 14.90
- call "dvdnav_jump_to_sector_by_time" again b/c 14.90 is < 15.00 and
the parameter specified "get me a > time".
The problem with this approach is the double-jump. This could look
potentially "jerky". Also, I'm not sure how reliable the get_time will
be (will the VM still be at 14.90 after the jump or could it have
advanced to 15.00).
Let me know your thoughts on the above.
More information about the DVDnav-discuss