mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
plugins: update buffer size with the one reported by allocator
There is a regression in 7a206923
, since the buffer pool ditches all
the buffers generated by them because the pool config size is
different of the buffer's size.
Test pipeline:
gst-launch-1.0 filesrc location=big_buck_bunny_1080p_h264.mov \
! qtdemux ! vaapih264dec ! vaapipostproc ! xvimagesink \
--gst-debug=GST_PERFORMANCE:5
The allocator may update the buffer size according to the VA surface
properties. In order to do this, the video info is modified when the
allocator is created, which reports through the allocation info the
updated size, and set it to the pool config.
This commit is contained in:
parent
9397cd7d4d
commit
05a41009f2
2 changed files with 27 additions and 11 deletions
|
@ -498,16 +498,15 @@ ensure_sinkpad_allocator (GstVaapiPluginBase * plugin, GstCaps * caps,
|
|||
guint * size)
|
||||
{
|
||||
GstVideoInfo vinfo;
|
||||
const GstVideoInfo *image_info;
|
||||
GstVaapiImageUsageFlags usage_flag =
|
||||
GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS;
|
||||
|
||||
if (!gst_video_info_from_caps (&vinfo, caps))
|
||||
goto error_invalid_caps;
|
||||
gst_video_info_force_nv12_if_encoded (&vinfo);
|
||||
*size = GST_VIDEO_INFO_SIZE (&vinfo);
|
||||
|
||||
if (!reset_allocator (plugin->sinkpad_allocator, &vinfo))
|
||||
return TRUE;
|
||||
goto bail;
|
||||
|
||||
if (has_dmabuf_capable_peer (plugin, plugin->sinkpad)) {
|
||||
plugin->sinkpad_allocator =
|
||||
|
@ -527,6 +526,14 @@ ensure_sinkpad_allocator (GstVaapiPluginBase * plugin, GstCaps * caps,
|
|||
bail:
|
||||
if (!plugin->sinkpad_allocator)
|
||||
goto error_create_allocator;
|
||||
|
||||
image_info =
|
||||
gst_allocator_get_vaapi_video_info (plugin->sinkpad_allocator, NULL);
|
||||
g_assert (image_info); /* allocator ought set its image info */
|
||||
|
||||
/* update the size with the one generated by the allocator */
|
||||
*size = GST_VIDEO_INFO_SIZE (image_info);
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -567,11 +574,12 @@ ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo,
|
|||
GstCaps * caps)
|
||||
{
|
||||
gboolean different_caps;
|
||||
const GstVideoInfo *image_info;
|
||||
GstVaapiImageUsageFlags usage_flag =
|
||||
GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS;
|
||||
|
||||
if (!reset_allocator (plugin->srcpad_allocator, vinfo))
|
||||
return TRUE;
|
||||
goto valid_allocator;
|
||||
|
||||
plugin->srcpad_allocator = NULL;
|
||||
if (caps && gst_caps_is_video_raw (caps)) {
|
||||
|
@ -595,6 +603,15 @@ ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo,
|
|||
if (!plugin->srcpad_allocator)
|
||||
goto error_create_allocator;
|
||||
|
||||
valid_allocator:
|
||||
image_info =
|
||||
gst_allocator_get_vaapi_video_info (plugin->srcpad_allocator, NULL);
|
||||
g_assert (image_info); /* both allocators ought set its image
|
||||
* info */
|
||||
|
||||
/* update the size with the one generated by the allocator */
|
||||
GST_VIDEO_INFO_SIZE (vinfo) = GST_VIDEO_INFO_SIZE (image_info);
|
||||
|
||||
/* the received caps are the "allocation caps" which may be
|
||||
* different from the "negotiation caps". In this case, we should
|
||||
* indicate the allocator to store the negotiation caps since they
|
||||
|
@ -605,11 +622,6 @@ ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo,
|
|||
if (different_caps) {
|
||||
guint i;
|
||||
GstVideoInfo vi = plugin->srcpad_info;
|
||||
const GstVideoInfo *image_info =
|
||||
gst_allocator_get_vaapi_video_info (plugin->srcpad_allocator, NULL);
|
||||
|
||||
g_assert (image_info); /* both allocators should set its video
|
||||
* info */
|
||||
|
||||
/* update the planes and the size with the allocator image/surface
|
||||
* info, but not the resolution */
|
||||
|
@ -934,6 +946,8 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
|||
if (!pool) {
|
||||
if (!ensure_srcpad_allocator (plugin, &vi, caps))
|
||||
goto error;
|
||||
size = GST_VIDEO_INFO_SIZE (&vi); /* size might be updated by
|
||||
* allocator */
|
||||
pool = gst_vaapi_plugin_base_create_pool (plugin, caps, size, min, max,
|
||||
pool_options, plugin->srcpad_allocator);
|
||||
if (!pool)
|
||||
|
|
|
@ -231,9 +231,11 @@ gst_vaapi_video_buffer_pool_set_config (GstBufferPool * pool,
|
|||
priv->vmeta_vinfo = (negotiated_vinfo) ?
|
||||
*negotiated_vinfo : new_allocation_vinfo;
|
||||
|
||||
if (GST_VIDEO_INFO_SIZE (&priv->vmeta_vinfo) != size) {
|
||||
/* last resource to set the correct buffer size */
|
||||
allocator_vinfo = gst_allocator_get_vaapi_video_info (allocator, NULL);
|
||||
if (GST_VIDEO_INFO_SIZE (allocator_vinfo) != size) {
|
||||
gst_buffer_pool_config_set_params (config, caps,
|
||||
GST_VIDEO_INFO_SIZE (&priv->vmeta_vinfo), min_buffers, max_buffers);
|
||||
GST_VIDEO_INFO_SIZE (allocator_vinfo), min_buffers, max_buffers);
|
||||
}
|
||||
}
|
||||
if (!priv->allocator)
|
||||
|
|
Loading…
Reference in a new issue