mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
plugin: encode: Store the coded caps in type's init data.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
This commit is contained in:
parent
53d5302cde
commit
e260e9cd90
7 changed files with 42 additions and 14 deletions
|
@ -44,7 +44,15 @@ G_BEGIN_DECLS
|
||||||
#define GST_IS_VAAPIENCODE_CLASS(klass) \
|
#define GST_IS_VAAPIENCODE_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE))
|
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE))
|
||||||
|
|
||||||
#define GST_VAAPI_ENCODE_REGISTER_TYPE(NAME, CODEC, CLASS, _EXT_FMT_) \
|
typedef struct _GstVaapiEncodeInitData GstVaapiEncodeInitData;
|
||||||
|
struct _GstVaapiEncodeInitData
|
||||||
|
{
|
||||||
|
GstCaps *sink_caps;
|
||||||
|
GstCaps *src_caps;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GST_VAAPI_ENCODE_REGISTER_TYPE(NAME, CODEC, CLASS, _EXT_FMT_, FUN) \
|
||||||
|
static GstVaapiEncodeInitData encode_init_data = { NULL, NULL }; \
|
||||||
static GType encode_type = G_TYPE_INVALID; \
|
static GType encode_type = G_TYPE_INVALID; \
|
||||||
static gpointer gst_vaapiencode_##NAME##_parent_class = NULL; \
|
static gpointer gst_vaapiencode_##NAME##_parent_class = NULL; \
|
||||||
static void \
|
static void \
|
||||||
|
@ -108,7 +116,23 @@ G_BEGIN_DECLS
|
||||||
\
|
\
|
||||||
/* class data will be leaked if the element never gets instantiated */ \
|
/* class data will be leaked if the element never gets instantiated */ \
|
||||||
GST_MINI_OBJECT_FLAG_SET (caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); \
|
GST_MINI_OBJECT_FLAG_SET (caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); \
|
||||||
type_info.class_data = caps; \
|
encode_init_data.sink_caps = caps; \
|
||||||
|
\
|
||||||
|
caps = gst_vaapi_build_template_coded_caps_by_codec (display, \
|
||||||
|
GST_VAAPI_CONTEXT_USAGE_ENCODE, \
|
||||||
|
GST_VAAPI_CODEC_##CODEC, GST_CODEC_CAPS, \
|
||||||
|
FUN); \
|
||||||
|
if (!caps) { \
|
||||||
|
GST_ERROR ("failed to get src caps for " #CODEC \
|
||||||
|
" encode, can not register"); \
|
||||||
|
gst_caps_unref (encode_init_data.sink_caps); \
|
||||||
|
return G_TYPE_INVALID; \
|
||||||
|
} \
|
||||||
|
GST_DEBUG (#CODEC" encode's src caps %" GST_PTR_FORMAT, caps); \
|
||||||
|
/* class data will be leaked if the element never gets instantiated */ \
|
||||||
|
GST_MINI_OBJECT_FLAG_SET (caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); \
|
||||||
|
encode_init_data.src_caps = caps; \
|
||||||
|
type_info.class_data = &encode_init_data; \
|
||||||
encode_type = g_type_register_static (GST_TYPE_VAAPIENCODE, \
|
encode_type = g_type_register_static (GST_TYPE_VAAPIENCODE, \
|
||||||
"GstVaapiEncode"#CLASS, &type_info, 0); \
|
"GstVaapiEncode"#CLASS, &type_info, 0); \
|
||||||
\
|
\
|
||||||
|
|
|
@ -95,7 +95,8 @@ static GstStaticPadTemplate gst_vaapiencode_h264_src_factory =
|
||||||
#define EXTRA_FORMATS {}
|
#define EXTRA_FORMATS {}
|
||||||
|
|
||||||
/* h264 encode */
|
/* h264 encode */
|
||||||
GST_VAAPI_ENCODE_REGISTER_TYPE (h264, H264, H264, EXTRA_FORMATS);
|
GST_VAAPI_ENCODE_REGISTER_TYPE (h264, H264, H264, EXTRA_FORMATS,
|
||||||
|
gst_vaapi_utils_h264_get_profile_string);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapiencode_h264_init (GstVaapiEncodeH264 * encode)
|
gst_vaapiencode_h264_init (GstVaapiEncodeH264 * encode)
|
||||||
|
@ -557,7 +558,7 @@ gst_vaapiencode_h264_class_init (GstVaapiEncodeH264Class * klass, gpointer data)
|
||||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
||||||
GstCaps *sink_caps = GST_CAPS_CAST (data);
|
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
|
||||||
gpointer encoder_class;
|
gpointer encoder_class;
|
||||||
|
|
||||||
object_class->finalize = gst_vaapiencode_h264_finalize;
|
object_class->finalize = gst_vaapiencode_h264_finalize;
|
||||||
|
|
|
@ -69,7 +69,8 @@ static GstStaticPadTemplate gst_vaapiencode_h265_src_factory =
|
||||||
#define EXTRA_FORMATS {}
|
#define EXTRA_FORMATS {}
|
||||||
|
|
||||||
/* h265 encode */
|
/* h265 encode */
|
||||||
GST_VAAPI_ENCODE_REGISTER_TYPE (h265, H265, H265, EXTRA_FORMATS);
|
GST_VAAPI_ENCODE_REGISTER_TYPE (h265, H265, H265, EXTRA_FORMATS,
|
||||||
|
gst_vaapi_utils_h265_get_profile_string);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapiencode_h265_init (GstVaapiEncodeH265 * encode)
|
gst_vaapiencode_h265_init (GstVaapiEncodeH265 * encode)
|
||||||
|
@ -370,7 +371,7 @@ gst_vaapiencode_h265_class_init (GstVaapiEncodeH265Class * klass, gpointer data)
|
||||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
||||||
GstCaps *sink_caps = GST_CAPS_CAST (data);
|
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
|
||||||
gpointer encoder_class;
|
gpointer encoder_class;
|
||||||
|
|
||||||
object_class->finalize = gst_vaapiencode_h265_finalize;
|
object_class->finalize = gst_vaapiencode_h265_finalize;
|
||||||
|
|
|
@ -65,7 +65,7 @@ static GstStaticPadTemplate gst_vaapiencode_jpeg_src_factory =
|
||||||
#define EXTRA_FORMATS { GST_VIDEO_FORMAT_BGRA, }
|
#define EXTRA_FORMATS { GST_VIDEO_FORMAT_BGRA, }
|
||||||
|
|
||||||
/* jpeg encode */
|
/* jpeg encode */
|
||||||
GST_VAAPI_ENCODE_REGISTER_TYPE (jpeg, JPEG, Jpeg, EXTRA_FORMATS);
|
GST_VAAPI_ENCODE_REGISTER_TYPE (jpeg, JPEG, Jpeg, EXTRA_FORMATS, NULL);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapiencode_jpeg_init (GstVaapiEncodeJpeg * encode)
|
gst_vaapiencode_jpeg_init (GstVaapiEncodeJpeg * encode)
|
||||||
|
@ -102,7 +102,7 @@ gst_vaapiencode_jpeg_class_init (GstVaapiEncodeJpegClass * klass, gpointer data)
|
||||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
||||||
GstCaps *sink_caps = GST_CAPS_CAST (data);
|
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
|
||||||
gpointer encoder_class;
|
gpointer encoder_class;
|
||||||
|
|
||||||
object_class->finalize = gst_vaapiencode_jpeg_finalize;
|
object_class->finalize = gst_vaapiencode_jpeg_finalize;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "gstcompat.h"
|
#include "gstcompat.h"
|
||||||
#include <gst/vaapi/gstvaapidisplay.h>
|
#include <gst/vaapi/gstvaapidisplay.h>
|
||||||
#include <gst/vaapi/gstvaapiencoder_mpeg2.h>
|
#include <gst/vaapi/gstvaapiencoder_mpeg2.h>
|
||||||
|
#include <gst/vaapi/gstvaapiutils_mpeg2.h>
|
||||||
#include "gstvaapiencode_mpeg2.h"
|
#include "gstvaapiencode_mpeg2.h"
|
||||||
#include "gstvaapipluginutil.h"
|
#include "gstvaapipluginutil.h"
|
||||||
#include "gstvaapivideomemory.h"
|
#include "gstvaapivideomemory.h"
|
||||||
|
@ -67,7 +68,8 @@ static GstStaticPadTemplate gst_vaapiencode_mpeg2_src_factory =
|
||||||
#define EXTRA_FORMATS {}
|
#define EXTRA_FORMATS {}
|
||||||
|
|
||||||
/* mpeg2 encode */
|
/* mpeg2 encode */
|
||||||
GST_VAAPI_ENCODE_REGISTER_TYPE (mpeg2, MPEG2, Mpeg2, EXTRA_FORMATS);
|
GST_VAAPI_ENCODE_REGISTER_TYPE (mpeg2, MPEG2, Mpeg2, EXTRA_FORMATS,
|
||||||
|
gst_vaapi_utils_mpeg2_get_profile_string);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapiencode_mpeg2_init (GstVaapiEncodeMpeg2 * encode)
|
gst_vaapiencode_mpeg2_init (GstVaapiEncodeMpeg2 * encode)
|
||||||
|
@ -106,7 +108,7 @@ gst_vaapiencode_mpeg2_class_init (GstVaapiEncodeMpeg2Class * klass,
|
||||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
||||||
GstCaps *sink_caps = GST_CAPS_CAST (data);
|
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
|
||||||
gpointer encoder_class;
|
gpointer encoder_class;
|
||||||
|
|
||||||
object_class->finalize = gst_vaapiencode_mpeg2_finalize;
|
object_class->finalize = gst_vaapiencode_mpeg2_finalize;
|
||||||
|
|
|
@ -65,7 +65,7 @@ static GstStaticPadTemplate gst_vaapiencode_vp8_src_factory =
|
||||||
#define EXTRA_FORMATS {}
|
#define EXTRA_FORMATS {}
|
||||||
|
|
||||||
/* vp8 encode */
|
/* vp8 encode */
|
||||||
GST_VAAPI_ENCODE_REGISTER_TYPE (vp8, VP8, VP8, EXTRA_FORMATS);
|
GST_VAAPI_ENCODE_REGISTER_TYPE (vp8, VP8, VP8, EXTRA_FORMATS, NULL);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapiencode_vp8_init (GstVaapiEncodeVP8 * encode)
|
gst_vaapiencode_vp8_init (GstVaapiEncodeVP8 * encode)
|
||||||
|
@ -102,7 +102,7 @@ gst_vaapiencode_vp8_class_init (GstVaapiEncodeVP8Class * klass, gpointer data)
|
||||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
||||||
GstCaps *sink_caps = GST_CAPS_CAST (data);
|
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
|
||||||
gpointer encoder_class;
|
gpointer encoder_class;
|
||||||
|
|
||||||
object_class->finalize = gst_vaapiencode_vp8_finalize;
|
object_class->finalize = gst_vaapiencode_vp8_finalize;
|
||||||
|
|
|
@ -65,7 +65,7 @@ static GstStaticPadTemplate gst_vaapiencode_vp9_src_factory =
|
||||||
#define EXTRA_FORMATS {}
|
#define EXTRA_FORMATS {}
|
||||||
|
|
||||||
/* vp9 encode */
|
/* vp9 encode */
|
||||||
GST_VAAPI_ENCODE_REGISTER_TYPE (vp9, VP9, VP9, EXTRA_FORMATS);
|
GST_VAAPI_ENCODE_REGISTER_TYPE (vp9, VP9, VP9, EXTRA_FORMATS, NULL);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapiencode_vp9_init (GstVaapiEncodeVP9 * encode)
|
gst_vaapiencode_vp9_init (GstVaapiEncodeVP9 * encode)
|
||||||
|
@ -102,7 +102,7 @@ gst_vaapiencode_vp9_class_init (GstVaapiEncodeVP9Class * klass, gpointer data)
|
||||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
|
||||||
GstCaps *sink_caps = GST_CAPS_CAST (data);
|
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
|
||||||
gpointer encoder_class;
|
gpointer encoder_class;
|
||||||
|
|
||||||
object_class->finalize = gst_vaapiencode_vp9_finalize;
|
object_class->finalize = gst_vaapiencode_vp9_finalize;
|
||||||
|
|
Loading…
Reference in a new issue