From 008faa3d7fd62c9e8af00281a04ed76db1b41391 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 May 2020 00:55:13 +0200 Subject: zimg: remove C11 aligned_alloc() requirement It's not available on Windows because MinGW is fucking horrible and Microsoft are fucking assholes. --- video/zimg.c | 14 +++++++++----- video/zimg.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/zimg.c b/video/zimg.c index b478ccbd1d..22f1a1a1b1 100644 --- a/video/zimg.c +++ b/video/zimg.c @@ -204,8 +204,8 @@ static zimg_color_primaries_e mp_to_z_prim(enum mp_csp_prim prim) static void destroy_zimg(struct mp_zimg_context *ctx) { - free(ctx->zimg_tmp); - ctx->zimg_tmp = NULL; + talloc_free(ctx->zimg_tmp_alloc); + ctx->zimg_tmp = ctx->zimg_tmp_alloc = NULL; zimg_filter_graph_free(ctx->zimg_graph); ctx->zimg_graph = NULL; TA_FREEP(&ctx->zimg_src); @@ -1334,11 +1334,15 @@ bool mp_zimg_config(struct mp_zimg_context *ctx) size_t tmp_size; if (!zimg_filter_graph_get_tmp_size(ctx->zimg_graph, &tmp_size)) { - tmp_size = MP_ALIGN_UP(tmp_size, ZIMG_ALIGN); - ctx->zimg_tmp = aligned_alloc(ZIMG_ALIGN, tmp_size); + tmp_size = MP_ALIGN_UP(tmp_size, ZIMG_ALIGN) + ZIMG_ALIGN; + ctx->zimg_tmp_alloc = ta_alloc_size(NULL, tmp_size); + if (ctx->zimg_tmp_alloc) { + ctx->zimg_tmp = + (void *)MP_ALIGN_UP((uintptr_t)ctx->zimg_tmp_alloc, ZIMG_ALIGN); + } } - if (!ctx->zimg_tmp) + if (!ctx->zimg_tmp_alloc) goto fail; if (!allocate_buffer(ctx, ctx->zimg_src) || diff --git a/video/zimg.h b/video/zimg.h index 0ef9c5a3a0..ef2aeaa112 100644 --- a/video/zimg.h +++ b/video/zimg.h @@ -40,6 +40,7 @@ struct mp_zimg_context { struct m_config_cache *opts_cache; zimg_filter_graph *zimg_graph; void *zimg_tmp; + void *zimg_tmp_alloc; struct mp_zimg_repack *zimg_src; struct mp_zimg_repack *zimg_dst; }; -- cgit v1.2.3