mirror of
https://github.com/mpv-player/mpv
synced 2025-01-08 16:10:29 +00:00
video: cleanup: replace old mp_image function names
mp_image_alloc() also changes argument order compared to alloc_mpi(). The format now comes first, then width/height.
This commit is contained in:
parent
15c7f7a339
commit
0c5311f17c
@ -274,8 +274,8 @@ static void draw_rgba(struct mp_draw_sub_cache **cache, struct mp_rect bb,
|
||||
part->imgs[i].i = talloc_steal(part, sbi);
|
||||
part->imgs[i].a = talloc_steal(part, sba);
|
||||
} else {
|
||||
free_mp_image(sbi);
|
||||
free_mp_image(sba);
|
||||
talloc_free(sbi);
|
||||
talloc_free(sba);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -520,7 +520,7 @@ void mp_draw_sub_bitmaps(struct mp_draw_sub_cache **cache, struct mp_image *dst,
|
||||
if (dst->imgfmt == format) {
|
||||
temp = &dst_region;
|
||||
} else {
|
||||
temp = alloc_mpi(bb.x1 - bb.x0, bb.y1 - bb.y0, format);
|
||||
temp = mp_image_alloc(format, bb.x1 - bb.x0, bb.y1 - bb.y0);
|
||||
// temp is always YUV, dst_region not
|
||||
// reduce amount of conversions in YUV case (upsampling/shifting only)
|
||||
if (dst_region.flags & MP_IMGFLAG_YUV) {
|
||||
@ -538,7 +538,7 @@ void mp_draw_sub_bitmaps(struct mp_draw_sub_cache **cache, struct mp_image *dst,
|
||||
|
||||
if (temp != &dst_region) {
|
||||
mp_image_swscale(&dst_region, temp, SWS_AREA); // chroma down
|
||||
free_mp_image(temp);
|
||||
talloc_free(temp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -581,7 +581,7 @@ static void backup_realloc(struct mp_draw_sub_backup *backup,
|
||||
return;
|
||||
|
||||
talloc_free_children(backup);
|
||||
backup->image = alloc_mpi(img->w, img->h, img->imgfmt);
|
||||
backup->image = mp_image_alloc(img->imgfmt, img->w, img->h);
|
||||
talloc_steal(backup, backup->image);
|
||||
for (int p = 0; p < MP_MAX_PLANES; p++) {
|
||||
backup->lines[p] = talloc_array(backup, struct line_ext,
|
||||
|
@ -73,7 +73,7 @@ bool osd_conv_idx_to_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs)
|
||||
rgba_to_premultiplied_rgba(sb.palette, 256);
|
||||
|
||||
*d = *s;
|
||||
struct mp_image *image = alloc_mpi(s->w, s->h, IMGFMT_BGRA);
|
||||
struct mp_image *image = mp_image_alloc(IMGFMT_BGRA, s->w, s->h);
|
||||
talloc_steal(c->parts, image);
|
||||
d->stride = image->stride[0];
|
||||
d->bitmap = image->planes[0];
|
||||
@ -104,8 +104,8 @@ bool osd_conv_blur_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs,
|
||||
|
||||
// add a transparent padding border to reduce artifacts
|
||||
int pad = 5;
|
||||
struct mp_image *temp = alloc_mpi(s->w + pad * 2, s->h + pad * 2,
|
||||
IMGFMT_BGRA);
|
||||
struct mp_image *temp = mp_image_alloc(IMGFMT_BGRA, s->w + pad * 2,
|
||||
s->h + pad * 2);
|
||||
memset_pic(temp->planes[0], 0, temp->w * 4, temp->h, temp->stride[0]);
|
||||
uint8_t *p0 = temp->planes[0] + pad * 4 + pad * temp->stride[0];
|
||||
memcpy_pic(p0, s->bitmap, s->w * 4, s->h, temp->stride[0], s->stride);
|
||||
@ -117,7 +117,7 @@ bool osd_conv_blur_rgba(struct osd_conv_cache *c, struct sub_bitmaps *imgs,
|
||||
d->y = s->y - pad * sy;
|
||||
d->w = d->dw = s->dw + pad * 2 * sx;
|
||||
d->h = d->dh = s->dh + pad * 2 * sy;
|
||||
struct mp_image *image = alloc_mpi(d->w, d->h, IMGFMT_BGRA);
|
||||
struct mp_image *image = mp_image_alloc(IMGFMT_BGRA, d->w, d->h);
|
||||
talloc_steal(c->parts, image);
|
||||
d->stride = image->stride[0];
|
||||
d->bitmap = image->planes[0];
|
||||
|
@ -285,7 +285,7 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts,
|
||||
// - RGB->YUV assumes BT.601
|
||||
// - color levels broken in various ways thanks to libswscale
|
||||
if (image->imgfmt != destfmt || is_anamorphic) {
|
||||
struct mp_image *dst = alloc_mpi(d_w, d_h, destfmt);
|
||||
struct mp_image *dst = mp_image_alloc(destfmt, d_w, d_h);
|
||||
mp_image_copy_attributes(dst, image);
|
||||
|
||||
int flags = SWS_LANCZOS | SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP |
|
||||
@ -310,7 +310,7 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts,
|
||||
filename);
|
||||
}
|
||||
|
||||
free_mp_image(allocated_image);
|
||||
talloc_free(allocated_image);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -91,11 +91,6 @@ typedef struct mp_image {
|
||||
void* priv;
|
||||
} mp_image_t;
|
||||
|
||||
#define alloc_mpi(w, h, fmt) mp_image_alloc(fmt, w, h)
|
||||
#define free_mp_image talloc_free
|
||||
#define new_mp_image mp_image_new_empty
|
||||
#define copy_mpi mp_image_copy
|
||||
|
||||
struct mp_image *mp_image_alloc(unsigned int fmt, int w, int h);
|
||||
void mp_image_clear(struct mp_image *mpi, int x0, int y0, int w, int h);
|
||||
void mp_image_copy(struct mp_image *dmpi, struct mp_image *mpi);
|
||||
|
@ -1978,7 +1978,7 @@ mp_image_t *glGetWindowScreenshot(GL *gl)
|
||||
{
|
||||
GLint vp[4]; //x, y, w, h
|
||||
gl->GetIntegerv(GL_VIEWPORT, vp);
|
||||
mp_image_t *image = alloc_mpi(vp[2], vp[3], IMGFMT_RGB24);
|
||||
mp_image_t *image = mp_image_alloc(IMGFMT_RGB24, vp[2], vp[3]);
|
||||
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
gl->PixelStorei(GL_PACK_ALIGNMENT, 0);
|
||||
gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
|
@ -98,7 +98,7 @@ struct voctrl_screenshot_args {
|
||||
// implemented.
|
||||
int full_window;
|
||||
// Will be set to a newly allocated image, that contains the screenshot.
|
||||
// The caller has to free the pointer with free_mp_image().
|
||||
// The caller has to free the image with talloc_free().
|
||||
// It is not specified whether the image data is a copy or references the
|
||||
// image data directly.
|
||||
// Is never NULL. (Failure has to be indicated by returning VO_FALSE.)
|
||||
|
@ -1616,7 +1616,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
|
||||
if (!get_video_buffer(priv, &buffer))
|
||||
return;
|
||||
|
||||
copy_mpi(&buffer, mpi);
|
||||
mp_image_copy(&buffer, mpi);
|
||||
|
||||
d3d_unlock_video_objects(priv);
|
||||
|
||||
@ -1697,7 +1697,7 @@ static mp_image_t *get_window_screenshot(d3d_priv *priv)
|
||||
if (width < 1 || height < 1)
|
||||
goto error_exit;
|
||||
|
||||
image = alloc_mpi(width, height, IMGFMT_BGR32);
|
||||
image = mp_image_alloc(IMGFMT_BGR32, width, height);
|
||||
|
||||
IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
|
||||
|
||||
@ -1712,7 +1712,7 @@ static mp_image_t *get_window_screenshot(d3d_priv *priv)
|
||||
|
||||
error_exit:
|
||||
if (image)
|
||||
free_mp_image(image);
|
||||
talloc_free(image);
|
||||
if (surface)
|
||||
IDirect3DSurface9_Release(surface);
|
||||
return NULL;
|
||||
|
@ -89,7 +89,7 @@ static void uninit(struct vo *vo)
|
||||
// palette hack
|
||||
if (vc->lastimg->imgfmt == IMGFMT_PAL8)
|
||||
vc->lastimg->planes[1] = NULL;
|
||||
free_mp_image(vc->lastimg);
|
||||
talloc_free(vc->lastimg);
|
||||
vc->lastimg = NULL;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
|
||||
vc->buffer = talloc_size(vc, vc->buffer_size);
|
||||
|
||||
vc->lastimg = alloc_mpi(width, height, format);
|
||||
vc->lastimg = mp_image_alloc(format, width, height);
|
||||
|
||||
// palette hack
|
||||
if (vc->lastimg->imgfmt == IMGFMT_PAL8)
|
||||
@ -455,7 +455,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
|
||||
mp_msg(MSGT_ENCODE, MSGL_INFO,
|
||||
"vo-lavc: Frame at pts %d got displayed %d times\n",
|
||||
(int) vc->lastframeipts, vc->lastdisplaycount);
|
||||
copy_mpi(vc->lastimg, mpi);
|
||||
mp_image_copy(vc->lastimg, mpi);
|
||||
vc->lastimg_wants_osd = true;
|
||||
|
||||
// palette hack
|
||||
|
@ -1321,8 +1321,8 @@ static mp_image_t *get_screenshot(struct gl_priv *p)
|
||||
{
|
||||
GL *gl = p->gl;
|
||||
|
||||
mp_image_t *image = alloc_mpi(p->texture_width, p->texture_height,
|
||||
p->image_format);
|
||||
mp_image_t *image = mp_image_alloc(p->image_format, p->texture_width,
|
||||
p->texture_height);
|
||||
|
||||
// NOTE about image formats with alpha plane: we don't even have the alpha
|
||||
// anymore. We never upload it to any texture, as it would be a waste of
|
||||
|
@ -791,8 +791,8 @@ static mp_image_t *get_screenshot(struct vo *vo)
|
||||
struct gl_priv *p = vo->priv;
|
||||
GL *gl = p->gl;
|
||||
|
||||
mp_image_t *image = alloc_mpi(p->texture_width, p->texture_height,
|
||||
p->image_format);
|
||||
mp_image_t *image = mp_image_alloc(p->image_format, p->texture_width,
|
||||
p->texture_height);
|
||||
|
||||
glDownloadTex(gl, p->target, p->gl_format, p->gl_type, image->planes[0],
|
||||
image->stride[0]);
|
||||
|
@ -448,7 +448,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
return -1;
|
||||
}
|
||||
|
||||
vc->ssmpi = alloc_mpi(width, height, format);
|
||||
vc->ssmpi = mp_image_alloc(format, width, height);
|
||||
|
||||
resize(vo, d_width, d_height);
|
||||
|
||||
@ -593,7 +593,7 @@ static void uninit(struct vo *vo)
|
||||
{
|
||||
struct priv *vc = vo->priv;
|
||||
destroy_renderer(vo);
|
||||
free_mp_image(vc->ssmpi);
|
||||
talloc_free(vc->ssmpi);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
talloc_free(vc);
|
||||
}
|
||||
@ -857,7 +857,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
|
||||
if (color_add > 255)
|
||||
color_add = 255;
|
||||
|
||||
// typically this runs in parallel with the following copy_mpi call
|
||||
// typically this runs in parallel with the following mp_image_copy call
|
||||
SDL_SetRenderDrawColor(vc->renderer, color_add, color_add, color_add, 255);
|
||||
SDL_RenderClear(vc->renderer);
|
||||
|
||||
@ -894,7 +894,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
|
||||
texmpi->stride[2] = pitch / 2;
|
||||
}
|
||||
}
|
||||
copy_mpi(texmpi, mpi);
|
||||
mp_image_copy(texmpi, mpi);
|
||||
|
||||
SDL_UnlockTexture(vc->tex);
|
||||
}
|
||||
@ -909,7 +909,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
|
||||
dst.w = vc->dst_rect.x1 - vc->dst_rect.x0;
|
||||
dst.h = vc->dst_rect.y1 - vc->dst_rect.y0;
|
||||
|
||||
// typically this runs in parallel with the following copy_mpi call
|
||||
// typically this runs in parallel with the following mp_image_copy call
|
||||
if (color_mod > 255) {
|
||||
SDL_SetTextureColorMod(vc->tex, color_mod / 2, color_mod / 2, color_mod / 2);
|
||||
SDL_RenderCopy(vc->renderer, vc->tex, &src, &dst);
|
||||
@ -919,7 +919,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
|
||||
SDL_RenderCopy(vc->renderer, vc->tex, &src, &dst);
|
||||
}
|
||||
if (mpi)
|
||||
copy_mpi(vc->ssmpi, mpi);
|
||||
mp_image_copy(vc->ssmpi, mpi);
|
||||
}
|
||||
|
||||
static void update_screeninfo(struct vo *vo)
|
||||
@ -940,19 +940,18 @@ static void update_screeninfo(struct vo *vo)
|
||||
static struct mp_image *get_screenshot(struct vo *vo)
|
||||
{
|
||||
struct priv *vc = vo->priv;
|
||||
mp_image_t *image = alloc_mpi(vc->ssmpi->w, vc->ssmpi->h, vc->ssmpi->imgfmt);
|
||||
copy_mpi(image, vc->ssmpi);
|
||||
return image;
|
||||
return mp_image_new_copy(vc->ssmpi);
|
||||
}
|
||||
|
||||
static struct mp_image *get_window_screenshot(struct vo *vo)
|
||||
{
|
||||
struct priv *vc = vo->priv;
|
||||
mp_image_t *image = alloc_mpi(vo->dwidth, vo->dheight, vc->osd_format.mpv);
|
||||
struct mp_image *image = mp_image_alloc(vc->osd_format.mpv, vo->dwidth,
|
||||
vo->dheight);
|
||||
if (SDL_RenderReadPixels(vc->renderer, NULL, vc->osd_format.sdl,
|
||||
image->planes[0], image->stride[0])) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "[sdl] SDL_RenderReadPixels failed\n");
|
||||
free_mp_image(image);
|
||||
talloc_free(image);
|
||||
return NULL;
|
||||
}
|
||||
return image;
|
||||
|
@ -1339,7 +1339,7 @@ static struct mp_image *read_output_surface(struct vdpctx *vc,
|
||||
{
|
||||
VdpStatus vdp_st;
|
||||
struct vdp_functions *vdp = vc->vdp;
|
||||
struct mp_image *image = alloc_mpi(width, height, IMGFMT_BGR32);
|
||||
struct mp_image *image = mp_image_alloc(IMGFMT_BGR32, width, height);
|
||||
image->colorspace = MP_CSP_RGB;
|
||||
image->levels = vc->colorspace.levels_out; // hardcoded with conv. matrix
|
||||
|
||||
|
@ -449,8 +449,7 @@ static mp_image_t *get_screenshot(struct vo *vo)
|
||||
struct priv *p = vo->priv;
|
||||
|
||||
struct mp_image img = get_x_buffer(p);
|
||||
struct mp_image *res = alloc_mpi(img.w, img.h, img.imgfmt);
|
||||
copy_mpi(res, &img);
|
||||
struct mp_image *res = mp_image_new_copy(&img);
|
||||
mp_draw_sub_backup_restore(p->osd_backup, res);
|
||||
|
||||
return res;
|
||||
|
@ -406,7 +406,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
|
||||
struct xvctx *ctx = vo->priv;
|
||||
|
||||
struct mp_image xv_buffer = get_xv_buffer(vo, ctx->current_buf);
|
||||
copy_mpi(&xv_buffer, mpi);
|
||||
mp_image_copy(&xv_buffer, mpi);
|
||||
|
||||
mp_draw_sub_backup_reset(ctx->osd_backup);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ static void to_gbrp(struct mp_image *dst, struct mp_image *src,
|
||||
case IMGFMT_ARGB: SET_COMPS(comp, 1, 2, 3, 0); break;
|
||||
case IMGFMT_RGBA: SET_COMPS(comp, 0, 1, 2, 3); break;
|
||||
default:
|
||||
temp = alloc_mpi(dst->w, dst->h, IMGFMT_RGBA);
|
||||
temp = mp_image_alloc(IMGFMT_RGBA, dst->w, dst->h);
|
||||
mp_image_swscale(temp, src, my_sws_flags);
|
||||
src = temp;
|
||||
SET_COMPS(comp, 0, 1, 2, 3);
|
||||
|
Loading…
Reference in New Issue
Block a user