From 7889e38f21a4ed65f020a1805b799478f1ad6e55 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 4 Mar 2013 22:21:57 +0100 Subject: Remove vo_fps global variable This is needed by the encode stuff for some reason, so we have to explicitly pass it. Functionality shouldn't change. --- core/encode.h | 1 + core/encode_lavc.c | 9 +++++++-- core/encode_lavc.h | 2 ++ core/mplayer.c | 15 ++++++++++++--- video/out/vo.c | 2 -- video/out/vo.h | 2 -- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/core/encode.h b/core/encode.h index f0f65f14c5..fdeb273f34 100644 --- a/core/encode.h +++ b/core/encode.h @@ -16,6 +16,7 @@ void encode_lavc_discontinuity(struct encode_lavc_context *ctx); bool encode_lavc_showhelp(struct MPOpts *opts); int encode_lavc_getstatus(struct encode_lavc_context *ctx, char *buf, int bufsize, float relative_position, float playback_time); void encode_lavc_expect_stream(struct encode_lavc_context *ctx, enum AVMediaType mt); +void encode_lavc_set_video_fps(struct encode_lavc_context *ctx, float fps); bool encode_lavc_didfail(struct encode_lavc_context *ctx); // check if encoding failed #endif diff --git a/core/encode_lavc.c b/core/encode_lavc.c index 070b806253..9bb1abcdcd 100644 --- a/core/encode_lavc.c +++ b/core/encode_lavc.c @@ -365,6 +365,11 @@ void encode_lavc_finish(struct encode_lavc_context *ctx) ctx->finished = true; } +void encode_lavc_set_video_fps(struct encode_lavc_context *ctx, float fps) +{ + ctx->vo_fps = fps; +} + static void encode_2pass_prepare(struct encode_lavc_context *ctx, AVDictionary **dictp, AVStream *stream, struct stream **bytebuf, @@ -458,8 +463,8 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx, if (ctx->options->fps > 0) r = av_d2q(ctx->options->fps, ctx->options->fps * 1001 + 2); - else if (ctx->options->autofps && vo_fps > 0) { - r = av_d2q(vo_fps, vo_fps * 1001 + 2); + else if (ctx->options->autofps && ctx->vo_fps > 0) { + r = av_d2q(ctx->vo_fps, ctx->vo_fps * 1001 + 2); mp_msg( MSGT_ENCODE, MSGL_INFO, "vo-lavc: option -ofps not specified " "but -oautofps is active, using guess of %u/%u\n", diff --git a/core/encode_lavc.h b/core/encode_lavc.h index fa935e039a..a0245c991a 100644 --- a/core/encode_lavc.h +++ b/core/encode_lavc.h @@ -35,6 +35,8 @@ struct encode_lavc_context { struct encode_output_conf *options; + float vo_fps; + // these are processed from the options AVFormatContext *avc; AVRational timebase; diff --git a/core/mplayer.c b/core/mplayer.c index b56415151d..d217f98932 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -2314,6 +2314,15 @@ static void vo_update_window_title(struct MPContext *mpctx) mpctx->video_out->window_title = talloc_steal(mpctx, title); } +static void update_fps(struct MPContext *mpctx) +{ +#ifdef CONFIG_ENCODING + struct sh_video *sh_video = mpctx->sh_video; + if (mpctx->encode_lavc_ctx && sh_video) + encode_lavc_set_video_fps(mpctx->encode_lavc_ctx, sh_video->fps); +#endif +} + int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; @@ -2338,7 +2347,7 @@ int reinit_video_chain(struct MPContext *mpctx) mpctx->sh_video->fps = force_fps; mpctx->sh_video->frametime = 1.0f / mpctx->sh_video->fps; } - vo_fps = mpctx->sh_video->fps; + update_fps(mpctx); if (!mpctx->sh_video->fps && !force_fps && !opts->correct_pts) { mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "FPS not specified in the " @@ -2453,7 +2462,7 @@ static double update_video_nocorrect_pts(struct MPContext *mpctx) if (mpctx->sh_audio) mpctx->delay -= frame_time; // video_read_frame can change fps (e.g. for ASF video) - vo_fps = sh_video->fps; + update_fps(mpctx); int framedrop_type = check_framedrop(mpctx, frame_time); void *decoded_frame; @@ -3215,7 +3224,7 @@ static void run_playloop(struct MPContext *mpctx) double buffered_audio = -1; while (mpctx->sh_video) { // never loops, for "break;" only struct vo *vo = mpctx->video_out; - vo_fps = mpctx->sh_video->fps; + update_fps(mpctx); video_left = vo->hasframe || vo->frame_loaded; if (!vo->frame_loaded && (!mpctx->paused || mpctx->restart_playback)) { diff --git a/video/out/vo.c b/video/out/vo.c index 5841d6fd52..50d2dd4193 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -42,8 +42,6 @@ #include "video/vfcap.h" #include "sub/sub.h" -float vo_fps=0; - // // Externally visible list of all vo drivers // diff --git a/video/out/vo.h b/video/out/vo.h index ed3be652bd..ce26269a91 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -310,8 +310,6 @@ const char *vo_get_window_title(struct vo *vo); // NULL terminated array of all drivers extern const struct vo_driver *video_out_drivers[]; -extern float vo_fps; - struct mp_keymap { int from; int to; -- cgit v1.2.3