diff options
author | wm4 <wm4@nowhere> | 2013-11-23 21:41:40 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-23 21:41:40 +0100 |
commit | f90e7ef7eafa0d5b1933f93bb116011cf1cb74b1 (patch) | |
tree | 56bd6201e2bd2f0d54eadeb24c8b888703d87c77 /mpvcore/player/video.c | |
parent | de68b8f23c8cfbf5967aa73b08835f75ac0f152e (diff) | |
download | mpv-f90e7ef7eafa0d5b1933f93bb116011cf1cb74b1.tar.bz2 mpv-f90e7ef7eafa0d5b1933f93bb116011cf1cb74b1.tar.xz |
video: don't overwrite demuxer FPS value
If the --fps option was given (MPOpts->force_fps), the demuxer FPS value
was overwritten with the forced value. This was fine, since the demuxer
value wasn't needed anymore. But with the recent changes not to write to
the demuxer stream headers, we don't want to do this anymore. So
maintain the (forced/updated) FPS value in dec_video->fps.
The removed code in loadfile.c is probably redundant, and an artifact
from past refactorings.
Note that sub.c will now always use the demuxer FPS value, instead of
the user override value. I think this is fine, because it used the
demuxer's video size values too. (And it's rare that these values are
used at all.)
Diffstat (limited to 'mpvcore/player/video.c')
-rw-r--r-- | mpvcore/player/video.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c index 0c0199dd7d..7b3a236265 100644 --- a/mpvcore/player/video.c +++ b/mpvcore/player/video.c @@ -48,7 +48,7 @@ void update_fps(struct MPContext *mpctx) #if HAVE_ENCODING struct dec_video *d_video = mpctx->d_video; if (mpctx->encode_lavc_ctx && d_video) - encode_lavc_set_video_fps(mpctx->encode_lavc_ctx, d_video->header->video->fps); + encode_lavc_set_video_fps(mpctx->encode_lavc_ctx, d_video->fps); #endif } @@ -99,14 +99,6 @@ int reinit_video_chain(struct MPContext *mpctx) sh->format, sh->video->disp_w, sh->video->disp_h, sh->video->fps); - if (opts->force_fps) - sh->video->fps = opts->force_fps; - update_fps(mpctx); - - if (!sh->video->fps && !opts->force_fps && !opts->correct_pts) { - MP_ERR(mpctx, "FPS not specified in the " - "header or invalid, use the -fps option.\n"); - } double ar = -1.0; //================== Init VIDEO (codec & libvo) ========================== @@ -129,6 +121,7 @@ int reinit_video_chain(struct MPContext *mpctx) d_video->last_pts = MP_NOPTS_VALUE; d_video->opts = mpctx->opts; d_video->header = sh; + d_video->fps = sh->video->fps; mpctx->initialized_flags |= INITIALIZED_VCODEC; vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &d_video->hwdec_info); @@ -158,6 +151,16 @@ int reinit_video_chain(struct MPContext *mpctx) vo_seek_reset(mpctx->video_out); reset_subtitles(mpctx); + if (opts->force_fps) { + d_video->fps = opts->force_fps; + MP_INFO(mpctx, "FPS forced to be %5.3f.\n", d_video->fps); + } + if (!sh->video->fps && !opts->force_fps && !opts->correct_pts) { + MP_ERR(mpctx, "FPS not specified in the " + "header or invalid, use the -fps option.\n"); + } + update_fps(mpctx); + return 1; err_out: @@ -247,7 +250,7 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time) { float delay = opts->playback_speed * ao_get_delay(mpctx->ao); float d = delay - mpctx->delay; - float fps = mpctx->d_video->header->video->fps; + float fps = mpctx->d_video->fps; if (frame_time < 0) frame_time = fps > 0 ? 1.0 / fps : 0; // we should avoid dropping too many frames in sequence unless we @@ -266,7 +269,6 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time) static struct demux_packet *video_read_frame(struct MPContext *mpctx) { struct dec_video *d_video = mpctx->d_video; - sh_video_t *sh_video = d_video->header->video; demuxer_t *demuxer = d_video->header->demuxer; float pts1 = d_video->last_pts; @@ -277,7 +279,7 @@ static struct demux_packet *video_read_frame(struct MPContext *mpctx) if (pkt->pts != MP_NOPTS_VALUE) d_video->last_pts = pkt->pts; - float frame_time = sh_video->fps > 0 ? 1.0f / sh_video->fps : 0; + float frame_time = d_video->fps > 0 ? 1.0f / d_video->fps : 0; // override frame_time for variable/unknown FPS formats: if (!mpctx->opts->force_fps) { @@ -287,10 +289,10 @@ static struct demux_packet *video_read_frame(struct MPContext *mpctx) if (d >= 0) { if (demuxer->type == DEMUXER_TYPE_TV) { if (d > 0) - sh_video->fps = 1.0f / d; + d_video->fps = 1.0f / d; frame_time = d; } else { - if ((int)sh_video->fps <= 1) + if ((int)d_video->fps <= 1) frame_time = d; } } |