libs: video: drop use of GSlice

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
This commit is contained in:
Tim-Philipp Müller 2023-01-08 17:10:57 +00:00 committed by GStreamer Marge Bot
parent df83590008
commit d56648ccdb
10 changed files with 49 additions and 47 deletions

View file

@ -498,7 +498,7 @@ gst_video_convert_frame_context_unref (GstVideoConvertSampleContext * ctx)
* must not end up here without finish() being called */
g_warn_if_fail (ctx->pipeline == NULL);
g_slice_free (GstVideoConvertSampleContext, ctx);
g_free (ctx);
}
static gboolean
@ -757,7 +757,7 @@ gst_video_convert_sample_async (GstSample * sample,
/* There's a reference cycle between the context and the pipeline, which is
* broken up once the finish() is called on the context. At latest when the
* timeout triggers the context will be freed */
ctx = g_slice_new0 (GstVideoConvertSampleContext);
ctx = g_new0 (GstVideoConvertSampleContext, 1);
ctx->ref_count = 1;
g_mutex_init (&ctx->mutex);
ctx->sample = gst_sample_ref (sample);

View file

@ -792,7 +792,7 @@ _new_input_state (GstCaps * caps)
GstStructure *structure;
const GValue *codec_data;
state = g_slice_new0 (GstVideoCodecState);
state = g_new0 (GstVideoCodecState, 1);
state->ref_count = 1;
gst_video_info_init (&state->info);
if (G_UNLIKELY (!gst_video_info_from_caps (&state->info, caps)))
@ -809,7 +809,7 @@ _new_input_state (GstCaps * caps)
parse_fail:
{
g_slice_free (GstVideoCodecState, state);
g_free (state);
return NULL;
}
}
@ -821,12 +821,12 @@ _new_output_state (GstVideoFormat fmt, GstVideoInterlaceMode interlace_mode,
{
GstVideoCodecState *state;
state = g_slice_new0 (GstVideoCodecState);
state = g_new0 (GstVideoCodecState, 1);
state->ref_count = 1;
gst_video_info_init (&state->info);
if (!gst_video_info_set_interlaced_format (&state->info, fmt, interlace_mode,
width, height)) {
g_slice_free (GstVideoCodecState, state);
g_free (state);
return NULL;
}
@ -2200,7 +2200,7 @@ struct _Timestamp
static void
timestamp_free (Timestamp * ts)
{
g_slice_free (Timestamp, ts);
g_free (ts);
}
static void
@ -2219,7 +2219,7 @@ gst_video_decoder_add_buffer_info (GstVideoDecoder * decoder,
return;
}
ts = g_slice_new (Timestamp);
ts = g_new (Timestamp, 1);
GST_LOG_OBJECT (decoder,
"adding PTS %" GST_TIME_FORMAT " DTS %" GST_TIME_FORMAT
@ -2933,7 +2933,7 @@ gst_video_decoder_new_frame (GstVideoDecoder * decoder)
GstVideoDecoderPrivate *priv = decoder->priv;
GstVideoCodecFrame *frame;
frame = g_slice_new0 (GstVideoCodecFrame);
frame = g_new0 (GstVideoCodecFrame, 1);
frame->ref_count = 1;

View file

@ -198,14 +198,14 @@ struct _ForcedKeyUnitEvent
static void
forced_key_unit_event_free (ForcedKeyUnitEvent * evt)
{
g_slice_free (ForcedKeyUnitEvent, evt);
g_free (evt);
}
static ForcedKeyUnitEvent *
forced_key_unit_event_new (GstClockTime running_time, gboolean all_headers,
guint count)
{
ForcedKeyUnitEvent *evt = g_slice_new0 (ForcedKeyUnitEvent);
ForcedKeyUnitEvent *evt = g_new0 (ForcedKeyUnitEvent, 1);
evt->running_time = running_time;
evt->all_headers = all_headers;
@ -634,12 +634,12 @@ _new_output_state (GstCaps * caps, GstVideoCodecState * reference)
{
GstVideoCodecState *state;
state = g_slice_new0 (GstVideoCodecState);
state = g_new0 (GstVideoCodecState, 1);
state->ref_count = 1;
gst_video_info_init (&state->info);
if (!gst_video_info_set_format (&state->info, GST_VIDEO_FORMAT_ENCODED, 0, 0)) {
g_slice_free (GstVideoCodecState, state);
g_free (state);
return NULL;
}
@ -669,12 +669,14 @@ _new_output_state (GstCaps * caps, GstVideoCodecState * reference)
GST_VIDEO_INFO_MULTIVIEW_FLAGS (tgt) = GST_VIDEO_INFO_MULTIVIEW_FLAGS (ref);
if (reference->mastering_display_info) {
state->mastering_display_info = g_slice_dup (GstVideoMasteringDisplayInfo,
reference->mastering_display_info);
state->mastering_display_info =
g_memdup2 (reference->mastering_display_info,
sizeof (GstVideoMasteringDisplayInfo));
}
if (reference->content_light_level) {
state->content_light_level = g_slice_dup (GstVideoContentLightLevel,
reference->content_light_level);
state->content_light_level =
g_memdup2 (reference->content_light_level,
sizeof (GstVideoContentLightLevel));
}
}
@ -688,7 +690,7 @@ _new_input_state (GstCaps * caps)
GstStructure *c_struct;
const gchar *s;
state = g_slice_new0 (GstVideoCodecState);
state = g_new0 (GstVideoCodecState, 1);
state->ref_count = 1;
gst_video_info_init (&state->info);
if (G_UNLIKELY (!gst_video_info_from_caps (&state->info, caps)))
@ -698,12 +700,12 @@ _new_input_state (GstCaps * caps)
c_struct = gst_caps_get_structure (caps, 0);
if ((s = gst_structure_get_string (c_struct, "mastering-display-info"))) {
state->mastering_display_info = g_slice_new (GstVideoMasteringDisplayInfo);
state->mastering_display_info = g_new (GstVideoMasteringDisplayInfo, 1);
gst_video_mastering_display_info_from_string (state->mastering_display_info,
s);
}
if ((s = gst_structure_get_string (c_struct, "content-light-level"))) {
state->content_light_level = g_slice_new (GstVideoContentLightLevel);
state->content_light_level = g_new (GstVideoContentLightLevel, 1);
gst_video_content_light_level_from_string (state->content_light_level, s);
}
@ -711,7 +713,7 @@ _new_input_state (GstCaps * caps)
parse_fail:
{
g_slice_free (GstVideoCodecState, state);
g_free (state);
return NULL;
}
}
@ -1495,7 +1497,7 @@ gst_video_encoder_new_frame (GstVideoEncoder * encoder, GstBuffer * buf,
GstVideoEncoderPrivate *priv = encoder->priv;
GstVideoCodecFrame *frame;
frame = g_slice_new0 (GstVideoCodecFrame);
frame = g_new0 (GstVideoCodecFrame, 1);
frame->ref_count = 1;

View file

@ -58,7 +58,7 @@ _gst_video_codec_frame_free (GstVideoCodecFrame * frame)
if (frame->user_data_destroy_notify)
frame->user_data_destroy_notify (frame->user_data);
g_slice_free (GstVideoCodecFrame, frame);
g_free (frame);
}
/**
@ -172,10 +172,10 @@ _gst_video_codec_state_free (GstVideoCodecState * state)
if (state->codec_data)
gst_buffer_unref (state->codec_data);
if (state->mastering_display_info)
g_slice_free (GstVideoMasteringDisplayInfo, state->mastering_display_info);
g_free (state->mastering_display_info);
if (state->content_light_level)
g_slice_free (GstVideoContentLightLevel, state->content_light_level);
g_slice_free (GstVideoCodecState, state);
g_free (state->content_light_level);
g_free (state);
}
/**

View file

@ -1090,7 +1090,7 @@ gst_video_chroma_resample_new (GstVideoChromaMethod method,
GST_DEBUG ("v_resample %d, factor %d, cosite %d", v_index, v_factor, cosite);
result = g_slice_new (GstVideoChromaResample);
result = g_new (GstVideoChromaResample, 1);
result->method = method;
result->site = site;
result->flags = flags;
@ -1140,7 +1140,7 @@ gst_video_chroma_resample_free (GstVideoChromaResample * resample)
{
g_return_if_fail (resample != NULL);
g_slice_free (GstVideoChromaResample, resample);
g_free (resample);
}
/**

View file

@ -514,7 +514,7 @@ gst_line_cache_new (GstLineCache * prev)
{
GstLineCache *result;
result = g_slice_new0 (GstLineCache);
result = g_new0 (GstLineCache, 1);
result->lines = g_ptr_array_new ();
result->prev = prev;
@ -539,7 +539,7 @@ gst_line_cache_free (GstLineCache * cache)
cache->alloc_line_notify (cache->alloc_line_data);
gst_line_cache_clear (cache);
g_ptr_array_unref (cache->lines);
g_slice_free (GstLineCache, cache);
g_free (cache);
}
static void
@ -668,7 +668,7 @@ converter_alloc_new (guint stride, guint n_lines, gpointer user_data,
ConverterAlloc *alloc;
GST_DEBUG ("stride %d, n_lines %d", stride, n_lines);
alloc = g_slice_new0 (ConverterAlloc);
alloc = g_new0 (ConverterAlloc, 1);
alloc->data = g_malloc (stride * n_lines);
alloc->stride = stride;
alloc->n_lines = n_lines;
@ -685,7 +685,7 @@ converter_alloc_free (ConverterAlloc * alloc)
if (alloc->notify)
alloc->notify (alloc->user_data);
g_free (alloc->data);
g_slice_free (ConverterAlloc, alloc);
g_free (alloc);
}
static void
@ -2333,7 +2333,7 @@ gst_video_converter_new_with_pool (const GstVideoInfo * in_info,
g_return_val_if_fail (in_info->interlace_mode == out_info->interlace_mode,
NULL);
convert = g_slice_new0 (GstVideoConverter);
convert = g_new0 (GstVideoConverter, 1);
fin = in_info->finfo;
fout = out_info->finfo;
@ -2681,7 +2681,7 @@ gst_video_converter_free (GstVideoConverter * convert)
g_free (convert->tasks_p[i]);
}
g_slice_free (GstVideoConverter, convert);
g_free (convert);
}
static gboolean

View file

@ -380,7 +380,7 @@ gst_video_dither_new (GstVideoDitherMethod method, GstVideoDitherFlags flags,
GstVideoDither *dither;
gint i;
dither = g_slice_new0 (GstVideoDither);
dither = g_new0 (GstVideoDither, 1);
dither->method = method;
dither->flags = flags;
dither->format = format;
@ -398,7 +398,7 @@ gst_video_dither_new (GstVideoDitherMethod method, GstVideoDitherFlags flags,
dither->depth = 16;
break;
default:
g_slice_free (GstVideoDither, dither);
g_free (dither);
g_return_val_if_reached (NULL);
break;
}
@ -470,7 +470,7 @@ gst_video_dither_free (GstVideoDither * dither)
g_return_if_fail (dither != NULL);
g_free (dither->errors);
g_slice_free (GstVideoDither, dither);
g_free (dither);
}
/**

View file

@ -70,7 +70,7 @@ ensure_debug_category (void)
GstVideoInfo *
gst_video_info_copy (const GstVideoInfo * info)
{
return g_slice_dup (GstVideoInfo, info);
return g_memdup2 (info, sizeof (GstVideoInfo));
}
/**
@ -85,7 +85,7 @@ gst_video_info_copy (const GstVideoInfo * info)
void
gst_video_info_free (GstVideoInfo * info)
{
g_slice_free (GstVideoInfo, info);
g_free (info);
}
G_DEFINE_BOXED_TYPE (GstVideoInfo, gst_video_info,
@ -106,7 +106,7 @@ gst_video_info_new (void)
{
GstVideoInfo *info;
info = g_slice_new (GstVideoInfo);
info = g_new (GstVideoInfo, 1);
gst_video_info_init (info);
return info;

View file

@ -322,7 +322,7 @@ gst_video_overlay_composition_free (GstMiniObject * mini_obj)
comp->rectangles = NULL;
comp->num_rectangles = 0;
g_slice_free (GstVideoOverlayComposition, comp);
g_free (comp);
}
/**
@ -346,7 +346,7 @@ gst_video_overlay_composition_new (GstVideoOverlayRectangle * rectangle)
g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_RECTANGLE (rectangle)
|| rectangle == NULL, NULL);
comp = g_slice_new0 (GstVideoOverlayComposition);
comp = g_new0 (GstVideoOverlayComposition, 1);
gst_mini_object_init (GST_MINI_OBJECT_CAST (comp), 0,
GST_TYPE_VIDEO_OVERLAY_COMPOSITION,
@ -649,7 +649,7 @@ gst_video_overlay_rectangle_free (GstMiniObject * mini_obj)
g_free (rect->initial_alpha);
g_mutex_clear (&rect->lock);
g_slice_free (GstVideoOverlayRectangle, rect);
g_free (rect);
}
static inline gboolean
@ -726,7 +726,7 @@ gst_video_overlay_rectangle_new_raw (GstBuffer * pixels,
NULL);
g_return_val_if_fail (height > 0 && width > 0, NULL);
rect = g_slice_new0 (GstVideoOverlayRectangle);
rect = g_new0 (GstVideoOverlayRectangle, 1);
gst_mini_object_init (GST_MINI_OBJECT_CAST (rect), 0,
GST_TYPE_VIDEO_OVERLAY_RECTANGLE,

View file

@ -219,7 +219,7 @@ gst_video_scaler_new (GstVideoResamplerMethod method, GstVideoScalerFlags flags,
g_return_val_if_fail (in_size != 0, NULL);
g_return_val_if_fail (out_size != 0, NULL);
scale = g_slice_new0 (GstVideoScaler);
scale = g_new0 (GstVideoScaler, 1);
GST_DEBUG ("%d %u %u->%u", method, n_taps, in_size, out_size);
@ -279,7 +279,7 @@ gst_video_scaler_free (GstVideoScaler * scale)
g_free (scale->offset_n);
g_free (scale->tmpline1);
g_free (scale->tmpline2);
g_slice_free (GstVideoScaler, scale);
g_free (scale);
}
/**
@ -1147,7 +1147,7 @@ gst_video_scaler_combine_packed_YUV (GstVideoScaler * y_scale,
g_return_val_if_fail (uv_scale->resampler.max_taps ==
y_scale->resampler.max_taps, NULL);
scale = g_slice_new0 (GstVideoScaler);
scale = g_new0 (GstVideoScaler, 1);
scale->method = y_scale->method;
scale->flags = y_scale->flags;