d3d11compositor: Performance optimization

Removing glvideomixer-like nuance (it was initially referenced)
and rewriting element since it's not an optimal design at all
from performance point of view.

* Remove wrapper bin (and internal conversion/upload/download elements)
  which will waste CPU/GPU resources. Conversion/blending can be done by the
  d3d11compositor element at once.
* Add support YUV blending without RGB conversion.
  The RGB <-> YUV conversion is completely unnecessary since YUV textures
  support blending as well.
* Remove complicated blending operation properties since it's hard
  to use from application point of view. Instead, adding "operator" property
  like what compositor element does.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2631>
This commit is contained in:
Seungha Yang 2022-06-18 20:14:22 +09:00
parent adcb3ec1f2
commit a040450685
6 changed files with 950 additions and 2202 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
* GStreamer
* Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
* 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
@ -18,8 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_D3D11_COMPOSITOR_H__
#define __GST_D3D11_COMPOSITOR_H__
#pragma once
#include <gst/gst.h>
#include <gst/video/video.h>
@ -36,58 +35,5 @@ G_DECLARE_FINAL_TYPE (GstD3D11CompositorPad, gst_d3d11_compositor_pad,
G_DECLARE_FINAL_TYPE (GstD3D11Compositor, gst_d3d11_compositor,
GST, D3D11_COMPOSITOR, GstVideoAggregator)
typedef enum
{
GST_D3D11_COMPOSITOR_BLEND_OP_ADD,
GST_D3D11_COMPOSITOR_BLEND_OP_SUBTRACT,
GST_D3D11_COMPOSITOR_BLEND_OP_REV_SUBTRACT,
GST_D3D11_COMPOSITOR_BLEND_OP_MIN,
GST_D3D11_COMPOSITOR_BLEND_OP_MAX
} GstD3D11CompositorBlendOperation;
#define GST_TYPE_D3D11_COMPOSITOR_BLEND_OPERATION (gst_d3d11_compositor_blend_operation_get_type())
GType gst_d3d11_compositor_blend_operation_get_type (void);
typedef enum
{
GST_D3D11_COMPOSITOR_BLEND_ZERO,
GST_D3D11_COMPOSITOR_BLEND_ONE,
GST_D3D11_COMPOSITOR_BLEND_SRC_COLOR,
GST_D3D11_COMPOSITOR_BLEND_INV_SRC_COLOR,
GST_D3D11_COMPOSITOR_BLEND_SRC_ALPHA,
GST_D3D11_COMPOSITOR_BLEND_INV_SRC_ALPHA,
GST_D3D11_COMPOSITOR_BLEND_DEST_ALPHA,
GST_D3D11_COMPOSITOR_BLEND_INV_DEST_ALPHA,
GST_D3D11_COMPOSITOR_BLEND_DEST_COLOR,
GST_D3D11_COMPOSITOR_BLEND_INV_DEST_COLOR,
GST_D3D11_COMPOSITOR_BLEND_SRC_ALPHA_SAT,
GST_D3D11_COMPOSITOR_BLEND_BLEND_FACTOR,
GST_D3D11_COMPOSITOR_BLEND_INV_BLEND_FACTOR,
} GstD3D11CompositorBlend;
#define GST_TYPE_D3D11_COMPOSITOR_BLEND (gst_d3d11_compositor_blend_get_type())
GType gst_d3d11_compositor_blend_get_type (void);
typedef enum
{
GST_D3D11_COMPOSITOR_BACKGROUND_CHECKER,
GST_D3D11_COMPOSITOR_BACKGROUND_BLACK,
GST_D3D11_COMPOSITOR_BACKGROUND_WHITE,
GST_D3D11_COMPOSITOR_BACKGROUND_TRANSPARENT,
} GstD3D11CompositorBackground;
#define GST_TYPE_D3D11_COMPOSITOR_BACKGROUND (gst_d3d11_compositor_background_get_type())
GType gst_d3d11_compositor_background_get_type (void);
typedef enum
{
GST_D3D11_COMPOSITOR_SIZING_POLICY_NONE,
GST_D3D11_COMPOSITOR_SIZING_POLICY_KEEP_ASPECT_RATIO,
} GstD3D11CompositorSizingPolicy;
#define GST_TYPE_D3D11_COMPOSITOR_SIZING_POLICY (gst_d3d11_compositor_sizing_policy_get_type())
GType gst_d3d11_compositor_sizing_policy_get_type (void);
G_END_DECLS
#endif /* __GST_D3D11_COMPOSITOR_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,66 +0,0 @@
/*
* GStreamer
* Copyright (C) 2020 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.
*/
#ifndef __GST_D3D11_COMPOSITOR_BIN_H__
#define __GST_D3D11_COMPOSITOR_BIN_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideoaggregator.h>
#include <gst/d3d11/gstd3d11.h>
G_BEGIN_DECLS
#define GST_TYPE_D3D11_COMPOSITOR_BIN_PAD (gst_d3d11_compositor_bin_pad_get_type())
#define GST_D3D11_COMPOSITOR_BIN_PAD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_D3D11_COMPOSITOR_BIN_PAD, GstD3D11CompositorBinPad))
#define GST_D3D11_COMPOSITOR_BIN_PAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_D3D11_COMPOSITOR_BIN_PAD, GstD3D11CompositorBinPadClass))
#define GST_IS_D3D11_COMPOSITOR_BIN_PAD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_D3D11_COMPOSITOR_BIN_PAD))
#define GST_IS_D3D11_COMPOSITOR_BIN_PAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3D11_COMPOSITOR_BIN_PAD))
#define GST_D3D11_COMPOSITOR_BIN_PAD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_D3D11_COMPOSITOR_BIN_PAD,GstD3D11CompositorBinPadClass))
typedef struct _GstD3D11CompositorBinPad GstD3D11CompositorBinPad;
typedef struct _GstD3D11CompositorBinPadClass GstD3D11CompositorBinPadClass;
struct _GstD3D11CompositorBinPadClass
{
GstGhostPadClass parent_class;
void (*set_target) (GstD3D11CompositorBinPad * pad, GstPad * target);
};
GType gst_d3d11_compositor_bin_pad_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstD3D11CompositorBinPad, gst_object_unref)
#define GST_TYPE_D3D11_COMPOSITOR_BIN_INPUT (gst_d3d11_compositor_bin_input_get_type())
G_DECLARE_FINAL_TYPE (GstD3D11CompositorBinInput, gst_d3d11_compositor_bin_input,
GST, D3D11_COMPOSITOR_BIN_INPUT, GstD3D11CompositorBinPad);
#define GST_TYPE_D3D11_COMPOSITOR_BIN (gst_d3d11_compositor_bin_get_type())
G_DECLARE_FINAL_TYPE (GstD3D11CompositorBin, gst_d3d11_compositor_bin,
GST, D3D11_COMPOSITOR_BIN, GstBin)
G_END_DECLS
#endif /* __GST_D3D11_COMPOSITOR_BIN_H__ */

View file

@ -2,7 +2,6 @@ d3d11_sources = [
'gstd3d11av1dec.cpp',
'gstd3d11basefilter.cpp',
'gstd3d11compositor.cpp',
'gstd3d11compositorbin.cpp',
'gstd3d11convert.cpp',
'gstd3d11converter.cpp',
'gstd3d11decoder.cpp',

View file

@ -68,7 +68,6 @@
#include "gstd3d11convert.h"
#include "gstd3d11shader.h"
#include "gstd3d11compositor.h"
#include "gstd3d11compositorbin.h"
#include "gstd3d11h264dec.h"
#include "gstd3d11h265dec.h"
#include "gstd3d11vp9dec.h"
@ -91,7 +90,6 @@ GST_DEBUG_CATEGORY (gst_d3d11_device_debug);
GST_DEBUG_CATEGORY (gst_d3d11_overlay_compositor_debug);
GST_DEBUG_CATEGORY (gst_d3d11_window_debug);
GST_DEBUG_CATEGORY (gst_d3d11_video_processor_debug);
GST_DEBUG_CATEGORY (gst_d3d11_compositor_debug);
GST_DEBUG_CATEGORY (gst_d3d11_decoder_debug);
GST_DEBUG_CATEGORY (gst_d3d11_h264_dec_debug);
GST_DEBUG_CATEGORY (gst_d3d11_h265_dec_debug);
@ -126,8 +124,6 @@ plugin_init (GstPlugin * plugin)
"d3d11window", 0, "d3d11window");
GST_DEBUG_CATEGORY_INIT (gst_d3d11_video_processor_debug,
"d3d11videoprocessor", 0, "d3d11videoprocessor");
GST_DEBUG_CATEGORY_INIT (gst_d3d11_compositor_debug,
"d3d11compositor", 0, "d3d11compositor element");
if (!gst_d3d11_shader_init ()) {
GST_WARNING ("Cannot initialize d3d11 shader");
@ -223,9 +219,7 @@ plugin_init (GstPlugin * plugin)
"d3d11videosink", video_sink_rank, GST_TYPE_D3D11_VIDEO_SINK);
gst_element_register (plugin,
"d3d11compositorelement", GST_RANK_NONE, GST_TYPE_D3D11_COMPOSITOR);
gst_element_register (plugin,
"d3d11compositor", GST_RANK_SECONDARY, GST_TYPE_D3D11_COMPOSITOR_BIN);
"d3d11compositor", GST_RANK_SECONDARY, GST_TYPE_D3D11_COMPOSITOR);
gst_element_register (plugin,
"d3d11testsrc", GST_RANK_NONE, GST_TYPE_D3D11_TEST_SRC);