decoder: decoder units are no longer dynamically allocated objects.

This commit is contained in:
Gwenole Beauchesne 2013-01-07 14:04:22 +01:00
parent a486d1af66
commit 8c403c2d98
2 changed files with 44 additions and 68 deletions

View file

@ -27,16 +27,6 @@
#include "sysdeps.h"
#include "gstvaapidecoder_unit.h"
static inline const GstVaapiMiniObjectClass *
gst_vaapi_decoder_unit_class(void)
{
static const GstVaapiMiniObjectClass GstVaapiDecoderUnitClass = {
sizeof(GstVaapiDecoderUnit),
(GDestroyNotify)gst_vaapi_decoder_unit_clear
};
return &GstVaapiDecoderUnitClass;
}
/**
* gst_vaapi_decoder_unit_init:
* @unit: a #GstVaapiDecoderUnit
@ -46,23 +36,16 @@ gst_vaapi_decoder_unit_class(void)
* @note This is an internal function used to implement lightweight
* sub-classes.
*/
static inline void
decoder_unit_init(GstVaapiDecoderUnit *unit)
void
gst_vaapi_decoder_unit_init(GstVaapiDecoderUnit *unit)
{
unit->flags = 0;
unit->size = 0;
unit->offset = 0;
unit->buffer = NULL;
unit->parsed_info = NULL;
unit->parsed_info_destroy_notify = NULL;
GST_VAAPI_DECODER_UNIT_FLAGS(unit) = 0;
}
void
gst_vaapi_decoder_unit_init(GstVaapiDecoderUnit *unit)
{
decoder_unit_init(unit);
}
/**
@ -75,39 +58,11 @@ gst_vaapi_decoder_unit_init(GstVaapiDecoderUnit *unit)
* @note This is an internal function used to implement lightweight
* sub-classes.
*/
static inline void
decoder_unit_clear(GstVaapiDecoderUnit *unit)
{
gst_buffer_replace(&unit->buffer, NULL);
gst_vaapi_decoder_unit_set_parsed_info(unit, NULL, NULL);
}
void
gst_vaapi_decoder_unit_clear(GstVaapiDecoderUnit *unit)
{
decoder_unit_clear(unit);
}
/**
* gst_vaapi_decoder_unit_new:
* @size: size in bytes of this bitstream data chunk
*
* Creates a new #GstVaapiDecoderUnit object.
*
* Returns: The newly allocated #GstVaapiDecoderUnit
*/
GstVaapiDecoderUnit *
gst_vaapi_decoder_unit_new(void)
{
GstVaapiDecoderUnit *unit;
unit = (GstVaapiDecoderUnit *)
gst_vaapi_mini_object_new(gst_vaapi_decoder_unit_class());
if (!unit)
return NULL;
decoder_unit_init(unit);
return unit;
gst_buffer_replace(&unit->buffer, NULL);
gst_vaapi_decoder_unit_set_parsed_info(unit, NULL, NULL);
}
/**

View file

@ -23,7 +23,6 @@
#define GST_VAAPI_DECODER_UNIT_H
#include <gst/gstbuffer.h>
#include <gst/vaapi/gstvaapiminiobject.h>
G_BEGIN_DECLS
@ -54,10 +53,44 @@ typedef enum {
GST_VAAPI_DECODER_UNIT_FLAG_LAST = (1 << 5)
} GstVaapiDecoderUnitFlags;
#define GST_VAAPI_DECODER_UNIT_FLAGS GST_VAAPI_MINI_OBJECT_FLAGS
#define GST_VAAPI_DECODER_UNIT_FLAG_IS_SET GST_VAAPI_MINI_OBJECT_FLAG_IS_SET
#define GST_VAAPI_DECODER_UNIT_FLAG_SET GST_VAAPI_MINI_OBJECT_FLAG_SET
#define GST_VAAPI_DECODER_UNIT_FLAG_UNSET GST_VAAPI_MINI_OBJECT_FLAG_UNSET
/**
* GST_VAAPI_DECODER_UNIT_FLAGS:
* @unit: a #GstVaapiDecoderUnit
*
* The entire set of flags for the @unit
*/
#define GST_VAAPI_DECODER_UNIT_FLAGS(unit) \
((unit)->flags)
/**
* GST_VAAPI_DECODER_UNIT_FLAG_IS_SET:
* @unit: a #GstVaapiDecoderUnit
* @flag: a flag to check for
*
* Checks whether the given @flag is set
*/
#define GST_VAAPI_DECODER_UNIT_FLAG_IS_SET(unit, flag) \
((GST_VAAPI_DECODER_UNIT_FLAGS(unit) & (flag)) != 0)
/**
* GST_VAAPI_DECODER_UNIT_FLAG_SET:
* @unit: a #GstVaapiDecoderUnit
* @flags: flags to set
*
* This macro sets the given bits
*/
#define GST_VAAPI_DECODER_UNIT_FLAG_SET(unit, flags) \
(GST_VAAPI_DECODER_UNIT_FLAGS(unit) |= (flags))
/**
* GST_VAAPI_DECODER_UNIT_FLAG_UNSET:
* @unit: a #GstVaapiDecoderUnit
* @flags: flags to unset
*
* This macro unsets the given bits.
*/
#define GST_VAAPI_DECODER_UNIT_FLAG_UNSET(unit, flags) \
(GST_VAAPI_DECODER_UNIT_FLAGS(unit) &= ~(flags))
/**
* GST_VAAPI_DECODER_UNIT_IS_FRAME_START:
@ -129,9 +162,7 @@ typedef enum {
* A chunk of bitstream data that was parsed.
*/
struct _GstVaapiDecoderUnit {
/*< private >*/
GstVaapiMiniObject parent_instance;
guint flags;
guint size;
guint offset;
GstBuffer *buffer;
@ -160,16 +191,6 @@ void
gst_vaapi_decoder_unit_set_parsed_info(GstVaapiDecoderUnit *unit,
gpointer parsed_info, GDestroyNotify destroy_notify);
#define gst_vaapi_decoder_unit_ref(unit) \
gst_vaapi_mini_object_ref(GST_VAAPI_MINI_OBJECT(unit))
#define gst_vaapi_decoder_unit_unref(unit) \
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(unit))
#define gst_vaapi_decoder_unit_replace(old_unit_p, new_unit) \
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)(old_unit_p), \
(GstVaapiMiniObject *)(new_unit))
G_END_DECLS
#endif /* GST_VAAPI_DECODER_UNIT_H */