annotate edl.c @ 17945:98f4e3704a76

Allow 6 ways (up/down/left/right/ok/cancel) navigation.
author albeu
date Sat, 25 Mar 2006 17:32:10 +0000
parents ac31a89c3d99
children 3b5b7e78b9af
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
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
11 #ifdef USE_EDL
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
12
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
13 /**
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
14 * Allocates a new EDL record and makes sure allocation was successful.
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
15 *
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
16 * \return New allocated EDL record.
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
17 * \brief Allocate new EDL record
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
18 */
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
19
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
20 static edl_record_ptr edl_alloc_new(edl_record_ptr next_edl_record)
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
21 {
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
22 edl_record_ptr new_record = calloc(1, sizeof(struct edl_record));
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
23 if (!new_record) {
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
24 mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_EdlOutOfMem);
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
25 exit(1);
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
26 }
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
27
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
28 if (next_edl_record) // if this isn't the first record, tell the previous one what the new one is.
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
29 next_edl_record->next = new_record;
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
30 new_record->prev = next_edl_record;
17802
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
31 new_record->next = NULL;
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
32
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
33 return new_record;
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
34 }
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
35
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
36 /**
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
37 * Goes through entire EDL records and frees all memory.
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
38 * Assumes next_edl_record is valid or NULL.
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
39 *
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
40 * \brief Free EDL memory
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
41 */
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
42
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
43 void free_edl(edl_record_ptr next_edl_record)
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
44 {
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
45 edl_record_ptr tmp;
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
46 while (next_edl_record) {
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
47 tmp = next_edl_record->next;
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
48 free(next_edl_record);
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
49 next_edl_record = tmp;
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
50 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
51 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
52
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
53 /** Parses edl_filename to fill EDL operations queue.
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
54 * Prints out how many EDL operations recorded total.
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
55 * \brief Fills EDL operations queue.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
56 */
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
57
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 17109
diff changeset
58 edl_record_ptr edl_parse_file(void)
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
59 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
60 FILE *fd;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
61 char line[100];
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
62 float start, stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
63 int action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
64 int record_count = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
65 int lineCount = 0;
17802
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
66 edl_record_ptr edl_records = NULL;
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
67 edl_record_ptr next_edl_record = NULL;
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
68
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
69 if (edl_filename)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
70 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
71 if ((fd = fopen(edl_filename, "r")) == NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
72 {
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
73 return NULL;
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
74 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
75 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
76 while (fgets(line, 99, fd) != NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
77 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
78 lineCount++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
79 if ((sscanf(line, "%f %f %d", &start, &stop, &action))
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
80 != 3)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
81 {
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
82 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
83 lineCount + 1);
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
84 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
85 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
86 {
17802
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
87 if (next_edl_record && start <= next_edl_record->stop_sec)
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
88 {
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
89 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
90 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineOverlap,
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
91 next_edl_record->prev->stop_sec, start);
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
92 continue;
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
93 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
94 if (stop <= start)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
95 {
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
96 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine,
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
97 line);
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
98 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
99 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
100 }
17802
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
101 next_edl_record = edl_alloc_new(next_edl_record);
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
102 if (!edl_records) edl_records = next_edl_record;
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
103
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
104 next_edl_record->action = action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
105 if (action == EDL_MUTE)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
106 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
107 next_edl_record->length_sec = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
108 next_edl_record->start_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
109 next_edl_record->stop_sec = start;
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
110
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
111 next_edl_record = edl_alloc_new(next_edl_record);
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
112
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
113 next_edl_record->action = action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
114 next_edl_record->length_sec = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
115 next_edl_record->start_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
116 next_edl_record->stop_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
117 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
118 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
119 next_edl_record->length_sec = stop - start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
120 next_edl_record->start_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
121 next_edl_record->stop_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
122 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
123 record_count++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
124 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
125 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
126 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
127 fclose(fd);
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
128 }
17802
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
129 if (edl_records) mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count);
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
130 else mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
ac31a89c3d99 remove edl.c pre-alloc, more readble and safe code
ods15
parents: 17566
diff changeset
131
14807
664b06b907cb Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents: 14607
diff changeset
132 return edl_records;
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
133 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
134
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
135 #endif