summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sub/osd.c15
-rw-r--r--sub/osd.h3
-rw-r--r--video/out/vo_corevideo.c5
-rw-r--r--video/out/vo_direct3d.c8
-rw-r--r--video/out/vo_image.c11
-rw-r--r--video/out/vo_lavc.c12
-rw-r--r--video/out/vo_opengl_old.c13
-rw-r--r--video/out/vo_vaapi.c6
-rw-r--r--video/out/vo_vdpau.c5
-rw-r--r--video/out/vo_xv.c7
10 files changed, 38 insertions, 47 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);
diff --git a/video/out/vo_corevideo.c b/video/out/vo_corevideo.c
index 20769d7ca1..d9e28e80fc 100644
--- a/video/out/vo_corevideo.c
+++ b/video/out/vo_corevideo.c
@@ -279,7 +279,7 @@ static int get_image_fmt(struct vo *vo, CVPixelBufferRef pbuf)
static mp_image_t *get_screenshot(struct vo *vo, CVPixelBufferRef pbuf)
{
int img_fmt = get_image_fmt(vo, pbuf);
- if (img_fmt < 0) return NULL;
+ if (img_fmt < 0 || !vo->params) return NULL;
struct priv *p = vo->priv;
CVPixelBufferLockBaseAddress(pbuf, 0);
@@ -295,8 +295,7 @@ static mp_image_t *get_screenshot(struct vo *vo, CVPixelBufferRef pbuf)
img.stride[0] = stride;
struct mp_image *image = mp_image_new_copy(&img);
- mp_image_set_display_size(image, vo->aspdat.prew, vo->aspdat.preh);
- mp_image_set_colorspace_details(image, &p->colorspace);
+ mp_image_set_attributes(image, vo->params);
CVPixelBufferUnlockBaseAddress(pbuf, 0);
return image;
diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c
index 10539d4f18..eae04eecb8 100644
--- a/video/out/vo_direct3d.c
+++ b/video/out/vo_direct3d.c
@@ -1432,15 +1432,15 @@ static mp_image_t *get_screenshot(d3d_priv *priv)
if (!priv->have_image)
return NULL;
+ if (!priv->vo->params)
+ return NULL;
+
struct mp_image buffer;
if (!get_video_buffer(priv, &buffer))
return NULL;
struct mp_image *image = mp_image_new_copy(&buffer);
- mp_image_set_display_size(image, priv->vo->aspdat.prew,
- priv->vo->aspdat.preh);
-
- mp_image_set_colorspace_details(image, &priv->colorspace);
+ mp_image_set_attributes(image, priv->vo->params);
d3d_unlock_video_objects(priv);
return image;
diff --git a/video/out/vo_image.c b/video/out/vo_image.c
index f7f3a35822..6c518655ad 100644
--- a/video/out/vo_image.c
+++ b/video/out/vo_image.c
@@ -87,16 +87,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct priv *p = vo->priv;
- struct aspect_data asp = vo->aspdat;
- double sar = (double)asp.orgw / asp.orgh;
- double dar = (double)asp.prew / asp.preh;
-
- struct mp_osd_res dim = {
- .w = asp.orgw,
- .h = asp.orgh,
- .display_par = sar / dar,
- };
-
+ struct mp_osd_res dim = osd_res_from_image_params(vo->params);
osd_draw_on_image(osd, dim, osd_get_vo_pts(osd), OSD_DRAW_SUB_ONLY, p->current);
}
diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c
index 8a784db37b..fe5bbcf775 100644
--- a/video/out/vo_lavc.c
+++ b/video/out/vo_lavc.c
@@ -487,16 +487,8 @@ 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 mp_osd_res dim = {
- .w = asp.orgw,
- .h = asp.orgh,
- .display_par = sar / dar,
- };
+ if (vc->lastimg && vc->lastimg_wants_osd && vo->params) {
+ struct mp_osd_res dim = osd_res_from_image_params(vo->params);
mp_image_set_colorspace_details(vc->lastimg, &vc->colorspace);
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c
index 3ce009e3d0..0d877c5946 100644
--- a/video/out/vo_opengl_old.c
+++ b/video/out/vo_opengl_old.c
@@ -1458,11 +1458,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
struct mp_osd_res res = p->osd_res;
if (p->scaled_osd) {
- res = (struct mp_osd_res) {
- .w = p->image_width,
- .h = p->image_height,
- .display_par = 1.0 / vo->aspdat.par,
- };
+ res = osd_res_from_image_params(vo->params);
gl->MatrixMode(GL_MODELVIEW);
gl->PushMatrix();
// Setup image space -> screen space (assumes osd_res in screen space)
@@ -2009,6 +2005,9 @@ static mp_image_t *get_screenshot(struct vo *vo)
struct gl_priv *p = vo->priv;
GL *gl = p->gl;
+ if (!vo->params)
+ return NULL;
+
mp_image_t *image = mp_image_alloc(p->image_format, p->texture_width,
p->texture_height);
@@ -2025,9 +2024,7 @@ static mp_image_t *get_screenshot(struct vo *vo)
gl->ActiveTexture(GL_TEXTURE0);
}
mp_image_set_size(image, p->image_width, p->image_height);
- mp_image_set_display_size(image, vo->aspdat.prew, vo->aspdat.preh);
-
- mp_image_set_colorspace_details(image, &p->colorspace);
+ mp_image_set_attributes(image, vo->params);
return image;
}
diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c
index 4876c454d9..8b40afe44c 100644
--- a/video/out/vo_vaapi.c
+++ b/video/out/vo_vaapi.c
@@ -420,11 +420,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
if (!p->osd_format.fourcc)
return;
- struct mp_osd_res vid_res = {
- .w = p->image_params.w,
- .h = p->image_params.h,
- .display_par = 1.0 / vo->aspdat.par,
- };
+ struct mp_osd_res vid_res = osd_res_from_image_params(vo->params);
struct mp_osd_res *res;
if (p->osd_screen) {
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index c93c3eb0a6..90460a9ff4 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -1239,6 +1239,9 @@ static struct mp_image *get_screenshot(struct vo *vo)
VdpStatus vdp_st;
struct vdp_functions *vdp = vc->vdp;
+ if (!vo->params)
+ return NULL;
+
if (vc->screenshot_surface == VDP_INVALID_HANDLE) {
vdp_st = vdp->output_surface_create(vc->vdp_device,
OUTPUT_RGBA_FORMAT,
@@ -1253,7 +1256,7 @@ static struct mp_image *get_screenshot(struct vo *vo)
struct mp_image *image = read_output_surface(vo, vc->screenshot_surface,
vc->vid_width, vc->vid_height);
- mp_image_set_display_size(image, vo->aspdat.prew, vo->aspdat.preh);
+ mp_image_set_display_size(image, vo->params->d_w, vo->params->d_h);
return image;
}
diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c
index 53a46cbe5a..9f63c2ba49 100644
--- a/video/out/vo_xv.c
+++ b/video/out/vo_xv.c
@@ -616,12 +616,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
struct mp_image img = get_xv_buffer(vo, ctx->current_buf);
- struct mp_osd_res res = {
- .w = ctx->image_width,
- .h = ctx->image_height,
- .display_par = 1.0 / vo->aspdat.par,
- };
-
+ struct mp_osd_res res = osd_res_from_image_params(vo->params);
osd_draw_on_image(osd, res, osd_get_vo_pts(osd), 0, &img);
}