summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-10 02:02:24 +0100
committerwm4 <wm4@nowhere>2013-01-13 17:39:32 +0100
commitd77d9fb933e0e7dc34de02f3d0c13791ddd80114 (patch)
treeca45e0f9d753e7ee7b5bd142eb2aed1638bf391c /video/out
parent1568161aadf24ee3a6d982612b7380f8b1dc4a58 (diff)
downloadmpv-d77d9fb933e0e7dc34de02f3d0c13791ddd80114.tar.bz2
mpv-d77d9fb933e0e7dc34de02f3d0c13791ddd80114.tar.xz
mp_image: require using mp_image_set_size() for setting w/h
Setting the size of a mp_image must be done with mp_image_set_size() now. Do this to guarantee that the redundant fields (like chroma_width) are updated consistently. Replacing the redundant fields by function calls would probably be better, but there are too many uses of them, and is a bit less convenient. Most code actually called mp_image_setfmt(), which did this as well. This commit just makes things a bit more explicit. Warning: the video filter chain still sets up mp_images manually, and vf_get_image() is not updated.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/vo_corevideo.m3
-rw-r--r--video/out/vo_direct3d.c10
-rw-r--r--video/out/vo_image.c3
-rw-r--r--video/out/vo_opengl.c7
-rw-r--r--video/out/vo_opengl_old.c7
-rw-r--r--video/out/vo_sdl.c3
-rw-r--r--video/out/vo_vdpau.c6
-rw-r--r--video/out/vo_x11.c3
-rw-r--r--video/out/vo_xv.c6
9 files changed, 16 insertions, 32 deletions
diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.m
index bc8833f12f..292dfea5a5 100644
--- a/video/out/vo_corevideo.m
+++ b/video/out/vo_corevideo.m
@@ -373,8 +373,7 @@ static mp_image_t *get_screenshot(struct vo *vo)
memcpy(image->planes[0], base, image_size);
image->stride[0] = stride;
- image->display_w = vo->aspdat.prew;
- image->display_h = vo->aspdat.preh;
+ mp_image_set_display_size(image, vo->aspdat.prew, vo->aspdat.preh);
mp_image_set_colorspace_details(image, &p->colorspace);
diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c
index ab69fdbdf2..d3c907f944 100644
--- a/video/out/vo_direct3d.c
+++ b/video/out/vo_direct3d.c
@@ -1558,8 +1558,7 @@ static void check_events(struct vo *vo)
static bool get_video_buffer(d3d_priv *priv, struct mp_image *out)
{
*out = (struct mp_image) {0};
- out->w = out->width = priv->src_width;
- out->h = out->height = priv->src_height;
+ mp_image_set_size(out, priv->src_width, priv->src_height);
mp_image_setfmt(out, priv->image_format);
if (!priv->d3d_device)
@@ -1639,10 +1638,9 @@ static mp_image_t *get_screenshot(d3d_priv *priv)
if (!get_video_buffer(priv, &buffer))
return NULL;
- struct mp_image *image = alloc_mpi(buffer.w, buffer.h, buffer.imgfmt);
- copy_mpi(image, &buffer);
- image->display_w = priv->vo->aspdat.prew;
- image->display_h = priv->vo->aspdat.preh;
+ 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);
diff --git a/video/out/vo_image.c b/video/out/vo_image.c
index 7862ceb596..12bd18862a 100644
--- a/video/out/vo_image.c
+++ b/video/out/vo_image.c
@@ -101,8 +101,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
struct priv *p = vo->priv;
mp_image_t img = *mpi;
- img.display_w = p->d_width;
- img.display_h = p->d_height;
+ mp_image_set_display_size(&img, p->d_width, p->d_height);
mp_image_set_colorspace_details(&img, &p->colorspace);
void *t = talloc_new(NULL);
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 759cb96ba7..fc94a86eac 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -1350,11 +1350,8 @@ static mp_image_t *get_screenshot(struct gl_priv *p)
image->planes[n], image->stride[n]);
}
gl->ActiveTexture(GL_TEXTURE0);
-
- image->w = p->image_width;
- image->h = p->image_height;
- image->display_w = p->vo->aspdat.prew;
- image->display_h = p->vo->aspdat.preh;
+ mp_image_set_size(image, p->image_width, p->image_height);
+ mp_image_set_display_size(image, p->vo->aspdat.prew, p->vo->aspdat.preh);
mp_image_set_colorspace_details(image, &p->colorspace);
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c
index 3f629ed43e..a8ad21408e 100644
--- a/video/out/vo_opengl_old.c
+++ b/video/out/vo_opengl_old.c
@@ -806,11 +806,8 @@ static mp_image_t *get_screenshot(struct vo *vo)
image->stride[2]);
gl->ActiveTexture(GL_TEXTURE0);
}
-
- image->w = p->image_width;
- image->h = p->image_height;
- image->display_w = vo->aspdat.prew;
- image->display_h = vo->aspdat.preh;
+ 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);
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index f5a17b84d3..d04a63e5a6 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -435,8 +435,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
}
mp_image_t *texmpi = &vc->texmpi;
- texmpi->width = texmpi->w = width;
- texmpi->height = texmpi->h = height;
+ mp_image_set_size(texmpi, width, height);
mp_image_setfmt(texmpi, format);
switch (texmpi->num_planes) {
case 1:
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index 67ac0593f8..661072b814 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -1375,8 +1375,7 @@ static struct mp_image *get_screenshot(struct vo *vo)
struct mp_image *image = read_output_surface(vc, vc->screenshot_surface,
vc->vid_width, vc->vid_height);
- image->display_w = vo->aspdat.prew;
- image->display_h = vo->aspdat.preh;
+ mp_image_set_display_size(image, vo->aspdat.prew, vo->aspdat.preh);
return image;
}
@@ -1389,8 +1388,7 @@ static struct mp_image *get_window_screenshot(struct vo *vo)
struct mp_image *image = read_output_surface(vo->priv, screen,
vc->output_surface_width,
vc->output_surface_height);
- image->width = image->w = vo->dwidth;
- image->height = image->h = vo->dheight;
+ mp_image_set_size(image, vo->dwidth, vo->dheight);
return image;
}
diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c
index 98ebc7f6d1..58c709e471 100644
--- a/video/out/vo_x11.c
+++ b/video/out/vo_x11.c
@@ -419,8 +419,7 @@ static void Display_Image(struct priv *p, XImage *myximage, uint8_t *ImageData)
static struct mp_image get_x_buffer(struct priv *p)
{
struct mp_image img = {0};
- img.w = img.width = p->image_width;
- img.h = img.height = p->image_height;
+ mp_image_set_size(&img, p->image_width, p->image_height);
mp_image_setfmt(&img, p->out_format);
img.planes[0] = p->ImageData;
diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c
index cc4d55777d..46fe4649f5 100644
--- a/video/out/vo_xv.c
+++ b/video/out/vo_xv.c
@@ -318,8 +318,7 @@ static struct mp_image get_xv_buffer(struct vo *vo, int buf_index)
XvImage *xv_image = ctx->xvimage[buf_index];
struct mp_image img = {0};
- img.w = img.width = ctx->image_width;
- img.h = img.height = ctx->image_height;
+ mp_image_set_size(&img, ctx->image_width, ctx->image_height);
mp_image_setfmt(&img, ctx->image_format);
bool swapuv = ctx->image_format == IMGFMT_YV12;
@@ -398,10 +397,9 @@ static mp_image_t *get_screenshot(struct vo *vo)
struct mp_image *res = alloc_mpi(img.w, img.h, img.imgfmt);
copy_mpi(res, &img);
vf_clone_mpi_attributes(res, &img);
+ mp_image_set_display_size(res, vo->aspdat.prew, vo->aspdat.preh);
// try to get an image without OSD
mp_draw_sub_backup_restore(ctx->osd_backup, res);
- res->display_w = vo->aspdat.prew;
- res->display_h = vo->aspdat.preh;
return res;
}