11 * We can't do -edl and -edlout at the same time
12 * so we check that here.
14 * \return EDL_ERROR on error and 1 otherwise.
15 * \brief Makes sure EDL has been called correctly.
18 int edl_check_mode(void)
20 if (edl_filename
&& edl_output_filename
)
28 /** Calculates the total amount of edl_records we will need
29 * to hold the EDL operations queue, we need one edl_record
30 * for each SKIP and two for each MUTE.
31 * \return Number of necessary EDL entries, EDL_ERROR when file can't be read.
32 * \brief Counts needed EDL entries.
35 int edl_count_entries(void)
46 if ((fd
= fopen(edl_filename
, "r")) == NULL
)
48 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlCantOpenForRead
,
53 while (fgets(line
, 99, fd
) != NULL
)
55 if ((sscanf(line
, "%f %f %d", &start
, &stop
, &action
)) ==
58 if (action
== EDL_SKIP
)
60 if (action
== EDL_MUTE
)
64 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlNOValidLine
, line
);
78 /** Parses edl_filename to fill EDL operations queue.
79 * \return Number of stored EDL records or EDL_ERROR when file can't be read.
80 * \brief Fills EDL operations queue.
83 int edl_parse_file(edl_record_ptr edl_records
)
91 struct edl_record
*next_edl_record
= edl_records
;
95 if ((fd
= fopen(edl_filename
, "r")) == NULL
)
100 while (fgets(line
, 99, fd
) != NULL
)
103 if ((sscanf(line
, "%f %f %d", &start
, &stop
, &action
))
106 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadlyFormattedLine
,
111 if (record_count
> 0)
113 if (start
<= (next_edl_record
- 1)->stop_sec
)
115 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
116 MSGTR_EdlNOValidLine
, line
);
117 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
118 MSGTR_EdlBadLineOverlap
,
119 (next_edl_record
- 1)->stop_sec
, start
);
125 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlNOValidLine
,
127 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadLineBadStop
);
130 next_edl_record
->action
= action
;
131 if (action
== EDL_MUTE
)
133 next_edl_record
->length_sec
= 0;
134 next_edl_record
->start_sec
= start
;
135 next_edl_record
->stop_sec
= start
;
136 next_edl_record
->mute_state
= EDL_MUTE_START
;
138 (next_edl_record
- 1)->next
= next_edl_record
;
139 next_edl_record
->action
= action
;
140 next_edl_record
->length_sec
= 0;
141 next_edl_record
->start_sec
= stop
;
142 next_edl_record
->stop_sec
= stop
;
143 next_edl_record
->mute_state
= EDL_MUTE_END
;
147 next_edl_record
->length_sec
= stop
- start
;
148 next_edl_record
->start_sec
= start
;
149 next_edl_record
->stop_sec
= stop
;
153 if (record_count
>= 0)
155 (next_edl_record
- 1)->next
= next_edl_record
;
162 if (record_count
> 0)
164 (next_edl_record
- 1)->next
= NULL
;
173 return (record_count
);