summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-18 17:31:00 +0200
committerwm4 <wm4@nowhere>2012-10-24 21:56:33 +0200
commit98f74335d509320f19db2da8786273f95cad2a69 (patch)
treefe0e36c96a26208ea87464a333ed89d056596ddb /sub
parentd5def80afbdc7d20a22f2f630cdd34c60a0b99a9 (diff)
downloadmpv-98f74335d509320f19db2da8786273f95cad2a69.tar.bz2
mpv-98f74335d509320f19db2da8786273f95cad2a69.tar.xz
sub: fix text subtitle aspect ratio with vo_xv and vo_lavc, refactor
This fixes that vo_xv didn't display text subtitles correctly when using anamorphic video. It didn't pass the aspect information to the subtitle renderer. Also, try to render OSD correctly with respect to aspect ratio settings: on vo_xv, the OSD is rendered into the video, and needs to be "stretched" too when playing anamorphic video. When the -monitorpixelaspect option is used, even with VOs such as vo_opengl the OSD has to be rendered with that aspect ratio. As preparation for future commits, replace the weird vsfilter_scale value with a somewhat more sensible video_par member. Also, struct mp_eosd_res is a better place for the aspect ratio parameters, as OSD needs this too. Use osd_draw_on_image() directly in vo_lavc, which fixes aspect ratio issues as well.
Diffstat (limited to 'sub')
-rw-r--r--sub/dec_sub.h2
-rw-r--r--sub/osd_libass.c1
-rw-r--r--sub/sd_ass.c4
-rw-r--r--sub/sub.c7
-rw-r--r--sub/sub.h2
5 files changed, 8 insertions, 8 deletions
diff --git a/sub/dec_sub.h b/sub/dec_sub.h
index 0c5c1ab7ee..389851503e 100644
--- a/sub/dec_sub.h
+++ b/sub/dec_sub.h
@@ -13,8 +13,6 @@ struct MPOpts *opts;
struct sub_render_params {
double pts;
struct mp_eosd_res dim;
- double normal_scale;
- double vsfilter_scale;
};
static inline bool is_text_sub(int type)
diff --git a/sub/osd_libass.c b/sub/osd_libass.c
index d77c0d1af2..a182c6bdf2 100644
--- a/sub/osd_libass.c
+++ b/sub/osd_libass.c
@@ -283,6 +283,7 @@ void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj,
return;
ass_set_frame_size(osd->osd_render, osd->res.w, osd->res.h);
+ ass_set_aspect_ratio(osd->osd_render, osd->res.display_par, 1.0);
mp_ass_render_frame(osd->osd_render, obj->osd_track, 0,
&obj->parts_cache, out_imgs);
talloc_steal(obj, obj->parts_cache);
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index a5e23d74da..7926820ece 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -137,11 +137,11 @@ static void get_bitmaps(struct sh_sub *sh, struct osd_state *osd,
if (params->pts == MP_NOPTS_VALUE)
return;
- double scale = params->normal_scale;
+ double scale = params->dim.display_par;
bool use_vs_aspect = opts->ass_style_override
? opts->ass_vsfilter_aspect_compat : 1;
if (ctx->vsfilter_aspect && use_vs_aspect)
- scale = params->vsfilter_scale;
+ scale = scale * params->dim.video_par;
ASS_Renderer *renderer = osd->ass_renderer;
mp_ass_configure(renderer, opts, &params->dim);
ass_set_aspect_ratio(renderer, scale, 1);
diff --git a/sub/sub.c b/sub/sub.c
index 862f5d1f6e..8599002927 100644
--- a/sub/sub.c
+++ b/sub/sub.c
@@ -270,15 +270,14 @@ void draw_osd_with_eosd(struct vo *vo, struct osd_state *osd)
formats[n] = vo_control(vo, VOCTRL_QUERY_EOSD_FORMAT, &data) == VO_TRUE;
}
- osd_update_ext(osd, dim);
+ dim.display_par = vo->monitor_par;
+ dim.video_par = vo->aspdat.par;
- struct aspect_data asp = vo->aspdat;
+ osd_update_ext(osd, dim);
struct sub_render_params subparams = {
.pts = osd->vo_sub_pts,
.dim = dim,
- .normal_scale = 1,
- .vsfilter_scale = (double) asp.prew / asp.preh * asp.orgh / asp.orgw,
};
for (int n = 0; n < MAX_OSD_PARTS; n++) {
diff --git a/sub/sub.h b/sub/sub.h
index 4f3ca905b6..3d40186b60 100644
--- a/sub/sub.h
+++ b/sub/sub.h
@@ -82,6 +82,8 @@ struct sub_bitmaps {
struct mp_eosd_res {
int w, h; // screen dimensions, including black borders
int mt, mb, ml, mr; // borders (top, bottom, left, right)
+ double display_par;
+ double video_par; // PAR of the original video (for some sub decoders)
};
enum mp_osdtype {