summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-03-22 19:58:21 +0100
committerChristian König <[email protected]>2011-03-22 19:58:21 +0100
commitba0bff85307c9b107cf432da05b39fd4ab242579 (patch)
tree9f2e973585b2ca1f9a17dcddea84dae521a62212 /src
parent52766c2c373a7ac484ae01dca3ab409e808709b2 (diff)
[g3dvl] make video buffer a public available interface
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_context.c361
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_context.h9
-rw-r--r--src/gallium/include/pipe/p_video_context.h44
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/surface.c65
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/xvmc_private.h2
5 files changed, 241 insertions, 240 deletions
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_context.c b/src/gallium/auxiliary/vl/vl_mpeg12_context.c
index 781ff2a4085..404a6c0c11d 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_context.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_context.c
@@ -38,8 +38,6 @@
#include <util/u_video.h>
#include <util/u_surface.h>
-#define NUM_BUFFERS 2
-
static const unsigned const_empty_block_mask_420[3][2][2] = {
{ { 0x20, 0x10 }, { 0x08, 0x04 } },
{ { 0x02, 0x02 }, { 0x02, 0x02 } },
@@ -47,108 +45,60 @@ static const unsigned const_empty_block_mask_420[3][2][2] = {
};
static void
-flush_buffer(struct vl_mpeg12_context *ctx)
+map_buffer(struct vl_mpeg12_buffer *buf)
{
- unsigned ne_start, ne_num, e_start, e_num;
- assert(ctx);
-
- if(ctx->cur_buffer != NULL) {
-
- vl_vb_unmap(&ctx->cur_buffer->vertex_stream, ctx->pipe);
- vl_idct_unmap_buffers(&ctx->idct_y, &ctx->cur_buffer->idct_y);
- vl_idct_unmap_buffers(&ctx->idct_cr, &ctx->cur_buffer->idct_cr);
- vl_idct_unmap_buffers(&ctx->idct_cb, &ctx->cur_buffer->idct_cb);
- vl_vb_restart(&ctx->cur_buffer->vertex_stream,
- &ne_start, &ne_num, &e_start, &e_num);
+ struct vl_mpeg12_context *ctx;
+ assert(buf);
- ctx->pipe->set_vertex_buffers(ctx->pipe, 2, ctx->cur_buffer->vertex_bufs.all);
- ctx->pipe->bind_vertex_elements_state(ctx->pipe, ctx->vertex_elems_state);
- vl_idct_flush(&ctx->idct_y, &ctx->cur_buffer->idct_y, ne_num);
- vl_idct_flush(&ctx->idct_cr, &ctx->cur_buffer->idct_cr, ne_num);
- vl_idct_flush(&ctx->idct_cb, &ctx->cur_buffer->idct_cb, ne_num);
- vl_mpeg12_mc_renderer_flush(&ctx->mc_renderer, &ctx->cur_buffer->mc,
- ne_start, ne_num, e_start, e_num);
+ ctx = (struct vl_mpeg12_context *)buf->base.context;
+ assert(ctx);
- ctx->cur_buffer = NULL;
+ if (!buf->mapped) {
+ vl_vb_map(&buf->vertex_stream, ctx->pipe);
+ vl_idct_map_buffers(&ctx->idct_y, &buf->idct_y);
+ vl_idct_map_buffers(&ctx->idct_cr, &buf->idct_cr);
+ vl_idct_map_buffers(&ctx->idct_cb, &buf->idct_cb);
+ buf->mapped = 1;
}
}
static void
-rotate_buffer(struct vl_mpeg12_context *ctx)
+unmap_buffer(struct vl_mpeg12_buffer *buf)
{
- struct pipe_resource *y, *cr, *cb;
- static unsigned key = 0;
- struct vl_mpeg12_buffer *buffer;
+ struct vl_mpeg12_context *ctx;
+ assert(buf);
+ ctx = (struct vl_mpeg12_context *)buf->base.context;
assert(ctx);
- flush_buffer(ctx);
-
- buffer = (struct vl_mpeg12_buffer*)util_keymap_lookup(ctx->buffer_map, &key);
- if (!buffer) {
- boolean added_to_map;
-
- buffer = CALLOC_STRUCT(vl_mpeg12_buffer);
- if (buffer == NULL)
- return;
-
- buffer->vertex_bufs.individual.quad.stride = ctx->quads.stride;
- buffer->vertex_bufs.individual.quad.buffer_offset = ctx->quads.buffer_offset;
- pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, ctx->quads.buffer);
-
- buffer->vertex_bufs.individual.stream = vl_vb_init(&buffer->vertex_stream, ctx->pipe,
- ctx->vertex_buffer_size);
- if (!(y = vl_idct_init_buffer(&ctx->idct_y, &buffer->idct_y))) {
- FREE(buffer);
- return;
- }
-
- if (!(cr = vl_idct_init_buffer(&ctx->idct_cr, &buffer->idct_cr))) {
- FREE(buffer);
- return;
- }
-
- if (!(cb = vl_idct_init_buffer(&ctx->idct_cb, &buffer->idct_cb))) {
- FREE(buffer);
- return;
- }
-
- if(!vl_mpeg12_mc_init_buffer(&ctx->mc_renderer, &buffer->mc, y, cr, cb)) {
- FREE(buffer);
- return;
- }
-
- added_to_map = util_keymap_insert(ctx->buffer_map, &key, buffer, ctx);
- assert(added_to_map);
+ if (buf->mapped) {
+ vl_vb_unmap(&buf->vertex_stream, ctx->pipe);
+ vl_idct_unmap_buffers(&ctx->idct_y, &buf->idct_y);
+ vl_idct_unmap_buffers(&ctx->idct_cr, &buf->idct_cr);
+ vl_idct_unmap_buffers(&ctx->idct_cb, &buf->idct_cb);
+ buf->mapped = 0;
}
- ++key;
- key %= NUM_BUFFERS;
- ctx->cur_buffer = buffer;
-
- vl_vb_map(&ctx->cur_buffer->vertex_stream, ctx->pipe);
- vl_idct_map_buffers(&ctx->idct_y, &ctx->cur_buffer->idct_y);
- vl_idct_map_buffers(&ctx->idct_cr, &ctx->cur_buffer->idct_cr);
- vl_idct_map_buffers(&ctx->idct_cb, &ctx->cur_buffer->idct_cb);
}
static void
-delete_buffer(const struct keymap *map,
- const void *key, void *data,
- void *user)
+flush_buffer(struct vl_mpeg12_buffer *buf)
{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)user;
- struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)data;
+ unsigned ne_start, ne_num, e_start, e_num;
+ struct vl_mpeg12_context *ctx;
+ assert(buf);
- assert(map);
- assert(key);
- assert(data);
- assert(user);
+ ctx = (struct vl_mpeg12_context *)buf->base.context;
+ assert(ctx);
- vl_vb_cleanup(&buf->vertex_stream);
- vl_idct_cleanup_buffer(&ctx->idct_y, &buf->idct_y);
- vl_idct_cleanup_buffer(&ctx->idct_cb, &buf->idct_cb);
- vl_idct_cleanup_buffer(&ctx->idct_cr, &buf->idct_cr);
- vl_mpeg12_mc_cleanup_buffer(&ctx->mc_renderer, &buf->mc);
+ vl_vb_restart(&buf->vertex_stream, &ne_start, &ne_num, &e_start, &e_num);
+
+ ctx->pipe->set_vertex_buffers(ctx->pipe, 2, buf->vertex_bufs.all);
+ ctx->pipe->bind_vertex_elements_state(ctx->pipe, ctx->vertex_elems_state);
+ vl_idct_flush(&ctx->idct_y, &buf->idct_y, ne_num);
+ vl_idct_flush(&ctx->idct_cr, &buf->idct_cr, ne_num);
+ vl_idct_flush(&ctx->idct_cb, &buf->idct_cb, ne_num);
+ vl_mpeg12_mc_renderer_flush(&ctx->mc_renderer, &buf->mc,
+ ne_start, ne_num, e_start, e_num);
}
static void
@@ -189,14 +139,77 @@ upload_buffer(struct vl_mpeg12_context *ctx,
}
static void
+vl_mpeg12_buffer_destroy(struct pipe_video_buffer *buffer)
+{
+ struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+ struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)buf->base.context;
+ assert(buf && ctx);
+
+ vl_vb_cleanup(&buf->vertex_stream);
+ vl_idct_cleanup_buffer(&ctx->idct_y, &buf->idct_y);
+ vl_idct_cleanup_buffer(&ctx->idct_cb, &buf->idct_cb);
+ vl_idct_cleanup_buffer(&ctx->idct_cr, &buf->idct_cr);
+ vl_mpeg12_mc_cleanup_buffer(&ctx->mc_renderer, &buf->mc);
+ pipe_surface_reference(&buf->surface, NULL);
+
+ FREE(buf);
+}
+
+static void
+vl_mpeg12_buffer_add_macroblocks(struct pipe_video_buffer *buffer,
+ struct pipe_video_buffer *past,
+ struct pipe_video_buffer *future,
+ unsigned num_macroblocks,
+ struct pipe_macroblock *macroblocks,
+ struct pipe_fence_handle **fence)
+{
+ struct pipe_mpeg12_macroblock *mpeg12_macroblocks = (struct pipe_mpeg12_macroblock*)macroblocks;
+ struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
+ struct vl_mpeg12_buffer *buf_past = (struct vl_mpeg12_buffer*)past;
+ struct vl_mpeg12_buffer *buf_future = (struct vl_mpeg12_buffer*)future;
+ struct vl_mpeg12_context *ctx;
+ unsigned i;
+
+ assert(buf);
+
+ ctx = (struct vl_mpeg12_context*)buf->base.context;
+ assert(ctx);
+
+ assert(num_macroblocks);
+ assert(macroblocks);
+ assert(macroblocks->codec == PIPE_VIDEO_CODEC_MPEG12);
+
+ map_buffer(buf);
+
+ for ( i = 0; i < num_macroblocks; ++i ) {
+ vl_vb_add_block(&buf->vertex_stream, &mpeg12_macroblocks[i], ctx->empty_block_mask);
+ upload_buffer(ctx, buf, &mpeg12_macroblocks[i]);
+ }
+
+ // TODO this doesn't belong here
+ if (buf_past) {
+ unmap_buffer(buf_past);
+ flush_buffer(buf_past);
+ }
+
+ if (buf_future) {
+ unmap_buffer(buf_future);
+ flush_buffer(buf_future);
+ }
+
+ vl_mpeg12_mc_set_surfaces(&ctx->mc_renderer, &buf->mc, buf->surface,
+ buf_past ? buf_past->surface : NULL,
+ buf_future ? buf_future->surface : NULL,
+ fence);
+}
+
+static void
vl_mpeg12_destroy(struct pipe_video_context *vpipe)
{
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
assert(vpipe);
- flush_buffer(ctx);
-
/* Asserted in softpipe_delete_fs_state() for some reason */
ctx->pipe->bind_vs_state(ctx->pipe, NULL);
ctx->pipe->bind_fs_state(ctx->pipe, NULL);
@@ -205,9 +218,7 @@ vl_mpeg12_destroy(struct pipe_video_context *vpipe)
ctx->pipe->delete_rasterizer_state(ctx->pipe, ctx->rast);
ctx->pipe->delete_depth_stencil_alpha_state(ctx->pipe, ctx->dsa);
- pipe_surface_reference(&ctx->decode_target, NULL);
vl_compositor_cleanup(&ctx->compositor);
- util_delete_keymap(ctx->buffer_map, ctx);
vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
vl_idct_cleanup(&ctx->idct_y);
vl_idct_cleanup(&ctx->idct_cr);
@@ -246,11 +257,87 @@ vl_mpeg12_create_surface(struct pipe_video_context *vpipe,
{
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
- assert(vpipe);
+ assert(ctx);
return ctx->pipe->create_surface(ctx->pipe, resource, templat);
}
+static struct pipe_video_buffer *
+vl_mpeg12_create_buffer(struct pipe_video_context *vpipe)
+{
+ struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
+ struct pipe_resource *y, *cr, *cb;
+ struct vl_mpeg12_buffer *buffer;
+
+ struct pipe_resource res_template, *resource;
+ struct pipe_surface surf_template;
+
+ assert(ctx);
+
+ buffer = CALLOC_STRUCT(vl_mpeg12_buffer);
+ if (buffer == NULL)
+ return NULL;
+
+ buffer->base.context = vpipe;
+ buffer->base.destroy = vl_mpeg12_buffer_destroy;
+ buffer->base.add_macroblocks = vl_mpeg12_buffer_add_macroblocks;
+
+ memset(&res_template, 0, sizeof(res_template));
+ res_template.target = PIPE_TEXTURE_2D;
+ res_template.format = ctx->decode_format;
+ res_template.last_level = 0;
+ res_template.width0 = ctx->buffer_width;
+ res_template.height0 = ctx->buffer_height;
+ res_template.depth0 = 1;
+ res_template.array_size = 1;
+ res_template.usage = PIPE_USAGE_DEFAULT;
+ res_template.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+ res_template.flags = 0;
+ resource = ctx->pipe->screen->resource_create(ctx->pipe->screen, &res_template);
+ if (!resource) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ memset(&surf_template, 0, sizeof(surf_template));
+ surf_template.format = resource->format;
+ surf_template.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+ buffer->surface = ctx->pipe->create_surface(ctx->pipe, resource, &surf_template);
+ pipe_resource_reference(&resource, NULL);
+ if (!buffer->surface) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ buffer->vertex_bufs.individual.quad.stride = ctx->quads.stride;
+ buffer->vertex_bufs.individual.quad.buffer_offset = ctx->quads.buffer_offset;
+ pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, ctx->quads.buffer);
+
+ buffer->vertex_bufs.individual.stream = vl_vb_init(&buffer->vertex_stream, ctx->pipe,
+ ctx->vertex_buffer_size);
+ if (!(y = vl_idct_init_buffer(&ctx->idct_y, &buffer->idct_y))) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ if (!(cr = vl_idct_init_buffer(&ctx->idct_cr, &buffer->idct_cr))) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ if (!(cb = vl_idct_init_buffer(&ctx->idct_cb, &buffer->idct_cb))) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ if(!vl_mpeg12_mc_init_buffer(&ctx->mc_renderer, &buffer->mc, y, cr, cb)) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ return &buffer->base;
+}
+
static boolean
vl_mpeg12_is_format_supported(struct pipe_video_context *vpipe,
enum pipe_format format,
@@ -266,35 +353,6 @@ vl_mpeg12_is_format_supported(struct pipe_video_context *vpipe,
}
static void
-vl_mpeg12_decode_macroblocks(struct pipe_video_context *vpipe,
- struct pipe_surface *past,
- struct pipe_surface *future,
- unsigned num_macroblocks,
- struct pipe_macroblock *macroblocks,
- struct pipe_fence_handle **fence)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
- struct pipe_mpeg12_macroblock *mpeg12_macroblocks = (struct pipe_mpeg12_macroblock*)macroblocks;
- unsigned i;
-
- assert(vpipe);
- assert(num_macroblocks);
- assert(macroblocks);
- assert(macroblocks->codec == PIPE_VIDEO_CODEC_MPEG12);
- assert(ctx->decode_target);
- assert(ctx->cur_buffer);
-
- for ( i = 0; i < num_macroblocks; ++i ) {
- vl_vb_add_block(&ctx->cur_buffer->vertex_stream, &mpeg12_macroblocks[i],
- ctx->empty_block_mask);
- upload_buffer(ctx, ctx->cur_buffer, &mpeg12_macroblocks[i]);
- }
-
- vl_mpeg12_mc_set_surfaces(&ctx->mc_renderer, &ctx->cur_buffer->mc,
- ctx->decode_target, past, future, fence);
-}
-
-static void
vl_mpeg12_clear_render_target(struct pipe_video_context *vpipe,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
@@ -312,6 +370,7 @@ vl_mpeg12_clear_render_target(struct pipe_video_context *vpipe,
util_clear_render_target(ctx->pipe, dst, rgba, dstx, dsty, width, height);
}
+#if 0
static void
vl_mpeg12_resource_copy_region(struct pipe_video_context *vpipe,
struct pipe_resource *dst,
@@ -341,6 +400,7 @@ vl_mpeg12_resource_copy_region(struct pipe_video_context *vpipe,
dstx, dsty, dstz,
src, 0, &box);
}
+#endif
static struct pipe_transfer*
vl_mpeg12_get_transfer(struct pipe_video_context *vpipe,
@@ -432,18 +492,15 @@ vl_mpeg12_transfer_inline_write(struct pipe_video_context *vpipe,
static void
vl_mpeg12_render_picture(struct pipe_video_context *vpipe,
- struct pipe_surface *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_surface *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_surface *future_surfaces,*/
+ struct pipe_video_buffer *src_surface,
struct pipe_video_rect *src_area,
+ enum pipe_mpeg12_picture_type picture_type,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
struct pipe_fence_handle **fence)
{
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
+ struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)src_surface;
assert(vpipe);
assert(src_surface);
@@ -451,10 +508,12 @@ vl_mpeg12_render_picture(struct pipe_video_context *vpipe,
assert(dst_surface);
assert(dst_area);
- flush_buffer(ctx);
+ unmap_buffer(buf);
+ flush_buffer(buf);
- vl_compositor_render(&ctx->compositor, src_surface,
- picture_type, src_area, dst_surface, dst_area, fence);
+ vl_compositor_render(&ctx->compositor, buf->surface,
+ picture_type, src_area,
+ dst_surface, dst_area, fence);
}
static void
@@ -488,22 +547,6 @@ vl_mpeg12_set_picture_layers(struct pipe_video_context *vpipe,
}
static void
-vl_mpeg12_set_decode_target(struct pipe_video_context *vpipe,
- struct pipe_surface *dt)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(dt);
-
- if (ctx->decode_target != dt || ctx->cur_buffer == NULL) {
- rotate_buffer(ctx);
-
- pipe_surface_reference(&ctx->decode_target, dt);
- }
-}
-
-static void
vl_mpeg12_set_csc_matrix(struct pipe_video_context *vpipe, const float *mat)
{
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
@@ -649,7 +692,6 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
enum pipe_format decode_format)
{
struct vl_mpeg12_context *ctx;
- unsigned buffer_width, buffer_height;
assert(u_reduce_video_profile(profile) == PIPE_VIDEO_CODEC_MPEG12);
@@ -669,10 +711,10 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
ctx->base.get_param = vl_mpeg12_get_param;
ctx->base.is_format_supported = vl_mpeg12_is_format_supported;
ctx->base.create_surface = vl_mpeg12_create_surface;
- ctx->base.decode_macroblocks = vl_mpeg12_decode_macroblocks;
+ ctx->base.create_buffer = vl_mpeg12_create_buffer;
ctx->base.render_picture = vl_mpeg12_render_picture;
ctx->base.clear_render_target = vl_mpeg12_clear_render_target;
- ctx->base.resource_copy_region = vl_mpeg12_resource_copy_region;
+ //ctx->base.resource_copy_region = vl_mpeg12_resource_copy_region;
ctx->base.get_transfer = vl_mpeg12_get_transfer;
ctx->base.transfer_destroy = vl_mpeg12_transfer_destroy;
ctx->base.transfer_map = vl_mpeg12_transfer_map;
@@ -682,7 +724,6 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
ctx->base.transfer_inline_write = vl_mpeg12_transfer_inline_write;
ctx->base.set_picture_background = vl_mpeg12_set_picture_background;
ctx->base.set_picture_layers = vl_mpeg12_set_picture_layers;
- ctx->base.set_decode_target = vl_mpeg12_set_decode_target;
ctx->base.set_csc_matrix = vl_mpeg12_set_csc_matrix;
ctx->pipe = pipe;
@@ -699,17 +740,18 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
return NULL;
}
- buffer_width = pot_buffers ? util_next_power_of_two(width) : width;
- buffer_height = pot_buffers ? util_next_power_of_two(height) : height;
+ ctx->buffer_width = pot_buffers ? util_next_power_of_two(width) : width;
+ ctx->buffer_height = pot_buffers ? util_next_power_of_two(height) : height;
- if (!init_idct(ctx, buffer_width, buffer_height)) {
+ if (!init_idct(ctx, ctx->buffer_width, ctx->buffer_height)) {
ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
return NULL;
}
if (!vl_mpeg12_mc_renderer_init(&ctx->mc_renderer, ctx->pipe,
- buffer_width, buffer_height, chroma_format)) {
+ ctx->buffer_width, ctx->buffer_height,
+ chroma_format)) {
vl_idct_cleanup(&ctx->idct_y);
vl_idct_cleanup(&ctx->idct_cr);
vl_idct_cleanup(&ctx->idct_cb);
@@ -718,23 +760,11 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
return NULL;
}
- ctx->buffer_map = util_new_keymap(sizeof(unsigned), -1, delete_buffer);
- if (!ctx->buffer_map) {
- vl_idct_cleanup(&ctx->idct_y);
- vl_idct_cleanup(&ctx->idct_cr);
- vl_idct_cleanup(&ctx->idct_cb);
- vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
- ctx->pipe->destroy(ctx->pipe);
- FREE(ctx);
- return NULL;
- }
-
if (!vl_compositor_init(&ctx->compositor, ctx->pipe)) {
vl_idct_cleanup(&ctx->idct_y);
vl_idct_cleanup(&ctx->idct_cr);
vl_idct_cleanup(&ctx->idct_cb);
vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
- util_delete_keymap(ctx->buffer_map, ctx);
ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
return NULL;
@@ -745,7 +775,6 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
vl_idct_cleanup(&ctx->idct_cr);
vl_idct_cleanup(&ctx->idct_cb);
vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
- util_delete_keymap(ctx->buffer_map, ctx);
vl_compositor_cleanup(&ctx->compositor);
ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_context.h b/src/gallium/auxiliary/vl/vl_mpeg12_context.h
index c88c436ad73..b2097c2e227 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_context.h
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_context.h
@@ -42,8 +42,8 @@ struct vl_mpeg12_context
struct pipe_context *pipe;
enum pipe_format decode_format;
bool pot_buffers;
+ unsigned buffer_width, buffer_height;
- struct pipe_surface *decode_target;
const unsigned (*empty_block_mask)[3][2][2];
struct pipe_vertex_buffer quads;
@@ -52,9 +52,6 @@ struct vl_mpeg12_context
struct vl_idct idct_y, idct_cr, idct_cb;
struct vl_mpeg12_mc_renderer mc_renderer;
-
- struct keymap *buffer_map;
- struct vl_mpeg12_buffer *cur_buffer;
struct vl_compositor compositor;
void *rast;
@@ -64,6 +61,10 @@ struct vl_mpeg12_context
struct vl_mpeg12_buffer
{
+ struct pipe_video_buffer base;
+ struct pipe_surface *surface;
+ bool mapped;
+
struct vl_vertex_buffer vertex_stream;
union
diff --git a/src/gallium/include/pipe/p_video_context.h b/src/gallium/include/pipe/p_video_context.h
index 2d59741ec18..08e3c7e340b 100644
--- a/src/gallium/include/pipe/p_video_context.h
+++ b/src/gallium/include/pipe/p_video_context.h
@@ -43,6 +43,7 @@ struct pipe_surface;
struct pipe_macroblock;
struct pipe_picture_desc;
struct pipe_fence_handle;
+struct pipe_video_buffer;
/**
* Gallium video rendering context
@@ -78,28 +79,25 @@ struct pipe_video_context
const struct pipe_surface *templat);
/**
+ * Creates a buffer for as decoding target
+ */
+ struct pipe_video_buffer *(*create_buffer)(struct pipe_video_context *vpipe);
+
+ /**
* Picture decoding and displaying
*/
+
+#if 0
/*@{*/
void (*decode_bitstream)(struct pipe_video_context *vpipe,
unsigned num_bufs,
struct pipe_buffer **bitstream_buf);
-
- void (*decode_macroblocks)(struct pipe_video_context *vpipe,
- struct pipe_surface *past,
- struct pipe_surface *future,
- unsigned num_macroblocks,
- struct pipe_macroblock *macroblocks,
- struct pipe_fence_handle **fence);
+#endif
void (*render_picture)(struct pipe_video_context *vpipe,
- struct pipe_surface *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_surface *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_surface *future_surfaces,*/
+ struct pipe_video_buffer *src_surface,
struct pipe_video_rect *src_area,
+ enum pipe_mpeg12_picture_type picture_type,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
struct pipe_fence_handle **fence);
@@ -110,12 +108,14 @@ struct pipe_video_context
const float *rgba,
unsigned width, unsigned height);
+#if 0
void (*resource_copy_region)(struct pipe_video_context *vpipe,
struct pipe_resource *dst,
unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src,
unsigned srcx, unsigned srcy, unsigned srcz,
unsigned width, unsigned height);
+#endif
struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe,
struct pipe_resource *resource,
@@ -164,15 +164,27 @@ struct pipe_video_context
void (*set_picture_desc)(struct pipe_video_context *vpipe,
const struct pipe_picture_desc *desc);
- void (*set_decode_target)(struct pipe_video_context *vpipe,
- struct pipe_surface *dt);
-
void (*set_csc_matrix)(struct pipe_video_context *vpipe, const float *mat);
/* TODO: Interface for scaling modes, post-processing, etc. */
/*@}*/
};
+struct pipe_video_buffer
+{
+ struct pipe_video_context* context;
+
+ void (*destroy)(struct pipe_video_buffer *buffer);
+
+ void (*add_macroblocks)(struct pipe_video_buffer *buffer,
+ struct pipe_video_buffer *past,
+ struct pipe_video_buffer *future,
+ unsigned num_macroblocks,
+ struct pipe_macroblock *macroblocks,
+ struct pipe_fence_handle **fence);
+
+
+};
#ifdef __cplusplus
}
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index 5896cdca76d..4dedf001ce9 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -155,7 +155,7 @@ MacroBlocksToPipe(struct pipe_screen *screen,
unsigned int num_macroblocks,
struct pipe_mpeg12_macroblock *mb)
{
- unsigned int i, j, k, l;
+ unsigned int i, j;
XvMCMacroBlock *xvmc_mb;
assert(xvmc_macroblocks);
@@ -204,10 +204,6 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
XvMCContextPrivate *context_priv;
struct pipe_video_context *vpipe;
XvMCSurfacePrivate *surface_priv;
- struct pipe_resource template;
- struct pipe_resource *vsfc_tex;
- struct pipe_surface surf_template;
- struct pipe_surface *vsfc;
XVMC_MSG(XVMC_TRACE, "[XvMC] Creating surface %p.\n", surface);
@@ -225,45 +221,9 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
if (!surface_priv)
return BadAlloc;
- memset(&template, 0, sizeof(struct pipe_resource));
- template.target = PIPE_TEXTURE_2D;
- template.format = (enum pipe_format)vpipe->get_param(vpipe, PIPE_CAP_DECODE_TARGET_PREFERRED_FORMAT);
- if (!vpipe->is_format_supported(vpipe, template.format,
- PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET)) {
- FREE(surface_priv);
- return BadAlloc;
- }
- template.last_level = 0;
- if (vpipe->get_param(vpipe, PIPE_CAP_NPOT_TEXTURES)) {
- template.width0 = context->width;
- template.height0 = context->height;
- }
- else {
- template.width0 = util_next_power_of_two(context->width);
- template.height0 = util_next_power_of_two(context->height);
- }
- template.depth0 = 1;
- template.array_size = 1;
- template.usage = PIPE_USAGE_DEFAULT;
- template.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- template.flags = 0;
- vsfc_tex = vpipe->screen->resource_create(vpipe->screen, &template);
- if (!vsfc_tex) {
- FREE(surface_priv);
- return BadAlloc;
- }
- memset(&surf_template, 0, sizeof(surf_template));
- surf_template.format = vsfc_tex->format;
- surf_template.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- vsfc = vpipe->create_surface(vpipe, vsfc_tex, &surf_template);
- pipe_resource_reference(&vsfc_tex, NULL);
- if (!vsfc) {
- FREE(surface_priv);
- return BadAlloc;
- }
- surface_priv->pipe_vsfc = vsfc;
+ surface_priv->pipe_buffer = vpipe->create_buffer(vpipe);
surface_priv->context = context;
surface->surface_id = XAllocID(dpy);
@@ -288,9 +248,9 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
)
{
struct pipe_video_context *vpipe;
- struct pipe_surface *t_vsfc;
- struct pipe_surface *p_vsfc;
- struct pipe_surface *f_vsfc;
+ struct pipe_video_buffer *t_vsfc;
+ struct pipe_video_buffer *p_vsfc;
+ struct pipe_video_buffer *f_vsfc;
XvMCContextPrivate *context_priv;
XvMCSurfacePrivate *target_surface_priv;
XvMCSurfacePrivate *past_surface_priv;
@@ -337,16 +297,15 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
context_priv = context->privData;
vpipe = context_priv->vctx->vpipe;
- t_vsfc = target_surface_priv->pipe_vsfc;
- p_vsfc = past_surface ? past_surface_priv->pipe_vsfc : NULL;
- f_vsfc = future_surface ? future_surface_priv->pipe_vsfc : NULL;
+ t_vsfc = target_surface_priv->pipe_buffer;
+ p_vsfc = past_surface ? past_surface_priv->pipe_buffer : NULL;
+ f_vsfc = future_surface ? future_surface_priv->pipe_buffer : NULL;
MacroBlocksToPipe(vpipe->screen, picture_structure, macroblocks, blocks, first_macroblock,
num_macroblocks, pipe_macroblocks);
- vpipe->set_decode_target(vpipe, t_vsfc);
- vpipe->decode_macroblocks(vpipe, p_vsfc, f_vsfc, num_macroblocks,
- &pipe_macroblocks->base, &target_surface_priv->render_fence);
+ t_vsfc->add_macroblocks(t_vsfc, p_vsfc, f_vsfc, num_macroblocks,
+ &pipe_macroblocks->base, &target_surface_priv->render_fence);
XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for rendering.\n", target_surface);
@@ -447,7 +406,7 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
else
vpipe->set_picture_layers(vpipe, NULL, NULL, NULL, 0);
- vpipe->render_picture(vpipe, surface_priv->pipe_vsfc, PictureToPipe(flags), &src_rect,
+ vpipe->render_picture(vpipe, surface_priv->pipe_buffer, &src_rect, PictureToPipe(flags),
drawable_surface, &dst_rect, &surface_priv->disp_fence);
XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for display. Pushing to front buffer.\n", surface);
@@ -506,7 +465,7 @@ Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface)
return XvMCBadSurface;
surface_priv = surface->privData;
- pipe_surface_reference(&surface_priv->pipe_vsfc, NULL);
+ surface_priv->pipe_buffer->destroy(surface_priv->pipe_buffer);
FREE(surface_priv);
surface->privData = NULL;
diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
index 1e2dfb4223a..01b82df3ba8 100644
--- a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
+++ b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
@@ -49,7 +49,7 @@ typedef struct
typedef struct
{
- struct pipe_surface *pipe_vsfc;
+ struct pipe_video_buffer *pipe_buffer;
struct pipe_fence_handle *render_fence;
struct pipe_fence_handle *disp_fence;