summaryrefslogtreecommitdiffstats
path: root/libvo/vo_lavc.c
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 /libvo/vo_lavc.c
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 'libvo/vo_lavc.c')
-rw-r--r--libvo/vo_lavc.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/libvo/vo_lavc.c b/libvo/vo_lavc.c
index 5ba548926e..72a1351d85 100644
--- a/libvo/vo_lavc.c
+++ b/libvo/vo_lavc.c
@@ -34,7 +34,7 @@
#include "encode_lavc.h"
#include "sub/sub.h"
-#include "sub/draw_bmp.h"
+#include "sub/dec_sub.h"
struct priv {
uint8_t *buffer;
@@ -485,6 +485,29 @@ static void check_events(struct vo *vo)
{
}
+static void draw_osd(struct vo *vo, struct osd_state *osd)
+{
+ struct priv *vc = vo->priv;
+
+ if (vc->lastimg && vc->lastimg_wants_osd) {
+ struct aspect_data asp = vo->aspdat;
+ double sar = (double)asp.orgw / asp.orgh;
+ double dar = (double)asp.prew / asp.preh;
+
+ struct sub_render_params subparams = {
+ .pts = osd->vo_sub_pts,
+ .dim = {
+ .w = asp.orgw,
+ .h = asp.orgh,
+ .display_par = sar / dar,
+ .video_par = dar / sar,
+ },
+ };
+
+ osd_draw_on_image(osd, vc->lastimg, &vc->colorspace, &subparams);
+ }
+}
+
static int control(struct vo *vo, uint32_t request, void *data)
{
struct priv *vc = vo->priv;
@@ -506,25 +529,6 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_GET_YUV_COLORSPACE:
*(struct mp_csp_details *)data = vc->colorspace;
return 1;
- case VOCTRL_DRAW_EOSD:
- if (vc->lastimg && vc->lastimg_wants_osd) {
- struct sub_bitmaps *imgs = data;
- mp_draw_sub_bitmaps(vc->lastimg, imgs, &vc->colorspace);
- }
- return VO_TRUE;
- case VOCTRL_GET_EOSD_RES: {
- struct mp_eosd_res *r = data;
- r->w = vc->stream->codec->width;
- r->h = vc->stream->codec->height;
- r->ml = r->mr = 0;
- r->mt = r->mb = 0;
- return VO_TRUE;
- }
- case VOCTRL_QUERY_EOSD_FORMAT: {
- int format = *(int *)data;
- return (format == SUBBITMAP_LIBASS || format == SUBBITMAP_RGBA)
- ? VO_TRUE : VO_NOTIMPL;
- }
}
return VO_NOTIMPL;
}
@@ -543,7 +547,7 @@ const struct vo_driver video_out_lavc = {
.control = control,
.uninit = uninit,
.check_events = check_events,
- .draw_osd = draw_osd_with_eosd,
+ .draw_osd = draw_osd,
.flip_page_timed = flip_page_timed,
};