summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-05-01 00:55:13 +0200
committerwm4 <wm4@nowhere>2020-05-01 00:59:57 +0200
commit008faa3d7fd62c9e8af00281a04ed76db1b41391 (patch)
tree743eb383362e47200d7fd142b6d7470e8ce562db /video
parent4f0206ab045e65798eef7e6e1efe0d862fe7b7f7 (diff)
downloadmpv-008faa3d7fd62c9e8af00281a04ed76db1b41391.tar.bz2
mpv-008faa3d7fd62c9e8af00281a04ed76db1b41391.tar.xz
zimg: remove C11 aligned_alloc() requirement
It's not available on Windows because MinGW is fucking horrible and Microsoft are fucking assholes.
Diffstat (limited to 'video')
-rw-r--r--video/zimg.c14
-rw-r--r--video/zimg.h1
2 files changed, 10 insertions, 5 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;
};