summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-23 21:41:40 +0100
committerwm4 <wm4@nowhere>2013-11-23 21:41:40 +0100
commitf90e7ef7eafa0d5b1933f93bb116011cf1cb74b1 (patch)
tree56bd6201e2bd2f0d54eadeb24c8b888703d87c77
parentde68b8f23c8cfbf5967aa73b08835f75ac0f152e (diff)
downloadmpv-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.)
-rw-r--r--mpvcore/player/command.c2
-rw-r--r--mpvcore/player/loadfile.c10
-rw-r--r--mpvcore/player/video.c30
-rw-r--r--video/decode/dec_video.h2
4 files changed, 18 insertions, 26 deletions
diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c
index d3d99c4b02..c2433106ac 100644
--- a/mpvcore/player/command.c
+++ b/mpvcore/player/command.c
@@ -1534,7 +1534,7 @@ static int mp_property_fps(m_option_t *prop, int action, void *arg,
{
if (!mpctx->d_video)
return M_PROPERTY_UNAVAILABLE;
- return m_property_float_ro(prop, action, arg, mpctx->d_video->header->video->fps);
+ return m_property_float_ro(prop, action, arg, mpctx->d_video->fps);
}
/// Video aspect (RO)
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index 33ee770b08..83916e5612 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -691,9 +691,6 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track)
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]);
@@ -1180,13 +1177,6 @@ goto_reopen_demuxer: ;
reinit_audio_chain(mpctx);
reinit_subs(mpctx);
- //================ SETUP STREAMS ==========================
-
- if (opts->force_fps && mpctx->d_video) {
- mpctx->d_video->header->video->fps = opts->force_fps;
- MP_INFO(mpctx, "FPS forced to be %5.3f.\n", mpctx->d_video->header->video->fps);
- }
-
//==================== START PLAYING =======================
if (!mpctx->d_video && !mpctx->d_audio) {
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;
}
}
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index ef0ff925ce..9f01d32947 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -57,7 +57,7 @@ struct dec_video {
float stream_aspect; // aspect ratio in media headers (DVD IFO files)
int i_bps; // == bitrate (compressed bytes/sec)
-
+ float fps; // FPS from demuxer or from user override
float initial_decoder_aspect;
};