Mercurial > mplayer.hg
annotate edl.c @ 17796:6edc4492b777
universal timestamp (= stream_id + timestamp in stream timebase)
-> simplify
add that thing to info packets as type too
author | michael |
---|---|
date | Fri, 10 Mar 2006 14:10:07 +0000 |
parents | f580a7755ac5 |
children | ac31a89c3d99 |
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 /** |
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 | 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; |
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
|
31 |
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 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
|
33 } |
13168 | 34 |
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
|
35 /** |
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 * 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
|
37 * 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
|
38 * |
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 * \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
|
40 */ |
13168 | 41 |
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
|
42 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
|
43 { |
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 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
|
45 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
|
46 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
|
47 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
|
48 next_edl_record = tmp; |
13168 | 49 } |
50 } | |
51 | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
52 /** 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
|
53 * 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
|
54 * \brief Fills EDL operations queue. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
55 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
56 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
17109
diff
changeset
|
57 edl_record_ptr edl_parse_file(void) |
13168 | 58 { |
59 FILE *fd; | |
60 char line[100]; | |
61 float start, stop; | |
62 int action; | |
63 int record_count = 0; | |
64 int lineCount = 0; | |
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
|
65 edl_record_ptr edl_records = edl_alloc_new(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
|
66 edl_record_ptr next_edl_record = edl_records; |
13168 | 67 |
68 if (edl_filename) | |
69 { | |
70 if ((fd = fopen(edl_filename, "r")) == NULL) | |
71 { | |
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
|
72 return NULL; |
13168 | 73 } else |
74 { | |
75 while (fgets(line, 99, fd) != NULL) | |
76 { | |
77 lineCount++; | |
78 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) | |
79 != 3) | |
80 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
81 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
|
82 lineCount + 1); |
13168 | 83 continue; |
84 } else | |
85 { | |
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
|
86 if (next_edl_record->prev && start <= next_edl_record->prev->stop_sec) |
13168 | 87 { |
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
|
88 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
|
89 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
|
90 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
|
91 continue; |
13168 | 92 } |
93 if (stop <= start) | |
94 { | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
95 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, |
13168 | 96 line); |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
97 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop); |
13168 | 98 continue; |
99 } | |
100 next_edl_record->action = action; | |
101 if (action == EDL_MUTE) | |
102 { | |
103 next_edl_record->length_sec = 0; | |
104 next_edl_record->start_sec = start; | |
105 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
|
106 |
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
|
107 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
|
108 |
13168 | 109 next_edl_record->action = action; |
110 next_edl_record->length_sec = 0; | |
111 next_edl_record->start_sec = stop; | |
112 next_edl_record->stop_sec = stop; | |
113 } else | |
114 { | |
115 next_edl_record->length_sec = stop - start; | |
116 next_edl_record->start_sec = start; | |
117 next_edl_record->stop_sec = stop; | |
118 } | |
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
|
119 next_edl_record = edl_alloc_new(next_edl_record); |
13168 | 120 record_count++; |
121 } | |
122 } | |
123 } | |
124 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
|
125 } |
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
|
126 if (next_edl_record->prev) { |
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
|
127 next_edl_record->prev->next = NULL; // a record was before me, i don't want them thinking i'm a real 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
|
128 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count); |
13168 | 129 } |
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
|
130 else { |
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
|
131 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty); |
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 edl_records = NULL; // there was no previous record, we only had one record, the empty one. |
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
|
133 } |
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
|
134 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
|
135 return edl_records; |
13168 | 136 } |
137 | |
138 #endif |