Debian Codegraph @

doc/searching.jump_to_time.readme

raw
1 PURPOSE:
2 --------
3 This file contains separate documentation to cover the functionality
4 in the dvdnav_jump_to_sector_by_time patch.
5
6
7 EXAMPLE:
8 --------
9 dvdnav_jump_to_sector_by_time(p_sys->dvdnav, 90000, 0);
10
11 This will jump to the 10 second mark in the current DVD title.
12
13 (Note that 90000 is in PTS, which is defined as PTS = time_in_ms * 90)
14
15
16 KEY POINTS
17 ----------
18 * dvdnav_jump_to_sector_by_time is a large patch. See BACKGROUND
19 and DETAIL for an explanation on why the length is required
20
21 * dvdnav_jump_to_sector_by_time is a standalone proc and introduces no
22 dependencies in the rest of searching.c.
23
24 * Libraries can choose not to call the dvdnav_jump_to_sector_by_time
25 and libdvdnav is otherwise unaffected
26
27
28 BACKGROUND
29 ----------
30 The Jump_to_sector_by_time patch is an alternative to dvdnav_time_search.
31 Note that dvdnav_time_search is marked 'FIXME: right now, this function
32 does not use the time tables but interpolates only the cell times'
33
34 The interpolation method is usually inaccurate: it interpolates using
35 cells and sectors, but one sector does not equal one fixed unit of time.
36 For example, consider a 10:00 cell that is 1000 sectors long.
37 dvdnav_time_search reasons that 5:00 is 50% between 0:00 and 10:00,
38 so it selects sector 500 since it is 50% between 500 and 1000.
39 However this assumes that all sectors are the same length in time.
40 In actuality, they are not, and jumping to sector 500 may actually
41 jump instead to another time, like 5:12.
42
43 The Jump_to_sector_by_time patch attempts to jump to a given time
44 by using the aforementioned "time tables". Specifically it
45 uses the time map and the vobu address map. Note that even with these
46 two items, the patch is not simple, nor entirely accurate. The complexity
47 will be evident in the DETAIL section below. The inaccuracy exists
48 because interpolation is still used. Note that this interpolation
49 is at a much smaller level: time map entries (4 - 5 seconds long)
50 and vobus (1/2 second long) instead of dvdnav_time_search's
51 cells (which may be multiple minutes) and sectors (which doesn't
52 really correspond to time)
53
54 A completely accurate method would use this proc to get the starting
55 VOBU, and then scan each VOBU's NAV packet time in the VOB files
56 (instead of interpolating). However, this would require significant changes
57 to dvdread, and may have some performance overhead. (Specifically,
58 reading the VOB file and scanning through the VOBUs to find the matching time)
59
60
61 DETAIL
62 ------
63 From a broad perspective, Jump_to_sector_by_time works like this:
64
65 (1) Find the two time map entries around a given time
66 (2) Get the vobus of these two time map entries
67 (3) Get the sector of the jump_time through interpolation of the vobus
68
69 For clarity's sake, I will repeat the above with fabricated data
70 (1) Find the two time map entries around a given time
71 Given time 56...
72 Time map index 10 is identified as 55 seconds
73 56 seconds must be between time map entries 10 and 11
74 (2) Get the vobus of these two time map entries
75 Time entry 10 is at sector 193 which is vobu 405
76 Time entry 11 is at sector 303 which is vobu 455
77 (3) Get the sector of the jump_time through interpolation of the vobus
78 56 is 20% of the way between 55 and 60
79 415 is 20% of the way between 405 and 455
80 320 is the corresponding sector of vobu 415
81
82 Note that step (1) actually requires more sub-steps
83 (1a) Find the cell for a given time
84 (1b) Find the tmap entries around the cell's start sector
85 (1c) Find the vobus for these tmap entries and cell start
86 (1d) Interpolate the time of earlier tmap entry
87 (1e) Find the tmap entries around jump_time
88 (2) Get the vobus of these two time map entries
89 (3) Get the sector of the jump_time through interpolation of the vobus
90
91 Again, here is the above with some fabricated data.
92
93 (I try to represent the tables visually below. It was written with a
94 fixed-width font.
95 My apologies if it does not show up formatted well.)
96
97 (1a) Find the cell for a given time
98 Given time 56...
99 ---- -------- -------- ---------- ----------
100 cell bgn_time end_time bgn_sector end_sector
101 ---- -------- -------- ---------- ----------
102 1 0 28 0 99
103 ---> 2 29 600 100 1000
104 3 601 900 1001 1400
105 ...
106 **** Cell 2 encloses 56.
107
108
109 (1b) Find the tmap entries around the cell's start sector
110 ---- ------
111 tmap sector
112 ---- ------
113 ...
114 3 71
115 ---> 4 88
116 ---> 5 108
117 6 121
118 ...
119 **** tmap entries 4 and 5 enclose cell start sector of 100.
120
121
122 (1c) Find the vobus for these tmap entries and cell start
123 ---- ------
124 vobu sector
125 ---- ------
126 ...
127 ---> 200 88
128 ...
129 ---> 208 100
130 209 102
131 ---> 210 108
132 ...
133 **** 200, 208 and 210 are the relevant vobus
134
135
136 (1d) Interpolate the time of earlier tmap entry
137 208 is 80% of the way between 200 and 210
138 4 secs is 80% of 5 secs
139 25 is the time-point when subtracting 4 from 29 (cell_bgn)
140 vobu 200 is at 25 seconds
141 **** 25 secs is the calculated time of tmap idx 4
142
143
144 (1e) Find the tmap entries around jump_time
145 ---- ---- ------
146 tmap time sector
147 ---- ---- ------
148 4 25
149 5 30
150 6 35
151 7 40
152 8 45
153 9 50
154 ---> 10 55 193
155 ---> 11 60 303
156 ...
157 **** 56 must be between tmap entries 10 and 11
158
159
160 (2) Get the vobus of these two time map entries
161 ---- ------
162 vobu sector
163 ---- ------
164 ...
165 ---> 405 193
166 ...
167 415 320
168 ...
169 ---> 455 503
170 ...
171 **** 405 and 445 are the relevant vobus
172
173
174 (3) Get the sector of the jump_time through interpolation of the vobus
175 56 is 20% of the way between 55 and 60
176 415 is 20% of the way between 405 and 455
177 320 is the corresponding sector of vobu 415
178 **** 320 is the closest vobu sector for 56 secs