diff options
Diffstat (limited to 'src/libXvMC/context.c')
-rw-r--r-- | src/libXvMC/context.c | 194 |
1 files changed, 86 insertions, 108 deletions
diff --git a/src/libXvMC/context.c b/src/libXvMC/context.c index 9cf654d6bb2..760e012d1a8 100644 --- a/src/libXvMC/context.c +++ b/src/libXvMC/context.c @@ -1,10 +1,23 @@ #include <assert.h> #include <X11/Xlib.h> #include <X11/extensions/XvMClib.h> +#include <pipe/p_context.h> +#include <vl_display.h> +#include <vl_screen.h> #include <vl_context.h> #include <vl_winsys.h> -static Status Validate(Display *display, XvPortID port, int surface_type_id, unsigned int width, unsigned int height, int flags, int *chroma_format) +static Status Validate +( + Display *display, + XvPortID port, + int surface_type_id, + unsigned int width, + unsigned int height, + int flags, + int *chroma_format, + int *mc_type +) { unsigned int found_port = 0; unsigned int found_surface = 0; @@ -14,13 +27,13 @@ static Status Validate(Display *display, XvPortID port, int surface_type_id, uns unsigned int max_width, max_height; Status ret; unsigned int i, j, k; - + assert(display && chroma_format); - + ret = XvQueryAdaptors(display, XDefaultRootWindow(display), &num_adaptors, &adaptor_info); if (ret != Success) return ret; - + /* Scan through all adaptors looking for this port and surface */ for (i = 0; i < num_adaptors && !found_port; ++i) { @@ -31,10 +44,10 @@ static Status Validate(Display *display, XvPortID port, int surface_type_id, uns if (adaptor_info[i].base_id + j == port) { XvMCSurfaceInfo *surface_info; - + found_port = 1; surface_info = XvMCListSurfaceTypes(display, adaptor_info[i].base_id, &num_types); - + if (surface_info) { for (k = 0; k < num_types && !found_surface; ++k) @@ -45,9 +58,10 @@ static Status Validate(Display *display, XvPortID port, int surface_type_id, uns max_width = surface_info[k].max_width; max_height = surface_info[k].max_height; *chroma_format = surface_info[k].chroma_format; + *mc_type = surface_info[k].mc_type; } } - + XFree(surface_info); } else @@ -58,9 +72,9 @@ static Status Validate(Display *display, XvPortID port, int surface_type_id, uns } } } - + XvFreeAdaptorInfo(adaptor_info); - + if (!found_port) return XvBadPort; if (!found_surface) @@ -69,60 +83,86 @@ static Status Validate(Display *display, XvPortID port, int surface_type_id, uns return BadValue; if (flags != XVMC_DIRECT && flags != 0) return BadValue; - + return Success; } -static enum VL_FORMAT FormatToVL(int xvmc_format) +static enum vlProfile ProfileToVL(int xvmc_profile) +{ + if (xvmc_profile & XVMC_MPEG_1) + assert(0); + else if (xvmc_profile & XVMC_MPEG_2) + return vlProfileMpeg2Main; + else if (xvmc_profile & XVMC_H263) + assert(0); + else if (xvmc_profile & XVMC_MPEG_4) + assert(0); + else + assert(0); + + return -1; +} + +static enum vlEntryPoint EntryToVL(int xvmc_entry) +{ + return xvmc_entry & XVMC_IDCT ? vlEntryPointIDCT : vlEntryPointMC; +} + +static enum vlFormat FormatToVL(int xvmc_format) { - enum VL_FORMAT vl_format; - switch (xvmc_format) { case XVMC_CHROMA_FORMAT_420: - { - vl_format = VL_FORMAT_YCBCR_420; - break; - } + return vlFormatYCbCr420; case XVMC_CHROMA_FORMAT_422: - { - vl_format = VL_FORMAT_YCBCR_422; - break; - } + return vlFormatYCbCr422; case XVMC_CHROMA_FORMAT_444: - { - vl_format = VL_FORMAT_YCBCR_444; - break; - } + return vlFormatYCbCr444; default: assert(0); } - - return vl_format; + + return -1; } Status XvMCCreateContext(Display *display, XvPortID port, int surface_type_id, int width, int height, int flags, XvMCContext *context) { int chroma_format; + int mc_type; Status ret; - struct VL_CONTEXT *vl_ctx; + struct vlDisplay *vl_dpy; + struct vlScreen *vl_scrn; + struct vlContext *vl_ctx; struct pipe_context *pipe; - + assert(display); - + if (!context) return XvMCBadContext; - - ret = Validate(display, port, surface_type_id, width, height, flags, &chroma_format); + + ret = Validate(display, port, surface_type_id, width, height, flags, &chroma_format, &mc_type); if (ret != Success) return ret; - + + /* XXX: Assumes default screen, should check which screen port is on */ pipe = create_pipe_context(display, XDefaultScreen(display)); - + assert(pipe); - - vlCreateContext(display, pipe, width, height, FormatToVL(chroma_format), &vl_ctx); - + + vlCreateDisplay(display, &vl_dpy); + vlCreateScreen(vl_dpy, XDefaultScreen(display), pipe->screen, &vl_scrn); + vlCreateContext + ( + vl_scrn, + pipe, + width, + height, + FormatToVL(chroma_format), + ProfileToVL(mc_type), + EntryToVL(mc_type), + &vl_ctx + ); + context->context_id = XAllocID(display); context->surface_type_id = surface_type_id; context->width = width; @@ -130,89 +170,27 @@ Status XvMCCreateContext(Display *display, XvPortID port, int surface_type_id, i context->flags = flags; context->port = port; context->privData = vl_ctx; - + return Success; } Status XvMCDestroyContext(Display *display, XvMCContext *context) { - struct VL_CONTEXT *vl_ctx; + struct vlContext *vl_ctx; struct pipe_context *pipe; - + assert(display); - + if (!context) return XvMCBadContext; - + vl_ctx = context->privData; - - assert(display == vl_ctx->display); - - pipe = vl_ctx->pipe; - vlDestroyContext(vl_ctx); - destroy_pipe_context(pipe); - - return Success; -} -/* XXX: The following are here temporarily, need to be implemented in the DDX driver */ -/* TODO: Figure out which of these need to be in DDX, which are better off in DDX, which can stay */ + assert(display == vlGetNativeDisplay(vlGetDisplay(vlContextGetScreen(vl_ctx)))); -Bool XvMCQueryExtension(Display *display, int *event_base, int *err_base) -{ - *event_base = 0; - *err_base = 0; - - return True; -} + pipe = vlGetPipeContext(vl_ctx); + vlDestroyContext(vl_ctx); + destroy_pipe_context(pipe); -Status XvMCQueryVersion(Display *display, int *major, int *minor) -{ - *major = 1; - *minor = 0; - return Success; } - -XvMCSurfaceInfo* XvMCListSurfaceTypes(Display *display, XvPortID port, int *num) -{ - XvMCSurfaceInfo *surface_info = calloc(1, sizeof(XvMCSurfaceInfo)); - - *num = 1; - - surface_info->chroma_format = XVMC_CHROMA_FORMAT_420; - surface_info->max_width = 2048; - surface_info->max_height = 2048; - surface_info->subpicture_max_width = 2048; - surface_info->subpicture_max_height = 2048; - surface_info->mc_type = XVMC_IDCT | XVMC_MPEG_2; - surface_info->surface_type_id = 123; /* FIXME: XAllocID(display)*/; - surface_info->flags = XVMC_INTRA_UNSIGNED | XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE; - - return surface_info; -} - -XvImageFormatValues* XvMCListSubpictureTypes(Display* display, XvPortID port, int surface_type_id, int *count_return) -{ - XvImageFormatValues *image_formats = calloc(1, sizeof(XvImageFormatValues)); - - *count_return = 1; - - image_formats[0].id = 123; - image_formats[0].type = XvRGB; - image_formats[0].byte_order = LSBFirst; - image_formats[0].bits_per_pixel = 8; - image_formats[0].format = XvPacked; - image_formats[0].num_planes = 1; - image_formats[0].depth = 8; - image_formats[0].red_mask = 0x0000FF; - image_formats[0].green_mask = 0x00FF00; - image_formats[0].blue_mask = 0xFF0000; - image_formats[0].component_order[0] = 'R'; - image_formats[0].component_order[0] = 'G'; - image_formats[0].component_order[0] = 'B'; - image_formats[0].scanline_order = XvTopToBottom; - - return image_formats; -} - |