summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
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 /libmpcodecs
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 'libmpcodecs')
-rw-r--r--libmpcodecs/vf_ass.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index 77248b49c0..167ebd6e15 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -63,7 +63,7 @@ static const struct vf_priv_s {
int auto_insert;
struct osd_state *osd;
- double aspect_correction;
+ struct mp_eosd_res dim;
unsigned char *planes[3];
struct line_limits {
@@ -92,7 +92,17 @@ static int config(struct vf_instance *vf,
vf->priv->planes[2] = malloc(vf->priv->outw * vf->priv->outh);
vf->priv->line_limits = malloc((vf->priv->outh + 1) / 2 * sizeof(*vf->priv->line_limits));
- vf->priv->aspect_correction = (double)width / height * d_height / d_width;
+ double dar = (double)d_width / d_height;
+ double sar = (double)width / height;
+
+ vf->priv->dim = (struct mp_eosd_res) {
+ .w = vf->priv->outw,
+ .h = vf->priv->outh,
+ .mt = opts->ass_top_margin,
+ .mb = opts->ass_bottom_margin,
+ .display_par = sar / dar,
+ .video_par = dar / sar,
+ };
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width,
d_height, flags, outfmt);
@@ -354,18 +364,12 @@ static int render_frame(struct vf_instance *vf, mp_image_t *mpi,
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
struct vf_priv_s *priv = vf->priv;
- struct MPOpts *opts = vf->opts;
struct osd_state *osd = priv->osd;
struct sub_bitmaps imgs = (struct sub_bitmaps) {0};
if (pts != MP_NOPTS_VALUE) {
struct sub_render_params subparams = {
.pts = pts,
- .dim = { .w = vf->priv->outw,
- .h = vf->priv->outh,
- .mt = opts->ass_top_margin,
- .mb = opts->ass_bottom_margin },
- .normal_scale = vf->priv->aspect_correction,
- .vsfilter_scale = 1,
+ .dim = priv->dim,
};
bool formats[SUBBITMAP_COUNT] = {[SUBBITMAP_LIBASS] = true};
osd_draw_sub(osd, &imgs, &subparams, formats);