Mercurial > mplayer.hg
annotate libmpdemux/cue_read.c @ 13624:18ea4c8f35a9
-fno-PIC will not work on OSX, and it is only useful on x86 anyway.
author | reimar |
---|---|
date | Tue, 12 Oct 2004 21:00:32 +0000 |
parents | 9a495bdc3a1e |
children | 5eb4994a691f |
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" | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
19 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
20 #define byte unsigned char |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
21 #define SIZERAW 2352 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
22 #define SIZEISO_MODE1 2048 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
23 #define SIZEISO_MODE2_RAW 2352 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
24 #define SIZEISO_MODE2_FORM1 2048 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
25 #define SIZEISO_MODE2_FORM2 2336 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
26 #define AUDIO 0 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
27 #define MODE1 1 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
28 #define MODE2 2 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
29 #define MODE1_2352 10 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
30 #define MODE2_2352 20 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
31 #define MODE1_2048 30 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
32 #define MODE2_2336 40 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
33 #define UNKNOWN -1 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
34 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
35 static FILE* fd_cue; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
36 static int fd_bin = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
37 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
38 static char bin_filename[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
39 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
40 static char cue_filename[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
41 static char bincue_path[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
42 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
43 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
44 typedef struct track |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
45 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
46 unsigned short mode; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
47 unsigned short minute; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
48 unsigned short second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
49 unsigned short frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
50 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
51 /* (min*60 + sec) * 75 + fps */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
52 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
53 unsigned long start_sector; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
54 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
55 /* = 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
|
56 /* 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
|
57 unsigned long start_offset; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
58 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
59 /* unsigned char num[3]; */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
60 } tTrack; |
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 /* max 99 tracks on a cd */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
63 static tTrack tracks[100]; |
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 static struct cue_track_pos { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
66 int track; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
67 unsigned short mode; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
68 unsigned short minute; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
69 unsigned short second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
70 unsigned short frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
71 } cue_current_pos; |
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 /* number of tracks on the cd */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
74 static int nTracks = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
75 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
76 /* presumes Line is preloaded with the "current" line of the file */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
77 int cue_getTrackinfo(char *Line, tTrack *track) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
78 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
79 char inum[3]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
80 char min; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
81 char sec; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
82 char fps; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
83 int already_set = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
84 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
85 /* Get the 'mode' */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
86 if (strncmp(&Line[2], "TRACK ", 6)==0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
87 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
88 /* 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
|
89 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
90 track->mode = UNKNOWN; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
97 else return(1); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
98 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
99 /* Get the track indexes */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
100 while(1) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
101 if(! fgets( Line, 256, fd_cue ) ) { break;} |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
102 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
103 if (strncmp(&Line[2], "TRACK ", 6)==0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
104 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
105 /* next track starting */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
106 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
107 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
108 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
109 /* 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
|
110 if (strncmp(&Line[4], "INDEX ", 6)==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 /* 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
|
113 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
|
114 if ((already_set == 0) && |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
115 ((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
|
116 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
117 already_set = 1; |
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 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
|
120 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
|
121 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
|
122 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
123 track->minute = (((min>>4)*10) + (min&0xf)); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
124 track->second = (((sec>>4)*10) + (sec&0xf)); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
125 track->frame = (((fps>>4)*10) + (fps&0xf)); |
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 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
128 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
|
129 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
|
130 else mp_msg (MSGT_OPEN,MSGL_INFO, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
131 "[bincue] Unexpected cuefile line: %s\n", Line); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
132 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
133 return(0); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
134 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
135 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
136 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
137 |
12646 | 138 /* FIXME: the string operations ( strcpy,strcat ) below depend |
139 * on the arrays to have the same size, thus we need to make | |
140 * sure the sizes are in sync. | |
141 */ | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
142 int cue_find_bin (char *firstline) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
143 int i,j; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
144 char s[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
145 char t[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
146 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
147 /* get the filename out of that */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
148 /* 12345 6 */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
149 if (strncmp(firstline, "FILE \"",6)==0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
150 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
151 i = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
152 j = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
153 while ( firstline[6 + i] != '"') |
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 bin_filename[j] = firstline[6 + i]; |
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 /* 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
|
158 switch (bin_filename[j]) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
159 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
160 case '\\': |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
161 j = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
162 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
163 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
164 case '/': |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
165 j = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
166 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
167 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
168 default: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
169 j++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
170 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
171 i++; |
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 bin_filename[j+1] = '\0'; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
174 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
175 } |
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 /* 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
|
178 fd_bin = open (bin_filename, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
179 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
180 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
181 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
|
182 bin_filename); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
183 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
184 /* now try to find it with the path of the cue file */ |
12646 | 185 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
|
186 fd_bin = open (s, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
187 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
188 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
189 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
190 "[bincue] bin filename tested: %s\n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
191 /* 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
|
192 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
|
193 s[strlen(cue_filename) - 3] = '\0'; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
194 strcat(s, "bin"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
195 fd_bin = open (s, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
196 if (fd_bin == -1) |
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 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
199 "[bincue] bin filename tested: %s\n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
200 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
201 /* ok try it with path */ |
12646 | 202 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
|
203 fd_bin = open (t, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
204 if (fd_bin == -1) |
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 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
207 "[bincue] bin filename tested: %s\n",t); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
208 /* 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
|
209 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
|
210 s[strlen(cue_filename) - 3] = '\0'; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
211 strcat(s, "img"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
212 fd_bin = open (s, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
213 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
214 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
215 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
216 "[bincue] bin filename tested: %s \n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
217 /* ok try it with path */ |
12646 | 218 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
|
219 fd_bin = open (t, O_RDONLY); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
220 if (fd_bin == -1) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
221 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
222 mp_msg(MSGT_OPEN,MSGL_STATUS, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
223 "[bincue] bin filename tested: %s\n", s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
224 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
225 /* I'll give up */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
226 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
227 "[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
|
228 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
229 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
230 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
231 } else strcpy(bin_filename, t); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
232 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
233 } else strcpy(bin_filename, s); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
234 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
235 } else strcpy(bin_filename, s); |
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 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
238 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
239 mp_msg(MSGT_OPEN,MSGL_INFO, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
240 "[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
|
241 return 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
242 } |
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 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
|
245 return frame + (second + minute * 60 ) * 75; |
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 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
248 static inline int cue_get_msf() { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
249 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
|
250 cue_current_pos.second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
251 cue_current_pos.frame); |
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 |
8812 | 254 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
|
255 cue_current_pos.frame=sect%75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
256 sect=sect/75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
257 cue_current_pos.second=sect%60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
258 sect=sect/60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
259 cue_current_pos.minute=sect; |
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 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
262 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
|
263 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
264 switch (mode) |
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 case AUDIO: return AUDIO; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
267 case MODE1_2352: return SIZERAW; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
268 case MODE1_2048: return SIZEISO_MODE1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
269 case MODE2_2352: return SIZEISO_MODE2_RAW; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
270 case MODE2_2336: return SIZEISO_MODE2_FORM2; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
271 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
272 default: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
273 mp_msg(MSGT_OPEN,MSGL_FATAL, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
274 "[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
|
275 abort(); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
276 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
277 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
278 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
279 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
280 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
281 int cue_read_cue (char *in_cue_filename) |
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 struct stat filestat; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
284 char sLine[256]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
285 unsigned int sect; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
286 char *s,*t; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
287 int i; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
288 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
289 /* we have no tracks at the beginning */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
290 nTracks = 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
291 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
292 fd_bin = 0; |
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 /* 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
|
295 s = strdup(in_cue_filename); |
8815 | 296 t = strrchr(s, '/'); |
297 if (t == (char *)NULL) | |
298 t = "."; | |
299 else { | |
300 *t = '\0'; | |
301 t = s; | |
8817
84522accebc0
10l, hopefully correct fix, before path was always overwritten to '/'
atmos4
parents:
8815
diff
changeset
|
302 if (*t == '\0') |
8815 | 303 strcpy(t, "/"); |
304 } | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
305 printf ("dirname: %s\n", t); |
12646 | 306 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
|
307 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
308 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
309 /* no path at all? */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
310 if (strcmp(bincue_path, ".") == 0) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
311 printf ("bincue_path: %s\n", bincue_path); |
12646 | 312 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
|
313 } else { |
12646 | 314 strlcpy(cue_filename,in_cue_filename + strlen(bincue_path) + 1, |
315 sizeof( cue_filename )); | |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
316 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
317 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
318 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
319 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
320 /* open the cue file */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
321 fd_cue = fopen (in_cue_filename, "r"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
322 if (fd_cue == NULL) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
323 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
324 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
325 "[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
|
326 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
327 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
328 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
329 /* 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
|
330 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
|
331 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
332 if(! fgets( sLine, 256, fd_cue ) ) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
333 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
334 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
335 "[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
|
336 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
337 return -1; |
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 if (cue_find_bin(sLine)) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
341 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
342 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
343 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
344 |
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 /* now build the track list */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
347 /* 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
|
348 if(! fgets( sLine, 256, fd_cue ) ) |
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 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
351 "[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
|
352 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
353 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
354 } |
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 while(!feof(fd_cue)) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
357 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
358 if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
359 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
360 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
361 "[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
|
362 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
363 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
364 } |
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 /* 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
|
368 if (fstat (fd_bin, &filestat) == -1) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
369 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
370 "[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
|
371 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
372 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
373 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
374 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
375 sect = filestat.st_size / 2352; |
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 tracks[nTracks].frame = sect%75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
378 sect=sect/75; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
379 tracks[nTracks].second = sect%60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
380 sect=sect/60; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
381 tracks[nTracks].minute = sect; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
382 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
383 |
11000 | 384 /* 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
|
385 for(i = 0; i <= nTracks; i++) |
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 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
|
388 tracks[nTracks].second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
389 tracks[nTracks].frame); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
390 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
391 /* 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
|
392 if (i == 0) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
393 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
394 /* 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
|
395 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
|
396 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
|
397 } else |
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[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
|
400 (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
|
401 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
|
402 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
403 } |
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 fclose (fd_cue); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
406 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
407 return fd_bin; |
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 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
410 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
411 |
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 int cue_read_toc_entry() { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
414 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
415 int track = cue_current_pos.track - 1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
416 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
417 /* 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
|
418 if (track >= nTracks) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
419 return -1; |
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 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
422 switch (tracks[track].mode) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
423 { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
424 case AUDIO: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
425 cue_current_pos.mode = AUDIO; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
426 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
427 case MODE1_2352: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
428 cue_current_pos.mode = MODE1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
429 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
430 case MODE1_2048: |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
431 cue_current_pos.mode = MODE1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
432 break; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
433 default: /* MODE2_2352 and MODE2_2336 */ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
434 cue_current_pos.mode = MODE2; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
435 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
436 cue_current_pos.minute = tracks[track].minute; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
437 cue_current_pos.second = tracks[track].second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
438 cue_current_pos.frame = tracks[track].frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
439 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
440 return 0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
441 } |
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 int cue_read_raw(char *buf) { |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
444 int position; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
445 int track = cue_current_pos.track - 1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
446 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
447 /* 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
|
448 position = tracks[track].start_offset + |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
449 (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
|
450 cue_current_pos.second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
451 cue_current_pos.frame) - |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
452 tracks[track].start_sector) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
453 * 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
|
454 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
455 /* 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
|
456 if (position >= tracks[track+1].start_offset) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
457 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
458 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
459 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
|
460 mp_msg(MSGT_OPEN,MSGL_ERR, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
461 "[bincue] unexpected end of bin file\n"); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
462 return -1; |
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 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
465 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
|
466 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
467 else |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
468 return VCD_SECTOR_DATA; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
469 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
470 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
471 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
472 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
473 int cue_vcd_seek_to_track (int track){ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
474 cue_current_pos.track = track; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
475 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
476 if (cue_read_toc_entry ()) |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
477 return -1; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
478 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
479 return VCD_SECTOR_DATA * cue_get_msf(); |
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 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
482 int cue_vcd_get_track_end (int track){ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
483 cue_current_pos.frame = tracks[track].frame; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
484 cue_current_pos.second = tracks[track].second; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
485 cue_current_pos.minute = tracks[track].minute; |
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 return VCD_SECTOR_DATA * cue_get_msf(); |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
488 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
489 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
490 void cue_vcd_read_toc(){ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
491 int i; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
492 for (i = 0; i < nTracks; ++i) { |
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 mp_msg(MSGT_OPEN,MSGL_INFO, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
495 "track %02d: format=%d %02d:%02d:%02d\n", |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
496 i, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
497 tracks[i].mode, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
498 tracks[i].minute, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
499 tracks[i].second, |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
500 tracks[i].frame |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
501 ); |
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 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
504 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
505 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
506 static char vcd_buf[VCD_SECTOR_SIZE]; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
507 |
8812 | 508 int cue_vcd_read(char *mem){ |
8782
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
509 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
510 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
|
511 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
512 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
|
513 |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
514 cue_current_pos.frame++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
515 if (cue_current_pos.frame==75){ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
516 cue_current_pos.frame=0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
517 cue_current_pos.second++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
518 if (cue_current_pos.second==60){ |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
519 cue_current_pos.second=0; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
520 cue_current_pos.minute++; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
521 } |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
522 } |
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 return VCD_SECTOR_DATA; |
6af7a6595cc9
cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff
changeset
|
525 } |