va: Fix the caps memory leak by gst_va_pool_new_with_config().

The gst_va_pool_new_with_config() will ref the caps, and so we need
to unref after that.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3503>
This commit is contained in:
He Junyan 2022-12-01 22:50:30 +08:00 committed by GStreamer Marge Bot
parent c8a0d706ca
commit 765adf5325
2 changed files with 5 additions and 2 deletions

View file

@ -312,10 +312,11 @@ _create_internal_pool (GstVaAV1Dec * self, gint width, gint height)
pool = gst_va_pool_new_with_config (caps, GST_VIDEO_INFO_SIZE (&info), pool = gst_va_pool_new_with_config (caps, GST_VIDEO_INFO_SIZE (&info),
1, 0, VA_SURFACE_ATTRIB_USAGE_HINT_DECODER, GST_VA_FEATURE_AUTO, 1, 0, VA_SURFACE_ATTRIB_USAGE_HINT_DECODER, GST_VA_FEATURE_AUTO,
allocator, &params); allocator, &params);
gst_clear_caps (&caps);
if (!pool) { if (!pool) {
GST_WARNING_OBJECT (self, "Failed to create internal pool"); GST_WARNING_OBJECT (self, "Failed to create internal pool");
gst_object_unref (allocator); gst_object_unref (allocator);
gst_clear_caps (&caps);
return NULL; return NULL;
} }

View file

@ -197,7 +197,7 @@ _get_sinkpad_pool (GstVaBaseEnc * base)
GstAllocationParams params = { 0, }; GstAllocationParams params = { 0, };
guint size, usage_hint = 0; guint size, usage_hint = 0;
GArray *surface_formats = NULL; GArray *surface_formats = NULL;
GstCaps *caps; GstCaps *caps = NULL;
if (base->priv->raw_pool) if (base->priv->raw_pool)
return base->priv->raw_pool; return base->priv->raw_pool;
@ -217,6 +217,8 @@ _get_sinkpad_pool (GstVaBaseEnc * base)
base->priv->raw_pool = gst_va_pool_new_with_config (caps, size, 1, 0, base->priv->raw_pool = gst_va_pool_new_with_config (caps, size, 1, 0,
usage_hint, GST_VA_FEATURE_AUTO, allocator, &params); usage_hint, GST_VA_FEATURE_AUTO, allocator, &params);
gst_clear_caps (&caps);
if (!base->priv->raw_pool) { if (!base->priv->raw_pool) {
gst_object_unref (allocator); gst_object_unref (allocator);
return NULL; return NULL;