summaryrefslogtreecommitdiffstats
path: root/sub/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-21 23:43:54 +0100
committerwm4 <wm4@nowhere>2014-01-22 00:35:52 +0100
commit4de73fd5c18b982d0a89e2381fcdb3c1e3fea4e3 (patch)
tree70638dee2c0ec0584bc3b859e2ecd41d7947524b /sub/osd.c
parent302e8ff464663522234cfe5b182b9d84193b1981 (diff)
downloadmpv-4de73fd5c18b982d0a89e2381fcdb3c1e3fea4e3.tar.bz2
mpv-4de73fd5c18b982d0a89e2381fcdb3c1e3fea4e3.tar.xz
video/out: don't access aspdat in VOs
vo->aspdat is basically an outdated version of vo->params, plus some weirdness. Get rid of it, which will allow further cleanups and which will make multithreading easier (less state to care about). Also, simplify some VO code by using mp_image_set_attributes() instead of caring about display size, colorspace, etc. manually. Add the function osd_res_from_image_params(), which is often needed in the case OSD renders into an image.
Diffstat (limited to 'sub/osd.c')
-rw-r--r--sub/osd.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sub/osd.c b/sub/osd.c
index f1953ffa84..8da9fd0756 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -386,6 +386,21 @@ void osd_draw_on_image_p(struct osd_state *osd, struct mp_osd_res res,
&draw_on_image, &closure);
}
+// Setup the OSD resolution to render into an image with the given parameters.
+// The interesting part about this is that OSD has to compensate the aspect
+// ratio if the image does not have a 1:1 pixel aspect ratio.
+struct mp_osd_res osd_res_from_image_params(const struct mp_image_params *p)
+{
+ double sar = (double)p->w / p->h;
+ double dar = (double)p->d_w / p->d_h;
+
+ return (struct mp_osd_res) {
+ .w = p->w,
+ .h = p->h,
+ .display_par = sar / dar,
+ };
+}
+
void osd_changed(struct osd_state *osd, int new_value)
{
pthread_mutex_lock(&osd->lock);