Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] Allow exporting of RGB and BGR images to CUDA.
@ 2022-07-08 21:51 dpeeters
  2022-07-28 16:23 ` dpeeters
  0 siblings, 1 reply; 3+ messages in thread
From: dpeeters @ 2022-07-08 21:51 UTC (permalink / raw)
  To: ffmpeg-devel

Use the step size when calculating the number of channels to allow for more than two channels per plane.  This allows the use of AV_PIX_FMT_0BGR32 when using av_hwframe_transfer_data to transfer data from a Vulkan frame to a CUDA frame.

Signed-off-by: David Peeters <dpeeters@MRU.MEDICAL.CANON>
---
 libavutil/hwcontext_vulkan.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 237caa4bc0..05e8fc5268 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2992,6 +2992,8 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc,
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format);
     VulkanDevicePriv *p = ctx->internal->priv;
     FFVulkanFunctions *vk = &p->vkfn;
+    int max_pixsteps[4];
+    int max_pixstep_comps[4];
 
     AVHWFramesContext *cuda_fc = (AVHWFramesContext*)cuda_hwfc->data;
     AVHWDeviceContext *cuda_cu = cuda_fc->device_ctx;
@@ -3001,6 +3003,8 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc,
     CUarray_format cufmt = desc->comp[0].depth > 8 ? CU_AD_FORMAT_UNSIGNED_INT16 :
                                                      CU_AD_FORMAT_UNSIGNED_INT8;
 
+    av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, desc);
+
     dst_f = (AVVkFrame *)frame->data[0];
 
     dst_int = dst_f->internal;
@@ -3023,7 +3027,9 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc,
                 .arrayDesc = {
                     .Depth = 0,
                     .Format = cufmt,
-                    .NumChannels = 1 + ((planes == 2) && i),
+                    .NumChannels = desc->comp[max_pixstep_comps[i]].depth > 8
+                        ? max_pixsteps[i] / 2
+                        : max_pixsteps[i],
                     .Flags = 0,
                 },
                 .numLevels = 1,
-- 
2.36.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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-23 20:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 21:51 [FFmpeg-devel] [PATCH] Allow exporting of RGB and BGR images to CUDA dpeeters
2022-07-28 16:23 ` dpeeters
2022-08-23 20:40   ` dpeeters

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