[FFmpeg-cvslog] hwcontext_vulkan: fix uploading and downloading from/to flipped images

Lynne git at videolan.org
Tue May 26 14:04:11 EEST 2020


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Tue May 26 12:01:54 2020 +0100| [64b12624e2d36beda90a4725e3ee43d7d0723213] | committer: Lynne

hwcontext_vulkan: fix uploading and downloading from/to flipped images

We want to copy the lowest amount of bytes per line, but while the buffer
stride is sanitized, the src/dst stride can be negative, and negative numbers
of bytes do not make a lot of sense.

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

 libavutil/hwcontext_vulkan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 8066b8536a..5e51d0390f 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -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)))
@@ -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);



More information about the ffmpeg-cvslog mailing list