mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
codec: add helper macros to maintain object refcount.
Add gst_vaapi_mini_object_{ref,unref,replace}() helper macros so that to avoid explicit casts to GstVaapiMiniObject in all caller sites.
This commit is contained in:
parent
caf13671bb
commit
39dda15f5f
4 changed files with 32 additions and 40 deletions
|
@ -73,16 +73,17 @@ gst_vaapi_codec_object_new (const GstVaapiCodecObjectClass * object_class,
|
|||
GstVaapiCodecBase * codec, gconstpointer param, guint param_size,
|
||||
gconstpointer data, guint data_size, guint flags)
|
||||
{
|
||||
GstVaapiMiniObject *obj;
|
||||
GstVaapiCodecObject *va_obj;
|
||||
GstVaapiCodecObject *obj;
|
||||
GstVaapiCodecObjectConstructorArgs args;
|
||||
|
||||
obj = gst_vaapi_mini_object_new0 (&object_class->parent_class);
|
||||
obj =
|
||||
(GstVaapiCodecObject *)
|
||||
gst_vaapi_mini_object_new0 (GST_VAAPI_MINI_OBJECT_CLASS (object_class));
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
va_obj = GST_VAAPI_CODEC_OBJECT (obj);
|
||||
va_obj->codec = codec;
|
||||
obj = GST_VAAPI_CODEC_OBJECT (obj);
|
||||
obj->codec = codec;
|
||||
|
||||
args.param = param;
|
||||
args.param_size = param_size;
|
||||
|
@ -90,10 +91,10 @@ gst_vaapi_codec_object_new (const GstVaapiCodecObjectClass * object_class,
|
|||
args.data_size = data_size;
|
||||
args.flags = flags;
|
||||
|
||||
if (gst_vaapi_codec_object_create (va_obj, &args))
|
||||
return va_obj;
|
||||
if (gst_vaapi_codec_object_create (obj, &args))
|
||||
return obj;
|
||||
|
||||
gst_vaapi_mini_object_unref (obj);
|
||||
gst_vaapi_codec_object_unref (obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,16 @@ gst_vaapi_codec_object_new (const GstVaapiCodecObjectClass * object_class,
|
|||
GstVaapiCodecBase * codec, gconstpointer param, guint param_size,
|
||||
gconstpointer data, guint data_size, guint flags);
|
||||
|
||||
#define gst_vaapi_codec_object_ref(object) \
|
||||
((gpointer) gst_vaapi_mini_object_ref (GST_VAAPI_MINI_OBJECT (object)))
|
||||
|
||||
#define gst_vaapi_codec_object_unref(object) \
|
||||
gst_vaapi_mini_object_unref (GST_VAAPI_MINI_OBJECT (object))
|
||||
|
||||
#define gst_vaapi_codec_object_replace(old_object_ptr, new_object) \
|
||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) (old_object_ptr), \
|
||||
GST_VAAPI_MINI_OBJECT (new_object))
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- Inverse Quantization Matrices --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
|
|
@ -60,29 +60,17 @@ enum
|
|||
GST_VAAPI_CREATE_PICTURE_FLAG_FIELD = 1 << 1,
|
||||
};
|
||||
|
||||
static void
|
||||
destroy_slice_cb (gpointer data, gpointer user_data)
|
||||
{
|
||||
GstVaapiMiniObject *const object = data;
|
||||
|
||||
gst_vaapi_mini_object_unref (object);
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_picture_destroy (GstVaapiPicture * picture)
|
||||
{
|
||||
if (picture->slices) {
|
||||
g_ptr_array_foreach (picture->slices, destroy_slice_cb, NULL);
|
||||
g_ptr_array_free (picture->slices, TRUE);
|
||||
g_ptr_array_unref (picture->slices);
|
||||
picture->slices = NULL;
|
||||
}
|
||||
|
||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) & picture->iq_matrix,
|
||||
NULL);
|
||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) & picture->huf_table,
|
||||
NULL);
|
||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) & picture->bitplane,
|
||||
NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->iq_matrix, NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->huf_table, NULL);
|
||||
gst_vaapi_codec_object_replace (&picture->bitplane, NULL);
|
||||
|
||||
if (picture->proxy) {
|
||||
gst_vaapi_surface_proxy_unref (picture->proxy);
|
||||
|
@ -164,7 +152,8 @@ gst_vaapi_picture_create (GstVaapiPicture * picture,
|
|||
return FALSE;
|
||||
picture->param_size = args->param_size;
|
||||
|
||||
picture->slices = g_ptr_array_new ();
|
||||
picture->slices = g_ptr_array_new_with_free_func ((GDestroyNotify)
|
||||
gst_vaapi_mini_object_unref);
|
||||
if (!picture->slices)
|
||||
return FALSE;
|
||||
|
||||
|
@ -382,8 +371,7 @@ gst_vaapi_slice_destroy (GstVaapiSlice * slice)
|
|||
{
|
||||
VADisplay const va_display = GET_VA_DISPLAY (slice);
|
||||
|
||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) & slice->huf_table,
|
||||
NULL);
|
||||
gst_vaapi_codec_object_replace (&slice->huf_table, NULL);
|
||||
|
||||
vaapi_destroy_buffer (va_display, &slice->data_id);
|
||||
vaapi_destroy_buffer (va_display, &slice->param_id);
|
||||
|
|
|
@ -176,21 +176,14 @@ void
|
|||
gst_vaapi_picture_set_crop_rect (GstVaapiPicture * picture,
|
||||
const GstVaapiRectangle * crop_rect);
|
||||
|
||||
static inline gpointer
|
||||
gst_vaapi_picture_ref (gpointer ptr)
|
||||
{
|
||||
return gst_vaapi_mini_object_ref (GST_VAAPI_MINI_OBJECT (ptr));
|
||||
}
|
||||
#define gst_vaapi_picture_ref(picture) \
|
||||
gst_vaapi_codec_object_ref (picture)
|
||||
|
||||
static inline void
|
||||
gst_vaapi_picture_unref (gpointer ptr)
|
||||
{
|
||||
gst_vaapi_mini_object_unref (GST_VAAPI_MINI_OBJECT (ptr));
|
||||
}
|
||||
#define gst_vaapi_picture_unref(picture) \
|
||||
gst_vaapi_codec_object_unref (picture)
|
||||
|
||||
#define gst_vaapi_picture_replace(old_picture_p, new_picture) \
|
||||
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) (old_picture_p), \
|
||||
(GstVaapiMiniObject *) (new_picture))
|
||||
#define gst_vaapi_picture_replace(old_picture_ptr, new_picture) \
|
||||
gst_vaapi_codec_object_replace (old_picture_ptr, new_picture)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- Slices --- */
|
||||
|
|
Loading…
Reference in a new issue