From 7576885677764a71fe03cec5f697f8a28f9365c8 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 19 Jan 2012 06:49:47 +0200 Subject: [PATCH] core: remove old EDL mode (--edl option) Remove the old EDL implementation that was activated with the --edl option. It is mostly redundant and inferior compared to the newer demux_edl support, though currently there's no support for using the same EDL files with the new implementation and the mute functionality of the old implementation is not supported. The main reason to remove the old implementation at this point is that the mute functionality would conflict with following audio volume handling changes, and working on the old code would be a wasted effort in the long run as at some point it would be removed anyway. The --edlout functionality is kept for now, even though after this commit there is no code that could directly read its output. --- Makefile | 1 - cfg-mplayer.h | 3 +- command.c | 13 ----- edl.c | 158 -------------------------------------------------- edl.h | 47 --------------- m_option.h | 1 + mp_core.h | 3 +- mplayer.c | 78 ++----------------------- 8 files changed, 9 insertions(+), 295 deletions(-) delete mode 100644 edl.c delete mode 100644 edl.h diff --git a/Makefile b/Makefile index 21191655e7..59cbdc4950 100644 --- a/Makefile +++ b/Makefile @@ -218,7 +218,6 @@ SRCS_COMMON = asxparser.c \ codec-cfg.c \ cpudetect.c \ defaultopts.c \ - edl.c \ fmt-conversion.c \ m_config.c \ m_option.c \ diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 471e3d8505..2f1ba666bb 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -488,7 +488,8 @@ const m_option_t common_opts[] = { // stop at given position {"endpos", &end_at, CONF_TYPE_TIME_SIZE, 0, 0, 0, NULL}, - {"edl", &edl_filename, CONF_TYPE_STRING, 0, 0, 0, NULL}, + OPT_ERRORMESSAGE("edl", "Old EDL functionality using the --edl option is " + "not supported.\n"), // AVI specific: force non-interleaved mode {"ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1, NULL}, diff --git a/command.c b/command.c index 5551da715c..48f0ecb013 100644 --- a/command.c +++ b/command.c @@ -719,8 +719,6 @@ static int mp_property_volume(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; mpctx->user_muted = 0; switch (action) { @@ -756,8 +754,6 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg, switch (action) { case M_PROPERTY_SET: - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; if (!arg) return M_PROPERTY_ERROR; if ((!!*(int *) arg) != mpctx->mixer.muted) @@ -766,18 +762,9 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg, return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; mixer_mute(&mpctx->mixer); mpctx->user_muted = mpctx->mixer.muted; return M_PROPERTY_OK; - case M_PROPERTY_PRINT: - if (!arg) - return M_PROPERTY_ERROR; - if (mpctx->edl_muted) { - *(char **) arg = talloc_strdup(NULL, mp_gtext("enabled (EDL)")); - return M_PROPERTY_OK; - } default: return m_property_flag(prop, action, arg, &mpctx->mixer.muted); diff --git a/edl.c b/edl.c deleted file mode 100644 index 677a2efb24..0000000000 --- a/edl.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include "config.h" -#include "mp_msg.h" -#include "edl.h" - -char *edl_filename; // file to extract EDL entries from (-edl) -char *edl_output_filename; // file to put EDL entries in (-edlout) - -/** - * Allocates a new EDL record and makes sure allocation was successful. - * - * \return New allocated EDL record. - * \brief Allocate new EDL record - */ - -static edl_record_ptr edl_alloc_new(edl_record_ptr next_edl_record) -{ - edl_record_ptr new_record = calloc(1, sizeof(struct edl_record)); - if (!new_record) { - mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Can't allocate enough memory to hold EDL data.\n"); - exit(1); - } - - if (next_edl_record) // if this isn't the first record, tell the previous one what the new one is. - next_edl_record->next = new_record; - new_record->prev = next_edl_record; - new_record->next = NULL; - - return new_record; -} - -/** - * Goes through entire EDL records and frees all memory. - * Assumes next_edl_record is valid or NULL. - * - * \brief Free EDL memory - */ - -void free_edl(edl_record_ptr next_edl_record) -{ - edl_record_ptr tmp; - while (next_edl_record) { - tmp = next_edl_record->next; - free(next_edl_record); - next_edl_record = tmp; - } -} - -/** Parses edl_filename to fill EDL operations queue. - * Prints out how many EDL operations recorded total. - * \brief Fills EDL operations queue. - */ - -edl_record_ptr edl_parse_file(void) -{ - FILE *fd; - char line[100]; - float start, stop; - int action; - int record_count = 0; - int lineCount = 0; - edl_record_ptr edl_records = NULL; - edl_record_ptr next_edl_record = NULL; - - if (edl_filename) - { - if ((fd = fopen(edl_filename, "r")) == NULL) - { - return NULL; - } - - while (fgets(line, 99, fd) != NULL) - { - lineCount++; - - if ((sscanf(line, "%f %f %d", &start, &stop, &action)) - != 3) - { - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Badly formatted EDL line [%d], discarding.\n", - lineCount); - continue; - } - - if (next_edl_record && start <= next_edl_record->stop_sec) - { - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Invalid EDL line: %s\n", line); - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, - "Last stop position was [%f]; next start is [%f].\n"\ - "Entries must be in chronological order, cannot overlap. Discarding.\n", - next_edl_record->stop_sec, start); - continue; - } - - if (stop <= start) - { - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Invalid EDL line: %s\n", - line); - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Stop time has to be after start time.\n"); - continue; - } - - next_edl_record = edl_alloc_new(next_edl_record); - - if (!edl_records) edl_records = next_edl_record; - - 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 = edl_alloc_new(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; - } else - { - next_edl_record->length_sec = stop - start; - next_edl_record->start_sec = start; - next_edl_record->stop_sec = stop; - } - - record_count++; - } - - fclose(fd); - } - - if (edl_records) - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Read %d EDL actions.\n", record_count); - else - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "There are no EDL actions to take care of.\n"); - - return edl_records; -} diff --git a/edl.h b/edl.h deleted file mode 100644 index 8160acb952..0000000000 --- a/edl.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * EDL version 0.6 - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_EDL_H -#define MPLAYER_EDL_H - -#define EDL_SKIP 0 -#define EDL_MUTE 1 - -#define EDL_MUTE_START 1 -#define EDL_MUTE_END 0 - -struct edl_record { - float start_sec; - float stop_sec; - float length_sec; - short action; - struct edl_record* next; - struct edl_record* prev; -}; - -typedef struct edl_record* edl_record_ptr; - -extern char *edl_filename; // file to extract EDL entries from (-edl) -extern char *edl_output_filename; // file to put EDL entries in (-edlout) - -void free_edl(edl_record_ptr next_edl_record); // free's entire EDL list. -edl_record_ptr edl_parse_file(void); // fills EDL stack - -#endif /* MPLAYER_EDL_H */ diff --git a/m_option.h b/m_option.h index 5b7e051290..de2854137d 100644 --- a/m_option.h +++ b/m_option.h @@ -507,5 +507,6 @@ static inline void m_option_free(const m_option_t *opt, void *dst) #define OPT_HELPER_REMOVEPAREN(...) __VA_ARGS__ #define OPT_CHOICE(optname, varname, flags, choices) {optname, NULL, &m_option_type_choice, flags, 0, 0, (void *)&(const struct m_opt_choice_alternatives[]){OPT_HELPER_REMOVEPAREN choices, {NULL}}, 1, offsetof(struct MPOpts, varname)} #define OPT_TIME(optname, varname, flags) {optname, NULL, &m_option_type_time, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} +#define OPT_ERRORMESSAGE(optname, message) {optname, message, CONF_TYPE_PRINT} #endif /* MPLAYER_M_OPTION_H */ diff --git a/mp_core.h b/mp_core.h index e46d3d77d2..1796f1b7f2 100644 --- a/mp_core.h +++ b/mp_core.h @@ -187,8 +187,7 @@ typedef struct MPContext { double last_chapter_pts; float begin_skip; ///< start time of the current skip while on edlout mode - // audio is muted if either EDL or user activates mute - short edl_muted; ///< Stores whether EDL is currently in muted mode. + short user_muted; ///< Stores whether user wanted muted mode. int global_sub_size; // this encompasses all subtitle sources diff --git a/mplayer.c b/mplayer.c index f8b24a1285..19d93bf2d8 100644 --- a/mplayer.c +++ b/mplayer.c @@ -90,8 +90,6 @@ #include "codec-cfg.h" -#include "edl.h" - #include "sub/spudec.h" #include "sub/vobsub.h" @@ -336,9 +334,9 @@ char *current_module; // for debugging // --- -edl_record_ptr edl_records = NULL; ///< EDL entries memory area -edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records FILE *edl_fd; // file to write to when in -edlout mode. +char *edl_output_filename; // file to put EDL entries in (-edlout) + int use_filedir_conf; int use_filename_title; @@ -683,8 +681,6 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) if (mask & INITIALIZED_AO) { mpctx->initialized_flags &= ~INITIALIZED_AO; current_module = "uninit_ao"; - if (mpctx->edl_muted) - mixer_mute(&mpctx->mixer); if (mpctx->ao) ao_uninit(mpctx->ao, mpctx->stop_play != AT_END_OF_FILE); mpctx->ao = NULL; @@ -695,7 +691,7 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc) { - if (mpctx->user_muted && !mpctx->edl_muted) + if (mpctx->user_muted) mixer_mute(&mpctx->mixer); uninit_player(mpctx, INITIALIZED_ALL); #if defined(__MINGW32__) || defined(__CYGWIN__) @@ -734,8 +730,6 @@ void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc) talloc_free(mpctx->key_fifo); - free(edl_records); // free mem allocated for EDL - edl_records = NULL; switch (how) { case EXIT_QUIT: mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "\nExiting... (%s)\n", "Quit"); @@ -3107,59 +3101,6 @@ static void pause_loop(struct MPContext *mpctx) } } - -// Find the right mute status and record position for new file position -static void edl_seek_reset(MPContext *mpctx) -{ - mpctx->edl_muted = 0; - next_edl_record = edl_records; - - while (next_edl_record) { - if (next_edl_record->start_sec >= get_current_time(mpctx)) - break; - - if (next_edl_record->action == EDL_MUTE) - mpctx->edl_muted = !mpctx->edl_muted; - next_edl_record = next_edl_record->next; - } - if ((mpctx->user_muted | mpctx->edl_muted) != mpctx->mixer.muted) - mixer_mute(&mpctx->mixer); -} - - -// Execute EDL command for the current position if one exists -static void edl_update(MPContext *mpctx) -{ - if (!next_edl_record) - return; - - if (!mpctx->sh_video) { - mp_tmsg(MSGT_CPLAYER, MSGL_ERR, - "Cannot use EDL without video, disabling.\n"); - free_edl(edl_records); - next_edl_record = NULL; - edl_records = NULL; - return; - } - - if (get_current_time(mpctx) >= next_edl_record->start_sec) { - if (next_edl_record->action == EDL_SKIP) { - mpctx->osd_function = OSD_FFW; - queue_seek(mpctx, MPSEEK_RELATIVE, next_edl_record->length_sec, 0); - mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_SKIP: start [%f], stop " - "[%f], length [%f]\n", next_edl_record->start_sec, - next_edl_record->stop_sec, next_edl_record->length_sec); - } else if (next_edl_record->action == EDL_MUTE) { - mpctx->edl_muted = !mpctx->edl_muted; - if ((mpctx->user_muted | mpctx->edl_muted) != mpctx->mixer.muted) - mixer_mute(&mpctx->mixer); - mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_MUTE: [%f]\n", - next_edl_record->start_sec); - } - next_edl_record = next_edl_record->next; - } -} - static void reinit_decoders(struct MPContext *mpctx) { reinit_video_chain(mpctx); @@ -3181,8 +3122,8 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao) mpctx->time_frame = 0; mpctx->restart_playback = true; // Not all demuxers set d_video->pts during seek, so this value - // (which is used by at least vobsub and edl code below) may - // be completely wrong (probably 0). + // (which is used by at least vobsub code below) may be completely + // wrong (probably 0). mpctx->sh_video->pts = mpctx->d_video->pts + mpctx->video_offset; mpctx->video_pts = mpctx->sh_video->pts; update_subtitles(mpctx, mpctx->sh_video->pts, mpctx->video_offset, @@ -3207,8 +3148,6 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao) vobsub_seek(vo_vobsub, mpctx->sh_video->pts); } - edl_seek_reset(mpctx); - mpctx->hrseek_active = false; mpctx->hrseek_framedrop = false; mpctx->total_avsync_change = 0; @@ -3851,8 +3790,6 @@ static void run_playloop(struct MPContext *mpctx) queue_seek(mpctx, MPSEEK_RELATIVE, step_sec, 0); } - edl_update(mpctx); - /* Looping. */ if (opts->loop_times >= 0 && (mpctx->stop_play == AT_END_OF_FILE || mpctx->stop_play == PT_NEXT_ENTRY)) { @@ -4401,11 +4338,6 @@ play_next_file: mp_basename(mpctx->filename)); } - if (edl_filename) { - if (edl_records) - free_edl(edl_records); - next_edl_record = edl_records = edl_parse_file(); - } if (edl_output_filename) { if (edl_fd) fclose(edl_fd);