mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
msdk: Add a helper function to get supported modifiers
The modifiers will be used when creating caps for dma feature. co-authored-by: Mengkejiergeli Ba <mengkejiergeli.ba@intel.com> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5208>
This commit is contained in:
parent
ea6d602cca
commit
8100b04ea0
2 changed files with 72 additions and 0 deletions
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <va/va.h>
|
||||
#include <va/va_drmcommon.h>
|
||||
#include <libdrm/drm_fourcc.h>
|
||||
#include <unistd.h>
|
||||
#include "gstmsdkallocator.h"
|
||||
#include "gstmsdkallocator_libva.h"
|
||||
|
@ -776,3 +777,70 @@ error_destroy_va_surface:
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
_get_usage_hint (GstMsdkContextJobType job_type)
|
||||
{
|
||||
guint hint = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC;
|
||||
|
||||
switch (job_type) {
|
||||
case GST_MSDK_JOB_DECODER:
|
||||
hint |= VA_SURFACE_ATTRIB_USAGE_HINT_DECODER;
|
||||
break;
|
||||
case GST_MSDK_JOB_ENCODER:
|
||||
hint |= VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER;
|
||||
break;
|
||||
case GST_MSDK_JOB_VPP:
|
||||
hint |= VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ |
|
||||
VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE;
|
||||
break;
|
||||
default:
|
||||
GST_WARNING ("Unsupported job type %d", job_type);
|
||||
break;
|
||||
}
|
||||
|
||||
return hint;
|
||||
}
|
||||
|
||||
void
|
||||
gst_msdk_get_supported_modifiers (GstMsdkContext * context,
|
||||
GstMsdkContextJobType job_type, GstVideoFormat format, GValue * modifiers)
|
||||
{
|
||||
guint64 mod = DRM_FORMAT_MOD_INVALID;
|
||||
guint64 mod_gen = DRM_FORMAT_MOD_INVALID;
|
||||
GValue gmod = G_VALUE_INIT;
|
||||
guint usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC;
|
||||
GstVaDisplay *display =
|
||||
(GstVaDisplay *) gst_msdk_context_get_va_display (context);
|
||||
|
||||
g_value_init (&gmod, G_TYPE_UINT64);
|
||||
|
||||
mod = gst_va_dmabuf_get_modifier_for_format (display, format, usage_hint);
|
||||
if (mod != DRM_FORMAT_MOD_INVALID && mod != DRM_FORMAT_MOD_LINEAR) {
|
||||
g_value_set_uint64 (&gmod, mod);
|
||||
gst_value_list_append_value (modifiers, &gmod);
|
||||
}
|
||||
|
||||
usage_hint = _get_usage_hint (job_type);
|
||||
if (usage_hint != VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC) {
|
||||
mod_gen =
|
||||
gst_va_dmabuf_get_modifier_for_format (display, format, usage_hint);
|
||||
if (mod_gen != mod && mod_gen != DRM_FORMAT_MOD_INVALID &&
|
||||
mod_gen != DRM_FORMAT_MOD_LINEAR) {
|
||||
g_value_set_uint64 (&gmod, mod_gen);
|
||||
gst_value_list_append_value (modifiers, &gmod);
|
||||
}
|
||||
}
|
||||
|
||||
if (mod == DRM_FORMAT_MOD_LINEAR || mod_gen == DRM_FORMAT_MOD_LINEAR) {
|
||||
g_value_set_uint64 (&gmod, DRM_FORMAT_MOD_LINEAR);
|
||||
gst_value_list_append_value (modifiers, &gmod);
|
||||
}
|
||||
|
||||
if (mod == DRM_FORMAT_MOD_INVALID && mod_gen == DRM_FORMAT_MOD_INVALID) {
|
||||
GST_WARNING ("Failed to get modifier %s:0x%016llx",
|
||||
gst_video_format_to_string (format), DRM_FORMAT_MOD_INVALID);
|
||||
}
|
||||
|
||||
g_value_unset (&gmod);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,10 @@ gboolean
|
|||
gst_msdk_replace_mfx_memid (GstMsdkContext *context,
|
||||
mfxFrameSurface1 *mfx_surface, VASurfaceID surface_id);
|
||||
|
||||
void
|
||||
gst_msdk_get_supported_modifiers (GstMsdkContext * context,
|
||||
GstMsdkContextJobType job_type, GstVideoFormat format, GValue * modifiers);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_MSDK_ALLOCATOR_LIBVA_H_ */
|
||||
|
|
Loading…
Reference in a new issue