From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id B9DF3481F2 for ; Tue, 15 Jul 2025 11:45:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 9C0C768E1FC; Tue, 15 Jul 2025 14:45:19 +0300 (EEST) Received: from vidala.pars.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id A96CB68D763 for ; Tue, 15 Jul 2025 14:45:12 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; s=202405r; d=lynne.ee; c=relaxed/relaxed; h=From:To:Subject:Date:Message-ID; t=1752579911; bh=4Mafxqq6dE4h4qaiL9SJHly yMTFYJkyOG6IRuBlyrIk=; b=kZHi/KjSNoDb2RSVUKEtcmu9ILWCrLaW7jx9ZSHWbcKsY9Bc08 V7h+p0jNahFhHIW3asdzSyJBDicTuEagmC26nkAN2QkJZmTB5lFARc8XHwepO7WetFHaXvZh9i7 hChW+aOjOXpvmhV6mNEMU4FuU5xrpBR9gHFz3LXrEzSlc8iEBJZBNsUuWCP1kbNMJ3huQhNpwtB ncyGzh4jdZvTtJpUmzj9LNM7OJ0+9NcOPfCNfW3KlZrYD5MqMp8PvoTSC/pS/oV6cyGCvVbbGwG dddvrouSw2b+qO/Nl76lgHRdBjNLORnb0dsP7t7wT/3ZrsuykW3zqBdRGQspee/LOaA==; DKIM-Signature: v=1; a=ed25519-sha256; s=202405e; d=lynne.ee; c=relaxed/relaxed; h=From:To:Subject:Date:Message-ID; t=1752579911; bh=4Mafxqq6dE4h4qaiL9SJHly yMTFYJkyOG6IRuBlyrIk=; b=v2IlQBlBydlMFlX357GF/zw09eeYEgzKTjGSYrmM+cJFYqgEwA GPa9S8EDNbxp0nthpWsnHbLYgYRk2V3J5mAQ==; Message-ID: Date: Tue, 15 Jul 2025 20:45:09 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20250715105117.78271-1-ffmpeg@haasn.xyz> Content-Language: en-US From: Lynne In-Reply-To: <20250715105117.78271-1-ffmpeg@haasn.xyz> Subject: Re: [FFmpeg-devel] [PATCH] avutil/hwcontext_vulkan: don't over-map buffers with prior padding 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 15/07/2025 19:51, Niklas Haas wrote: > From: Niklas Haas > > If the image data is not at the start of the buffer allocation, such as > when the buffer has padding before the image data, this function maps too > much memory, since src_data + src_buf->size exceeds the buffer size. > > Fix this by subtracting the difference between the buffer start and the > provided image data pointer from the size of the memory range to map. > > An easy way to reproduce this issue is using the vf_pad filter, which > allocates image data buffers with a nonzero offset whenever padding is > requested before the start of the image data. > --- > libavutil/vulkan.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c > index f36f2bb7cf..04cc45ee05 100644 > --- a/libavutil/vulkan.c > +++ b/libavutil/vulkan.c > @@ -1408,7 +1408,8 @@ int ff_vk_host_map_buffer(FFVulkanContext *s, AVBufferRef **dst, > return AVERROR(ENOMEM); > > /* Add the offset at the start, which gets ignored */ > - buffer_size = offs + src_buf->size; > + const ptrdiff_t src_offset = src_data - src_buf->data; > + buffer_size = offs + (src_buf->size - src_offset); > buffer_size = FFALIGN(buffer_size, s->props.properties.limits.minMemoryMapAlignment); > buffer_size = FFALIGN(buffer_size, s->hprops.minImportedHostPointerAlignment); > lgtm _______________________________________________ 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".