From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 875EF4497F for ; Wed, 28 Sep 2022 10:49:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BA08A68BC8F; Wed, 28 Sep 2022 13:49:12 +0300 (EEST) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- 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 */ -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".