gst_vaapidecode_update_src_caps (GstVaapiDecode * decode)
{
GstVideoDecoder *const vdec = GST_VIDEO_DECODER (decode);
+ GstPad *const srcpad = GST_VIDEO_DECODER_SRC_PAD (vdec);
+ GstCaps *templ;
GstVideoCodecState *state, *ref_state;
GstVaapiCapsFeature feature;
GstCapsFeatures *features = NULL;
ref_state = decode->input_state;
format = GST_VIDEO_INFO_FORMAT (&decode->decoded_info);
- feature =
- gst_vaapi_find_preferred_caps_feature (GST_VIDEO_DECODER_SRC_PAD (vdec),
- &format);
+ templ = gst_pad_get_pad_template_caps (srcpad);
+ feature = gst_vaapi_find_preferred_caps_feature (srcpad, templ, &format);
+ gst_caps_unref (templ);
if (feature == GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED)
return FALSE;
goto error_no_caps;
if (!feature)
- feature = gst_vaapi_find_preferred_caps_feature (plugin->srcpad, NULL);
+ feature = gst_vaapi_find_preferred_caps_feature (plugin->srcpad, caps,
+ NULL);
has_video_meta = gst_query_find_allocation_meta (query,
GST_VIDEO_META_API_TYPE, NULL);
}
GstVaapiCapsFeature
-gst_vaapi_find_preferred_caps_feature (GstPad * pad,
+gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps,
GstVideoFormat * out_format_ptr)
{
GstVaapiCapsFeature feature = GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED;
guint i, j, num_structures;
- GstCaps *caps = NULL;
- GstCaps *out_caps, *templ;
+ GstCaps *out_caps, *caps = NULL;
static const guint feature_list[] = { GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE,
GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META,
GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY,
};
- templ = gst_pad_get_pad_template_caps (pad);
- out_caps = gst_pad_peer_query_caps (pad, templ);
- gst_caps_unref (templ);
+ out_caps = gst_pad_peer_query_caps (pad, allowed_caps);
if (!out_caps)
goto cleanup;
+ if (gst_caps_is_any (out_caps) || gst_caps_is_empty (out_caps))
+ goto cleanup;
+
feature = GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY;
num_structures = gst_caps_get_size (out_caps);
for (i = 0; i < num_structures; i++) {
G_GNUC_INTERNAL
GstVaapiCapsFeature
-gst_vaapi_find_preferred_caps_feature (GstPad * pad,
+gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps,
GstVideoFormat * out_format_ptr);
G_GNUC_INTERNAL
* if the user didn't explicitly ask for colorspace conversion.
* Use a filter caps which contain all raw video formats, (excluding
* GST_VIDEO_FORMAT_ENCODED) */
+ out_format = GST_VIDEO_FORMAT_UNKNOWN;
if (postproc->format != DEFAULT_FORMAT)
out_format = postproc->format;
- else {
- GstCaps *peer_caps;
- GstVideoInfo peer_vi;
- peer_caps =
- gst_pad_peer_query_caps (GST_BASE_TRANSFORM_SRC_PAD (trans),
- postproc->allowed_srcpad_caps);
- if (gst_caps_is_any (peer_caps) || gst_caps_is_empty (peer_caps))
- return peer_caps;
- if (!gst_caps_is_fixed (peer_caps))
- peer_caps = gst_caps_fixate (peer_caps);
- gst_video_info_from_caps (&peer_vi, peer_caps);
- out_format = GST_VIDEO_INFO_FORMAT (&peer_vi);
- if (peer_caps)
- gst_caps_unref (peer_caps);
- }
feature =
gst_vaapi_find_preferred_caps_feature (GST_BASE_TRANSFORM_SRC_PAD (trans),
- &out_format);
- gst_video_info_change_format (&vi, out_format, width, height);
+ postproc->allowed_srcpad_caps,
+ (out_format == GST_VIDEO_FORMAT_UNKNOWN) ? &out_format : NULL);
+ if (feature == GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED)
+ return gst_pad_peer_query_caps (GST_BASE_TRANSFORM_SRC_PAD (trans),
+ postproc->allowed_srcpad_caps);
+
+ gst_video_info_change_format (&vi, out_format, width, height);
out_caps = gst_video_info_to_caps (&vi);
if (!out_caps)
return NULL;