diff --git a/girs/GstVa-1.0.gir b/girs/GstVa-1.0.gir index 52e23f24c9..f36e59cb3e 100644 --- a/girs/GstVa-1.0.gir +++ b/girs/GstVa-1.0.gir @@ -642,8 +642,8 @@ otherwise. - a #GstVideoInfo - + a #GstVideoInfoDmaDrm + VA usage hint @@ -676,9 +676,9 @@ otherwise. @allocator, and it tries the configuration, if @allocator has not allocated memories yet. -If @allocator has memory allocated already, and frame size and -format in @info are the same as currently configured in @allocator, -the rest of @info parameters are updated internally. +If @allocator has memory allocated already, and frame size, format +and modifier in @info are the same as currently configured in +@allocator, the rest of @info parameters are updated internally. %TRUE if the configuration is valid or updated; %FALSE if @@ -691,8 +691,8 @@ configuration is not valid or not updated. - a #GstVideoInfo - + a #GstVideoInfoDmaDrm + VA usage hint diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c index d24a55dc37..ddd157f3f9 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c @@ -445,6 +445,8 @@ gst_va_dmabuf_allocator_init (GstVaDmabufAllocator * self) self->parent_copy = allocator->mem_copy; allocator->mem_copy = gst_va_dmabuf_mem_copy; + gst_video_info_dma_drm_init (&self->info); + gst_va_memory_pool_init (&self->pool); } @@ -546,7 +548,7 @@ _va_create_surface_and_export_to_dmabuf (GstVaDisplay * display, VASurfaceAttribExternalBuffers *extbuf = NULL, ext_buf; GstVideoFormat format; VASurfaceID surface; - guint64 prev_modifier; + guint64 prev_modifier = DRM_FORMAT_MOD_INVALID; _init_debug_category (); @@ -691,7 +693,7 @@ gst_va_dmabuf_allocator_setup_buffer_full (GstAllocator * allocator, g_return_val_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator), FALSE); if (!_va_create_surface_and_export_to_dmabuf (self->display, self->usage_hint, - NULL, 0, &self->info.vinfo, &surface, &desc)) + &self->info.drm_modifier, 1, &self->info.vinfo, &surface, &desc)) return FALSE; buf = gst_va_buffer_surface_new (surface); @@ -956,16 +958,16 @@ gst_va_dmabuf_allocator_try (GstAllocator * allocator) /** * gst_va_dmabuf_allocator_set_format: * @allocator: a #GstAllocator - * @info: (in) (out caller-allocates) (not nullable): a #GstVideoInfo + * @info: (in) (out caller-allocates) (not nullable): a #GstVideoInfoDmaDrm * @usage_hint: VA usage hint * * Sets the configuration defined by @info and @usage_hint for * @allocator, and it tries the configuration, if @allocator has not * allocated memories yet. * - * If @allocator has memory allocated already, and frame size and - * format in @info are the same as currently configured in @allocator, - * the rest of @info parameters are updated internally. + * If @allocator has memory allocated already, and frame size, format + * and modifier in @info are the same as currently configured in + * @allocator, the rest of @info parameters are updated internally. * * Returns: %TRUE if the configuration is valid or updated; %FALSE if * configuration is not valid or not updated. @@ -974,43 +976,40 @@ gst_va_dmabuf_allocator_try (GstAllocator * allocator) */ gboolean gst_va_dmabuf_allocator_set_format (GstAllocator * allocator, - GstVideoInfo * info, guint usage_hint) + GstVideoInfoDmaDrm * info, guint usage_hint) { GstVaDmabufAllocator *self; gboolean ret; - /* TODO: change API to pass GstVideoInfoDmaDrm, though ignoring the drm - * modifier since that's set by the driver. Still we might want to pass the - * list of available modifiers by upstream for the negotiated format */ - g_return_val_if_fail (GST_IS_VA_DMABUF_ALLOCATOR (allocator), FALSE); g_return_val_if_fail (info, FALSE); self = GST_VA_DMABUF_ALLOCATOR (allocator); if (gst_va_memory_pool_surface_count (&self->pool) != 0) { - if (GST_VIDEO_INFO_FORMAT (info) + if (info->drm_modifier == self->info.drm_modifier + && GST_VIDEO_INFO_FORMAT (&info->vinfo) == GST_VIDEO_INFO_FORMAT (&self->info.vinfo) - && GST_VIDEO_INFO_WIDTH (info) + && GST_VIDEO_INFO_WIDTH (&info->vinfo) == GST_VIDEO_INFO_WIDTH (&self->info.vinfo) - && GST_VIDEO_INFO_HEIGHT (info) + && GST_VIDEO_INFO_HEIGHT (&info->vinfo) == GST_VIDEO_INFO_HEIGHT (&self->info.vinfo) && usage_hint == self->usage_hint) { - *info = self->info.vinfo; /* update callee info (offset & stride) */ + *info = self->info; /* update callee info (offset & stride) */ return TRUE; } return FALSE; } self->usage_hint = usage_hint; - self->info.vinfo = *info; + self->info = *info; g_clear_pointer (&self->copy, gst_va_surface_copy_free); ret = gst_va_dmabuf_allocator_try (allocator); if (ret) - *info = self->info.vinfo; + *info = self->info; return ret; } @@ -1018,7 +1017,7 @@ gst_va_dmabuf_allocator_set_format (GstAllocator * allocator, /** * gst_va_dmabuf_allocator_get_format: * @allocator: a #GstAllocator - * @info: (out) (optional): a #GstVideoInfo + * @info: (out) (optional): a #GstVideoInfoDmaDrm * @usage_hint: (out) (optional): VA usage hint * * Gets current internal configuration of @allocator. @@ -1030,7 +1029,7 @@ gst_va_dmabuf_allocator_set_format (GstAllocator * allocator, */ gboolean gst_va_dmabuf_allocator_get_format (GstAllocator * allocator, - GstVideoInfo * info, guint * usage_hint) + GstVideoInfoDmaDrm * info, guint * usage_hint) { GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator); @@ -1038,7 +1037,7 @@ gst_va_dmabuf_allocator_get_format (GstAllocator * allocator, return FALSE; if (info) - *info = self->info.vinfo; + *info = self->info; if (usage_hint) *usage_hint = self->usage_hint; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h index cf1bcfc8a4..f7b1e9d2c2 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h @@ -49,11 +49,11 @@ GST_VA_API void gst_va_dmabuf_allocator_flush (GstAllocator * allocator); GST_VA_API gboolean gst_va_dmabuf_allocator_set_format (GstAllocator * allocator, - GstVideoInfo * info, + GstVideoInfoDmaDrm * info, guint usage_hint); GST_VA_API gboolean gst_va_dmabuf_allocator_get_format (GstAllocator * allocator, - GstVideoInfo * info, + GstVideoInfoDmaDrm * info, guint * usage_hint); GST_VA_API diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c index 14e78521b1..8a352ae9b7 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c @@ -426,8 +426,10 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, } if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) { - gst_va_dmabuf_allocator_get_format (allocator, &self->priv->srcpad_info, - NULL); + GstVideoInfoDmaDrm dma_info; + + gst_va_dmabuf_allocator_get_format (allocator, &dma_info, NULL); + self->priv->srcpad_info = dma_info.vinfo; } else if (GST_IS_VA_ALLOCATOR (allocator)) { gst_va_allocator_get_format (allocator, &self->priv->srcpad_info, NULL, NULL); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvacompositor.c b/subprojects/gst-plugins-bad/sys/va/gstvacompositor.c index 882bc055db..3f2175816f 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvacompositor.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvacompositor.c @@ -737,7 +737,10 @@ gst_va_compositor_decide_allocation (GstAggregator * agg, GstQuery * query) } if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) { - gst_va_dmabuf_allocator_get_format (allocator, &vagg->info, NULL); + GstVideoInfoDmaDrm dma_info; + + gst_va_dmabuf_allocator_get_format (allocator, &dma_info, NULL); + vagg->info = dma_info.vinfo; } else if (GST_IS_VA_ALLOCATOR (allocator)) { gst_va_allocator_get_format (allocator, &vagg->info, NULL, NULL); } @@ -819,7 +822,10 @@ _get_sinkpad_pool (GstVaCompositor * self, GstVaCompositorPad * pad) } if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) { - gst_va_dmabuf_allocator_get_format (allocator, &info, NULL); + GstVideoInfoDmaDrm dma_info; + + gst_va_dmabuf_allocator_get_format (allocator, &dma_info, NULL); + info = dma_info.vinfo; } else if (GST_IS_VA_ALLOCATOR (allocator)) { gst_va_allocator_get_format (allocator, &info, NULL, NULL); }