From da2b4aa5870f407ad322b6116ed8d66a66dbeadf Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 27 Jul 2013 21:24:54 +0200 Subject: core: make mpctx->opts a pointer Prevents some awkwardness in a later commit, and makes the code more uniform with other places where MPOpts is accessed. This is a pretty annoying commit (touches tons of lines all over the place), but it hurts only once. --- core/command.c | 34 ++++---- core/mp_core.h | 2 +- core/mplayer.c | 197 ++++++++++++++++++++++---------------------- core/screenshot.c | 8 +- core/timeline/tl_cue.c | 6 +- core/timeline/tl_edl.c | 4 +- core/timeline/tl_matroska.c | 12 +-- 7 files changed, 132 insertions(+), 131 deletions(-) (limited to 'core') diff --git a/core/command.c b/core/command.c index d60c07c7f1..7445ab06d7 100644 --- a/core/command.c +++ b/core/command.c @@ -122,7 +122,7 @@ static int mp_property_generic_option(struct m_option *prop, int action, static int mp_property_playback_speed(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; double orig_speed = opts->playback_speed; switch (action) { case M_PROPERTY_SET: { @@ -437,7 +437,7 @@ static int mp_property_list_chapters(m_option_t *prop, int action, void *arg, static int mp_property_edition(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct demuxer *demuxer = mpctx->master_demuxer; if (!demuxer) return M_PROPERTY_UNAVAILABLE; @@ -752,13 +752,13 @@ static int mp_property_audio_delay(m_option_t *prop, int action, { if (!(mpctx->sh_audio && mpctx->sh_video)) return M_PROPERTY_UNAVAILABLE; - float delay = mpctx->opts.audio_delay; + float delay = mpctx->opts->audio_delay; switch (action) { case M_PROPERTY_PRINT: *(char **)arg = format_delay(delay); return M_PROPERTY_OK; case M_PROPERTY_SET: - mpctx->audio_delay = mpctx->opts.audio_delay = *(float *)arg; + mpctx->audio_delay = mpctx->opts->audio_delay = *(float *)arg; mpctx->delay -= mpctx->audio_delay - delay; return M_PROPERTY_OK; } @@ -1139,7 +1139,7 @@ static int mp_property_colormatrix(m_option_t *prop, int action, void *arg, if (action != M_PROPERTY_PRINT) return video_refresh_property_helper(prop, action, arg, mpctx); - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct mp_csp_details vo_csp = {0}; if (mpctx->sh_video && mpctx->sh_video->vfilter) @@ -1173,7 +1173,7 @@ static int mp_property_colormatrix_input_range(m_option_t *prop, int action, if (action != M_PROPERTY_PRINT) return video_refresh_property_helper(prop, action, arg, mpctx); - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct mp_csp_details vo_csp = {0}; if (mpctx->sh_video && mpctx->sh_video->vfilter) @@ -1213,7 +1213,7 @@ static int mp_property_colormatrix_output_range(m_option_t *prop, int action, return r; } - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; int req = opts->requested_output_range; struct mp_csp_details actual = {0}; @@ -1271,7 +1271,7 @@ static int mp_property_ontop(m_option_t *prop, int action, void *arg, MPContext *mpctx) { return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, - &mpctx->opts.vo.ontop, mpctx); + &mpctx->opts->vo.ontop, mpctx); } /// Show window borders (RW) @@ -1279,7 +1279,7 @@ static int mp_property_border(m_option_t *prop, int action, void *arg, MPContext *mpctx) { return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, - &mpctx->opts.vo.border, mpctx); + &mpctx->opts->vo.border, mpctx); } static int mp_property_framedrop(m_option_t *prop, int action, @@ -1295,7 +1295,7 @@ static int mp_property_framedrop(m_option_t *prop, int action, static int mp_property_gamma(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - int *gamma = (int *)((char *)&mpctx->opts + prop->offset); + int *gamma = (int *)((char *)mpctx->opts + prop->offset); int r, val; if (!mpctx->sh_video) @@ -1425,7 +1425,7 @@ static int mp_property_aspect(m_option_t *prop, int action, void *arg, float f = *(float *)arg; if (f < 0.1) f = (float)mpctx->sh_video->disp_w / mpctx->sh_video->disp_h; - mpctx->opts.movie_aspect = f; + mpctx->opts->movie_aspect = f; video_reinit_vo(mpctx->sh_video); return M_PROPERTY_OK; } @@ -1460,7 +1460,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg, static int mp_property_sub_delay(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; switch (action) { @@ -1474,7 +1474,7 @@ static int mp_property_sub_delay(m_option_t *prop, int action, void *arg, static int mp_property_sub_pos(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; if (action == M_PROPERTY_PRINT) { @@ -1882,7 +1882,7 @@ static struct property_osd_display { static void show_property_osd(MPContext *mpctx, const char *pname, enum mp_on_osd osd_mode) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct m_option prop = {0}; struct property_osd_display *p; @@ -1983,7 +1983,7 @@ static bool reinit_filters(MPContext *mpctx, enum stream_type mediatype) static void change_filters(MPContext *mpctx, enum stream_type mediatype, const char *cmd, const char *arg) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct m_config *conf = mpctx->mconfig; struct m_obj_settings *old_settings = NULL; bool success = false; @@ -2034,7 +2034,7 @@ static void change_video_filters(MPContext *mpctx, const char *cmd, void run_command(MPContext *mpctx, mp_cmd_t *cmd) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; sh_video_t *const sh_video = mpctx->sh_video; int osd_duration = opts->osd_duration; bool auto_osd = cmd->on_osd == MP_ON_OSD_AUTO; @@ -2136,7 +2136,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) case MP_CMD_SPEED_MULT: { float v = cmd->args[0].v.f; - v *= mpctx->opts.playback_speed; + v *= mpctx->opts->playback_speed; mp_property_do("speed", M_PROPERTY_SET, &v, mpctx); show_property_osd(mpctx, "speed", cmd->on_osd); break; diff --git a/core/mp_core.h b/core/mp_core.h index 6bbe18c71e..d2eb8ef296 100644 --- a/core/mp_core.h +++ b/core/mp_core.h @@ -113,7 +113,7 @@ enum { }; typedef struct MPContext { - struct MPOpts opts; + struct MPOpts *opts; struct m_config *mconfig; struct input_ctx *input; struct osd_state *osd; diff --git a/core/mplayer.c b/core/mplayer.c index 3e14abc499..e7fc84e645 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -230,7 +230,7 @@ static double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t, static double get_play_end_pts(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (opts->play_end.type) { return rel_time_to_abs(mpctx, opts->play_end, MP_NOPTS_VALUE); } else if (opts->play_length.type) { @@ -440,7 +440,7 @@ static void uninit_subs(struct demuxer *demuxer) void uninit_player(struct MPContext *mpctx, unsigned int mask) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; mask &= mpctx->initialized_flags; @@ -563,7 +563,7 @@ static MP_NORETURN void exit_player(struct MPContext *mpctx, timeEndPeriod(1); #endif - mp_input_uninit(mpctx->input, &mpctx->opts.input); + mp_input_uninit(mpctx->input, &mpctx->opts->input); osd_free(mpctx->osd); @@ -620,7 +620,7 @@ static int cfg_include(struct m_config *conf, char *filename) static bool parse_cfgfiles(struct MPContext *mpctx, m_config_t *conf) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; char *conffile; int conffile_fd; if (!opts->load_config) @@ -1036,7 +1036,7 @@ static void vo_update_window_title(struct MPContext *mpctx) { if (!mpctx->video_out) return; - char *title = mp_property_expand_string(mpctx, mpctx->opts.wintitle); + char *title = mp_property_expand_string(mpctx, mpctx->opts->wintitle); if (!mpctx->video_out->window_title || strcmp(title, mpctx->video_out->window_title)) { @@ -1077,7 +1077,7 @@ static int get_term_width(void) static void write_status_line(struct MPContext *mpctx, const char *line) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (opts->slave_mode) { mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s\n", line); } else if (erase_to_end_of_line) { @@ -1092,7 +1092,7 @@ static void write_status_line(struct MPContext *mpctx, const char *line) static void print_status(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; sh_video_t * const sh_video = mpctx->sh_video; vo_update_window_title(mpctx); @@ -1124,12 +1124,12 @@ static void print_status(struct MPContext *mpctx) // Playback position double cur = get_current_time(mpctx); - sadd_hhmmssff(&line, cur, mpctx->opts.osd_fractions); + sadd_hhmmssff(&line, cur, mpctx->opts->osd_fractions); double len = get_time_length(mpctx); if (len >= 0) { saddf(&line, " / "); - sadd_hhmmssff(&line, len, mpctx->opts.osd_fractions); + sadd_hhmmssff(&line, len, mpctx->opts->osd_fractions); } sadd_percentage(&line, get_percent_pos(mpctx)); @@ -1265,7 +1265,7 @@ void rm_osd_msg(struct MPContext *mpctx, int id) static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; mp_osd_msg_t *msg, *prev, *last = NULL; double now = mp_time_sec(); double diff; @@ -1324,7 +1324,7 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx) void set_osd_bar(struct MPContext *mpctx, int type, const char *name, double min, double max, double val) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (opts->osd_level < 1 || !opts->osd_bar_visible) return; @@ -1377,7 +1377,7 @@ static void set_osd_bar_chapters(struct MPContext *mpctx, int type) void set_osd_function(struct MPContext *mpctx, int osd_function) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; mpctx->osd_function = osd_function; mpctx->osd_function_visible = mp_time_sec() + opts->osd_duration / 1000.0; @@ -1412,10 +1412,10 @@ static void saddf_osd_function_sym(char **buffer, int sym) static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full) { - bool fractions = mpctx->opts.osd_fractions; + bool fractions = mpctx->opts->osd_fractions; int sym = mpctx->osd_function; if (!sym) { - if (mpctx->paused_for_cache && !mpctx->opts.pause) { + if (mpctx->paused_for_cache && !mpctx->opts->pause) { sym = OSD_CLOCK; } else if (mpctx->paused || mpctx->step_frames) { sym = OSD_PAUSE; @@ -1424,7 +1424,7 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full) } } saddf_osd_function_sym(buffer, sym); - char *custom_msg = mpctx->opts.osd_status_msg; + char *custom_msg = mpctx->opts->osd_status_msg; if (custom_msg && full) { char *text = mp_property_expand_string(mpctx, custom_msg); *buffer = talloc_strdup_append(*buffer, text); @@ -1453,19 +1453,19 @@ static void add_seek_osd_messages(struct MPContext *mpctx) } if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) { mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1, - mpctx->opts.osd_duration); + mpctx->opts->osd_duration); msg->show_position = true; } if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) { char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx)); - set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, + set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts->osd_duration, "Chapter: %s", chapter); talloc_free(chapter); } if ((mpctx->add_osd_seek_info & OSD_SEEK_INFO_EDITION) && mpctx->master_demuxer) { - set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, + set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts->osd_duration, "Playing edition %d of %d.", mpctx->master_demuxer->edition + 1, mpctx->master_demuxer->num_editions); @@ -1484,7 +1484,7 @@ static void add_seek_osd_messages(struct MPContext *mpctx) static void update_osd_msg(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct osd_state *osd = mpctx->osd; add_seek_osd_messages(mpctx); @@ -1537,7 +1537,7 @@ static int build_afilter_chain(struct MPContext *mpctx) { struct sh_audio *sh_audio = mpctx->sh_audio; struct ao *ao = mpctx->ao; - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; int new_srate; if (af_control_any_rev(sh_audio->afilter, AF_CONTROL_PLAYBACK_SPEED | AF_CONTROL_SET, @@ -1560,7 +1560,7 @@ static int build_afilter_chain(struct MPContext *mpctx) static int recreate_audio_filters(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; assert(mpctx->sh_audio); // init audio filters: @@ -1605,7 +1605,7 @@ int reinit_audio_filters(struct MPContext *mpctx) void reinit_audio_chain(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; init_demux_stream(mpctx, STREAM_AUDIO); if (!mpctx->sh_audio) { uninit_player(mpctx, INITIALIZED_VOL | INITIALIZED_AO); @@ -1722,7 +1722,7 @@ static double written_audio_pts(struct MPContext *mpctx) // Filters divide audio length by playback_speed, so multiply by it // to get the length in original units without speedup or slowdown - a_pts -= buffered_output * mpctx->opts.playback_speed / mpctx->ao->bps; + a_pts -= buffered_output * mpctx->opts->playback_speed / mpctx->ao->bps; return a_pts + mpctx->video_offset; } @@ -1733,7 +1733,7 @@ double playing_audio_pts(struct MPContext *mpctx) double pts = written_audio_pts(mpctx); if (pts == MP_NOPTS_VALUE) return pts; - return pts - mpctx->opts.playback_speed *ao_get_delay(mpctx->ao); + return pts - mpctx->opts->playback_speed * ao_get_delay(mpctx->ao); } // When reading subtitles from a demuxer, and we read video or audio from the @@ -1763,7 +1763,7 @@ static void reset_subtitles(struct MPContext *mpctx) static void update_subtitles(struct MPContext *mpctx, double refpts_tl) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (!(mpctx->initialized_flags & INITIALIZED_SUB)) return; @@ -1818,7 +1818,7 @@ static void update_subtitles(struct MPContext *mpctx, double refpts_tl) static int check_framedrop(struct MPContext *mpctx, double frame_time) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; // check for frame-drop: if (mpctx->sh_audio && !mpctx->ao->untimed && !demux_stream_eof(mpctx->sh_audio->gsh)) @@ -1833,7 +1833,7 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time) && !mpctx->restart_playback) { mpctx->drop_frame_cnt++; mpctx->dropped_frames++; - return mpctx->opts.frame_dropping; + return mpctx->opts->frame_dropping; } else mpctx->dropped_frames = 0; } @@ -1844,7 +1844,7 @@ static double timing_sleep(struct MPContext *mpctx, double time_frame) { // assume kernel HZ=100 for softsleep, works with larger HZ but with // unnecessarily high CPU usage - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; double margin = opts->softsleep ? 0.011 : 0; while (time_frame > margin) { mp_sleep_us(1000000 * (time_frame - margin)); @@ -1904,7 +1904,7 @@ static void set_dvdsub_fake_extradata(struct dec_sub *dec_sub, struct stream *st static void reinit_subs(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct track *track = mpctx->current_track[STREAM_SUB]; assert(!(mpctx->initialized_flags & INITIALIZED_SUB)); @@ -1984,7 +1984,7 @@ void mp_switch_track(struct MPContext *mpctx, enum stream_type type, if (type == STREAM_VIDEO) { uninit_player(mpctx, INITIALIZED_VCODEC | - (mpctx->opts.fixed_vo && track ? 0 : INITIALIZED_VO)); + (mpctx->opts->fixed_vo && track ? 0 : INITIALIZED_VO)); } else if (type == STREAM_AUDIO) { uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_ACODEC | INITIALIZED_VOL); } else if (type == STREAM_SUB) { @@ -1995,13 +1995,13 @@ void mp_switch_track(struct MPContext *mpctx, enum stream_type type, int user_tid = track ? track->user_tid : -2; if (type == STREAM_VIDEO) { - mpctx->opts.video_id = user_tid; + mpctx->opts->video_id = user_tid; reinit_video_chain(mpctx); } else if (type == STREAM_AUDIO) { - mpctx->opts.audio_id = user_tid; + mpctx->opts->audio_id = user_tid; reinit_audio_chain(mpctx); } else if (type == STREAM_SUB) { - mpctx->opts.sub_id = user_tid; + mpctx->opts->sub_id = user_tid; reinit_subs(mpctx); } @@ -2059,7 +2059,7 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track) */ static void adjust_sync(struct MPContext *mpctx, double frame_time) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (!mpctx->sh_audio || mpctx->syncing_audio) return; @@ -2088,7 +2088,7 @@ static int write_to_ao(struct MPContext *mpctx, void *data, int len, int flags, if (mpctx->paused) return 0; struct ao *ao = mpctx->ao; - double bps = ao->bps / mpctx->opts.playback_speed; + double bps = ao->bps / mpctx->opts->playback_speed; ao->pts = pts; int played = ao_play(mpctx->ao, data, len, flags); if (played > 0) { @@ -2105,7 +2105,7 @@ static int write_to_ao(struct MPContext *mpctx, void *data, int len, int flags, static int audio_start_sync(struct MPContext *mpctx, int playsize) { struct ao *ao = mpctx->ao; - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; sh_audio_t * const sh_audio = mpctx->sh_audio; int res; @@ -2190,7 +2190,7 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize) static int fill_audio_out_buffers(struct MPContext *mpctx, double endpts) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct ao *ao = mpctx->ao; int playsize; int playflags = 0; @@ -2225,7 +2225,7 @@ static int fill_audio_out_buffers(struct MPContext *mpctx, double endpts) * implementation would require draining buffered old-format audio * while displaying video, then doing the output format switch. */ - if (!mpctx->opts.gapless_audio) + if (!mpctx->opts->gapless_audio) uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_VOL); reinit_audio_chain(mpctx); return -1; @@ -2287,7 +2287,7 @@ static void update_fps(struct MPContext *mpctx) static void recreate_video_filters(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct sh_video *sh_video = mpctx->sh_video; assert(sh_video); @@ -2320,7 +2320,7 @@ int reinit_video_filters(struct MPContext *mpctx) int reinit_video_chain(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; assert(!(mpctx->initialized_flags & INITIALIZED_VCODEC)); init_demux_stream(mpctx, STREAM_VIDEO); sh_video_t * const sh_video = mpctx->sh_video; @@ -2408,7 +2408,7 @@ no_video: // frame. This can go wrong in all sorts of ways, so use sparingly. void mp_force_video_refresh(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; // If not paused, the next frame should come soon enough. if (opts->pause && mpctx->last_vo_pts != MP_NOPTS_VALUE) @@ -2497,7 +2497,7 @@ static struct demux_packet *video_read_frame(struct MPContext *mpctx) float frame_time = sh_video->fps > 0 ? 1.0f / sh_video->fps : 0; // override frame_time for variable/unknown FPS formats: - if (!mpctx->opts.force_fps) { + if (!mpctx->opts->force_fps) { double next_pts = demux_get_next_pts(sh_video->gsh); double d = next_pts == MP_NOPTS_VALUE ? sh_video->last_pts - pts1 : next_pts - sh_video->last_pts; @@ -2569,7 +2569,7 @@ static double update_video_attached_pic(struct MPContext *mpctx) static void determine_frame_pts(struct MPContext *mpctx) { struct sh_video *sh_video = mpctx->sh_video; - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (opts->user_pts_assoc_mode) sh_video->pts_assoc_mode = opts->user_pts_assoc_mode; @@ -2603,7 +2603,7 @@ static double update_video(struct MPContext *mpctx, double endpts) struct vo *video_out = mpctx->video_out; sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ, mpctx->osd); // for vf_sub - if (!mpctx->opts.correct_pts) + if (!mpctx->opts->correct_pts) return update_video_nocorrect_pts(mpctx); if (sh_video->gsh->attached_picture) @@ -2694,7 +2694,7 @@ static double update_video(struct MPContext *mpctx, double endpts) void pause_player(struct MPContext *mpctx) { - mpctx->opts.pause = 1; + mpctx->opts->pause = 1; if (mpctx->video_out) vo_control(mpctx->video_out, VOCTRL_RESTORE_SCREENSAVER, NULL); @@ -2717,15 +2717,15 @@ void pause_player(struct MPContext *mpctx) if (mpctx->num_sources) print_status(mpctx); - if (!mpctx->opts.quiet) + if (!mpctx->opts->quiet) mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_PAUSED\n"); } void unpause_player(struct MPContext *mpctx) { - mpctx->opts.pause = 0; + mpctx->opts->pause = 0; - if (mpctx->video_out && mpctx->opts.stop_screensaver) + if (mpctx->video_out && mpctx->opts->stop_screensaver) vo_control(mpctx->video_out, VOCTRL_KILL_SCREENSAVER, NULL); if (!mpctx->paused) @@ -2828,7 +2828,7 @@ static bool timeline_set_part(struct MPContext *mpctx, int i, bool force) enum stop_play_reason orig_stop_play = mpctx->stop_play; if (!mpctx->sh_video && mpctx->stop_play == KEEP_PLAYING) mpctx->stop_play = AT_END_OF_FILE; // let audio uninit drain data - uninit_player(mpctx, INITIALIZED_VCODEC | (mpctx->opts.fixed_vo ? 0 : INITIALIZED_VO) | (mpctx->opts.gapless_audio ? 0 : INITIALIZED_AO) | INITIALIZED_VOL | INITIALIZED_ACODEC | INITIALIZED_SUB); + uninit_player(mpctx, INITIALIZED_VCODEC | (mpctx->opts->fixed_vo ? 0 : INITIALIZED_VO) | (mpctx->opts->gapless_audio ? 0 : INITIALIZED_AO) | INITIALIZED_VOL | INITIALIZED_ACODEC | INITIALIZED_SUB); mpctx->stop_play = orig_stop_play; mpctx->demuxer = n->source; @@ -2872,7 +2872,7 @@ static double timeline_set_from_time(struct MPContext *mpctx, double pts, static int seek(MPContext *mpctx, struct seek_params seek, bool timeline_fallthrough) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; uint64_t prev_seek_ts = mpctx->vo_pts_history_seek_ts; if (!mpctx->demuxer) @@ -3109,7 +3109,7 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range) double start = get_start_time(mpctx); double len = get_time_length(mpctx); if (use_range) { - double startpos = rel_time_to_abs(mpctx, mpctx->opts.play_start, + double startpos = rel_time_to_abs(mpctx, mpctx->opts->play_start, MP_NOPTS_VALUE); double endpos = get_play_end_pts(mpctx); if (endpos == MP_NOPTS_VALUE || endpos > start + len) @@ -3132,9 +3132,9 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range) ans = av_clipf((double)(fpos - demuxer->movi_start) / size, 0, 1); } if (use_range) { - if (mpctx->opts.play_frames > 0) + if (mpctx->opts->play_frames > 0) ans = max(ans, 1.0 - - mpctx->max_frames / (double) mpctx->opts.play_frames); + mpctx->max_frames / (double) mpctx->opts->play_frames); } return ans; } @@ -3262,7 +3262,7 @@ static void update_avsync(struct MPContext *mpctx) mpctx->last_av_difference = a_pos - mpctx->video_pts - mpctx->audio_delay; if (mpctx->time_frame > 0) mpctx->last_av_difference += - mpctx->time_frame * mpctx->opts.playback_speed; + mpctx->time_frame * mpctx->opts->playback_speed; if (a_pos == MP_NOPTS_VALUE || mpctx->video_pts == MP_NOPTS_VALUE) mpctx->last_av_difference = MP_NOPTS_VALUE; if (mpctx->last_av_difference > 0.5 && mpctx->drop_frame_cnt > 50 @@ -3274,7 +3274,7 @@ static void update_avsync(struct MPContext *mpctx) static void handle_pause_on_low_cache(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; int cache = mp_get_cache_percent(mpctx); bool idle = mp_get_cache_idle(mpctx); if (mpctx->paused && mpctx->paused_for_cache) { @@ -3317,7 +3317,7 @@ static double get_wakeup_period(struct MPContext *mpctx) static void run_playloop(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; bool full_audio_buffers = false; bool audio_left = false, video_left = false; double endpts = get_play_end_pts(mpctx); @@ -3560,7 +3560,7 @@ static void run_playloop(struct MPContext *mpctx) double a_pos = 0; if (mpctx->sh_audio) { a_pos = (written_audio_pts(mpctx) - - mpctx->opts.playback_speed * buffered_audio); + mpctx->opts->playback_speed * buffered_audio); } mpctx->playback_pts = a_pos; print_status(mpctx); @@ -3834,7 +3834,7 @@ static struct track *select_track(struct MPContext *mpctx, if (pick && !select_fallback && !pick->is_external && !match_lang(langs, pick->lang) && !pick->default_track) pick = NULL; - if (pick && pick->attached_picture && !mpctx->opts.audio_display) + if (pick && pick->attached_picture && !mpctx->opts->audio_display) pick = NULL; return pick; } @@ -3843,7 +3843,7 @@ static struct track *select_track(struct MPContext *mpctx, // code resets track selection if the new file has a different track layout. static void check_previous_track_selection(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (!mpctx->track_layout_hash) return; @@ -3852,11 +3852,11 @@ static void check_previous_track_selection(struct MPContext *mpctx) if (strcmp(h, mpctx->track_layout_hash) != 0) { // Reset selection, but only if they're not "auto" or "off". if (opts->video_id >= 0) - mpctx->opts.video_id = -1; + mpctx->opts->video_id = -1; if (opts->audio_id >= 0) - mpctx->opts.audio_id = -1; + mpctx->opts->audio_id = -1; if (opts->sub_id >= 0) - mpctx->opts.sub_id = -1; + mpctx->opts->sub_id = -1; talloc_free(mpctx->track_layout_hash); mpctx->track_layout_hash = NULL; } @@ -3872,10 +3872,10 @@ static int read_keys(void *ctx, int fd) static void init_input(struct MPContext *mpctx) { - mpctx->input = mp_input_init(&mpctx->opts.input, mpctx->opts.load_config); - if (mpctx->opts.slave_mode) + mpctx->input = mp_input_init(&mpctx->opts->input, mpctx->opts->load_config); + if (mpctx->opts->slave_mode) mp_input_add_cmd_fd(mpctx->input, 0, USE_FD0_CMD_SELECT, MP_INPUT_SLAVE_CMD_FUNC, NULL); - else if (mpctx->opts.consolecontrols) + else if (mpctx->opts->consolecontrols) mp_input_add_key_fd(mpctx->input, 0, 1, read_keys, NULL, mpctx->input); // Set the libstream interrupt callback stream_set_interrupt_callback(mp_input_check_interrupt, mpctx->input); @@ -3890,12 +3890,12 @@ static void open_subtitles_from_options(struct MPContext *mpctx) // after reading video params we should load subtitles because // we know fps so now we can adjust subtitle time to ~6 seconds AST // check .sub - if (mpctx->opts.sub_name) { - for (int i = 0; mpctx->opts.sub_name[i] != NULL; ++i) - mp_add_subtitles(mpctx, mpctx->opts.sub_name[i], 0); + if (mpctx->opts->sub_name) { + for (int i = 0; mpctx->opts->sub_name[i] != NULL; ++i) + mp_add_subtitles(mpctx, mpctx->opts->sub_name[i], 0); } - if (mpctx->opts.sub_auto) { // auto load sub file ... - char **tmp = find_text_subtitles(&mpctx->opts, mpctx->filename); + if (mpctx->opts->sub_auto) { // auto load sub file ... + char **tmp = find_text_subtitles(mpctx->opts, mpctx->filename); int nsub = MP_TALLOC_ELEMS(tmp); for (int i = 0; i < nsub; i++) { struct track *track = mp_add_subtitles(mpctx, tmp[i], 1); @@ -3910,13 +3910,13 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, char *demuxer_name, int stream_cache, enum stream_type filter) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (!filename) return NULL; char *disp_filename = filename; if (strncmp(disp_filename, "memory://", 9) == 0) disp_filename = "memory://"; // avoid noise - struct stream *stream = stream_open(filename, &mpctx->opts); + struct stream *stream = stream_open(filename, mpctx->opts); if (!stream) goto err_out; stream_enable_cache_percent(&stream, stream_cache, @@ -3927,7 +3927,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, .ass_library = mpctx->ass_library, // demux_libass requires it }; struct demuxer *demuxer = - demux_open(stream, demuxer_name, ¶ms, &mpctx->opts); + demux_open(stream, demuxer_name, ¶ms, mpctx->opts); if (!demuxer) { free_stream(stream); goto err_out; @@ -3961,21 +3961,21 @@ err_out: static void open_audiofiles_from_options(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; open_external_file(mpctx, opts->audio_stream, opts->audio_demuxer_name, opts->audio_stream_cache, STREAM_AUDIO); } struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename, int noerr) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; return open_external_file(mpctx, filename, opts->sub_demuxer_name, 0, STREAM_SUB); } static void open_subtitles_from_resolve(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; struct mp_resolve_result *res = mpctx->resolve_result; if (!res) return; @@ -4018,12 +4018,12 @@ static void print_timeline(struct MPContext *mpctx) static void add_subtitle_fonts_from_sources(struct MPContext *mpctx) { #ifdef CONFIG_ASS - if (mpctx->opts.ass_enabled) { + if (mpctx->opts->ass_enabled) { for (int j = 0; j < mpctx->num_sources; j++) { struct demuxer *d = mpctx->sources[j]; for (int i = 0; i < d->num_attachments; i++) { struct demux_attachment *att = d->attachments + i; - if (mpctx->opts.use_embedded_fonts && attachment_is_font(att)) + if (mpctx->opts->use_embedded_fonts && attachment_is_font(att)) ass_add_font(mpctx->ass_library, att->name, att->data, att->data_size); } @@ -4036,7 +4036,7 @@ static void add_subtitle_fonts_from_sources(struct MPContext *mpctx) mpctx->osd->ass_renderer = ass_renderer_init(mpctx->osd->ass_library); if (mpctx->osd->ass_renderer) mp_ass_configure_fonts(mpctx->osd->ass_renderer, - mpctx->opts.sub_text_style); + mpctx->opts->sub_text_style); #endif } @@ -4054,7 +4054,7 @@ static struct mp_resolve_result *resolve_url(const char *filename, static void idle_loop(struct MPContext *mpctx) { // ================= idle loop (STOP state) ========================= - while (mpctx->opts.player_idle_mode && !mpctx->playlist->current + while (mpctx->opts->player_idle_mode && !mpctx->playlist->current && mpctx->stop_play != PT_QUIT) { uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_VO); @@ -4069,7 +4069,7 @@ static void idle_loop(struct MPContext *mpctx) static void stream_dump(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; char *filename = opts->stream_dump; stream_t *stream = mpctx->stream; assert(stream && filename); @@ -4100,7 +4100,7 @@ static void stream_dump(struct MPContext *mpctx) // Handle initialization and deinitialization. static void play_current_file(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; mpctx->stop_play = 0; mpctx->filename = NULL; @@ -4274,13 +4274,13 @@ goto_reopen_demuxer: ; check_previous_track_selection(mpctx); mpctx->current_track[STREAM_VIDEO] = - select_track(mpctx, STREAM_VIDEO, mpctx->opts.video_id, NULL); + select_track(mpctx, STREAM_VIDEO, mpctx->opts->video_id, NULL); mpctx->current_track[STREAM_AUDIO] = - select_track(mpctx, STREAM_AUDIO, mpctx->opts.audio_id, - mpctx->opts.audio_lang); + select_track(mpctx, STREAM_AUDIO, mpctx->opts->audio_id, + mpctx->opts->audio_lang); mpctx->current_track[STREAM_SUB] = - select_track(mpctx, STREAM_SUB, mpctx->opts.sub_id, - mpctx->opts.sub_lang); + select_track(mpctx, STREAM_SUB, mpctx->opts->sub_id, + mpctx->opts->sub_lang); demux_info_print(mpctx->master_demuxer); print_file_properties(mpctx, mpctx->filename); @@ -4377,7 +4377,7 @@ goto_reopen_demuxer: ; get_relative_time(mpctx); // reset current delta - if (mpctx->opts.pause) + if (mpctx->opts->pause) pause_player(mpctx); while (!mpctx->stop_play) @@ -4433,13 +4433,13 @@ terminate_playback: // don't jump here after ao/vo/getch initialization! struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction) { struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction); - if (!next && mpctx->opts.loop_times >= 0) { + if (!next && mpctx->opts->loop_times >= 0) { if (direction > 0) { next = mpctx->playlist->first; - if (next && mpctx->opts.loop_times > 0) { - mpctx->opts.loop_times--; - if (mpctx->opts.loop_times == 0) - mpctx->opts.loop_times = -1; + if (next && mpctx->opts->loop_times > 0) { + mpctx->opts->loop_times--; + if (mpctx->opts->loop_times == 0) + mpctx->opts->loop_times = -1; } } else { next = mpctx->playlist->last; @@ -4482,7 +4482,7 @@ static void play_files(struct MPContext *mpctx) mpctx->playlist->current_was_replaced = false; mpctx->stop_play = 0; - if (!mpctx->playlist->current && !mpctx->opts.player_idle_mode) + if (!mpctx->playlist->current && !mpctx->opts->player_idle_mode) break; } } @@ -4505,7 +4505,7 @@ void mp_print_version(int always) static bool handle_help_options(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; int opt_exit = 0; if (opts->audio_decoders && strcmp(opts->audio_decoders, "help") == 0) { struct mp_decoder_list *list = mp_audio_decoder_list(); @@ -4538,7 +4538,7 @@ static bool handle_help_options(struct MPContext *mpctx) opt_exit = 1; } #ifdef CONFIG_ENCODING - if (encode_lavc_showhelp(&mpctx->opts)) + if (encode_lavc_showhelp(mpctx->opts)) opt_exit = 1; #endif return opt_exit; @@ -4597,7 +4597,7 @@ static int mpv_main(int argc, char *argv[]) struct MPContext *mpctx = talloc(NULL, MPContext); *mpctx = (struct MPContext){ - .opts = mp_default_opts, + .opts = talloc(mpctx, struct MPOpts), .last_dvb_step = 1, .terminal_osd_text = talloc_strdup(mpctx, ""), .playlist = talloc_struct(mpctx, struct playlist, {0}), @@ -4607,8 +4607,9 @@ static int mpv_main(int argc, char *argv[]) init_libav(); screenshot_init(mpctx); - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; // Create the config context and register the options + *opts = mp_default_opts; mpctx->mconfig = m_config_new(opts, cfg_include); m_config_register_options(mpctx->mconfig, mp_opts); mp_input_register_options(mpctx->mconfig); diff --git a/core/screenshot.c b/core/screenshot.c index ee568d4b3d..ea2fe7a3c9 100644 --- a/core/screenshot.c +++ b/core/screenshot.c @@ -81,7 +81,7 @@ static void screenshot_msg(screenshot_ctx *ctx, int status, const char *msg, mp_msg(MSGT_CPLAYER, status == SMSG_ERR ? MSGL_ERR : MSGL_INFO, "%s\n", s); if (ctx->osd) { - set_osd_tmsg(ctx->mpctx, OSD_MSG_TEXT, 1, ctx->mpctx->opts.osd_duration, + set_osd_tmsg(ctx->mpctx, OSD_MSG_TEXT, 1, ctx->mpctx->opts->osd_duration, "%s", s); } @@ -234,7 +234,7 @@ static char *gen_fname(screenshot_ctx *ctx, const char *file_ext) for (;;) { int prev_sequence = sequence; char *fname = create_fname(ctx->mpctx, - ctx->mpctx->opts.screenshot_template, + ctx->mpctx->opts->screenshot_template, file_ext, &sequence, &ctx->frameno); @@ -282,7 +282,7 @@ static void screenshot_save(struct MPContext *mpctx, struct mp_image *image) { screenshot_ctx *ctx = mpctx->screenshot_ctx; - struct image_writer_opts *opts = mpctx->opts.screenshot_image_opts; + struct image_writer_opts *opts = mpctx->opts->screenshot_image_opts; char *filename = gen_fname(ctx, image_writer_file_ext(opts)); if (filename) { @@ -322,7 +322,7 @@ void screenshot_to_file(struct MPContext *mpctx, const char *filename, int mode, bool osd) { screenshot_ctx *ctx = mpctx->screenshot_ctx; - struct image_writer_opts opts = *mpctx->opts.screenshot_image_opts; + struct image_writer_opts opts = *mpctx->opts->screenshot_image_opts; bool old_osd = ctx->osd; ctx->osd = osd; diff --git a/core/timeline/tl_cue.c b/core/timeline/tl_cue.c index 1953f46116..3c4a997982 100644 --- a/core/timeline/tl_cue.c +++ b/core/timeline/tl_cue.c @@ -188,10 +188,10 @@ static bool try_open(struct MPContext *mpctx, char *filename) || bstrcasecmp(bstr0(mpctx->demuxer->filename), bfilename) == 0) return false; - struct stream *s = stream_open(filename, &mpctx->opts); + struct stream *s = stream_open(filename, mpctx->opts); if (!s) return false; - struct demuxer *d = demux_open(s, NULL, NULL, &mpctx->opts); + struct demuxer *d = demux_open(s, NULL, NULL, mpctx->opts); // Since .bin files are raw PCM data with no headers, we have to explicitly // open them. Also, try to avoid to open files that are most likely not .bin // files, as that would only play noise. Checking the file extension is @@ -200,7 +200,7 @@ static bool try_open(struct MPContext *mpctx, char *filename) // CD sector size (2352 bytes) if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Opening as BIN file!\n"); - d = demux_open(s, "rawaudio", NULL, &mpctx->opts); + d = demux_open(s, "rawaudio", NULL, mpctx->opts); } if (d) { add_source(mpctx, d); diff --git a/core/timeline/tl_edl.c b/core/timeline/tl_edl.c index 6096d03b6a..4afb346dae 100644 --- a/core/timeline/tl_edl.c +++ b/core/timeline/tl_edl.c @@ -354,10 +354,10 @@ void build_edl_timeline(struct MPContext *mpctx) mpctx->num_sources = 1; for (int i = 0; i < num_sources; i++) { - struct stream *s = stream_open(edl_ids[i].filename, &mpctx->opts); + struct stream *s = stream_open(edl_ids[i].filename, mpctx->opts); if (!s) goto openfail; - struct demuxer *d = demux_open(s, NULL, NULL, &mpctx->opts); + struct demuxer *d = demux_open(s, NULL, NULL, mpctx->opts); if (!d) { free_stream(s); openfail: diff --git a/core/timeline/tl_matroska.c b/core/timeline/tl_matroska.c index 7c100618a3..cc6e62d429 100644 --- a/core/timeline/tl_matroska.c +++ b/core/timeline/tl_matroska.c @@ -116,7 +116,7 @@ static char **find_files(const char *original_file, const char *suffix) static int enable_cache(struct MPContext *mpctx, struct stream **stream, struct demuxer **demuxer, struct demuxer_params *params) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (opts->stream_cache_size <= 0) return 0; @@ -125,7 +125,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream, free_demuxer(*demuxer); free_stream(*stream); - *stream = stream_open(filename, &mpctx->opts); + *stream = stream_open(filename, opts); if (!*stream) { talloc_free(filename); return -1; @@ -137,7 +137,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream, opts->stream_cache_min_percent, opts->stream_cache_seek_min_percent); - *demuxer = demux_open(*stream, "mkv", params, &mpctx->opts); + *demuxer = demux_open(*stream, "mkv", params, opts); if (!*demuxer) { talloc_free(filename); free_stream(*stream); @@ -159,10 +159,10 @@ static bool check_file_seg(struct MPContext *mpctx, struct demuxer **sources, .matroska_wanted_segment = segment, .matroska_was_valid = &was_valid, }; - struct stream *s = stream_open(filename, &mpctx->opts); + struct stream *s = stream_open(filename, mpctx->opts); if (!s) return false; - struct demuxer *d = demux_open(s, "mkv", ¶ms, &mpctx->opts); + struct demuxer *d = demux_open(s, "mkv", ¶ms, mpctx->opts); if (!d) { free_stream(s); @@ -258,7 +258,7 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx, void build_ordered_chapter_timeline(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; + struct MPOpts *opts = mpctx->opts; if (!opts->ordered_chapters) { mp_msg(MSGT_CPLAYER, MSGL_INFO, "File uses ordered chapters, but " -- cgit v1.2.3