diff options
Diffstat (limited to 'src/gallium/drivers/nvc0/nvc0_video.c')
-rw-r--r-- | src/gallium/drivers/nvc0/nvc0_video.c | 135 |
1 files changed, 4 insertions, 131 deletions
diff --git a/src/gallium/drivers/nvc0/nvc0_video.c b/src/gallium/drivers/nvc0/nvc0_video.c index a871ab792d7..2fc9233dc96 100644 --- a/src/gallium/drivers/nvc0/nvc0_video.c +++ b/src/gallium/drivers/nvc0/nvc0_video.c @@ -88,12 +88,12 @@ nvc0_decoder_decode_bitstream(struct pipe_video_decoder *decoder, const unsigned *num_bytes) { struct nvc0_decoder *dec = (struct nvc0_decoder *)decoder; - struct nvc0_video_buffer *target = (struct nvc0_video_buffer *)video_target; + struct nouveau_vp3_video_buffer *target = (struct nouveau_vp3_video_buffer *)video_target; uint32_t comm_seq = ++dec->fence_seq; union pipe_desc desc; unsigned vp_caps, is_ref, ret; - struct nvc0_video_buffer *refs[16] = {}; + struct nouveau_vp3_video_buffer *refs[16] = {}; desc.base = picture; @@ -531,137 +531,10 @@ fail: return NULL; } -static struct pipe_sampler_view ** -nvc0_video_buffer_sampler_view_planes(struct pipe_video_buffer *buffer) -{ - struct nvc0_video_buffer *buf = (struct nvc0_video_buffer *)buffer; - return buf->sampler_view_planes; -} - -static struct pipe_sampler_view ** -nvc0_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer) -{ - struct nvc0_video_buffer *buf = (struct nvc0_video_buffer *)buffer; - return buf->sampler_view_components; -} - -static struct pipe_surface ** -nvc0_video_buffer_surfaces(struct pipe_video_buffer *buffer) -{ - struct nvc0_video_buffer *buf = (struct nvc0_video_buffer *)buffer; - return buf->surfaces; -} - -static void -nvc0_video_buffer_destroy(struct pipe_video_buffer *buffer) -{ - struct nvc0_video_buffer *buf = (struct nvc0_video_buffer *)buffer; - unsigned i; - - assert(buf); - - for (i = 0; i < VL_NUM_COMPONENTS; ++i) { - pipe_resource_reference(&buf->resources[i], NULL); - pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL); - pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL); - pipe_surface_reference(&buf->surfaces[i * 2], NULL); - pipe_surface_reference(&buf->surfaces[i * 2 + 1], NULL); - } - FREE(buffer); -} - struct pipe_video_buffer * nvc0_video_buffer_create(struct pipe_context *pipe, const struct pipe_video_buffer *templat) { - struct nvc0_video_buffer *buffer; - struct pipe_resource templ; - unsigned i, j, component; - struct pipe_sampler_view sv_templ; - struct pipe_surface surf_templ; - - assert(templat->interlaced); - if (getenv("XVMC_VL") || templat->buffer_format != PIPE_FORMAT_NV12) - return vl_video_buffer_create(pipe, templat); - - assert(templat->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420); - - buffer = CALLOC_STRUCT(nvc0_video_buffer); - if (!buffer) - return NULL; - - buffer->base.buffer_format = templat->buffer_format; - buffer->base.context = pipe; - buffer->base.destroy = nvc0_video_buffer_destroy; - buffer->base.chroma_format = templat->chroma_format; - buffer->base.width = templat->width; - buffer->base.height = templat->height; - buffer->base.get_sampler_view_planes = nvc0_video_buffer_sampler_view_planes; - buffer->base.get_sampler_view_components = nvc0_video_buffer_sampler_view_components; - buffer->base.get_surfaces = nvc0_video_buffer_surfaces; - buffer->base.interlaced = true; - - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D_ARRAY; - templ.depth0 = 1; - templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; - templ.format = PIPE_FORMAT_R8_UNORM; - templ.width0 = buffer->base.width; - templ.height0 = (buffer->base.height + 1)/2; - templ.flags = NVC0_RESOURCE_FLAG_VIDEO; - templ.array_size = 2; - - buffer->resources[0] = pipe->screen->resource_create(pipe->screen, &templ); - if (!buffer->resources[0]) - goto error; - - templ.format = PIPE_FORMAT_R8G8_UNORM; - buffer->num_planes = 2; - templ.width0 = (templ.width0 + 1) / 2; - templ.height0 = (templ.height0 + 1) / 2; - for (i = 1; i < buffer->num_planes; ++i) { - buffer->resources[i] = pipe->screen->resource_create(pipe->screen, &templ); - if (!buffer->resources[i]) - goto error; - } - - memset(&sv_templ, 0, sizeof(sv_templ)); - for (component = 0, i = 0; i < buffer->num_planes; ++i ) { - struct pipe_resource *res = buffer->resources[i]; - unsigned nr_components = util_format_get_nr_components(res->format); - - u_sampler_view_default_template(&sv_templ, res, res->format); - buffer->sampler_view_planes[i] = pipe->create_sampler_view(pipe, res, &sv_templ); - if (!buffer->sampler_view_planes[i]) - goto error; - - for (j = 0; j < nr_components; ++j, ++component) { - sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = PIPE_SWIZZLE_RED + j; - sv_templ.swizzle_a = PIPE_SWIZZLE_ONE; - - buffer->sampler_view_components[component] = pipe->create_sampler_view(pipe, res, &sv_templ); - if (!buffer->sampler_view_components[component]) - goto error; - } - } - - memset(&surf_templ, 0, sizeof(surf_templ)); - for (j = 0; j < buffer->num_planes; ++j) { - surf_templ.format = buffer->resources[j]->format; - surf_templ.u.tex.first_layer = surf_templ.u.tex.last_layer = 0; - buffer->surfaces[j * 2] = pipe->create_surface(pipe, buffer->resources[j], &surf_templ); - if (!buffer->surfaces[j * 2]) - goto error; - - surf_templ.u.tex.first_layer = surf_templ.u.tex.last_layer = 1; - buffer->surfaces[j * 2 + 1] = pipe->create_surface(pipe, buffer->resources[j], &surf_templ); - if (!buffer->surfaces[j * 2 + 1]) - goto error; - } - - return &buffer->base; - -error: - nvc0_video_buffer_destroy(&buffer->base); - return NULL; + return nouveau_vp3_video_buffer_create( + pipe, templat, NVC0_RESOURCE_FLAG_VIDEO); } |