diff options
-rw-r--r-- | cfg-common-opts.h | 2 | ||||
-rw-r--r-- | defaultopts.c | 1 | ||||
-rw-r--r-- | m_option.c | 46 | ||||
-rw-r--r-- | m_option.h | 2 | ||||
-rw-r--r-- | mencoder.c | 8 | ||||
-rw-r--r-- | mplayer.c | 21 | ||||
-rw-r--r-- | options.h | 1 | ||||
-rw-r--r-- | stream/open.c | 2 | ||||
-rw-r--r-- | stream/stream.h | 2 | ||||
-rw-r--r-- | stream/stream_dvd.c | 38 | ||||
-rw-r--r-- | stream/stream_dvd.h | 1 | ||||
-rw-r--r-- | stream/stream_dvdnav.c | 5 |
12 files changed, 69 insertions, 60 deletions
diff --git a/cfg-common-opts.h b/cfg-common-opts.h index 7a32b2101a..1dea0485ed 100644 --- a/cfg-common-opts.h +++ b/cfg-common-opts.h @@ -52,12 +52,12 @@ {"dvd-speed", &dvd_speed, CONF_TYPE_INT, 0, 0, 0, NULL}, {"dvd", "-dvd N has been removed, use dvd://N instead.\n" , CONF_TYPE_PRINT, 0, 0, 0, NULL}, {"dvdangle", &dvd_angle, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL}, - {"chapter", dvd_parse_chapter_range, CONF_TYPE_FUNC_PARAM, 0, 0, 0, NULL}, #else {"dvd-device", "MPlayer was compiled without libdvdread support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, {"dvd-speed", "MPlayer was compiled without libdvdread support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, {"dvd", "MPlayer was compiled without libdvdread support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, #endif /* CONFIG_DVDREAD */ + OPT_INTPAIR("chapter", chapterrange, 0), OPT_INTRANGE("edition", edition_id, 0, -1, 8190), {"alang", &audio_lang, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"slang", &dvdsub_lang, CONF_TYPE_STRING, 0, 0, 0, NULL}, diff --git a/defaultopts.c b/defaultopts.c index b5917c53a7..ee24087f63 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -21,6 +21,7 @@ void set_default_mplayer_options(struct MPOpts *opts) .osd_duration = 1000, .loop_times = -1, .ordered_chapters = 1, + .chapterrange = {-1, -1}, .edition_id = -1, .user_correct_pts = -1, .key_fifo_size = 7, diff --git a/m_option.c b/m_option.c index b37a94966d..63436bb165 100644 --- a/m_option.c +++ b/m_option.c @@ -221,6 +221,52 @@ const m_option_type_t m_option_type_int64 = { NULL }; +static int parse_intpair(const struct m_option *opt, const char *name, + const char *param, void *dst, int src) +{ + if (param == NULL) + return M_OPT_MISSING_PARAM; + + char *s = (char *)param; + int start = -1; + int end = -1; + if (*s) { + start = strtol(s, &s, 10); + if (s == param) + goto bad; + } + if (*s) { + if (*s != '-') + goto bad; + s++; + } + if (*s) + end = strtol(s, &s, 10); + if (*s) + goto bad; + + if (dst) { + int *p = dst; + p[0] = start; + p[1] = end; + } + + return 1; + + bad: + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid integer range " + "specification for option %s: %s\n", name, param); + return M_OPT_INVALID; +} + +const struct m_option_type m_option_type_intpair = { + .name = "Int[-Int]", + .size = sizeof(int[2]), + .parse = parse_intpair, + .save = copy_opt, + .set = copy_opt, +}; + // Float #undef VAL diff --git a/m_option.h b/m_option.h index 3ce842e825..41c8eae64f 100644 --- a/m_option.h +++ b/m_option.h @@ -45,6 +45,7 @@ struct m_struct_st; extern const m_option_type_t m_option_type_flag; extern const m_option_type_t m_option_type_int; extern const m_option_type_t m_option_type_int64; +extern const m_option_type_t m_option_type_intpair; extern const m_option_type_t m_option_type_float; extern const m_option_type_t m_option_type_double; extern const m_option_type_t m_option_type_string; @@ -525,6 +526,7 @@ m_option_free(const m_option_t* opt,void* dst) { #define OPT_STRINGLIST(optname, varname, flags) {optname, NULL, &m_option_type_string_list, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} #define OPT_INT(optname, varname, flags) {optname, NULL, &m_option_type_int, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} #define OPT_INTRANGE(optname, varname, flags, min, max) {optname, NULL, &m_option_type_int, (flags)|CONF_RANGE, min, max, NULL, 1, offsetof(struct MPOpts, varname)} +#define OPT_INTPAIR(optname, varname, flags) {optname, NULL, &m_option_type_intpair, (flags), 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} #define OPT_FLOATRANGE(optname, varname, flags, min, max) {optname, NULL, &m_option_type_float, (flags)|CONF_RANGE, min, max, NULL, 1, offsetof(struct MPOpts, varname)} #define OPT_STRING(optname, varname, flags) {optname, NULL, &m_option_type_string, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} #define OPT_SETTINGSLIST(optname, varname, flags, objlist) {optname, NULL, &m_option_type_obj_settings_list, flags, 0, 0, objlist, 1, offsetof(struct MPOpts, varname)} diff --git a/mencoder.c b/mencoder.c index 75a458f6a4..df1c568cb9 100644 --- a/mencoder.c +++ b/mencoder.c @@ -644,9 +644,9 @@ if(stream->type==STREAMTYPE_DVDNAV){ } } - if(dvd_chapter>1) { + if(opts.chapterrange[0]>1) { double pts; - if (demuxer_seek_chapter(demuxer, dvd_chapter-1, &pts, NULL) >= 0 && pts > -1.0) + if (demuxer_seek_chapter(demuxer, opts.chapterrange[0]-1, &pts, NULL) >= 0 && pts > -1.0) seek_to_sec = pts; } @@ -1193,9 +1193,9 @@ while(!at_eof){ --play_n_frames; if(play_n_frames<0) break; } - if(dvd_last_chapter>0) { + if(opts.chapterrange[1]>0) { int cur_chapter = demuxer_get_current_chapter(demuxer); - if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter) + if(cur_chapter!=-1 && cur_chapter+1>opts.chapterrange[1]) break; } @@ -3571,8 +3571,8 @@ if(stream_dump_type==5){ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Cannot open dump file.\n"); exit_player(mpctx, EXIT_ERROR); } - if (dvd_chapter > 1) { - int chapter = dvd_chapter - 1; + if (opts->chapterrange[0] > 1) { + int chapter = opts->chapterrange[0] - 1; stream_control(mpctx->stream, STREAM_CTRL_SEEK_TO_CHAPTER, &chapter); } while(!mpctx->stream->eof && !async_quit_request){ @@ -3583,10 +3583,11 @@ if(stream_dump_type==5){ exit_player(mpctx, EXIT_ERROR); } } - if(dvd_last_chapter > 0) { + if (opts->chapterrange[1] > 0) { int chapter = -1; if (stream_control(mpctx->stream, STREAM_CTRL_GET_CURRENT_CHAPTER, - &chapter) == STREAM_OK && chapter + 1 > dvd_last_chapter) + &chapter) == STREAM_OK + && chapter + 1 > opts->chapterrange[1]) break; } } @@ -3715,9 +3716,9 @@ if(!mpctx->demuxer) mpctx->num_sources = 1; } -if(dvd_chapter>1) { +if(opts->chapterrange[0]>1) { double pts; - if (seek_chapter(mpctx, dvd_chapter-1, &pts, NULL) >= 0 && pts > -1.0) + if (seek_chapter(mpctx, opts->chapterrange[0]-1, &pts, NULL) >= 0 && pts > -1.0) seek(mpctx, pts, SEEK_ABSOLUTE); } @@ -3799,9 +3800,9 @@ if((stream_dump_type)&&(stream_dump_type<4)){ if( (mpctx->demuxer->file_format==DEMUXER_TYPE_AVI || mpctx->demuxer->file_format==DEMUXER_TYPE_ASF || mpctx->demuxer->file_format==DEMUXER_TYPE_MOV) && stream_dump_type==2) fwrite(&in_size,1,4,f); if(in_size>0) fwrite(start,in_size,1,f); - if(dvd_last_chapter>0) { + if (opts->chapterrange[1] > 0) { int cur_chapter = demuxer_get_current_chapter(mpctx->demuxer); - if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter) + if(cur_chapter!=-1 && cur_chapter+1 > opts->chapterrange[1]) break; } } @@ -4090,9 +4091,9 @@ if (mpctx->stream->type == STREAMTYPE_DVDNAV) { while(!mpctx->stop_play){ float aq_sleep_time=0; -if(dvd_last_chapter>0) { +if (opts->chapterrange[1] > 0) { int cur_chapter = get_current_chapter(mpctx); - if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter) + if(cur_chapter!=-1 && cur_chapter+1 > opts->chapterrange[1]) goto goto_next_file; } @@ -29,6 +29,7 @@ typedef struct MPOpts { int osd_duration; int loop_times; int ordered_chapters; + int chapterrange[2]; int edition_id; int correct_pts; int user_correct_pts; diff --git a/stream/open.c b/stream/open.c index 3eb895349f..f5cf71fae8 100644 --- a/stream/open.c +++ b/stream/open.c @@ -39,8 +39,6 @@ /// We keep these 2 for the gui atm, but they will be removed. int vcd_track=0; char* cdrom_device=NULL; -int dvd_chapter=1; -int dvd_last_chapter=0; char* dvd_device=NULL; int dvd_title=0; diff --git a/stream/stream.h b/stream/stream.h index 62a2ee8d4e..d46730bd80 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -342,8 +342,6 @@ void stream_set_interrupt_callback(int (*cb)(struct input_ctx*, int), int stream_check_interrupt(int time); extern int dvd_title; -extern int dvd_chapter; -extern int dvd_last_chapter; extern int dvd_angle; extern char * audio_stream; diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index d1a91f88c1..a006047871 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -83,42 +83,6 @@ static const struct m_struct_st stream_opts = { stream_opts_fields }; -int dvd_parse_chapter_range(const m_option_t *conf, const char *range) { - const char *s; - char *t; - if (!range) - return M_OPT_MISSING_PARAM; - s = range; - dvd_chapter = 1; - dvd_last_chapter = 0; - if(*range && isdigit(*range)) { - dvd_chapter = strtol(range, &s, 10); - if(range == s) { - mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); - return M_OPT_INVALID; - } - } - if(*s == 0) - return 0; - else if(*s != '-') { - mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); - return M_OPT_INVALID; - } - ++s; - if(*s == 0) - return 0; - if(! isdigit(*s)) { - mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); - return M_OPT_INVALID; - } - dvd_last_chapter = strtol(s, &t, 10); - if (s == t || *t) { - mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range); - return M_OPT_INVALID; - } - return 0; -} - int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) { pgc_t * cur_pgc; @@ -411,8 +375,6 @@ static void dvd_close(dvd_priv_t *d) { ifoClose(d->vmg_file); DVDCloseFile(d->title); DVDClose(d->dvd); - dvd_chapter = 1; - dvd_last_chapter = 0; dvd_set_speed(dvd_device_current, -1); /* -1 => restore default */ } diff --git a/stream/stream_dvd.h b/stream/stream_dvd.h index 1e6c80163a..5872cb1d59 100644 --- a/stream/stream_dvd.h +++ b/stream/stream_dvd.h @@ -62,6 +62,5 @@ int dvd_lang_from_sid(stream_t *stream, int id); int dvd_aid_from_lang(stream_t *stream, unsigned char* lang); int dvd_sid_from_lang(stream_t *stream, unsigned char* lang); int dvd_chapter_from_cell(dvd_priv_t *dvd,int title,int cell); -int dvd_parse_chapter_range(const m_option_t *conf, const char *range); #endif /* MPLAYER_STREAM_DVD_H */ diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index b87fdaa4c5..5932fd049c 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -23,6 +23,7 @@ #include <unistd.h> #include <string.h> #include <errno.h> +#include "options.h" #include "mp_msg.h" #include "osdep/timer.h" #include "input/input.h" @@ -379,9 +380,9 @@ static int fill_buffer(stream_t *s, char *but, int len) priv->state &= ~NAV_FLAG_WAIT; if (priv->state & NAV_FLAG_WAIT_READ_AUTO) priv->state |= NAV_FLAG_WAIT_READ; - if(priv->title > 0 && dvd_last_chapter > 0) { + if(priv->title > 0 && s->opts->chapterrange[1] > 0) { int tit=0, part=0; - if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) == DVDNAV_STATUS_OK && part > dvd_last_chapter) { + if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) == DVDNAV_STATUS_OK && part > s->opts->chapterrange[1]) { priv->state |= NAV_FLAG_EOF; return 0; } |