diff options
author | wm4 <wm4@nowhere> | 2016-02-05 21:50:37 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-02-05 23:17:27 +0100 |
commit | 8af70561a419c5a4a9926f9e60381dc4282a3fd9 (patch) | |
tree | cbf0fc3ef42ada34a744c95c94746786a5894cb8 /player/video.c | |
parent | 242dbc6c2c985bfd4dd8df699c6df6c33f8889d1 (diff) | |
download | mpv-8af70561a419c5a4a9926f9e60381dc4282a3fd9.tar.bz2 mpv-8af70561a419c5a4a9926f9e60381dc4282a3fd9.tar.xz |
player: move audio and video decoder init to separate functions
Preparation.
Diffstat (limited to 'player/video.c')
-rw-r--r-- | player/video.c | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/player/video.c b/player/video.c index 0cba95a9c8..4df51b1128 100644 --- a/player/video.c +++ b/player/video.c @@ -307,6 +307,42 @@ void uninit_video_chain(struct MPContext *mpctx) } } +int init_video_decoder(struct MPContext *mpctx, struct track *track) +{ + assert(!track->d_video); + if (!track->stream) + goto err_out; + + track->d_video = talloc_zero(NULL, struct dec_video); + struct dec_video *d_video = track->d_video; + d_video->global = mpctx->global; + d_video->log = mp_log_new(d_video, mpctx->log, "!vd"); + d_video->opts = mpctx->opts; + d_video->header = track->stream; + d_video->fps = d_video->header->codec->fps; + if (mpctx->vo_chain) + d_video->hwdec_info = mpctx->vo_chain->hwdec_info; + + MP_VERBOSE(d_video, "Container reported FPS: %f\n", d_video->fps); + + if (d_video->opts->force_fps) { + d_video->fps = d_video->opts->force_fps; + MP_INFO(mpctx, "FPS forced to %5.3f.\n", d_video->fps); + MP_INFO(mpctx, "Use --no-correct-pts to force FPS based timing.\n"); + } + + if (!video_init_best_codec(d_video, d_video->opts->video_decoders)) + goto err_out; + + return 1; + +err_out: + video_uninit(track->d_video); + track->d_video = NULL; + error_on_track(mpctx, track); + return 0; +} + int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; @@ -342,37 +378,20 @@ int reinit_video_chain(struct MPContext *mpctx) vo_control(vo_c->vo, VOCTRL_GET_HWDEC_INFO, &vo_c->hwdec_info); - track->d_video = talloc_zero(NULL, struct dec_video); - struct dec_video *d_video = track->d_video; - d_video->global = mpctx->global; - d_video->log = mp_log_new(d_video, mpctx->log, "!vd"); - d_video->opts = mpctx->opts; - d_video->header = sh; - d_video->fps = sh->codec->fps; - d_video->hwdec_info = vo_c->hwdec_info; - - MP_VERBOSE(d_video, "Container reported FPS: %f\n", sh->codec->fps); - - if (opts->force_fps) { - d_video->fps = opts->force_fps; - MP_INFO(mpctx, "FPS forced to %5.3f.\n", d_video->fps); - MP_INFO(mpctx, "Use --no-correct-pts to force FPS based timing.\n"); - } + if (!init_video_decoder(mpctx, track)) + goto err_out; - vo_c->container_fps = d_video->fps; + vo_c->video_src = track->d_video; + vo_c->container_fps = vo_c->video_src->fps; vo_c->is_coverart = !!sh->attached_picture; - vo_c->video_src = d_video; #if HAVE_ENCODING if (mpctx->encode_lavc_ctx) - encode_lavc_set_video_fps(mpctx->encode_lavc_ctx, d_video->fps); + encode_lavc_set_video_fps(mpctx->encode_lavc_ctx, vo_c->container_fps); #endif recreate_video_filters(mpctx); - if (!video_init_best_codec(d_video, opts->video_decoders)) - goto err_out; - bool saver_state = opts->pause || !opts->stop_screensaver; vo_control(vo_c->vo, saver_state ? VOCTRL_RESTORE_SCREENSAVER : VOCTRL_KILL_SCREENSAVER, NULL); |