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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
1 #include <stdio.h>
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
2 #include <stdlib.h>
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
3 #include "config.h"
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
4 #include "mp_msg.h"
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
7
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
8 #ifdef USE_EDL
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
18 int edl_check_mode(void)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
19 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
20 if (edl_filename && edl_output_filename)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
21 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
22 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
23 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
24
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
25 return (1);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
26 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
35 int edl_count_entries(void)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
36 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
37 FILE *fd = NULL;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
38 int entries = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
39 int action = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
40 float start = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
41 float stop = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
42 char line[100];
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
43
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
44 if (edl_filename)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
45 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
46 if ((fd = fopen(edl_filename, "r")) == NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
49 edl_filename);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
50 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
51 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
52 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
53 while (fgets(line, 99, fd) != NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
54 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
55 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) ==
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
56 3)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
57 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
58 if (action == EDL_SKIP)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
59 entries += 1;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
60 if (action == EDL_MUTE)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
61 entries += 2;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
62 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
65 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
66 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
67
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
68 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
69 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
70 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
71 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
72 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
73 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
74
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
75 return (entries);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
76 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
83 int edl_parse_file(edl_record_ptr edl_records)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
84 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
85 FILE *fd;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
86 char line[100];
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
87 float start, stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
88 int action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
89 int record_count = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
90 int lineCount = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
91 struct edl_record *next_edl_record = edl_records;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
92
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
93 if (edl_filename)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
94 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
95 if ((fd = fopen(edl_filename, "r")) == NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
96 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
97 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
98 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
99 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
100 while (fgets(line, 99, fd) != NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
101 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
102 lineCount++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
103 if ((sscanf(line, "%f %f %d", &start, &stop, &action))
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
104 != 3)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
108 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
109 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
110 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
111 if (record_count > 0)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
112 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
113 if (start <= (next_edl_record - 1)->stop_sec)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
114 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
119 (next_edl_record - 1)->stop_sec, start);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
120 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
121 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
122 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
123 if (stop <= start)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
128 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
129 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
130 next_edl_record->action = action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
131 if (action == EDL_MUTE)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
132 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
133 next_edl_record->length_sec = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
134 next_edl_record->start_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
135 next_edl_record->stop_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
136 next_edl_record->mute_state = EDL_MUTE_START;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
137 next_edl_record++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
138 (next_edl_record - 1)->next = next_edl_record;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
139 next_edl_record->action = action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
140 next_edl_record->length_sec = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
141 next_edl_record->start_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
142 next_edl_record->stop_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
143 next_edl_record->mute_state = EDL_MUTE_END;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
144
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
145 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
146 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
147 next_edl_record->length_sec = stop - start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
148 next_edl_record->start_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
149 next_edl_record->stop_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
150 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
151 next_edl_record++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
152
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
153 if (record_count >= 0)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
154 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
155 (next_edl_record - 1)->next = next_edl_record;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
156 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
157
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
158 record_count++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
159 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
160 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
161
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
162 if (record_count > 0)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
163 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
164 (next_edl_record - 1)->next = NULL;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
165 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
166 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
167 fclose(fd);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
168 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
169 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
170 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
171 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
172
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
173 return (record_count);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
174 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
175
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
176 #endif