From ce82c0570ef2a007d7f996fbd36e7f9396bd7460 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 30 Jun 2022 16:45:46 +0900 Subject: [PATCH] cuda: Add YUY2 and UYVY formats for GL interop Those formats are not supported conversion formats by CUDA convert/scale elements but would be useful for GL <-> CUDA interop use case. Part-of: --- .../gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c | 2 ++ .../gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c | 8 ++++++-- subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c index 3cddb30fb3..78188275e9 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c @@ -185,6 +185,8 @@ gst_cuda_allocator_alloc_internal (GstCudaAllocator * self, case GST_VIDEO_FORMAT_BGR: case GST_VIDEO_FORMAT_BGR10A2_LE: case GST_VIDEO_FORMAT_RGB10A2_LE: + case GST_VIDEO_FORMAT_YUY2: + case GST_VIDEO_FORMAT_UYVY: alloc_info->stride[0] = pitch; alloc_info->offset[0] = 0; break; diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c index a0c1dfaeaa..4d7ef7861b 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudabasefilter.c @@ -40,18 +40,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_cuda_base_filter_debug); #define GST_CAT_DEFAULT gst_cuda_base_filter_debug +#define GST_CUDA_FILTER_FORMATS \ + "{ I420, YV12, NV12, NV21, P010_10LE, P016_LE, I420_10LE, Y444, Y444_16LE, " \ + "BGRA, RGBA, RGBx, BGRx, ARGB, ABGR, RGB, BGR, BGR10A2_LE, RGB10A2_LE, Y42B, I422_10LE, I422_12LE }" + static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES - (GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY, GST_CUDA_FORMATS)) + (GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY, GST_CUDA_FILTER_FORMATS)) ); static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES - (GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY, GST_CUDA_FORMATS)) + (GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY, GST_CUDA_FILTER_FORMATS)) ); #define gst_cuda_base_filter_parent_class parent_class diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h index 8c6096720e..5f756af1ff 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h @@ -25,11 +25,13 @@ G_BEGIN_DECLS #define GST_CUDA_FORMATS \ "{ I420, YV12, NV12, NV21, P010_10LE, P016_LE, I420_10LE, Y444, Y444_16LE, " \ - "BGRA, RGBA, RGBx, BGRx, ARGB, ABGR, RGB, BGR, BGR10A2_LE, RGB10A2_LE, Y42B, I422_10LE, I422_12LE }" + "BGRA, RGBA, RGBx, BGRx, ARGB, ABGR, RGB, BGR, BGR10A2_LE, RGB10A2_LE, " \ + "Y42B, I422_10LE, I422_12LE, YUY2, UYVY }" #define GST_CUDA_GL_FORMATS \ "{ I420, YV12, NV12, NV21, P010_10LE, P016_LE, Y444, " \ - "BGRA, RGBA, RGBx, BGRx, ARGB, ABGR, RGB, BGR, BGR10A2_LE, RGB10A2_LE }" + "BGRA, RGBA, RGBx, BGRx, ARGB, ABGR, RGB, BGR, BGR10A2_LE, RGB10A2_LE, " \ + "YUY2, UYVY }" #define GST_CUDA_D3D11_FORMATS \ "{ I420, YV12, I420_10LE, Y444, Y444_16LE, " \