mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
vaapidecode: add support for VideoAlignment bufferpool option.
Always add VideoAlignment bufferpool option if the downstream element expects its own pool to be used but does not offer it through a proper propose_allocation() implementation for instance, and that the ALLOCATION query does not expose the availability of the Video Meta API. This fixes propagation of video buffer stride information to Firefox.
This commit is contained in:
parent
1d1be0ae76
commit
cafb25c4d1
2 changed files with 35 additions and 0 deletions
|
@ -516,6 +516,7 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
|
||||||
guint size, min, max;
|
guint size, min, max;
|
||||||
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;
|
||||||
GstVideoCodecState *state;
|
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;
|
||||||
|
@ -572,6 +573,11 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
|
||||||
gst_query_parse_nth_allocation_pool(query, 0, &pool, &size, &min, &max);
|
gst_query_parse_nth_allocation_pool(query, 0, &pool, &size, &min, &max);
|
||||||
size = MAX(size, vi.size);
|
size = MAX(size, vi.size);
|
||||||
update_pool = TRUE;
|
update_pool = TRUE;
|
||||||
|
|
||||||
|
/* Check whether downstream element proposed a bufferpool but did
|
||||||
|
not provide a correct propose_allocation() implementation */
|
||||||
|
has_video_alignment = gst_buffer_pool_has_option(pool,
|
||||||
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
|
@ -609,6 +615,12 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
|
||||||
#endif
|
#endif
|
||||||
gst_buffer_pool_set_config(pool, config);
|
gst_buffer_pool_set_config(pool, config);
|
||||||
}
|
}
|
||||||
|
else if (has_video_alignment) {
|
||||||
|
config = gst_buffer_pool_get_config(pool);
|
||||||
|
gst_buffer_pool_config_add_option(config,
|
||||||
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||||
|
gst_buffer_pool_set_config(pool, config);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -47,6 +47,7 @@ struct _GstVaapiVideoBufferPoolPrivate {
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
guint has_video_meta : 1;
|
guint has_video_meta : 1;
|
||||||
|
guint has_video_alignment : 1;
|
||||||
guint has_texture_upload_meta : 1;
|
guint has_texture_upload_meta : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,6 +102,19 @@ gst_vaapi_video_buffer_pool_get_property(GObject *object, guint prop_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fill_video_alignment(GstVaapiVideoBufferPool *pool, GstVideoAlignment *align)
|
||||||
|
{
|
||||||
|
GstVideoInfo * const vip =
|
||||||
|
&GST_VAAPI_VIDEO_ALLOCATOR_CAST(pool->priv->allocator)->image_info;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
gst_video_alignment_reset(align);
|
||||||
|
for (i = 0; i < GST_VIDEO_INFO_N_PLANES(vip); i++)
|
||||||
|
align->stride_align[i] =
|
||||||
|
(1U << g_bit_nth_lsf(GST_VIDEO_INFO_PLANE_STRIDE(vip, i), 0)) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
static const gchar **
|
static const gchar **
|
||||||
gst_vaapi_video_buffer_pool_get_options(GstBufferPool *pool)
|
gst_vaapi_video_buffer_pool_get_options(GstBufferPool *pool)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +122,7 @@ gst_vaapi_video_buffer_pool_get_options(GstBufferPool *pool)
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_META,
|
GST_BUFFER_POOL_OPTION_VIDEO_META,
|
||||||
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META,
|
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
|
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
|
||||||
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
return g_options;
|
return g_options;
|
||||||
|
@ -122,6 +137,7 @@ gst_vaapi_video_buffer_pool_set_config(GstBufferPool *pool,
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstVideoInfo * const cur_vip = &priv->video_info[priv->video_info_index];
|
GstVideoInfo * const cur_vip = &priv->video_info[priv->video_info_index];
|
||||||
GstVideoInfo * const new_vip = &priv->video_info[!priv->video_info_index];
|
GstVideoInfo * const new_vip = &priv->video_info[!priv->video_info_index];
|
||||||
|
GstVideoAlignment align;
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
gboolean changed_caps;
|
gboolean changed_caps;
|
||||||
|
|
||||||
|
@ -152,6 +168,13 @@ gst_vaapi_video_buffer_pool_set_config(GstBufferPool *pool,
|
||||||
priv->has_video_meta = gst_buffer_pool_config_has_option(config,
|
priv->has_video_meta = gst_buffer_pool_config_has_option(config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||||
|
|
||||||
|
priv->has_video_alignment = gst_buffer_pool_config_has_option(config,
|
||||||
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||||
|
if (priv->has_video_alignment) {
|
||||||
|
fill_video_alignment(GST_VAAPI_VIDEO_BUFFER_POOL(pool), &align);
|
||||||
|
gst_buffer_pool_config_set_video_alignment(config, &align);
|
||||||
|
}
|
||||||
|
|
||||||
priv->has_texture_upload_meta = gst_buffer_pool_config_has_option(config,
|
priv->has_texture_upload_meta = gst_buffer_pool_config_has_option(config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue