diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2011-01-26 20:42:15 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2011-01-26 20:42:15 +0200 |
commit | f50f34245efa1012855a693558680bcfb7c348e5 (patch) | |
tree | 76e8fc186a96fdc1106b5c634d5937e514a06037 /libmpcodecs/vf_vo.c | |
parent | ec55a188e4d0232acd50fcabc0a3db3be2b9538e (diff) | |
parent | c9026cb3210205b07e2e068467a18ee40f9259a3 (diff) | |
download | mpv-f50f34245efa1012855a693558680bcfb7c348e5.tar.bz2 mpv-f50f34245efa1012855a693558680bcfb7c348e5.tar.xz |
Merge branch 'sub'
* sub:
sub/OSD: move some related files to sub/
subtitles: options: enable -ass by default
subtitles: change default libass rendering style
demux_mkv, chapters: change millisecond arithmetic to ns
cleanup: rename ass_* functions to mp_ass_*
subs: use correct font aspect ratio for libass + converted subs
cleanup: some random minor code simplification and cleanup
vf_vo: fix EOSD change detection bug
sd_ass: remove subreader use, support plaintext markup
subtitles: style support for common SubRip tags and MicroDVD
core: ordered chapters: fix bad subtitle parameter
subs/demux: don't try to enable sub track when creating it
subtitles/demux: store duration instead of endpts in demux packets
subtitles: add framework for subtitle decoders
options: add special -leak-report option
subtitles: remove code trying to handle text subs with libavcodec
cleanup: move MP_NOPTS_VALUE definition to mpcommon.h
subtitles: move global ass_track to struct osd_state
core: move most mpcommon.c contents to mplayer.c
core: move global "subdata" and "vo_sub_last" to mpctx
subtitles: remove sub_last_pts hack
options: move -noconfig to option struct, simplify
Diffstat (limited to 'libmpcodecs/vf_vo.c')
-rw-r--r-- | libmpcodecs/vf_vo.c | 78 |
1 files changed, 52 insertions, 26 deletions
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 0e8563d5a6..8bbaf465b3 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -29,21 +29,19 @@ #include "libvo/video_out.h" -#ifdef CONFIG_ASS -#include "ass_mp.h" -extern ASS_Track *ass_track; -#endif +#include "sub/ass_mp.h" +#include "sub/sub.h" //===========================================================================// -extern int sub_visibility; extern float sub_delay; struct vf_priv_s { struct vo *vo; #ifdef CONFIG_ASS - ASS_Renderer *ass_priv; - int prev_visibility; + ASS_Renderer *renderer_realaspect; + ASS_Renderer *renderer_vsfilter; + bool prev_visibility; double scale_ratio; #endif }; @@ -86,8 +84,12 @@ static int config(struct vf_instance *vf, #ifdef CONFIG_ASS vf->priv->scale_ratio = (double) d_width / d_height * height / width; - if (vf->priv->ass_priv) - ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED)); + if (vf->priv->renderer_realaspect) { + mp_ass_configure(vf->priv->renderer_realaspect, width, height, + vf->default_caps & VFCAP_EOSD_UNSCALED); + mp_ass_configure(vf->priv->renderer_vsfilter, width, height, + vf->default_caps & VFCAP_EOSD_UNSCALED); + } #endif return 1; @@ -133,33 +135,55 @@ static int control(struct vf_instance *vf, int request, void* data) #ifdef CONFIG_ASS case VFCTRL_INIT_EOSD: { - vf->priv->ass_priv = ass_renderer_init((ASS_Library*)data); - if (!vf->priv->ass_priv) return CONTROL_FALSE; - ass_configure_fonts(vf->priv->ass_priv); - vf->priv->prev_visibility = 0; + vf->priv->renderer_realaspect = ass_renderer_init(data); + if (!vf->priv->renderer_realaspect) + return CONTROL_FALSE; + vf->priv->renderer_vsfilter = ass_renderer_init(data); + if (!vf->priv->renderer_vsfilter) { + ass_renderer_done(vf->priv->renderer_realaspect); + return CONTROL_FALSE; + } + mp_ass_configure_fonts(vf->priv->renderer_realaspect); + mp_ass_configure_fonts(vf->priv->renderer_vsfilter); + vf->priv->prev_visibility = false; return CONTROL_TRUE; } case VFCTRL_DRAW_EOSD: { + struct osd_state *osd = data; mp_eosd_images_t images = {NULL, 2}; double pts = video_out->next_pts; - if (!video_out->config_ok || !vf->priv->ass_priv) return CONTROL_FALSE; - if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) { - mp_eosd_res_t res; - memset(&res, 0, sizeof(res)); + ASS_Renderer *renderer; + double scale; + if (osd->vsfilter_aspect) { + renderer = vf->priv->renderer_vsfilter; + scale = vf->priv->scale_ratio; + } else { + renderer = vf->priv->renderer_realaspect; + scale = 1; + } + if (!video_out->config_ok || !renderer) + return CONTROL_FALSE; + if (osd->ass_track_changed) + vf->priv->prev_visibility = false; + osd->ass_track_changed = false; + if (sub_visibility && osd->ass_track && (pts != MP_NOPTS_VALUE)) { + struct mp_eosd_res res = {0}; if (vo_control(video_out, VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) { - ass_set_frame_size(vf->priv->ass_priv, res.w, res.h); - ass_set_margins(vf->priv->ass_priv, res.mt, res.mb, res.ml, res.mr); - ass_set_aspect_ratio(vf->priv->ass_priv, vf->priv->scale_ratio, 1); + ass_set_frame_size(renderer, res.w, res.h); + ass_set_margins(renderer, res.mt, res.mb, res.ml, res.mr); + ass_set_aspect_ratio(renderer, scale, 1); } - images.imgs = ass_mp_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5, &images.changed); + images.imgs = mp_ass_render_frame(renderer, + osd->ass_track, + (pts+sub_delay) * 1000 + .5, + &images.changed); if (!vf->priv->prev_visibility) images.changed = 2; - vf->priv->prev_visibility = 1; + vf->priv->prev_visibility = true; } else - vf->priv->prev_visibility = 0; - vf->priv->prev_visibility = sub_visibility; + vf->priv->prev_visibility = false; return vo_control(video_out, VOCTRL_DRAW_EOSD, &images) == VO_TRUE; } #endif @@ -223,8 +247,10 @@ static void uninit(struct vf_instance *vf) * to get rid of numbered-mpi references that will now be invalid. */ vo_seek_reset(video_out); #ifdef CONFIG_ASS - if (vf->priv->ass_priv) - ass_renderer_done(vf->priv->ass_priv); + if (vf->priv->renderer_realaspect) { + ass_renderer_done(vf->priv->renderer_realaspect); + ass_renderer_done(vf->priv->renderer_vsfilter); + } #endif free(vf->priv); } |