vl: use u_format in vl_video_buffer_formats
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
parent
a122e70858
commit
35680bfea1
|
@ -39,11 +39,11 @@ vl_create_decoder(struct pipe_context *pipe,
|
||||||
/*
|
/*
|
||||||
* vl_video_buffer stubs
|
* vl_video_buffer stubs
|
||||||
*/
|
*/
|
||||||
const enum pipe_format *
|
void
|
||||||
vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format)
|
vl_get_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format,
|
||||||
|
enum pipe_format out_format[VL_NUM_COMPONENTS])
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -38,60 +38,6 @@
|
||||||
|
|
||||||
#include "vl_video_buffer.h"
|
#include "vl_video_buffer.h"
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_YV12[3] = {
|
|
||||||
PIPE_FORMAT_R8_UNORM,
|
|
||||||
PIPE_FORMAT_R8_UNORM,
|
|
||||||
PIPE_FORMAT_R8_UNORM
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_NV12[3] = {
|
|
||||||
PIPE_FORMAT_R8_UNORM,
|
|
||||||
PIPE_FORMAT_R8G8_UNORM,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_YUVA[3] = {
|
|
||||||
PIPE_FORMAT_R8G8B8A8_UNORM,
|
|
||||||
PIPE_FORMAT_NONE,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_VUYA[3] = {
|
|
||||||
PIPE_FORMAT_B8G8R8A8_UNORM,
|
|
||||||
PIPE_FORMAT_NONE,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_YUVX[3] = {
|
|
||||||
PIPE_FORMAT_R8G8B8X8_UNORM,
|
|
||||||
PIPE_FORMAT_NONE,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_VUYX[3] = {
|
|
||||||
PIPE_FORMAT_B8G8R8X8_UNORM,
|
|
||||||
PIPE_FORMAT_NONE,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_YUYV[3] = {
|
|
||||||
PIPE_FORMAT_R8G8_R8B8_UNORM,
|
|
||||||
PIPE_FORMAT_NONE,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_UYVY[3] = {
|
|
||||||
PIPE_FORMAT_G8R8_B8R8_UNORM,
|
|
||||||
PIPE_FORMAT_NONE,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const enum pipe_format const_resource_formats_P016[3] = {
|
|
||||||
PIPE_FORMAT_R16_UNORM,
|
|
||||||
PIPE_FORMAT_R16G16_UNORM,
|
|
||||||
PIPE_FORMAT_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const unsigned const_resource_plane_order_YUV[3] = {
|
const unsigned const_resource_plane_order_YUV[3] = {
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
@ -104,40 +50,22 @@ const unsigned const_resource_plane_order_YVU[3] = {
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
|
|
||||||
const enum pipe_format *
|
void
|
||||||
vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format)
|
vl_get_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format,
|
||||||
|
enum pipe_format out_format[VL_NUM_COMPONENTS])
|
||||||
{
|
{
|
||||||
switch(format) {
|
unsigned num_planes = util_format_get_num_planes(format);
|
||||||
case PIPE_FORMAT_YV12:
|
unsigned i;
|
||||||
return const_resource_formats_YV12;
|
|
||||||
|
|
||||||
case PIPE_FORMAT_NV12:
|
for (i = 0; i < num_planes; i++)
|
||||||
return const_resource_formats_NV12;
|
out_format[i] = util_format_get_plane_format(format, i);
|
||||||
|
for (; i < VL_NUM_COMPONENTS; i++)
|
||||||
|
out_format[i] = PIPE_FORMAT_NONE;
|
||||||
|
|
||||||
case PIPE_FORMAT_R8G8B8A8_UNORM:
|
if (format == PIPE_FORMAT_YUYV)
|
||||||
return const_resource_formats_YUVA;
|
out_format[0] = PIPE_FORMAT_R8G8_R8B8_UNORM;
|
||||||
|
else if (format == PIPE_FORMAT_UYVY)
|
||||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
out_format[0] = PIPE_FORMAT_G8R8_B8R8_UNORM;
|
||||||
return const_resource_formats_VUYA;
|
|
||||||
|
|
||||||
case PIPE_FORMAT_R8G8B8X8_UNORM:
|
|
||||||
return const_resource_formats_YUVX;
|
|
||||||
|
|
||||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
|
||||||
return const_resource_formats_VUYX;
|
|
||||||
|
|
||||||
case PIPE_FORMAT_YUYV:
|
|
||||||
return const_resource_formats_YUYV;
|
|
||||||
|
|
||||||
case PIPE_FORMAT_UYVY:
|
|
||||||
return const_resource_formats_UYVY;
|
|
||||||
|
|
||||||
case PIPE_FORMAT_P016:
|
|
||||||
return const_resource_formats_P016;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned *
|
const unsigned *
|
||||||
|
@ -178,12 +106,10 @@ vl_video_buffer_is_format_supported(struct pipe_screen *screen,
|
||||||
enum pipe_video_profile profile,
|
enum pipe_video_profile profile,
|
||||||
enum pipe_video_entrypoint entrypoint)
|
enum pipe_video_entrypoint entrypoint)
|
||||||
{
|
{
|
||||||
const enum pipe_format *resource_formats;
|
enum pipe_format resource_formats[VL_NUM_COMPONENTS];
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
resource_formats = vl_video_buffer_formats(screen, format);
|
vl_get_video_buffer_formats(screen, format, resource_formats);
|
||||||
if (!resource_formats)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
|
for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
|
||||||
enum pipe_format format = resource_formats[i];
|
enum pipe_format format = resource_formats[i];
|
||||||
|
@ -328,7 +254,7 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
|
||||||
struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
|
struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
|
||||||
struct pipe_sampler_view sv_templ;
|
struct pipe_sampler_view sv_templ;
|
||||||
struct pipe_context *pipe;
|
struct pipe_context *pipe;
|
||||||
const enum pipe_format *sampler_format;
|
enum pipe_format sampler_format[VL_NUM_COMPONENTS];
|
||||||
const unsigned *plane_order;
|
const unsigned *plane_order;
|
||||||
unsigned i, j, component;
|
unsigned i, j, component;
|
||||||
|
|
||||||
|
@ -336,7 +262,7 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
|
||||||
|
|
||||||
pipe = buf->base.context;
|
pipe = buf->base.context;
|
||||||
|
|
||||||
sampler_format = vl_video_buffer_formats(pipe->screen, buf->base.buffer_format);
|
vl_get_video_buffer_formats(pipe->screen, buf->base.buffer_format, sampler_format);
|
||||||
plane_order = vl_video_buffer_plane_order(buf->base.buffer_format);
|
plane_order = vl_video_buffer_plane_order(buf->base.buffer_format);
|
||||||
|
|
||||||
for (component = 0, i = 0; i < buf->num_planes; ++i ) {
|
for (component = 0, i = 0; i < buf->num_planes; ++i ) {
|
||||||
|
@ -416,7 +342,7 @@ struct pipe_video_buffer *
|
||||||
vl_video_buffer_create(struct pipe_context *pipe,
|
vl_video_buffer_create(struct pipe_context *pipe,
|
||||||
const struct pipe_video_buffer *tmpl)
|
const struct pipe_video_buffer *tmpl)
|
||||||
{
|
{
|
||||||
const enum pipe_format *resource_formats;
|
enum pipe_format resource_formats[VL_NUM_COMPONENTS];
|
||||||
struct pipe_video_buffer templat, *result;
|
struct pipe_video_buffer templat, *result;
|
||||||
bool pot_buffers;
|
bool pot_buffers;
|
||||||
|
|
||||||
|
@ -431,9 +357,7 @@ vl_video_buffer_create(struct pipe_context *pipe,
|
||||||
PIPE_VIDEO_CAP_NPOT_TEXTURES
|
PIPE_VIDEO_CAP_NPOT_TEXTURES
|
||||||
);
|
);
|
||||||
|
|
||||||
resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format);
|
vl_get_video_buffer_formats(pipe->screen, tmpl->buffer_format, resource_formats);
|
||||||
if (!resource_formats)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
templat = *tmpl;
|
templat = *tmpl;
|
||||||
templat.width = pot_buffers ? util_next_power_of_two(tmpl->width)
|
templat.width = pot_buffers ? util_next_power_of_two(tmpl->width)
|
||||||
|
|
|
@ -69,8 +69,9 @@ vl_video_buffer_adjust_size(unsigned *width, unsigned *height, unsigned plane,
|
||||||
/**
|
/**
|
||||||
* get subformats for each plane
|
* get subformats for each plane
|
||||||
*/
|
*/
|
||||||
const enum pipe_format *
|
void
|
||||||
vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format);
|
vl_get_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format,
|
||||||
|
enum pipe_format out_format[VL_NUM_COMPONENTS]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get YUV plane order
|
* get YUV plane order
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
|
||||||
struct r600_texture *resources[VL_NUM_COMPONENTS] = {};
|
struct r600_texture *resources[VL_NUM_COMPONENTS] = {};
|
||||||
struct radeon_surf* surfaces[VL_NUM_COMPONENTS] = {};
|
struct radeon_surf* surfaces[VL_NUM_COMPONENTS] = {};
|
||||||
struct pb_buffer **pbs[VL_NUM_COMPONENTS] = {};
|
struct pb_buffer **pbs[VL_NUM_COMPONENTS] = {};
|
||||||
const enum pipe_format *resource_formats;
|
enum pipe_format resource_formats[3];
|
||||||
struct pipe_video_buffer template;
|
struct pipe_video_buffer template;
|
||||||
struct pipe_resource templ;
|
struct pipe_resource templ;
|
||||||
unsigned i, array_size;
|
unsigned i, array_size;
|
||||||
|
@ -70,9 +70,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
|
||||||
assert(pipe);
|
assert(pipe);
|
||||||
|
|
||||||
/* first create the needed resources as "normal" textures */
|
/* first create the needed resources as "normal" textures */
|
||||||
resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format);
|
vl_get_video_buffer_formats(pipe->screen, tmpl->buffer_format, resource_formats);
|
||||||
if (!resource_formats)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
array_size = tmpl->interlaced ? 2 : 1;
|
array_size = tmpl->interlaced ? 2 : 1;
|
||||||
template = *tmpl;
|
template = *tmpl;
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
|
||||||
struct si_texture *resources[VL_NUM_COMPONENTS] = {};
|
struct si_texture *resources[VL_NUM_COMPONENTS] = {};
|
||||||
struct radeon_surf *surfaces[VL_NUM_COMPONENTS] = {};
|
struct radeon_surf *surfaces[VL_NUM_COMPONENTS] = {};
|
||||||
struct pb_buffer **pbs[VL_NUM_COMPONENTS] = {};
|
struct pb_buffer **pbs[VL_NUM_COMPONENTS] = {};
|
||||||
const enum pipe_format *resource_formats;
|
enum pipe_format resource_formats[VL_NUM_COMPONENTS];
|
||||||
struct pipe_video_buffer vidtemplate;
|
struct pipe_video_buffer vidtemplate;
|
||||||
struct pipe_resource templ;
|
struct pipe_resource templ;
|
||||||
unsigned i, array_size;
|
unsigned i, array_size;
|
||||||
|
@ -52,9 +52,7 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
|
||||||
assert(pipe);
|
assert(pipe);
|
||||||
|
|
||||||
/* first create the needed resources as "normal" textures */
|
/* first create the needed resources as "normal" textures */
|
||||||
resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format);
|
vl_get_video_buffer_formats(pipe->screen, tmpl->buffer_format, resource_formats);
|
||||||
if (!resource_formats)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
array_size = tmpl->interlaced ? 2 : 1;
|
array_size = tmpl->interlaced ? 2 : 1;
|
||||||
vidtemplate = *tmpl;
|
vidtemplate = *tmpl;
|
||||||
|
|
|
@ -565,7 +565,7 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
|
||||||
struct pipe_resource res_templ;
|
struct pipe_resource res_templ;
|
||||||
struct winsys_handle whandle;
|
struct winsys_handle whandle;
|
||||||
struct pipe_resource *resources[VL_NUM_COMPONENTS];
|
struct pipe_resource *resources[VL_NUM_COMPONENTS];
|
||||||
const enum pipe_format *resource_formats = NULL;
|
enum pipe_format resource_formats[VL_NUM_COMPONENTS];
|
||||||
VAStatus result;
|
VAStatus result;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -584,9 +584,7 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
|
||||||
if (memory_attribute->num_planes > VL_NUM_COMPONENTS)
|
if (memory_attribute->num_planes > VL_NUM_COMPONENTS)
|
||||||
return VA_STATUS_ERROR_INVALID_PARAMETER;
|
return VA_STATUS_ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
resource_formats = vl_video_buffer_formats(pscreen, templat->buffer_format);
|
vl_get_video_buffer_formats(pscreen, templat->buffer_format, resource_formats);
|
||||||
if (!resource_formats)
|
|
||||||
return VA_STATUS_ERROR_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
memset(&res_templ, 0, sizeof(res_templ));
|
memset(&res_templ, 0, sizeof(res_templ));
|
||||||
res_templ.target = PIPE_TEXTURE_2D;
|
res_templ.target = PIPE_TEXTURE_2D;
|
||||||
|
|
Loading…
Reference in New Issue