diff options
author | Cooper Yuan <cooperyuan@gmail.com> | 2009-10-09 17:44:48 +0800 |
---|---|---|
committer | Cooper Yuan <cooperyuan@gmail.com> | 2009-10-09 17:44:48 +0800 |
commit | a152dd69aeb7a41145a091acf9de93c7e904ee49 (patch) | |
tree | bc11a6a1f9e5a4ad86c58445d0fd0d7dd288e366 | |
parent | be1f1406b77aeb7d8f73f28b2c10fba17ec079cc (diff) |
xvmc: create hardware dependent context for video
-rw-r--r-- | src/gallium/winsys/g3dvl/radeon/radeon_vl.c | 93 | ||||
-rw-r--r-- | src/gallium/winsys/g3dvl/radeon/radeon_vl.h | 12 |
2 files changed, 86 insertions, 19 deletions
diff --git a/src/gallium/winsys/g3dvl/radeon/radeon_vl.c b/src/gallium/winsys/g3dvl/radeon/radeon_vl.c index aa75d2b5f..e6dbdd815 100644 --- a/src/gallium/winsys/g3dvl/radeon/radeon_vl.c +++ b/src/gallium/winsys/g3dvl/radeon/radeon_vl.c @@ -41,8 +41,71 @@ #include "p_video_context.h" #include "radeon_vl.h" +struct pipe_video_context * +radeon_mpeg12_context_create(struct pipe_screen *screen, + enum pipe_video_profile profile, + enum pipe_video_chroma_format chr_f, + unsigned int width, + unsigned int height) +{ + struct radeon_mpeg12_context *ctx; + ctx = CALLOC_STRUCT(radeon_mpeg12_context); + if (!ctx) + return NULL; + + ctx->base.profile = profile; + ctx->base.chroma_format = chr_f; + ctx->base.width = width; + ctx->base.height = height; + ctx->base.screen = screen; + + ctx->base.destroy = NULL; + ctx->base.decode_macroblocks = NULL; + ctx->base.clear_surface = NULL; + ctx->base.render_picture = NULL; + ctx->base.set_decode_target = NULL; + ctx->base.set_csc_matrix = NULL; + + ctx->pipe = r300_create_context(screen,(struct r300_winsys*)screen->winsys); + if (!ctx->pipe) + { + FREE(ctx); + return NULL; + } + + if (!vl_mpeg12_mc_renderer_init(&ctx->mc_renderer, ctx->pipe, + width, height, chr_f, + VL_MPEG12_MC_RENDERER_BUFFER_PICTURE, + VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE, + true)) + { + ctx->pipe->destroy(ctx->pipe); + FREE(ctx); + return NULL; + } + + if (!vl_compositor_init(&ctx->compositor, ctx->pipe)) + { + vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer); + ctx->pipe->destroy(ctx->pipe); + FREE(ctx); + return NULL; + } + + if (!init_pipe_state(ctx)) + { + vl_compositor_cleanup(&ctx->compositor); + vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer); + ctx->pipe->destroy(ctx->pipe); + FREE(ctx); + return NULL; + } + + return &ctx->base; +} + /* - * The following 4 functions are exported to xvmc. + * The following 3 functions are exported to xvmc. */ Drawable vl_video_bind_drawable(struct pipe_video_context *p_context, Drawable drawable) @@ -75,6 +138,7 @@ struct pipe_screen *vl_screen_create(Display *display, int screen) return p_screen; } + struct pipe_video_context *vl_video_create(struct pipe_screen *screen, enum pipe_video_profile profile, enum pipe_video_chroma_format chr_f, @@ -88,7 +152,15 @@ struct pipe_video_context *vl_video_create(struct pipe_screen *screen, assert(width && height); /* create radeon pipe_context */ - p_context = r300_create_context(screen, (struct r300_winsys*)screen->winsys); + switch(u_reduce_video_profile(profile)) + { + case PIPE_VIDEO_CODEC_MPEG12: + p_context = radeon_mpeg12_context_create(screen, profile, chr_f, + width, height); + default: + return NULL; + } + /* create radeon_vl_context*/ rvl_ctx = calloc(1, sizeof(struct radeon_vl_context)); rvl_ctx->screen = screen; @@ -98,20 +170,3 @@ struct pipe_video_context *vl_video_create(struct pipe_screen *screen, return p_context; } -int destroy_pipe_context(struct pipe_context *p_context) -{ - struct pipe_screen *p_screen; - struct pipe_winsys *p_winsys; - - assert(p_context); - - p_screen = p_context->screen; - p_winsys = p_context->winsys; - - free(p_context->priv); - p_context->destroy(p_context); - p_screen->destroy(p_screen); - free(p_winsys); - - return 0; -} diff --git a/src/gallium/winsys/g3dvl/radeon/radeon_vl.h b/src/gallium/winsys/g3dvl/radeon/radeon_vl.h index 9096a46f4..fe846f991 100644 --- a/src/gallium/winsys/g3dvl/radeon/radeon_vl.h +++ b/src/gallium/winsys/g3dvl/radeon/radeon_vl.h @@ -39,4 +39,16 @@ struct radeon_vl_screen struct pipe_screen base; }; +struct radeon_mpeg12_context +{ + struct pipe_video_context base; + struct pipe_context *pipe; + struct pipe_video_surface *decode_surface; + struct vl_mpeg12_mc_renderer mc_render; + struct vl_compositor compositor; + void *rast; + void *dsa; + void *blend; +}; + #endif //__RADEON_VL_H__
\ No newline at end of file |