}
void
-vl_idct_map_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer)
-{
- struct pipe_resource *tex;
-
- assert(idct && buffer);
-
- tex = buffer->sampler_views.individual.source->texture;
-
- struct pipe_box rect =
- {
- 0, 0, 0,
- tex->width0,
- tex->height0,
- 1
- };
-
- buffer->tex_transfer = idct->pipe->get_transfer
- (
- idct->pipe, tex,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
- &rect
- );
-
- buffer->texels = idct->pipe->transfer_map(idct->pipe, buffer->tex_transfer);
-}
-
-void
-vl_idct_add_block(struct vl_idct_buffer *buffer, unsigned x, unsigned y, short *block)
-{
- unsigned tex_pitch;
- short *texels;
-
- unsigned i;
-
- assert(buffer);
- assert(block);
-
- tex_pitch = buffer->tex_transfer->stride / sizeof(short);
- texels = buffer->texels + y * tex_pitch * BLOCK_HEIGHT + x * BLOCK_WIDTH;
-
- for (i = 0; i < BLOCK_HEIGHT; ++i)
- memcpy(texels + i * tex_pitch, block + i * BLOCK_WIDTH, BLOCK_WIDTH * sizeof(short));
-}
-
-void
-vl_idct_unmap_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer)
-{
- assert(idct && buffer);
-
- idct->pipe->transfer_unmap(idct->pipe, buffer->tex_transfer);
- idct->pipe->transfer_destroy(idct->pipe, buffer->tex_transfer);
-}
-
-void
vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_instances)
{
unsigned num_verts;
struct pipe_sampler_view *transpose, *intermediate;
} individual;
} sampler_views;
-
- struct pipe_transfer *tex_transfer;
- short *texels;
};
/* upload the idct matrix, which can be shared by all idct instances of a pipe */
/* cleanup a buffer of an idct instance */
void vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer);
-/* map a buffer for use with vl_idct_add_block */
-void vl_idct_map_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer);
-
-/* add an block of to be tranformed data a the given x and y coordinate */
-void vl_idct_add_block(struct vl_idct_buffer *buffer, unsigned x, unsigned y, short *block);
-
-/* unmaps the buffers before flushing */
-void vl_idct_unmap_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer);
-
/* flush the buffer and start rendering, vertex buffers needs to be setup before calling this */
void vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_verts);
};
static void
+map_buffers(struct vl_mpeg12_decoder *ctx, struct vl_mpeg12_buffer *buffer)
+{
+ struct pipe_sampler_view **sampler_views;
+ struct pipe_resource *tex;
+ unsigned i;
+
+ assert(ctx && buffer);
+
+ sampler_views = buffer->idct_source->get_sampler_views(buffer->idct_source);
+ assert(sampler_views);
+
+ for (i = 0; i < VL_MAX_PLANES; ++i) {
+ tex = sampler_views[i]->texture;
+
+ struct pipe_box rect =
+ {
+ 0, 0, 0,
+ tex->width0,
+ tex->height0,
+ 1
+ };
+
+ buffer->tex_transfer[i] = ctx->pipe->get_transfer
+ (
+ ctx->pipe, tex,
+ 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+ &rect
+ );
+
+ buffer->texels[i] = ctx->pipe->transfer_map(ctx->pipe, buffer->tex_transfer[i]);
+ }
+}
+
+static void
+upload_block(struct vl_mpeg12_buffer *buffer, unsigned plane, unsigned x, unsigned y, short *block)
+{
+ unsigned tex_pitch;
+ short *texels;
+
+ unsigned i;
+
+ assert(buffer);
+ assert(block);
+
+ tex_pitch = buffer->tex_transfer[plane]->stride / sizeof(short);
+ texels = buffer->texels[plane] + y * tex_pitch * BLOCK_HEIGHT + x * BLOCK_WIDTH;
+
+ for (i = 0; i < BLOCK_HEIGHT; ++i)
+ memcpy(texels + i * tex_pitch, block + i * BLOCK_WIDTH, BLOCK_WIDTH * sizeof(short));
+}
+
+static void
upload_buffer(struct vl_mpeg12_decoder *ctx,
struct vl_mpeg12_buffer *buffer,
struct pipe_mpeg12_macroblock *mb)
for (y = 0; y < 2; ++y) {
for (x = 0; x < 2; ++x, ++tb) {
if (mb->cbp & (*ctx->empty_block_mask)[0][y][x]) {
- vl_idct_add_block(&buffer->idct[0], mb->mbx * 2 + x, mb->mby * 2 + y, blocks);
+ upload_block(buffer, 0, mb->mbx * 2 + x, mb->mby * 2 + y, blocks);
blocks += BLOCK_WIDTH * BLOCK_HEIGHT;
}
}
for (tb = 1; tb < 3; ++tb) {
if (mb->cbp & (*ctx->empty_block_mask)[tb][0][0]) {
- vl_idct_add_block(&buffer->idct[tb], mb->mbx, mb->mby, blocks);
+ upload_block(buffer, tb, mb->mbx, mb->mby, blocks);
blocks += BLOCK_WIDTH * BLOCK_HEIGHT;
}
}
}
static void
+unmap_buffers(struct vl_mpeg12_decoder *ctx, struct vl_mpeg12_buffer *buffer)
+{
+ unsigned i;
+
+ assert(ctx && buffer);
+
+ for (i = 0; i < VL_MAX_PLANES; ++i) {
+ ctx->pipe->transfer_unmap(ctx->pipe, buffer->tex_transfer[i]);
+ ctx->pipe->transfer_destroy(ctx->pipe, buffer->tex_transfer[i]);
+ }
+}
+
+static void
vl_mpeg12_buffer_destroy(struct pipe_video_decode_buffer *buffer)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
assert(dec);
vl_vb_map(&buf->vertex_stream, dec->pipe);
- vl_idct_map_buffers(&dec->idct_y, &buf->idct[0]);
- vl_idct_map_buffers(&dec->idct_c, &buf->idct[1]);
- vl_idct_map_buffers(&dec->idct_c, &buf->idct[2]);
+ map_buffers(dec, buf);
}
static void
assert(dec);
vl_vb_unmap(&buf->vertex_stream, dec->pipe);
- vl_idct_unmap_buffers(&dec->idct_y, &buf->idct[0]);
- vl_idct_unmap_buffers(&dec->idct_c, &buf->idct[1]);
- vl_idct_unmap_buffers(&dec->idct_c, &buf->idct[2]);
+ unmap_buffers(dec, buf);
}
static void