Mercurial > mplayer.hg
comparison stream/stream_cue.c @ 25704:1977ed7f06d4
Simplify cue-parsing
author | reimar |
---|---|
date | Sun, 13 Jan 2008 15:13:04 +0000 |
parents | 986e8d8c1ae7 |
children | c43ce7268677 |
comparison
equal
deleted
inserted
replaced
25703:986e8d8c1ae7 | 25704:1977ed7f06d4 |
---|---|
93 } cue_current_pos; | 93 } cue_current_pos; |
94 | 94 |
95 /* number of tracks on the cd */ | 95 /* number of tracks on the cd */ |
96 static int nTracks = 0; | 96 static int nTracks = 0; |
97 | 97 |
98 static int digits2int(char s[2], int errval) { | |
99 uint8_t a = s[0] - '0'; | |
100 uint8_t b = s[1] - '0'; | |
101 if (a > 9 || b > 9) | |
102 return errval; | |
103 return a * 10 + b; | |
104 } | |
105 | |
98 /* presumes Line is preloaded with the "current" line of the file */ | 106 /* presumes Line is preloaded with the "current" line of the file */ |
99 static int cue_getTrackinfo(char *Line, tTrack *track) | 107 static int cue_getTrackinfo(char *Line, tTrack *track) |
100 { | 108 { |
101 char min; | |
102 char sec; | |
103 char fps; | |
104 int already_set = 0; | 109 int already_set = 0; |
105 | 110 |
106 /* Get the 'mode' */ | 111 /* Get the 'mode' */ |
107 if (strncmp(&Line[2], "TRACK ", 6)==0) | 112 if (strncmp(&Line[2], "TRACK ", 6)==0) |
108 { | 113 { |
129 | 134 |
130 /* Track 0 or 1, take the first an get fill the values*/ | 135 /* Track 0 or 1, take the first an get fill the values*/ |
131 if (strncmp(&Line[4], "INDEX ", 6)==0) | 136 if (strncmp(&Line[4], "INDEX ", 6)==0) |
132 { | 137 { |
133 /* check stuff here so if the answer is false the else stuff below won't be executed */ | 138 /* check stuff here so if the answer is false the else stuff below won't be executed */ |
134 Line[12] = 0; | 139 if ((already_set == 0) && digits2int(Line + 10, 100) <= 1) |
135 if ((already_set == 0) && | |
136 ((strcmp(&Line[10], "00")==0) || (strcmp(&Line[10], "01")==0))) | |
137 { | 140 { |
138 already_set = 1; | 141 already_set = 1; |
139 | 142 |
140 min = ((Line[13]-'0')<<4) | (Line[14]-'0'); | 143 track->minute = digits2int(Line + 13, 0); |
141 sec = ((Line[16]-'0')<<4) | (Line[17]-'0'); | 144 track->second = digits2int(Line + 16, 0); |
142 fps = ((Line[19]-'0')<<4) | (Line[20]-'0'); | 145 track->frame = digits2int(Line + 19, 0); |
143 | |
144 track->minute = (((min>>4)*10) + (min&0xf)); | |
145 track->second = (((sec>>4)*10) + (sec&0xf)); | |
146 track->frame = (((fps>>4)*10) + (fps&0xf)); | |
147 } | 146 } |
148 } | 147 } |
149 else if (strncmp(&Line[4], "PREGAP ", 7)==0) { ; /* ignore */ } | 148 else if (strncmp(&Line[4], "PREGAP ", 7)==0) { ; /* ignore */ } |
150 else if (strncmp(&Line[4], "FLAGS ", 6)==0) { ; /* ignore */ } | 149 else if (strncmp(&Line[4], "FLAGS ", 6)==0) { ; /* ignore */ } |
151 else mp_msg (MSGT_OPEN,MSGL_INFO, | 150 else mp_msg (MSGT_OPEN,MSGL_INFO, |