aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-09-18 20:48:15 -0400
committerMarek Olšák <[email protected]>2019-10-09 17:06:54 -0400
commit35680bfea1d0e2fe8ee4504cf1e4ae4aa747b766 (patch)
tree921e0d45fc8b258329fa460f70ba3e0adcc63c1b
parenta122e708580627f10df00ab9ac3103c398f11a53 (diff)
vl: use u_format in vl_video_buffer_formats
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
-rw-r--r--src/gallium/auxiliary/vl/vl_stubs.c6
-rw-r--r--src/gallium/auxiliary/vl/vl_video_buffer.c114
-rw-r--r--src/gallium/auxiliary/vl/vl_video_buffer.h5
-rw-r--r--src/gallium/drivers/r600/r600_uvd.c6
-rw-r--r--src/gallium/drivers/radeonsi/si_uvd.c6
-rw-r--r--src/gallium/state_trackers/va/surface.c6
6 files changed, 31 insertions, 112 deletions
diff --git a/src/gallium/auxiliary/vl/vl_stubs.c b/src/gallium/auxiliary/vl/vl_stubs.c
index d3fce669e55..befd2468f49 100644
--- a/src/gallium/auxiliary/vl/vl_stubs.c
+++ b/src/gallium/auxiliary/vl/vl_stubs.c
@@ -39,11 +39,11 @@ vl_create_decoder(struct pipe_context *pipe,
/*
* vl_video_buffer stubs
*/
-const enum pipe_format *
-vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format)
+void
+vl_get_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format,
+ enum pipe_format out_format[VL_NUM_COMPONENTS])
{
assert(0);
- return NULL;
}
bool
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c
index 0c6bf5e1291..b1769ee4f05 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -38,60 +38,6 @@
#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] = {
0,
1,
@@ -104,40 +50,22 @@ const unsigned const_resource_plane_order_YVU[3] = {
1
};
-const enum pipe_format *
-vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format)
+void
+vl_get_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format,
+ enum pipe_format out_format[VL_NUM_COMPONENTS])
{
- switch(format) {
- case PIPE_FORMAT_YV12:
- return const_resource_formats_YV12;
-
- case PIPE_FORMAT_NV12:
- return const_resource_formats_NV12;
-
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return const_resource_formats_YUVA;
-
- case PIPE_FORMAT_B8G8R8A8_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;
+ unsigned num_planes = util_format_get_num_planes(format);
+ unsigned i;
- case PIPE_FORMAT_P016:
- return const_resource_formats_P016;
+ for (i = 0; i < num_planes; i++)
+ out_format[i] = util_format_get_plane_format(format, i);
+ for (; i < VL_NUM_COMPONENTS; i++)
+ out_format[i] = PIPE_FORMAT_NONE;
- default:
- return NULL;
- }
+ if (format == PIPE_FORMAT_YUYV)
+ out_format[0] = PIPE_FORMAT_R8G8_R8B8_UNORM;
+ else if (format == PIPE_FORMAT_UYVY)
+ out_format[0] = PIPE_FORMAT_G8R8_B8R8_UNORM;
}
const unsigned *
@@ -178,12 +106,10 @@ vl_video_buffer_is_format_supported(struct pipe_screen *screen,
enum pipe_video_profile profile,
enum pipe_video_entrypoint entrypoint)
{
- const enum pipe_format *resource_formats;
+ enum pipe_format resource_formats[VL_NUM_COMPONENTS];
unsigned i;
- resource_formats = vl_video_buffer_formats(screen, format);
- if (!resource_formats)
- return false;
+ vl_get_video_buffer_formats(screen, format, resource_formats);
for (i = 0; i < VL_NUM_COMPONENTS; ++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 pipe_sampler_view sv_templ;
struct pipe_context *pipe;
- const enum pipe_format *sampler_format;
+ enum pipe_format sampler_format[VL_NUM_COMPONENTS];
const unsigned *plane_order;
unsigned i, j, component;
@@ -336,7 +262,7 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
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);
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,
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;
bool pot_buffers;
@@ -431,9 +357,7 @@ vl_video_buffer_create(struct pipe_context *pipe,
PIPE_VIDEO_CAP_NPOT_TEXTURES
);
- resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format);
- if (!resource_formats)
- return NULL;
+ vl_get_video_buffer_formats(pipe->screen, tmpl->buffer_format, resource_formats);
templat = *tmpl;
templat.width = pot_buffers ? util_next_power_of_two(tmpl->width)
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h
index 5f21ab2650f..ae98341ae25 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.h
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.h
@@ -69,8 +69,9 @@ vl_video_buffer_adjust_size(unsigned *width, unsigned *height, unsigned plane,
/**
* get subformats for each plane
*/
-const enum pipe_format *
-vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format);
+void
+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
diff --git a/src/gallium/drivers/r600/r600_uvd.c b/src/gallium/drivers/r600/r600_uvd.c
index ca4248aed69..2e7d7ee4d40 100644
--- a/src/gallium/drivers/r600/r600_uvd.c
+++ b/src/gallium/drivers/r600/r600_uvd.c
@@ -62,7 +62,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
struct r600_texture *resources[VL_NUM_COMPONENTS] = {};
struct radeon_surf* surfaces[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_resource templ;
unsigned i, array_size;
@@ -70,9 +70,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
assert(pipe);
/* first create the needed resources as "normal" textures */
- resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format);
- if (!resource_formats)
- return NULL;
+ vl_get_video_buffer_formats(pipe->screen, tmpl->buffer_format, resource_formats);
array_size = tmpl->interlaced ? 2 : 1;
template = *tmpl;
diff --git a/src/gallium/drivers/radeonsi/si_uvd.c b/src/gallium/drivers/radeonsi/si_uvd.c
index 19d1b09f1c1..1469b6ac7f1 100644
--- a/src/gallium/drivers/radeonsi/si_uvd.c
+++ b/src/gallium/drivers/radeonsi/si_uvd.c
@@ -44,7 +44,7 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
struct si_texture *resources[VL_NUM_COMPONENTS] = {};
struct radeon_surf *surfaces[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_resource templ;
unsigned i, array_size;
@@ -52,9 +52,7 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
assert(pipe);
/* first create the needed resources as "normal" textures */
- resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format);
- if (!resource_formats)
- return NULL;
+ vl_get_video_buffer_formats(pipe->screen, tmpl->buffer_format, resource_formats);
array_size = tmpl->interlaced ? 2 : 1;
vidtemplate = *tmpl;
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index 86daf0f7988..391eab65e69 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -565,7 +565,7 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
struct pipe_resource res_templ;
struct winsys_handle whandle;
struct pipe_resource *resources[VL_NUM_COMPONENTS];
- const enum pipe_format *resource_formats = NULL;
+ enum pipe_format resource_formats[VL_NUM_COMPONENTS];
VAStatus result;
int i;
@@ -584,9 +584,7 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
if (memory_attribute->num_planes > VL_NUM_COMPONENTS)
return VA_STATUS_ERROR_INVALID_PARAMETER;
- resource_formats = vl_video_buffer_formats(pscreen, templat->buffer_format);
- if (!resource_formats)
- return VA_STATUS_ERROR_INVALID_PARAMETER;
+ vl_get_video_buffer_formats(pscreen, templat->buffer_format, resource_formats);
memset(&res_templ, 0, sizeof(res_templ));
res_templ.target = PIPE_TEXTURE_2D;