vl: initial implementation of vlVaQueryImageFormats(), vlVaCreateImage(), vlVaQuerySubpictureFormats(), vlVaCreateSurfaces(), vlVaQueryConfigEntrypoints(), vlVaQueryConfigProfiles()
This commit is contained in:
parent
8ba4c96f82
commit
2b296ec77c
|
@ -30,6 +30,8 @@
|
|||
#include <va/va_backend.h>
|
||||
#include "va_private.h"
|
||||
|
||||
struct VADriverVTable vlVaGetVtable();
|
||||
|
||||
static struct VADriverVTable vtable =
|
||||
{
|
||||
&vlVaTerminate, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */
|
||||
|
@ -125,7 +127,7 @@ static struct VADriverVTable vtable =
|
|||
unsigned int *buffer_name,
|
||||
void **buffer); */
|
||||
&vlVaUnlockSurface, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */
|
||||
0x44 /* struct VADriverVTableGLX *glx; "Optional" */
|
||||
NULL /* struct VADriverVTableGLX *glx; "Optional" */
|
||||
};
|
||||
|
||||
struct VADriverVTable vlVaGetVtable()
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
#include <os/os_thread.h>
|
||||
#include "va_private.h"
|
||||
|
||||
#define VL_HANDLES
|
||||
|
||||
typedef uint32_t vlHandle;
|
||||
boolean vlCreateHTAB(void);
|
||||
void vlDestroyHTAB(void);
|
||||
vlHandle vlAddDataHTAB(void *data);
|
||||
void* vlGetDataHTAB(vlHandle handle);
|
||||
|
||||
#ifdef VL_HANDLES
|
||||
static struct handle_table *htab = NULL;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <va/va.h>
|
||||
#include <va/va_backend.h>
|
||||
#include <util/u_debug.h>
|
||||
#include "va_private.h"
|
||||
|
||||
VAStatus vlVaQueryConfigProfiles( VADriverContextP ctx,
|
||||
|
@ -36,19 +37,48 @@ VAStatus vlVaQueryConfigProfiles( VADriverContextP ctx,
|
|||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
int i = 0;
|
||||
|
||||
profile_list[i++] = VAProfileMPEG2Simple;
|
||||
*num_profiles = i;
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
VAStatus vlVaQueryConfigEntrypoints( VADriverContextP ctx,
|
||||
VAProfile profile,
|
||||
VAEntrypoint *entypoint_list,
|
||||
VAEntrypoint *entrypoint_list,
|
||||
int *num_entrypoints)
|
||||
{
|
||||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
VAStatus vaStatus = VA_STATUS_SUCCESS;
|
||||
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
switch (profile) {
|
||||
case VAProfileMPEG2Simple:
|
||||
case VAProfileMPEG2Main:
|
||||
VA_INFO("Using profile %08x\n",profile);
|
||||
*num_entrypoints = 1;
|
||||
entrypoint_list[0] = VAEntrypointMoComp;
|
||||
break;
|
||||
|
||||
case VAProfileH264Baseline:
|
||||
case VAProfileH264Main:
|
||||
case VAProfileH264High:
|
||||
vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||
*num_entrypoints = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
VA_ERROR("Unsupported profile %08x\n",profile);
|
||||
vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||
*num_entrypoints = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return vaStatus;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,10 @@
|
|||
|
||||
#include <pipe/p_compiler.h>
|
||||
#include <pipe/p_video_context.h>
|
||||
#include <pipe/p_screen.h>
|
||||
#include <vl_winsys.h>
|
||||
#include <util/u_debug.h>
|
||||
#include <util/u_memory.h>
|
||||
#include <va/va.h>
|
||||
#include <va/va_backend.h>
|
||||
#include "va_private.h"
|
||||
|
@ -37,19 +40,35 @@
|
|||
PUBLIC
|
||||
VAStatus __vaDriverInit_0_31 (VADriverContextP ctx)
|
||||
{
|
||||
vlVaDriverContextPriv *driver_context = NULL;
|
||||
|
||||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
|
||||
|
||||
/* Create private driver context */
|
||||
driver_context = CALLOC(1,sizeof(vlVaDriverContextPriv));
|
||||
if (!driver_context)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
|
||||
driver_context->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
|
||||
if (!driver_context->vscreen)
|
||||
{
|
||||
FREE(driver_context);
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
ctx->str_vendor = "mesa gallium vaapi";
|
||||
ctx->vtable = vlVaGetVtable();
|
||||
ctx->max_attributes = 1;
|
||||
ctx->max_display_attributes = 1;
|
||||
ctx->max_entrypoints = 1;
|
||||
ctx->max_image_formats = 1;
|
||||
ctx->max_entrypoints = VA_MAX_ENTRYPOINTS;
|
||||
ctx->max_image_formats = VA_MAX_IMAGE_FORMATS_SUPPORTED;
|
||||
ctx->max_profiles = 1;
|
||||
ctx->max_subpic_formats = 1;
|
||||
ctx->max_subpic_formats = VA_MAX_SUBPIC_FORMATS_SUPPORTED;
|
||||
ctx->version_major = 3;
|
||||
ctx->version_minor = 1;
|
||||
ctx->pDriverData = (void *)driver_context;
|
||||
|
||||
VA_INFO("vl_screen_pointer %p\n",ctx->native_dpy);
|
||||
|
||||
|
|
|
@ -37,8 +37,12 @@ VAStatus vlVaQueryDisplayAttributes( VADriverContextP ctx,
|
|||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
if (!(attr_list && num_attributes))
|
||||
return VA_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
*num_attributes = 0;
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VAStatus vlVaGetDisplayAttributes( VADriverContextP ctx,
|
||||
|
|
|
@ -27,10 +27,30 @@
|
|||
|
||||
#include <util/u_memory.h>
|
||||
#include <util/u_format.h>
|
||||
#include <util/u_debug.h>
|
||||
#include <pipe/p_format.h>
|
||||
#include <va/va.h>
|
||||
#include <va/va_backend.h>
|
||||
#include "va_private.h"
|
||||
|
||||
typedef struct {
|
||||
enum pipe_format pipe_format;
|
||||
VAImageFormat va_format;
|
||||
} va_image_formats_supported_t;
|
||||
|
||||
static const va_image_formats_supported_t va_image_formats_supported[VA_MAX_IMAGE_FORMATS_SUPPORTED] =
|
||||
{
|
||||
{ PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
{ VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }},
|
||||
{ PIPE_FORMAT_R8G8B8A8_UNORM,
|
||||
{ VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }}
|
||||
};
|
||||
|
||||
boolean vlCreateHTAB(void);
|
||||
void vlDestroyHTAB(void);
|
||||
vlHandle vlAddDataHTAB(void *data);
|
||||
void* vlGetDataHTAB(vlHandle handle);
|
||||
|
||||
VAStatus
|
||||
vlVaQueryImageFormats ( VADriverContextP ctx,
|
||||
VAImageFormat *format_list,
|
||||
|
@ -39,8 +59,20 @@ vlVaQueryImageFormats ( VADriverContextP ctx,
|
|||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
if (!(format_list && num_formats))
|
||||
return VA_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
int n = 0;
|
||||
|
||||
num_formats[0] = VA_MAX_IMAGE_FORMATS_SUPPORTED;
|
||||
|
||||
/* Query supported formats */
|
||||
for (n = 0; n < VA_MAX_IMAGE_FORMATS_SUPPORTED; n++)
|
||||
{
|
||||
format_list[n] = va_image_formats_supported[n].va_format;
|
||||
}
|
||||
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VAStatus vlVaCreateImage( VADriverContextP ctx,
|
||||
|
@ -52,7 +84,31 @@ VAStatus vlVaCreateImage( VADriverContextP ctx,
|
|||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
if(!format)
|
||||
return VA_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
if (!(width && height))
|
||||
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
|
||||
|
||||
if (!vlCreateHTAB())
|
||||
return VA_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
switch (format->fourcc) {
|
||||
case VA_FOURCC('B','G','R','A'):
|
||||
VA_INFO("Creating BGRA image of size %dx%d\n",width,height);
|
||||
break;
|
||||
case VA_FOURCC_RGBA:
|
||||
VA_INFO("Creating RGBA image of size %dx%d\n",width,height);
|
||||
break;
|
||||
default:
|
||||
VA_ERROR("Couldn't create image of type %0x08\n",format->fourcc);
|
||||
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
|
||||
break;
|
||||
}
|
||||
|
||||
VA_INFO("Image %p created successfully\n",format);
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VAStatus vlVaDeriveImage( VADriverContextP ctx,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <va/va.h>
|
||||
#include <va/va_backend.h>
|
||||
#include <util/u_debug.h>
|
||||
#include "va_private.h"
|
||||
|
||||
VAStatus vlVaBeginPicture( VADriverContextP ctx,
|
||||
|
|
|
@ -30,17 +30,41 @@
|
|||
|
||||
#include <va/va.h>
|
||||
#include <va/va_backend.h>
|
||||
#include <pipe/p_format.h>
|
||||
#include <pipe/p_state.h>
|
||||
|
||||
#define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__)
|
||||
#define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__)
|
||||
#define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__)
|
||||
#define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__)
|
||||
|
||||
#define VA_MAX_IMAGE_FORMATS_SUPPORTED 2
|
||||
#define VA_MAX_SUBPIC_FORMATS_SUPPORTED 2
|
||||
#define VA_MAX_ENTRYPOINTS 1
|
||||
|
||||
#define VL_HANDLES
|
||||
|
||||
typedef unsigned int vlHandle;
|
||||
|
||||
typedef struct {
|
||||
struct vl_screen *vscreen;
|
||||
struct pipe_surface *backbuffer;
|
||||
} vlVaDriverContextPriv;
|
||||
|
||||
typedef struct {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
enum pipe_video_chroma_format format;
|
||||
VADriverContextP ctx;
|
||||
} vlVaSurfacePriv;
|
||||
|
||||
// Public functions:
|
||||
VAStatus __vaDriverInit_0_31 (VADriverContextP ctx);
|
||||
|
||||
// Private functions:
|
||||
struct VADriverVTable vlVaGetVtable();
|
||||
|
||||
|
||||
// Vtable functions:
|
||||
VAStatus vlVaTerminate (VADriverContextP ctx);
|
||||
VAStatus vlVaQueryConfigProfiles (VADriverContextP ctx, VAProfile *profile_list,int *num_profiles);
|
||||
|
|
|
@ -30,23 +30,20 @@
|
|||
#include <pipe/p_format.h>
|
||||
#include "va_private.h"
|
||||
|
||||
#define NUM_FORMATS_SUPPORTED 2
|
||||
|
||||
typedef struct {
|
||||
enum pipe_format;
|
||||
enum pipe_format pipe_format;
|
||||
VAImageFormat va_format;
|
||||
unsigned int va_flags;
|
||||
} va_subpicture_formats_supported_t;
|
||||
|
||||
static const va_subpicture_formats_supported_t va_subpicture_formats_supported[NUM_FORMATS_SUPPORTED] =
|
||||
static const va_subpicture_formats_supported_t va_subpicture_formats_supported[VA_MAX_SUBPIC_FORMATS_SUPPORTED + 1] =
|
||||
{
|
||||
{ PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
{ VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32,
|
||||
32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 },
|
||||
{ VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 },
|
||||
0 },
|
||||
{ PIPE_FORMAT_R8G8B8A8_UNORM,
|
||||
{ VA_FOURCC('R','G','B','A'), VA_LSB_FIRST, 32,
|
||||
32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 },
|
||||
{ VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 },
|
||||
0 }
|
||||
};
|
||||
|
||||
|
@ -62,12 +59,15 @@ vlVaQuerySubpictureFormats( VADriverContextP ctx,
|
|||
if (!(format_list && flags && num_formats))
|
||||
return VA_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
num_formats[0] = VA_MAX_SUBPIC_FORMATS_SUPPORTED;
|
||||
|
||||
int n = 0;
|
||||
/* Query supported formats */
|
||||
for (n = 0; n < NUM_FORMATS_SUPPORTED; n++)
|
||||
for (n = 0; n < VA_MAX_SUBPIC_FORMATS_SUPPORTED ; n++)
|
||||
{
|
||||
flags[n] = va_subpicture_formats_supported[n].va_flags;
|
||||
format_list[n] = va_subpicture_formats_supported[n].va_format;
|
||||
const va_subpicture_formats_supported_t * const format_map = &va_subpicture_formats_supported[n];
|
||||
flags[n] = format_map->va_flags;
|
||||
format_list[n] = format_map->va_format;
|
||||
}
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
|
|
|
@ -27,8 +27,31 @@
|
|||
|
||||
#include <va/va.h>
|
||||
#include <va/va_backend.h>
|
||||
#include <util/u_debug.h>
|
||||
#include <util/u_memory.h>
|
||||
#include "va_private.h"
|
||||
|
||||
boolean vlCreateHTAB(void);
|
||||
void vlDestroyHTAB(void);
|
||||
vlHandle vlAddDataHTAB(void *data);
|
||||
void* vlGetDataHTAB(vlHandle handle);
|
||||
|
||||
static enum pipe_video_chroma_format VaRTFormatToPipe(unsigned int va_type)
|
||||
{
|
||||
switch (va_type) {
|
||||
case VA_RT_FORMAT_YUV420:
|
||||
return PIPE_VIDEO_CHROMA_FORMAT_420;
|
||||
case VA_RT_FORMAT_YUV422:
|
||||
return PIPE_VIDEO_CHROMA_FORMAT_422;
|
||||
case VA_RT_FORMAT_YUV444:
|
||||
return PIPE_VIDEO_CHROMA_FORMAT_444;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
VAStatus vlVaCreateSurfaces( VADriverContextP ctx,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -39,7 +62,31 @@ VAStatus vlVaCreateSurfaces( VADriverContextP ctx,
|
|||
if (!ctx)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
/* We only support one format */
|
||||
if (VA_RT_FORMAT_YUV420 != format)
|
||||
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
|
||||
|
||||
if (!(width && height))
|
||||
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
|
||||
|
||||
if (!vlCreateHTAB())
|
||||
return VA_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
vlVaSurfacePriv *va_surface = (vlVaSurfacePriv *)CALLOC(num_surfaces,sizeof(vlVaSurfacePriv));
|
||||
if (!va_surface)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
|
||||
int n = 0;
|
||||
for (n = 0; n < num_surfaces; n++)
|
||||
{
|
||||
va_surface[n].width = width;
|
||||
va_surface[n].height = height;
|
||||
va_surface[n].format = VaRTFormatToPipe(format);
|
||||
va_surface[n].ctx = ctx;
|
||||
surfaces[n] = (VASurfaceID *)vlAddDataHTAB((void *)(va_surface + n));
|
||||
}
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VAStatus vlVaDestroySurfaces( VADriverContextP ctx,
|
||||
|
|
Loading…
Reference in New Issue