Mercurial > mplayer.hg
annotate libmpdemux/cue_read.c @ 15476:5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
author | nicodvb |
---|---|
date | Sun, 15 May 2005 07:38:42 +0000 |
parents | 9a495bdc3a1e |
children | 15f012150986 |
rev | line source |
---|---|
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
1 //=================== VideoCD BinCue ========================== |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
2 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
3 #include <stdio.h> |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
4 #include <stdlib.h> |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
5 #include <string.h> |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
6 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
7 #include <sys/types.h> |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
8 #include <sys/stat.h> |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
9 #include <unistd.h> |
8812 | 10 #include <fcntl.h> |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
11 |
8812 | 12 #include "config.h" |
13 #include "mp_msg.h" | |
14 //#include "help_mp.h" | |
15 | |
16 #include "stream.h" | |
17 | |
18 #include "cue_read.h" | |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
19 #include "help_mp.h" |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
20 #include "../m_option.h" |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
21 #include "../m_struct.h" |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
22 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
23 #define byte unsigned char |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
24 #define SIZERAW 2352 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
25 #define SIZEISO_MODE1 2048 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
26 #define SIZEISO_MODE2_RAW 2352 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
27 #define SIZEISO_MODE2_FORM1 2048 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
28 #define SIZEISO_MODE2_FORM2 2336 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
29 #define AUDIO 0 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
30 #define MODE1 1 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
31 #define MODE2 2 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
32 #define MODE1_2352 10 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
33 #define MODE2_2352 20 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
34 #define MODE1_2048 30 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
35 #define MODE2_2336 40 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
36 #define UNKNOWN -1 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
37 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
38 static struct stream_priv_s { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
39 char* filename; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
40 } stream_priv_dflts = { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
41 NULL |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
42 }; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
43 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
44 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
45 /// URL definition |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
46 static m_option_t stream_opts_fields[] = { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
47 { "string", ST_OFF(filename), CONF_TYPE_STRING, 0, 0 ,0, NULL}, |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
48 { NULL, NULL, 0, 0, 0, 0, NULL } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
49 }; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
50 static struct m_struct_st stream_opts = { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
51 "cue", |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
52 sizeof(struct stream_priv_s), |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
53 &stream_priv_dflts, |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
54 stream_opts_fields |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
55 }; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
56 |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
57 static FILE* fd_cue; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
58 static int fd_bin = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
59 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
60 static char bin_filename[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
61 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
62 static char cue_filename[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
63 static char bincue_path[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
64 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
65 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
66 typedef struct track |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
67 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
68 unsigned short mode; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
69 unsigned short minute; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
70 unsigned short second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
71 unsigned short frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
72 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
73 /* (min*60 + sec) * 75 + fps */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
74 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
75 unsigned long start_sector; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
76 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
77 /* = the sizes in bytes off all tracks bevor this one */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
78 /* its needed if there are mode1 tracks befor the mpeg tracks */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
79 unsigned long start_offset; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
80 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
81 /* unsigned char num[3]; */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
82 } tTrack; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
83 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
84 /* max 99 tracks on a cd */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
85 static tTrack tracks[100]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
86 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
87 static struct cue_track_pos { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
88 int track; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
89 unsigned short mode; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
90 unsigned short minute; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
91 unsigned short second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
92 unsigned short frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
93 } cue_current_pos; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
94 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
95 /* number of tracks on the cd */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
96 static int nTracks = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
97 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
98 /* presumes Line is preloaded with the "current" line of the file */ |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
99 static int cue_getTrackinfo(char *Line, tTrack *track) |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
100 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
101 char inum[3]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
102 char min; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
103 char sec; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
104 char fps; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
105 int already_set = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
106 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
107 /* Get the 'mode' */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
108 if (strncmp(&Line[2], "TRACK ", 6)==0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
109 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
110 /* strncpy(track->num, &Line[8], 2); track->num[2] = '\0'; */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
111 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
112 track->mode = UNKNOWN; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
113 if(strncmp(&Line[11], "AUDIO", 5)==0) track->mode = AUDIO; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
114 if(strncmp(&Line[11], "MODE1/2352", 10)==0) track->mode = MODE1_2352; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
115 if(strncmp(&Line[11], "MODE1/2048", 10)==0) track->mode = MODE1_2048; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
116 if(strncmp(&Line[11], "MODE2/2352", 10)==0) track->mode = MODE2_2352; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
117 if(strncmp(&Line[11], "MODE2/2336", 10)==0) track->mode = MODE2_2336; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
118 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
119 else return(1); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
120 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
121 /* Get the track indexes */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
122 while(1) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
123 if(! fgets( Line, 256, fd_cue ) ) { break;} |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
124 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
125 if (strncmp(&Line[2], "TRACK ", 6)==0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
126 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
127 /* next track starting */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
128 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
129 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
130 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
131 /* Track 0 or 1, take the first an get fill the values*/ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
132 if (strncmp(&Line[4], "INDEX ", 6)==0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
133 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
134 /* check stuff here so if the answer is false the else stuff below won't be executed */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
135 strncpy(inum, &Line[10], 2); inum[2] = '\0'; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
136 if ((already_set == 0) && |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
137 ((strcmp(inum, "00")==0) || (strcmp(inum, "01")==0))) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
138 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
139 already_set = 1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
140 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
141 min = ((Line[13]-'0')<<4) | (Line[14]-'0'); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
142 sec = ((Line[16]-'0')<<4) | (Line[17]-'0'); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
143 fps = ((Line[19]-'0')<<4) | (Line[20]-'0'); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
144 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
145 track->minute = (((min>>4)*10) + (min&0xf)); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
146 track->second = (((sec>>4)*10) + (sec&0xf)); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
147 track->frame = (((fps>>4)*10) + (fps&0xf)); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
148 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
149 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
150 else if (strncmp(&Line[4], "PREGAP ", 7)==0) { ; /* ignore */ } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
151 else if (strncmp(&Line[4], "FLAGS ", 6)==0) { ; /* ignore */ } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
152 else mp_msg (MSGT_OPEN,MSGL_INFO, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
153 "[bincue] Unexpected cuefile line: %s\n", Line); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
154 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
155 return(0); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
156 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
157 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
158 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
159 |
12646 | 160 /* FIXME: the string operations ( strcpy,strcat ) below depend |
161 * on the arrays to have the same size, thus we need to make | |
162 * sure the sizes are in sync. | |
163 */ | |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
164 static int cue_find_bin (char *firstline) { |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
165 int i,j; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
166 char s[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
167 char t[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
168 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
169 /* get the filename out of that */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
170 /* 12345 6 */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
171 if (strncmp(firstline, "FILE \"",6)==0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
172 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
173 i = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
174 j = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
175 while ( firstline[6 + i] != '"') |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
176 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
177 bin_filename[j] = firstline[6 + i]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
178 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
179 /* if I found a path info, than delete all bevor it */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
180 switch (bin_filename[j]) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
181 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
182 case '\\': |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
183 j = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
184 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
185 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
186 case '/': |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
187 j = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
188 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
189 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
190 default: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
191 j++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
192 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
193 i++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
194 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
195 bin_filename[j+1] = '\0'; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
196 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
197 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
198 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
199 /* now try to open that file, without path */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
200 fd_bin = open (bin_filename, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
201 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
202 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
203 mp_msg(MSGT_OPEN,MSGL_STATUS, "[bincue] bin filename tested: %s\n", |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
204 bin_filename); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
205 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
206 /* now try to find it with the path of the cue file */ |
12646 | 207 snprintf(s,sizeof( s ),"%s/%s",bincue_path,bin_filename); |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
208 fd_bin = open (s, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
209 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
210 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
211 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
212 "[bincue] bin filename tested: %s\n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
213 /* now I would say the whole filename is shit, build our own */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
214 strncpy(s, cue_filename, strlen(cue_filename) - 3 ); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
215 s[strlen(cue_filename) - 3] = '\0'; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
216 strcat(s, "bin"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
217 fd_bin = open (s, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
218 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
219 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
220 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
221 "[bincue] bin filename tested: %s\n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
222 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
223 /* ok try it with path */ |
12646 | 224 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s); |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
225 fd_bin = open (t, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
226 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
227 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
228 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
229 "[bincue] bin filename tested: %s\n",t); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
230 /* now I would say the whole filename is shit, build our own */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
231 strncpy(s, cue_filename, strlen(cue_filename) - 3 ); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
232 s[strlen(cue_filename) - 3] = '\0'; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
233 strcat(s, "img"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
234 fd_bin = open (s, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
235 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
236 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
237 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
238 "[bincue] bin filename tested: %s \n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
239 /* ok try it with path */ |
12646 | 240 snprintf(t, sizeof( t ), "%s/%s", bincue_path, s); |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
241 fd_bin = open (t, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
242 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
243 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
244 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
245 "[bincue] bin filename tested: %s\n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
246 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
247 /* I'll give up */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
248 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
249 "[bincue] couldn't find the bin file - giving up\n"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
250 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
251 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
252 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
253 } else strcpy(bin_filename, t); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
254 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
255 } else strcpy(bin_filename, s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
256 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
257 } else strcpy(bin_filename, s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
258 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
259 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
260 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
261 mp_msg(MSGT_OPEN,MSGL_INFO, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
262 "[bincue] using bin file %s\n", bin_filename); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
263 return 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
264 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
265 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
266 static inline int cue_msf_2_sector(int minute, int second, int frame) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
267 return frame + (second + minute * 60 ) * 75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
268 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
269 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
270 static inline int cue_get_msf() { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
271 return cue_msf_2_sector (cue_current_pos.minute, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
272 cue_current_pos.second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
273 cue_current_pos.frame); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
274 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
275 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
276 static inline void cue_set_msf(unsigned int sect){ |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
277 cue_current_pos.frame=sect%75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
278 sect=sect/75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
279 cue_current_pos.second=sect%60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
280 sect=sect/60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
281 cue_current_pos.minute=sect; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
282 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
283 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
284 static inline int cue_mode_2_sector_size(int mode) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
285 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
286 switch (mode) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
287 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
288 case AUDIO: return AUDIO; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
289 case MODE1_2352: return SIZERAW; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
290 case MODE1_2048: return SIZEISO_MODE1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
291 case MODE2_2352: return SIZEISO_MODE2_RAW; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
292 case MODE2_2336: return SIZEISO_MODE2_FORM2; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
293 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
294 default: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
295 mp_msg(MSGT_OPEN,MSGL_FATAL, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
296 "[bincue] unknown mode for binfile. should not happen. aborting\n"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
297 abort(); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
298 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
299 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
300 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
301 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
302 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
303 static int cue_read_cue (char *in_cue_filename) |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
304 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
305 struct stat filestat; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
306 char sLine[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
307 unsigned int sect; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
308 char *s,*t; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
309 int i; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
310 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
311 /* we have no tracks at the beginning */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
312 nTracks = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
313 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
314 fd_bin = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
315 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
316 /* split the filename into a path and filename part */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
317 s = strdup(in_cue_filename); |
8815 | 318 t = strrchr(s, '/'); |
319 if (t == (char *)NULL) | |
320 t = "."; | |
321 else { | |
322 *t = '\0'; | |
323 t = s; | |
8817
84522accebc0
10l, hopefully correct fix, before path was always overwritten to '/'
atmos4
parents:
8815
diff
changeset
|
324 if (*t == '\0') |
8815 | 325 strcpy(t, "/"); |
326 } | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
327 printf ("dirname: %s\n", t); |
12646 | 328 strlcpy(bincue_path,t,sizeof( bincue_path )); |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
329 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
330 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
331 /* no path at all? */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
332 if (strcmp(bincue_path, ".") == 0) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
333 printf ("bincue_path: %s\n", bincue_path); |
12646 | 334 strlcpy(cue_filename,in_cue_filename,sizeof( cue_filename )); |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
335 } else { |
12646 | 336 strlcpy(cue_filename,in_cue_filename + strlen(bincue_path) + 1, |
337 sizeof( cue_filename )); | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
338 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
339 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
340 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
341 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
342 /* open the cue file */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
343 fd_cue = fopen (in_cue_filename, "r"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
344 if (fd_cue == NULL) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
345 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
346 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
347 "[bincue] cannot open %s\n", in_cue_filename); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
348 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
349 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
350 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
351 /* read the first line and hand it to find_bin, which will |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
352 test more than one possible name of the file */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
353 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
354 if(! fgets( sLine, 256, fd_cue ) ) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
355 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
356 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
357 "[bincue] error reading from %s\n", in_cue_filename); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
358 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
359 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
360 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
361 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
362 if (cue_find_bin(sLine)) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
363 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
364 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
365 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
366 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
367 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
368 /* now build the track list */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
369 /* red the next line and call our track finder */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
370 if(! fgets( sLine, 256, fd_cue ) ) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
371 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
372 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
373 "[bincue] error reading from %s\n", in_cue_filename); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
374 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
375 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
376 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
377 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
378 while(!feof(fd_cue)) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
379 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
380 if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
381 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
382 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
383 "[bincue] error reading from %s\n", in_cue_filename); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
384 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
385 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
386 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
387 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
388 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
389 /* make a fake track with stands for the Lead out */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
390 if (fstat (fd_bin, &filestat) == -1) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
391 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
392 "[bincue] error getting size of bin file\n"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
393 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
394 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
395 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
396 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
397 sect = filestat.st_size / 2352; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
398 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
399 tracks[nTracks].frame = sect%75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
400 sect=sect/75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
401 tracks[nTracks].second = sect%60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
402 sect=sect/60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
403 tracks[nTracks].minute = sect; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
404 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
405 |
11000 | 406 /* let's calculate the start sectors and offsets */ |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
407 for(i = 0; i <= nTracks; i++) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
408 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
409 tracks[i].start_sector = cue_msf_2_sector(tracks[i].minute, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
410 tracks[nTracks].second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
411 tracks[nTracks].frame); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
412 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
413 /* if we're the first track we don't need to offset of the one befor */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
414 if (i == 0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
415 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
416 /* was always 0 on my svcds, but who knows */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
417 tracks[0].start_offset = tracks[0].start_sector * |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
418 cue_mode_2_sector_size(tracks[0].mode); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
419 } else |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
420 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
421 tracks[i].start_offset = tracks[i-1].start_offset + |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
422 (tracks[i].start_sector - tracks[i-1].start_sector) * |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
423 cue_mode_2_sector_size(tracks[i-1].mode); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
424 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
425 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
426 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
427 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
428 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
429 return fd_bin; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
430 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
431 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
432 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
433 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
434 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
435 static int cue_read_toc_entry() { |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
436 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
437 int track = cue_current_pos.track - 1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
438 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
439 /* check if its a valid track, if not return -1 */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
440 if (track >= nTracks) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
441 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
442 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
443 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
444 switch (tracks[track].mode) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
445 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
446 case AUDIO: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
447 cue_current_pos.mode = AUDIO; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
448 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
449 case MODE1_2352: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
450 cue_current_pos.mode = MODE1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
451 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
452 case MODE1_2048: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
453 cue_current_pos.mode = MODE1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
454 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
455 default: /* MODE2_2352 and MODE2_2336 */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
456 cue_current_pos.mode = MODE2; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
457 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
458 cue_current_pos.minute = tracks[track].minute; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
459 cue_current_pos.second = tracks[track].second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
460 cue_current_pos.frame = tracks[track].frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
461 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
462 return 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
463 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
464 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
465 static int cue_read_raw(char *buf) { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
466 unsigned long position; |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
467 int track = cue_current_pos.track - 1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
468 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
469 /* get the mode of the bin file part and calc the positon */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
470 position = tracks[track].start_offset + |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
471 (cue_msf_2_sector(cue_current_pos.minute, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
472 cue_current_pos.second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
473 cue_current_pos.frame) - |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
474 tracks[track].start_sector) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
475 * cue_mode_2_sector_size(tracks[track].mode); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
476 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
477 /* check if the track is at its end*/ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
478 if (position >= tracks[track+1].start_offset) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
479 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
480 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
481 if (lseek (fd_bin, position, SEEK_SET) == -1) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
482 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
483 "[bincue] unexpected end of bin file\n"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
484 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
485 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
486 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
487 if (!read (fd_bin, buf, VCD_SECTOR_SIZE)) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
488 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
489 else |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
490 return VCD_SECTOR_DATA; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
491 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
492 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
493 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
494 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
495 static int cue_vcd_seek_to_track (int track){ |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
496 cue_current_pos.track = track; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
497 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
498 if (cue_read_toc_entry ()) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
499 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
500 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
501 return VCD_SECTOR_DATA * cue_get_msf(); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
502 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
503 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
504 static int cue_vcd_get_track_end (int track){ |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
505 cue_current_pos.frame = tracks[track].frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
506 cue_current_pos.second = tracks[track].second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
507 cue_current_pos.minute = tracks[track].minute; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
508 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
509 return VCD_SECTOR_DATA * cue_get_msf(); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
510 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
511 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
512 static void cue_vcd_read_toc(){ |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
513 int i; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
514 for (i = 0; i < nTracks; ++i) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
515 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
516 mp_msg(MSGT_OPEN,MSGL_INFO, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
517 "track %02d: format=%d %02d:%02d:%02d\n", |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
518 i+1, |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
519 tracks[i].mode, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
520 tracks[i].minute, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
521 tracks[i].second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
522 tracks[i].frame |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
523 ); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
524 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
525 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
526 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
527 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
528 static char vcd_buf[VCD_SECTOR_SIZE]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
529 |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
530 static int cue_vcd_read(stream_t *stream, char *mem, int size) { |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
531 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
532 if (cue_read_raw(vcd_buf)==-1) return 0; // EOF? |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
533 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
534 memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
535 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
536 cue_current_pos.frame++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
537 if (cue_current_pos.frame==75){ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
538 cue_current_pos.frame=0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
539 cue_current_pos.second++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
540 if (cue_current_pos.second==60){ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
541 cue_current_pos.second=0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
542 cue_current_pos.minute++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
543 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
544 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
545 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
546 return VCD_SECTOR_DATA; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
547 } |
15476
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
548 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
549 static int seek(stream_t *s,off_t newpos) { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
550 s->pos=newpos; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
551 cue_set_msf(s->pos/VCD_SECTOR_DATA); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
552 return 1; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
553 } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
554 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
555 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
556 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
557 struct stream_priv_s* p = (struct stream_priv_s*)opts; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
558 int ret,ret2,f,track = 0; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
559 char *filename = NULL, *colon = NULL; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
560 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
561 if(mode != STREAM_READ || !p->filename) { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
562 m_struct_free(&stream_opts,opts); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
563 return STREAM_UNSUPORTED; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
564 } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
565 filename = strdup(p->filename); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
566 if(!filename) { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
567 m_struct_free(&stream_opts,opts); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
568 return STREAM_UNSUPORTED; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
569 } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
570 colon = strstr(filename, ":"); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
571 if(colon) { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
572 if(strlen(colon)>1) |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
573 track = atoi(colon+1); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
574 *colon = 0; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
575 } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
576 if(!track) |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
577 track = 1; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
578 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
579 f = cue_read_cue(filename); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
580 if(f < 0) { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
581 m_struct_free(&stream_opts,opts); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
582 return STREAM_UNSUPORTED; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
583 } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
584 cue_vcd_read_toc(); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
585 ret2=cue_vcd_get_track_end(track); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
586 ret=cue_vcd_seek_to_track(track); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
587 if(ret<0){ |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
588 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n"); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
589 return STREAM_UNSUPORTED; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
590 } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
591 mp_msg(MSGT_OPEN,MSGL_INFO,"CUE stream_open, filename=%s, track=%d, available tracks: %d -> %d\n", filename, track, ret, ret2); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
592 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
593 stream->fd = f; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
594 stream->type = STREAMTYPE_VCDBINCUE; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
595 stream->sector_size = VCD_SECTOR_DATA; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
596 stream->flags = STREAM_READ | STREAM_SEEK_FW; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
597 stream->start_pos = ret; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
598 stream->end_pos = ret2; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
599 stream->fill_buffer = cue_vcd_read; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
600 stream->seek = seek; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
601 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
602 free(filename); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
603 m_struct_free(&stream_opts,opts); |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
604 return STREAM_OK; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
605 } |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
606 |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
607 stream_info_t stream_info_cue = { |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
608 "CUE track", |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
609 "cue", |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
610 "Albeu", |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
611 "based on the code from ???", |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
612 open_s, |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
613 { "cue", NULL }, |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
614 &stream_opts, |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
615 1 // Urls are an option string |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
616 }; |
5eb4994a691f
ported cue:// to the new stream api; note: this stream must still be optimized in its read() and seek() functions
nicodvb
parents:
12646
diff
changeset
|
617 |