mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 19:55:32 +00:00
vaapidecode: simplify bufferpool configuration.
Rework the logics behind the configuration of an adequate bufferpool, especially when OpenGL meta or additional capsfeatures are needed. Besides, for GStreamer >= 1.4, the first capsfeatures that gets matched, and that is not system memory, is now selected by default.
This commit is contained in:
parent
c5102c72af
commit
0607898019
2 changed files with 38 additions and 24 deletions
|
@ -517,11 +517,10 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
|
||||||
gboolean need_pool, update_pool;
|
gboolean need_pool, update_pool;
|
||||||
gboolean has_video_meta = FALSE;
|
gboolean has_video_meta = FALSE;
|
||||||
gboolean has_video_alignment = FALSE;
|
gboolean has_video_alignment = FALSE;
|
||||||
GstVideoCodecState *state;
|
|
||||||
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
||||||
gboolean has_texture_upload_meta = FALSE;
|
gboolean has_texture_upload_meta = FALSE;
|
||||||
GstCapsFeatures *features, *features2;
|
|
||||||
#endif
|
#endif
|
||||||
|
GstVideoCodecState *state;
|
||||||
|
|
||||||
gst_query_parse_allocation(query, &caps, &need_pool);
|
gst_query_parse_allocation(query, &caps, &need_pool);
|
||||||
|
|
||||||
|
@ -531,34 +530,27 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
|
||||||
state = gst_video_decoder_get_output_state(vdec);
|
state = gst_video_decoder_get_output_state(vdec);
|
||||||
|
|
||||||
decode->has_texture_upload_meta = FALSE;
|
decode->has_texture_upload_meta = FALSE;
|
||||||
has_video_meta = gst_query_find_allocation_meta(query, GST_VIDEO_META_API_TYPE, NULL);
|
has_video_meta = gst_query_find_allocation_meta(query,
|
||||||
|
GST_VIDEO_META_API_TYPE, NULL);
|
||||||
|
|
||||||
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
||||||
if (has_video_meta)
|
has_texture_upload_meta = gst_query_find_allocation_meta(query,
|
||||||
decode->has_texture_upload_meta = gst_query_find_allocation_meta(query,
|
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL);
|
||||||
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL);
|
|
||||||
|
|
||||||
features = gst_caps_get_features(state->caps, 0);
|
decode->has_texture_upload_meta =
|
||||||
features2 = gst_caps_features_new(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, NULL);
|
|
||||||
|
|
||||||
has_texture_upload_meta =
|
|
||||||
gst_vaapi_find_preferred_caps_feature(GST_VIDEO_DECODER_SRC_PAD(vdec),
|
gst_vaapi_find_preferred_caps_feature(GST_VIDEO_DECODER_SRC_PAD(vdec),
|
||||||
GST_VIDEO_FORMAT_ENCODED) ==
|
GST_VIDEO_FORMAT_ENCODED) ==
|
||||||
GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META;
|
GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META;
|
||||||
|
|
||||||
/* Update src caps if feature is not handled downstream */
|
|
||||||
if (!decode->has_texture_upload_meta &&
|
|
||||||
gst_caps_features_is_equal(features, features2))
|
|
||||||
gst_vaapidecode_update_src_caps (decode, state);
|
|
||||||
else if (has_texture_upload_meta &&
|
|
||||||
!gst_caps_features_is_equal(features, features2)) {
|
|
||||||
gst_video_info_set_format(&state->info, GST_VIDEO_FORMAT_RGBA,
|
|
||||||
state->info.width,
|
|
||||||
state->info.height);
|
|
||||||
gst_vaapidecode_update_src_caps(decode, state);
|
|
||||||
}
|
|
||||||
gst_caps_features_free(features2);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Update src caps if feature is not handled downstream */
|
||||||
|
if (!gst_caps_is_always_compatible(caps, state->caps)) {
|
||||||
|
if (decode->has_texture_upload_meta)
|
||||||
|
gst_video_info_set_format(&state->info, GST_VIDEO_FORMAT_RGBA,
|
||||||
|
GST_VIDEO_INFO_WIDTH(&state->info),
|
||||||
|
GST_VIDEO_INFO_HEIGHT(&state->info));
|
||||||
|
gst_vaapidecode_update_src_caps(decode, state);
|
||||||
|
}
|
||||||
gst_video_codec_state_unref(state);
|
gst_video_codec_state_unref(state);
|
||||||
|
|
||||||
gst_video_info_init(&vi);
|
gst_video_info_init(&vi);
|
||||||
|
@ -609,7 +601,7 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
|
||||||
gst_buffer_pool_config_add_option(config,
|
gst_buffer_pool_config_add_option(config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||||
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
||||||
if (decode->has_texture_upload_meta)
|
if (has_texture_upload_meta)
|
||||||
gst_buffer_pool_config_add_option(config,
|
gst_buffer_pool_config_add_option(config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
|
||||||
#endif
|
#endif
|
||||||
|
@ -622,6 +614,15 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
|
||||||
gst_buffer_pool_set_config(pool, config);
|
gst_buffer_pool_set_config(pool, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
|
||||||
|
if (decode->has_texture_upload_meta && !has_texture_upload_meta) {
|
||||||
|
config = gst_buffer_pool_get_config(pool);
|
||||||
|
gst_buffer_pool_config_add_option(config,
|
||||||
|
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
|
||||||
|
gst_buffer_pool_set_config(pool, config);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (update_pool)
|
if (update_pool)
|
||||||
gst_query_set_nth_allocation_pool(query, 0, pool, size, min, max);
|
gst_query_set_nth_allocation_pool(query, 0, pool, size, min, max);
|
||||||
else
|
else
|
||||||
|
|
|
@ -541,6 +541,12 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstVideoFormat format)
|
||||||
GstCapsFeatures *const features = gst_caps_get_features (out_caps, i);
|
GstCapsFeatures *const features = gst_caps_get_features (out_caps, i);
|
||||||
GstStructure *const structure = gst_caps_get_structure (out_caps, i);
|
GstStructure *const structure = gst_caps_get_structure (out_caps, i);
|
||||||
|
|
||||||
|
#if GST_CHECK_VERSION(1,3,0)
|
||||||
|
/* Skip ANY features, we need an exact match for correct evaluation */
|
||||||
|
if (gst_caps_features_is_any (features))
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
caps = gst_caps_new_full (gst_structure_copy (structure), NULL);
|
caps = gst_caps_new_full (gst_structure_copy (structure), NULL);
|
||||||
if (!caps)
|
if (!caps)
|
||||||
continue;
|
continue;
|
||||||
|
@ -556,6 +562,13 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstVideoFormat format)
|
||||||
feature < GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY)
|
feature < GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY)
|
||||||
feature = GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY;
|
feature = GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY;
|
||||||
gst_caps_replace (&caps, NULL);
|
gst_caps_replace (&caps, NULL);
|
||||||
|
|
||||||
|
#if GST_CHECK_VERSION(1,3,0)
|
||||||
|
/* Stop at the first match, the caps should already be sorted out
|
||||||
|
by preference order from downstream elements */
|
||||||
|
if (feature != GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY)
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
Loading…
Reference in a new issue