summaryrefslogtreecommitdiffstats
path: root/video
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 /video
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 'video')
-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
8 files changed, 20 insertions, 47 deletions
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);
}