]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/hwcontext_vulkan.c
lavfi/lavfutils: switch to the new decoding API
[ffmpeg] / libavutil / hwcontext_vulkan.c
index 8066b8536a1b561224a2075b002a9a9b226b018d..a98ea916e7710716f9af902dc23251be7f35cca5 100644 (file)
@@ -3025,7 +3025,8 @@ static int vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst,
     for (int i = 0; i < planes; i++) {
         int h = src->height;
         int p_height = i > 0 ? AV_CEIL_RSHIFT(h, log2_chroma) : h;
-        size_t p_size = FFABS(src->linesize[i]) * p_height;
+        size_t p_size = FFALIGN(FFABS(src->linesize[i]) * p_height,
+                                p->hprops.minImportedHostPointerAlignment);
 
         VkImportMemoryHostPointerInfoEXT import_desc = {
             .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT,
@@ -3036,7 +3037,6 @@ static int vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst,
         /* We can only map images with positive stride and alignment appropriate
          * for the device. */
         host_mapped[i] = map_host && src->linesize[i] > 0 &&
-                         !(p_size % p->hprops.minImportedHostPointerAlignment) &&
                          !(((uintptr_t)import_desc.pHostPointer) %
                            p->hprops.minImportedHostPointerAlignment);
         p_size = host_mapped[i] ? p_size : 0;
@@ -3063,7 +3063,8 @@ static int vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst,
 
         av_image_copy_plane(tmp.data[i], tmp.linesize[i],
                             (const uint8_t *)src->data[i], src->linesize[i],
-                            FFMIN(tmp.linesize[i], src->linesize[i]), p_height);
+                            FFMIN(tmp.linesize[i], FFABS(src->linesize[i])),
+                            p_height);
     }
 
     if ((err = unmap_buffers(dev_ctx, bufs, planes, 1)))
@@ -3208,7 +3209,8 @@ static int vulkan_transfer_data_to_mem(AVHWFramesContext *hwfc, AVFrame *dst,
     for (int i = 0; i < planes; i++) {
         int h = dst->height;
         int p_height = i > 0 ? AV_CEIL_RSHIFT(h, log2_chroma) : h;
-        size_t p_size = FFABS(dst->linesize[i]) * p_height;
+        size_t p_size = FFALIGN(FFABS(dst->linesize[i]) * p_height,
+                                p->hprops.minImportedHostPointerAlignment);
 
         VkImportMemoryHostPointerInfoEXT import_desc = {
             .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT,
@@ -3219,7 +3221,6 @@ static int vulkan_transfer_data_to_mem(AVHWFramesContext *hwfc, AVFrame *dst,
         /* We can only map images with positive stride and alignment appropriate
          * for the device. */
         host_mapped[i] = map_host && dst->linesize[i] > 0 &&
-                         !(p_size % p->hprops.minImportedHostPointerAlignment) &&
                          !(((uintptr_t)import_desc.pHostPointer) %
                            p->hprops.minImportedHostPointerAlignment);
         p_size = host_mapped[i] ? p_size : 0;
@@ -3251,7 +3252,8 @@ static int vulkan_transfer_data_to_mem(AVHWFramesContext *hwfc, AVFrame *dst,
 
         av_image_copy_plane(dst->data[i], dst->linesize[i],
                             (const uint8_t *)tmp.data[i], tmp.linesize[i],
-                            FFMIN(tmp.linesize[i], dst->linesize[i]), p_height);
+                            FFMIN(tmp.linesize[i], FFABS(dst->linesize[i])),
+                            p_height);
     }
 
     err = unmap_buffers(dev_ctx, bufs, planes, 0);