summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
Diffstat (limited to 'sub')
-rw-r--r--sub/osd.c15
-rw-r--r--sub/osd.h3
2 files changed, 18 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);
diff --git a/sub/osd.h b/sub/osd.h
index 239286c5e6..048256bb92 100644
--- a/sub/osd.h
+++ b/sub/osd.h
@@ -200,6 +200,9 @@ void osd_draw_on_image_p(struct osd_state *osd, struct mp_osd_res res,
double video_pts, int draw_flags,
struct mp_image_pool *pool, struct mp_image *dest);
+struct mp_image_params;
+struct mp_osd_res osd_res_from_image_params(const struct mp_image_params *p);
+
void osd_object_get_scale_factor(struct osd_state *osd, int obj,
double *sw, double *sh);