From patchwork Wed Sep 28 10:48:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38437 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp121923pzh; Wed, 28 Sep 2022 03:49:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/wLFZmulTgcAlMwB9jt1zyXv4cKtOLzalfEclw8TRihNHXCXFpit0EcdhAdWxtHW3YfgZ X-Received: by 2002:a05:6402:33c5:b0:447:e4a3:c930 with SMTP id a5-20020a05640233c500b00447e4a3c930mr32650112edc.401.1664362196587; Wed, 28 Sep 2022 03:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664362196; cv=none; d=google.com; s=arc-20160816; b=juXnkpjzweJWiVUzQIVFQm0B3NESXTpsMOzMae1l1SYW2hz2xCBIYMLCSWK5nmHo85 FdbnPFnOTLVxItjWBAUigT0Vnd/ub8qXZgCx7zJuCzD9FwCrxN0zyUPD7k0w7Kf5TUBh 0rw48mqFpsiRa7MsHcl2vnqvPC82Pm6JD8QttL31rIIMBJH+oEvTPMJBEKnPvWpnB58O 9CMBvhYDmuNrOWmWEoYHo/szDp/iRlQ8f/R5uAlJuDMVMx0YP7POO/zVX5u+dlpszPZ4 C14N59/VGuLgT/irVL89k7JCRhgJtfTswGxL4pOYuzBDr+OD2yI23qKsy+LsC4ugz6Fx ssLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=LajfefaK52L4OcG6HZ3FA/vz40ax56U7Ayz9ZAJp2Nw=; b=nkDd03Kr8uQNmZtacNngwFTT/e7KuffQldO0TYPYQVkhlE/Es14UQjaThxR0XbexoY Ja89qH+uYf/Mt8isHYPutk0rn+PRc10j5pgd76ocQGfTVY9NKtydeEs2cEEtXfc4AcQV YdA02MThahV8twTOjysXfctykBbQMosi9vhw8CV5UVZ9Qg0hxQ5DE4dSYAXPelh1g6/L gsF/2Ia8worIaV6L4GukAQBFhZhQQ2+H0uMnGV78ePAWDXRD+Ch02ylAnVK4xMTQLDWS bw15JE2Rt7i0F7EyllX7HrcLHGmKLqWVsiH5pcasv+9vKEGeSm7un9rrzqB6ybwveAXD NCUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sb35-20020a1709076da300b00741559ff58dsi4409455ejc.787.2022.09.28.03.49.56; Wed, 28 Sep 2022 03:49:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F312568BBDD; Wed, 28 Sep 2022 13:49:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 465D568BA2F for ; Wed, 28 Sep 2022 13:49:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D03F72404F5 for ; Wed, 28 Sep 2022 12:49:00 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id FdI7RuH15kA1 for ; Wed, 28 Sep 2022 12:49:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id C4FBA240183 for ; Wed, 28 Sep 2022 12:48:57 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9A2193A0520 for ; Wed, 28 Sep 2022 12:48:57 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 12:48:50 +0200 Message-Id: <20220928104854.18629-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220928104854.18629-1-anton@khirnov.net> References: <20220928104854.18629-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] lavu: replace av_fast_realloc() with av_realloc_reuse() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: V40yHhHpAh9S --- libavutil/hwcontext_vulkan.c | 6 +++--- libavutil/tx.c | 6 +++--- libavutil/vulkan.c | 40 ++++++++++++++++++------------------ libavutil/vulkan.h | 18 ++++++++-------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index f1db1c7291..907f3ecc77 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -65,7 +65,7 @@ typedef struct VulkanQueueCtx { /* Buffer dependencies */ AVBufferRef **buf_deps; int nb_buf_deps; - int buf_deps_alloc_size; + size_t buf_deps_alloc_size; } VulkanQueueCtx; typedef struct VulkanExecCtx { @@ -1226,8 +1226,8 @@ static int add_buf_dep_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd, if (!deps || !nb_deps) return 0; - dst = av_fast_realloc(q->buf_deps, &q->buf_deps_alloc_size, - (q->nb_buf_deps + nb_deps) * sizeof(*dst)); + dst = av_realloc_reuse(q->buf_deps, &q->buf_deps_alloc_size, + (q->nb_buf_deps + nb_deps) * sizeof(*dst)); if (!dst) goto err; diff --git a/libavutil/tx.c b/libavutil/tx.c index 0c16ecffc3..2ea56a732b 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -443,7 +443,7 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, int ret = 0; AVTXContext *sub = NULL; TXCodeletMatch *cd_tmp, *cd_matches = NULL; - unsigned int cd_matches_size = 0; + size_t cd_matches_size = 0; int nb_cd_matches = 0; #if !CONFIG_SMALL AVBPrint bp = { 0 }; @@ -533,8 +533,8 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, continue; /* Realloc array and append */ - cd_tmp = av_fast_realloc(cd_matches, &cd_matches_size, - sizeof(*cd_tmp) * (nb_cd_matches + 1)); + cd_tmp = av_realloc_reuse(cd_matches, &cd_matches_size, + sizeof(*cd_tmp) * (nb_cd_matches + 1)); if (!cd_tmp) { av_free(cd_matches); return AVERROR(ENOMEM); diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 403f0b1f27..d70bc2e2af 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -284,8 +284,8 @@ int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer *buf, uint8_t *mem[], }; if (buf[i].flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) continue; - inval_list = av_fast_realloc(s->scratch, &s->scratch_size, - (++inval_count)*sizeof(*inval_list)); + inval_list = av_realloc_reuse(s->scratch, &s->scratch_size, + (++inval_count)*sizeof(*inval_list)); if (!inval_list) return AVERROR(ENOMEM); inval_list[inval_count - 1] = ival_buf; @@ -322,8 +322,8 @@ int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer *buf, int nb_buffers, }; if (buf[i].flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) continue; - flush_list = av_fast_realloc(s->scratch, &s->scratch_size, - (++flush_count)*sizeof(*flush_list)); + flush_list = av_realloc_reuse(s->scratch, &s->scratch_size, + (++flush_count)*sizeof(*flush_list)); if (!flush_list) return AVERROR(ENOMEM); flush_list[flush_count - 1] = flush_buf; @@ -516,43 +516,43 @@ int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, int planes = av_pix_fmt_count_planes(fc->sw_format); for (int i = 0; i < planes; i++) { - e->sem_wait = av_fast_realloc(e->sem_wait, &e->sem_wait_alloc, - (e->sem_wait_cnt + 1)*sizeof(*e->sem_wait)); + e->sem_wait = av_realloc_reuse(e->sem_wait, &e->sem_wait_alloc, + (e->sem_wait_cnt + 1)*sizeof(*e->sem_wait)); if (!e->sem_wait) { ff_vk_discard_exec_deps(e); return AVERROR(ENOMEM); } - e->sem_wait_dst = av_fast_realloc(e->sem_wait_dst, &e->sem_wait_dst_alloc, - (e->sem_wait_cnt + 1)*sizeof(*e->sem_wait_dst)); + e->sem_wait_dst = av_realloc_reuse(e->sem_wait_dst, &e->sem_wait_dst_alloc, + (e->sem_wait_cnt + 1)*sizeof(*e->sem_wait_dst)); if (!e->sem_wait_dst) { ff_vk_discard_exec_deps(e); return AVERROR(ENOMEM); } - e->sem_wait_val = av_fast_realloc(e->sem_wait_val, &e->sem_wait_val_alloc, - (e->sem_wait_cnt + 1)*sizeof(*e->sem_wait_val)); + e->sem_wait_val = av_realloc_reuse(e->sem_wait_val, &e->sem_wait_val_alloc, + (e->sem_wait_cnt + 1)*sizeof(*e->sem_wait_val)); if (!e->sem_wait_val) { ff_vk_discard_exec_deps(e); return AVERROR(ENOMEM); } - e->sem_sig = av_fast_realloc(e->sem_sig, &e->sem_sig_alloc, - (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig)); + e->sem_sig = av_realloc_reuse(e->sem_sig, &e->sem_sig_alloc, + (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig)); if (!e->sem_sig) { ff_vk_discard_exec_deps(e); return AVERROR(ENOMEM); } - e->sem_sig_val = av_fast_realloc(e->sem_sig_val, &e->sem_sig_val_alloc, - (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig_val)); + e->sem_sig_val = av_realloc_reuse(e->sem_sig_val, &e->sem_sig_val_alloc, + (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig_val)); if (!e->sem_sig_val) { ff_vk_discard_exec_deps(e); return AVERROR(ENOMEM); } - e->sem_sig_val_dst = av_fast_realloc(e->sem_sig_val_dst, &e->sem_sig_val_dst_alloc, - (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig_val_dst)); + e->sem_sig_val_dst = av_realloc_reuse(e->sem_sig_val_dst, &e->sem_sig_val_dst_alloc, + (e->sem_sig_cnt + 1)*sizeof(*e->sem_sig_val_dst)); if (!e->sem_sig_val_dst) { ff_vk_discard_exec_deps(e); return AVERROR(ENOMEM); @@ -569,8 +569,8 @@ int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, e->sem_sig_cnt++; } - dst = av_fast_realloc(q->frame_deps, &q->frame_deps_alloc_size, - (q->nb_frame_deps + 1) * sizeof(*dst)); + dst = av_realloc_reuse(q->frame_deps, &q->frame_deps_alloc_size, + (q->nb_frame_deps + 1) * sizeof(*dst)); if (!dst) { ff_vk_discard_exec_deps(e); return AVERROR(ENOMEM); @@ -645,8 +645,8 @@ int ff_vk_add_dep_exec_ctx(FFVulkanContext *s, FFVkExecContext *e, if (!deps || !nb_deps) return 0; - dst = av_fast_realloc(q->buf_deps, &q->buf_deps_alloc_size, - (q->nb_buf_deps + nb_deps) * sizeof(*dst)); + dst = av_realloc_reuse(q->buf_deps, &q->buf_deps_alloc_size, + (q->nb_buf_deps + nb_deps) * sizeof(*dst)); if (!dst) goto err; diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index d1ea1e24fb..ae5ae551f2 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -143,12 +143,12 @@ typedef struct FFVkQueueCtx { /* Buffer dependencies */ AVBufferRef **buf_deps; int nb_buf_deps; - int buf_deps_alloc_size; + size_t buf_deps_alloc_size; /* Frame dependencies */ AVFrame **frame_deps; int nb_frame_deps; - int frame_deps_alloc_size; + size_t frame_deps_alloc_size; } FFVkQueueCtx; typedef struct FFVkExecContext { @@ -165,24 +165,24 @@ typedef struct FFVkExecContext { FFVulkanPipeline *bound_pl; VkSemaphore *sem_wait; - int sem_wait_alloc; /* Allocated sem_wait */ + size_t sem_wait_alloc; /* Allocated sem_wait */ int sem_wait_cnt; uint64_t *sem_wait_val; - int sem_wait_val_alloc; + size_t sem_wait_val_alloc; VkPipelineStageFlagBits *sem_wait_dst; - int sem_wait_dst_alloc; /* Allocated sem_wait_dst */ + size_t sem_wait_dst_alloc; /* Allocated sem_wait_dst */ VkSemaphore *sem_sig; - int sem_sig_alloc; /* Allocated sem_sig */ + size_t sem_sig_alloc; /* Allocated sem_sig */ int sem_sig_cnt; uint64_t *sem_sig_val; - int sem_sig_val_alloc; + size_t sem_sig_val_alloc; uint64_t **sem_sig_val_dst; - int sem_sig_val_dst_alloc; + size_t sem_sig_val_dst_alloc; } FFVkExecContext; typedef struct FFVulkanContext { @@ -222,7 +222,7 @@ typedef struct FFVulkanContext { int pipelines_num; void *scratch; /* Scratch memory used only in functions */ - unsigned int scratch_size; + size_t scratch_size; } FFVulkanContext; /* Identity mapping - r = r, b = b, g = g, a = a */