codec: re-indent base codec objects.

This commit is contained in:
Gwenole Beauchesne 2014-01-09 09:10:21 +01:00
parent 231a067cdd
commit c010ce2340
2 changed files with 174 additions and 212 deletions

View file

@ -41,60 +41,60 @@
gst_vaapi_codec_object_get_class(object) gst_vaapi_codec_object_get_class(object)
const GstVaapiCodecObjectClass * const GstVaapiCodecObjectClass *
gst_vaapi_codec_object_get_class(GstVaapiCodecObject *object) gst_vaapi_codec_object_get_class (GstVaapiCodecObject * object)
{ {
return (const GstVaapiCodecObjectClass *) return (const GstVaapiCodecObjectClass *)
GST_VAAPI_MINI_OBJECT_GET_CLASS(object); GST_VAAPI_MINI_OBJECT_GET_CLASS (object);
} }
static gboolean static gboolean
gst_vaapi_codec_object_create(GstVaapiCodecObject *object, gst_vaapi_codec_object_create (GstVaapiCodecObject * object,
const GstVaapiCodecObjectConstructorArgs *args) const GstVaapiCodecObjectConstructorArgs * args)
{ {
const GstVaapiCodecObjectClass *klass; const GstVaapiCodecObjectClass *klass;
g_return_val_if_fail(args->param_size > 0, FALSE); g_return_val_if_fail (args->param_size > 0, FALSE);
if (GST_VAAPI_MINI_OBJECT_FLAG_IS_SET(object, if (GST_VAAPI_MINI_OBJECT_FLAG_IS_SET (object,
GST_VAAPI_CODEC_OBJECT_FLAG_CONSTRUCTED)) GST_VAAPI_CODEC_OBJECT_FLAG_CONSTRUCTED))
return TRUE;
klass = GST_VAAPI_CODEC_OBJECT_GET_CLASS(object);
if (!klass->create || !klass->create(object, args))
return FALSE;
GST_VAAPI_MINI_OBJECT_FLAG_SET(object,
GST_VAAPI_CODEC_OBJECT_FLAG_CONSTRUCTED);
return TRUE; return TRUE;
klass = GST_VAAPI_CODEC_OBJECT_GET_CLASS (object);
if (!klass->create || !klass->create (object, args))
return FALSE;
GST_VAAPI_MINI_OBJECT_FLAG_SET (object,
GST_VAAPI_CODEC_OBJECT_FLAG_CONSTRUCTED);
return TRUE;
} }
GstVaapiCodecObject * GstVaapiCodecObject *
gst_vaapi_codec_object_new(const GstVaapiCodecObjectClass *object_class, gst_vaapi_codec_object_new (const GstVaapiCodecObjectClass * object_class,
GstVaapiCodecBase *codec, gconstpointer param, guint param_size, GstVaapiCodecBase * codec, gconstpointer param, guint param_size,
gconstpointer data, guint data_size, guint flags) gconstpointer data, guint data_size, guint flags)
{ {
GstVaapiMiniObject *obj; GstVaapiMiniObject *obj;
GstVaapiCodecObject *va_obj; GstVaapiCodecObject *va_obj;
GstVaapiCodecObjectConstructorArgs args; GstVaapiCodecObjectConstructorArgs args;
obj = gst_vaapi_mini_object_new0(&object_class->parent_class); obj = gst_vaapi_mini_object_new0 (&object_class->parent_class);
if (!obj) if (!obj)
return NULL;
va_obj = GST_VAAPI_CODEC_OBJECT(obj);
va_obj->codec = codec;
args.param = param;
args.param_size = param_size;
args.data = data;
args.data_size = data_size;
args.flags = flags;
if (gst_vaapi_codec_object_create(va_obj, &args))
return va_obj;
gst_vaapi_mini_object_unref(obj);
return NULL; return NULL;
va_obj = GST_VAAPI_CODEC_OBJECT (obj);
va_obj->codec = codec;
args.param = param;
args.param_size = param_size;
args.data = data;
args.data_size = data_size;
args.flags = flags;
if (gst_vaapi_codec_object_create (va_obj, &args))
return va_obj;
gst_vaapi_mini_object_unref (obj);
return NULL;
} }
#define GET_DECODER(obj) GST_VAAPI_DECODER_CAST((obj)->parent_instance.codec) #define GET_DECODER(obj) GST_VAAPI_DECODER_CAST((obj)->parent_instance.codec)
@ -105,97 +105,73 @@ gst_vaapi_codec_object_new(const GstVaapiCodecObjectClass *object_class,
/* --- Inverse Quantization Matrices --- */ /* --- Inverse Quantization Matrices --- */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
GST_VAAPI_CODEC_DEFINE_TYPE(GstVaapiIqMatrix, gst_vaapi_iq_matrix); GST_VAAPI_CODEC_DEFINE_TYPE (GstVaapiIqMatrix, gst_vaapi_iq_matrix);
void void
gst_vaapi_iq_matrix_destroy(GstVaapiIqMatrix *iq_matrix) gst_vaapi_iq_matrix_destroy (GstVaapiIqMatrix * iq_matrix)
{ {
vaapi_destroy_buffer(GET_VA_DISPLAY(iq_matrix), &iq_matrix->param_id); vaapi_destroy_buffer (GET_VA_DISPLAY (iq_matrix), &iq_matrix->param_id);
iq_matrix->param = NULL; iq_matrix->param = NULL;
} }
gboolean gboolean
gst_vaapi_iq_matrix_create( gst_vaapi_iq_matrix_create (GstVaapiIqMatrix * iq_matrix,
GstVaapiIqMatrix *iq_matrix, const GstVaapiCodecObjectConstructorArgs * args)
const GstVaapiCodecObjectConstructorArgs *args
)
{ {
iq_matrix->param_id = VA_INVALID_ID; iq_matrix->param_id = VA_INVALID_ID;
return vaapi_create_buffer(GET_VA_DISPLAY(iq_matrix), return vaapi_create_buffer (GET_VA_DISPLAY (iq_matrix),
GET_VA_CONTEXT(iq_matrix), GET_VA_CONTEXT (iq_matrix), VAIQMatrixBufferType,
VAIQMatrixBufferType, args->param_size, args->param, &iq_matrix->param_id, &iq_matrix->param);
args->param_size,
args->param,
&iq_matrix->param_id,
&iq_matrix->param);
} }
GstVaapiIqMatrix * GstVaapiIqMatrix *
gst_vaapi_iq_matrix_new( gst_vaapi_iq_matrix_new (GstVaapiDecoder * decoder,
GstVaapiDecoder *decoder, gconstpointer param, guint param_size)
gconstpointer param,
guint param_size
)
{ {
GstVaapiCodecObject *object; GstVaapiCodecObject *object;
object = gst_vaapi_codec_object_new( object = gst_vaapi_codec_object_new (&GstVaapiIqMatrixClass,
&GstVaapiIqMatrixClass, GST_VAAPI_CODEC_BASE (decoder), param, param_size, NULL, 0, 0);
GST_VAAPI_CODEC_BASE(decoder), if (!object)
param, param_size, return NULL;
NULL, 0, return GST_VAAPI_IQ_MATRIX_CAST (object);
0
);
if (!object)
return NULL;
return GST_VAAPI_IQ_MATRIX_CAST(object);
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* --- VC-1 Bit Planes --- */ /* --- VC-1 Bit Planes --- */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
GST_VAAPI_CODEC_DEFINE_TYPE(GstVaapiBitPlane, gst_vaapi_bitplane); GST_VAAPI_CODEC_DEFINE_TYPE (GstVaapiBitPlane, gst_vaapi_bitplane);
void void
gst_vaapi_bitplane_destroy(GstVaapiBitPlane *bitplane) gst_vaapi_bitplane_destroy (GstVaapiBitPlane * bitplane)
{ {
vaapi_destroy_buffer(GET_VA_DISPLAY(bitplane), &bitplane->data_id); vaapi_destroy_buffer (GET_VA_DISPLAY (bitplane), &bitplane->data_id);
bitplane->data = NULL; bitplane->data = NULL;
} }
gboolean gboolean
gst_vaapi_bitplane_create( gst_vaapi_bitplane_create (GstVaapiBitPlane * bitplane,
GstVaapiBitPlane *bitplane, const GstVaapiCodecObjectConstructorArgs * args)
const GstVaapiCodecObjectConstructorArgs *args
)
{ {
bitplane->data_id = VA_INVALID_ID; bitplane->data_id = VA_INVALID_ID;
return vaapi_create_buffer(GET_VA_DISPLAY(bitplane), return vaapi_create_buffer (GET_VA_DISPLAY (bitplane),
GET_VA_CONTEXT(bitplane), GET_VA_CONTEXT (bitplane), VABitPlaneBufferType, args->param_size,
VABitPlaneBufferType, args->param, &bitplane->data_id, (void **) &bitplane->data);
args->param_size,
args->param,
&bitplane->data_id,
(void **)&bitplane->data);
} }
GstVaapiBitPlane * GstVaapiBitPlane *
gst_vaapi_bitplane_new(GstVaapiDecoder *decoder, guint8 *data, guint data_size) gst_vaapi_bitplane_new (GstVaapiDecoder * decoder, guint8 * data,
guint data_size)
{ {
GstVaapiCodecObject *object; GstVaapiCodecObject *object;
object = gst_vaapi_codec_object_new( object = gst_vaapi_codec_object_new (&GstVaapiBitPlaneClass,
&GstVaapiBitPlaneClass, GST_VAAPI_CODEC_BASE (decoder), data, data_size, NULL, 0, 0);
GST_VAAPI_CODEC_BASE(decoder), if (!object)
data, data_size, return NULL;
NULL, 0, return GST_VAAPI_BITPLANE_CAST (object);
0
);
if (!object)
return NULL;
return GST_VAAPI_BITPLANE_CAST(object);
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
@ -203,49 +179,35 @@ gst_vaapi_bitplane_new(GstVaapiDecoder *decoder, guint8 *data, guint data_size)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#if USE_JPEG_DECODER #if USE_JPEG_DECODER
GST_VAAPI_CODEC_DEFINE_TYPE(GstVaapiHuffmanTable, gst_vaapi_huffman_table); GST_VAAPI_CODEC_DEFINE_TYPE (GstVaapiHuffmanTable, gst_vaapi_huffman_table);
void void
gst_vaapi_huffman_table_destroy(GstVaapiHuffmanTable *huf_table) gst_vaapi_huffman_table_destroy (GstVaapiHuffmanTable * huf_table)
{ {
vaapi_destroy_buffer(GET_VA_DISPLAY(huf_table), &huf_table->param_id); vaapi_destroy_buffer (GET_VA_DISPLAY (huf_table), &huf_table->param_id);
huf_table->param = NULL; huf_table->param = NULL;
} }
gboolean gboolean
gst_vaapi_huffman_table_create( gst_vaapi_huffman_table_create (GstVaapiHuffmanTable * huf_table,
GstVaapiHuffmanTable *huf_table, const GstVaapiCodecObjectConstructorArgs * args)
const GstVaapiCodecObjectConstructorArgs *args
)
{ {
huf_table->param_id = VA_INVALID_ID; huf_table->param_id = VA_INVALID_ID;
return vaapi_create_buffer(GET_VA_DISPLAY(huf_table), return vaapi_create_buffer (GET_VA_DISPLAY (huf_table),
GET_VA_CONTEXT(huf_table), GET_VA_CONTEXT (huf_table), VAHuffmanTableBufferType, args->param_size,
VAHuffmanTableBufferType, args->param, &huf_table->param_id, (void **) &huf_table->param);
args->param_size,
args->param,
&huf_table->param_id,
(void **)&huf_table->param);
} }
GstVaapiHuffmanTable * GstVaapiHuffmanTable *
gst_vaapi_huffman_table_new( gst_vaapi_huffman_table_new (GstVaapiDecoder * decoder,
GstVaapiDecoder *decoder, guint8 * data, guint data_size)
guint8 *data,
guint data_size
)
{ {
GstVaapiCodecObject *object; GstVaapiCodecObject *object;
object = gst_vaapi_codec_object_new( object = gst_vaapi_codec_object_new (&GstVaapiHuffmanTableClass,
&GstVaapiHuffmanTableClass, GST_VAAPI_CODEC_BASE (decoder), data, data_size, NULL, 0, 0);
GST_VAAPI_CODEC_BASE(decoder), if (!object)
data, data_size, return NULL;
NULL, 0, return GST_VAAPI_HUFFMAN_TABLE_CAST (object);
0
);
if (!object)
return NULL;
return GST_VAAPI_HUFFMAN_TABLE_CAST(object);
} }
#endif #endif

View file

@ -43,27 +43,29 @@ typedef struct _GstVaapiHuffmanTable GstVaapiHuffmanTable;
/* XXX: remove when a common base class for decoder and encoder is available */ /* XXX: remove when a common base class for decoder and encoder is available */
#define GST_VAAPI_CODEC_BASE(obj) \ #define GST_VAAPI_CODEC_BASE(obj) \
((GstVaapiCodecBase *)(obj)) ((GstVaapiCodecBase *) (obj))
#define GST_VAAPI_CODEC_OBJECT(obj) \ #define GST_VAAPI_CODEC_OBJECT(obj) \
((GstVaapiCodecObject *)(obj)) ((GstVaapiCodecObject *) (obj))
enum { enum
GST_VAAPI_CODEC_OBJECT_FLAG_CONSTRUCTED = (1 << 0), {
GST_VAAPI_CODEC_OBJECT_FLAG_LAST = (1 << 1) GST_VAAPI_CODEC_OBJECT_FLAG_CONSTRUCTED = (1 << 0),
GST_VAAPI_CODEC_OBJECT_FLAG_LAST = (1 << 1)
}; };
typedef struct { typedef struct
gconstpointer param; {
guint param_size; gconstpointer param;
gconstpointer data; guint param_size;
guint data_size; gconstpointer data;
guint flags; guint data_size;
guint flags;
} GstVaapiCodecObjectConstructorArgs; } GstVaapiCodecObjectConstructorArgs;
typedef gboolean typedef gboolean
(*GstVaapiCodecObjectCreateFunc)(GstVaapiCodecObject *object, (*GstVaapiCodecObjectCreateFunc)(GstVaapiCodecObject * object,
const GstVaapiCodecObjectConstructorArgs *args); const GstVaapiCodecObjectConstructorArgs * args);
typedef GDestroyNotify GstVaapiCodecObjectDestroyFunc; typedef GDestroyNotify GstVaapiCodecObjectDestroyFunc;
@ -72,10 +74,11 @@ typedef GDestroyNotify GstVaapiCodecObjectDestroyFunc;
* *
* A #GstVaapiMiniObject holding the base codec object data * A #GstVaapiMiniObject holding the base codec object data
*/ */
struct _GstVaapiCodecObject { struct _GstVaapiCodecObject
/*< private >*/ {
GstVaapiMiniObject parent_instance; /*< private >*/
GstVaapiCodecBase *codec; GstVaapiMiniObject parent_instance;
GstVaapiCodecBase *codec;
}; };
/** /**
@ -83,21 +86,22 @@ struct _GstVaapiCodecObject {
* *
* The #GstVaapiCodecObject base class. * The #GstVaapiCodecObject base class.
*/ */
struct _GstVaapiCodecObjectClass { struct _GstVaapiCodecObjectClass
/*< private >*/ {
GstVaapiMiniObjectClass parent_class; /*< private >*/
GstVaapiMiniObjectClass parent_class;
GstVaapiCodecObjectCreateFunc create; GstVaapiCodecObjectCreateFunc create;
}; };
G_GNUC_INTERNAL G_GNUC_INTERNAL
const GstVaapiCodecObjectClass * const GstVaapiCodecObjectClass *
gst_vaapi_codec_object_get_class(GstVaapiCodecObject *object) G_GNUC_CONST; gst_vaapi_codec_object_get_class (GstVaapiCodecObject * object) G_GNUC_CONST;
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiCodecObject * GstVaapiCodecObject *
gst_vaapi_codec_object_new(const GstVaapiCodecObjectClass *object_class, gst_vaapi_codec_object_new (const GstVaapiCodecObjectClass * object_class,
GstVaapiCodecBase *codec, gconstpointer param, guint param_size, GstVaapiCodecBase * codec, gconstpointer param, guint param_size,
gconstpointer data, guint data_size, guint flags); gconstpointer data, guint data_size, guint flags);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
@ -105,120 +109,116 @@ gst_vaapi_codec_object_new(const GstVaapiCodecObjectClass *object_class,
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#define GST_VAAPI_IQ_MATRIX_CAST(obj) \ #define GST_VAAPI_IQ_MATRIX_CAST(obj) \
((GstVaapiIqMatrix *)(obj)) ((GstVaapiIqMatrix *) (obj))
/** /**
* GstVaapiIqMatrix: * GstVaapiIqMatrix:
* *
* A #GstVaapiCodecObject holding an inverse quantization matrix parameter. * A #GstVaapiCodecObject holding an inverse quantization matrix parameter.
*/ */
struct _GstVaapiIqMatrix { struct _GstVaapiIqMatrix
/*< private >*/ {
GstVaapiCodecObject parent_instance; /*< private >*/
VABufferID param_id; GstVaapiCodecObject parent_instance;
VABufferID param_id;
/*< public >*/ /*< public >*/
gpointer param; gpointer param;
}; };
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiIqMatrix * GstVaapiIqMatrix *
gst_vaapi_iq_matrix_new( gst_vaapi_iq_matrix_new (GstVaapiDecoder * decoder, gconstpointer param,
GstVaapiDecoder *decoder, guint param_size);
gconstpointer param,
guint param_size
);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* --- VC-1 Bit Planes --- */ /* --- VC-1 Bit Planes --- */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#define GST_VAAPI_BITPLANE_CAST(obj) \ #define GST_VAAPI_BITPLANE_CAST(obj) \
((GstVaapiBitPlane *)(obj)) ((GstVaapiBitPlane *) (obj))
/** /**
* GstVaapiBitPlane: * GstVaapiBitPlane:
* *
* A #GstVaapiCodecObject holding a VC-1 bit plane parameter. * A #GstVaapiCodecObject holding a VC-1 bit plane parameter.
*/ */
struct _GstVaapiBitPlane { struct _GstVaapiBitPlane
/*< private >*/ {
GstVaapiCodecObject parent_instance; /*< private >*/
VABufferID data_id; GstVaapiCodecObject parent_instance;
VABufferID data_id;
/*< public >*/ /*< public >*/
guint8 *data; guint8 *data;
}; };
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiBitPlane * GstVaapiBitPlane *
gst_vaapi_bitplane_new(GstVaapiDecoder *decoder, guint8 *data, guint data_size); gst_vaapi_bitplane_new (GstVaapiDecoder * decoder, guint8 * data,
guint data_size);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* --- JPEG Huffman Tables --- */ /* --- JPEG Huffman Tables --- */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#define GST_VAAPI_HUFFMAN_TABLE_CAST(obj) \ #define GST_VAAPI_HUFFMAN_TABLE_CAST(obj) \
((GstVaapiHuffmanTable *)(obj)) ((GstVaapiHuffmanTable *) (obj))
/** /**
* GstVaapiHuffmanTable: * GstVaapiHuffmanTable:
* *
* A #GstVaapiCodecObject holding huffman table. * A #GstVaapiCodecObject holding huffman table.
*/ */
struct _GstVaapiHuffmanTable { struct _GstVaapiHuffmanTable
/*< private >*/ {
GstVaapiCodecObject parent_instance; /*< private >*/
VABufferID param_id; GstVaapiCodecObject parent_instance;
VABufferID param_id;
/*< public >*/ /*< public >*/
gpointer param; gpointer param;
}; };
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiHuffmanTable * GstVaapiHuffmanTable *
gst_vaapi_huffman_table_new( gst_vaapi_huffman_table_new (GstVaapiDecoder * decoder, guint8 * data,
GstVaapiDecoder *decoder, guint data_size);
guint8 *data,
guint data_size
);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* --- Helpers to create codec-dependent objects --- */ /* --- Helpers to create codec-dependent objects --- */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
#define GST_VAAPI_CODEC_DEFINE_TYPE(type, prefix) \ #define GST_VAAPI_CODEC_DEFINE_TYPE(type, prefix) \
G_GNUC_INTERNAL \ G_GNUC_INTERNAL \
void \ void \
prefix##_destroy(type *); \ G_PASTE (prefix, _destroy) (type *); \
\ \
G_GNUC_INTERNAL \ G_GNUC_INTERNAL \
gboolean \ gboolean \
prefix##_create( \ G_PASTE (prefix, _create) (type *, \
type *, \ const GstVaapiCodecObjectConstructorArgs * args); \
const GstVaapiCodecObjectConstructorArgs *args \ \
); \ static const GstVaapiCodecObjectClass G_PASTE (type, Class) = { \
\ .parent_class = { \
static const GstVaapiCodecObjectClass type##Class = { \ .size = sizeof (type), \
.parent_class = { \ .finalize = (GstVaapiCodecObjectDestroyFunc) \
.size = sizeof(type), \ G_PASTE (prefix, _destroy) \
.finalize = (GstVaapiCodecObjectDestroyFunc) \ }, \
prefix##_destroy \ .create = (GstVaapiCodecObjectCreateFunc) \
}, \ G_PASTE (prefix, _create), \
.create = (GstVaapiCodecObjectCreateFunc) \
prefix##_create, \
} }
#define GST_VAAPI_IQ_MATRIX_NEW(codec, decoder) \ #define GST_VAAPI_IQ_MATRIX_NEW(codec, decoder) \
gst_vaapi_iq_matrix_new(GST_VAAPI_DECODER_CAST(decoder), \ gst_vaapi_iq_matrix_new (GST_VAAPI_DECODER_CAST (decoder), \
NULL, sizeof(VAIQMatrixBuffer##codec)) NULL, sizeof (G_PASTE (VAIQMatrixBuffer, codec)))
#define GST_VAAPI_BITPLANE_NEW(decoder, size) \ #define GST_VAAPI_BITPLANE_NEW(decoder, size) \
gst_vaapi_bitplane_new(GST_VAAPI_DECODER_CAST(decoder), NULL, size) gst_vaapi_bitplane_new (GST_VAAPI_DECODER_CAST (decoder), NULL, size)
#define GST_VAAPI_HUFFMAN_TABLE_NEW(codec, decoder) \ #define GST_VAAPI_HUFFMAN_TABLE_NEW(codec, decoder) \
gst_vaapi_huffman_table_new(GST_VAAPI_DECODER_CAST(decoder), \ gst_vaapi_huffman_table_new (GST_VAAPI_DECODER_CAST (decoder), \
NULL, sizeof(VAHuffmanTableBuffer##codec)) NULL, sizeof (G_PASTE (VAHuffmanTableBuffer, codec)))
G_END_DECLS G_END_DECLS