Mercurial > mplayer.hg
annotate edl.c @ 13887:48ce49693b3c
respect immed uninit flag, initialize ao_data.outburst.
author | reimar |
---|---|
date | Sat, 06 Nov 2004 22:33:17 +0000 |
parents | 567875b88aab |
children | 7a80c6ac5058 |
rev | line source |
---|---|
13168 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include "config.h" | |
4 #include "mp_msg.h" | |
5 #include "edl.h" | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
6 #include "help_mp.h" |
13168 | 7 |
8 #ifdef USE_EDL | |
9 | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
10 /** |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
11 * We can't do -edl and -edlout at the same time |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
12 * so we check that here. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
13 * |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
14 * \return EDL_ERROR on error and 1 otherwise. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
15 * \brief Makes sure EDL has been called correctly. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
16 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
17 |
13168 | 18 int edl_check_mode(void) |
19 { | |
20 if (edl_filename && edl_output_filename) | |
21 { | |
22 return (EDL_ERROR); | |
23 } | |
24 | |
25 return (1); | |
26 } | |
27 | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
28 /** Calculates the total amount of edl_records we will need |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
29 * to hold the EDL operations queue, we need one edl_record |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
30 * for each SKIP and two for each MUTE. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
31 * \return Number of necessary EDL entries, EDL_ERROR when file can't be read. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
32 * \brief Counts needed EDL entries. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
33 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
34 |
13168 | 35 int edl_count_entries(void) |
36 { | |
37 FILE *fd = NULL; | |
38 int entries = 0; | |
39 int action = 0; | |
40 float start = 0; | |
41 float stop = 0; | |
42 char line[100]; | |
43 | |
44 if (edl_filename) | |
45 { | |
46 if ((fd = fopen(edl_filename, "r")) == NULL) | |
47 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
48 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlCantOpenForRead, |
13168 | 49 edl_filename); |
50 return (EDL_ERROR); | |
51 } else | |
52 { | |
53 while (fgets(line, 99, fd) != NULL) | |
54 { | |
55 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) == | |
56 3) | |
57 { | |
58 if (action == EDL_SKIP) | |
59 entries += 1; | |
60 if (action == EDL_MUTE) | |
61 entries += 2; | |
62 } else | |
63 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
64 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line); |
13168 | 65 return (EDL_ERROR); |
66 } | |
67 | |
68 } | |
69 } | |
70 } else | |
71 { | |
72 return (EDL_ERROR); | |
73 } | |
74 | |
75 return (entries); | |
76 } | |
77 | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
78 /** Parses edl_filename to fill EDL operations queue. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
79 * \return Number of stored EDL records or EDL_ERROR when file can't be read. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
80 * \brief Fills EDL operations queue. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
81 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
82 |
13168 | 83 int edl_parse_file(edl_record_ptr edl_records) |
84 { | |
85 FILE *fd; | |
86 char line[100]; | |
87 float start, stop; | |
88 int action; | |
89 int record_count = 0; | |
90 int lineCount = 0; | |
91 struct edl_record *next_edl_record = edl_records; | |
92 | |
93 if (edl_filename) | |
94 { | |
95 if ((fd = fopen(edl_filename, "r")) == NULL) | |
96 { | |
97 return (EDL_ERROR); | |
98 } else | |
99 { | |
100 while (fgets(line, 99, fd) != NULL) | |
101 { | |
102 lineCount++; | |
103 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) | |
104 != 3) | |
105 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
106 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadlyFormattedLine, |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
107 lineCount + 1); |
13168 | 108 continue; |
109 } else | |
110 { | |
111 if (record_count > 0) | |
112 { | |
113 if (start <= (next_edl_record - 1)->stop_sec) | |
114 { | |
115 mp_msg(MSGT_CPLAYER, MSGL_WARN, | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
116 MSGTR_EdlNOValidLine, line); |
13168 | 117 mp_msg(MSGT_CPLAYER, MSGL_WARN, |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
118 MSGTR_EdlBadLineOverlap, |
13168 | 119 (next_edl_record - 1)->stop_sec, start); |
120 continue; | |
121 } | |
122 } | |
123 if (stop <= start) | |
124 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
125 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, |
13168 | 126 line); |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
127 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop); |
13168 | 128 continue; |
129 } | |
130 next_edl_record->action = action; | |
131 if (action == EDL_MUTE) | |
132 { | |
133 next_edl_record->length_sec = 0; | |
134 next_edl_record->start_sec = start; | |
135 next_edl_record->stop_sec = start; | |
136 next_edl_record->mute_state = EDL_MUTE_START; | |
137 next_edl_record++; | |
138 (next_edl_record - 1)->next = next_edl_record; | |
139 next_edl_record->action = action; | |
140 next_edl_record->length_sec = 0; | |
141 next_edl_record->start_sec = stop; | |
142 next_edl_record->stop_sec = stop; | |
143 next_edl_record->mute_state = EDL_MUTE_END; | |
144 | |
145 } else | |
146 { | |
147 next_edl_record->length_sec = stop - start; | |
148 next_edl_record->start_sec = start; | |
149 next_edl_record->stop_sec = stop; | |
150 } | |
151 next_edl_record++; | |
152 | |
153 if (record_count >= 0) | |
154 { | |
155 (next_edl_record - 1)->next = next_edl_record; | |
156 } | |
157 | |
158 record_count++; | |
159 } | |
160 } | |
161 | |
162 if (record_count > 0) | |
163 { | |
164 (next_edl_record - 1)->next = NULL; | |
165 } | |
166 } | |
167 fclose(fd); | |
168 } else | |
169 { | |
170 return (EDL_ERROR); | |
171 } | |
172 | |
173 return (record_count); | |
174 } | |
175 | |
176 #endif |