compositor->fb_state.width = 0;
compositor->fb_state.height = 0;
- compositor->bg = NULL;
- compositor->dirty_bg = false;
for (i = 0; i < VL_COMPOSITOR_MAX_LAYERS; ++i)
compositor->layers[i] = NULL;
compositor->dirty_layers = 0;
if (!vb)
return 0;
- if (c->dirty_bg) {
- struct vertex2f bg_inv_size = {1.0f / c->bg->texture->width0, 1.0f / c->bg->texture->height0};
- gen_rect_verts(num_rects, &c->bg_src_rect, &bg_inv_size, NULL, NULL, vb);
- textures[num_rects] = c->bg;
- /* XXX: Hack */
- frag_shaders[num_rects] = c->fragment_shader.rgb_2_rgb;
- ++num_rects;
- c->dirty_bg = false;
- }
-
{
struct vertex2f src_inv_size = { 1.0f / src_surface->texture->width0, 1.0f / src_surface->texture->height0};
gen_rect_verts(num_rects, src_rect, &src_inv_size, dst_rect, &c->fb_inv_size, vb);
draw_layers(compositor, src_surface, src_area, dst_area);
- assert(!compositor->dirty_bg && !compositor->dirty_layers);
+ assert(!compositor->dirty_layers);
compositor->pipe->flush(compositor->pipe, fence);
}
void *vertex_elems_state;
struct pipe_resource *fs_const_buf;
- struct pipe_sampler_view *bg;
- struct pipe_video_rect bg_src_rect;
- bool dirty_bg;
struct pipe_sampler_view *layers[VL_COMPOSITOR_MAX_LAYERS];
struct pipe_video_rect layer_src_rects[VL_COMPOSITOR_MAX_LAYERS];
struct pipe_video_rect layer_dst_rects[VL_COMPOSITOR_MAX_LAYERS];
void vl_compositor_cleanup(struct vl_compositor *compositor);
-#if 0
-void vl_compositor_set_background(struct vl_compositor *compositor,
- struct pipe_surface *bg, struct pipe_video_rect *bg_src_rect);
-#endif
-
void vl_compositor_set_layers(struct vl_compositor *compositor,
struct pipe_sampler_view *layers[],
struct pipe_video_rect *src_rects[],
0, usage);
}
-#if 0
-static void
-vl_mpeg12_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)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(dst);
-
- struct pipe_box box;
- box.x = srcx;
- box.y = srcy;
- box.z = srcz;
- box.width = width;
- box.height = height;
-
- if (ctx->pipe->resource_copy_region)
- ctx->pipe->resource_copy_region(ctx->pipe, dst, 0,
- dstx, dsty, dstz,
- src, 0, &box);
- else
- util_resource_copy_region(ctx->pipe, dst, 0,
- dstx, dsty, dstz,
- src, 0, &box);
-}
-
-static struct pipe_transfer*
-vl_mpeg12_get_transfer(struct pipe_video_context *vpipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage, /* a combination of PIPE_TRANSFER_x */
- const struct pipe_box *box)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(resource);
- assert(box);
-
- return ctx->pipe->get_transfer(ctx->pipe, resource, level, usage, box);
-}
-
-static void
-vl_mpeg12_transfer_destroy(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(transfer);
-
- ctx->pipe->transfer_destroy(ctx->pipe, transfer);
-}
-
-static void*
-vl_mpeg12_transfer_map(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(transfer);
-
- return ctx->pipe->transfer_map(ctx->pipe, transfer);
-}
-
-static void
-vl_mpeg12_transfer_flush_region(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer,
- const struct pipe_box *box)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(transfer);
- assert(box);
-
- ctx->pipe->transfer_flush_region(ctx->pipe, transfer, box);
-}
-
-static void
-vl_mpeg12_transfer_unmap(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(transfer);
-
- ctx->pipe->transfer_unmap(ctx->pipe, transfer);
-}
-
-#endif
-
static void
vl_mpeg12_clear_sampler(struct pipe_video_context *vpipe,
struct pipe_sampler_view *dst,
dst_surface, dst_area, fence);
}
-#if 0
-static void
-vl_mpeg12_set_picture_background(struct pipe_video_context *vpipe,
- struct pipe_surface *bg,
- struct pipe_video_rect *bg_src_rect)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(bg);
- assert(bg_src_rect);
-
- vl_compositor_set_background(&ctx->compositor, bg, bg_src_rect);
-}
-#endif
-
static void
vl_mpeg12_set_picture_layers(struct pipe_video_context *vpipe,
struct pipe_sampler_view *layers[],
ctx->base.create_buffer = vl_mpeg12_create_buffer;
ctx->base.render_picture = vl_mpeg12_render_picture;
ctx->base.clear_sampler = vl_mpeg12_clear_sampler;
- //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;
- //ctx->base.transfer_flush_region = vl_mpeg12_transfer_flush_region;
- //ctx->base.transfer_unmap = vl_mpeg12_transfer_unmap;
ctx->base.upload_sampler = vl_mpeg12_upload_sampler;
- //ctx->base.set_picture_background = vl_mpeg12_set_picture_background;
ctx->base.set_picture_layers = vl_mpeg12_set_picture_layers;
ctx->base.set_csc_matrix = vl_mpeg12_set_csc_matrix;
struct pipe_resource *resource,
const struct pipe_surface *templ);
+ /**
+ * sampler view handling, used for subpictures for example
+ */
+ /*@{*/
+
/**
* create a sampler view of a texture, for subpictures for example
*/
struct pipe_resource *resource,
const struct pipe_sampler_view *templ);
+ /**
+ * upload image data to a sampler
+ */
+ void (*upload_sampler)(struct pipe_video_context *vpipe,
+ struct pipe_sampler_view *dst,
+ const struct pipe_box *dst_box,
+ const void *src, unsigned src_stride,
+ unsigned src_x, unsigned src_y);
+
+ /**
+ * clear a sampler with a specific rgba color
+ */
+ void (*clear_sampler)(struct pipe_video_context *vpipe,
+ struct pipe_sampler_view *dst,
+ const struct pipe_box *dst_box,
+ const float *rgba);
/**
* Creates a buffer as decoding target
*/
*/
#if 0
- /*@{*/
void (*decode_bitstream)(struct pipe_video_context *vpipe,
unsigned num_bufs,
struct pipe_buffer **bitstream_buf);
#endif
+ /**
+ * render a video buffer to the frontbuffer
+ */
void (*render_picture)(struct pipe_video_context *vpipe,
struct pipe_video_buffer *src_surface,
struct pipe_video_rect *src_area,
struct pipe_video_rect *dst_area,
struct pipe_fence_handle **fence);
-#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);
-
- struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage, /* a combination of PIPE_TRANSFER_x */
- const struct pipe_box *box);
-
- void (*transfer_destroy)(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer);
-
- void* (*transfer_map)(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer);
-
- void (*transfer_flush_region)(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer,
- const struct pipe_box *box);
-
- void (*transfer_unmap)(struct pipe_video_context *vpipe,
- struct pipe_transfer *transfer);
-#endif
-
- void (*upload_sampler)(struct pipe_video_context *vpipe,
- struct pipe_sampler_view *dst,
- const struct pipe_box *dst_box,
- const void *src, unsigned src_stride,
- unsigned src_x, unsigned src_y);
-
- void (*clear_sampler)(struct pipe_video_context *vpipe,
- struct pipe_sampler_view *dst,
- const struct pipe_box *dst_box,
- const float *rgba);
-
/*@}*/
/**
* Parameter-like states (or properties)
*/
/*@{*/
-#if 0
- void (*set_picture_background)(struct pipe_video_context *vpipe,
- struct pipe_surface *bg,
- struct pipe_video_rect *bg_src_rect);
-#endif
+ /**
+ * set overlay samplers
+ */
void (*set_picture_layers)(struct pipe_video_context *vpipe,
struct pipe_sampler_view *layers[],
struct pipe_video_rect *src_rects[],
struct pipe_video_rect *dst_rects[],
unsigned num_layers);
-#if 0
- void (*set_picture_desc)(struct pipe_video_context *vpipe,
- const struct pipe_picture_desc *desc);
-#endif
-
void (*set_csc_matrix)(struct pipe_video_context *vpipe, const float *mat);
/* TODO: Interface for scaling modes, post-processing, etc. */
{
struct pipe_video_context* context;
+ /**
+ * destroy this video buffer
+ */
void (*destroy)(struct pipe_video_buffer *buffer);
+ /**
+ * map the buffer into memory before calling add_macroblocks
+ */
void (*map)(struct pipe_video_buffer *buffer);
+ /**
+ * add macroblocks to buffer for decoding
+ */
void (*add_macroblocks)(struct pipe_video_buffer *buffer,
unsigned num_macroblocks,
struct pipe_macroblock *macroblocks);
+ /**
+ * unmap buffer before flushing
+ */
void (*unmap)(struct pipe_video_buffer *buffer);
+ /**
+ * flush buffer to video hardware
+ */
void (*flush)(struct pipe_video_buffer *buffer,
struct pipe_video_buffer *ref_frames[2],
struct pipe_fence_handle **fence);
int width, int height, int flags, XvMCContext *context)
{
bool found_port;
- int scrn;
- int chroma_format;
- int mc_type;
- int surface_flags;
- unsigned short subpic_max_w;
- unsigned short subpic_max_h;
+ int scrn = 0;
+ int chroma_format = 0;
+ int mc_type = 0;
+ int surface_flags = 0;
+ unsigned short subpic_max_w = 0;
+ unsigned short subpic_max_h = 0;
Status ret;
struct vl_screen *vscreen;
struct vl_context *vctx;
#include <util/u_memory.h>
#include <util/u_math.h>
#include <util/u_format.h>
+#include <util/u_sampler.h>
#include "xvmc_private.h"
#define FOURCC_RGB 0x0000003
tex = vpipe->screen->resource_create(vpipe->screen, &tex_templ);
memset(&sampler_templ, 0, sizeof(sampler_templ));
+ u_sampler_view_default_template(&sampler_templ, tex, tex->format);
+
+#if 0
+ switch (image->id) {
+ case FOURCC_RGB:
+ assert(subpicture_priv->sfc->format == XvIDToPipe(image->id));
+ for (y = 0; y < height; ++y) {
+ dst_line = dst;
+ for (x = 0; x < width; ++x, src += 3, dst_line += 4) {
+ dst_line[0] = src[2]; /* B */
+ dst_line[1] = src[1]; /* G */
+ dst_line[2] = src[0]; /* R */
+ }
+ dst += xfer->stride;
+ }
+ break;
+ default:
+ XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized Xv image ID 0x%08X.\n", image->id);
+ }
+#endif
+
subpicture_priv->sampler = vpipe->create_sampler_view(vpipe, tex, &sampler_templ);
pipe_resource_reference(&tex, NULL);
if (!subpicture_priv->sampler) {
{
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
+ struct pipe_box dst_box = {x, y, 0, width, height, 1};
float color_f[4];
assert(dpy);
subpicture_priv = subpicture->privData;
context_priv = subpicture_priv->context->privData;
/* TODO: Assert clear rect is within bounds? Or clip? */
- //context_priv->vctx->vpipe->clear_render_target(context_priv->vctx->vpipe,
- // subpicture_priv->sampler, x, y,
- // color_f, width, height);
+ context_priv->vctx->vpipe->clear_sampler(context_priv->vctx->vpipe,
+ subpicture_priv->sampler, &dst_box,
+ color_f);
return Success;
}
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
struct pipe_video_context *vpipe;
-
- unsigned char *src, *dst, *dst_line;
- unsigned x, y;
struct pipe_box dst_box = {dstx, dsty, 0, width, height, 1};
XVMC_MSG(XVMC_TRACE, "[XvMC] Compositing subpicture %p.\n", subpicture);
vpipe->upload_sampler(vpipe, subpicture_priv->sampler, &dst_box,
image->data, width*3, srcx, srcy);
-#if 0
- switch (image->id) {
- case FOURCC_RGB:
- assert(subpicture_priv->sfc->format == XvIDToPipe(image->id));
- for (y = 0; y < height; ++y) {
- dst_line = dst;
- for (x = 0; x < width; ++x, src += 3, dst_line += 4) {
- dst_line[0] = src[2]; /* B */
- dst_line[1] = src[1]; /* G */
- dst_line[2] = src[0]; /* R */
- }
- dst += xfer->stride;
- }
- break;
- default:
- XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized Xv image ID 0x%08X.\n", image->id);
- }
-#endif
-
XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p composited.\n", subpicture);
return Success;