mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
libs: move memory types conversions to gstvaapiutils
And add more supported memory types by current VA.
This commit is contained in:
parent
4851959da8
commit
738be524b1
4 changed files with 80 additions and 41 deletions
|
@ -30,44 +30,6 @@
|
|||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
guint
|
||||
from_GstVaapiBufferMemoryType (guint type)
|
||||
{
|
||||
guint va_type;
|
||||
|
||||
switch (type) {
|
||||
case GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF:
|
||||
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
|
||||
break;
|
||||
case GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF:
|
||||
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM;
|
||||
break;
|
||||
default:
|
||||
va_type = 0;
|
||||
break;
|
||||
}
|
||||
return va_type;
|
||||
}
|
||||
|
||||
guint
|
||||
to_GstVaapiBufferMemoryType (guint va_type)
|
||||
{
|
||||
guint type;
|
||||
|
||||
switch (va_type) {
|
||||
case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME:
|
||||
type = GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF;
|
||||
break;
|
||||
case VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM:
|
||||
type = GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF;
|
||||
break;
|
||||
default:
|
||||
type = 0;
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
|
||||
{
|
||||
|
|
|
@ -59,14 +59,20 @@ typedef struct _GstVaapiBufferProxy GstVaapiBufferProxy;
|
|||
|
||||
/**
|
||||
* GstVaapiBufferMemoryType:
|
||||
* @GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF: DRM PRIME buffer memory type.
|
||||
* @GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF: DRM PRIME buffer memory type (old version).
|
||||
* @GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF2: DRM PRIME buffer memory type.
|
||||
* @GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF: Kernel DRM buffer memory type.
|
||||
* @GST_VAAPI_BUFFER_MEMORY_TYPE_V4L2: V4L2 buffer memory type.
|
||||
* @GST_VAAPI_BUFFER_MEMORY_TYPE_USER_PTR: User pointer memory type.
|
||||
*
|
||||
* Set of underlying VA buffer memory types.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF = 1,
|
||||
GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF2,
|
||||
GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF,
|
||||
GST_VAAPI_BUFFER_MEMORY_TYPE_V4L2,
|
||||
GST_VAAPI_BUFFER_MEMORY_TYPE_USER_PTR,
|
||||
} GstVaapiBufferMemoryType;
|
||||
|
||||
GstVaapiBufferProxy *
|
||||
|
|
|
@ -25,9 +25,10 @@
|
|||
#include "sysdeps.h"
|
||||
#include "gstvaapicompat.h"
|
||||
#include "gstvaapiutils.h"
|
||||
#include "gstvaapisurface.h"
|
||||
#include "gstvaapisubpicture.h"
|
||||
#include "gstvaapibufferproxy.h"
|
||||
#include "gstvaapifilter.h"
|
||||
#include "gstvaapisubpicture.h"
|
||||
#include "gstvaapisurface.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
@ -907,3 +908,65 @@ from_GstVideoOrientationMethod (guint value, guint * va_mirror,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* from_GstVaapiBufferMemoryType:
|
||||
* @type: a #GstVaapiBufferMemoryType
|
||||
*
|
||||
* Returns: the VA's memory type symbol
|
||||
**/
|
||||
guint
|
||||
from_GstVaapiBufferMemoryType (guint type)
|
||||
{
|
||||
guint va_type;
|
||||
|
||||
switch (type) {
|
||||
#if VA_CHECK_VERSION(1,1,0)
|
||||
case GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF2:
|
||||
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2;
|
||||
break;
|
||||
#endif
|
||||
case GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF:
|
||||
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
|
||||
break;
|
||||
case GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF:
|
||||
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM;
|
||||
break;
|
||||
case GST_VAAPI_BUFFER_MEMORY_TYPE_V4L2:
|
||||
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_V4L2;
|
||||
break;
|
||||
case GST_VAAPI_BUFFER_MEMORY_TYPE_USER_PTR:
|
||||
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR;
|
||||
default:
|
||||
va_type = 0;
|
||||
break;
|
||||
}
|
||||
return va_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* to_GstVaapiBufferMemoryType:
|
||||
* @va_type: a VA's memory type symbol
|
||||
*
|
||||
* It will return the first "supported" memory type from @va_type bit
|
||||
* flag.
|
||||
*
|
||||
* Returns: a #GstVaapiBufferMemoryType or 0 if unknown.
|
||||
**/
|
||||
guint
|
||||
to_GstVaapiBufferMemoryType (guint va_type)
|
||||
{
|
||||
#if VA_CHECK_VERSION(1,1,0)
|
||||
if ((va_type & VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2))
|
||||
return GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF2;
|
||||
#endif
|
||||
if ((va_type & VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME))
|
||||
return GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF;
|
||||
if ((va_type & VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM))
|
||||
return GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF;
|
||||
if ((va_type & VA_SURFACE_ATTRIB_MEM_TYPE_V4L2))
|
||||
return GST_VAAPI_BUFFER_MEMORY_TYPE_V4L2;
|
||||
if ((va_type & VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR))
|
||||
return GST_VAAPI_BUFFER_MEMORY_TYPE_USER_PTR;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -158,4 +158,12 @@ void
|
|||
from_GstVideoOrientationMethod (guint value, guint * va_mirror,
|
||||
guint * va_rotation);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiBufferMemoryType (guint type);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
to_GstVaapiBufferMemoryType (guint va_type);
|
||||
|
||||
#endif /* GST_VAAPI_UTILS_H */
|
||||
|
|
Loading…
Reference in a new issue