static struct pipe_video_buffer *
vl_context_create_buffer(struct pipe_video_context *context,
enum pipe_format buffer_format,
+ enum pipe_format resource_formats[3],
enum pipe_video_chroma_format chroma_format,
unsigned width, unsigned height)
{
- const enum pipe_format resource_formats[3] = {
- PIPE_FORMAT_R8_SNORM,
- PIPE_FORMAT_R8_SNORM,
- PIPE_FORMAT_R8_SNORM
- };
-
struct vl_context *ctx = (struct vl_context*)context;
struct pipe_video_buffer *result;
unsigned buffer_width, buffer_height;
result = vl_video_buffer_init(context, ctx->pipe,
buffer_width, buffer_height, 1,
- chroma_format, 3,
+ chroma_format,
resource_formats,
PIPE_USAGE_STATIC);
if (result) // TODO move format handling into vl_video_buffer
formats[0] = formats[1] = formats[2] = dec->idct_source_format;
buffer->idct_source = vl_video_buffer_init(dec->base.context, dec->pipe,
dec->base.width / 4, dec->base.height, 1,
- dec->base.chroma_format, 3,
+ dec->base.chroma_format,
formats, PIPE_USAGE_STREAM);
if (!buffer->idct_source)
goto error_source;
buffer->idct_intermediate = vl_video_buffer_init(dec->base.context, dec->pipe,
dec->base.width / dec->nr_of_idct_render_targets,
dec->base.height / 4, dec->nr_of_idct_render_targets,
- dec->base.chroma_format, 3,
+ dec->base.chroma_format,
formats, PIPE_USAGE_STATIC);
if (!buffer->idct_intermediate)
formats[0] = formats[1] = formats[2] =dec->mc_source_format;
buffer->mc_source = vl_video_buffer_init(dec->base.context, dec->pipe,
dec->base.width, dec->base.height, 1,
- dec->base.chroma_format, 3,
+ dec->base.chroma_format,
formats, PIPE_USAGE_STATIC);
if (!buffer->mc_source)
struct pipe_context *pipe,
unsigned width, unsigned height, unsigned depth,
enum pipe_video_chroma_format chroma_format,
- unsigned num_planes,
const enum pipe_format resource_formats[VL_MAX_PLANES],
unsigned usage)
{
unsigned i;
assert(context && pipe);
- assert(num_planes > 0 && num_planes <= VL_MAX_PLANES);
buffer = CALLOC_STRUCT(vl_video_buffer);
buffer->base.get_sampler_views = vl_video_buffer_sampler_views;
buffer->base.get_surfaces = vl_video_buffer_surfaces;
buffer->pipe = pipe;
- buffer->num_planes = num_planes;
+ buffer->num_planes = 1;
memset(&templ, 0, sizeof(templ));
templ.target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D;
if (!buffer->resources[0])
goto error;
- if (num_planes == 1) {
+ if (resource_formats[1] == PIPE_FORMAT_NONE) {
assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444);
+ assert(resource_formats[2] == PIPE_FORMAT_NONE);
return &buffer->base;
- }
+ } else
+ buffer->num_planes = 2;
templ.format = resource_formats[1];
if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
if (!buffer->resources[1])
goto error;
- if (num_planes == 2)
+ if (resource_formats[2] == PIPE_FORMAT_NONE)
return &buffer->base;
+ else
+ buffer->num_planes = 3;
templ.format = resource_formats[2];
buffer->resources[2] = pipe->screen->resource_create(pipe->screen, &templ);
struct pipe_context *pipe,
unsigned width, unsigned height, unsigned depth,
enum pipe_video_chroma_format chroma_format,
- unsigned num_planes,
const enum pipe_format resource_formats[VL_MAX_PLANES],
unsigned usage);
#endif /* vl_ycbcr_buffer_h */
*/
struct pipe_video_buffer *(*create_buffer)(struct pipe_video_context *context,
enum pipe_format buffer_format,
+ enum pipe_format resource_formats[3],
enum pipe_video_chroma_format chroma_format,
unsigned width, unsigned height);
uint32_t width, uint32_t height,
VdpVideoSurface *surface)
{
+ const enum pipe_format resource_formats[3] = {
+ PIPE_FORMAT_R8_UNORM,
+ PIPE_FORMAT_R8_UNORM,
+ PIPE_FORMAT_R8_UNORM
+ };
+
vlVdpSurface *p_surf;
VdpStatus ret;
p_surf->device = dev;
p_surf->video_buffer = dev->context->vpipe->create_buffer(dev->context->vpipe,
PIPE_FORMAT_YV12, // most common used
+ resource_formats,
ChromaToPipe(chroma_type),
width, height);
PUBLIC
Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surface)
{
+ const enum pipe_format resource_formats[3] = {
+ PIPE_FORMAT_R8_SNORM,
+ PIPE_FORMAT_R8_SNORM,
+ PIPE_FORMAT_R8_SNORM
+ };
+
XvMCContextPrivate *context_priv;
struct pipe_video_context *vpipe;
XvMCSurfacePrivate *surface_priv;
surface_priv->decode_buffer = context_priv->decoder->create_buffer(context_priv->decoder);
surface_priv->video_buffer = vpipe->create_buffer(vpipe, PIPE_FORMAT_YV12, //TODO
+ resource_formats,
context_priv->decoder->chroma_format,
context_priv->decoder->width,
context_priv->decoder->height);