mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
gstreamer-vaapi: drop use of GSlice allocator
Some code incorrectly relied on GstVideoDecoder/Encoder base class implementation details. Follow-up to !3695. Fixes #1742. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3783>
This commit is contained in:
parent
20d394cb21
commit
1c7003f95f
23 changed files with 54 additions and 53 deletions
|
@ -69,7 +69,7 @@ coded_buffer_free (GstVaapiCodedBuffer * buf)
|
|||
|
||||
gst_vaapi_display_replace (&GST_VAAPI_CODED_BUFFER_DISPLAY (buf), NULL);
|
||||
|
||||
g_slice_free1 (sizeof (GstVaapiCodedBuffer), buf);
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -126,7 +126,7 @@ gst_vaapi_coded_buffer_new (GstVaapiContext * context, guint buf_size)
|
|||
display = GST_VAAPI_CONTEXT_DISPLAY (context);
|
||||
g_return_val_if_fail (display != NULL, NULL);
|
||||
|
||||
buf = g_slice_new (GstVaapiCodedBuffer);
|
||||
buf = g_new (GstVaapiCodedBuffer, 1);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -500,7 +500,7 @@ gst_vaapi_context_new (GstVaapiDisplay * display,
|
|||
|| cip->entrypoint == GST_VAAPI_ENTRYPOINT_INVALID)
|
||||
return NULL;
|
||||
|
||||
context = g_slice_new (GstVaapiContext);
|
||||
context = g_new (GstVaapiContext, 1);
|
||||
if (!context)
|
||||
return NULL;
|
||||
|
||||
|
@ -783,6 +783,6 @@ gst_vaapi_context_unref (GstVaapiContext * context)
|
|||
context_destroy (context);
|
||||
context_destroy_surfaces (context);
|
||||
gst_vaapi_display_replace (&context->display, NULL);
|
||||
g_slice_free (GstVaapiContext, context);
|
||||
g_free (context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ decode_step (GstVaapiDecoder * decoder)
|
|||
|
||||
do {
|
||||
if (!ps->current_frame) {
|
||||
ps->current_frame = g_slice_new0 (GstVideoCodecFrame);
|
||||
ps->current_frame = g_new0 (GstVideoCodecFrame, 1);
|
||||
if (!ps->current_frame)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
ps->current_frame->ref_count = 1;
|
||||
|
@ -569,7 +569,7 @@ gst_vaapi_decoder_init (GstVaapiDecoder * decoder)
|
|||
|
||||
parser_state_init (&decoder->parser_state);
|
||||
|
||||
codec_state = g_slice_new0 (GstVideoCodecState);
|
||||
codec_state = g_new0 (GstVideoCodecState, 1);
|
||||
codec_state->ref_count = 1;
|
||||
gst_video_info_init (&codec_state->info);
|
||||
|
||||
|
|
|
@ -297,8 +297,9 @@ av1_decode_seqeunce (GstVaapiDecoderAV1 * decoder, GstVaapiDecoderUnit * unit)
|
|||
|
||||
/* update the sequence */
|
||||
if (priv->seq_header)
|
||||
g_slice_free (GstAV1SequenceHeaderOBU, priv->seq_header);
|
||||
priv->seq_header = g_slice_dup (GstAV1SequenceHeaderOBU, &pi->seq_header);
|
||||
g_free (priv->seq_header);
|
||||
priv->seq_header =
|
||||
g_memdup2 (&pi->seq_header, sizeof (GstAV1SequenceHeaderOBU));
|
||||
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -988,7 +989,7 @@ av1_decoder_reset (GstVaapiDecoderAV1 * decoder)
|
|||
gst_vaapi_picture_replace (&priv->current_picture, NULL);
|
||||
|
||||
if (priv->seq_header) {
|
||||
g_slice_free (GstAV1SequenceHeaderOBU, priv->seq_header);
|
||||
g_free (priv->seq_header);
|
||||
priv->seq_header = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1888,14 +1888,14 @@ reference_pic_free (GstVaapiEncoderH264 * encoder, GstVaapiEncoderH264Ref * ref)
|
|||
return;
|
||||
if (ref->pic)
|
||||
gst_vaapi_encoder_release_surface (GST_VAAPI_ENCODER (encoder), ref->pic);
|
||||
g_slice_free (GstVaapiEncoderH264Ref, ref);
|
||||
g_free (ref);
|
||||
}
|
||||
|
||||
static inline GstVaapiEncoderH264Ref *
|
||||
reference_pic_create (GstVaapiEncoderH264 * encoder,
|
||||
GstVaapiEncPicture * picture, GstVaapiSurfaceProxy * surface)
|
||||
{
|
||||
GstVaapiEncoderH264Ref *const ref = g_slice_new0 (GstVaapiEncoderH264Ref);
|
||||
GstVaapiEncoderH264Ref *const ref = g_new0 (GstVaapiEncoderH264Ref, 1);
|
||||
|
||||
ref->pic = surface;
|
||||
ref->frame_num = picture->frame_num;
|
||||
|
|
|
@ -1767,14 +1767,14 @@ reference_pic_free (GstVaapiEncoderH265 * encoder, GstVaapiEncoderH265Ref * ref)
|
|||
return;
|
||||
if (ref->pic)
|
||||
gst_vaapi_encoder_release_surface (GST_VAAPI_ENCODER (encoder), ref->pic);
|
||||
g_slice_free (GstVaapiEncoderH265Ref, ref);
|
||||
g_free (ref);
|
||||
}
|
||||
|
||||
static inline GstVaapiEncoderH265Ref *
|
||||
reference_pic_create (GstVaapiEncoderH265 * encoder,
|
||||
GstVaapiEncPicture * picture, GstVaapiSurfaceProxy * surface)
|
||||
{
|
||||
GstVaapiEncoderH265Ref *const ref = g_slice_new0 (GstVaapiEncoderH265Ref);
|
||||
GstVaapiEncoderH265Ref *const ref = g_new0 (GstVaapiEncoderH265Ref, 1);
|
||||
|
||||
ref->pic = surface;
|
||||
ref->poc = picture->poc;
|
||||
|
|
|
@ -538,7 +538,7 @@ static void
|
|||
op_data_free (GstVaapiFilterOpData * op_data)
|
||||
{
|
||||
g_free (op_data->va_caps);
|
||||
g_slice_free (GstVaapiFilterOpData, op_data);
|
||||
g_free (op_data);
|
||||
}
|
||||
|
||||
static inline gpointer
|
||||
|
@ -546,7 +546,7 @@ op_data_new (GstVaapiFilterOp op, GParamSpec * pspec)
|
|||
{
|
||||
GstVaapiFilterOpData *op_data;
|
||||
|
||||
op_data = g_slice_new0 (GstVaapiFilterOpData);
|
||||
op_data = g_new0 (GstVaapiFilterOpData, 1);
|
||||
if (!op_data)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ gst_vaapi_image_free (GstVaapiImage * image)
|
|||
|
||||
gst_vaapi_display_replace (&GST_VAAPI_IMAGE_DISPLAY (image), NULL);
|
||||
|
||||
g_slice_free1 (sizeof (GstVaapiImage), image);
|
||||
g_free (image);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -284,7 +284,7 @@ gst_vaapi_image_new (GstVaapiDisplay * display,
|
|||
GST_DEBUG ("format %s, size %ux%u", gst_vaapi_video_format_to_string (format),
|
||||
width, height);
|
||||
|
||||
image = g_slice_new (GstVaapiImage);
|
||||
image = g_new (GstVaapiImage, 1);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
|
@ -328,7 +328,7 @@ gst_vaapi_image_new_with_image (GstVaapiDisplay * display, VAImage * va_image)
|
|||
GST_FOURCC_ARGS (va_image->format.fourcc),
|
||||
va_image->width, va_image->height);
|
||||
|
||||
image = g_slice_new (GstVaapiImage);
|
||||
image = g_new (GstVaapiImage, 1);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ gst_vaapi_mini_object_free (GstVaapiMiniObject * object)
|
|||
klass->finalize (object);
|
||||
|
||||
if (G_LIKELY (g_atomic_int_dec_and_test (&object->ref_count)))
|
||||
g_slice_free1 (klass->size, object);
|
||||
g_free (object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ gst_vaapi_mini_object_new (const GstVaapiMiniObjectClass * object_class)
|
|||
|
||||
g_return_val_if_fail (object_class->size >= sizeof (*object), NULL);
|
||||
|
||||
object = g_slice_alloc (object_class->size);
|
||||
object = g_malloc (object_class->size);
|
||||
if (!object)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ gst_vaapi_subpicture_free (GstVaapiSubpicture * subpicture)
|
|||
{
|
||||
gst_vaapi_subpicture_free_image (subpicture);
|
||||
gst_vaapi_display_replace (&subpicture->display, NULL);
|
||||
g_slice_free1 (sizeof (GstVaapiSubpicture), subpicture);
|
||||
g_free (subpicture);
|
||||
}
|
||||
|
||||
GST_DEFINE_MINI_OBJECT_TYPE (GstVaapiSubpicture, gst_vaapi_subpicture);
|
||||
|
@ -142,7 +142,7 @@ gst_vaapi_subpicture_new (GstVaapiImage * image, guint flags)
|
|||
if (flags & ~va_flags)
|
||||
return NULL;
|
||||
|
||||
subpicture = g_slice_new (GstVaapiSubpicture);
|
||||
subpicture = g_new (GstVaapiSubpicture, 1);
|
||||
if (!subpicture)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ gst_vaapi_surface_free (GstVaapiSurface * surface)
|
|||
gst_vaapi_buffer_proxy_replace (&surface->extbuf_proxy, NULL);
|
||||
gst_vaapi_display_replace (&GST_VAAPI_SURFACE_DISPLAY (surface), NULL);
|
||||
|
||||
g_slice_free1 (sizeof (GstVaapiSurface), surface);
|
||||
g_free (surface);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -330,7 +330,7 @@ GST_DEFINE_MINI_OBJECT_TYPE (GstVaapiSurface, gst_vaapi_surface);
|
|||
static GstVaapiSurface *
|
||||
gst_vaapi_surface_create (GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiSurface *surface = g_slice_new (GstVaapiSurface);
|
||||
GstVaapiSurface *surface = g_new (GstVaapiSurface, 1);
|
||||
if (!surface)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ static void
|
|||
gst_vaapi_texture_free (GstVaapiTexture * texture)
|
||||
{
|
||||
gst_vaapi_display_replace (&GST_VAAPI_TEXTURE_DISPLAY (texture), NULL);
|
||||
g_slice_free1 (sizeof (GstVaapiTexture), texture);
|
||||
g_free (texture);
|
||||
}
|
||||
|
||||
GST_DEFINE_MINI_OBJECT_TYPE (GstVaapiTexture, gst_vaapi_texture);
|
||||
|
@ -100,7 +100,7 @@ gst_vaapi_texture_new_internal (GstVaapiDisplay * display, GstVaapiID id,
|
|||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
|
||||
texture = g_slice_alloc (sizeof (GstVaapiTexture));
|
||||
texture = g_new (GstVaapiTexture, 1);
|
||||
if (!texture)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ gst_vaapi_config_surface_attributes_get (GstVaapiDisplay * display,
|
|||
if (!surface_attribs)
|
||||
return NULL;
|
||||
|
||||
attribs = g_slice_new0 (GstVaapiConfigSurfaceAttributes);
|
||||
attribs = g_new0 (GstVaapiConfigSurfaceAttributes, 1);
|
||||
if (!attribs)
|
||||
goto error;
|
||||
|
||||
|
@ -223,5 +223,5 @@ gst_vaapi_config_surface_attributes_free (GstVaapiConfigSurfaceAttributes *
|
|||
|
||||
if (attribs->formats)
|
||||
g_array_unref (attribs->formats);
|
||||
g_slice_free (GstVaapiConfigSurfaceAttributes, attribs);
|
||||
g_free (attribs);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ frame_state_new (GstVaapiWindow * window)
|
|||
{
|
||||
FrameState *frame;
|
||||
|
||||
frame = g_slice_new (FrameState);
|
||||
frame = g_new (FrameState, 1);
|
||||
if (!frame)
|
||||
return NULL;
|
||||
|
||||
|
@ -160,7 +160,7 @@ frame_state_free (FrameState * frame)
|
|||
|
||||
g_clear_pointer (&frame->callback, wl_callback_destroy);
|
||||
wl_buffer_destroy (frame->buffer);
|
||||
g_slice_free (FrameState, frame);
|
||||
g_free (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -145,7 +145,7 @@ copy_video_codec_state (const GstVideoCodecState * in_state)
|
|||
|
||||
g_return_val_if_fail (in_state != NULL, NULL);
|
||||
|
||||
state = g_slice_new0 (GstVideoCodecState);
|
||||
state = g_new0 (GstVideoCodecState, 1);
|
||||
state->ref_count = 1;
|
||||
state->info = in_state->info;
|
||||
state->caps = gst_caps_copy (in_state->caps);
|
||||
|
|
|
@ -122,7 +122,7 @@ prop_value_free (PropValue * prop_value)
|
|||
g_param_spec_unref (prop_value->pspec);
|
||||
prop_value->pspec = NULL;
|
||||
}
|
||||
g_slice_free (PropValue, prop_value);
|
||||
g_free (prop_value);
|
||||
}
|
||||
|
||||
static PropValue *
|
||||
|
@ -133,7 +133,7 @@ prop_value_new_entry (guint id, GParamSpec * pspec, const GValue * value)
|
|||
if (!pspec)
|
||||
return NULL;
|
||||
|
||||
prop_value = g_slice_new0 (PropValue);
|
||||
prop_value = g_new0 (PropValue, 1);
|
||||
if (!prop_value)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ gst_vaapi_video_memory_new (GstAllocator * base_allocator,
|
|||
|
||||
g_return_val_if_fail (GST_VAAPI_IS_VIDEO_ALLOCATOR (allocator), NULL);
|
||||
|
||||
mem = g_slice_new (GstVaapiVideoMemory);
|
||||
mem = g_new (GstVaapiVideoMemory, 1);
|
||||
if (!mem)
|
||||
return NULL;
|
||||
|
||||
|
@ -620,7 +620,7 @@ gst_vaapi_video_allocator_free (GstAllocator * allocator, GstMemory * base_mem)
|
|||
gst_vaapi_surface_proxy_replace (&mem->proxy, NULL);
|
||||
gst_vaapi_video_meta_replace (&mem->meta, NULL);
|
||||
g_mutex_clear (&mem->lock);
|
||||
g_slice_free (GstVaapiVideoMemory, mem);
|
||||
g_free (mem);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -169,13 +169,13 @@ gst_vaapi_video_meta_init (GstVaapiVideoMeta * meta)
|
|||
static inline GstVaapiVideoMeta *
|
||||
_gst_vaapi_video_meta_create (void)
|
||||
{
|
||||
return g_slice_new (GstVaapiVideoMeta);
|
||||
return g_new (GstVaapiVideoMeta, 1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
_gst_vaapi_video_meta_destroy (GstVaapiVideoMeta * meta)
|
||||
{
|
||||
g_slice_free1 (sizeof (*meta), meta);
|
||||
g_free (meta);
|
||||
}
|
||||
|
||||
static inline GstVaapiVideoMeta *
|
||||
|
|
|
@ -126,7 +126,7 @@ meta_texture_free (GstVaapiVideoMetaTexture * meta)
|
|||
return;
|
||||
|
||||
gst_mini_object_replace ((GstMiniObject **) & meta->texture, NULL);
|
||||
g_slice_free (GstVaapiVideoMetaTexture, meta);
|
||||
g_free (meta);
|
||||
}
|
||||
|
||||
static GstVaapiVideoMetaTexture *
|
||||
|
@ -134,7 +134,7 @@ meta_texture_new (void)
|
|||
{
|
||||
GstVaapiVideoMetaTexture *meta;
|
||||
|
||||
meta = g_slice_new (GstVaapiVideoMetaTexture);
|
||||
meta = g_new (GstVaapiVideoMetaTexture, 1);
|
||||
if (!meta)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ codec_identifier_free (CodecIdentifier * cip)
|
|||
cip->file = NULL;
|
||||
}
|
||||
gst_caps_replace (&cip->caps, NULL);
|
||||
g_slice_free (CodecIdentifier, cip);
|
||||
g_free (cip);
|
||||
}
|
||||
|
||||
static CodecIdentifier *
|
||||
|
@ -144,7 +144,7 @@ codec_identifier_new (const gchar * filename)
|
|||
CodecIdentifier *cip;
|
||||
GstTypeFind *tfp;
|
||||
|
||||
cip = g_slice_new0 (CodecIdentifier);
|
||||
cip = g_new0 (CodecIdentifier, 1);
|
||||
if (!cip)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ typedef struct
|
|||
static inline RenderFrame *
|
||||
render_frame_new (void)
|
||||
{
|
||||
return g_slice_new (RenderFrame);
|
||||
return g_new (RenderFrame, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -119,7 +119,7 @@ render_frame_free (RenderFrame * rfp)
|
|||
if (G_UNLIKELY (!rfp))
|
||||
return;
|
||||
gst_vaapi_surface_proxy_replace (&rfp->proxy, NULL);
|
||||
g_slice_free (RenderFrame, rfp);
|
||||
g_free (rfp);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -536,7 +536,7 @@ app_free (App * app)
|
|||
g_cond_clear (&app->render_ready);
|
||||
g_cond_clear (&app->event_cond);
|
||||
g_mutex_clear (&app->mutex);
|
||||
g_slice_free (App, app);
|
||||
g_free (app);
|
||||
}
|
||||
|
||||
static App *
|
||||
|
@ -544,7 +544,7 @@ app_new (void)
|
|||
{
|
||||
App *app;
|
||||
|
||||
app = g_slice_new0 (App);
|
||||
app = g_new0 (App, 1);
|
||||
if (!app)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ new_codec_state (gint width, gint height, gint fps_n, gint fps_d)
|
|||
{
|
||||
GstVideoCodecState *state;
|
||||
|
||||
state = g_slice_new0 (GstVideoCodecState);
|
||||
state = g_new0 (GstVideoCodecState, 1);
|
||||
state->ref_count = 1;
|
||||
gst_video_info_set_format (&state->info, GST_VIDEO_FORMAT_ENCODED, width,
|
||||
height);
|
||||
|
@ -175,7 +175,7 @@ set_format (GstVaapiEncoder * encoder, gint width, gint height, gint fps_n,
|
|||
|
||||
in_state = new_codec_state (width, height, fps_n, fps_d);
|
||||
status = gst_vaapi_encoder_set_codec_state (encoder, in_state);
|
||||
g_slice_free (GstVideoCodecState, in_state);
|
||||
g_free (in_state);
|
||||
|
||||
return (status == GST_VAAPI_ENCODER_STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -308,13 +308,13 @@ app_free (App * app)
|
|||
if (app->output_file)
|
||||
fclose (app->output_file);
|
||||
|
||||
g_slice_free (App, app);
|
||||
g_free (app);
|
||||
}
|
||||
|
||||
static App *
|
||||
app_new (const gchar * input_fn, const gchar * output_fn)
|
||||
{
|
||||
App *app = g_slice_new0 (App);
|
||||
App *app = g_new0 (App, 1);
|
||||
if (!app)
|
||||
return NULL;
|
||||
|
||||
|
@ -362,7 +362,7 @@ upload_frame (GstVaapiEncoder * encoder, GstVaapiSurfaceProxy * proxy)
|
|||
GstVideoCodecFrame *frame;
|
||||
GstVaapiEncoderStatus ret;
|
||||
|
||||
frame = g_slice_new0 (GstVideoCodecFrame);
|
||||
frame = g_new0 (GstVideoCodecFrame, 1);
|
||||
gst_video_codec_frame_set_user_data (frame,
|
||||
gst_vaapi_surface_proxy_ref (proxy),
|
||||
(GDestroyNotify) gst_vaapi_surface_proxy_unref);
|
||||
|
|
|
@ -144,7 +144,7 @@ y4m_reader_open (const gchar * filename)
|
|||
{
|
||||
Y4MReader *imagefile;
|
||||
|
||||
imagefile = g_slice_new0 (Y4MReader);
|
||||
imagefile = g_new0 (Y4MReader, 1);
|
||||
|
||||
if (filename) {
|
||||
imagefile->fp = fopen (filename, "r");
|
||||
|
@ -165,7 +165,7 @@ bail:
|
|||
if (imagefile->fp && imagefile->fp != stdin)
|
||||
fclose (imagefile->fp);
|
||||
|
||||
g_slice_free (Y4MReader, imagefile);
|
||||
g_free (imagefile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ y4m_reader_close (Y4MReader * file)
|
|||
if (file->fp && file->fp != stdin)
|
||||
fclose (file->fp);
|
||||
|
||||
g_slice_free (Y4MReader, file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue