Mercurial > mplayer.hg
annotate libmpdemux/open.c @ 7441:13716c8114a8
fixing edit-list playback (it uses the mvhd-timescale instead of the mdhd-one)
author | arpi |
---|---|
date | Wed, 18 Sep 2002 19:09:11 +0000 |
parents | 8705ce9a9fe9 |
children | c4434bdf6e51 |
rev | line source |
---|---|
1467 | 1 |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
2 #include <ctype.h> |
1467 | 3 #include <stdio.h> |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include <unistd.h> | |
7 #include <fcntl.h> | |
8 | |
9 #include "config.h" | |
1567 | 10 #include "mp_msg.h" |
1584 | 11 #include "help_mp.h" |
1467 | 12 |
1468 | 13 #ifdef __FreeBSD__ |
14 #include <sys/cdrio.h> | |
15 #endif | |
16 | |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
17 #include "../cfgparser.h" |
1467 | 18 #include "stream.h" |
1482 | 19 #include "demuxer.h" |
4551 | 20 #include "mf.h" |
1467 | 21 |
22 #ifdef STREAMING | |
23 #include "url.h" | |
24 #include "network.h" | |
6910
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
25 #ifdef STREAMING_LIVE_DOT_COM |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
26 #include "demux_rtp.h" |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
27 int isSDPFile = 0; |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
28 #endif |
1467 | 29 static URL_t* url; |
30 #endif | |
31 | |
1596 | 32 int dvd_title=0; |
33 int dvd_chapter=1; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
34 int dvd_last_chapter=0; |
1596 | 35 int dvd_angle=1; |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
36 char* dvd_device=NULL; |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
37 char* cdrom_device=NULL; |
5472 | 38 int dvd_nav=0; /* use libdvdnav? */ |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
39 |
5381 | 40 #ifdef USE_DVDNAV |
5472 | 41 #include "dvdnav_stream.h" |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
42 #endif |
1596 | 43 |
44 #ifdef USE_DVDREAD | |
45 | |
1875 | 46 #define DVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) |
47 | |
48 /* | |
49 * Try to autodetect the libdvd-0.9.0 library | |
50 * (0.9.0 removed the <dvdread/dvd_udf.h> header, and moved the two defines | |
51 * DVD_VIDEO_LB_LEN and MAX_UDF_FILE_NAME_LEN from it to | |
52 * <dvdread/dvd_reader.h>) | |
53 */ | |
54 #if defined(DVD_VIDEO_LB_LEN) && defined(MAX_UDF_FILE_NAME_LEN) | |
55 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,9,0) | |
56 #else | |
57 #define LIBDVDREAD_VERSION DVDREAD_VERSION(0,8,0) | |
58 #endif | |
59 | |
2935 | 60 char * dvd_audio_stream_types[8] = |
61 { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; | |
1596 | 62 |
6651 | 63 char * dvd_audio_stream_channels[6] = |
64 { "unknown", "stereo", "unknown", "unknown", "unknown", "5.1" }; | |
1596 | 65 #endif |
66 | |
1467 | 67 extern int vcd_get_track_end(int fd,int track); |
68 | |
2790 | 69 #ifdef USE_TV |
70 #include "tv.h" | |
2931 | 71 |
72 extern int stream_open_tv(stream_t *stream, tvi_handle_t *tvh); | |
2790 | 73 #endif |
74 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
75 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
76 stream_t* open_cdda(char* dev,char* track); |
7432
8705ce9a9fe9
Enable CDDB support only if the network layer is enabled.
bertrand
parents:
7408
diff
changeset
|
77 #ifdef STREAMING |
6474 | 78 stream_t* cddb_open(char* dev,char* track); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
79 #endif |
7432
8705ce9a9fe9
Enable CDDB support only if the network layer is enabled.
bertrand
parents:
7408
diff
changeset
|
80 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
81 |
1467 | 82 // Open a new stream (stdin/file/vcd/url) |
83 | |
84 stream_t* open_stream(char* filename,int vcd_track,int* file_format){ | |
85 stream_t* stream=NULL; | |
86 int f=-1; | |
87 off_t len; | |
88 #ifdef __FreeBSD__ | |
89 int bsize = VCD_SECTOR_SIZE; | |
90 #endif | |
91 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
92 #ifdef HAVE_CDDA |
6490
d7605d08b32f
filename can be NULL. Fix the conflict between cdda and dvdnav.
albeu
parents:
6479
diff
changeset
|
93 if(filename && strncmp("cdda://",filename,7) == 0) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
94 return open_cdda(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7); |
7432
8705ce9a9fe9
Enable CDDB support only if the network layer is enabled.
bertrand
parents:
7408
diff
changeset
|
95 #ifdef STREAMING |
6490
d7605d08b32f
filename can be NULL. Fix the conflict between cdda and dvdnav.
albeu
parents:
6479
diff
changeset
|
96 if(filename && strncmp("cddb://",filename,7) == 0) |
6474 | 97 return cddb_open(cdrom_device ? cdrom_device : DEFAULT_CDROM_DEVICE,filename+7); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
98 #endif |
7432
8705ce9a9fe9
Enable CDDB support only if the network layer is enabled.
bertrand
parents:
7408
diff
changeset
|
99 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
6320
diff
changeset
|
100 |
1467 | 101 //============ Open VideoCD track ============== |
3261 | 102 #ifdef HAVE_VCD |
1467 | 103 if(vcd_track){ |
104 int ret,ret2; | |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
105 if(!cdrom_device) cdrom_device=DEFAULT_CDROM_DEVICE; |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
106 f=open(cdrom_device,O_RDONLY); |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
107 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,cdrom_device);return NULL; } |
1467 | 108 vcd_read_toc(f); |
109 ret2=vcd_get_track_end(f,vcd_track); | |
1584 | 110 if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;} |
1467 | 111 ret=vcd_seek_to_track(f,vcd_track); |
1584 | 112 if(ret<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");return NULL;} |
1467 | 113 // seek_to_byte+=ret; |
1567 | 114 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); |
1467 | 115 #ifdef __FreeBSD__ |
116 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { | |
117 perror ( "Error in CDRIOCSETBLOCKSIZE"); | |
118 } | |
119 #endif | |
120 stream=new_stream(f,STREAMTYPE_VCD); | |
121 stream->start_pos=ret; | |
122 stream->end_pos=ret2; | |
123 return stream; | |
124 } | |
3261 | 125 #endif |
1467 | 126 |
1596 | 127 //============ Open DVD title ============== |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
128 #ifdef USE_DVDNAV |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
129 if(dvd_nav){ |
5472 | 130 dvdnav_priv_t *dvdnav_priv; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
131 int event,len,tmplen=0; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
132 |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
133 stream=new_stream(-1,STREAMTYPE_DVDNAV); |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
134 if (!stream) { |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
135 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_Exit_error); |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
136 return NULL; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
137 } |
5472 | 138 |
139 if(!filename) filename=DEFAULT_DVD_DEVICE; | |
140 if (!(dvdnav_priv=new_dvdnav_stream(filename))) { | |
141 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,filename); | |
142 return NULL; | |
143 } | |
144 | |
145 stream->priv=(void*)dvdnav_priv; | |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
146 return stream; |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
147 } |
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
148 #endif |
1596 | 149 #ifdef USE_DVDREAD |
150 if(dvd_title){ | |
2050 | 151 // int ret,ret2; |
5380
8a01cde9cf39
DVDnav support patch by David Holm and Kees Cook <mplayer@outflux.net>
arpi
parents:
4729
diff
changeset
|
152 dvd_priv_t *d; |
1596 | 153 int ttn,pgc_id,pgn; |
154 dvd_reader_t *dvd; | |
155 dvd_file_t *title; | |
156 ifo_handle_t *vmg_file; | |
157 tt_srpt_t *tt_srpt; | |
158 ifo_handle_t *vts_file; | |
159 /** | |
160 * Open the disc. | |
161 */ | |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
162 if(!dvd_device) dvd_device=DEFAULT_DVD_DEVICE; |
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
163 dvd = DVDOpen(dvd_device); |
1596 | 164 if( !dvd ) { |
4222
de7eddb3fd70
Change to use cdrom-device and dvd-device options needed for DVD/TV/VCD
albeu
parents:
4146
diff
changeset
|
165 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device); |
1596 | 166 return NULL; |
167 } | |
168 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
169 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait); |
1596 | 170 |
171 /** | |
172 * Load the video manager to find out the information about the titles on | |
173 * this disc. | |
174 */ | |
175 vmg_file = ifoOpen( dvd, 0 ); | |
176 if( !vmg_file ) { | |
177 mp_msg(MSGT_OPEN,MSGL_ERR, "Can't open VMG info!\n"); | |
178 DVDClose( dvd ); | |
179 return NULL; | |
180 } | |
181 tt_srpt = vmg_file->tt_srpt; | |
182 /** | |
183 * Make sure our title number is valid. | |
184 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
185 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumTitles, |
1596 | 186 tt_srpt->nr_of_srpts ); |
187 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
|
188 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidTitle, dvd_title); |
1596 | 189 ifoClose( vmg_file ); |
190 DVDClose( dvd ); | |
191 return NULL; | |
192 } | |
193 --dvd_title; // remap 1.. -> 0.. | |
194 /** | |
195 * Make sure the chapter number is valid for this title. | |
196 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
197 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumChapters, |
1596 | 198 tt_srpt->title[dvd_title].nr_of_ptts ); |
199 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
|
200 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidChapter, dvd_chapter); |
1596 | 201 ifoClose( vmg_file ); |
202 DVDClose( dvd ); | |
203 return NULL; | |
204 } | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
205 if( dvd_last_chapter>0 ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
206 if ( dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
207 mp_msg(MSGT_OPEN,MSGL_ERR, "Invalid DVD last chapter number: %d\n", dvd_last_chapter); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
208 ifoClose( vmg_file ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
209 DVDClose( dvd ); |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
210 return NULL; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
211 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
212 } |
1596 | 213 --dvd_chapter; // remap 1.. -> 0.. |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
214 /* XXX No need to remap dvd_last_chapter */ |
1596 | 215 /** |
216 * Make sure the angle number is valid for this title. | |
217 */ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
218 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDnumAngles, |
1596 | 219 tt_srpt->title[dvd_title].nr_of_angles ); |
220 if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) { | |
1977 | 221 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDinvalidAngle, dvd_angle); |
1596 | 222 ifoClose( vmg_file ); |
223 DVDClose( dvd ); | |
224 return NULL; | |
225 } | |
1617 | 226 --dvd_angle; // remap 1.. -> 0.. |
1596 | 227 /** |
228 * Load the VTS information for the title set our title is in. | |
229 */ | |
230 vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); | |
231 if( !vts_file ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
232 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoIFO, |
1596 | 233 tt_srpt->title[dvd_title].title_set_nr ); |
234 ifoClose( vmg_file ); | |
235 DVDClose( dvd ); | |
236 return NULL; | |
237 } | |
238 /** | |
239 * We've got enough info, time to open the title set data. | |
240 */ | |
241 title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, | |
242 DVD_READ_TITLE_VOBS ); | |
243 if( !title ) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
244 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_DVDnoVOBs, |
1596 | 245 tt_srpt->title[dvd_title].title_set_nr ); |
246 ifoClose( vts_file ); | |
247 ifoClose( vmg_file ); | |
248 DVDClose( dvd ); | |
249 return NULL; | |
250 } | |
251 | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1899
diff
changeset
|
252 mp_msg(MSGT_OPEN,MSGL_INFO, MSGTR_DVDopenOk); |
1596 | 253 // store data |
254 d=malloc(sizeof(dvd_priv_t)); memset(d,0,sizeof(dvd_priv_t)); | |
255 d->dvd=dvd; | |
256 d->title=title; | |
257 d->vmg_file=vmg_file; | |
258 d->tt_srpt=tt_srpt; | |
259 d->vts_file=vts_file; | |
260 | |
261 /** | |
2935 | 262 * Check number of audio channels and types |
263 */ | |
264 { | |
265 int ac3aid = 128; | |
266 int mpegaid = 0; | |
267 int pcmaid = 160; | |
268 | |
269 d->nr_of_channels=0; | |
270 | |
271 if ( vts_file->vts_pgcit ) | |
272 { | |
273 int i; | |
274 for ( i=0;i<8;i++ ) | |
275 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->audio_control[i] & 0x8000 ) | |
276 { | |
277 audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i]; | |
278 int language = 0; | |
279 char tmp[] = "unknown"; | |
280 | |
281 if ( audio->lang_type == 1 ) | |
282 { | |
283 language=audio->lang_code; | |
284 tmp[0]=language>>8; | |
285 tmp[1]=language&0xff; | |
286 tmp[2]=0; | |
287 } | |
288 | |
289 d->audio_streams[d->nr_of_channels].language=language; | |
290 d->audio_streams[d->nr_of_channels].id=0; | |
291 switch ( audio->audio_format ) | |
292 { | |
293 case 0: // ac3 | |
294 case 6: // dts | |
295 d->audio_streams[d->nr_of_channels].id=ac3aid; | |
296 ac3aid++; | |
297 break; | |
298 case 2: // mpeg layer 1/2/3 | |
299 case 3: // mpeg2 ext | |
300 d->audio_streams[d->nr_of_channels].id=mpegaid; | |
301 mpegaid++; | |
302 break; | |
303 case 4: // lpcm | |
304 d->audio_streams[d->nr_of_channels].id=pcmaid; | |
305 pcmaid++; | |
306 break; | |
307 } | |
308 | |
6651 | 309 d->audio_streams[d->nr_of_channels].type=audio->audio_format; |
310 // Pontscho: to my mind, tha channels: | |
311 // 1 - stereo | |
312 // 5 - 5.1 | |
313 d->audio_streams[d->nr_of_channels].channels=audio->channels; | |
314 mp_msg(MSGT_OPEN,MSGL_V,"[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", | |
2935 | 315 d->nr_of_channels, |
316 dvd_audio_stream_types[ audio->audio_format ], | |
6651 | 317 dvd_audio_stream_channels[ audio->channels ], |
2935 | 318 tmp, |
319 d->audio_streams[d->nr_of_channels].id | |
320 ); | |
3753 | 321 |
2935 | 322 d->nr_of_channels++; |
323 } | |
324 } | |
3048 | 325 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of audio channels on disk: %d.\n",d->nr_of_channels ); |
326 } | |
327 | |
328 /** | |
329 * Check number of subtitles and language | |
330 */ | |
331 { | |
332 int i; | |
333 | |
334 d->nr_of_subtitles=0; | |
335 for ( i=0;i<32;i++ ) | |
336 if ( vts_file->vts_pgcit->pgci_srp[0].pgc->subp_control[i] & 0x80000000 ) | |
337 { | |
338 subp_attr_t * subtitle = &vts_file->vtsi_mat->vts_subp_attr[i]; | |
339 int language = 0; | |
340 char tmp[] = "unknown"; | |
341 | |
342 if ( subtitle->type == 1 ) | |
343 { | |
344 language=subtitle->lang_code; | |
345 tmp[0]=language>>8; | |
346 tmp[1]=language&0xff; | |
347 tmp[2]=0; | |
348 } | |
349 | |
350 d->subtitles[ d->nr_of_subtitles ].language=language; | |
351 d->subtitles[ d->nr_of_subtitles ].id=d->nr_of_subtitles; | |
352 | |
353 mp_msg(MSGT_OPEN,MSGL_V,"[open] subtitle ( sid ): %d language: %s\n", | |
354 d->nr_of_subtitles, | |
355 tmp | |
356 ); | |
357 d->nr_of_subtitles++; | |
358 } | |
359 mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); | |
2935 | 360 } |
361 | |
362 /** | |
1596 | 363 * Determine which program chain we want to watch. This is based on the |
364 * chapter number. | |
365 */ | |
366 ttn = tt_srpt->title[ dvd_title ].vts_ttn; // local | |
367 pgc_id = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgcn; // local | |
368 pgn = vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_chapter].pgn; // local | |
369 d->cur_pgc = vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; | |
370 d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here | |
371 d->packs_left=-1; // for Navi stuff | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
372 d->angle_seek=0; |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
373 /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */ |
6853
c52dc92ebf4b
There appears to be a trivial namespace error in determining the valid
arpi
parents:
6774
diff
changeset
|
374 if ( dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[dvd_title].nr_of_ptts ) { |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
375 pgn=vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_last_chapter].pgn; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
376 d->last_cell=d->cur_pgc->program_map[pgn-1] - 1; |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
377 } |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
378 else |
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
379 d->last_cell=d->cur_pgc->nr_of_cells; |
1596 | 380 |
6651 | 381 if( d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; |
1596 | 382 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
383 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
384 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); | |
385 | |
386 // ... (unimplemented) | |
387 // return NULL; | |
388 stream=new_stream(-1,STREAMTYPE_DVD); | |
389 stream->start_pos=(off_t)d->cur_pack*2048; | |
4390 | 390 stream->end_pos=(off_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048; |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
391 mp_msg(MSGT_DVD,MSGL_V,"DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector); |
1596 | 392 stream->priv=(void*)d; |
393 return stream; | |
394 } | |
395 #endif | |
396 | |
7408 | 397 //============ Check for TV-input or multi-file input ==== |
398 if( (mf_support == 1) | |
2790 | 399 #ifdef USE_TV |
7408 | 400 || (tv_param_on == 1) |
2790 | 401 #endif |
7408 | 402 ){ |
4551 | 403 /* create stream */ |
7407 | 404 stream = new_stream(-1, STREAMTYPE_DUMMY); |
405 if (!stream) return(NULL); | |
7408 | 406 stream->url=filename?strdup(filename):NULL; |
4551 | 407 return(stream); |
408 } | |
1467 | 409 |
410 #ifdef STREAMING | |
411 url = url_new(filename); | |
412 if(url) { | |
4251
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
413 stream=new_stream(f,STREAMTYPE_STREAM); |
4729
f51bd827ed1c
fixed MP3 ICY detection, return detected file format for open_stream
alex
parents:
4551
diff
changeset
|
414 if( streaming_start( stream, file_format, url )<0){ |
4251
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
415 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename); |
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
416 url_free(url); |
05affdf4bdcd
Moved network related code from open.c to network.c
bertrand
parents:
4222
diff
changeset
|
417 return NULL; |
4046
f732854e3d16
Kept the HTTP connection open after autodetect, so
bertrand
parents:
3753
diff
changeset
|
418 } |
1584 | 419 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ConnToServer, url->hostname ); |
3045
6c14fd789ba5
Changed the order of processing the network opening.
bertrand
parents:
2935
diff
changeset
|
420 url_free(url); |
2315 | 421 return stream; |
1467 | 422 } |
423 #endif | |
424 | |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
425 //============ Open STDIN or plain FILE ============ |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
426 if(!strcmp(filename,"-")){ |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
427 // read from stdin |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
428 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN); |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
429 f=0; // 0=stdin |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
430 } else { |
1467 | 431 f=open(filename,O_RDONLY); |
1584 | 432 if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; } |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
433 } |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
434 |
1467 | 435 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); |
436 if (len == -1) | |
6320
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
437 return new_stream(f,STREAMTYPE_STREAM); // open as stream |
12136df07dbd
common code to handle file/stdin/fifo opening, allows using named pipes and
arpi
parents:
5932
diff
changeset
|
438 |
1467 | 439 #ifdef _LARGEFILE_SOURCE |
1567 | 440 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len); |
1467 | 441 #else |
1567 | 442 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len); |
1467 | 443 #endif |
6910
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
444 |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
445 #ifdef STREAMING_LIVE_DOT_COM |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
446 // Check for a special case: a SDP file: |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
447 if (isSDPFile) { |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
448 return stream_open_sdp(f, len, file_format); |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
449 } |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
450 #endif |
1a747aee653b
applied live.com streaming patch (-sdp and rtsp:// support) by Ross Finlayson <finlayson@live.com>
arpi
parents:
6853
diff
changeset
|
451 |
1467 | 452 stream=new_stream(f,STREAMTYPE_FILE); |
453 stream->end_pos=len; | |
454 return stream; | |
455 } | |
1596 | 456 |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
457 int dvd_parse_chapter_range(struct config *conf, const char *range){ |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
458 char *s, *t; |
4344 | 459 conf; /* prevent warning from GCC */ |
460 s = range; | |
4343
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
461 dvd_chapter = 1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
462 dvd_last_chapter = 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
463 if (*range && isdigit(*range)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
464 dvd_chapter = strtol(range, &s, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
465 if (range == s) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
466 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
467 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
468 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
469 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
470 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
471 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
472 else if (*s != '-') { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
473 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
474 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
475 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
476 ++s; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
477 if (*s == 0) |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
478 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
479 if (! isdigit(*s)) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
480 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
481 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
482 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
483 dvd_last_chapter = strtol(s, &t, 10); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
484 if (s == t || *t) { |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
485 mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
486 return -1; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
487 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
488 return 0; |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
489 } |
b0c8eed7473c
Extended DVD chapter specification. Remove -last-chapter option.
kmkaplan
parents:
4291
diff
changeset
|
490 |
3753 | 491 #ifdef USE_DVDREAD |
1596 | 492 |
3753 | 493 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang){ |
494 dvd_priv_t *d=stream->priv; | |
495 int code,i; | |
496 while(lang && strlen(lang)>=2){ | |
497 code=lang[1]|(lang[0]<<8); | |
498 for(i=0;i<d->nr_of_channels;i++){ | |
499 if(d->audio_streams[i].language==code){ | |
500 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD audio channel: %d language: %c%c\n", | |
501 d->audio_streams[i].id, lang[0],lang[1]); | |
502 return d->audio_streams[i].id; | |
503 } | |
504 // printf("%X != %X (%c%c)\n",code,d->audio_streams[i].language,lang[0],lang[1]); | |
505 } | |
506 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
507 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
508 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD audio language found!\n"); |
3753 | 509 return -1; |
510 } | |
511 | |
512 int dvd_sid_from_lang(stream_t *stream, unsigned char* lang){ | |
513 dvd_priv_t *d=stream->priv; | |
514 int code,i; | |
515 while(lang && strlen(lang)>=2){ | |
516 code=lang[1]|(lang[0]<<8); | |
517 for(i=0;i<d->nr_of_subtitles;i++){ | |
518 if(d->subtitles[i].language==code){ | |
519 mp_msg(MSGT_OPEN,MSGL_INFO,"Selected DVD subtitle channel: %d language: %c%c\n", | |
520 d->subtitles[i].id, lang[0],lang[1]); | |
521 return d->subtitles[i].id; | |
522 } | |
523 } | |
524 lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; | |
525 } | |
5932
1ebeebca86f3
printf to mp_msg + warning msg from MSGL_INFO to MSGT_WARN
albeu
parents:
5819
diff
changeset
|
526 mp_msg(MSGT_OPEN,MSGL_WARN,"No matching DVD subtitle language found!\n"); |
3753 | 527 return -1; |
528 } | |
1596 | 529 |
530 static int dvd_next_cell(dvd_priv_t *d){ | |
531 int next_cell=d->cur_cell; | |
1616 | 532 |
533 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next1=0x%X \n",next_cell); | |
1596 | 534 |
535 if( d->cur_pgc->cell_playback[ next_cell ].block_type | |
536 == BLOCK_TYPE_ANGLE_BLOCK ) { | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
537 while(next_cell<d->last_cell){ |
1596 | 538 if( d->cur_pgc->cell_playback[next_cell].block_mode |
539 == BLOCK_MODE_LAST_CELL ) break; | |
540 ++next_cell; | |
541 } | |
542 } | |
1616 | 543 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X \n",next_cell); |
1596 | 544 |
545 ++next_cell; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
546 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 547 if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){ |
548 next_cell+=dvd_angle; | |
4291
e889d37f25b2
Add option -last-chapter for DVD playing/encoding
kmkaplan
parents:
4251
diff
changeset
|
549 if(next_cell>=d->last_cell) return -1; // EOF |
1596 | 550 } |
1616 | 551 mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X \n",next_cell); |
1596 | 552 return next_cell; |
553 } | |
554 | |
555 int dvd_read_sector(dvd_priv_t *d,unsigned char* data){ | |
556 int len; | |
557 | |
558 if(d->packs_left==0){ | |
559 /** | |
560 * If we're not at the end of this cell, we can determine the next | |
561 * VOBU to display using the VOBU_SRI information section of the | |
562 * DSI. Using this value correctly follows the current angle, | |
563 * avoiding the doubled scenes in The Matrix, and makes our life | |
564 * really happy. | |
565 * | |
566 * Otherwise, we set our next address past the end of this cell to | |
567 * force the code above to go to the next cell in the program. | |
568 */ | |
569 if( d->dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { | |
570 d->cur_pack= d->dsi_pack.dsi_gi.nv_pck_lbn + | |
571 ( d->dsi_pack.vobu_sri.next_vobu & 0x7fffffff ); | |
572 mp_msg(MSGT_DVD,MSGL_DBG2, "Navi new pos=0x%X \n",d->cur_pack); | |
573 } else { | |
574 // end of cell! find next cell! | |
575 mp_msg(MSGT_DVD,MSGL_V, "--- END OF CELL !!! ---\n"); | |
576 d->cur_pack=d->cell_last_pack+1; | |
577 } | |
578 } | |
579 | |
580 read_next: | |
581 | |
582 if(d->cur_pack>d->cell_last_pack){ | |
583 // end of cell! | |
584 int next=dvd_next_cell(d); | |
585 if(next>=0){ | |
586 d->cur_cell=next; | |
587 | |
1615 | 588 // if( d->cur_pgc->cell_playback[d->cur_cell].block_type |
589 // == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
1596 | 590 d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; |
591 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
592 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); | |
593 | |
594 } else return -1; // EOF | |
595 } | |
596 | |
597 len = DVDReadBlocks( d->title, d->cur_pack, 1, data ); | |
598 if(!len) return -1; //error | |
599 | |
600 if(data[38]==0 && data[39]==0 && data[40]==1 && data[41]==0xBF && | |
601 data[1024]==0 && data[1025]==0 && data[1026]==1 && data[1027]==0xBF){ | |
602 // found a Navi packet!!! | |
1875 | 603 #if LIBDVDREAD_VERSION >= DVDREAD_VERSION(0,9,0) |
604 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]) ); | |
605 #else | |
1596 | 606 navRead_DSI( &d->dsi_pack, &(data[ DSI_START_BYTE ]), sizeof(dsi_t) ); |
1875 | 607 #endif |
1596 | 608 if(d->cur_pack != d->dsi_pack.dsi_gi.nv_pck_lbn ){ |
609 mp_msg(MSGT_DVD,MSGL_V, "Invalid NAVI packet! lba=0x%X navi=0x%X \n", | |
610 d->cur_pack,d->dsi_pack.dsi_gi.nv_pck_lbn); | |
611 } else { | |
612 // process! | |
613 d->packs_left = d->dsi_pack.dsi_gi.vobu_ea; | |
614 mp_msg(MSGT_DVD,MSGL_DBG2, "Found NAVI packet! lba=0x%X len=%d \n",d->cur_pack,d->packs_left); | |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
615 //navPrint_DSI(&d->dsi_pack); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
616 mp_msg(MSGT_DVD,MSGL_DBG3,"\r### CELL %d: Navi: %d/%d IFO: %d/%d \n",d->cur_cell, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
617 d->dsi_pack.dsi_gi.vobu_c_idn,d->dsi_pack.dsi_gi.vobu_vob_idn, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
618 d->cur_pgc->cell_position[d->cur_cell].cell_nr, |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
619 d->cur_pgc->cell_position[d->cur_cell].vob_id_nr); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
620 |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
621 if(d->angle_seek){ |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
622 int i,skip=0; |
7296
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
623 #if defined(__GNUC__) && defined(__sparc__) |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
624 // workaround for a bug in the sparc version of gcc 2.95.X ... 3.2, |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
625 // it generates incorrect code for unaligned access to a packed |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
626 // structure member, resulting in an mplayer crash with a SIGBUS |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
627 // signal. |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
628 // |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
629 // See also gcc problem report PR c/7847: |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
630 // http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&cmd=view+audit-trail&pr=7847 |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
631 for(i=0;i<9;i++){ // check if all values zero: |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
632 typeof(d->dsi_pack.sml_agli.data[i].address) tmp_addr; |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
633 memcpy(&tmp_addr,&d->dsi_pack.sml_agli.data[i].address,sizeof(tmp_addr)); |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
634 if((skip=tmp_addr)!=0) break; |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
635 } |
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
636 #else |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
637 for(i=0;i<9;i++) // check if all values zero: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
638 if((skip=d->dsi_pack.sml_agli.data[i].address)!=0) break; |
7296
f4710b873abd
SPARC gcc generates bad code accessing an unaligned and packed structure member
jkeil
parents:
6910
diff
changeset
|
639 #endif |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
640 if(skip){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
641 // sml_agli table has valid data (at least one non-zero): |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
642 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
643 d->dsi_pack.sml_agli.data[dvd_angle].address; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
644 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
645 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
646 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
647 // check if we're in the right cell, jump otherwise: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
648 if( (d->dsi_pack.dsi_gi.vobu_c_idn==d->cur_pgc->cell_position[d->cur_cell].cell_nr) && |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
649 (d->dsi_pack.dsi_gi.vobu_vob_idn==d->cur_pgc->cell_position[d->cur_cell].vob_id_nr) ){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
650 d->angle_seek=0; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
651 mp_msg(MSGT_DVD,MSGL_V, "Angle-seek synced by cell/vob IDN search! \n"); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
652 } else { |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
653 // wrong angle, skip this vobu: |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
654 d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
655 d->dsi_pack.dsi_gi.vobu_ea; |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
656 d->angle_seek=2; // DEBUG |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
657 } |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
658 } |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
659 } |
1596 | 660 } |
661 ++d->cur_pack; | |
662 goto read_next; | |
663 } | |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
664 |
1596 | 665 ++d->cur_pack; |
666 if(d->packs_left>=0) --d->packs_left; | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
667 |
6774
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
668 if(d->angle_seek){ |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
669 if(d->angle_seek==2) mp_msg(MSGT_DVD,MSGL_V, "!!! warning! reading packet while angle_seek !!!\n"); |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
670 goto read_next; // searching for Navi packet |
3bcd52b7b2ae
Workaround for seeking multiangle discs with missing sml_agli[] table, as a
arpi
parents:
6651
diff
changeset
|
671 } |
1596 | 672 |
673 return d->cur_pack-1; | |
674 } | |
675 | |
676 void dvd_seek(dvd_priv_t *d,int pos){ | |
677 d->packs_left=-1; | |
678 d->cur_pack=pos; | |
679 | |
680 // 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
|
681 if(d->cur_pack>d->cell_last_pack || |
1596 | 682 d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ |
683 | |
684 // ok, cell change, find the right cell! | |
685 d->cur_cell=0; | |
686 if( d->cur_pgc->cell_playback[d->cur_cell].block_type | |
687 == BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle; | |
688 | |
689 while(1){ | |
690 int next; | |
691 d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; | |
692 if(d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector){ | |
693 d->cur_pack=d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; | |
694 break; | |
695 } | |
696 if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :) | |
697 next=dvd_next_cell(d); | |
698 if(next<0){ | |
699 // d->cur_pack=d->cell_last_pack+1; | |
700 break; // we're after the last cell | |
701 } | |
702 d->cur_cell=next; | |
703 } | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
704 |
1596 | 705 } |
706 | |
707 mp_msg(MSGT_DVD,MSGL_V, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", | |
708 d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack); | |
709 | |
1609
84199d075839
ugly seeking bug fixed, correct multiangle seek implemented
arpi
parents:
1596
diff
changeset
|
710 // if we're in interleaved multi-angle cell, find the right angle chain! |
1596 | 711 // (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
|
712 d->angle_seek=1; |
1596 | 713 |
714 } | |
715 | |
6479 | 716 void dvd_close(dvd_priv_t *d) { |
717 ifoClose(d->vts_file); | |
718 ifoClose(d->vmg_file); | |
719 DVDCloseFile(d->title); | |
720 DVDClose(d->dvd); | |
721 } | |
722 | |
1596 | 723 #endif |