8 char *edl_filename
; // file to extract EDL entries from (-edl)
9 char *edl_output_filename
; // file to put EDL entries in (-edlout)
14 * We can't do -edl and -edlout at the same time
15 * so we check that here.
17 * \return EDL_ERROR on error and 1 otherwise.
18 * \brief Makes sure EDL has been called correctly.
21 int edl_check_mode(void)
23 if (edl_filename
&& edl_output_filename
)
32 * Allocates a new EDL record and makes sure allocation was successful.
34 * \return New allocated EDL record.
35 * \brief Allocate new EDL record
38 static edl_record_ptr
edl_alloc_new(edl_record_ptr next_edl_record
)
40 edl_record_ptr new_record
= calloc(1, sizeof(struct edl_record
));
42 mp_msg(MSGT_CPLAYER
, MSGL_FATAL
, MSGTR_EdlOutOfMem
);
46 if (next_edl_record
) // if this isn't the first record, tell the previous one what the new one is.
47 next_edl_record
->next
= new_record
;
48 new_record
->prev
= next_edl_record
;
54 * Goes through entire EDL records and frees all memory.
55 * Assumes next_edl_record is valid or NULL.
57 * \brief Free EDL memory
60 void free_edl(edl_record_ptr next_edl_record
)
63 while (next_edl_record
) {
64 tmp
= next_edl_record
->next
;
65 free(next_edl_record
);
66 next_edl_record
= tmp
;
70 /** Parses edl_filename to fill EDL operations queue.
71 * Prints out how many EDL operations recorded total.
72 * \brief Fills EDL operations queue.
75 edl_record_ptr
edl_parse_file()
83 edl_record_ptr edl_records
= edl_alloc_new(NULL
);
84 edl_record_ptr next_edl_record
= edl_records
;
88 if ((fd
= fopen(edl_filename
, "r")) == NULL
)
93 while (fgets(line
, 99, fd
) != NULL
)
96 if ((sscanf(line
, "%f %f %d", &start
, &stop
, &action
))
99 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadlyFormattedLine
,
104 if (next_edl_record
->prev
&& start
<= next_edl_record
->prev
->stop_sec
)
106 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlNOValidLine
, line
);
107 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadLineOverlap
,
108 next_edl_record
->prev
->stop_sec
, start
);
113 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlNOValidLine
,
115 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadLineBadStop
);
118 next_edl_record
->action
= action
;
119 if (action
== EDL_MUTE
)
121 next_edl_record
->length_sec
= 0;
122 next_edl_record
->start_sec
= start
;
123 next_edl_record
->stop_sec
= start
;
125 next_edl_record
= edl_alloc_new(next_edl_record
);
127 next_edl_record
->action
= action
;
128 next_edl_record
->length_sec
= 0;
129 next_edl_record
->start_sec
= stop
;
130 next_edl_record
->stop_sec
= stop
;
133 next_edl_record
->length_sec
= stop
- start
;
134 next_edl_record
->start_sec
= start
;
135 next_edl_record
->stop_sec
= stop
;
137 next_edl_record
= edl_alloc_new(next_edl_record
);
144 if (next_edl_record
->prev
) {
145 next_edl_record
->prev
->next
= NULL
; // a record was before me, i don't want them thinking i'm a real record.
146 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdlRecordsNo
, record_count
);
149 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdlQueueEmpty
);
150 edl_records
= NULL
; // there was no previous record, we only had one record, the empty one.
152 free(next_edl_record
);