Mercurial > mplayer.hg
annotate edl.c @ 14741:c29a660e8bd7
man page review part XVI
author | diego |
---|---|
date | Sun, 20 Feb 2005 18:34:06 +0000 |
parents | 7a80c6ac5058 |
children | 664b06b907cb |
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 |
14607
7a80c6ac5058
several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents:
13358
diff
changeset
|
8 char *edl_filename; // file to extract EDL entries from (-edl) |
7a80c6ac5058
several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents:
13358
diff
changeset
|
9 char *edl_output_filename; // file to put EDL entries in (-edlout) |
7a80c6ac5058
several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents:
13358
diff
changeset
|
10 |
13168 | 11 #ifdef USE_EDL |
12 | |
13358
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 * 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
|
15 * so we check that here. |
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 * \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
|
18 * \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
|
19 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
20 |
13168 | 21 int edl_check_mode(void) |
22 { | |
23 if (edl_filename && edl_output_filename) | |
24 { | |
25 return (EDL_ERROR); | |
26 } | |
27 | |
28 return (1); | |
29 } | |
30 | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
31 /** 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
|
32 * 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
|
33 * 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
|
34 * \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
|
35 * \brief Counts needed EDL entries. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
36 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
37 |
13168 | 38 int edl_count_entries(void) |
39 { | |
40 FILE *fd = NULL; | |
41 int entries = 0; | |
42 int action = 0; | |
43 float start = 0; | |
44 float stop = 0; | |
45 char line[100]; | |
46 | |
47 if (edl_filename) | |
48 { | |
49 if ((fd = fopen(edl_filename, "r")) == NULL) | |
50 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
51 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlCantOpenForRead, |
13168 | 52 edl_filename); |
53 return (EDL_ERROR); | |
54 } else | |
55 { | |
56 while (fgets(line, 99, fd) != NULL) | |
57 { | |
58 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) == | |
59 3) | |
60 { | |
61 if (action == EDL_SKIP) | |
62 entries += 1; | |
63 if (action == EDL_MUTE) | |
64 entries += 2; | |
65 } else | |
66 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
67 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line); |
13168 | 68 return (EDL_ERROR); |
69 } | |
70 | |
71 } | |
72 } | |
73 } else | |
74 { | |
75 return (EDL_ERROR); | |
76 } | |
77 | |
78 return (entries); | |
79 } | |
80 | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
81 /** 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
|
82 * \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
|
83 * \brief Fills EDL operations queue. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
84 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
85 |
13168 | 86 int edl_parse_file(edl_record_ptr edl_records) |
87 { | |
88 FILE *fd; | |
89 char line[100]; | |
90 float start, stop; | |
91 int action; | |
92 int record_count = 0; | |
93 int lineCount = 0; | |
94 struct edl_record *next_edl_record = edl_records; | |
95 | |
96 if (edl_filename) | |
97 { | |
98 if ((fd = fopen(edl_filename, "r")) == NULL) | |
99 { | |
100 return (EDL_ERROR); | |
101 } else | |
102 { | |
103 while (fgets(line, 99, fd) != NULL) | |
104 { | |
105 lineCount++; | |
106 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) | |
107 != 3) | |
108 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
109 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
|
110 lineCount + 1); |
13168 | 111 continue; |
112 } else | |
113 { | |
114 if (record_count > 0) | |
115 { | |
116 if (start <= (next_edl_record - 1)->stop_sec) | |
117 { | |
118 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
|
119 MSGTR_EdlNOValidLine, line); |
13168 | 120 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
|
121 MSGTR_EdlBadLineOverlap, |
13168 | 122 (next_edl_record - 1)->stop_sec, start); |
123 continue; | |
124 } | |
125 } | |
126 if (stop <= start) | |
127 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
128 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, |
13168 | 129 line); |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
130 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop); |
13168 | 131 continue; |
132 } | |
133 next_edl_record->action = action; | |
134 if (action == EDL_MUTE) | |
135 { | |
136 next_edl_record->length_sec = 0; | |
137 next_edl_record->start_sec = start; | |
138 next_edl_record->stop_sec = start; | |
139 next_edl_record->mute_state = EDL_MUTE_START; | |
140 next_edl_record++; | |
141 (next_edl_record - 1)->next = next_edl_record; | |
142 next_edl_record->action = action; | |
143 next_edl_record->length_sec = 0; | |
144 next_edl_record->start_sec = stop; | |
145 next_edl_record->stop_sec = stop; | |
146 next_edl_record->mute_state = EDL_MUTE_END; | |
147 | |
148 } else | |
149 { | |
150 next_edl_record->length_sec = stop - start; | |
151 next_edl_record->start_sec = start; | |
152 next_edl_record->stop_sec = stop; | |
153 } | |
154 next_edl_record++; | |
155 | |
156 if (record_count >= 0) | |
157 { | |
158 (next_edl_record - 1)->next = next_edl_record; | |
159 } | |
160 | |
161 record_count++; | |
162 } | |
163 } | |
164 | |
165 if (record_count > 0) | |
166 { | |
167 (next_edl_record - 1)->next = NULL; | |
168 } | |
169 } | |
170 fclose(fd); | |
171 } else | |
172 { | |
173 return (EDL_ERROR); | |
174 } | |
175 | |
176 return (record_count); | |
177 } | |
178 | |
179 #endif |