svtav1enc: Use G_DECLARE_FINAL_TYPE and GST_ELEMENT_REGISTER_DEFINE

This commit is contained in:
Sebastian Dröge 2023-02-03 21:33:17 +02:00
parent aca2bad25c
commit a0ccb6b558
2 changed files with 37 additions and 39 deletions

View file

@ -53,6 +53,36 @@ gst_svtav1enc_intra_refresh_type_get_type (void)
return intra_refresh_type;
}
typedef struct _GstSvtAv1Enc
{
GstVideoEncoder video_encoder;
/* SVT-AV1 Encoder Handle */
EbComponentType *svt_encoder;
/* GStreamer Codec state */
GstVideoCodecState *state;
/* SVT-AV1 configuration */
EbSvtAv1EncConfiguration *svt_config;
/* Property values */
guint preset;
guint target_bitrate;
guint max_bitrate;
guint max_qp_allowed;
guint min_qp_allowed;
gint cqp, crf;
guint maximum_buffer_size;
gint intra_period_length;
gint intra_refresh_type;
gint logical_processors;
gint target_socket;
gchar *parameters_string;
EbBufferHeaderType *input_buf;
} GstSvtAv1Enc;
/* prototypes */
static void gst_svtav1enc_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec);
@ -140,6 +170,9 @@ G_DEFINE_TYPE_WITH_CODE (GstSvtAv1Enc, gst_svtav1enc, GST_TYPE_VIDEO_ENCODER,
GST_DEBUG_CATEGORY_INIT (gst_svtav1enc_debug_category, "svtav1enc", 0,
"SVT-AV1 encoder element"));
GST_ELEMENT_REGISTER_DEFINE (svtav1enc, "svtav1enc", GST_RANK_SECONDARY,
gst_svtav1enc_get_type ());
/* this mutex is required to avoid race conditions in SVT-AV1 memory allocations, which aren't thread-safe */
G_LOCK_DEFINE_STATIC (init_mutex);
@ -1074,8 +1107,7 @@ gst_svtav1enc_parse_parameters_string (GstSvtAv1Enc * svtav1enc)
static gboolean
plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "svtav1enc", GST_RANK_SECONDARY,
GST_TYPE_SVTAV1ENC);
return GST_ELEMENT_REGISTER (svtav1enc, plugin);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, svtav1,

View file

@ -15,46 +15,12 @@
#include <EbSvtAv1Enc.h>
G_BEGIN_DECLS
#define GST_TYPE_SVTAV1ENC (gst_svtav1enc_get_type())
#define GST_SVTAV1ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_SVTAV1ENC, GstSvtAv1Enc))
#define GST_SVTAV1ENC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SVTAV1ENC, GstSvtHevcEncClass))
#define GST_IS_SVTAV1ENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_SVTAV1ENC))
#define GST_IS_SVTAV1ENC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SVTAV1ENC))
typedef struct _GstSvtAv1Enc {
GstVideoEncoder video_encoder;
G_DECLARE_FINAL_TYPE (GstSvtAv1Enc, gst_svtav1enc, GST, SVTAV1ENC, GstVideoEncoder);
/* SVT-AV1 Encoder Handle */
EbComponentType *svt_encoder;
/* GStreamer Codec state */
GstVideoCodecState *state;
/* SVT-AV1 configuration */
EbSvtAv1EncConfiguration *svt_config;
/* Property values */
guint preset;
guint target_bitrate;
guint max_bitrate;
guint max_qp_allowed;
guint min_qp_allowed;
gint cqp, crf;
guint maximum_buffer_size;
gint intra_period_length;
gint intra_refresh_type;
gint logical_processors;
gint target_socket;
gchar *parameters_string;
EbBufferHeaderType *input_buf;
} GstSvtAv1Enc;
typedef struct _GstSvtAv1EncClass {
GstVideoEncoderClass video_encoder_class;
} GstSvtAv1EncClass;
GType gst_svtav1enc_get_type(void);
GST_ELEMENT_REGISTER_DECLARE (svtav1enc);
G_END_DECLS
#endif