Example #1
0
File: sub.c Project: farizalfa/mpv
static void reinit_subdec(struct MPContext *mpctx, struct track *track,
                          struct dec_sub *dec_sub)
{
    struct MPOpts *opts = mpctx->opts;

    if (sub_is_initialized(dec_sub))
        return;

    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;

    init_sub_renderer(mpctx);

    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, track->stream);

    if (mpctx->ass_renderer) {
        mp_ass_configure_fonts(mpctx->ass_renderer, opts->sub_text_style,
                               mpctx->global, mpctx->ass_log);
    }

    // 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 && !opts->sub_clear_on_seek) {
        demux_seek(track->demuxer, 0, SEEK_ABSOLUTE);
        track->preloaded = sub_read_all_packets(dec_sub, track->stream);
    }
}
Example #2
0
static void enable_output(struct sd *sd, bool enable)
{
    struct sd_ass_priv *ctx = sd->priv;
    if (enable == !!ctx->ass_renderer)
        return;
    if (ctx->ass_renderer) {
        ass_renderer_done(ctx->ass_renderer);
        ctx->ass_renderer = NULL;
    } else {
        ctx->ass_renderer = ass_renderer_init(ctx->ass_library);

        mp_ass_configure_fonts(ctx->ass_renderer, sd->opts->sub_text_style,
                               sd->global, sd->log);
    }
}
Example #3
0
static void init_sub_renderer(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;

    if (mpctx->ass_renderer)
        return;

    if (!mpctx->ass_log)
        mpctx->ass_log = mp_log_new(mpctx, mpctx->global->log, "!libass");

    mpctx->ass_library = mp_ass_init(mpctx->global, mpctx->ass_log);

    add_subtitle_fonts_from_sources(mpctx);

    if (opts->ass_style_override)
        ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list);

    mpctx->ass_renderer = ass_renderer_init(mpctx->ass_library);

    mp_ass_configure_fonts(mpctx->ass_renderer, opts->sub_text_style,
                           mpctx->global, mpctx->ass_log);
}