static bool
init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
{
- struct pipe_resource tex_templ, *tex;
- struct pipe_sampler_view sv_templ;
+ struct pipe_resource *tex;
struct pipe_surface surf_templ;
unsigned i;
assert(idct && buffer);
- memset(&tex_templ, 0, sizeof(tex_templ));
- tex_templ.target = PIPE_TEXTURE_3D;
- tex_templ.format = PIPE_FORMAT_R16G16B16A16_SNORM;
- tex_templ.width0 = idct->buffer_width / NR_RENDER_TARGETS;
- tex_templ.height0 = idct->buffer_height / 4;
- tex_templ.depth0 = NR_RENDER_TARGETS;
- tex_templ.array_size = 1;
- tex_templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- tex_templ.usage = PIPE_USAGE_STATIC;
-
- tex = idct->pipe->screen->resource_create(idct->pipe->screen, &tex_templ);
- if (!tex)
- goto error_tex;
-
- memset(&sv_templ, 0, sizeof(sv_templ));
- u_sampler_view_default_template(&sv_templ, tex, tex->format);
- buffer->sampler_views.individual.intermediate =
- idct->pipe->create_sampler_view(idct->pipe, tex, &sv_templ);
- if (!buffer->sampler_views.individual.intermediate)
- goto error_sampler_view;
+ tex = buffer->sampler_views.individual.intermediate->texture;
buffer->fb_state[0].width = tex->width0;
buffer->fb_state[0].height = tex->height0;
buffer->viewport[0].scale[0] = tex->width0;
buffer->viewport[0].scale[1] = tex->height0;
- pipe_resource_reference(&tex, NULL);
return true;
error_surfaces:
for(i = 0; i < NR_RENDER_TARGETS; ++i)
pipe_surface_reference(&buffer->fb_state[0].cbufs[i], NULL);
- pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, NULL);
-
-error_sampler_view:
- pipe_resource_reference(&tex, NULL);
-
-error_tex:
return false;
}
bool
vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
- struct pipe_sampler_view *source, struct pipe_surface *destination)
+ struct pipe_sampler_view *source,
+ struct pipe_sampler_view *intermediate,
+ struct pipe_surface *destination)
{
unsigned i;
pipe_sampler_view_reference(&buffer->sampler_views.individual.matrix, idct->matrix);
pipe_sampler_view_reference(&buffer->sampler_views.individual.source, source);
pipe_sampler_view_reference(&buffer->sampler_views.individual.transpose, idct->matrix);
+ pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, intermediate);
if (!init_intermediate(idct, buffer))
return false;
/* init a buffer assosiated with agiven idct instance */
bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
- struct pipe_sampler_view *source, struct pipe_surface *destination);
+ struct pipe_sampler_view *source,
+ struct pipe_sampler_view *intermediate,
+ struct pipe_surface *destination);
/* cleanup a buffer of an idct instance */
void vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer);
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
buf->idct_source->destroy(buf->idct_source);
+ buf->idct_intermediate->destroy(buf->idct_intermediate);
vl_idct_cleanup_buffer(&dec->idct_y, &buf->idct[0]);
vl_idct_cleanup_buffer(&dec->idct_c, &buf->idct[1]);
vl_idct_cleanup_buffer(&dec->idct_c, &buf->idct[2]);
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
struct vl_mpeg12_buffer *buffer;
- struct pipe_sampler_view **idct_views, **mc_views;
+ struct pipe_sampler_view **idct_source_sv, **idct_intermediate_sv, **mc_source_sv;
struct pipe_surface **idct_surfaces;
assert(dec);
if (!buffer->idct_source)
goto error_idct_source;
+ buffer->idct_intermediate = vl_video_buffer_init(dec->base.context, dec->pipe,
+ dec->base.width / 4, dec->base.height / 4, 4,
+ dec->base.chroma_format, 3,
+ idct_source_formats,
+ PIPE_USAGE_STATIC);
- idct_views = buffer->idct_source->get_sampler_views(buffer->idct_source);
- if (!idct_views)
- goto error_idct_views;
+ if (!buffer->idct_intermediate)
+ goto error_idct_intermediate;
+
+ idct_source_sv = buffer->idct_source->get_sampler_views(buffer->idct_source);
+ if (!idct_source_sv)
+ goto error_idct_source_sv;
+
+ idct_intermediate_sv = buffer->idct_intermediate->get_sampler_views(buffer->idct_intermediate);
+ if (!idct_intermediate_sv)
+ goto error_idct_intermediate_sv;
idct_surfaces = buffer->mc_source->get_surfaces(buffer->mc_source);
if (!idct_surfaces)
goto error_idct_surfaces;
if (!vl_idct_init_buffer(&dec->idct_y, &buffer->idct[0],
- idct_views[0], idct_surfaces[0]))
+ idct_source_sv[0],
+ idct_intermediate_sv[0],
+ idct_surfaces[0]))
goto error_idct_y;
if (!vl_idct_init_buffer(&dec->idct_c, &buffer->idct[1],
- idct_views[1], idct_surfaces[1]))
+ idct_source_sv[1],
+ idct_intermediate_sv[1],
+ idct_surfaces[1]))
goto error_idct_cb;
if (!vl_idct_init_buffer(&dec->idct_c, &buffer->idct[2],
- idct_views[2], idct_surfaces[2]))
+ idct_source_sv[2],
+ idct_intermediate_sv[2],
+ idct_surfaces[2]))
goto error_idct_cr;
}
- mc_views = buffer->mc_source->get_sampler_views(buffer->mc_source);
- if (!mc_views)
- goto error_mc_views;
+ mc_source_sv = buffer->mc_source->get_sampler_views(buffer->mc_source);
+ if (!mc_source_sv)
+ goto error_mc_source_sv;
- if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[0], mc_views[0]))
+ if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[0], mc_source_sv[0]))
goto error_mc_y;
- if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[1], mc_views[1]))
+ if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[1], mc_source_sv[1]))
goto error_mc_cb;
- if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[2], mc_views[2]))
+ if(!vl_mpeg12_mc_init_buffer(&dec->mc, &buffer->mc[2], mc_source_sv[2]))
goto error_mc_cr;
return &buffer->base;
vl_mpeg12_mc_cleanup_buffer(&buffer->mc[0]);
error_mc_y:
-error_mc_views:
+error_mc_source_sv:
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
vl_idct_cleanup_buffer(&dec->idct_c, &buffer->idct[2]);
error_idct_y:
error_idct_surfaces:
-error_idct_views:
+error_idct_intermediate_sv:
+error_idct_source_sv:
+ if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
+ buffer->idct_intermediate->destroy(buffer->idct_intermediate);
+
+error_idct_intermediate:
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
buffer->idct_source->destroy(buffer->idct_source);
struct vl_vertex_buffer vertex_stream;
struct pipe_video_buffer *idct_source;
+ struct pipe_video_buffer *idct_intermediate;
struct pipe_video_buffer *mc_source;
union
buffer->num_planes = num_planes;
memset(&templ, 0, sizeof(templ));
- templ.target = PIPE_TEXTURE_2D;
+ templ.target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D;
templ.format = resource_formats[0];
templ.width0 = width;
templ.height0 = height;
templ.format = resource_formats[1];
if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- if (depth > 1)
- templ.depth0 /= 2;
- else
- templ.width0 /= 2;
+ templ.width0 /= 2;
templ.height0 /= 2;
} else if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
- if (depth > 1)
- templ.depth0 /= 2;
- else
- templ.height0 /= 2;
+ templ.height0 /= 2;
}
buffer->resources[1] = pipe->screen->resource_create(pipe->screen, &templ);