mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
vaapiencode: enhance how the profile is defined
This code doesn't define the profile used by the internal encoder, but it used to "predict" which is going to be used and to get the caps restrictions. Before the profile was predicted by checking the donwstream caps, but sometimes they are not defined, setting an unknown profile. In order to enhances this situation, the encoder asks to internal encoder if it has one. If so, it is used. To ask the internal encoder's profile a new accessor function was added: gst_vaapi_encoder_get_profile()
This commit is contained in:
parent
bd3d347fd7
commit
3ba3966fc3
3 changed files with 43 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue