libs: move memory types conversions to gstvaapiutils

And add more supported memory types by current VA.
This commit is contained in:
Víctor Manuel Jáquez Leal 2019-08-02 12:46:55 +02:00
parent 4851959da8
commit 738be524b1
4 changed files with 80 additions and 41 deletions

View file

@ -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)
{

View file

@ -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 *

View file

@ -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;
}

View file

@ -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 */