diff options
author | Christian König <[email protected]> | 2011-04-06 00:06:20 +0200 |
---|---|---|
committer | Christian König <[email protected]> | 2011-04-06 00:06:20 +0200 |
commit | d9ad3aa3b9647f1ede2568600978af956ff32fff (patch) | |
tree | 91eb6e083acdaa6f368a607ad558df27d6d2ede1 /src/gallium/state_trackers | |
parent | 3a2b906805985e0a4258bcbaed4cdff758875514 (diff) |
[g3dvl] and finally split the decoder part out of the context
This should give a good basis to implement vdpau ontop of it.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/xorg/xvmc/context.c | 19 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xvmc/surface.c | 29 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xvmc/xvmc_private.h | 5 |
3 files changed, 39 insertions, 14 deletions
diff --git a/src/gallium/state_trackers/xorg/xvmc/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c index bdcba72d7cf..2690f8046a8 100644 --- a/src/gallium/state_trackers/xorg/xvmc/context.c +++ b/src/gallium/state_trackers/xorg/xvmc/context.c @@ -231,9 +231,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, return BadAlloc; } - vctx = vl_video_create(vscreen, ProfileToPipe(mc_type), - FormatToPipe(chroma_format), width, height); - + vctx = vl_video_create(vscreen); if (!vctx) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n"); vl_screen_destroy(vscreen); @@ -241,9 +239,23 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, return BadAlloc; } + context_priv->decoder = vctx->vpipe->create_decoder(vctx->vpipe, + ProfileToPipe(mc_type), + FormatToPipe(chroma_format), + width, height); + + if (!context_priv->decoder) { + XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL decoder.\n"); + vl_video_destroy(vctx); + vl_screen_destroy(vscreen); + FREE(context_priv); + return BadAlloc; + } + context_priv->compositor = vctx->vpipe->create_compositor(vctx->vpipe); if (!context_priv->compositor) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor.\n"); + context_priv->decoder->destroy(context_priv->decoder); vl_video_destroy(vctx); vl_screen_destroy(vscreen); FREE(context_priv); @@ -295,6 +307,7 @@ Status XvMCDestroyContext(Display *dpy, XvMCContext *context) context_priv = context->privData; vctx = context_priv->vctx; vscreen = vctx->vscreen; + context_priv->decoder->destroy(context_priv->decoder); context_priv->compositor->destroy(context_priv->compositor); vl_video_destroy(vctx); vl_screen_destroy(vscreen); diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index efbebaa4ccf..ba55d9ddb22 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -151,10 +151,13 @@ static void unmap_and_flush_surface(XvMCSurfacePrivate *surface) { struct pipe_video_buffer *ref_frames[2]; + XvMCContextPrivate *context_priv; unsigned i; assert(surface); + context_priv = surface->context->privData; + for ( i = 0; i < 2; ++i ) { if (surface->ref_surfaces[i]) { XvMCSurfacePrivate *ref = surface->ref_surfaces[i]->privData; @@ -163,17 +166,18 @@ unmap_and_flush_surface(XvMCSurfacePrivate *surface) unmap_and_flush_surface(ref); surface->ref_surfaces[i] = NULL; - ref_frames[i] = ref->pipe_buffer; + ref_frames[i] = ref->video_buffer; } else { ref_frames[i] = NULL; } } if (surface->mapped) { - surface->pipe_buffer->unmap(surface->pipe_buffer); - surface->pipe_buffer->flush(surface->pipe_buffer, - ref_frames, - &surface->flush_fence); + surface->decode_buffer->unmap(surface->decode_buffer); + context_priv->decoder->flush_buffer(surface->decode_buffer, + ref_frames, + surface->video_buffer, + &surface->flush_fence); surface->mapped = 0; } } @@ -201,7 +205,11 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac if (!surface_priv) return BadAlloc; - surface_priv->pipe_buffer = vpipe->create_buffer(vpipe); + surface_priv->decode_buffer = context_priv->decoder->create_buffer(context_priv->decoder); + surface_priv->video_buffer = vpipe->create_buffer(vpipe, PIPE_FORMAT_YV12, //TODO + context_priv->decoder->chroma_format, + context_priv->decoder->width, + context_priv->decoder->height); surface_priv->context = context; surface->surface_id = XAllocID(dpy); @@ -226,7 +234,7 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur ) { struct pipe_video_context *vpipe; - struct pipe_video_buffer *t_buffer; + struct pipe_video_decode_buffer *t_buffer; XvMCContextPrivate *context_priv; XvMCSurfacePrivate *target_surface_priv; XvMCSurfacePrivate *past_surface_priv; @@ -274,7 +282,7 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur context_priv = context->privData; vpipe = context_priv->vctx->vpipe; - t_buffer = target_surface_priv->pipe_buffer; + t_buffer = target_surface_priv->decode_buffer; // enshure that all reference frames are flushed // not really nessasary, but speeds ups rendering @@ -395,7 +403,7 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, unmap_and_flush_surface(surface_priv); compositor->clear_layers(compositor); - compositor->set_buffer_layer(compositor, 0, surface_priv->pipe_buffer, &src_rect, NULL); + compositor->set_buffer_layer(compositor, 0, surface_priv->video_buffer, &src_rect, NULL); if (subpicture_priv) { struct pipe_video_rect src_rect = {surface_priv->subx, surface_priv->suby, surface_priv->subw, surface_priv->subh}; @@ -471,7 +479,8 @@ Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface) return XvMCBadSurface; surface_priv = surface->privData; - surface_priv->pipe_buffer->destroy(surface_priv->pipe_buffer); + surface_priv->decode_buffer->destroy(surface_priv->decode_buffer); + surface_priv->video_buffer->destroy(surface_priv->video_buffer); FREE(surface_priv); surface->privData = NULL; diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h index 29518b36dbf..9a5338c2923 100644 --- a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h +++ b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h @@ -42,6 +42,7 @@ struct pipe_fence_handle; typedef struct { struct vl_context *vctx; + struct pipe_video_decoder *decoder; struct pipe_video_compositor *compositor; unsigned short subpicture_max_width; @@ -50,7 +51,9 @@ typedef struct typedef struct { - struct pipe_video_buffer *pipe_buffer; + struct pipe_video_decode_buffer *decode_buffer; + struct pipe_video_buffer *video_buffer; + bool mapped; // are we still mapped to memory? XvMCSurface *ref_surfaces[2]; |