mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
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:
parent
5ae7bbf5fb
commit
94e6a6e3de
3 changed files with 31 additions and 34 deletions
|
@ -322,9 +322,9 @@ otherwise.</doc>
|
||||||
<type name="guint" c:type="guint*"/>
|
<type name="guint" c:type="guint*"/>
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="use_derived" direction="out" caller-allocates="0" transfer-ownership="full" optional="1" allow-none="1">
|
<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
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">whether derived images are used for buffer
|
||||||
are used for buffer mapping.</doc>
|
mapping.</doc>
|
||||||
<type name="VaFeature" c:type="GstVaFeature*"/>
|
<type name="gboolean" c:type="gboolean*"/>
|
||||||
</parameter>
|
</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
</function>
|
</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>
|
<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"/>
|
<type name="guint" c:type="guint"/>
|
||||||
</parameter>
|
</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>
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c">a #GstVaFeature</doc>
|
||||||
<type name="VaFeature" c:type="GstVaFeature"/>
|
<type name="VaFeature" c:type="GstVaFeature"/>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
|
|
@ -1192,7 +1192,6 @@ struct _GstVaAllocator
|
||||||
|
|
||||||
GstVaDisplay *display;
|
GstVaDisplay *display;
|
||||||
|
|
||||||
GstVaFeature feat_use_derived;
|
|
||||||
gboolean use_derived;
|
gboolean use_derived;
|
||||||
GArray *surface_formats;
|
GArray *surface_formats;
|
||||||
|
|
||||||
|
@ -1385,7 +1384,8 @@ _update_info (GstVideoInfo * info, const VAImage * image)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
_update_image_info (GstVaAllocator * va_allocator)
|
_update_image_info (GstVaAllocator * va_allocator,
|
||||||
|
GstVaFeature feat_use_derived)
|
||||||
{
|
{
|
||||||
VASurfaceID surface;
|
VASurfaceID surface;
|
||||||
VAImage image = {.image_id = VA_INVALID_ID, };
|
VAImage image = {.image_id = VA_INVALID_ID, };
|
||||||
|
@ -1405,9 +1405,9 @@ _update_image_info (GstVaAllocator * va_allocator)
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
/* XXX: Derived image is problematic for D3D backend */
|
/* 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.");
|
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;
|
va_allocator->use_derived = FALSE;
|
||||||
#else
|
#else
|
||||||
|
@ -1416,28 +1416,25 @@ _update_image_info (GstVaAllocator * va_allocator)
|
||||||
*/
|
*/
|
||||||
if (va_allocator->img_format == GST_VIDEO_FORMAT_P010_10LE
|
if (va_allocator->img_format == GST_VIDEO_FORMAT_P010_10LE
|
||||||
&& _is_old_mesa (va_allocator)) {
|
&& _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.");
|
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;
|
va_allocator->use_derived = FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Try derived first, but different formats can never derive */
|
/* 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) {
|
&& va_allocator->surface_format == va_allocator->img_format) {
|
||||||
if (va_get_derive_image (va_allocator->display, surface, &image)) {
|
va_allocator->use_derived =
|
||||||
va_allocator->use_derived = TRUE;
|
va_get_derive_image (va_allocator->display, surface, &image);
|
||||||
|
if (va_allocator->use_derived)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
image.image_id = VA_INVALID_ID; /* reset it */
|
image.image_id = VA_INVALID_ID; /* reset it */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (va_allocator->feat_use_derived == GST_VA_FEATURE_ENABLED
|
if (feat_use_derived == GST_VA_FEATURE_ENABLED && !va_allocator->use_derived)
|
||||||
&& !va_allocator->use_derived) {
|
|
||||||
GST_WARNING_OBJECT (va_allocator, "Derived images are disabled.");
|
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. */
|
/* Then we try to create a image. */
|
||||||
if (!va_create_image (va_allocator->display, va_allocator->img_format,
|
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);
|
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);
|
GST_OBJECT_FLAG_SET (self, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1890,7 +1885,7 @@ gst_va_allocator_flush (GstAllocator * allocator)
|
||||||
* Since: 1.22
|
* Since: 1.22
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_va_allocator_try (GstAllocator * allocator)
|
gst_va_allocator_try (GstAllocator * allocator, GstVaFeature feat_use_derived)
|
||||||
{
|
{
|
||||||
GstVaAllocator *self;
|
GstVaAllocator *self;
|
||||||
|
|
||||||
|
@ -1922,7 +1917,7 @@ gst_va_allocator_try (GstAllocator * allocator)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_update_image_info (self)) {
|
if (!_update_image_info (self, feat_use_derived)) {
|
||||||
GST_ERROR_OBJECT (allocator, "Failed to update allocator info");
|
GST_ERROR_OBJECT (allocator, "Failed to update allocator info");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1943,7 +1938,7 @@ gst_va_allocator_try (GstAllocator * allocator)
|
||||||
* @allocator: a #GstAllocator
|
* @allocator: a #GstAllocator
|
||||||
* @info: (inout): a #GstVideoInfo
|
* @info: (inout): a #GstVideoInfo
|
||||||
* @usage_hint: VA usage hint
|
* @usage_hint: VA usage hint
|
||||||
* @use_derived: a #GstVaFeature
|
* @feat_use_derived: a #GstVaFeature
|
||||||
*
|
*
|
||||||
* Sets the configuration defined by @info, @usage_hint and
|
* Sets the configuration defined by @info, @usage_hint and
|
||||||
* @use_derived for @allocator, and it tries the configuration, if
|
* @use_derived for @allocator, and it tries the configuration, if
|
||||||
|
@ -1960,9 +1955,10 @@ gst_va_allocator_try (GstAllocator * allocator)
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
|
gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
|
||||||
guint usage_hint, GstVaFeature use_derived)
|
guint usage_hint, GstVaFeature feat_use_derived)
|
||||||
{
|
{
|
||||||
GstVaAllocator *self;
|
GstVaAllocator *self;
|
||||||
|
gboolean use_derived;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), FALSE);
|
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);
|
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_va_memory_pool_surface_count (&self->pool) != 0) {
|
||||||
if (GST_VIDEO_INFO_FORMAT (info) == GST_VIDEO_INFO_FORMAT (&self->info)
|
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_WIDTH (info) == GST_VIDEO_INFO_WIDTH (&self->info)
|
||||||
&& GST_VIDEO_INFO_HEIGHT (info) == GST_VIDEO_INFO_HEIGHT (&self->info)
|
&& GST_VIDEO_INFO_HEIGHT (info) == GST_VIDEO_INFO_HEIGHT (&self->info)
|
||||||
&& usage_hint == self->usage_hint
|
&& usage_hint == self->usage_hint && use_derived == self->use_derived) {
|
||||||
&& use_derived == self->feat_use_derived) {
|
|
||||||
*info = self->info; /* update callee info (offset & stride) */
|
*info = self->info; /* update callee info (offset & stride) */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1983,12 +1981,11 @@ gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
|
||||||
}
|
}
|
||||||
|
|
||||||
self->usage_hint = usage_hint;
|
self->usage_hint = usage_hint;
|
||||||
self->feat_use_derived = use_derived;
|
|
||||||
self->info = *info;
|
self->info = *info;
|
||||||
|
|
||||||
g_clear_pointer (&self->copy, gst_va_surface_copy_free);
|
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)
|
if (ret)
|
||||||
*info = self->info;
|
*info = self->info;
|
||||||
|
|
||||||
|
@ -2000,8 +1997,8 @@ gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
|
||||||
* @allocator: a #GstAllocator
|
* @allocator: a #GstAllocator
|
||||||
* @info: (out) (optional): a #GstVideoInfo
|
* @info: (out) (optional): a #GstVideoInfo
|
||||||
* @usage_hint: (out) (optional): VA usage hint
|
* @usage_hint: (out) (optional): VA usage hint
|
||||||
* @use_derived: (out) (optional): a #GstVaFeature if derived images
|
* @use_derived: (out) (optional): whether derived images are used for buffer
|
||||||
* are used for buffer mapping.
|
* mapping.
|
||||||
*
|
*
|
||||||
* Gets current internal configuration of @allocator.
|
* Gets current internal configuration of @allocator.
|
||||||
*
|
*
|
||||||
|
@ -2012,7 +2009,7 @@ gst_va_allocator_set_format (GstAllocator * allocator, GstVideoInfo * info,
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info,
|
gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info,
|
||||||
guint * usage_hint, GstVaFeature * use_derived)
|
guint * usage_hint, gboolean * use_derived)
|
||||||
{
|
{
|
||||||
GstVaAllocator *self;
|
GstVaAllocator *self;
|
||||||
|
|
||||||
|
@ -2027,7 +2024,7 @@ gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info,
|
||||||
if (usage_hint)
|
if (usage_hint)
|
||||||
*usage_hint = self->usage_hint;
|
*usage_hint = self->usage_hint;
|
||||||
if (use_derived)
|
if (use_derived)
|
||||||
*use_derived = self->feat_use_derived;
|
*use_derived = self->use_derived;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,12 +113,12 @@ GST_VA_API
|
||||||
gboolean gst_va_allocator_set_format (GstAllocator * allocator,
|
gboolean gst_va_allocator_set_format (GstAllocator * allocator,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
guint usage_hint,
|
guint usage_hint,
|
||||||
GstVaFeature use_derived);
|
GstVaFeature feat_use_derived);
|
||||||
GST_VA_API
|
GST_VA_API
|
||||||
gboolean gst_va_allocator_get_format (GstAllocator * allocator,
|
gboolean gst_va_allocator_get_format (GstAllocator * allocator,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
guint * usage_hint,
|
guint * usage_hint,
|
||||||
GstVaFeature * use_derived);
|
gboolean * use_derived);
|
||||||
GST_VA_API
|
GST_VA_API
|
||||||
void gst_va_allocator_set_hacks (GstAllocator * allocator,
|
void gst_va_allocator_set_hacks (GstAllocator * allocator,
|
||||||
guint32 hacks);
|
guint32 hacks);
|
||||||
|
|
Loading…
Reference in a new issue