libs: decoder: refactor decoders as gobject

https://bugzilla.gnome.org/show_bug.cgi?id=796308
parent 7872d126
......@@ -38,6 +38,16 @@
#define DEBUG 1
#include "gstvaapidebug.h"
enum
{
PROP_DISPLAY = 1,
PROP_CAPS,
N_PROPERTIES
};
static GParamSpec *g_properties[N_PROPERTIES] = { NULL, };
G_DEFINE_TYPE (GstVaapiDecoder, gst_vaapi_decoder, GST_TYPE_OBJECT);
static void drop_frame (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame);
static void
......@@ -453,14 +463,10 @@ notify_codec_state_changed (GstVaapiDecoder * decoder)
decoder->codec_state_changed_data);
}
void
gst_vaapi_decoder_finalize (GstVaapiDecoder * decoder)
static void
gst_vaapi_decoder_finalize (GObject * object)
{
const GstVaapiDecoderClass *const klass =
GST_VAAPI_DECODER_GET_CLASS (decoder);
if (klass->destroy)
klass->destroy (decoder);
GstVaapiDecoder *const decoder = GST_VAAPI_DECODER (object);
gst_video_codec_state_unref (decoder->codec_state);
decoder->codec_state = NULL;
......@@ -482,16 +488,90 @@ gst_vaapi_decoder_finalize (GstVaapiDecoder * decoder)
gst_vaapi_display_replace (&decoder->display, NULL);
decoder->va_display = NULL;
G_OBJECT_CLASS (gst_vaapi_decoder_parent_class)->finalize (object);
}
static gboolean
gst_vaapi_decoder_init (GstVaapiDecoder * decoder, GstVaapiDisplay * display,
GstCaps * caps)
static void
gst_vaapi_decoder_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
GstVaapiDecoder *const decoder = GST_VAAPI_DECODER (object);
switch (property_id) {
case PROP_DISPLAY:
g_assert (decoder->display == NULL);
decoder->display = g_value_dup_object (value);
g_assert (decoder->display != NULL);
decoder->va_display = GST_VAAPI_DISPLAY_VADISPLAY (decoder->display);
break;
case PROP_CAPS:{
GstCaps *caps = g_value_get_boxed (value);
if (!set_caps (decoder, caps)) {
GST_WARNING_OBJECT (decoder, "failed to set caps %" GST_PTR_FORMAT,
caps);
}
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
gst_vaapi_decoder_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
GstVaapiDecoder *const decoder = GST_VAAPI_DECODER (object);
switch (property_id) {
case PROP_DISPLAY:
g_value_set_object (value, decoder->display);
break;
case PROP_CAPS:
g_value_set_boxed (value, get_caps (decoder));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
gst_vaapi_decoder_class_init (GstVaapiDecoderClass * klass)
{
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gst_vaapi_decoder_set_property;
object_class->get_property = gst_vaapi_decoder_get_property;
object_class->finalize = gst_vaapi_decoder_finalize;
/**
* GstVaapiDecoder:display:
*
* #GstVaapiDisplay to be used.
*/
g_properties[PROP_DISPLAY] =
g_param_spec_object ("display", "Gst VA-API Display",
"The VA-API display object to use", GST_TYPE_VAAPI_DISPLAY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME);
/**
* GstCaps:caps:
*
* #GstCaps the caps describing the media to process.
*/
g_properties[PROP_CAPS] =
g_param_spec_boxed ("caps", "Caps",
"The caps describing the media to process", GST_TYPE_CAPS,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME);
g_object_class_install_properties (object_class, N_PROPERTIES, g_properties);
}
static void
gst_vaapi_decoder_init (GstVaapiDecoder * decoder)
{
const GstVaapiDecoderClass *const klass =
GST_VAAPI_DECODER_GET_CLASS (decoder);
GstVideoCodecState *codec_state;
guint sub_size;
parser_state_init (&decoder->parser_state);
......@@ -499,56 +579,21 @@ gst_vaapi_decoder_init (GstVaapiDecoder * decoder, GstVaapiDisplay * display,
codec_state->ref_count = 1;
gst_video_info_init (&codec_state->info);
decoder->user_data = NULL;
decoder->display = gst_object_ref (display);
decoder->va_display = GST_VAAPI_DISPLAY_VADISPLAY (display);
decoder->context = NULL;
decoder->va_context = VA_INVALID_ID;
decoder->codec = 0;
decoder->codec_state = codec_state;
decoder->codec_state_changed_func = NULL;
decoder->codec_state_changed_data = NULL;
decoder->buffers = g_async_queue_new_full ((GDestroyNotify) gst_buffer_unref);
decoder->frames = g_async_queue_new_full ((GDestroyNotify)
gst_video_codec_frame_unref);
if (!set_caps (decoder, caps))
return FALSE;
sub_size = GST_VAAPI_MINI_OBJECT_CLASS (klass)->size - sizeof (*decoder);
if (sub_size > 0)
memset (((guchar *) decoder) + sizeof (*decoder), 0, sub_size);
if (klass->create && !klass->create (decoder))
return FALSE;
return TRUE;
}
GstVaapiDecoder *
gst_vaapi_decoder_new (const GstVaapiDecoderClass * klass,
GstVaapiDisplay * display, GstCaps * caps)
gst_vaapi_decoder_new (GstVaapiDisplay * display, GstCaps * caps)
{
GstVaapiDecoder *decoder;
g_return_val_if_fail (display != NULL, NULL);
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
decoder = (GstVaapiDecoder *)
gst_vaapi_mini_object_new (GST_VAAPI_MINI_OBJECT_CLASS (klass));
if (!decoder)
return NULL;
if (!gst_vaapi_decoder_init (decoder, display, caps))
goto error;
return decoder;
/* ERRORS */
error:
{
gst_vaapi_decoder_unref (decoder);
return NULL;
}
return g_object_new (GST_TYPE_VAAPI_DECODER, "display", display,
"caps", caps, NULL);
}
/**
......@@ -562,7 +607,7 @@ error:
GstVaapiDecoder *
gst_vaapi_decoder_ref (GstVaapiDecoder * decoder)
{
return gst_vaapi_object_ref (decoder);
return gst_object_ref (decoder);
}
/**
......@@ -575,7 +620,7 @@ gst_vaapi_decoder_ref (GstVaapiDecoder * decoder)
void
gst_vaapi_decoder_unref (GstVaapiDecoder * decoder)
{
gst_vaapi_object_unref (decoder);
gst_object_unref (decoder);
}
/**
......@@ -591,8 +636,7 @@ void
gst_vaapi_decoder_replace (GstVaapiDecoder ** old_decoder_ptr,
GstVaapiDecoder * new_decoder)
{
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) old_decoder_ptr,
GST_VAAPI_MINI_OBJECT (new_decoder));
gst_object_replace ((GstObject **) old_decoder_ptr, GST_OBJECT (new_decoder));
}
/**
......
......@@ -32,8 +32,12 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DECODER \
(gst_vaapi_decoder_get_type ())
#define GST_VAAPI_DECODER(obj) \
((GstVaapiDecoder *)(obj))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DECODER, GstVaapiDecoder))
#define GST_VAAPI_IS_DECODER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DECODER))
typedef struct _GstVaapiDecoder GstVaapiDecoder;
typedef void (*GstVaapiDecoderStateChangedFunc) (GstVaapiDecoder * decoder,
......@@ -73,6 +77,9 @@ typedef enum {
GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN = -1
} GstVaapiDecoderStatus;
GType
gst_vaapi_decoder_get_type (void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_ref (GstVaapiDecoder * decoder);
......@@ -141,6 +148,10 @@ gst_vaapi_decoder_check_status (GstVaapiDecoder * decoder);
gboolean
gst_vaapi_decoder_update_caps (GstVaapiDecoder * decoder, GstCaps * caps);
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiDecoder, gst_vaapi_decoder_unref)
#endif
G_END_DECLS
#endif /* GST_VAAPI_DECODER_H */
......@@ -558,6 +558,9 @@ struct _GstVaapiDecoderH264Class
GstVaapiDecoderClass parent_class;
};
G_DEFINE_TYPE (GstVaapiDecoderH264, gst_vaapi_decoder_h264,
GST_TYPE_VAAPI_DECODER);
static gboolean
exec_ref_pic_marking (GstVaapiDecoderH264 * decoder,
GstVaapiPictureH264 * picture);
......@@ -4710,16 +4713,21 @@ gst_vaapi_decoder_h264_flush (GstVaapiDecoder * base_decoder)
return GST_VAAPI_DECODER_STATUS_SUCCESS;
}
static void
gst_vaapi_decoder_h264_finalize (GObject * object)
{
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (object);
gst_vaapi_decoder_h264_destroy (base_decoder);
G_OBJECT_CLASS (gst_vaapi_decoder_h264_parent_class)->finalize (object);
}
static void
gst_vaapi_decoder_h264_class_init (GstVaapiDecoderH264Class * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstVaapiDecoderClass *const decoder_class = GST_VAAPI_DECODER_CLASS (klass);
object_class->size = sizeof (GstVaapiDecoderH264);
object_class->finalize = (GDestroyNotify) gst_vaapi_decoder_finalize;
decoder_class->create = gst_vaapi_decoder_h264_create;
decoder_class->destroy = gst_vaapi_decoder_h264_destroy;
decoder_class->reset = gst_vaapi_decoder_h264_reset;
......@@ -4728,21 +4736,17 @@ gst_vaapi_decoder_h264_class_init (GstVaapiDecoderH264Class * klass)
decoder_class->start_frame = gst_vaapi_decoder_h264_start_frame;
decoder_class->end_frame = gst_vaapi_decoder_h264_end_frame;
decoder_class->flush = gst_vaapi_decoder_h264_flush;
decoder_class->decode_codec_data = gst_vaapi_decoder_h264_decode_codec_data;
object_class->finalize = gst_vaapi_decoder_h264_finalize;
}
static inline const GstVaapiDecoderClass *
gst_vaapi_decoder_h264_class (void)
static void
gst_vaapi_decoder_h264_init (GstVaapiDecoderH264 * decoder)
{
static GstVaapiDecoderH264Class g_class;
static gsize g_class_init = FALSE;
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder);
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_decoder_h264_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DECODER_CLASS (&g_class);
gst_vaapi_decoder_h264_create (base_decoder);
}
/**
......@@ -4830,5 +4834,6 @@ gst_vaapi_decoder_h264_get_low_latency (GstVaapiDecoderH264 * decoder)
GstVaapiDecoder *
gst_vaapi_decoder_h264_new (GstVaapiDisplay * display, GstCaps * caps)
{
return gst_vaapi_decoder_new (gst_vaapi_decoder_h264_class (), display, caps);
return g_object_new (GST_TYPE_VAAPI_DECODER_H264, "display", display,
"caps", caps, NULL);
}
......@@ -27,8 +27,12 @@
G_BEGIN_DECLS
#define GST_VAAPI_DECODER_H264(decoder) \
((GstVaapiDecoderH264 *)(decoder))
#define GST_TYPE_VAAPI_DECODER_H264 \
(gst_vaapi_decoder_h264_get_type ())
#define GST_VAAPI_DECODER_H264(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DECODER_H264, GstVaapiDecoderH264))
#define GST_VAAPI_IS_DECODER_H264(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DECODER_H264))
typedef struct _GstVaapiDecoderH264 GstVaapiDecoderH264;
......@@ -48,8 +52,11 @@ typedef enum {
GST_VAAPI_STREAM_ALIGN_H264_AU
} GstVaapiStreamAlignH264;
GType
gst_vaapi_decoder_h264_get_type (void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_h264_new(GstVaapiDisplay *display, GstCaps *caps);
gst_vaapi_decoder_h264_new (GstVaapiDisplay *display, GstCaps *caps);
void
gst_vaapi_decoder_h264_set_alignment(GstVaapiDecoderH264 *decoder,
......
......@@ -445,6 +445,9 @@ struct _GstVaapiDecoderH265Class
GstVaapiDecoderClass parent_class;
};
G_DEFINE_TYPE (GstVaapiDecoderH265, gst_vaapi_decoder_h265,
GST_TYPE_VAAPI_DECODER);
#define RSV_VCL_N10 10
#define RSV_VCL_N12 12
#define RSV_VCL_N14 14
......@@ -3032,15 +3035,23 @@ gst_vaapi_decoder_h265_flush (GstVaapiDecoder * base_decoder)
return GST_VAAPI_DECODER_STATUS_SUCCESS;
}
static void
gst_vaapi_decoder_h265_finalize (GObject * object)
{
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (object);
gst_vaapi_decoder_h265_destroy (base_decoder);
G_OBJECT_CLASS (gst_vaapi_decoder_h265_parent_class)->finalize (object);
}
static void
gst_vaapi_decoder_h265_class_init (GstVaapiDecoderH265Class * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstVaapiDecoderClass *const decoder_class = GST_VAAPI_DECODER_CLASS (klass);
object_class->size = sizeof (GstVaapiDecoderH265);
object_class->finalize = (GDestroyNotify) gst_vaapi_decoder_finalize;
object_class->finalize = gst_vaapi_decoder_h265_finalize;
decoder_class->create = gst_vaapi_decoder_h265_create;
decoder_class->destroy = gst_vaapi_decoder_h265_destroy;
decoder_class->parse = gst_vaapi_decoder_h265_parse;
......@@ -3051,17 +3062,12 @@ gst_vaapi_decoder_h265_class_init (GstVaapiDecoderH265Class * klass)
decoder_class->decode_codec_data = gst_vaapi_decoder_h265_decode_codec_data;
}
static inline const GstVaapiDecoderClass *
gst_vaapi_decoder_h265_class (void)
static void
gst_vaapi_decoder_h265_init (GstVaapiDecoderH265 * decoder)
{
static GstVaapiDecoderH265Class g_class;
static gsize g_class_init = FALSE;
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder);
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_decoder_h265_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DECODER_CLASS (&g_class);
gst_vaapi_decoder_h265_create (base_decoder);
}
/**
......@@ -3094,5 +3100,6 @@ gst_vaapi_decoder_h265_set_alignment (GstVaapiDecoderH265 * decoder,
GstVaapiDecoder *
gst_vaapi_decoder_h265_new (GstVaapiDisplay * display, GstCaps * caps)
{
return gst_vaapi_decoder_new (gst_vaapi_decoder_h265_class (), display, caps);
return g_object_new (GST_TYPE_VAAPI_DECODER_H265, "display", display,
"caps", caps, NULL);
}
......@@ -28,8 +28,12 @@
G_BEGIN_DECLS
#define GST_VAAPI_DECODER_H265(decoder) \
((GstVaapiDecoderH265 *)(decoder))
#define GST_TYPE_VAAPI_DECODER_H265 \
(gst_vaapi_decoder_h265_get_type ())
#define GST_VAAPI_DECODER_H265(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DECODER_H265, GstVaapiDecoderH265))
#define GST_VAAPI_IS_DECODER_H265(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DECODER_H265))
typedef struct _GstVaapiDecoderH265 GstVaapiDecoderH265;
......@@ -49,11 +53,14 @@ typedef enum {
GST_VAAPI_STREAM_ALIGN_H265_AU
} GstVaapiStreamAlignH265;
GType
gst_vaapi_decoder_h265_get_type (void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_h265_new(GstVaapiDisplay *display, GstCaps *caps);
gst_vaapi_decoder_h265_new (GstVaapiDisplay *display, GstCaps *caps);
void
gst_vaapi_decoder_h265_set_alignment(GstVaapiDecoderH265 *decoder,
gst_vaapi_decoder_h265_set_alignment (GstVaapiDecoderH265 *decoder,
GstVaapiStreamAlignH265 alignment);
G_END_DECLS
......
......@@ -96,6 +96,9 @@ struct _GstVaapiDecoderJpegClass
GstVaapiDecoderClass parent_class;
};
G_DEFINE_TYPE (GstVaapiDecoderJpeg, gst_vaapi_decoder_jpeg,
GST_TYPE_VAAPI_DECODER);
static inline void
unit_set_marker_code (GstVaapiDecoderUnit * unit, GstJpegMarker marker)
{
......@@ -844,15 +847,22 @@ gst_vaapi_decoder_jpeg_end_frame (GstVaapiDecoder * base_decoder)
return decode_current_picture (decoder);
}
static void
gst_vaapi_decoder_jpeg_finalize (GObject * object)
{
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (object);
gst_vaapi_decoder_jpeg_destroy (base_decoder);
G_OBJECT_CLASS (gst_vaapi_decoder_jpeg_parent_class)->finalize (object);
}
static void
gst_vaapi_decoder_jpeg_class_init (GstVaapiDecoderJpegClass * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstVaapiDecoderClass *const decoder_class = GST_VAAPI_DECODER_CLASS (klass);
object_class->size = sizeof (GstVaapiDecoderJpeg);
object_class->finalize = (GDestroyNotify) gst_vaapi_decoder_finalize;
object_class->finalize = gst_vaapi_decoder_jpeg_finalize;
decoder_class->create = gst_vaapi_decoder_jpeg_create;
decoder_class->destroy = gst_vaapi_decoder_jpeg_destroy;
......@@ -862,17 +872,12 @@ gst_vaapi_decoder_jpeg_class_init (GstVaapiDecoderJpegClass * klass)
decoder_class->end_frame = gst_vaapi_decoder_jpeg_end_frame;
}
static inline const GstVaapiDecoderClass *
gst_vaapi_decoder_jpeg_class (void)
static void
gst_vaapi_decoder_jpeg_init (GstVaapiDecoderJpeg * decoder)
{
static GstVaapiDecoderJpegClass g_class;
static gsize g_class_init = FALSE;
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder);
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_decoder_jpeg_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DECODER_CLASS (&g_class);
gst_vaapi_decoder_jpeg_create (base_decoder);
}
/**
......@@ -888,5 +893,6 @@ gst_vaapi_decoder_jpeg_class (void)
GstVaapiDecoder *
gst_vaapi_decoder_jpeg_new (GstVaapiDisplay * display, GstCaps * caps)
{
return gst_vaapi_decoder_new (gst_vaapi_decoder_jpeg_class (), display, caps);
return g_object_new (GST_TYPE_VAAPI_DECODER_JPEG, "display", display,
"caps", caps, NULL);
}
......@@ -28,10 +28,20 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DECODER_JPEG \
(gst_vaapi_decoder_jpeg_get_type ())
#define GST_VAAPI_DECODER_JPEG(decoder) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DECODER_JPEG, GstVaapiDecoderJpeg))
#define GST_VAAPI_IS_DECODER_JPEG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DECODER_JPEG))
typedef struct _GstVaapiDecoderJpeg GstVaapiDecoderJpeg;
GType
gst_vaapi_decoder_jpeg_get_type (void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_jpeg_new(GstVaapiDisplay *display, GstCaps *caps);
gst_vaapi_decoder_jpeg_new (GstVaapiDisplay *display, GstCaps *caps);
G_END_DECLS
......
......@@ -296,6 +296,9 @@ struct _GstVaapiDecoderMpeg2Class
GstVaapiDecoderClass parent_class;
};
G_DEFINE_TYPE (GstVaapiDecoderMpeg2, gst_vaapi_decoder_mpeg2,
GST_TYPE_VAAPI_DECODER);
static void
gst_vaapi_decoder_mpeg2_close (GstVaapiDecoderMpeg2 * decoder)
{
......@@ -1564,15 +1567,22 @@ gst_vaapi_decoder_mpeg2_flush (GstVaapiDecoder * base_decoder)
return GST_VAAPI_DECODER_STATUS_SUCCESS;
}
static void
gst_vaapi_decoder_mpeg2_finalize (GObject * object)
{
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (object);
gst_vaapi_decoder_mpeg2_destroy (base_decoder);
G_OBJECT_CLASS (gst_vaapi_decoder_mpeg2_parent_class)->finalize (object);
}
static void
gst_vaapi_decoder_mpeg2_class_init (GstVaapiDecoderMpeg2Class * klass)
{
GstVaapiMiniObjectClass *const object_class =
GST_VAAPI_MINI_OBJECT_CLASS (klass);
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstVaapiDecoderClass *const decoder_class = GST_VAAPI_DECODER_CLASS (klass);
object_class->size = sizeof (GstVaapiDecoderMpeg2);
object_class->finalize = (GDestroyNotify) gst_vaapi_decoder_finalize;
object_class->finalize = gst_vaapi_decoder_mpeg2_finalize;
decoder_class->create = gst_vaapi_decoder_mpeg2_create;
decoder_class->destroy = gst_vaapi_decoder_mpeg2_destroy;
......@@ -1583,17 +1593,12 @@ gst_vaapi_decoder_mpeg2_class_init (GstVaapiDecoderMpeg2Class * klass)
decoder_class->flush = gst_vaapi_decoder_mpeg2_flush;
}
static inline const GstVaapiDecoderClass *
gst_vaapi_decoder_mpeg2_class (void)
static void
gst_vaapi_decoder_mpeg2_init (GstVaapiDecoderMpeg2 * decoder)
{
static GstVaapiDecoderMpeg2Class g_class;
static gsize g_class_init = FALSE;
GstVaapiDecoder *const base_decoder = GST_VAAPI_DECODER (decoder);
if (g_once_init_enter (&g_class_init)) {
gst_vaapi_decoder_mpeg2_class_init (&g_class);
g_once_init_leave (&g_class_init, TRUE);
}
return GST_VAAPI_DECODER_CLASS (&g_class);
gst_vaapi_decoder_mpeg2_create (base_decoder);
}
/**
......@@ -1609,6 +1614,6 @@ gst_vaapi_decoder_mpeg2_class (void)
GstVaapiDecoder *
gst_vaapi_decoder_mpeg2_new (GstVaapiDisplay * display, GstCaps * caps)
{
return gst_vaapi_decoder_new (gst_vaapi_decoder_mpeg2_class (),
display, caps);
return g_object_new (GST_TYPE_VAAPI_DECODER_MPEG2, "display", display,
"caps", caps, NULL);
}
......@@ -28,10 +28,20 @@
G_BEGIN_DECLS
#define GST_TYPE_VAAPI_DECODER_MPEG2 \
(gst_vaapi_decoder_mpeg2_get_type ())
#define GST_VAAPI_DECODER_MPEG2(decoder) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DECODER_MPEG2, GstVaapiDecoderMpeg2))
#define GST_VAAPI_IS_DECODER_MPEG2(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DECODER_MPEG2))
typedef struct _GstVaapiDecoderMpeg2 GstVaapiDecoderMpeg2;
GType
gst_vaapi_decoder_mpeg2_get_type (void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_mpeg2_new(GstVaapiDisplay *display, GstCaps *caps);
gst_vaapi_decoder_mpeg2_new (GstVaapiDisplay *display, GstCaps *caps);
G_END_DECLS
......
......@@ -119,6 +119,9 @@ struct _GstVaapiDecoderMpeg4Class
GstVaapiDecoderClass parent_class;
};
G_DEFINE_TYPE (GstVaapiDecoderMpeg4, gst_vaapi_decoder_mpeg4,
GST_TYPE_VAAPI_DECODER);
static void