From 8eaa63689a25be909dc31c6a2c8c9dad3777943a Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 29 Dec 2014 23:09:50 +0100 Subject: demux_mf: move mf.c contents to demux_mf.c There's no reason why parts of this demuxer would be in a separate source file. The existence of this code is already somewhat questionable anyway, so it may as well be dumped into a single file. Even stranger that demux.c included mf.h for no reason (it was an artifact from 2002 when the architecture was uncleaner). --- demux/demux.c | 1 - demux/demux_mf.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++- demux/mf.c | 144 ------------------------------------------------------- demux/mf.h | 40 ---------------- 4 files changed, 122 insertions(+), 187 deletions(-) delete mode 100644 demux/mf.c delete mode 100644 demux/mf.h (limited to 'demux') diff --git a/demux/demux.c b/demux/demux.c index e7b0729b77..70b0c84f36 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -38,7 +38,6 @@ #include "stream/stream.h" #include "demux.h" #include "stheader.h" -#include "mf.h" #include "audio/format.h" diff --git a/demux/demux_mf.c b/demux/demux_mf.c index 5bb2cf392a..4fb5f2a1f4 100644 --- a/demux/demux_mf.c +++ b/demux/demux_mf.c @@ -22,22 +22,142 @@ #include #include #include -#include #include "osdep/io.h" #include "talloc.h" #include "common/msg.h" #include "options/options.h" +#include "options/path.h" +#include "misc/ctype.h" #include "stream/stream.h" #include "demux.h" #include "stheader.h" #include "codec_tags.h" -#include "mf.h" #define MF_MAX_FILE_SIZE (1024 * 1024 * 256) +typedef struct mf { + struct mp_log *log; + struct sh_video *sh; + int curr_frame; + int nr_of_files; + char **names; + // optional + struct stream **streams; +} mf_t; + + +static void mf_add(mf_t *mf, const char *fname) +{ + char *entry = talloc_strdup(mf, fname); + MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry); +} + +static mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename) +{ + int error_count = 0; + int count = 0; + + mf_t *mf = talloc_zero(talloc_ctx, mf_t); + mf->log = log; + + if (filename[0] == '@') { + FILE *lst_f = fopen(filename + 1, "r"); + if (lst_f) { + char *fname = talloc_size(mf, 512); + while (fgets(fname, 512, lst_f)) { + /* remove spaces from end of fname */ + char *t = fname + strlen(fname) - 1; + while (t > fname && mp_isspace(*t)) + *(t--) = 0; + if (!mp_path_exists(fname)) { + mp_verbose(log, "file not found: '%s'\n", fname); + } else { + mf_add(mf, fname); + } + } + fclose(lst_f); + + mp_info(log, "number of files: %d\n", mf->nr_of_files); + goto exit_mf; + } + mp_info(log, "%s is not indirect filelist\n", filename + 1); + } + + if (strchr(filename, ',')) { + mp_info(log, "filelist: %s\n", filename); + bstr bfilename = bstr0(filename); + + while (bfilename.len) { + bstr bfname; + bstr_split_tok(bfilename, ",", &bfname, &bfilename); + char *fname2 = bstrdup0(mf, bfname); + + if (!mp_path_exists(fname2)) + mp_verbose(log, "file not found: '%s'\n", fname2); + else { + mf_add(mf, fname2); + } + talloc_free(fname2); + } + mp_info(log, "number of files: %d\n", mf->nr_of_files); + + goto exit_mf; + } + + char *fname = talloc_size(mf, strlen(filename) + 32); + + if (!strchr(filename, '%')) { + strcpy(fname, filename); + if (!strchr(filename, '*')) + strcat(fname, "*"); + + mp_info(log, "search expr: %s\n", fname); + + glob_t gg; + if (glob(fname, 0, NULL, &gg)) { + talloc_free(mf); + return NULL; + } + + for (int i = 0; i < gg.gl_pathc; i++) { + if (mp_path_isdir(gg.gl_pathv[i])) + continue; + mf_add(mf, gg.gl_pathv[i]); + } + mp_info(log, "number of files: %d\n", mf->nr_of_files); + globfree(&gg); + goto exit_mf; + } + + mp_info(log, "search expr: %s\n", filename); + + while (error_count < 5) { + sprintf(fname, filename, count++); + if (!mp_path_exists(fname)) { + error_count++; + mp_verbose(log, "file not found: '%s'\n", fname); + } else { + mf_add(mf, fname); + } + } + + mp_info(log, "number of files: %d\n", mf->nr_of_files); + +exit_mf: + return mf; +} + +static mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename) +{ + mf_t *mf = talloc_zero(talloc_ctx, mf_t); + mf->log = log; + mf_add(mf, filename); + return mf; +} + static void demux_seek_mf(demuxer_t *demuxer, double rel_seek_secs, int flags) { mf_t *mf = demuxer->priv; diff --git a/demux/mf.c b/demux/mf.c deleted file mode 100644 index d687c3cb19..0000000000 --- a/demux/mf.c +++ /dev/null @@ -1,144 +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 -#include -#include -#include -#include -#include - -#include "osdep/io.h" -#include "talloc.h" -#include "common/msg.h" -#include "stream/stream.h" -#include "misc/ctype.h" -#include "options/path.h" - -#include "mf.h" - -static void mf_add(mf_t *mf, const char *fname) -{ - char *entry = talloc_strdup(mf, fname); - MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry); -} - -mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename) -{ - int error_count = 0; - int count = 0; - - mf_t *mf = talloc_zero(talloc_ctx, mf_t); - mf->log = log; - - if (filename[0] == '@') { - FILE *lst_f = fopen(filename + 1, "r"); - if (lst_f) { - char *fname = talloc_size(mf, 512); - while (fgets(fname, 512, lst_f)) { - /* remove spaces from end of fname */ - char *t = fname + strlen(fname) - 1; - while (t > fname && mp_isspace(*t)) - *(t--) = 0; - if (!mp_path_exists(fname)) { - mp_verbose(log, "file not found: '%s'\n", fname); - } else { - mf_add(mf, fname); - } - } - fclose(lst_f); - - mp_info(log, "number of files: %d\n", mf->nr_of_files); - goto exit_mf; - } - mp_info(log, "%s is not indirect filelist\n", filename + 1); - } - - if (strchr(filename, ',')) { - mp_info(log, "filelist: %s\n", filename); - bstr bfilename = bstr0(filename); - - while (bfilename.len) { - bstr bfname; - bstr_split_tok(bfilename, ",", &bfname, &bfilename); - char *fname2 = bstrdup0(mf, bfname); - - if (!mp_path_exists(fname2)) - mp_verbose(log, "file not found: '%s'\n", fname2); - else { - mf_add(mf, fname2); - } - talloc_free(fname2); - } - mp_info(log, "number of files: %d\n", mf->nr_of_files); - - goto exit_mf; - } - - char *fname = talloc_size(mf, strlen(filename) + 32); - - if (!strchr(filename, '%')) { - strcpy(fname, filename); - if (!strchr(filename, '*')) - strcat(fname, "*"); - - mp_info(log, "search expr: %s\n", fname); - - glob_t gg; - if (glob(fname, 0, NULL, &gg)) { - talloc_free(mf); - return NULL; - } - - for (int i = 0; i < gg.gl_pathc; i++) { - if (mp_path_isdir(gg.gl_pathv[i])) - continue; - mf_add(mf, gg.gl_pathv[i]); - } - mp_info(log, "number of files: %d\n", mf->nr_of_files); - globfree(&gg); - goto exit_mf; - } - - mp_info(log, "search expr: %s\n", filename); - - while (error_count < 5) { - sprintf(fname, filename, count++); - if (!mp_path_exists(fname)) { - error_count++; - mp_verbose(log, "file not found: '%s'\n", fname); - } else { - mf_add(mf, fname); - } - } - - mp_info(log, "number of files: %d\n", mf->nr_of_files); - -exit_mf: - return mf; -} - -mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename) -{ - mf_t *mf = talloc_zero(talloc_ctx, mf_t); - mf->log = log; - mf_add(mf, filename); - return mf; -} diff --git a/demux/mf.h b/demux/mf.h deleted file mode 100644 index 09f6e03b4f..0000000000 --- a/demux/mf.h +++ /dev/null @@ -1,40 +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. - */ - -#ifndef MPLAYER_MF_H -#define MPLAYER_MF_H - -struct mp_log; - -extern double mf_fps; -extern char * mf_type; - -typedef struct mf { - struct mp_log *log; - struct sh_video *sh; - int curr_frame; - int nr_of_files; - char **names; - // optional - struct stream **streams; -} mf_t; - -mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename); -mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename); - -#endif /* MPLAYER_MF_H */ -- cgit v1.2.3