From c1efa9ac4b6ccac1be9bc649e503a2c3056c6df4 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 10 Nov 2022 19:38:03 +0900 Subject: [PATCH] cudaupload,cudadownload: Add support for planar 8bits RGB formats Defines RGBP, BGRP, and GBR formats, which have the same memory layout as already supported Y444. And defines GBRA format as well which needs just one additional alpha plane Part-of: --- .../gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c | 19 +++++++++++++++++++ .../gst-plugins-bad/sys/nvcodec/gstcudaformat.h | 4 ++-- 2 files changed, 21 insertions(+), 2 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 7818827..50ff67b 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudamemory.c @@ -168,6 +168,9 @@ gst_cuda_allocator_alloc_internal (GstCudaAllocator * self, break; case GST_VIDEO_FORMAT_Y444: case GST_VIDEO_FORMAT_Y444_16LE: + case GST_VIDEO_FORMAT_RGBP: + case GST_VIDEO_FORMAT_BGRP: + case GST_VIDEO_FORMAT_GBR: alloc_info->stride[0] = pitch; alloc_info->stride[1] = pitch; alloc_info->stride[2] = pitch; @@ -175,6 +178,16 @@ gst_cuda_allocator_alloc_internal (GstCudaAllocator * self, alloc_info->offset[1] = alloc_info->stride[0] * height; alloc_info->offset[2] = alloc_info->offset[1] * 2; break; + case GST_VIDEO_FORMAT_GBRA: + alloc_info->stride[0] = pitch; + alloc_info->stride[1] = pitch; + alloc_info->stride[2] = pitch; + alloc_info->stride[3] = pitch; + alloc_info->offset[0] = 0; + alloc_info->offset[1] = alloc_info->stride[0] * height; + alloc_info->offset[2] = alloc_info->offset[1] * 2; + alloc_info->offset[3] = alloc_info->offset[1] * 3; + break; case GST_VIDEO_FORMAT_BGRA: case GST_VIDEO_FORMAT_RGBA: case GST_VIDEO_FORMAT_RGBx: @@ -516,8 +529,14 @@ gst_cuda_allocator_alloc (GstCudaAllocator * allocator, case GST_VIDEO_FORMAT_I422_12LE: case GST_VIDEO_FORMAT_Y444: case GST_VIDEO_FORMAT_Y444_16LE: + case GST_VIDEO_FORMAT_RGBP: + case GST_VIDEO_FORMAT_BGRP: + case GST_VIDEO_FORMAT_GBR: alloc_height *= 3; break; + case GST_VIDEO_FORMAT_GBRA: + alloc_height *= 4; + break; default: break; } diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h index 5f756af..2a29657 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaformat.h @@ -26,12 +26,12 @@ 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, YUY2, UYVY }" + "Y42B, I422_10LE, I422_12LE, YUY2, UYVY, RGBP, BGRP, GBR, GBRA }" #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, " \ - "YUY2, UYVY }" + "YUY2, UYVY, RGBP, BGRP, GBR, GBRA }" #define GST_CUDA_D3D11_FORMATS \ "{ I420, YV12, I420_10LE, Y444, Y444_16LE, " \ -- 2.7.4