diff options
author | rtognimp <rtognimp@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-08-28 00:46:05 +0000 |
---|---|---|
committer | rtognimp <rtognimp@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-08-28 00:46:05 +0000 |
commit | afdca81f8f6a33b491f56494c35983de97a2ebea (patch) | |
tree | 7d4354dd372d41c4447cf39ffd2441cdedd7e3cf /edl.c | |
parent | 020f569cc149612f63e58701c743a6c49fa3b063 (diff) | |
download | mpv-afdca81f8f6a33b491f56494c35983de97a2ebea.tar.bz2 mpv-afdca81f8f6a33b491f56494c35983de97a2ebea.tar.xz |
EDL enhancement/fixes:
*Some edl's code moved from mplayer.c to edl.c (mencoder will use the
same functions)
* slighty faster
* removed MAX_EDL_ENTRIES limit (just reserve the memory we really need)
* really treat edl_records as a linked list (coz it is)
* edl now 'remembers' pending operations after a manual _seek_
* better way of handling Mute/Umute eliminates some nasty bugs
when manual seeking (scrwed up mute/unmute order, no audio after
seek, etc)
* seeking while on -edl mode now _WORKS_
Patch by Reynaldo H. Verdejo Pinochet (reynaldo at opendot dot cl)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13169 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'edl.c')
-rw-r--r-- | edl.c | 161 |
1 files changed, 161 insertions, 0 deletions
@@ -0,0 +1,161 @@ +#include <stdio.h> +#include <stdlib.h> +#include "config.h" +#include "mp_msg.h" +#include "edl.h" + +#ifdef USE_EDL + +int edl_check_mode(void) +{ + if (edl_filename && edl_output_filename) + { + return (EDL_ERROR); + } + + return (1); +} + +int edl_count_entries(void) +{ + FILE *fd = NULL; + int entries = 0; + int action = 0; + float start = 0; + float stop = 0; + char line[100]; + + if (edl_filename) + { + if ((fd = fopen(edl_filename, "r")) == NULL) + { + mp_msg(MSGT_CPLAYER, MSGL_WARN, + "Invalid EDL file, cant open '%s' for reading!\n", + edl_filename); + return (EDL_ERROR); + } else + { + while (fgets(line, 99, fd) != NULL) + { + if ((sscanf(line, "%f %f %d", &start, &stop, &action)) == + 3) + { + if (action == EDL_SKIP) + entries += 1; + if (action == EDL_MUTE) + entries += 2; + } else + { + mp_msg(MSGT_CPLAYER, MSGL_WARN, + "Invalid EDL line: %s\n", line); + return (EDL_ERROR); + } + + } + } + } else + { + return (EDL_ERROR); + } + + return (entries); +} + +int edl_parse_file(edl_record_ptr edl_records) +{ + FILE *fd; + char line[100]; + float start, stop; + int action; + int record_count = 0; + int lineCount = 0; + struct edl_record *next_edl_record = edl_records; + + if (edl_filename) + { + if ((fd = fopen(edl_filename, "r")) == NULL) + { + return (EDL_ERROR); + } else + { + while (fgets(line, 99, fd) != NULL) + { + lineCount++; + if ((sscanf(line, "%f %f %d", &start, &stop, &action)) + != 3) + { + mp_msg(MSGT_CPLAYER, MSGL_WARN, + "Badly formated EDL line [%d]. Discarding!\n", + lineCount + 1, line); + continue; + } else + { + if (record_count > 0) + { + if (start <= (next_edl_record - 1)->stop_sec) + { + mp_msg(MSGT_CPLAYER, MSGL_WARN, + "Invalid EDL line [%d]: %s", + lineCount, line); + mp_msg(MSGT_CPLAYER, MSGL_WARN, + "Last stop position was [%f]; next start is [%f]. Entries must be in chronological order and cannot overlap. Discarding!\n", + (next_edl_record - 1)->stop_sec, start); + continue; + } + } + if (stop <= start) + { + mp_msg(MSGT_CPLAYER, MSGL_WARN, + "Invalid EDL line [%d]: %s", lineCount, + line); + mp_msg(MSGT_CPLAYER, MSGL_WARN, + "Stop time must follow start time. Discarding!\n"); + continue; + } + next_edl_record->action = action; + if (action == EDL_MUTE) + { + next_edl_record->length_sec = 0; + next_edl_record->start_sec = start; + next_edl_record->stop_sec = start; + next_edl_record->mute_state = EDL_MUTE_START; + next_edl_record++; + (next_edl_record - 1)->next = next_edl_record; + next_edl_record->action = action; + next_edl_record->length_sec = 0; + next_edl_record->start_sec = stop; + next_edl_record->stop_sec = stop; + next_edl_record->mute_state = EDL_MUTE_END; + + } else + { + next_edl_record->length_sec = stop - start; + next_edl_record->start_sec = start; + next_edl_record->stop_sec = stop; + } + next_edl_record++; + + if (record_count >= 0) + { + (next_edl_record - 1)->next = next_edl_record; + } + + record_count++; + } + } + + if (record_count > 0) + { + (next_edl_record - 1)->next = NULL; + } + } + fclose(fd); + } else + { + return (EDL_ERROR); + } + + return (record_count); +} + +#endif |