diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index 51bcd069a9..937eb10a1c 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -1869,6 +1869,14 @@ gst_vaapi_encoder_ensure_max_num_ref_frames (GstVaapiEncoder * encoder, return TRUE; } +GstVaapiProfile +gst_vaapi_encoder_get_profile (GstVaapiEncoder * encoder) +{ + g_return_val_if_fail (encoder, GST_VAAPI_PROFILE_UNKNOWN); + + return encoder->profile; +} + /** Returns a GType for the #GstVaapiEncoderTune set */ GType gst_vaapi_encoder_tune_get_type (void) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.h b/gst-libs/gst/vaapi/gstvaapiencoder.h index b22fde9e8c..a813dd2168 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder.h @@ -216,6 +216,10 @@ gst_vaapi_encoder_flush (GstVaapiEncoder * encoder); GArray * gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder, GstVaapiProfile profile); + +GstVaapiProfile +gst_vaapi_encoder_get_profile (GstVaapiEncoder * encoder); + G_END_DECLS #endif /* GST_VAAPI_ENCODER_H */ diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c index 7f26016e2f..5bcff26354 100644 --- a/gst/vaapi/gstvaapiencode.c +++ b/gst/vaapi/gstvaapiencode.c @@ -365,35 +365,54 @@ gst_vaapiencode_buffer_loop (GstVaapiEncode * encode) gst_pad_pause_task (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode)); } +static GstVaapiProfile +get_profile (GstVaapiEncode * encode) +{ + GstVaapiEncodeClass *klass = GST_VAAPIENCODE_GET_CLASS (encode); + + if (klass->get_profile) { + GstVaapiProfile profile = GST_VAAPI_PROFILE_UNKNOWN; + GstCaps *allowed = + gst_pad_get_allowed_caps (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode)); + + if (allowed) { + if (!gst_caps_is_empty (allowed) && !gst_caps_is_any (allowed)) + profile = klass->get_profile (allowed); + gst_caps_unref (allowed); + } + + if (profile != GST_VAAPI_PROFILE_UNKNOWN) + return profile; + } + + if (encode->encoder) + return gst_vaapi_encoder_get_profile (encode->encoder); + + return GST_VAAPI_PROFILE_UNKNOWN; +} + static gboolean ensure_allowed_sinkpad_caps (GstVaapiEncode * encode) { - GstVaapiEncodeClass *klass = GST_VAAPIENCODE_GET_CLASS (encode); GstCaps *out_caps, *raw_caps = NULL; GArray *formats = NULL; gboolean ret = FALSE; - GstVaapiProfile profile = GST_VAAPI_PROFILE_UNKNOWN; + GstVaapiProfile profile; if (encode->allowed_sinkpad_caps) return TRUE; if (!encode->encoder) return TRUE; + profile = get_profile (encode); + if (profile == GST_VAAPI_PROFILE_UNKNOWN) + return TRUE; + out_caps = gst_caps_from_string (GST_VAAPI_MAKE_SURFACE_CAPS ";" GST_VAAPI_MAKE_DMABUF_CAPS); if (!out_caps) goto failed_create_va_caps; - if (klass->get_profile) { - GstCaps *allowed = - gst_pad_get_allowed_caps (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode)); - if (allowed) { - if (!gst_caps_is_empty (allowed) && !gst_caps_is_any (allowed)) - profile = klass->get_profile (allowed); - gst_caps_unref (allowed); - } - } - formats = gst_vaapi_encoder_get_surface_formats (encode->encoder, profile); if (!formats) goto failed_get_formats;