From 9f627ef2344f5d9f50d53eafc61c0615b6bf3a90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 17 Jan 2020 14:24:37 +0100 Subject: [PATCH] vaapih264enc: update level in src caps And, if downstream requests a specific level, the caps are not negotiated, because there is no mechanism right now to specify a custom level in the internal encoder. --- gst/vaapi/gstvaapiencode_h264.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gst/vaapi/gstvaapiencode_h264.c b/gst/vaapi/gstvaapiencode_h264.c index 4a3b4ac..98badf4 100644 --- a/gst/vaapi/gstvaapiencode_h264.c +++ b/gst/vaapi/gstvaapiencode_h264.c @@ -319,7 +319,12 @@ gst_vaapiencode_h264_set_config (GstVaapiEncode * base_encode) stream_format = gst_structure_get_string (structure, "stream-format"); encode->is_avc = (g_strcmp0 (stream_format, "avc") == 0); - if (profile != GST_VAAPI_PROFILE_UNKNOWN) { + if (gst_structure_has_field (structure, "level")) { + /* @TODO(victor): add a mechansim for user set a specific + * level */ + GST_WARNING_OBJECT (encode, "cannot set level configuration"); + ret = FALSE; + } else if (profile != GST_VAAPI_PROFILE_UNKNOWN) { GST_INFO ("using %s profile as target decoder constraints", gst_vaapi_utils_h264_get_profile_string (profile)); ret = gst_vaapi_encoder_h264_set_max_profile (encoder, profile); @@ -346,7 +351,7 @@ fail: static void set_compatible_profile (GstVaapiEncodeH264 * encode, GstCaps * caps, - GstVaapiProfile profile) + GstVaapiProfile profile, GstVaapiLevelH264 level) { GstCaps *allowed_caps, *tmp_caps; gboolean ret = FALSE; @@ -380,7 +385,9 @@ retry: } } else { gst_caps_set_simple (caps, "profile", G_TYPE_STRING, - gst_vaapi_utils_h264_get_profile_string (profile), NULL); + gst_vaapi_utils_h264_get_profile_string (profile), + "level", G_TYPE_STRING, gst_vaapi_utils_h264_get_level_string (level), + NULL); ret = TRUE; } @@ -399,6 +406,7 @@ gst_vaapiencode_h264_get_caps (GstVaapiEncode * base_encode) GstVaapiEncoderH264 *const encoder = GST_VAAPI_ENCODER_H264 (base_encode->encoder); GstVaapiProfile profile; + GstVaapiLevelH264 level; GstCaps *caps; caps = gst_caps_from_string (GST_CODEC_CAPS); @@ -407,13 +415,11 @@ gst_vaapiencode_h264_get_caps (GstVaapiEncode * base_encode) encode->is_avc ? "avc" : "byte-stream", NULL); /* Update profile determined by encoder */ - gst_vaapi_encoder_h264_get_profile_and_level (encoder, &profile, NULL); + gst_vaapi_encoder_h264_get_profile_and_level (encoder, &profile, &level); if (profile != GST_VAAPI_PROFILE_UNKNOWN) - set_compatible_profile (encode, caps, profile); + set_compatible_profile (encode, caps, profile, level); GST_INFO_OBJECT (base_encode, "out caps %" GST_PTR_FORMAT, caps); - - /* XXX: update level information */ return caps; } -- 2.7.4