mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 00:06:25 +01:00
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.
This commit is contained in:
parent
6ef1a1cddd
commit
7889e38f21
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -42,8 +42,6 @@
|
||||
#include "video/vfcap.h"
|
||||
#include "sub/sub.h"
|
||||
|
||||
float vo_fps=0;
|
||||
|
||||
//
|
||||
// Externally visible list of all vo drivers
|
||||
//
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user