assert(idct);
- idct->quad = vl_vb_upload_quads(idct->pipe, idct->blocks_x, idct->blocks_y);
-
- if(idct->quad.buffer == NULL)
- return false;
-
for (i = 0; i < 4; ++i) {
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_REPEAT;
rs_state.gl_rasterization_rules = false;
idct->rs_state = idct->pipe->create_rasterizer_state(idct->pipe, &rs_state);
- idct->vertex_elems_state = vl_vb_get_elems_state(idct->pipe, false);
-
return true;
}
idct->pipe->delete_sampler_state(idct->pipe, idct->samplers.all[i]);
idct->pipe->delete_rasterizer_state(idct->pipe, idct->rs_state);
- idct->pipe->delete_vertex_elements_state(idct->pipe, idct->vertex_elems_state);
}
static bool
}
}
-static bool
-init_vertex_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer, struct pipe_vertex_buffer stream)
-{
- assert(idct && buffer);
-
- buffer->vertex_bufs.individual.quad.stride = idct->quad.stride;
- buffer->vertex_bufs.individual.quad.buffer_offset = idct->quad.buffer_offset;
- pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, idct->quad.buffer);
-
- buffer->vertex_bufs.individual.stream.stride = stream.stride;
- buffer->vertex_bufs.individual.stream.buffer_offset = stream.buffer_offset;
- pipe_resource_reference(&buffer->vertex_bufs.individual.stream.buffer, stream.buffer);
-
- return true;
-}
-
-static void
-cleanup_vertex_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer)
-{
- assert(idct && buffer);
-
- pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, NULL);
- pipe_resource_reference(&buffer->vertex_bufs.individual.stream.buffer, NULL);
-}
-
struct pipe_resource *
vl_idct_upload_matrix(struct pipe_context *pipe)
{
bool
vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
- struct pipe_resource *dst, struct pipe_vertex_buffer stream)
+ struct pipe_resource *dst)
{
struct pipe_surface template;
if (!init_textures(idct, buffer))
return false;
- if (!init_vertex_buffers(idct, buffer, stream))
- return false;
-
/* init state */
buffer->viewport[0].scale[0] = buffer->textures.individual.intermediate->width0;
buffer->viewport[0].scale[1] = buffer->textures.individual.intermediate->height0;
idct->pipe->surface_destroy(idct->pipe, buffer->fb_state[1].cbufs[0]);
cleanup_textures(idct, buffer);
- cleanup_vertex_buffers(idct, buffer);
}
void
num_verts = idct->blocks_x * idct->blocks_y * 4;
idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state);
- idct->pipe->set_vertex_buffers(idct->pipe, 2, buffer->vertex_bufs.all);
- idct->pipe->bind_vertex_elements_state(idct->pipe, idct->vertex_elems_state);
/* first stage */
idct->pipe->set_framebuffer_state(idct->pipe, &buffer->fb_state[0]);
unsigned blocks_x, blocks_y;
void *rs_state;
- void *vertex_elems_state;
union
{
void *matrix_fs, *transpose_fs;
struct pipe_resource *matrix;
- struct pipe_vertex_buffer quad;
};
struct vl_idct_buffer
} individual;
} textures;
- union
- {
- struct pipe_vertex_buffer all[2];
- struct { struct pipe_vertex_buffer quad, stream; } individual;
- } vertex_bufs;
-
struct pipe_transfer *tex_transfer;
short *texels;
};
void vl_idct_cleanup(struct vl_idct *idct);
bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
- struct pipe_resource *dst, struct pipe_vertex_buffer stream);
+ struct pipe_resource *dst);
void vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer);
init_buffers(struct vl_mpeg12_mc_renderer *r)
{
struct pipe_resource *idct_matrix;
-
- const unsigned mbw =
- align(r->buffer_width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH;
- const unsigned mbh =
- align(r->buffer_height, MACROBLOCK_HEIGHT) / MACROBLOCK_HEIGHT;
-
unsigned chroma_width, chroma_height, chroma_blocks_x, chroma_blocks_y;
assert(r);
- r->macroblocks_per_batch =
- mbw * (r->bufmode == VL_MPEG12_MC_RENDERER_BUFFER_PICTURE ? mbh : 1);
-
if (!(idct_matrix = vl_idct_upload_matrix(r->pipe)))
return false;
chroma_blocks_x, chroma_blocks_y, TGSI_SWIZZLE_Z, idct_matrix))
return false;
- r->quad = vl_vb_upload_quads(r->pipe, 1, 1);
- r->vertex_elems_state = vl_vb_get_elems_state(r->pipe, true);
-
- if (r->vertex_elems_state == NULL)
- return false;
-
r->vs = create_vert_shader(r);
r->fs = create_frag_shader(r);
vl_idct_cleanup(&r->idct_y);
vl_idct_cleanup(&r->idct_cr);
vl_idct_cleanup(&r->idct_cb);
-
- r->pipe->delete_vertex_elements_state(r->pipe, r->vertex_elems_state);
}
static struct pipe_sampler_view
}
}
-static void
-grab_macroblock(struct vl_mpeg12_mc_renderer *r,
- struct vl_mpeg12_mc_buffer *buffer,
- struct pipe_mpeg12_macroblock *mb)
-{
- assert(r);
- assert(mb);
- assert(mb->blocks);
-
- vl_vb_add_block(&buffer->vertex_stream, mb, r->empty_block_mask);
- grab_blocks(r, buffer, mb->mbx, mb->mby, mb->cbp, mb->blocks);
-}
-
static void
texview_map_delete(const struct keymap *map,
const void *key, void *data,
struct pipe_context *pipe,
unsigned buffer_width,
unsigned buffer_height,
- enum pipe_video_chroma_format chroma_format,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode)
+ enum pipe_video_chroma_format chroma_format)
{
assert(renderer);
assert(pipe);
- /* TODO: Implement other policies */
- assert(bufmode == VL_MPEG12_MC_RENDERER_BUFFER_PICTURE);
-
memset(renderer, 0, sizeof(struct vl_mpeg12_mc_renderer));
renderer->pipe = pipe;
renderer->buffer_width = buffer_width;
renderer->buffer_height = buffer_height;
renderer->chroma_format = chroma_format;
- renderer->bufmode = bufmode;
/* TODO: Implement 422, 444 */
assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
buffer->past = NULL;
buffer->future = NULL;
- buffer->vertex_bufs.individual.quad.stride = renderer->quad.stride;
- buffer->vertex_bufs.individual.quad.buffer_offset = renderer->quad.buffer_offset;
- pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, renderer->quad.buffer);
-
- buffer->vertex_bufs.individual.stream = vl_vb_init(&buffer->vertex_stream, renderer->pipe,
- renderer->macroblocks_per_batch);
-
memset(&template, 0, sizeof(struct pipe_resource));
template.target = PIPE_TEXTURE_2D;
/* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
buffer->textures.individual.y = renderer->pipe->screen->resource_create(renderer->pipe->screen, &template);
- if (!vl_idct_init_buffer(&renderer->idct_y, &buffer->idct_y,
- buffer->textures.individual.y,
- buffer->vertex_bufs.individual.stream))
+ if (!vl_idct_init_buffer(&renderer->idct_y, &buffer->idct_y, buffer->textures.individual.y))
return false;
if (renderer->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
buffer->textures.individual.cr =
renderer->pipe->screen->resource_create(renderer->pipe->screen, &template);
- if (!vl_idct_init_buffer(&renderer->idct_cb, &buffer->idct_cb,
- buffer->textures.individual.cb,
- buffer->vertex_bufs.individual.stream))
+ if (!vl_idct_init_buffer(&renderer->idct_cb, &buffer->idct_cb, buffer->textures.individual.cb))
return false;
- if (!vl_idct_init_buffer(&renderer->idct_cr, &buffer->idct_cr,
- buffer->textures.individual.cr,
- buffer->vertex_bufs.individual.stream))
+ if (!vl_idct_init_buffer(&renderer->idct_cr, &buffer->idct_cr, buffer->textures.individual.cr))
return false;
for (i = 0; i < 3; ++i) {
for (i = 0; i < 3; ++i) {
pipe_sampler_view_reference(&buffer->sampler_views.all[i], NULL);
- pipe_resource_reference(&buffer->vertex_bufs.all[i].buffer, NULL);
pipe_resource_reference(&buffer->textures.all[i], NULL);
}
- pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, NULL);
- vl_vb_cleanup(&buffer->vertex_stream);
-
vl_idct_cleanup_buffer(&renderer->idct_y, &buffer->idct_y);
vl_idct_cleanup_buffer(&renderer->idct_cb, &buffer->idct_cb);
vl_idct_cleanup_buffer(&renderer->idct_cr, &buffer->idct_cr);
vl_idct_map_buffers(&renderer->idct_y, &buffer->idct_y);
vl_idct_map_buffers(&renderer->idct_cr, &buffer->idct_cr);
vl_idct_map_buffers(&renderer->idct_cb, &buffer->idct_cb);
-
- vl_vb_map(&buffer->vertex_stream, renderer->pipe);
}
void
}
for (i = 0; i < num_macroblocks; ++i) {
- assert(mpeg12_macroblocks[i].base.codec == PIPE_VIDEO_CODEC_MPEG12);
- grab_macroblock(renderer, buffer, &mpeg12_macroblocks[i]);
+ struct pipe_mpeg12_macroblock *mb = &mpeg12_macroblocks[i];
+
+ assert(mb->base.codec == PIPE_VIDEO_CODEC_MPEG12);
+ grab_blocks(renderer, buffer, mb->mbx, mb->mby, mb->cbp, mb->blocks);
}
}
vl_idct_unmap_buffers(&renderer->idct_y, &buffer->idct_y);
vl_idct_unmap_buffers(&renderer->idct_cr, &buffer->idct_cr);
vl_idct_unmap_buffers(&renderer->idct_cb, &buffer->idct_cb);
-
- vl_vb_unmap(&buffer->vertex_stream, renderer->pipe);
}
void
-vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer)
+vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer,
+ unsigned not_empty_start_instance, unsigned not_empty_num_instances,
+ unsigned empty_start_instance, unsigned empty_num_instances)
{
- unsigned num_not_empty, num_empty;
assert(renderer && buffer);
- num_not_empty = buffer->vertex_stream.num_not_empty;
- num_empty = buffer->vertex_stream.num_empty;
-
- if (num_not_empty == 0 && num_empty == 0)
+ if (not_empty_num_instances == 0 && empty_num_instances == 0)
return;
- vl_idct_flush(&renderer->idct_y, &buffer->idct_y, num_not_empty);
- vl_idct_flush(&renderer->idct_cr, &buffer->idct_cr, num_not_empty);
- vl_idct_flush(&renderer->idct_cb, &buffer->idct_cb, num_not_empty);
+ vl_idct_flush(&renderer->idct_y, &buffer->idct_y, not_empty_num_instances);
+ vl_idct_flush(&renderer->idct_cr, &buffer->idct_cr, not_empty_num_instances);
+ vl_idct_flush(&renderer->idct_cb, &buffer->idct_cb, not_empty_num_instances);
renderer->fb_state.cbufs[0] = buffer->surface;
renderer->pipe->bind_rasterizer_state(renderer->pipe, renderer->rs_state);
renderer->pipe->set_framebuffer_state(renderer->pipe, &renderer->fb_state);
renderer->pipe->set_viewport_state(renderer->pipe, &renderer->viewport);
- renderer->pipe->set_vertex_buffers(renderer->pipe, 2, buffer->vertex_bufs.all);
- renderer->pipe->bind_vertex_elements_state(renderer->pipe, renderer->vertex_elems_state);
if (buffer->past) {
buffer->sampler_views.individual.ref[0] = find_or_create_sampler_view(renderer, buffer->past);
renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs);
renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs);
- if (num_not_empty > 0)
- util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_not_empty);
+ if (not_empty_num_instances > 0)
+ util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4,
+ not_empty_start_instance, not_empty_num_instances);
- if (num_empty > 0)
+ if (empty_num_instances > 0)
util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4,
- buffer->vertex_stream.size - num_empty, num_empty);
+ empty_start_instance, empty_num_instances);
renderer->pipe->flush(renderer->pipe, PIPE_FLUSH_RENDER_CACHE, buffer->fence);
pipe_surface_reference(&buffer->surface, NULL);
pipe_surface_reference(&buffer->past, NULL);
pipe_surface_reference(&buffer->future, NULL);
-
- vl_vb_restart(&buffer->vertex_stream);
}
struct pipe_macroblock;
struct keymap;
-/* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
-enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
-{
- VL_MPEG12_MC_RENDERER_BUFFER_SLICE, /* Saves memory at the cost of smaller batches */
- VL_MPEG12_MC_RENDERER_BUFFER_PICTURE /* Larger batches, more memory */
-};
-
struct vl_mpeg12_mc_renderer
{
struct pipe_context *pipe;
unsigned buffer_height;
enum pipe_video_chroma_format chroma_format;
const unsigned (*empty_block_mask)[3][2][2];
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode;
- unsigned macroblocks_per_batch;
struct pipe_viewport_state viewport;
struct pipe_framebuffer_state fb_state;
struct vl_idct idct_y, idct_cr, idct_cb;
- void *vertex_elems_state;
void *rs_state;
void *vs, *fs;
- struct pipe_vertex_buffer quad;
-
union
{
void *all[5];
{
struct vl_idct_buffer idct_y, idct_cb, idct_cr;
- struct vl_vertex_buffer vertex_stream;
-
union
{
struct pipe_sampler_view *all[5];
struct { struct pipe_resource *y, *cb, *cr; } individual;
} textures;
- union
- {
- struct pipe_vertex_buffer all[2];
- struct {
- struct pipe_vertex_buffer quad, stream;
- } individual;
- } vertex_bufs;
-
struct pipe_surface *surface, *past, *future;
struct pipe_fence_handle **fence;
};
struct pipe_context *pipe,
unsigned picture_width,
unsigned picture_height,
- enum pipe_video_chroma_format chroma_format,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode);
+ enum pipe_video_chroma_format chroma_format);
void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
void vl_mpeg12_mc_unmap_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
-void vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer);
+void vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer,
+ unsigned not_empty_start_instance, unsigned not_empty_num_instances,
+ unsigned empty_start_instance, unsigned empty_num_instances);
#endif /* vl_mpeg12_mc_renderer_h */
}
void
-vl_vb_restart(struct vl_vertex_buffer *buffer)
+vl_vb_restart(struct vl_vertex_buffer *buffer,
+ unsigned *not_empty_start_instance, unsigned *not_empty_num_instances,
+ unsigned *empty_start_instance, unsigned *empty_num_instances)
{
assert(buffer);
+ *not_empty_start_instance = 0;
+ *not_empty_num_instances = buffer->num_not_empty;
+ *empty_start_instance = buffer->size - buffer->num_empty;
+ *empty_num_instances = buffer->num_empty;
+
buffer->num_not_empty = 0;
buffer->num_empty = 0;
}
void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
-void vl_vb_restart(struct vl_vertex_buffer *buffer);
+void vl_vb_restart(struct vl_vertex_buffer *buffer,
+ unsigned *not_empty_start_instance, unsigned *not_empty_num_instances,
+ unsigned *empty_start_instance, unsigned *empty_num_instances);
void vl_vb_cleanup(struct vl_vertex_buffer *buffer);
return NULL;
return sp_video_create_ex(pipe, profile, chroma_format, width, height,
- VL_MPEG12_MC_RENDERER_BUFFER_PICTURE,
true,
PIPE_FORMAT_VUYX);
}
#include "sp_public.h"
#include "sp_texture.h"
+#define MACROBLOCK_WIDTH 16
+#define MACROBLOCK_HEIGHT 16
+
#define NUM_BUFFERS 2
static void
flush_buffer(struct sp_mpeg12_context *ctx)
{
+ unsigned ne_start, ne_num, e_start, e_num;
assert(ctx);
- if(ctx->mc_buffer != NULL) {
+ if(ctx->cur_buffer != NULL) {
+
+ vl_vb_unmap(&ctx->cur_buffer->vertex_stream, ctx->pipe);
+ vl_mpeg12_mc_unmap_buffer(&ctx->mc_renderer, &ctx->cur_buffer->mc);
+ vl_vb_restart(&ctx->cur_buffer->vertex_stream, &ne_start, &ne_num, &e_start, &e_num);
- vl_mpeg12_mc_unmap_buffer(&ctx->mc_renderer, ctx->mc_buffer);
- vl_mpeg12_mc_renderer_flush(&ctx->mc_renderer, ctx->mc_buffer);
+ 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_mpeg12_mc_renderer_flush(&ctx->mc_renderer, &ctx->cur_buffer->mc, ne_start, ne_num, e_start, e_num);
- ctx->mc_buffer = NULL;
+ ctx->cur_buffer = NULL;
}
}
rotate_buffer(struct sp_mpeg12_context *ctx)
{
static unsigned key = 0;
- struct vl_mpeg12_mc_buffer *buffer;
+ struct sp_mpeg12_buffer *buffer;
assert(ctx);
flush_buffer(ctx);
- buffer = (struct vl_mpeg12_mc_buffer*)util_keymap_lookup(ctx->buffer_map, &key);
+ buffer = (struct sp_mpeg12_buffer*)util_keymap_lookup(ctx->buffer_map, &key);
if (!buffer) {
boolean added_to_map;
- buffer = CALLOC_STRUCT(vl_mpeg12_mc_buffer);
+ buffer = CALLOC_STRUCT(sp_mpeg12_buffer);
if (buffer == NULL)
return;
- if(!vl_mpeg12_mc_init_buffer(&ctx->mc_renderer, buffer)) {
+ 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(!vl_mpeg12_mc_init_buffer(&ctx->mc_renderer, &buffer->mc)) {
FREE(buffer);
return;
}
}
++key;
key %= NUM_BUFFERS;
- ctx->mc_buffer = buffer;
+ ctx->cur_buffer = buffer;
- vl_mpeg12_mc_map_buffer(&ctx->mc_renderer, ctx->mc_buffer);
+ vl_vb_map(&ctx->cur_buffer->vertex_stream, ctx->pipe);
+ vl_mpeg12_mc_map_buffer(&ctx->mc_renderer, &ctx->cur_buffer->mc);
}
static void
void *user)
{
struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)user;
- struct vl_mpeg12_mc_buffer *buf = (struct vl_mpeg12_mc_buffer*)data;
+ struct sp_mpeg12_buffer *buf = (struct sp_mpeg12_buffer*)data;
assert(map);
assert(key);
assert(data);
assert(user);
- vl_mpeg12_mc_cleanup_buffer(&ctx->mc_renderer, buf);
+ vl_vb_cleanup(&buf->vertex_stream);
+ vl_mpeg12_mc_cleanup_buffer(&ctx->mc_renderer, &buf->mc);
}
static void
vl_compositor_cleanup(&ctx->compositor);
util_delete_keymap(ctx->buffer_map, ctx);
vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
+ ctx->pipe->delete_vertex_elements_state(ctx->pipe, ctx->vertex_elems_state);
+ pipe_resource_reference(&ctx->quads.buffer, NULL);
ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
{
struct sp_mpeg12_context *ctx = (struct sp_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->mc_buffer);
+ assert(ctx->cur_buffer);
+
+ for ( i = 0; i < num_macroblocks; ++i )
+ vl_vb_add_block(&ctx->cur_buffer->vertex_stream, &mpeg12_macroblocks[i], ctx->mc_renderer.empty_block_mask);
vl_mpeg12_mc_renderer_render_macroblocks(&ctx->mc_renderer,
- ctx->mc_buffer,
+ &ctx->cur_buffer->mc,
ctx->decode_target,
past, future, num_macroblocks,
mpeg12_macroblocks, fence);
assert(vpipe);
assert(dt);
- if (ctx->decode_target != dt || ctx->mc_buffer == NULL) {
+ if (ctx->decode_target != dt || ctx->cur_buffer == NULL) {
rotate_buffer(ctx);
pipe_surface_reference(&ctx->decode_target, dt);
rast.offset_units = 1;
rast.offset_scale = 1;
rast.gl_rasterization_rules = 1;
-
+
ctx->rast = ctx->pipe->create_rasterizer_state(ctx->pipe, &rast);
ctx->pipe->bind_rasterizer_state(ctx->pipe, ctx->rast);
sp_mpeg12_create(struct pipe_context *pipe, enum pipe_video_profile profile,
enum pipe_video_chroma_format chroma_format,
unsigned width, unsigned height,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
bool pot_buffers,
enum pipe_format decode_format)
{
/* TODO: Non-pot buffers untested, probably doesn't work without changes to texcoord generation, vert shader, etc */
assert(pot_buffers);
- buffer_width = pot_buffers ? util_next_power_of_two(width) : width;
- buffer_height = pot_buffers ? util_next_power_of_two(height) : height;
+ buffer_width = pot_buffers ? util_next_power_of_two(width) : width;
+ buffer_height = pot_buffers ? util_next_power_of_two(height) : height;
ctx->base.profile = profile;
ctx->base.chroma_format = chroma_format;
ctx->pipe = pipe;
ctx->decode_format = decode_format;
+ ctx->quads = vl_vb_upload_quads(ctx->pipe, 2, 2);
+ ctx->vertex_buffer_size = width / MACROBLOCK_WIDTH * height / MACROBLOCK_HEIGHT;
+ ctx->vertex_elems_state = vl_vb_get_elems_state(ctx->pipe, true);
+
+ if (ctx->vertex_elems_state == NULL) {
+ 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,
- bufmode)) {
+ buffer_width, buffer_height, chroma_format)) {
ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
return NULL;
return sp_video_create_ex(pipe, profile,
chroma_format,
width, height,
- VL_MPEG12_MC_RENDERER_BUFFER_PICTURE,
true,
PIPE_FORMAT_XYUV);
}
sp_video_create_ex(struct pipe_context *pipe, enum pipe_video_profile profile,
enum pipe_video_chroma_format chroma_format,
unsigned width, unsigned height,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
bool pot_buffers,
enum pipe_format decode_format)
{
return sp_mpeg12_create(pipe, profile,
chroma_format,
width, height,
- bufmode,
pot_buffers,
decode_format);
default:
struct pipe_screen;
struct pipe_context;
+struct sp_mpeg12_buffer
+{
+ struct vl_vertex_buffer vertex_stream;
+
+ union
+ {
+ struct pipe_vertex_buffer all[2];
+ struct {
+ struct pipe_vertex_buffer quad, stream;
+ } individual;
+ } vertex_bufs;
+
+ struct vl_mpeg12_mc_buffer mc;
+};
+
struct sp_mpeg12_context
{
struct pipe_video_context base;
struct pipe_context *pipe;
struct pipe_surface *decode_target;
+
+ struct pipe_vertex_buffer quads;
+ unsigned vertex_buffer_size;
+ void *vertex_elems_state;
+
struct vl_mpeg12_mc_renderer mc_renderer;
+
struct keymap *buffer_map;
- struct vl_mpeg12_mc_buffer *mc_buffer;
+ struct sp_mpeg12_buffer *cur_buffer;
struct vl_compositor compositor;
void *rast;
sp_video_create_ex(struct pipe_context *pipe, enum pipe_video_profile profile,
enum pipe_video_chroma_format chroma_format,
unsigned width, unsigned height,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
bool pot_buffers,
enum pipe_format decode_format);