annotate libmpdemux/cue_read.c @ 18505:01b9f29c2fb5

Fix some potential integer overflow in memory allocation (mot of these were probably safe or disabled anyway)
author rtognimp
date Sun, 14 May 2006 15:51:05 +0000
parents f580a7755ac5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
10 #include <fcntl.h>
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
11
8812
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
12 #include "config.h"
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
13 #include "mp_msg.h"
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
14 #include "help_mp.h"
8812
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
15
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
16 #include "stream.h"
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
17
f6456b177fdc vcd_read_cue.h -> cue_read.c+h
arpi
parents: 8782
diff changeset
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"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16967
diff changeset
20 #include "m_option.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16967
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,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
153 MSGTR_MPDEMUX_CUEREAD_UnexpectedCuefileLine, Line);
8782
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
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
160 /* FIXME: the string operations ( strcpy,strcat ) below depend
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
161 * on the arrays to have the same size, thus we need to make
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
162 * sure the sizes are in sync.
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
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 */
15482
c4af653727eb better implementation of read()
nicodvb
parents: 15477
diff changeset
171 mp_msg (MSGT_OPEN,MSGL_INFO, "[bincue] cue_find_bin(%s)\n", firstline);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
172 if (strncmp(firstline, "FILE \"",6)==0)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
173 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
174 i = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
175 j = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
176 while ( firstline[6 + i] != '"')
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
177 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
178 bin_filename[j] = firstline[6 + i];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
179
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
180 /* 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
181 switch (bin_filename[j])
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
182 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
183 case '\\':
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
184 j = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
185 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
186
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
187 case '/':
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
188 j = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
189 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
190
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
191 default:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
192 j++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
193 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
194 i++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
195 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
196 bin_filename[j+1] = '\0';
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
200 /* 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
201 fd_bin = open (bin_filename, O_RDONLY);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
202 if (fd_bin == -1)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
203 {
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
204 mp_msg(MSGT_OPEN,MSGL_STATUS, MSGTR_MPDEMUX_CUEREAD_BinFilenameTested,
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
205 bin_filename);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
206
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
207 /* now try to find it with the path of the cue file */
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
208 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
209 fd_bin = open (s, O_RDONLY);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
210 if (fd_bin == -1)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
211 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
212 mp_msg(MSGT_OPEN,MSGL_STATUS,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
213 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
214 /* 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
215 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
216 s[strlen(cue_filename) - 3] = '\0';
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
217 strcat(s, "bin");
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
218 fd_bin = open (s, O_RDONLY);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
219 if (fd_bin == -1)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
220 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
221 mp_msg(MSGT_OPEN,MSGL_STATUS,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
222 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
223
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
224 /* ok try it with path */
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
225 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
226 fd_bin = open (t, O_RDONLY);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
227 if (fd_bin == -1)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
228 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
229 mp_msg(MSGT_OPEN,MSGL_STATUS,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
230 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested,t);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
231 /* 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
232 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
233 s[strlen(cue_filename) - 3] = '\0';
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
234 strcat(s, "img");
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
235 fd_bin = open (s, O_RDONLY);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
236 if (fd_bin == -1)
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 mp_msg(MSGT_OPEN,MSGL_STATUS,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
239 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
240 /* ok try it with path */
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
241 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
242 fd_bin = open (t, O_RDONLY);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
243 if (fd_bin == -1)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
244 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
245 mp_msg(MSGT_OPEN,MSGL_STATUS,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
246 MSGTR_MPDEMUX_CUEREAD_BinFilenameTested, s);
8782
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 /* I'll give up */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
249 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
250 MSGTR_MPDEMUX_CUEREAD_CannotFindBinFile);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
251 return -1;
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 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
254 } else strcpy(bin_filename, t);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
255
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
256 } else strcpy(bin_filename, s);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
257
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
258 } else strcpy(bin_filename, s);
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
262 mp_msg(MSGT_OPEN,MSGL_INFO,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
263 MSGTR_MPDEMUX_CUEREAD_UsingBinFile, bin_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
264 return 0;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
267 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
268 return frame + (second + minute * 60 ) * 75;
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
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 17012
diff changeset
271 static inline int cue_get_msf(void) {
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
272 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
273 cue_current_pos.second,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
274 cue_current_pos.frame);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
275 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
276
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
277 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
278 cue_current_pos.frame=sect%75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
279 sect=sect/75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
280 cue_current_pos.second=sect%60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
281 sect=sect/60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
282 cue_current_pos.minute=sect;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
285 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
286 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
287 switch (mode)
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 case AUDIO: return AUDIO;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
290 case MODE1_2352: return SIZERAW;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
291 case MODE1_2048: return SIZEISO_MODE1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
292 case MODE2_2352: return SIZEISO_MODE2_RAW;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
293 case MODE2_2336: return SIZEISO_MODE2_FORM2;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
294
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
295 default:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
296 mp_msg(MSGT_OPEN,MSGL_FATAL,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
297 MSGTR_MPDEMUX_CUEREAD_UnknownModeForBinfile);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
298 abort();
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
303
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
304 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
305 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
306 struct stat filestat;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
307 char sLine[256];
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
308 unsigned int sect;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
309 char *s,*t;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
310 int i;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
311
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
312 /* we have no tracks at the beginning */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
313 nTracks = 0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
314
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
315 fd_bin = 0;
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 /* 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
318 s = strdup(in_cue_filename);
8815
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
319 t = strrchr(s, '/');
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
320 if (t == (char *)NULL)
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
321 t = ".";
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
322 else {
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
323 *t = '\0';
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
324 t = s;
8817
84522accebc0 10l, hopefully correct fix, before path was always overwritten to '/'
atmos4
parents: 8815
diff changeset
325 if (*t == '\0')
8815
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
326 strcpy(t, "/");
74dd9b5cc7f6 dirname() (from libgen) dependency removed
arpi
parents: 8813
diff changeset
327 }
15482
c4af653727eb better implementation of read()
nicodvb
parents: 15477
diff changeset
328
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
329 strlcpy(bincue_path,t,sizeof( bincue_path ));
15482
c4af653727eb better implementation of read()
nicodvb
parents: 15477
diff changeset
330 mp_msg(MSGT_OPEN,MSGL_V,"dirname: %s, cuepath: %s\n", t, bincue_path);
8782
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 /* no path at all? */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
333 if (strcmp(bincue_path, ".") == 0) {
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
334 mp_msg(MSGT_OPEN,MSGL_V,"bincue_path: %s\n", bincue_path);
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
335 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
336 } else {
12646
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
337 strlcpy(cue_filename,in_cue_filename + strlen(bincue_path) + 1,
9a495bdc3a1e string handling security fixes
diego
parents: 11000
diff changeset
338 sizeof( cue_filename ));
8782
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
343 /* open the cue file */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
344 fd_cue = fopen (in_cue_filename, "r");
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
345 if (fd_cue == NULL)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
346 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
347 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
348 MSGTR_MPDEMUX_CUEREAD_CannotOpenCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
349 return -1;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
352 /* 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
353 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
354
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
355 if(! fgets( sLine, 256, fd_cue ) )
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
356 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
357 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
358 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
359 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
360 return -1;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
363 if (cue_find_bin(sLine)) {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
364 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
365 return -1;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
369 /* now build the track list */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
370 /* 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
371 if(! fgets( sLine, 256, fd_cue ) )
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
372 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
373 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
374 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
375 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
376 return -1;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
379 while(!feof(fd_cue))
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
380 {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
381 if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0)
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 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
384 MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
385 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
386 return -1;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
390 /* 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
391 if (fstat (fd_bin, &filestat) == -1) {
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
392 mp_msg(MSGT_OPEN,MSGL_ERR,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
393 MSGTR_MPDEMUX_CUEREAD_ErrGettingBinFileSize);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
394 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
395 return -1;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
398 sect = filestat.st_size / 2352;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
399
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
400 tracks[nTracks].frame = sect%75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
401 sect=sect/75;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
402 tracks[nTracks].second = sect%60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
403 sect=sect/60;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
404 tracks[nTracks].minute = sect;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
405
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
406
11000
6e35326c742f many small typo and grammar fixes
gabucino
parents: 8817
diff changeset
407 /* 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
408 for(i = 0; i <= nTracks; i++)
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 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
411 tracks[nTracks].second,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
412 tracks[nTracks].frame);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
413
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
414 /* 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
415 if (i == 0)
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 /* 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
418 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
419 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
420 } else
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 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
423 (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
424 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
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
428 fclose (fd_cue);
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
429
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
430 return fd_bin;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
435
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 17012
diff changeset
436 static int cue_read_toc_entry(void) {
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
437
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
438 int track = cue_current_pos.track - 1;
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 /* 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
441 if (track >= nTracks)
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
442 return -1;
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
445 switch (tracks[track].mode)
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 case AUDIO:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
448 cue_current_pos.mode = AUDIO;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
449 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
450 case MODE1_2352:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
451 cue_current_pos.mode = MODE1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
452 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
453 case MODE1_2048:
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
454 cue_current_pos.mode = MODE1;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
455 break;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
456 default: /* MODE2_2352 and MODE2_2336 */
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
457 cue_current_pos.mode = MODE2;
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 cue_current_pos.minute = tracks[track].minute;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
460 cue_current_pos.second = tracks[track].second;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
461 cue_current_pos.frame = tracks[track].frame;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
462
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
463 return 0;
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
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
466 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
467 cue_current_pos.track = track;
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 if (cue_read_toc_entry ())
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
470 return -1;
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 return VCD_SECTOR_DATA * cue_get_msf();
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
473 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
474
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
475 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
476 cue_current_pos.frame = tracks[track].frame;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
477 cue_current_pos.second = tracks[track].second;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
478 cue_current_pos.minute = tracks[track].minute;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
479
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
480 return VCD_SECTOR_DATA * cue_get_msf();
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
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 17012
diff changeset
483 static void cue_vcd_read_toc(void){
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
484 int i;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
485 for (i = 0; i < nTracks; ++i) {
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 mp_msg(MSGT_OPEN,MSGL_INFO,
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
488 MSGTR_MPDEMUX_CUEREAD_InfoTrackFormat,
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
489 i+1,
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
490 tracks[i].mode,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
491 tracks[i].minute,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
492 tracks[i].second,
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
493 tracks[i].frame
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
494 );
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
495 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
496 }
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
497
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
498 static int cue_vcd_read(stream_t *stream, char *mem, int size) {
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
499 unsigned long position;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
500 int track = cue_current_pos.track - 1;
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
501
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
502 position = tracks[track].start_offset +
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
503 (cue_msf_2_sector(cue_current_pos.minute,
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
504 cue_current_pos.second,
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
505 cue_current_pos.frame) -
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
506 tracks[track].start_sector)
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
507 * cue_mode_2_sector_size(tracks[track].mode);
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
508
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
509
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
510 if(position >= tracks[track+1].start_offset)
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
511 return 0;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
512
15482
c4af653727eb better implementation of read()
nicodvb
parents: 15477
diff changeset
513 if(lseek(fd_bin, position+VCD_SECTOR_OFFS, SEEK_SET) == -1) {
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
514 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_UnexpectedBinFileEOF);
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
515 return 0;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
516 }
8782
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
517
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
518 if(read(fd_bin, mem, VCD_SECTOR_DATA) != VCD_SECTOR_DATA) {
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
519 mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_MPDEMUX_CUEREAD_CannotReadNBytesOfPayload, VCD_SECTOR_DATA);
15477
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
520 return 0;
15f012150986 more efficient read() without memcpy()
nicodvb
parents: 15476
diff changeset
521 }
8782
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 cue_current_pos.frame++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
524 if (cue_current_pos.frame==75){
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
525 cue_current_pos.frame=0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
526 cue_current_pos.second++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
527 if (cue_current_pos.second==60){
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
528 cue_current_pos.second=0;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
529 cue_current_pos.minute++;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
530 }
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
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
533 return VCD_SECTOR_DATA;
6af7a6595cc9 cdrwin-style bin/cue VCD image support (-vcd <track> -cuefile file.cue)
arpi
parents:
diff changeset
534 }
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
535
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
536 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
537 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
538 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
539 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
540 }
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
541
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
542
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
543 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
544 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
545 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
546 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
547
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 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
549 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
550 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
551 }
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 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
553 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
554 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
555 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
556 }
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 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
558 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
559 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
560 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
561 *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
562 }
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 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
564 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
565
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 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
567 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
568 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
569 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
570 }
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 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
572 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
573 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
574 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
575 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
576 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
577 }
16967
32e2c59c8e86 [TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents: 15482
diff changeset
578 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_MPDEMUX_CUEREAD_CueStreamInfo_FilenameTrackTracksavail, filename, track, ret, ret2);
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
579
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 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
581 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
582 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
583 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
584 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
585 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
586 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
587 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
588
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 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
590 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
591 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
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
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_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
595 "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
596 "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
597 "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
598 "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
599 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
600 { "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
601 &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
602 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
603 };
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