void uninit_sub(struct MPContext *mpctx, int order) { if (mpctx->d_sub[order]) { reset_subtitles(mpctx, order); mpctx->d_sub[order] = NULL; // Note: not free'd. update_osd_sub_state(mpctx, order, NULL); // unset reselect_demux_streams(mpctx); } }
void uninit_sub(struct MPContext *mpctx, int order) { if (mpctx->d_sub[order]) { mpctx->d_sub[order] = NULL; // Note: not free'd. int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB; osd_set_sub(mpctx->osd, obj, NULL); reset_subtitles(mpctx, order); reselect_demux_streams(mpctx); } }
void reset_subtitle_state(struct MPContext *mpctx) { reset_subtitles(mpctx, 0); reset_subtitles(mpctx, 1); }
int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; assert(!(mpctx->initialized_flags & INITIALIZED_VCODEC)); init_demux_stream(mpctx, STREAM_VIDEO); sh_video_t *sh_video = mpctx->sh_video; if (!sh_video) goto no_video; MP_VERBOSE(mpctx, "[V] fourcc:0x%X size:%dx%d fps:%5.3f\n", mpctx->sh_video->format, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h, mpctx->sh_video->fps); if (opts->force_fps) mpctx->sh_video->fps = opts->force_fps; update_fps(mpctx); if (!mpctx->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) ========================== if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) { mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input, mpctx->encode_lavc_ctx); if (!mpctx->video_out) { MP_FATAL(mpctx, "Error opening/initializing " "the selected video_out (-vo) device.\n"); goto err_out; } mpctx->mouse_cursor_visible = true; mpctx->initialized_flags |= INITIALIZED_VO; } // dynamic allocation only to make stheader.h lighter talloc_free(sh_video->hwdec_info); sh_video->hwdec_info = talloc_zero(sh_video, struct mp_hwdec_info); vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, sh_video->hwdec_info); update_window_title(mpctx, true); if (stream_control(mpctx->sh_video->gsh->demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar) != STREAM_UNSUPPORTED) mpctx->sh_video->stream_aspect = ar; recreate_video_filters(mpctx); init_best_video_codec(sh_video, opts->video_decoders); if (!sh_video->initialized) goto err_out; mpctx->initialized_flags |= INITIALIZED_VCODEC; bool saver_state = opts->pause || !opts->stop_screensaver; vo_control(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER : VOCTRL_KILL_SCREENSAVER, NULL); vo_control(mpctx->video_out, mpctx->paused ? VOCTRL_PAUSE : VOCTRL_RESUME, NULL); sh_video->last_pts = MP_NOPTS_VALUE; sh_video->num_buffered_pts = 0; sh_video->next_frame_time = 0; mpctx->last_vf_reconfig_count = 0; mpctx->restart_playback = true; mpctx->sync_audio_to_video = !sh_video->gsh->attached_picture; mpctx->delay = 0; mpctx->vo_pts_history_seek_ts++; vo_seek_reset(mpctx->video_out); reset_subtitles(mpctx); return 1; err_out: no_video: uninit_player(mpctx, INITIALIZED_VCODEC | (opts->force_vo ? 0 : INITIALIZED_VO)); cleanup_demux_stream(mpctx, STREAM_VIDEO); mpctx->current_track[STREAM_VIDEO] = NULL; handle_force_window(mpctx, true); MP_INFO(mpctx, "Video: no video\n"); return 0; }
int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; assert(!(mpctx->initialized_flags & INITIALIZED_VCODEC)); assert(!mpctx->d_video); struct track *track = mpctx->current_track[0][STREAM_VIDEO]; struct sh_stream *sh = init_demux_stream(mpctx, track); if (!sh) goto no_video; MP_VERBOSE(mpctx, "[V] fourcc:0x%X size:%dx%d fps:%5.3f\n", sh->format, sh->video->disp_w, sh->video->disp_h, sh->video->fps); double ar = -1.0; //================== Init VIDEO (codec & libvo) ========================== if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) { mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input, mpctx->encode_lavc_ctx); if (!mpctx->video_out) { MP_FATAL(mpctx, "Error opening/initializing " "the selected video_out (-vo) device.\n"); goto err_out; } mpctx->mouse_cursor_visible = true; mpctx->initialized_flags |= INITIALIZED_VO; } update_window_title(mpctx, true); struct dec_video *d_video = talloc_zero(NULL, struct dec_video); mpctx->d_video = 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->video->fps; d_video->vo = mpctx->video_out; mpctx->initialized_flags |= INITIALIZED_VCODEC; vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &d_video->hwdec_info); if (stream_control(sh->demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar) != STREAM_UNSUPPORTED) d_video->stream_aspect = ar; 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(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER : VOCTRL_KILL_SCREENSAVER, NULL); vo_control(mpctx->video_out, mpctx->paused ? VOCTRL_PAUSE : VOCTRL_RESUME, NULL); mpctx->restart_playback = true; mpctx->sync_audio_to_video = !sh->attached_picture; mpctx->delay = 0; mpctx->video_next_pts = MP_NOPTS_VALUE; mpctx->playing_last_frame = false; mpctx->last_frame_duration = 0; mpctx->vo_pts_history_seek_ts++; vo_seek_reset(mpctx->video_out); reset_subtitles(mpctx, 0); reset_subtitles(mpctx, 1); 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: no_video: uninit_player(mpctx, INITIALIZED_VCODEC | (opts->force_vo ? 0 : INITIALIZED_VO)); mp_deselect_track(mpctx, track); handle_force_window(mpctx, true); MP_INFO(mpctx, "Video: no video\n"); return 0; }
void reinit_subs(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; struct track *track = mpctx->current_track[STREAM_SUB]; assert(!(mpctx->initialized_flags & INITIALIZED_SUB)); init_demux_stream(mpctx, STREAM_SUB); struct sh_stream *sh = mpctx->sh[STREAM_SUB]; // No track selected, or lazily added DVD track (will actually be created // on first sub packet) if (!sh) return; if (!sh->sub->dec_sub) { assert(!mpctx->d_sub); sh->sub->dec_sub = sub_create(mpctx->global); } assert(!mpctx->d_sub || sh->sub->dec_sub == mpctx->d_sub); // The decoder is kept in the stream header in order to make ordered // chapters work well. mpctx->d_sub = sh->sub->dec_sub; mpctx->initialized_flags |= INITIALIZED_SUB; struct dec_sub *dec_sub = mpctx->d_sub; assert(dec_sub); if (!sub_is_initialized(dec_sub)) { struct sh_video *sh_video = mpctx->d_video ? mpctx->d_video->header->video : NULL; int w = sh_video ? sh_video->disp_w : 0; int h = sh_video ? sh_video->disp_h : 0; float fps = sh_video ? sh_video->fps : 25; set_dvdsub_fake_extradata(dec_sub, track->demuxer->stream, w, h); sub_set_video_res(dec_sub, w, h); sub_set_video_fps(dec_sub, fps); sub_set_ass_renderer(dec_sub, mpctx->ass_library, mpctx->ass_renderer); sub_init_from_sh(dec_sub, sh); // Don't do this if the file has video/audio streams. Don't do it even // if it has only sub streams, because reading packets will change the // demuxer position. if (!track->preloaded && track->is_external) { demux_seek(track->demuxer, 0, SEEK_ABSOLUTE); track->preloaded = sub_read_all_packets(dec_sub, sh); } } mpctx->osd->dec_sub = dec_sub; // Decides whether to use OSD path or normal subtitle rendering path. mpctx->osd->render_bitmap_subs = opts->ass_enabled || !sub_has_get_text(dec_sub); reset_subtitles(mpctx); }