formats[0] = formats[1] = formats[2] = dec->zscan_source_format;
buffer->zscan_source = vl_video_buffer_init(dec->base.context, dec->pipe,
dec->blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT,
- align(dec->max_blocks, dec->blocks_per_line) / dec->blocks_per_line,
+ align(dec->num_blocks, dec->blocks_per_line) / dec->blocks_per_line,
1, PIPE_VIDEO_CHROMA_FORMAT_444,
formats, PIPE_USAGE_STATIC);
if (!buffer->zscan_source)
}
}
+ vb[2] = dec->block_num;
+
dec->pipe->bind_vertex_elements_state(dec->pipe, dec->ves_ycbcr);
for (i = 0; i < VL_MAX_PLANES; ++i) {
if (!num_ycbcr_blocks[i]) continue;
vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, i);
- dec->pipe->set_vertex_buffers(dec->pipe, 2, vb);
+ dec->pipe->set_vertex_buffers(dec->pipe, 3, vb);
vl_zscan_render(&buf->zscan[i] , num_ycbcr_blocks[i]);
if (!num_ycbcr_blocks[i]) continue;
vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, component);
- dec->pipe->set_vertex_buffers(dec->pipe, 2, vb);
+ dec->pipe->set_vertex_buffers(dec->pipe, 3, vb);
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
vl_idct_prepare_stage2(component == 0 ? &dec->idct_y : &dec->idct_c, &buf->idct[component]);
static bool
init_zscan(struct vl_mpeg12_decoder *dec, const struct format_config* format_config)
{
- const unsigned block_size_pixels = BLOCK_WIDTH * BLOCK_HEIGHT;
unsigned num_channels;
assert(dec);
- dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4);
- dec->max_blocks = (dec->base.width * dec->base.height) / block_size_pixels;
-
dec->zscan_source_format = format_config->zscan_source_format;
dec->zscan_linear = vl_zscan_layout(dec->pipe, vl_zscan_linear, dec->blocks_per_line);
dec->zscan_normal = vl_zscan_layout(dec->pipe, vl_zscan_normal, dec->blocks_per_line);
num_channels = dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT ? 4 : 1;
if (!vl_zscan_init(&dec->zscan_y, dec->pipe, dec->base.width, dec->base.height,
- dec->blocks_per_line, dec->max_blocks, num_channels))
+ dec->blocks_per_line, dec->num_blocks, num_channels))
return false;
if (!vl_zscan_init(&dec->zscan_c, dec->pipe, dec->chroma_width, dec->chroma_height,
- dec->blocks_per_line, dec->max_blocks, num_channels))
+ dec->blocks_per_line, dec->num_blocks, num_channels))
return false;
return true;
enum pipe_video_chroma_format chroma_format,
unsigned width, unsigned height)
{
+ const unsigned block_size_pixels = BLOCK_WIDTH * BLOCK_HEIGHT;
const struct format_config *format_config;
struct vl_mpeg12_decoder *dec;
dec->pipe = pipe;
+ dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4);
+ dec->num_blocks = (dec->base.width * dec->base.height) / block_size_pixels;
+
dec->quads = vl_vb_upload_quads(dec->pipe);
dec->pos = vl_vb_upload_pos(
dec->pipe,
dec->base.width / MACROBLOCK_WIDTH,
dec->base.height / MACROBLOCK_HEIGHT
);
+ dec->block_num = vl_vb_upload_block_num(dec->pipe, dec->num_blocks);
dec->ves_ycbcr = vl_vb_get_ves_ycbcr(dec->pipe);
dec->ves_mv = vl_vb_get_ves_mv(dec->pipe);
unsigned chroma_width, chroma_height;
unsigned blocks_per_line;
- unsigned max_blocks;
+ unsigned num_blocks;
enum pipe_format zscan_source_format;
struct pipe_vertex_buffer quads;
struct pipe_vertex_buffer pos;
+ struct pipe_vertex_buffer block_num;
void *ves_ycbcr;
void *ves_mv;
return pos;
}
+struct pipe_vertex_buffer
+vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks)
+{
+ struct pipe_vertex_buffer buf;
+ struct pipe_transfer *buf_transfer;
+ struct vertex2s *v;
+ unsigned i;
+
+ assert(pipe);
+
+ /* create buffer */
+ buf.stride = sizeof(struct vertex2s);
+ buf.buffer_offset = 0;
+ buf.buffer = pipe_buffer_create
+ (
+ pipe->screen,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(struct vertex2s) * num_blocks
+ );
+
+ if(!buf.buffer)
+ return buf;
+
+ /* and fill it */
+ v = pipe_buffer_map
+ (
+ pipe,
+ buf.buffer,
+ PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
+ &buf_transfer
+ );
+
+ for ( i = 0; i < num_blocks; ++i, ++v) {
+ v->x = i;
+ v->y = i;
+ }
+
+ pipe_buffer_unmap(pipe, buf_transfer);
+
+ return buf;
+}
+
static struct pipe_vertex_element
vl_vb_get_quad_vertex_element(void)
{
vl_vb_element_helper(&vertex_elems[VS_I_VPOS], 1, 1);
- return pipe->create_vertex_elements_state(pipe, 2, vertex_elems);
+ /* block num element */
+ vertex_elems[VS_I_BLOCK_NUM].src_format = PIPE_FORMAT_R16G16_SSCALED;
+
+ vl_vb_element_helper(&vertex_elems[VS_I_BLOCK_NUM], 1, 2);
+
+ return pipe->create_vertex_elements_state(pipe, 3, vertex_elems);
}
void *
return false;
}
+unsigned
+vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer)
+{
+ return 1;
+}
+
struct pipe_vertex_buffer
vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component)
{
/* inputs to the vertex shaders */
enum VS_INPUT
{
- VS_I_RECT,
- VS_I_VPOS,
+ VS_I_RECT = 0,
+ VS_I_VPOS = 1,
- VS_I_MV_TOP,
- VS_I_MV_BOTTOM,
+ VS_I_BLOCK_NUM = 2,
- NUM_VS_INPUTS
+ VS_I_MV_TOP = 2,
+ VS_I_MV_BOTTOM = 3,
+
+ NUM_VS_INPUTS = 4
};
struct vl_vertex_buffer
struct pipe_vertex_buffer vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height);
+struct pipe_vertex_buffer vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks);
+
void *vl_vb_get_ves_ycbcr(struct pipe_context *pipe);
void *vl_vb_get_ves_mv(struct pipe_context *pipe);
struct pipe_context *pipe,
unsigned width, unsigned height);
+unsigned vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer);
+
void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component);
{
struct ureg_program *shader;
- struct ureg_src scale, instance;
- struct ureg_src vrect, vpos;
+ struct ureg_src scale;
+ struct ureg_src vrect, vpos, block_num;
struct ureg_dst tmp;
struct ureg_dst o_vpos, o_vtex[zscan->num_channels];
(float)BLOCK_WIDTH / zscan->buffer_width,
(float)BLOCK_HEIGHT / zscan->buffer_height);
- instance = ureg_DECL_system_value(shader, 0, TGSI_SEMANTIC_INSTANCEID, 0);
-
vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
+ block_num = ureg_DECL_system_value(shader, 0, TGSI_SEMANTIC_INSTANCEID, 0);
+
tmp = ureg_DECL_temporary(shader);
o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
ureg_MUL(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_XY), ureg_src(tmp), scale);
ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_ZW), ureg_imm1f(shader, 1.0f));
- ureg_MUL(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XW), ureg_scalar(instance, TGSI_SWIZZLE_X),
+ ureg_MUL(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XW), ureg_scalar(block_num, TGSI_SWIZZLE_X),
ureg_imm1f(shader, 1.0f / zscan->blocks_per_line));
ureg_FRC(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X));