From eb911e9eabb646a35f73be094fa2f94ddf8bf53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 5 Apr 2016 13:37:40 +0200 Subject: [PATCH] vaapidecode: move GstCapsFeatures near to its use Move the handling of the GstCapsFeatures just after it is used, in order to avoid handling its memory. --- gst/vaapi/gstvaapidecode.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index a9603babc8..0559e75dd9 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -240,14 +240,14 @@ gst_vaapidecode_update_src_caps (GstVaapiDecode * decode) GstCaps *templ; GstVideoCodecState *state, *ref_state; GstVaapiCapsFeature feature; - GstCapsFeatures *features = NULL; + GstCapsFeatures *features; GstCaps *allocation_caps; GstVideoInfo *vi; GstVideoFormat format; GstClockTime latency; gint fps_d, fps_n; guint width, height; - const gchar *format_str; + const gchar *format_str, *feature_str; if (!decode->input_state) return FALSE; @@ -276,20 +276,6 @@ gst_vaapidecode_update_src_caps (GstVaapiDecode * decode) (&decode->decoded_info)), gst_video_format_to_string (format)); } - switch (feature) { - case GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META: - features = - gst_caps_features_new - (GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, NULL); - break; - case GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE: - features = - gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, NULL); - break; - default: - break; - } - width = decode->display_width; height = decode->display_height; @@ -303,18 +289,25 @@ gst_vaapidecode_update_src_caps (GstVaapiDecode * decode) if (!state || GST_VIDEO_INFO_WIDTH (&state->info) == 0 || GST_VIDEO_INFO_HEIGHT (&state->info) == 0) { - if (features) - gst_caps_features_free (features); if (state) gst_video_codec_state_unref (state); return FALSE; } vi = &state->info; - state->caps = gst_video_info_to_caps (vi); - if (features) - gst_caps_set_features (state->caps, 0, features); + + switch (feature) { + case GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META: + case GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE:{ + feature_str = gst_vaapi_caps_feature_to_string (feature); + features = gst_caps_features_new (feature_str, NULL); + gst_caps_set_features (state->caps, 0, features); + break; + } + default: + break; + } /* Allocation query is different from pad's caps */ allocation_caps = NULL;