Mercurial > mplayer.hg
annotate libmpdemux/open.c @ 3231:4bc4354ec88e
Added support for upsampling since dxr3/h+ only supports 44100Hz and 48000Hz, currently it only works on 44100/(2*ratio)
Reverted get_delay to return a properly calculated value instead of 0.0
author | mswitch |
---|---|
date | Fri, 30 Nov 2001 22:18:51 +0000 |
parents | b01551d725d4 |
children | caac174877b7 |
rev | line source |
---|---|
1467 | 1 |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <string.h> | |
5 #include <unistd.h> | |
6 #include <fcntl.h> | |
7 | |
8 #include "config.h" | |
1567 | 9 #include "mp_msg.h" |
1584 | 10 #include "help_mp.h" |
1467 | 11 |
1468 | 12 #ifdef __FreeBSD__ |
13 #include <sys/cdrio.h> | |
14 #endif | |
15 | |
1467 | 16 #include "stream.h" |
1482 | 17 #include "demuxer.h" |
1467 | 18 |
19 #ifdef STREAMING | |
20 #include "url.h" | |
21 #include "network.h" | |
22 static URL_t* url; | |
23 #endif | |
24 | |
1596 | 25 int dvd_title=0; |
26 int dvd_chapter=1; | |
27 int dvd_angle=1; | |
28 | |
29 #ifdef USE_DVDREAD | |
30 | |
31 #include <dvdread/dvd_reader.h> | |
32 #include <dvdread/ifo_types.h> | |
33 #include <dvdread/ifo_read.h> | |
34 #include <dvdread/nav_read.h> | |
1875 | 35 |
36 #define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) | |
37 | |
38 /* | |
39 * Try to autodetect the libdvd-0.9.0 library | |
40 * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines | |
41 * DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to | |
42 * <dvdread/dvd_reader.h>) | |
43 */ | |
44 #if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) | |
45 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0) | |
46 #else | |
47 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0) | |
48 #endif | |
49 | |
2935 | 50 char * dvd_audio_stream_types[8] = |
51 { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; | |
1596 | 52 |
53 #endif | |
54 | |
1467 | 55 extern int vcd_get_track_end(int fd,int track); |
56 | |
2790 | 57 #ifdef USE_TV |
58 #include "tv.h" | |
2802 | 59 tvi_handle_t *tv_handler; |
2931 | 60 |
61 extern int stream_open_tv(stream_t *stream, tvi_handle_t *tvh); | |
2790 | 62 #endif |
63 | |
1467 | 64 // Open a new stream (stdin/file/vcd/url) |
65 | |
66 stream_t* open_stream(char* filename,int vcd_track,int* file_format){ | |
67 stream_t* stream=NULL; | |
68 int f=-1; | |
69 off_t len; | |
70 #ifdef VCD_CACHE | |
71 int vcd_cache_size=128; | |
72 #endif | |
73 #ifdef __FreeBSD__ | |
74 int bsize = VCD_SECTOR_SIZE; | |
75 #endif | |
76 | |
77 //============ Open VideoCD track ============== | |
78 if(vcd_track){ | |
79 int ret,ret2; | |
1596 | 80 if(!filename) filename=DEFAULT_CDROM_DEVICE; |
1467 | 81 f=open(filename,O_RDONLY); |
1584 | 82 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,filename);return NULL; } |
1467 | 83 vcd_read_toc(f); |
84 ret2=vcd_get_track_end(f,vcd_track); | |
1584 | 85 if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;} |
1467 | 86 ret=vcd_seek_to_track(f,vcd_track); |
1584 | 87 if(ret<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");return NULL;} |
1467 | 88 // seek_to_byte+=ret; |
1567 | 89 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); |
1467 | 90 #ifdef VCD_CACHE |
91 vcd_cache_init(vcd_cache_size); | |
92 #endif | |
93 #ifdef __FreeBSD__ | |
94 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { | |
95 perror ( "Error in CDRIOCSETBLOCKSIZE"); | |
96 } | |
97 #endif | |
98 stream=new_stream(f,STREAMTYPE_VCD); | |
99 stream->start_pos=ret; | |
100 stream->end_pos=ret2; | |
101 return stream; | |
102 } | |
103 | |
1596 | 104 //============ Open DVD title ============== |
105 #ifdef USE_DVDREAD | |
106 if(dvd_title){ | |
2050 | 107 // int ret,ret2; |
1596 | 108 dvd_priv_t *d; |
109 int ttn,pgc_id,pgn; | |
110 dvd_reader_t *dvd; | |
111 dvd_file_t *title; | |
112 ifo_handle_t *vmg_file; | |
113 tt_srpt_t *tt_srpt; | |
114 ifo_handle_t *vts_file; | |
115 /** | |
116 * Open the disc. | |
117 */ | |
118 if(!filename) filename=DEFAULT_DVD_DEVICE; | |
119 dvd = DVDOpen(filename); | |
120 if( !dvd ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
121 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename); |
1596 | 122 return NULL; |
123 } | |
124 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
125 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait); |
1596 | 126 |
127 /** | |
128 * Load the video manager to find out the information about the titles on | |
129 * this disc. | |
130 */ | |
131 vmg_file = ifoOpen( dvd, 0 ); | |
132 if( !vmg_file ) { | |
133 mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n"); | |
134 DVDClose( dvd ); | |
135 return NULL; | |
136 } | |
137 tt_srpt = vmg_file->tt_srpt; | |
138 /** | |
139 * Make sure our title number is valid. | |
140 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
141 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles, |
1596 | 142 tt_srpt->nr_of_srpts ); |
143 if( dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
144 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title); |
1596 | 145 ifoClose( vmg_file ); |
146 DVDClose( dvd ); | |
147 return NULL; | |
148 } | |
149 --dvd_title; // remap 1.. -> 0.. | |
150 /** | |
151 * Make sure the chapter number is valid for this title. | |
152 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
153 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters, |
1596 | 154 tt_srpt->title[dvd_title].nr_of_ptts ); |
155 if( dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
156 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter); |
1596 | 157 ifoClose( vmg_file ); |
158 DVDClose( dvd ); | |
159 return NULL; | |
160 } | |
161 --dvd_chapter; // remap 1.. -> 0.. | |
162 /** | |
163 * Make sure the angle number is valid for this title. | |
164 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
165 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles, |
1596 | 166 tt_srpt->title[dvd_title].nr_of_angles ); |
167 if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) { | |
1977 | 168 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle); |
1596 | 169 ifoClose( vmg_file ); |
170 DVDClose( dvd ); | |
171 return NULL; | |
172 } | |
1617 | 173 --dvd_angle; // remap 1.. -> 0.. |
1596 | 174 /** |
175 * Load the VTS information for the title set our title is in. | |
176 */ | |
177 vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); | |
178 if( !vts_file ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
179 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO, |
1596 | 180 tt_srpt->title[dvd_title].title_set_nr ); |
181 ifoClose( vmg_file ); | |
182 DVDClose( dvd ); | |
183 return NULL; | |
184 } | |
185 /** | |
186 * We've got enough info, time to open the title set data. | |
187 */ | |
188 title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, | |
189 DVD_READ_TITLE_VOBS ); | |
190 if( !title ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
191 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs, |
1596 | 192 tt_srpt->title[dvd_title].title_set_nr ); |
193 ifoClose( vts_file ); | |
194 ifoClose( vmg_file ); | |
195 DVDClose( dvd ); | |
196 return NULL; | |
197 } | |
198 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
199 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDopenOk); |
1596 | 200 // store data |
201 d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t)); | |
202 d->dvd=dvd; | |
203 d->title=title; | |
204 d->vmg_file=vmg_file; | |
205 d->tt_srpt=tt_srpt; | |
206 d->vts_file=vts_file; | |
207 | |
208 /** | |
2935 | 209 * Check number of audio channels and types |
210 */ | |
211 { | |
212 int ac3aid = 128; | |
213 int mpegaid = 0; | |
214 int pcmaid = 160; | |
215 | |
216 d->nr_of_channels=0; | |
217 | |
218 if ( vts_file->vts_pgcit ) | |
219 { | |
220 int i; | |
221 for ( i=0;i<8;i++ ) | |
222 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 ) | |
223 { | |
224 audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; | |
225 int language = 0; | |
226 char tmp[] = "unknown"; | |
227 | |
228 if ( audio->lang_type == 1 ) | |
229 { | |
230 language=audio->lang_code; | |
231 tmp[0]=language>>8; | |
232 tmp[1]=language&0xff; | |
233 tmp[2]=0; | |
234 } | |
235 | |
236 d->audio_streams[d->nr_of_channels].language=language; | |
237 d->audio_streams[d->nr_of_channels].id=0; | |
238 switch ( audio->audio_format ) | |
239 { | |
240 case 0: // ac3 | |
241 case 6: // dts | |
242 d->audio_streams[d->nr_of_channels].id=ac3aid; | |
243 ac3aid++; | |
244 break; | |
245 case 2: // mpeg layer 1/2/3 | |
246 case 3: // mpeg2 ext | |
247 d->audio_streams[d->nr_of_channels].id=mpegaid; | |
248 mpegaid++; | |
249 break; | |
250 case 4: // lpcm | |
251 d->audio_streams[d->nr_of_channels].id=pcmaid; | |
252 pcmaid++; | |
253 break; | |
254 } | |
255 | |
256 mp_msg(MSGT_OPEN,MSGL_V,"[open] audio stream: %d audio format: %s language: %s aid: %d\n", | |
257 d->nr_of_channels, | |
258 dvd_audio_stream_types[ audio->audio_format ], | |
259 tmp, | |
260 d->audio_streams[d->nr_of_channels].id | |
261 ); | |
262 | |
263 d->nr_of_channels++; | |
264 } | |
265 } | |
3048 | 266 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); |
267 } | |
268 | |
269 /** | |
270 * Check number of subtitles and language | |
271 */ | |
272 { | |
273 int i; | |
274 | |
275 d->nr_of_subtitles=0; | |
276 for ( i=0;i<32;i++ ) | |
277 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 ) | |
278 { | |
279 subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; | |
280 int language = 0; | |
281 char tmp[] = "unknown"; | |
282 | |
283 if ( subtitle->type == 1 ) | |
284 { | |
285 language=subtitle->lang_code; | |
286 tmp[0]=language>>8; | |
287 tmp[1]=language&0xff; | |
288 tmp[2]=0; | |
289 } | |
290 | |
291 d->subtitles[ d->nr_of_subtitles ].language=language; | |
292 d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; | |
293 | |
294 mp_msg(MSGT_OPEN,MSGL_V,"[open] subtitle ( sid ): %d language: %s\n", | |
295 d->nr_of_subtitles, | |
296 tmp | |
297 ); | |
298 d->nr_of_subtitles++; | |
299 } | |
300 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); | |
2935 | 301 } |
302 | |
303 /** | |
1596 | 304 * Determine which program chain we want to watch. This is based on the |
305 * chapter number. | |
306 */ | |
307 ttn = tt_srpt->title[ dvd_title ].vts_ttn; // local | |
308 pgc_id = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgcn; // local | |
309 pgn = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgn; // local | |
310 d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
311 d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here | |
312 d->packs_left=-1; // for Navi stuff | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
313 d->angle_seek=0; |
1596 | 314 |
315 if( d->cur_pgc->cell_playback[d->cur_cell].block_type | |
316 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
317 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
318 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
319 mp_msg(MSGT_DVD,MSGL_V, "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); | |
320 | |
321 // ... (unimplemented) | |
322 // return NULL; | |
323 stream=new_stream(-1,STREAMTYPE_DVD); | |
324 stream->start_pos=(off_t)d->cur_pack*2048; | |
325 //stream->end_pos=0; | |
326 stream->priv=(void*)d; | |
327 return stream; | |
328 } | |
329 #endif | |
330 | |
2790 | 331 #ifdef USE_TV |
332 //============ Check for TV-input ==== | |
2931 | 333 if (tv_param_on == 1) |
2790 | 334 { |
2931 | 335 /* create stream */ |
336 stream = new_stream(-1, STREAMTYPE_TV); | |
337 if (!stream) | |
338 return(NULL); | |
339 | |
340 /* create tvi handler */ | |
2790 | 341 tv_handler = tv_begin(); |
342 if (!tv_handler) | |
343 return(NULL); | |
2931 | 344 |
345 /* preinit */ | |
346 if (!tv_init(tv_handler)) | |
347 goto tv_err; | |
348 | |
349 if (!stream_open_tv(stream, tv_handler)) | |
350 goto tv_err; | |
351 | |
352 return(stream); | |
353 | |
354 /* something went wrong - uninit */ | |
355 tv_err: | |
2837 | 356 tv_uninit(tv_handler); |
2802 | 357 return(NULL); |
2790 | 358 } |
359 #endif | |
360 | |
1467 | 361 //============ Open STDIN ============ |
362 if(!strcmp(filename,"-")){ | |
363 // read from stdin | |
1584 | 364 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN); |
1467 | 365 f=0; // 0=stdin |
366 stream=new_stream(f,STREAMTYPE_STREAM); | |
367 return stream; | |
368 } | |
369 | |
370 #ifdef STREAMING | |
371 url = url_new(filename); | |
372 if(url) { | |
373 (*file_format)=autodetectProtocol( url, &f ); | |
374 if( (*file_format)==DEMUXER_TYPE_UNKNOWN ) { | |
1584 | 375 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename); |
1467 | 376 url_free(url); |
377 return NULL; | |
378 } | |
3045
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
379 //if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, url->url); return NULL; } |
1584 | 380 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname ); |
1467 | 381 stream=new_stream(f,STREAMTYPE_STREAM); |
3045
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
382 if( streaming_start( stream , url, *file_format )<0){ |
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
383 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename); |
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
384 url_free(url); |
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
385 return NULL; |
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
386 } |
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
387 url_free(url); |
2315 | 388 return stream; |
1467 | 389 } |
390 #endif | |
391 | |
392 //============ Open plain FILE ============ | |
393 f=open(filename,O_RDONLY); | |
1584 | 394 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; } |
1467 | 395 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); |
396 if (len == -1) | |
397 perror("Error: lseek failed to obtain video file size"); | |
398 else | |
399 #ifdef _LARGEFILE_SOURCE | |
1567 | 400 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len); |
1467 | 401 #else |
1567 | 402 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len); |
1467 | 403 #endif |
404 stream=new_stream(f,STREAMTYPE_FILE); | |
405 stream->end_pos=len; | |
406 return stream; | |
407 | |
408 } | |
1596 | 409 |
410 | |
411 #ifdef USE_DVDREAD | |
412 | |
413 static int dvd_next_cell(dvd_priv_t *d){ | |
414 int next_cell=d->cur_cell; | |
1616 | 415 |
416 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next1=0x%X \n",next_cell); | |
1596 | 417 |
418 if( d->cur_pgc->cell_playback[ next_cell ].block_type | |
419 == BLOCK_TYPE_ANGLE_BLOCK ) { | |
420 while(next_cell<d->cur_pgc->nr_of_cells){ | |
421 if( d->cur_pgc->cell_playback[next_cell].block_mode | |
422 == BLOCK_MODE_LAST_CELL ) break; | |
423 ++next_cell; | |
424 } | |
425 } | |
1616 | 426 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X \n",next_cell); |
1596 | 427 |
428 ++next_cell; | |
429 if(next_cell>=d->cur_pgc->nr_of_cells) return -1; // EOF | |
430 if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){ | |
431 next_cell+=dvd_angle; | |
432 if(next_cell>=d->cur_pgc->nr_of_cells) return -1; // EOF | |
433 } | |
1616 | 434 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X \n",next_cell); |
1596 | 435 return next_cell; |
436 } | |
437 | |
438 int dvd_read_sector(dvd_priv_t *d,unsigned char* data){ | |
439 int len; | |
440 | |
441 if(d->packs_left==0){ | |
442 /** | |
443 * If we're not at the end of this cell, we can determine the next | |
444 * VOBU to display using the VOBU_SRI information section of the | |
445 * DSI. Using this value correctly follows the current angle, | |
446 * avoiding the doubled scenes in The Matrix, and makes our life | |
447 * really happy. | |
448 * | |
449 * Otherwise, we set our next address past the end of this cell to | |
450 * force the code above to go to the next cell in the program. | |
451 */ | |
452 if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { | |
453 d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + | |
454 ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff ); | |
455 mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack); | |
456 } else { | |
457 // end of cell! find next cell! | |
458 mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n"); | |
459 d->cur_pack=d->cell_last_pack+1; | |
460 } | |
461 } | |
462 | |
463 read_next: | |
464 | |
465 if(d->cur_pack>d->cell_last_pack){ | |
466 // end of cell! | |
467 int next=dvd_next_cell(d); | |
468 if(next>=0){ | |
469 d->cur_cell=next; | |
470 | |
1615 | 471 // if( d->cur_pgc->cell_playback[d->cur_cell].block_type |
472 // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
1596 | 473 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
474 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
475 mp_msg(MSGT_DVD,MSGL_V, "DVD next cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); | |
476 | |
477 } else return -1; // EOF | |
478 } | |
479 | |
480 len = DVDReadBlocks( d->title, d->cur_pack, 1, data ); | |
481 if(!len) return -1; //error | |
482 | |
483 if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && | |
484 data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){ | |
485 // found a Navi packet!!! | |
1875 | 486 #if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0) |
487 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]) ); | |
488 #else | |
1596 | 489 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t) ); |
1875 | 490 #endif |
1596 | 491 if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ){ |
492 mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n", | |
493 d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn); | |
494 } else { | |
495 // process! | |
496 d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; | |
497 mp_msg(MSGT_DVD,MSGL_DBG2, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left); | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
498 if(d->angle_seek){ |
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
499 int skip=d->dsi_pack.sml_agli.data[dvd_angle].address; |
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
500 if(skip) d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+skip; |
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
501 d->angle_seek=0; |
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
502 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced! skip=%d new_lba=0x%X \n",skip,d->cur_pack); |
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
503 } |
1596 | 504 } |
505 ++d->cur_pack; | |
506 goto read_next; | |
507 } | |
508 | |
509 ++d->cur_pack; | |
510 if(d->packs_left>=0) --d->packs_left; | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
511 |
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
512 if(d->angle_seek) goto read_next; // searching for Navi packet |
1596 | 513 |
514 return d->cur_pack-1; | |
515 } | |
516 | |
517 void dvd_seek(dvd_priv_t *d,int pos){ | |
518 d->packs_left=-1; | |
519 d->cur_pack=pos; | |
520 | |
521 // check if we stay in current cell (speedup things, and avoid angle skip) | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
522 if(d->cur_pack>d->cell_last_pack || |
1596 | 523 d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ |
524 | |
525 // ok, cell change, find the right cell! | |
526 d->cur_cell=0; | |
527 if( d->cur_pgc->cell_playback[d->cur_cell].block_type | |
528 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
529 | |
530 while(1){ | |
531 int next; | |
532 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
533 if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ | |
534 d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
535 break; | |
536 } | |
537 if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :) | |
538 next=dvd_next_cell(d); | |
539 if(next<0){ | |
540 // d->cur_pack=d->cell_last_pack+1; | |
541 break; // we're after the last cell | |
542 } | |
543 d->cur_cell=next; | |
544 } | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
545 |
1596 | 546 } |
547 | |
548 mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", | |
549 d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack); | |
550 | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
551 // if we're in interleaved multi-angle cell, find the right angle chain! |
1596 | 552 // (read Navi block, and use the seamless angle jump table) |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
553 d->angle_seek=1; |
1596 | 554 |
555 } | |
556 | |
557 #endif |