#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,
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 *
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];
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;
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 ) {
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;
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)