Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/6] lavu: replace av_fast_realloc() with av_realloc_reuse()
Date: Wed, 28 Sep 2022 12:48:50 +0200
Message-ID: <20220928104854.18629-2-anton@khirnov.net> (raw)
In-Reply-To: <20220928104854.18629-1-anton@khirnov.net>

---
 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".

  reply	other threads:[~2022-09-28 10:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28 10:48 [FFmpeg-devel] [PATCH 1/6] lavu/mem: add av_realloc_reuse() as a replacement for av_fast_realloc() Anton Khirnov
2022-09-28 10:48 ` Anton Khirnov [this message]
2022-09-28 10:48 ` [FFmpeg-devel] [PATCH 3/6] lavc: replace av_fast_realloc() with av_realloc_reuse() Anton Khirnov
2022-09-28 10:48 ` [FFmpeg-devel] [PATCH 4/6] lavfi: " Anton Khirnov
2022-09-28 10:48 ` [FFmpeg-devel] [PATCH 5/6] lavf: " Anton Khirnov
2022-09-28 10:48 ` [FFmpeg-devel] [PATCH 6/6] sws: " Anton Khirnov
2022-09-28 10:51 ` [FFmpeg-devel] [PATCH 1/6] lavu/mem: add av_realloc_reuse() as a replacement for av_fast_realloc() Rémi Denis-Courmont
2022-09-28 10:55   ` Rémi Denis-Courmont
2022-09-28 11:48 ` Tomas Härdin
2022-09-28 15:04   ` Anton Khirnov
2022-09-28 15:33   ` Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220928104854.18629-2-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git