cuda: Add convertscale element

GstCudaConverter object can do colorspace conversion and scale at once.
Adding new element "cudaconvertscale" to do that, this can
save unnecessary GPU operation if colorspace conversion and
rescale is required for given input stream format.

Most of codes are taken from d3d11convert element

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3389>
This commit is contained in:
Seungha Yang 2022-11-09 21:31:01 +09:00 committed by GStreamer Marge Bot
parent 30841dae99
commit eb2ef5a4fd
5 changed files with 1497 additions and 16 deletions

View file

@ -51,6 +51,8 @@ struct _GstCudaBaseFilterClass
GType gst_cuda_base_filter_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstCudaBaseFilter, gst_object_unref)
G_END_DECLS
#endif /* __GST_CUDA_BASE_FILTER_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,50 @@
/* GStreamer
* Copyright (C) 2022 Seungha Yang <seungha@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <gst/gst.h>
#include "gstcudabasetransform.h"
G_BEGIN_DECLS
#define GST_TYPE_CUDA_BASE_CONVERT (gst_cuda_base_convert_get_type())
#define GST_CUDA_BASE_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CUDA_BASE_CONVERT,GstCudaBaseConvert))
#define GST_CUDA_BASE_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CUDA_BASE_CONVERT,GstCudaBaseConvertClass))
#define GST_CUDA_BASE_CONVERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_CUDA_BASE_CONVERT,GstCudaBaseConvertClass))
#define GST_IS_CUDA_BASE_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CUDA_BASE_CONVERT))
#define GST_IS_CUDA_BASE_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_CUDA_BASE_CONVERT))
typedef struct _GstCudaBaseConvert GstCudaBaseConvert;
typedef struct _GstCudaBaseConvertClass GstCudaBaseConvertClass;
struct _GstCudaBaseConvertClass
{
GstCudaBaseTransform parent_class;
};
GType gst_cuda_base_convert_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstCudaBaseConvert, gst_object_unref)
#define GST_TYPE_CUDA_CONVERT_SCALE (gst_cuda_convert_scale_get_type())
G_DECLARE_FINAL_TYPE (GstCudaConvertScale, gst_cuda_convert_scale,
GST, CUDA_CONVERT_SCALE, GstCudaBaseConvert)
G_END_DECLS

View file

@ -27,6 +27,7 @@
#include "gstcudafilter.h"
#include "gstcudaconvert.h"
#include "gstcudascale.h"
#include "gstcudaconvertscale.h"
/* *INDENT-OFF* */
const gchar *nvrtc_test_source =
@ -53,4 +54,6 @@ gst_cuda_filter_plugin_init (GstPlugin * plugin)
GST_TYPE_CUDA_CONVERT);
gst_element_register (plugin, "cudascale", GST_RANK_NONE,
GST_TYPE_CUDA_SCALE);
gst_element_register (plugin, "cudaconvertscale", GST_RANK_NONE,
GST_TYPE_CUDA_CONVERT_SCALE);
}

View file

@ -1,27 +1,28 @@
nvcodec_sources = [
'plugin.c',
'gstnvenc.c',
'gstnvbaseenc.c',
'gstnvh264enc.c',
'gstnvh265enc.c',
'gstnvdec.c',
'cuda-converter.c',
'gstcudabasefilter.c',
'gstcudabasetransform.c',
'gstcudaconvert.c',
'gstcudaconvertscale.c',
'gstcudafilter.c',
'gstcudamemorycopy.c',
'gstcudascale.c',
'gstcuvidloader.c',
'gstnvav1dec.c',
'gstnvbaseenc.c',
'gstnvdec.c',
'gstnvdecoder.c',
'gstnvenc.c',
'gstnvencoder.cpp',
'gstnvh264enc.c',
'gstnvh264encoder.cpp',
'gstnvh265enc.c',
'gstnvh265encoder.cpp',
'gstnvh264dec.c',
'gstnvh265dec.c',
'gstcudabasetransform.c',
'gstcudamemorycopy.c',
'cuda-converter.c',
'gstcudafilter.c',
'gstcudabasefilter.c',
'gstcudaconvert.c',
'gstcudascale.c',
'gstnvvp8dec.c',
'gstnvvp9dec.c',
'gstnvencoder.cpp',
'gstnvh264encoder.cpp',
'gstnvh265encoder.cpp',
'plugin.c',
]
nvmm_sources = [