Example #1
0
File: sd_spu.c Project: ihling/mpv
static void get_bitmaps(struct sd *sd, struct mp_osd_res d, double pts,
                        struct sub_bitmaps *res)
{
    struct MPOpts *opts = sd->opts;
    struct sd_spu_priv *priv = sd->priv;

    spudec_set_forced_subs_only(priv->spudec, opts->forced_subs_only);
    spudec_heartbeat(priv->spudec, pts * 90000);

    if (spudec_visible(priv->spudec)) {
        double xscale = 1;
        double yscale = 1;
        if (opts->stretch_dvd_subs) {
            // For DVD subs, try to keep the subtitle PAR at display PAR.
            double video_par =
                  (priv->video_params.d_w / (double)priv->video_params.d_h)
                / (priv->video_params.w   / (double)priv->video_params.h);
            if (video_par > 1.0) {
                xscale /= video_par;
            } else {
                yscale *= video_par;
            }
        }
        spudec_get_indexed(priv->spudec, &d, xscale, yscale, res);
    }
}
Example #2
0
void init_vo_spudec(struct stream *stream, struct sh_video *sh_video, struct sh_sub *sh_sub)
{
    unsigned width, height;
    spudec_free(vo_spudec);
    vo_spudec = NULL;

    // we currently can't work without video stream
    if (!sh_video)
        return;

    if (spudec_ifo) {
        unsigned int palette[16];
        current_module = "spudec_init_vobsub";
        if (vobsub_parse_ifo(NULL, spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
            vo_spudec = spudec_new_scaled(palette, width, height, NULL, 0);
    }

    width  = sh_video->disp_w;
    height = sh_video->disp_h;

#ifdef CONFIG_DVDREAD
    if (vo_spudec == NULL && stream->type == STREAMTYPE_DVD) {
        current_module = "spudec_init_dvdread";
        vo_spudec      = spudec_new_scaled(((dvd_priv_t *)(stream->priv))->cur_pgc->palette,
                                           width, height,
                                           NULL, 0);
    }
#endif

#ifdef CONFIG_DVDNAV
    if (vo_spudec == NULL && stream->type == STREAMTYPE_DVDNAV) {
        unsigned int *palette = mp_dvdnav_get_spu_clut(stream);
        current_module = "spudec_init_dvdnav";
        vo_spudec      = spudec_new_scaled(palette, width, height, NULL, 0);
    }
#endif

    if (vo_spudec == NULL) {
        current_module = "spudec_init_normal";
        vo_spudec      = spudec_new_scaled(NULL, width, height,
                                           sh_sub ? sh_sub->extradata : NULL,
                                           sh_sub ? sh_sub->extradata_len : 0);
        spudec_set_font_factor(vo_spudec, font_factor);
    }

    if (vo_spudec)
        spudec_set_forced_subs_only(vo_spudec, forced_subs_only);
}