Commit 3cc7b269 authored by Gwenole Beauchesne's avatar Gwenole Beauchesne

libs: use GstVaapiMiniObject for video decoders.

Port GstVaapiDecoder and GstVaapiDecoder{MPEG2,MPEG4,JPEG,H264,VC1} to
GstVaapiMiniObject. Add gst_vaapi_decoder_set_codec_state_changed_func()
helper function to let the user add a callback to a function triggered
whenever the codec state (e.g. caps) changes.
parent 2e6ff64a
......@@ -96,8 +96,8 @@ gst_vaapi_codec_object_new(const GstVaapiCodecObjectClass *object_class,
}
#define GET_DECODER(obj) GST_VAAPI_DECODER_CAST((obj)->parent_instance.codec)
#define GET_VA_DISPLAY(obj) GET_DECODER(obj)->priv->va_display
#define GET_VA_CONTEXT(obj) GET_DECODER(obj)->priv->va_context
#define GET_VA_DISPLAY(obj) GET_DECODER(obj)->va_display
#define GET_VA_CONTEXT(obj) GET_DECODER(obj)->va_context
/* ------------------------------------------------------------------------- */
/* --- Inverse Quantization Matrices --- */
......
This diff is collapsed.
......@@ -31,34 +31,15 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_DECODER \
(gst_vaapi_decoder_get_type())
#define GST_VAAPI_DECODER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_DECODER, \
GstVaapiDecoder))
#define GST_VAAPI_DECODER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_DECODER, \
GstVaapiDecoderClass))
#define GST_VAAPI_DECODER(obj) \
((GstVaapiDecoder *)(obj))
#define GST_VAAPI_IS_DECODER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DECODER))
#define GST_VAAPI_IS_DECODER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DECODER))
#define GST_VAAPI_DECODER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_DECODER, \
GstVaapiDecoderClass))
((obj) != NULL)
typedef struct _GstVaapiDecoder GstVaapiDecoder;
typedef struct _GstVaapiDecoderPrivate GstVaapiDecoderPrivate;
typedef struct _GstVaapiDecoderClass GstVaapiDecoderClass;
struct _GstVaapiDecoderUnit;
typedef void (*GstVaapiDecoderStateChangedFunc)(GstVaapiDecoder *decoder,
const GstVideoCodecState *codec_state, gpointer user_data);
/**
* GstVaapiDecoderStatus:
......@@ -94,42 +75,21 @@ typedef enum {
GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN = -1
} GstVaapiDecoderStatus;
/**
* GstVaapiDecoder:
*
* A VA decoder base instance.
*/
struct _GstVaapiDecoder {
/*< private >*/
GObject parent_instance;
GstVaapiDecoder *
gst_vaapi_decoder_ref(GstVaapiDecoder *decoder);
GstVaapiDecoderPrivate *priv;
};
void
gst_vaapi_decoder_unref(GstVaapiDecoder *decoder);
/**
* GstVaapiDecoderClass:
*
* A VA decoder base class.
*/
struct _GstVaapiDecoderClass {
/*< private >*/
GObjectClass parent_class;
GstVaapiDecoderStatus (*parse)(GstVaapiDecoder *decoder,
GstAdapter *adapter, gboolean at_eos,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*decode)(GstVaapiDecoder *decoder,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*start_frame)(GstVaapiDecoder *decoder,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*end_frame)(GstVaapiDecoder *decoder);
GstVaapiDecoderStatus (*flush)(GstVaapiDecoder *decoder);
GstVaapiDecoderStatus (*decode_codec_data)(GstVaapiDecoder *decoder,
const guchar *buf, guint buf_size);
};
GType
gst_vaapi_decoder_get_type(void) G_GNUC_CONST;
void
gst_vaapi_decoder_replace(GstVaapiDecoder **old_decoder_ptr,
GstVaapiDecoder *new_decoder);
gpointer
gst_vaapi_decoder_get_user_data(GstVaapiDecoder *decoder);
void
gst_vaapi_decoder_set_user_data(GstVaapiDecoder *decoder, gpointer user_data);
GstVaapiCodec
gst_vaapi_decoder_get_codec(GstVaapiDecoder *decoder);
......@@ -137,6 +97,10 @@ gst_vaapi_decoder_get_codec(GstVaapiDecoder *decoder);
GstVideoCodecState *
gst_vaapi_decoder_get_codec_state(GstVaapiDecoder *decoder);
void
gst_vaapi_decoder_set_codec_state_changed_func(GstVaapiDecoder *decoder,
GstVaapiDecoderStateChangedFunc func, gpointer user_data);
GstCaps *
gst_vaapi_decoder_get_caps(GstVaapiDecoder *decoder);
......
This diff is collapsed.
......@@ -26,58 +26,7 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_DECODER_H264 \
(gst_vaapi_decoder_h264_get_type())
#define GST_VAAPI_DECODER_H264(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_DECODER_H264, \
GstVaapiDecoderH264))
#define GST_VAAPI_DECODER_H264_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_DECODER_H264, \
GstVaapiDecoderH264Class))
#define GST_VAAPI_IS_DECODER_H264(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DECODER_H264))
#define GST_VAAPI_IS_DECODER_H264_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DECODER_H264))
#define GST_VAAPI_DECODER_H264_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_DECODER_H264, \
GstVaapiDecoderH264Class))
typedef struct _GstVaapiDecoderH264 GstVaapiDecoderH264;
typedef struct _GstVaapiDecoderH264Private GstVaapiDecoderH264Private;
typedef struct _GstVaapiDecoderH264Class GstVaapiDecoderH264Class;
/**
* GstVaapiDecoderH264:
*
* A decoder based on H264.
*/
struct _GstVaapiDecoderH264 {
/*< private >*/
GstVaapiDecoder parent_instance;
GstVaapiDecoderH264Private *priv;
};
/**
* GstVaapiDecoderH264Class:
*
* A decoder class based on H264.
*/
struct _GstVaapiDecoderH264Class {
/*< private >*/
GstVaapiDecoderClass parent_class;
};
GType
gst_vaapi_decoder_h264_get_type(void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_h264_new(GstVaapiDisplay *display, GstCaps *caps);
......
This diff is collapsed.
......@@ -26,58 +26,7 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_DECODER_JPEG \
(gst_vaapi_decoder_jpeg_get_type())
#define GST_VAAPI_DECODER_JPEG(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_DECODER_JPEG, \
GstVaapiDecoderJpeg))
#define GST_VAAPI_DECODER_JPEG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_DECODER_JPEG, \
GstVaapiDecoderJpegClass))
#define GST_VAAPI_IS_DECODER_JPEG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DECODER_JPEG))
#define GST_VAAPI_IS_DECODER_JPEG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DECODER_JPEG))
#define GST_VAAPI_DECODER_JPEG_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_DECODER_JPEG, \
GstVaapiDecoderJpegClass))
typedef struct _GstVaapiDecoderJpeg GstVaapiDecoderJpeg;
typedef struct _GstVaapiDecoderJpegPrivate GstVaapiDecoderJpegPrivate;
typedef struct _GstVaapiDecoderJpegClass GstVaapiDecoderJpegClass;
/**
* GstVaapiDecoderJpeg:
*
* A decoder based on Jpeg.
*/
struct _GstVaapiDecoderJpeg {
/*< private >*/
GstVaapiDecoder parent_instance;
GstVaapiDecoderJpegPrivate *priv;
};
/**
* GstVaapiDecoderJpegClass:
*
* A decoder class based on Jpeg.
*/
struct _GstVaapiDecoderJpegClass {
/*< private >*/
GstVaapiDecoderClass parent_class;
};
GType
gst_vaapi_decoder_jpeg_get_type(void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_jpeg_new(GstVaapiDisplay *display, GstCaps *caps);
......
This diff is collapsed.
......@@ -27,58 +27,7 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_DECODER_MPEG2 \
(gst_vaapi_decoder_mpeg2_get_type())
#define GST_VAAPI_DECODER_MPEG2(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_DECODER_MPEG2, \
GstVaapiDecoderMpeg2))
#define GST_VAAPI_DECODER_MPEG2_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_DECODER_MPEG2, \
GstVaapiDecoderMpeg2Class))
#define GST_VAAPI_IS_DECODER_MPEG2(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DECODER_MPEG2))
#define GST_VAAPI_IS_DECODER_MPEG2_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DECODER_MPEG2))
#define GST_VAAPI_DECODER_MPEG2_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_DECODER_MPEG2, \
GstVaapiDecoderMpeg2Class))
typedef struct _GstVaapiDecoderMpeg2 GstVaapiDecoderMpeg2;
typedef struct _GstVaapiDecoderMpeg2Private GstVaapiDecoderMpeg2Private;
typedef struct _GstVaapiDecoderMpeg2Class GstVaapiDecoderMpeg2Class;
/**
* GstVaapiDecoderMpeg2:
*
* A decoder based on Mpeg2.
*/
struct _GstVaapiDecoderMpeg2 {
/*< private >*/
GstVaapiDecoder parent_instance;
GstVaapiDecoderMpeg2Private *priv;
};
/**
* GstVaapiDecoderMpeg2Class:
*
* A decoder class based on Mpeg2.
*/
struct _GstVaapiDecoderMpeg2Class {
/*< private >*/
GstVaapiDecoderClass parent_class;
};
GType
gst_vaapi_decoder_mpeg2_get_type(void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_mpeg2_new(GstVaapiDisplay *display, GstCaps *caps);
......
This diff is collapsed.
......@@ -27,58 +27,7 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_DECODER_MPEG4 \
(gst_vaapi_decoder_mpeg4_get_type())
#define GST_VAAPI_DECODER_MPEG4(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_DECODER_MPEG4, \
GstVaapiDecoderMpeg4))
#define GST_VAAPI_DECODER_MPEG4_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_DECODER_MPEG4, \
GstVaapiDecoderMpeg4Class))
#define GST_VAAPI_IS_DECODER_MPEG4(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DECODER_MPEG4))
#define GST_VAAPI_IS_DECODER_MPEG4_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DECODER_MPEG4))
#define GST_VAAPI_DECODER_MPEG4_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_DECODER_MPEG4, \
GstVaapiDecoderMpeg4Class))
typedef struct _GstVaapiDecoderMpeg4 GstVaapiDecoderMpeg4;
typedef struct _GstVaapiDecoderMpeg4Private GstVaapiDecoderMpeg4Private;
typedef struct _GstVaapiDecoderMpeg4Class GstVaapiDecoderMpeg4Class;
/**
* GstVaapiDecoderMpeg4:
*
* A decoder based on Mpeg4.
*/
struct _GstVaapiDecoderMpeg4 {
/*< private >*/
GstVaapiDecoder parent_instance;
GstVaapiDecoderMpeg4Private *priv;
};
/**
* GstVaapiDecoderMpeg4Class:
*
* A decoder class based on Mpeg4.
*/
struct _GstVaapiDecoderMpeg4Class {
/*< private >*/
GstVaapiDecoderClass parent_class;
};
GType
gst_vaapi_decoder_mpeg4_get_type(void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_mpeg4_new(GstVaapiDisplay *display, GstCaps *caps);
......
......@@ -33,9 +33,9 @@
#include "gstvaapidebug.h"
#define GET_DECODER(obj) GST_VAAPI_DECODER_CAST((obj)->parent_instance.codec)
#define GET_CONTEXT(obj) GET_DECODER(obj)->priv->context
#define GET_VA_DISPLAY(obj) GET_DECODER(obj)->priv->va_display
#define GET_VA_CONTEXT(obj) GET_DECODER(obj)->priv->va_context
#define GET_CONTEXT(obj) GET_DECODER(obj)->context
#define GET_VA_DISPLAY(obj) GET_DECODER(obj)->va_display
#define GET_VA_CONTEXT(obj) GET_DECODER(obj)->va_context
/* ------------------------------------------------------------------------- */
/* --- Pictures --- */
......
......@@ -27,10 +27,24 @@
#include <gst/vaapi/gstvaapidecoder.h>
#include <gst/vaapi/gstvaapidecoder_unit.h>
#include <gst/vaapi/gstvaapicontext.h>
#include "gstvaapiminiobject.h"
G_BEGIN_DECLS
#define GST_VAAPI_DECODER_CAST(decoder) ((GstVaapiDecoder *)(decoder))
#define GST_VAAPI_DECODER_CAST(decoder) \
((GstVaapiDecoder *)(decoder))
#define GST_VAAPI_DECODER_CLASS(klass) \
((GstVaapiDecoderClass *)(klass))
#define GST_VAAPI_IS_DECODER_CLASS(klass) \
((klass) != NULL))
#define GST_VAAPI_DECODER_GET_CLASS(obj) \
GST_VAAPI_DECODER_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(obj))
typedef struct _GstVaapiDecoderClass GstVaapiDecoderClass;
struct _GstVaapiDecoderUnit;
/**
* GST_VAAPI_PARSER_STATE:
......@@ -41,7 +55,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_PARSER_STATE
#define GST_VAAPI_PARSER_STATE(decoder) \
(&GST_VAAPI_DECODER_CAST(decoder)->priv->parser_state)
(&GST_VAAPI_DECODER_CAST(decoder)->parser_state)
/**
* GST_VAAPI_DECODER_DISPLAY:
......@@ -52,7 +66,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DECODER_DISPLAY
#define GST_VAAPI_DECODER_DISPLAY(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->display
GST_VAAPI_DECODER_CAST(decoder)->display
/**
* GST_VAAPI_DECODER_CONTEXT:
......@@ -63,7 +77,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DECODER_CONTEXT
#define GST_VAAPI_DECODER_CONTEXT(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->context
GST_VAAPI_DECODER_CAST(decoder)->context
/**
* GST_VAAPI_DECODER_CODEC:
......@@ -74,7 +88,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DECODER_CODEC
#define GST_VAAPI_DECODER_CODEC(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->codec
GST_VAAPI_DECODER_CAST(decoder)->codec
/**
* GST_VAAPI_DECODER_CODEC_STATE:
......@@ -86,7 +100,7 @@ G_BEGIN_DECLS
*/
#undef GST_VAAPI_DECODER_CODEC_STATE
#define GST_VAAPI_DECODER_CODEC_STATE(decoder) \
GST_VAAPI_DECODER_CAST(decoder)->priv->codec_state
GST_VAAPI_DECODER_CAST(decoder)->codec_state
/**
* GST_VAAPI_DECODER_CODEC_DATA:
......@@ -161,7 +175,16 @@ struct _GstVaapiParserState {
guint at_eos : 1;
};
struct _GstVaapiDecoderPrivate {
/**
* GstVaapiDecoder:
*
* A VA decoder base instance.
*/
struct _GstVaapiDecoder {
/*< private >*/
GstVaapiMiniObject parent_instance;
gpointer user_data;
GstVaapiDisplay *display;
VADisplay va_display;
GstVaapiContext *context;
......@@ -171,8 +194,43 @@ struct _GstVaapiDecoderPrivate {
GAsyncQueue *buffers;
GAsyncQueue *frames;
GstVaapiParserState parser_state;
GstVaapiDecoderStateChangedFunc codec_state_changed_func;
gpointer codec_state_changed_data;
};
/**
* GstVaapiDecoderClass:
*
* A VA decoder base class.
*/
struct _GstVaapiDecoderClass {
/*< private >*/
GstVaapiMiniObjectClass parent_class;
gboolean (*create)(GstVaapiDecoder *decoder);
void (*destroy)(GstVaapiDecoder *decoder);
GstVaapiDecoderStatus (*parse)(GstVaapiDecoder *decoder,
GstAdapter *adapter, gboolean at_eos,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*decode)(GstVaapiDecoder *decoder,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*start_frame)(GstVaapiDecoder *decoder,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*end_frame)(GstVaapiDecoder *decoder);
GstVaapiDecoderStatus (*flush)(GstVaapiDecoder *decoder);
GstVaapiDecoderStatus (*decode_codec_data)(GstVaapiDecoder *decoder,
const guchar *buf, guint buf_size);
};
G_GNUC_INTERNAL
GstVaapiDecoder *
gst_vaapi_decoder_new(const GstVaapiDecoderClass *klass,
GstVaapiDisplay *display, GstCaps *caps);
G_GNUC_INTERNAL
void
gst_vaapi_decoder_finalize(GstVaapiDecoder *decoder);
G_GNUC_INTERNAL
void
gst_vaapi_decoder_set_picture_size(
......
This diff is collapsed.
......@@ -27,58 +27,7 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_DECODER_VC1 \
(gst_vaapi_decoder_vc1_get_type())
#define GST_VAAPI_DECODER_VC1(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
GST_VAAPI_TYPE_DECODER_VC1, \
GstVaapiDecoderVC1))
#define GST_VAAPI_DECODER_VC1_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), \
GST_VAAPI_TYPE_DECODER_VC1, \
GstVaapiDecoderVC1Class))
#define GST_VAAPI_IS_DECODER_VC1(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_DECODER_VC1))
#define GST_VAAPI_IS_DECODER_VC1_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_DECODER_VC1))
#define GST_VAAPI_DECODER_VC1_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), \
GST_VAAPI_TYPE_DECODER_VC1, \
GstVaapiDecoderVC1Class))
typedef struct _GstVaapiDecoderVC1 GstVaapiDecoderVC1;
typedef struct _GstVaapiDecoderVC1Private GstVaapiDecoderVC1Private;
typedef struct _GstVaapiDecoderVC1Class GstVaapiDecoderVC1Class;
/**
* GstVaapiDecoderVC1:
*
* A decoder based on VC1.
*/
struct _GstVaapiDecoderVC1 {
/*< private >*/
GstVaapiDecoder parent_instance;
GstVaapiDecoderVC1Private *priv;
};
/**
* GstVaapiDecoderVC1Class:
*
* A decoder class based on VC1.
*/
struct _GstVaapiDecoderVC1Class {
/*< private >*/
GstVaapiDecoderClass parent_class;
};
GType
gst_vaapi_decoder_vc1_get_type(void) G_GNUC_CONST;
GstVaapiDecoder *
gst_vaapi_decoder_vc1_new(GstVaapiDisplay *display, GstCaps *caps);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment