vaallocator: clean up use derived feature

Remove allocator member variable for use derived feature which doesn't need to be kept,
it's just for configuration purposes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5799>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-12-11 17:28:06 +01:00
parent 5ae7bbf5fb
commit 94e6a6e3de
3 changed files with 31 additions and 34 deletions

View file

@ -322,9 +322,9 @@ otherwise.</doc>
<type name="guint" c:type="guint*"/>
</parameter>
<parameter name="use_derived" direction="out" caller-allocates="0" transfer-ownership="full" optional="1" allow-none="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVaFeature if derived images
are used for buffer mapping.</doc>
<type name="VaFeature" c:type="GstVaFeature*"/>
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">whether derived images are used for buffer
mapping.</doc>
<type name="gboolean" c:type="gboolean*"/>
</parameter>
</parameters>
</function>
@ -389,7 +389,7 @@ configuration is not valid or not updated.</doc>
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">VA usage hint</doc>
<type name="guint" c:type="guint"/>
</parameter>
<parameter name="use_derived" transfer-ownership="none">
<parameter name="feat_use_derived" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVaFeature</doc>
<type name="VaFeature" c:type="GstVaFeature"/>
</parameter>

View file

@ -1192,7 +1192,6 @@ struct _GstVaAllocator
GstVaDisplay *display;
GstVaFeature feat_use_derived;
gboolean use_derived;
GArray *surface_formats;
@ -1385,7 +1384,8 @@ _update_info (GstVideoInfo * info, const VAImage * image)
}
static inline gboolean
_update_image_info (GstVaAllocator * va_allocator)
_update_image_info (GstVaAllocator * va_allocator,
GstVaFeature feat_use_derived)
{
VASurfaceID surface;
VAImage image = {.image_id = VA_INVALID_ID, };
@ -1405,9 +1405,9 @@ _update_image_info (GstVaAllocator * va_allocator)
#ifdef G_OS_WIN32
/* XXX: Derived image is problematic for D3D backend */
if (va_allocator->feat_use_derived != GST_VA_FEATURE_DISABLED) {
if (feat_use_derived != GST_VA_FEATURE_DISABLED) {
GST_INFO_OBJECT (va_allocator, "Disable image derive on Windows.");
va_allocator->feat_use_derived = GST_VA_FEATURE_DISABLED;
feat_use_derived = GST_VA_FEATURE_DISABLED;
}
va_allocator->use_derived = FALSE;
#else
@ -1416,28 +1416,25 @@ _update_image_info (GstVaAllocator * va_allocator)
*/
if (va_allocator->img_format == GST_VIDEO_FORMAT_P010_10LE
&& _is_old_mesa (va_allocator)) {
if (va_allocator->feat_use_derived != GST_VA_FEATURE_DISABLED) {
if (feat_use_derived != GST_VA_FEATURE_DISABLED) {
GST_INFO_OBJECT (va_allocator, "Disable image derive on old Mesa.");
va_allocator->feat_use_derived = GST_VA_FEATURE_DISABLED;
feat_use_derived = GST_VA_FEATURE_DISABLED;
}
va_allocator->use_derived = FALSE;
}
#endif
/* Try derived first, but different formats can never derive */
if (va_allocator->feat_use_derived != GST_VA_FEATURE_DISABLED
if (feat_use_derived != GST_VA_FEATURE_DISABLED
&& va_allocator->surface_format == va_allocator->img_format) {
if (va_get_derive_image (va_allocator->display, surface, &image)) {
va_allocator->use_derived = TRUE;
va_allocator->use_derived =
va_get_derive_image (va_allocator->display, surface, &image);
if (va_allocator->use_derived)
goto done;
}
image.image_id = VA_INVALID_ID; /* reset it */
}
if (va_allocator->feat_use_derived == GST_VA_FEATURE_ENABLED
&& !va_allocator->use_derived) {
if (feat_use_derived == GST_VA_FEATURE_ENABLED && !va_allocator->use_derived)
GST_WARNING_OBJECT (va_allocator, "Derived images are disabled.");
va_allocator->feat_use_derived = GST_VA_FEATURE_DISABLED;
}
/* Then we try to create a image. */
if (!va_create_image (va_allocator->display, va_allocator->img_format,
@ -1689,8 +1686,6 @@ gst_va_allocator_init (GstVaAllocator * self)
gst_va_memory_pool_init (&self->pool);
self->feat_use_derived = GST_VA_FEATURE_AUTO;
GST_OBJECT_FLAG_SET (self, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
}
@ -1890,7 +1885,7 @@ gst_va_allocator_flush (GstAllocator * allocator)
* Since: 1.22
*/
static gboolean
gst_va_allocator_try (GstAllocator * allocator)
gst_va_allocator_try (GstAllocator * allocator, GstVaFeature feat_use_derived)
{
GstVaAllocator *self;
@ -1922,7 +1917,7 @@ gst_va_allocator_try (GstAllocator * allocator)
return FALSE;
}
if (!_update_image_info (self)) {
if (!_update_image_info (self, feat_use_derived)) {
GST_ERROR_OBJECT (allocator, "Failed to update allocator info");
return FALSE;
}
@ -1943,7 +1938,7 @@ gst_va_allocator_try (GstAllocator * allocator)
* @allocator: a #GstAllocator
* @info: (inout): a #GstVideoInfo
* @usage_hint: VA usage hint
* @use_derived: a #GstVaFeature
* @feat_use_derived: a #GstVaFeature
*
* Sets the configuration defined by @info, @usage_hint and
* @use_derived for @allocator, and it tries the configuration, if
@ -1960,9 +1955,10 @@ gst_va_allocator_try (GstAllocator * allocator)
*/
gboolean
gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
guint usage_hint, GstVaFeature use_derived)
guint usage_hint, GstVaFeature feat_use_derived)
{
GstVaAllocator *self;
gboolean use_derived;
gboolean ret;
g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE);
@ -1970,12 +1966,14 @@ gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
self = GST_VA_ALLOCATOR (allocator);
use_derived = feat_use_derived == GST_VA_FEATURE_AUTO ? self->use_derived
: feat_use_derived == GST_VA_FEATURE_DISABLED ? FALSE : TRUE;
if (gst_va_memory_pool_surface_count (&self->pool) != 0) {
if (GST_VIDEO_INFO_FORMAT (info) == GST_VIDEO_INFO_FORMAT (&self->info)
&& GST_VIDEO_INFO_WIDTH (info) == GST_VIDEO_INFO_WIDTH (&self->info)
&& GST_VIDEO_INFO_HEIGHT (info) == GST_VIDEO_INFO_HEIGHT (&self->info)
&& usage_hint == self->usage_hint
&& use_derived == self->feat_use_derived) {
&& usage_hint == self->usage_hint && use_derived == self->use_derived) {
*info = self->info; /* update callee info (offset & stride) */
return TRUE;
}
@ -1983,12 +1981,11 @@ gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
}
self->usage_hint = usage_hint;
self->feat_use_derived = use_derived;
self->info = *info;
g_clear_pointer (&self->copy, gst_va_surface_copy_free);
ret = gst_va_allocator_try (allocator);
ret = gst_va_allocator_try (allocator, feat_use_derived);
if (ret)
*info = self->info;
@ -2000,8 +1997,8 @@ gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
* @allocator: a #GstAllocator
* @info: (out) (optional): a #GstVideoInfo
* @usage_hint: (out) (optional): VA usage hint
* @use_derived: (out) (optional): a #GstVaFeature if derived images
* are used for buffer mapping.
* @use_derived: (out) (optional): whether derived images are used for buffer
* mapping.
*
* Gets current internal configuration of @allocator.
*
@ -2012,7 +2009,7 @@ gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
*/
gboolean
gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info,
guint * usage_hint, GstVaFeature * use_derived)
guint * usage_hint, gboolean * use_derived)
{
GstVaAllocator *self;
@ -2027,7 +2024,7 @@ gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info,
if (usage_hint)
*usage_hint = self->usage_hint;
if (use_derived)
*use_derived = self->feat_use_derived;
*use_derived = self->use_derived;
return TRUE;
}

View file

@ -113,12 +113,12 @@ GST_VA_API
gboolean gst_va_allocator_set_format (GstAllocator * allocator,
GstVideoInfo * info,
guint usage_hint,
GstVaFeature use_derived);
GstVaFeature feat_use_derived);
GST_VA_API
gboolean gst_va_allocator_get_format (GstAllocator * allocator,
GstVideoInfo * info,
guint * usage_hint,
GstVaFeature * use_derived);
gboolean * use_derived);
GST_VA_API
void gst_va_allocator_set_hacks (GstAllocator * allocator,
guint32 hacks);