[FFmpeg-cvslog] vulkan_ffv1: allocate just as much memory for slice state as needed

Lynne git at videolan.org
Mon Apr 14 07:16:10 EEST 2025


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Wed Apr  2 00:03:11 2025 +0000| [1f09b55c943a63c85a92761ccf63a2a99b9d16ea] | committer: Lynne

vulkan_ffv1: allocate just as much memory for slice state as needed

Rather than always using the maximum allowed slices, just use the number
of slices present in this frame.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f09b55c943a63c85a92761ccf63a2a99b9d16ea
---

 libavcodec/vulkan_ffv1.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vulkan_ffv1.c b/libavcodec/vulkan_ffv1.c
index b6c9320ec2..9747721f0d 100644
--- a/libavcodec/vulkan_ffv1.c
+++ b/libavcodec/vulkan_ffv1.c
@@ -197,7 +197,7 @@ static int vk_ffv1_start_frame(AVCodecContext          *avctx,
                                       &fp->slice_state,
                                       VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
                                       VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
-                                      NULL, f->max_slice_count*fp->slice_state_size,
+                                      NULL, f->slice_count*fp->slice_state_size,
                                       VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
         if (err < 0)
             return err;
@@ -213,7 +213,7 @@ static int vk_ffv1_start_frame(AVCodecContext          *avctx,
                                   &fp->tmp_data,
                                   VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
                                   VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
-                                  NULL, f->max_slice_count*CONTEXT_SIZE,
+                                  NULL, f->slice_count*CONTEXT_SIZE,
                                   VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
     if (err < 0)
         return err;
@@ -223,7 +223,7 @@ static int vk_ffv1_start_frame(AVCodecContext          *avctx,
                                   &fp->slice_offset_buf,
                                   VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
                                   VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
-                                  NULL, 2*f->max_slice_count*sizeof(uint32_t),
+                                  NULL, 2*f->slice_count*sizeof(uint32_t),
                                   VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
                                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
     if (err < 0)
@@ -234,7 +234,7 @@ static int vk_ffv1_start_frame(AVCodecContext          *avctx,
                                   &fp->slice_status_buf,
                                   VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
                                   VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
-                                  NULL, f->max_slice_count*sizeof(uint32_t),
+                                  NULL, f->slice_count*sizeof(uint32_t),
                                   VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
                                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
     if (err < 0)



More information about the ffmpeg-cvslog mailing list