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 + wscript | 6 ------ 3 files changed, 10 insertions(+), 11 deletions(-) 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; }; diff --git a/wscript b/wscript index eb68ab1f5d..2ef1c6b7da 100644 --- a/wscript +++ b/wscript @@ -223,11 +223,6 @@ main_dependencies = [ 'atomic_fetch_add(&test, 1)')), 'req': True, 'fmsg': 'C11 atomics are required; you may need a newer compiler', - }, { - # C11; technically we require C11, but aligned_alloc() is not in MinGW - 'name': 'aligned_alloc', - 'desc': 'C11 aligned_alloc()', - 'func': check_statement('stdlib.h', 'aligned_alloc(1, 1)'), }, { 'name': 'librt', 'desc': 'linking with -lrt', @@ -379,7 +374,6 @@ iconv support use --disable-iconv.", 'func': check_pkg_config('rubberband', '>= 1.8.0'), }, { 'name': '--zimg', - 'deps': 'aligned_alloc', 'desc': 'libzimg support (high quality software scaler)', 'func': check_pkg_config('zimg', '>= 2.9'), }, { -- cgit v1.2.3