{
unsigned nr_of_idct_render_targets, max_inst;
enum pipe_format formats[3];
+ struct pipe_video_buffer templat;
struct pipe_sampler_view *matrix = NULL;
nr_of_idct_render_targets = 1;
formats[0] = formats[1] = formats[2] = format_config->idct_source_format;
+ memset(&templat, 0, sizeof(templat));
+ templat.width = dec->base.width / 4;
+ templat.height = dec->base.height;
+ templat.chroma_format = dec->base.chroma_format;
dec->idct_source = vl_video_buffer_create_ex
(
- dec->base.context, dec->base.width / 4, dec->base.height, 1,
- dec->base.chroma_format, formats, PIPE_USAGE_STATIC
+ dec->base.context, &templat,
+ formats, 1, PIPE_USAGE_STATIC
);
if (!dec->idct_source)
goto error_idct_source;
formats[0] = formats[1] = formats[2] = format_config->mc_source_format;
+ memset(&templat, 0, sizeof(templat));
+ templat.width = dec->base.width / nr_of_idct_render_targets;
+ templat.height = dec->base.height / 4;
+ templat.chroma_format = dec->base.chroma_format;
dec->mc_source = vl_video_buffer_create_ex
(
- dec->base.context, dec->base.width / nr_of_idct_render_targets,
- dec->base.height / 4, nr_of_idct_render_targets,
- dec->base.chroma_format, formats, PIPE_USAGE_STATIC
+ dec->base.context, &templat,
+ formats, nr_of_idct_render_targets, PIPE_USAGE_STATIC
);
if (!dec->mc_source)
init_mc_source_widthout_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_config)
{
enum pipe_format formats[3];
+ struct pipe_video_buffer templat;
formats[0] = formats[1] = formats[2] = format_config->mc_source_format;
+ memset(&templat, 0, sizeof(templat));
+ templat.width = dec->base.width;
+ templat.height = dec->base.height;
+ templat.chroma_format = dec->base.chroma_format;
dec->mc_source = vl_video_buffer_create_ex
(
- dec->base.context, dec->base.width, dec->base.height, 1,
- dec->base.chroma_format, formats, PIPE_USAGE_STATIC
+ dec->base.context, &templat,
+ formats, 1, PIPE_USAGE_STATIC
);
return dec->mc_source != NULL;
struct pipe_video_buffer *
vl_video_buffer_create(struct pipe_context *pipe,
- enum pipe_format buffer_format,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
+ const struct pipe_video_buffer *tmpl)
{
const enum pipe_format *resource_formats;
- struct pipe_video_buffer *result;
- unsigned buffer_width, buffer_height;
+ struct pipe_video_buffer templat;
bool pot_buffers;
assert(pipe);
- assert(width > 0 && height > 0);
+ assert(tmpl->width > 0 && tmpl->height > 0);
pot_buffers = !pipe->screen->get_video_param
(
PIPE_VIDEO_CAP_NPOT_TEXTURES
);
- resource_formats = vl_video_buffer_formats(pipe->screen, buffer_format);
+ resource_formats = vl_video_buffer_formats(pipe->screen, tmpl->buffer_format);
if (!resource_formats)
return NULL;
- buffer_width = pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
- buffer_height = pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
+ templat = *tmpl;
+ templat.width = pot_buffers ? util_next_power_of_two(tmpl->width)
+ : align(tmpl->width, MACROBLOCK_WIDTH);
+ templat.height = pot_buffers ? util_next_power_of_two(tmpl->height)
+ : align(tmpl->height, MACROBLOCK_HEIGHT);
- result = vl_video_buffer_create_ex
+ return vl_video_buffer_create_ex
(
- pipe, buffer_width, buffer_height, 1,
- chroma_format, resource_formats, PIPE_USAGE_STATIC
+ pipe, &templat, resource_formats,
+ 1, PIPE_USAGE_STATIC
);
- if (result)
- result->buffer_format = buffer_format;
-
- return result;
}
struct pipe_video_buffer *
vl_video_buffer_create_ex(struct pipe_context *pipe,
- unsigned width, unsigned height, unsigned depth,
- enum pipe_video_chroma_format chroma_format,
+ const struct pipe_video_buffer *tmpl,
const enum pipe_format resource_formats[VL_MAX_PLANES],
- unsigned usage)
+ unsigned depth, unsigned usage)
{
struct vl_video_buffer *buffer;
struct pipe_resource templ;
buffer = CALLOC_STRUCT(vl_video_buffer);
+ buffer->base = *tmpl;
buffer->base.context = pipe;
buffer->base.destroy = vl_video_buffer_destroy;
buffer->base.get_sampler_view_planes = vl_video_buffer_sampler_view_planes;
buffer->base.get_sampler_view_components = vl_video_buffer_sampler_view_components;
buffer->base.get_surfaces = vl_video_buffer_surfaces;
- buffer->base.chroma_format = chroma_format;
- buffer->base.width = width;
- buffer->base.height = height;
buffer->num_planes = 1;
memset(&templ, 0, sizeof(templ));
templ.target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D;
templ.format = resource_formats[0];
- templ.width0 = width;
- templ.height0 = height;
+ templ.width0 = tmpl->width;
+ templ.height0 = tmpl->height;
templ.depth0 = depth;
templ.array_size = 1;
templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
goto error;
if (resource_formats[1] == PIPE_FORMAT_NONE) {
- assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444);
+ assert(tmpl->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 (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
templ.width0 /= 2;
templ.height0 /= 2;
- } else if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
+ } else if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
templ.height0 /= 2;
}
*/
struct pipe_video_buffer *
vl_video_buffer_create(struct pipe_context *pipe,
- enum pipe_format buffer_format,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height);
+ const struct pipe_video_buffer *templat);
/**
* extended create function, gets depth, usage and formats for each plane seperately
*/
struct pipe_video_buffer *
vl_video_buffer_create_ex(struct pipe_context *pipe,
- unsigned width, unsigned height, unsigned depth,
- enum pipe_video_chroma_format chroma_format,
+ const struct pipe_video_buffer *templat,
const enum pipe_format resource_formats[VL_MAX_PLANES],
- unsigned usage);
+ unsigned depth, unsigned usage);
#endif /* vl_video_buffer_h */
static struct pipe_video_buffer *
nouveau_video_buffer_create(struct pipe_context *pipe,
struct nouveau_screen *screen,
- enum pipe_format buffer_format,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
+ const struct pipe_video_buffer *templat)
{
struct nouveau_video_buffer *buffer;
struct pipe_resource templ;
+ unsigned width, height;
/* Only do a linear surface when a hardware decoder is used
* hardware decoder is only supported on some chipsets
* and it only supports the NV12 format
*/
- if (buffer_format != PIPE_FORMAT_NV12 || getenv("XVMC_VL") ||
+ if (templat->buffer_format != PIPE_FORMAT_NV12 || getenv("XVMC_VL") ||
(screen->device->chipset >= 0x98 && screen->device->chipset != 0xa0))
- return vl_video_buffer_create(pipe, buffer_format, chroma_format, width, height);
+ return vl_video_buffer_create(pipe, templat);
- assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
- width = align(width, 64);
- height = align(height, 64);
+ assert(templat->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
+ width = align(templat->width, 64);
+ height = align(templat->height, 64);
buffer = CALLOC_STRUCT(nouveau_video_buffer);
if (!buffer)
buffer->base.get_sampler_view_planes = nouveau_video_buffer_sampler_view_planes;
buffer->base.get_sampler_view_components = nouveau_video_buffer_sampler_view_components;
buffer->base.get_surfaces = nouveau_video_buffer_surfaces;
- buffer->base.chroma_format = chroma_format;
+ buffer->base.chroma_format = templat->chroma_format;
buffer->base.width = width;
buffer->base.height = height;
buffer->num_planes = 2;
static struct pipe_video_buffer *
nvfx_context_video_buffer_create(struct pipe_context *pipe,
- enum pipe_format buffer_format,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
+ const struct pipe_video_buffer *templat)
{
struct nouveau_screen *screen = &nvfx_context(pipe)->screen->base;
- return nouveau_video_buffer_create(pipe, screen, buffer_format, chroma_format, width, height);
+ return nouveau_video_buffer_create(pipe, screen, templat);
}
void
static struct pipe_video_buffer *
nouveau_context_video_buffer_create(struct pipe_context *pipe,
- enum pipe_format buffer_format,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
+ const struct pipe_video_buffer *templat)
{
struct nouveau_screen *screen = nouveau_context(pipe)->screen;
- return nouveau_video_buffer_create(pipe, screen, buffer_format, chroma_format, width, height);
+ return nouveau_video_buffer_create(pipe, screen, templat);
}
void
* Creates a video buffer as decoding target
*/
struct pipe_video_buffer *(*create_video_buffer)( struct pipe_context *context,
- enum pipe_format buffer_format,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height );
+ const struct pipe_video_buffer *templat );
};
uint32_t width, uint32_t height,
VdpVideoSurface *surface)
{
+ struct pipe_video_buffer tmpl;
vlVdpSurface *p_surf;
VdpStatus ret;
}
p_surf->device = dev;
+ memset(&tmpl, 0, sizeof(tmpl));
+ tmpl.buffer_format = PIPE_FORMAT_YV12;
+ tmpl.chroma_format = ChromaToPipe(chroma_type);
+ tmpl.width = width;
+ tmpl.height = height;
p_surf->video_buffer = dev->context->pipe->create_video_buffer
(
dev->context->pipe,
- PIPE_FORMAT_YV12, // most common used
- ChromaToPipe(chroma_type),
- width, height
+ &tmpl
);
*surface = vlAddDataHTAB(p_surf);
XvMCContextPrivate *context_priv;
struct pipe_context *pipe;
XvMCSurfacePrivate *surface_priv;
+ struct pipe_video_buffer tmpl;
XVMC_MSG(XVMC_TRACE, "[XvMC] Creating surface %p.\n", surface);
if (!surface_priv)
return BadAlloc;
- surface_priv->video_buffer = pipe->create_video_buffer
- (
- pipe, PIPE_FORMAT_NV12, context_priv->decoder->chroma_format,
- context_priv->decoder->width, context_priv->decoder->height
- );
-
+ memset(&tmpl, 0, sizeof(tmpl));
+ tmpl.buffer_format = PIPE_FORMAT_NV12;
+ tmpl.chroma_format = context_priv->decoder->chroma_format;
+ tmpl.width = context_priv->decoder->width;
+ tmpl.height = context_priv->decoder->height;
+
+ surface_priv->video_buffer = pipe->create_video_buffer(pipe, &tmpl);
surface_priv->context = context;
surface->surface_id = XAllocID(dpy);