198af18c5Smrg
298af18c5Smrg   X-Video Motion Compensation - API specification v. 1.0
398af18c5Smrg
498af18c5Smrg   Mark Vojkovich <markv@xfree86.org>
598af18c5Smrg
698af18c5Smrg
798af18c5Smrg/* history */
898af18c5Smrg
998af18c5Smrg   first draft (9/6/00)
1098af18c5Smrg   second draft (10/31/00) - Changed to allow acceleration at both
1198af18c5Smrg      the motion compensation and IDCT level.
1298af18c5Smrg   third draft (1/21/01) - Some refinements and subpicture support.
1398af18c5Smrg   fourth draft (5/2/01) - Dual Prime clarification, add
1498af18c5Smrg      XvMCSetAttribute.
1598af18c5Smrg   fifth draft (6/26/01) - Change definition of XvMCCompositeSubpicture
1698af18c5Smrg      plus some clarifications and fixed typographical errors.
1742941e3bSmrg   sixth draft (9/24/01) - Added XVMC_SECOND_FIELD and removed
1898af18c5Smrg      XVMC_PROGRESSIVE_FRAME and XVMC_TOP_FIELD_FIRST flags.
1998af18c5Smrg   seventh draft (10/26/01) - Added XVMC_INTRA_UNSIGNED option.
2098af18c5Smrg   eighth draft (11/13/02) - Removed IQ level acceleration and
2198af18c5Smrg      changed some structures to remove unused fields.
2298af18c5Smrg
2398af18c5Smrg/* acknowledgements */
2498af18c5Smrg
2598af18c5Smrg   Thanks to Matthew J. Sottek from Intel for lots of input.
2698af18c5Smrg
2798af18c5Smrg/********************************************************************/
2898af18c5Smrg
2998af18c5Smrg      OVERVIEW
3098af18c5Smrg
3198af18c5Smrg/********************************************************************/
3298af18c5Smrg
3398af18c5Smrg     XvMC extends the X-Video extension (Xv) and makes use of the
3440613eb2Smrg  familiar concept of the XvPort.  Ports have attributes that can be set
3598af18c5Smrg  and queried through Xv.  In XvMC ports can also have hardware motion
3642941e3bSmrg  compensation contexts created for use with them.  Ports which support
3742941e3bSmrg  XvImages (ie. they have an "XV_IMAGE" port encoding as described in
3898af18c5Smrg  the Xv version 2.2 API addendum) can be queried for the list of XvMCSurface
3942941e3bSmrg  types they support.  If they support any XvMCSurface types an
4098af18c5Smrg  XvMCContext can be created for that port.
4198af18c5Smrg
4298af18c5Smrg     An XvMCContext describes the state of the motion compensation
4398af18c5Smrg  pipeline.  An individual XvMCContext can be created for use with
4498af18c5Smrg  a single port, surface type, motion compensation type, width and
4598af18c5Smrg  height combination.  For example, a context might be created for a
4698af18c5Smrg  particular port that does MPEG-2 motion compensation on 720 x 480
4742941e3bSmrg  4:2:0 surfaces.  Once the context is created, referencing it implies
4898af18c5Smrg  the port, surface type, size and the motion compensation type.  Contexts
4998af18c5Smrg  may be "direct" or "indirect".  For indirect contexts the X server
5098af18c5Smrg  renders all video using the data passed to it by the client.  For
5198af18c5Smrg  direct contexts the client libraries render the video with little
5298af18c5Smrg  or no interaction with the X server.
5398af18c5Smrg
5498af18c5Smrg     XvMCSurfaces are buffers into which the motion compensation
5598af18c5Smrg  hardware can render.  The data in the buffers themselves are not client
5698af18c5Smrg  accessible and may be stored in a hardware-specific format.  Any
5798af18c5Smrg  number of buffers can be created for use with a particular context
5898af18c5Smrg  (resources permitting).
5998af18c5Smrg
6098af18c5Smrg     XvMC provides video acceleration starting at one of two places
6198af18c5Smrg  in the video pipeline.  Acceleration starting at the first point,
6298af18c5Smrg  which we shall call the "Motion Compensation" level, begins after the
6398af18c5Smrg  the inverse quantization and IDCT at the place where motion compensation
6442941e3bSmrg  is to be applied.  The second point, which we shall call the "IDCT"
6598af18c5Smrg  level, begins before the IDCT just after the inverse quantization.
6698af18c5Smrg
6798af18c5Smrg     Rendering is done by presenting the library with a target XvMCSurface
6842941e3bSmrg  and up to two reference XvMCSurfaces for the motion compensation, a
6998af18c5Smrg  buffer of 8x8 blocks and a command buffer which describes how to
7098af18c5Smrg  use the 8x8 blocks along with motion compensation vectors to construct
7198af18c5Smrg  the data in the target XvMCSurface.  When the pipeline starts at the
7298af18c5Smrg  IDCT level, Xv will perform the IDCT on the blocks before performing
7398af18c5Smrg  the motion compensation. A function is provided to copy/overlay a
7498af18c5Smrg  portion of the XvMCSurface to a drawable with arbitrary scaling.
7598af18c5Smrg
7698af18c5Smrg    XvMCSubpictures are separate surfaces that may be blended with the
7798af18c5Smrg  target surface.  Any number of XvMCSubpictures may be created for use
7898af18c5Smrg  with a context (resources permitting).  Both "backend" and "frontend"
7998af18c5Smrg  subpicture behavior are supported.
8098af18c5Smrg
8198af18c5Smrg/********************************************************************/
8298af18c5Smrg
8342941e3bSmrg          QUERYING THE EXTENSION
8498af18c5Smrg
8598af18c5Smrg/********************************************************************/
8698af18c5Smrg
8798af18c5Smrg/* Errors */
8898af18c5Smrg#define XvMCBadContext		0
8998af18c5Smrg#define XvMCBadSurface		1
9098af18c5Smrg#define XvMCBadSubpicture	2
9198af18c5Smrg
9298af18c5SmrgBool XvMCQueryExtension (Display *display, int *eventBase, int *errBase)
9398af18c5Smrg
9498af18c5Smrg   Returns True if the extension exists, False otherwise.  Also returns
9598af18c5Smrg the error and event bases.
9698af18c5Smrg
9798af18c5Smrg   display - The connection to the server.
9898af18c5Smrg
9998af18c5Smrg   eventBase -
10098af18c5Smrg   errBase -  The returned event and error bases.  Currently there
10198af18c5Smrg              are no events defined.
10298af18c5Smrg
10398af18c5SmrgStatus XvMCQueryVersion (Display *display, int *major, int *minor)
10498af18c5Smrg
10598af18c5Smrg   Query the major and minor version numbers of the extension.
10698af18c5Smrg
10798af18c5Smrg   display - The connection to the server.
10898af18c5Smrg
10998af18c5Smrg   major -
11098af18c5Smrg   minor -  The returned major and minor version numbers.
11198af18c5Smrg
11298af18c5Smrg/********************************************************************/
11398af18c5Smrg
11498af18c5Smrg          QUERYING SURFACE TYPES
11598af18c5Smrg
11698af18c5Smrg/********************************************************************/
11798af18c5Smrg
11898af18c5Smrg/* Chroma formats */
11998af18c5Smrg#define XVMC_CHROMA_FORMAT_420		0x00000001
12098af18c5Smrg#define XVMC_CHROMA_FORMAT_422		0x00000002
12198af18c5Smrg#define XVMC_CHROMA_FORMAT_444		0x00000003
12298af18c5Smrg
12398af18c5Smrg/* XvMCSurfaceInfo Flags */
12498af18c5Smrg#define XVMC_OVERLAID_SURFACE			0x00000001
12598af18c5Smrg#define XVMC_BACKEND_SUBPICTURE			0x00000002
12698af18c5Smrg#define XVMC_SUBPICTURE_INDEPENDENT_SCALING	0x00000004
12798af18c5Smrg#define XVMC_INTRA_UNSIGNED                     0x00000008
12898af18c5Smrg
12998af18c5Smrg/* Motion Compensation types */
13098af18c5Smrg#define XVMC_MOCOMP			0x00000000
13198af18c5Smrg#define XVMC_IDCT			0x00010000
13298af18c5Smrg
13398af18c5Smrg#define	XVMC_MPEG_1			0x00000001
13498af18c5Smrg#define XVMC_MPEG_2			0x00000002
13598af18c5Smrg#define XVMC_H263			0x00000003
13698af18c5Smrg#define XVMC_MPEG_4			0x00000004
13798af18c5Smrg
13898af18c5Smrg
13998af18c5Smrgtypedef struct {
14098af18c5Smrg   int surface_type_id;
14198af18c5Smrg   int chroma_format;
14242941e3bSmrg   unsigned short max_width;
14342941e3bSmrg   unsigned short max_height;
14498af18c5Smrg   unsigned short subpicture_max_width;
14598af18c5Smrg   unsigned short subpicture_max_height;
14642941e3bSmrg   int mc_type;
14798af18c5Smrg   int flags;
14898af18c5Smrg} XvMCSurfaceInfo;
14998af18c5Smrg
15098af18c5Smrg   surface_type_id - Unique descriptor for this surface type.
15198af18c5Smrg
15242941e3bSmrg   chroma_format - Chroma format of this surface (eg. XVMC_CHROMA_FORMAT_420,
15398af18c5Smrg		XVMC_CHROMA_FORMAT_422, XVMC_CHROMA_FORMAT_444).
15498af18c5Smrg
15598af18c5Smrg   max_width -
15698af18c5Smrg   max_height -  Maximum dimensions of the luma data in pixels.
15798af18c5Smrg
15898af18c5Smrg   subpicture_max_width -
15942941e3bSmrg   subpicture_max_height -  The Maximum dimensions of the subpicture
16098af18c5Smrg                            that can be created for use with this surface
16198af18c5Smrg                            Both fields are zero if subpictures are not
16298af18c5Smrg                            supported.
16398af18c5Smrg
16498af18c5Smrg   mc_type -  The type of motion compensation available for this
16598af18c5Smrg              surface.  This consists of XVMC_MPEG_1, XVMC_MPEG_2, XVMC_H263
16698af18c5Smrg              or XVMC_MPEG_4 OR'd together with any of the following:
16798af18c5Smrg
16898af18c5Smrg                 XVMC_MOCOMP - Acceleration starts at the motion compensation
16998af18c5Smrg                               level;
17098af18c5Smrg
17198af18c5Smrg                 XVMC_IDCT - Acceleration starts at the IDCT level.
17242941e3bSmrg
17398af18c5Smrg   flags -  Any combination of the following may be OR'd together.
17498af18c5Smrg
17598af18c5Smrg	XVMC_OVERLAID_SURFACE - Displayed data is overlaid and not
17698af18c5Smrg	                        physically in the visible framebuffer.
17798af18c5Smrg                                When this is set the client is responsible
17898af18c5Smrg                                for painting the colorkey.
17998af18c5Smrg
18042941e3bSmrg	XVMC_BACKEND_SUBPICTURE - The supicture is of the "backend"
18198af18c5Smrg                                  variety.  It is "frontend" otherwise.
18298af18c5Smrg                                  There is more information on this in the
18398af18c5Smrg                                  section on subpictures below.
18498af18c5Smrg
18598af18c5Smrg	XVMC_SUBPICTURE_INDEPENDENT_SCALING - The subpicture can be scaled
18698af18c5Smrg                                              independently of the video
18798af18c5Smrg                                              surface.  See the section on
18898af18c5Smrg                                              subpictures below.
18998af18c5Smrg
19098af18c5Smrg        XVMC_INTRA_UNSIGNED - When this flag is set, the motion compenstation
19198af18c5Smrg                              level Intra macroblock data should be in an
19298af18c5Smrg                              unsigned format rather than the signed format
19398af18c5Smrg                              present in the mpeg stream.  This flag applies
19498af18c5Smrg                              only to motion compensation level acceleration.
19598af18c5Smrg
19698af18c5SmrgXvMCSurfaceInfo * XvMCListSurfaceTypes(Display *dpy, XvPortID port, int *num)
19798af18c5Smrg
19842941e3bSmrg   Returns the number of surface types supported by the XvPort and an array
19942941e3bSmrg   of XvMCSurfaceInfo describing each surface type.  The returned array
20098af18c5Smrg   should be freed with XFree().
20198af18c5Smrg
20298af18c5Smrg   dpy -  The connection to the server.
20398af18c5Smrg
20498af18c5Smrg   port - The port we want to get the XvMCSurfaceInfo array for.
20598af18c5Smrg
20698af18c5Smrg   num  - The number of elements returned in the array.
20798af18c5Smrg
20898af18c5Smrg   Errors:
20998af18c5Smrg
21098af18c5Smrg      XvBadPort -  The requested port does not exist.
21198af18c5Smrg
21298af18c5Smrg      BadAlloc - There are insufficient resources to complete this request.
21398af18c5Smrg
21498af18c5Smrg
21598af18c5Smrg/********************************************************************/
21698af18c5Smrg
21798af18c5Smrg          CREATING A CONTEXT
21898af18c5Smrg
21998af18c5Smrg/********************************************************************/
22098af18c5Smrg
22198af18c5Smrg/* XvMCContext flags */
22298af18c5Smrg#define XVMC_DIRECT			0x00000001
22398af18c5Smrg
22498af18c5Smrgtypedef struct {
22598af18c5Smrg   XID context_id;
22698af18c5Smrg   int surface_type_id;
22798af18c5Smrg   unsigned short width;
22898af18c5Smrg   unsigned short height;
22998af18c5Smrg   XVPortID port;
23098af18c5Smrg   int flags;
23198af18c5Smrg   void * privData;  /* private to the library */
23298af18c5Smrg} XvMCContext;
23398af18c5Smrg
23498af18c5Smrg   context_id - An XID associated with the context.
23598af18c5Smrg
23698af18c5Smrg   surface_type_id - This refers to the XvMCSurfaceInfo that describes
23798af18c5Smrg                     the surface characteristics.
23842941e3bSmrg
23998af18c5Smrg   width -
24098af18c5Smrg   height -  The dimensions (of the luma data) this context supports.
24198af18c5Smrg
24298af18c5Smrg   port -  The port that this context supports.
24398af18c5Smrg
24498af18c5Smrg   flags -  Any combination may be OR'd together.
24598af18c5Smrg
24698af18c5Smrg	XVMC_DIRECT -  This context is direct rendered.
24798af18c5Smrg
24898af18c5Smrg
24998af18c5SmrgStatus XvMCCreateContext (
25098af18c5Smrg   Display display,
25198af18c5Smrg   XVPortID port,
25298af18c5Smrg   int surface_type_id,
25398af18c5Smrg   int width,
25498af18c5Smrg   int height,
25598af18c5Smrg   int flags,
25698af18c5Smrg   XvMCContext * context
25798af18c5Smrg);
25898af18c5Smrg
25942941e3bSmrg   This creates a context by filling out the XvMCContext structure passed
26098af18c5Smrg   to it and returning Success.
26198af18c5Smrg
26298af18c5Smrg   display -  Specifies the connection to the server.
26398af18c5Smrg
26498af18c5Smrg   port -  Specifies the port to create the context for.
26598af18c5Smrg
26698af18c5Smrg   surface_type_id -
26798af18c5Smrg   width -
26898af18c5Smrg   height -  Specifies the surface type and dimensions that this
26998af18c5Smrg             context will be used for.  The surface_type_id corresponds
27098af18c5Smrg             to the surface_type_id referenced by the XvMCSurfaceInfo.
27198af18c5Smrg	     The surface returned may be larger than the surface requested
27298af18c5Smrg             (usually the next larger multiple of 16x16 pixels).
27398af18c5Smrg
27498af18c5Smrg   flags -  Any of the following may by OR'd together:
27598af18c5Smrg
27698af18c5Smrg	 XVMC_DIRECT -  A direct context is requested.
27798af18c5Smrg                        If a direct context cannot be created the request
27842941e3bSmrg                        will not fail, rather, an indirect context will
27998af18c5Smrg			be created instead.
28042941e3bSmrg
28198af18c5Smrg   context - Pointer to the pre-allocated XvMCContext structure.
28242941e3bSmrg
28398af18c5Smrg
28498af18c5Smrg
28598af18c5Smrg   Errors:
28698af18c5Smrg
28798af18c5Smrg      XvBadPort -  The requested port does not exist.
28898af18c5Smrg
28998af18c5Smrg      BadValue -  The dimensions requested are not supported by the
29098af18c5Smrg                  surface type.
29198af18c5Smrg
29298af18c5Smrg      BadMatch -  The surface_type_id is not supported by the port.
29398af18c5Smrg
29498af18c5Smrg      BadAlloc -  There are not sufficient resources to fulfill this
29598af18c5Smrg                  request.
29698af18c5Smrg
29798af18c5Smrg
29898af18c5SmrgStatus XvMCDestroyContext (Display display, XvMCContext * context)
29998af18c5Smrg
30042941e3bSmrg     Destroys the specified context.
30198af18c5Smrg
30298af18c5Smrg      display - Specifies the connection to the server.
30398af18c5Smrg
30498af18c5Smrg      context - The context to be destroyed.
30598af18c5Smrg
30642941e3bSmrg     Errors:
30798af18c5Smrg
30898af18c5Smrg       XvMCBadContext - The XvMCContext is not valid.
30998af18c5Smrg
31098af18c5Smrg
31198af18c5Smrg/*********************************************************************/
31298af18c5Smrg
31398af18c5Smrg          SURFACE CREATION
31498af18c5Smrg
31598af18c5Smrg/*********************************************************************/
31698af18c5Smrg
31798af18c5Smrgtypedef struct {
31842941e3bSmrg  XID surface_id;
31998af18c5Smrg  XID context_id;
32098af18c5Smrg  int surface_type_id;
32198af18c5Smrg  unsigned short width;
32298af18c5Smrg  unsigned short height;
32398af18c5Smrg  void *privData;  /* private to the library */
32498af18c5Smrg} XvMCSurface;
32598af18c5Smrg
32698af18c5Smrg  surface_id -  An XID associated with the surface.
32798af18c5Smrg
32898af18c5Smrg  context_id -  The XID of the context for which the surface was created.
32998af18c5Smrg
33098af18c5Smrg  surface_type_id - Derived from the context_id, it specifies the
33198af18c5Smrg                    XvMCSurfaceInfo describing the surface.
33298af18c5Smrg
33398af18c5Smrg  width -
33498af18c5Smrg  height -  The width and height of the luma data.
33598af18c5Smrg
33698af18c5Smrg
33742941e3bSmrgStatus
33898af18c5SmrgXvMCCreateSurface(
33998af18c5Smrg  Display *display,
34098af18c5Smrg  XvMCContext * context;
34198af18c5Smrg  XvMCSurface * surface;
34298af18c5Smrg);
34398af18c5Smrg
34442941e3bSmrg     Creates a surface (Frame) for use with the specified context.
34598af18c5Smrg   The surface structure is filled out and Success is returned if no
34640613eb2Smrg   error occurred.
34798af18c5Smrg
34898af18c5Smrg   context - pointer to a valid context.  The context implies
34998af18c5Smrg             the surface type to be created, and its dimensions.
35098af18c5Smrg
35198af18c5Smrg   surface - pointer to a pre-allocated XvMCSurface structure.
35298af18c5Smrg
35398af18c5Smrg   Errors:
35498af18c5Smrg
35598af18c5Smrg	XvMCBadContext - the context is not valid.
35698af18c5Smrg
35742941e3bSmrg        BadAlloc - there are insufficient resources to complete
35898af18c5Smrg                   this operation.
35998af18c5Smrg
36098af18c5SmrgStatus XvMCDestroySurface(Display *display, XvMCSurface *surface);
36198af18c5Smrg
36298af18c5Smrg   Destroys the given surface.
36398af18c5Smrg
36498af18c5Smrg    display - Specifies the connection to the server.
36598af18c5Smrg
36698af18c5Smrg    surface - The surface to be destroyed.
36798af18c5Smrg
36898af18c5Smrg    Errors:
36998af18c5Smrg
37098af18c5Smrg       XvMCBadSurface - The XvMCSurface is not valid.
37198af18c5Smrg
37298af18c5Smrg
37398af18c5Smrg
37498af18c5Smrg/*********************************************************************/
37598af18c5Smrg
37698af18c5Smrg    RENDERING A FRAME
37798af18c5Smrg
37898af18c5Smrg/*********************************************************************/
37998af18c5Smrg
38098af18c5Smrgtypedef struct {
38198af18c5Smrg  XID context_id;
38298af18c5Smrg  unsigned int num_blocks;
38398af18c5Smrg  short *blocks;
38498af18c5Smrg  void *privData;	/* private to the library */
38598af18c5Smrg} XvMCBlockArray;
38698af18c5Smrg
38798af18c5Smrg   num_blocks - Number of 64 element blocks in the blocks array.
38898af18c5Smrg
38998af18c5Smrg   context_id - XID of the context these blocks were allocated for.
39098af18c5Smrg
39198af18c5Smrg   blocks -  Pointer to an array of (64 * num_blocks) shorts.
39298af18c5Smrg
39398af18c5SmrgStatus XvMCCreateBlocks (
39442941e3bSmrg    Display *display,
39598af18c5Smrg    XvMCContext *context,
39698af18c5Smrg    unsigned int num_blocks,
39798af18c5Smrg    XvMCBlockArray * block
39898af18c5Smrg);
39998af18c5Smrg
40098af18c5Smrg   This allocates an array of DCT blocks in the XvMCBlockArray
40140613eb2Smrg   structure passed to it.  Success is returned if no error occurred.
40298af18c5Smrg
40398af18c5Smrg    display - The connection to the server.
40498af18c5Smrg
40598af18c5Smrg    context -  The context the block array is being created for.
40698af18c5Smrg
40798af18c5Smrg    num_blocks - The number of 64 element short blocks to be allocated.
40898af18c5Smrg                 This number must be non-zero.
40998af18c5Smrg
41098af18c5Smrg    block -  A pointer to a pre-allocated XvMCBlockArray structure.
41142941e3bSmrg
41242941e3bSmrg      Errors:
41398af18c5Smrg
41498af18c5Smrg	  XvMCBadContext - the context is invalid.
41598af18c5Smrg
41642941e3bSmrg          BadAlloc -  There are insufficient resources to complete the
41798af18c5Smrg                      operation.
41898af18c5Smrg
41998af18c5Smrg          BadValue -  num_blocks was zero.
42098af18c5Smrg
42198af18c5SmrgStatus XvMCDestroyBlocks (Display *display, XvMCBlockArray * block)
42298af18c5Smrg
42398af18c5Smrg   Frees the given array.
42498af18c5Smrg
42598af18c5Smrg     display -  The connection to the server.
42698af18c5Smrg
42798af18c5Smrg     block - The block array to be freed.
42898af18c5Smrg
42998af18c5Smrg
43098af18c5Smrg   ----------------------------------------------------------
43198af18c5Smrg
43298af18c5Smrg#define XVMC_MB_TYPE_MOTION_FORWARD	0x02
43398af18c5Smrg#define XVMC_MB_TYPE_MOTION_BACKWARD	0x04
43498af18c5Smrg#define XVMC_MB_TYPE_PATTERN		0x08
43598af18c5Smrg#define XVMC_MB_TYPE_INTRA		0x10
43698af18c5Smrg
43798af18c5Smrg#define XVMC_PREDICTION_FIELD		0x01
43898af18c5Smrg#define XVMC_PREDICTION_FRAME		0x02
43998af18c5Smrg#define XVMC_PREDICTION_DUAL_PRIME	0x03
44042941e3bSmrg#define XVMC_PREDICTION_16x8		0x02
44198af18c5Smrg#define XVMC_PREDICTION_4MV		0x04
44298af18c5Smrg
44398af18c5Smrg#define XVMC_SELECT_FIRST_FORWARD	0x01
44498af18c5Smrg#define XVMC_SELECT_FIRST_BACKWARD	0x02
44598af18c5Smrg#define XVMC_SELECT_SECOND_FORWARD	0x04
44698af18c5Smrg#define XVMC_SELECT_SECOND_BACKWARD	0x08
44798af18c5Smrg
44898af18c5Smrg#define XVMC_DCT_TYPE_FRAME		0x00
44998af18c5Smrg#define XVMC_DCT_TYPE_FIELD		0x01
45098af18c5Smrg
45198af18c5Smrgtypedef struct {
45298af18c5Smrg   unsigned short x;
45398af18c5Smrg   unsigned short y;
45498af18c5Smrg   unsigned char macroblock_type;
45542941e3bSmrg   unsigned char motion_type;
45698af18c5Smrg   unsigned char motion_vertical_field_select;
45798af18c5Smrg   unsigned char dct_type;
45898af18c5Smrg   short PMV[2][2][2];
45998af18c5Smrg   unsigned int index;
46098af18c5Smrg   unsigned short coded_block_pattern;
46198af18c5Smrg   unsigned short pad0;
46298af18c5Smrg} XvMCMacroBlock;
46398af18c5Smrg
46498af18c5Smrg    x, y -  location of the macroblock on the surface in units of macroblocks.
46598af18c5Smrg
46698af18c5Smrg    macroblock_type - can be any of the following flags OR'd together:
46798af18c5Smrg
46898af18c5Smrg	XVMC_MB_TYPE_MOTION_FORWARD - Forward motion prediction should
46998af18c5Smrg                                      be done.  This flag is ignored for
47098af18c5Smrg				      Intra frames.
47198af18c5Smrg
47298af18c5Smrg	XVMC_MB_TYPE_MOTION_BACKWARD - Backward motion prediction should
47398af18c5Smrg                                       be done.  This flag is ignored when
47498af18c5Smrg				       the frame is not bidirectionally
47598af18c5Smrg                                       predicted.
47698af18c5Smrg
47742941e3bSmrg        XVMC_MB_TYPE_PATTERN -  Blocks are referenced and they contain
47898af18c5Smrg                                differentials.  The coded_block_pattern will
47998af18c5Smrg                                indicate the number of blocks and index will
48098af18c5Smrg                                note their locations in the block array.
48198af18c5Smrg
48242941e3bSmrg	XVMC_MB_TYPE_INTRA -  Blocks are referenced and they are intra blocks.
48398af18c5Smrg                              The coded_block_pattern will indicate the number
48442941e3bSmrg                              of blocks and index will note their locations in
48598af18c5Smrg                              the block array.  XVMC_MB_TYPE_PATTERN and
48698af18c5Smrg                              XVMC_MB_TYPE_INTRA are mutually exclusive.  If
48798af18c5Smrg                              both are specified, XVMC_MB_TYPE_INTRA takes
48898af18c5Smrg                              precedence.
48998af18c5Smrg
49098af18c5Smrg    motion_type -  If the surface is a field, the following are valid:
49198af18c5Smrg			XVMC_PREDICTION_FIELD
49298af18c5Smrg			XVMC_PREDICTION_16x8
49398af18c5Smrg			XVMC_PREDICTION_DUAL_PRIME
49498af18c5Smrg		   If the surface is a frame, the following are valid:
49598af18c5Smrg			XVMC_PREDICTION_FIELD
49698af18c5Smrg			XVMC_PREDICTION_FRAME
49798af18c5Smrg			XVMC_PREDICTION_DUAL_PRIME
49898af18c5Smrg
49998af18c5Smrg    motion_vertical_field_select - The following flags may be OR'd together
50098af18c5Smrg
50198af18c5Smrg		XVMC_SELECT_FIRST_FORWARD
50298af18c5Smrg		XVMC_SELECT_FIRST_BACKWARD
50398af18c5Smrg		XVMC_SELECT_SECOND_FORWARD
50498af18c5Smrg		XVMC_SELECT_SECOND_BACKWARD
50542941e3bSmrg
50698af18c5Smrg              If the bit is set the bottom field is indicated.
50798af18c5Smrg              If the bit is clear the top field is indicated.
50898af18c5Smrg
50998af18c5Smrg              X X X X D C B A
51098af18c5Smrg              ------- | | | |_  First vector forward
51198af18c5Smrg                |     | | |___  First vector backward
51298af18c5Smrg              unused  | |_____ Second vector forward
51398af18c5Smrg                      |_______ Second vector backward
51498af18c5Smrg
51598af18c5Smrg    PMV -  The motion vector(s)
51642941e3bSmrg
51798af18c5Smrg               PMV[c][b][a]
51898af18c5Smrg
51998af18c5Smrg                  a - This holds the vector. 0 = horizontal, 1 = vertical.
52098af18c5Smrg                  b - 0 = forward, 1 = backward.
52198af18c5Smrg                  c - 0 = first vector, 1 = second vector.
52298af18c5Smrg
52398af18c5Smrg	    The motion vectors are used only when XVMC_MB_TYPE_MOTION_FORWARD
52498af18c5Smrg            or XVMC_MB_TYPE_MOTION_BACKWARD are set.
52598af18c5Smrg
52698af18c5Smrg            DualPrime vectors must be fully decoded and placed in the PMV
52742941e3bSmrg            array as follows.
52898af18c5Smrg
52998af18c5Smrg            Field structure:
53098af18c5Smrg
53198af18c5Smrg                PMV[0][0][1:0]  from same parity
53298af18c5Smrg                PMV[0][1][1:0]  from opposite parity
53398af18c5Smrg
53498af18c5Smrg            Frame structure:
53542941e3bSmrg
53698af18c5Smrg                PMV[0][0][1:0]  top from top
53798af18c5Smrg                PMV[0][1][1:0]  bottom from bottom
53898af18c5Smrg                PMV[1][0][1:0]  top from bottom
53998af18c5Smrg                PMV[1][1][1:0]  bottom from top
54098af18c5Smrg
54198af18c5Smrg
54298af18c5Smrg    index -  The offset in units of (64 * sizeof(short)) from the start of
54398af18c5Smrg             the block array where this macroblock's DCT blocks, as indicated
54498af18c5Smrg             by the coded_block_pattern, are stored.
54598af18c5Smrg
54698af18c5Smrg    coded_block_pattern - Indicates the blocks to be updated.  The bitplanes
54798af18c5Smrg                          are specific to the mc_type of the surface.  This
54842941e3bSmrg                          field is valid only if XVMC_MB_TYPE_PATTERN or
54998af18c5Smrg                          XVMC_MB_TYPE_INTRA are set.  In that case the blocks
55098af18c5Smrg                          are differential or intra blocks respectively.
55198af18c5Smrg			  The bitplanes are described in ISO/IEC 13818-2
55298af18c5Smrg			  Figures 6.10-12.
55398af18c5Smrg
55498af18c5Smrg    dct_type -  This field indicates whether frame pictures are frame DCT
55598af18c5Smrg                coded or field DCT coded. ie XVMC_DCT_TYPE_FIELD or
55698af18c5Smrg                XVMC_DCT_TYPE_FRAME.
55798af18c5Smrg
55898af18c5Smrg
55998af18c5Smrgtypedef struct {
56098af18c5Smrg  unsigned int num_blocks;
56198af18c5Smrg  XID context_id;
56298af18c5Smrg  XvMCMacroBlock *macro_blocks;
56398af18c5Smrg  void *privData;	/* private to the library */
56498af18c5Smrg} XvMCMacroBlockArray;
56598af18c5Smrg
56698af18c5Smrg
56798af18c5Smrg   num_blocks - Number of XvMCMacroBlocks in the macro_blocks array.
56898af18c5Smrg
56998af18c5Smrg   context_id - XID of the context these macroblocks were allocated for.
57098af18c5Smrg
57198af18c5Smrg   macro_blocks -  Pointer to an array of num_blocks XvMCMacroBlocks.
57298af18c5Smrg
57398af18c5Smrg
57498af18c5SmrgStatus XvMCCreateMacroBlocks (
57542941e3bSmrg    Display *display,
57698af18c5Smrg    XvMCContext *context,
57798af18c5Smrg    unsigned int num_blocks,
57898af18c5Smrg    XvMCMacroBlockArray * blocks
57998af18c5Smrg);
58098af18c5Smrg
58198af18c5Smrg   This allocates an array of XvMCMacroBlocks in the XvMCMacroBlockArray
58240613eb2Smrg   structure passed to it.  Success is returned if no error occurred.
58398af18c5Smrg
58498af18c5Smrg    display - The connection to the server.
58598af18c5Smrg
58698af18c5Smrg    context -  The context the macroblock array is being created for.
58798af18c5Smrg
58898af18c5Smrg    num_blocks - The number of XvMCMacroBlocks to be allocated.
58998af18c5Smrg                 This number must be non-zero.
59098af18c5Smrg
59198af18c5Smrg    blocks -  A pointer to a pre-allocated XvMCMacroBlockArray structure.
59242941e3bSmrg
59342941e3bSmrg      Errors:
59498af18c5Smrg
59598af18c5Smrg	  XvMCBadContext - the context is invalid.
59698af18c5Smrg
59742941e3bSmrg          BadAlloc -  There are insufficient resources to complete the
59898af18c5Smrg                      operation.
59998af18c5Smrg
60098af18c5Smrg          BadValue -  num_blocks was zero.
60198af18c5Smrg
60298af18c5SmrgStatus XvMCDestroyMacroBlocks (Display *display, XvMCMacroBlockArray * block)
60398af18c5Smrg
60498af18c5Smrg   Frees the given array.
60598af18c5Smrg
60698af18c5Smrg    display - The connection to the server.
60798af18c5Smrg
60898af18c5Smrg    block -  The macro block array to be freed.
60998af18c5Smrg
61042941e3bSmrg
61198af18c5Smrg    ------------------------------------------------------------
61298af18c5Smrg
61398af18c5Smrg#define XVMC_TOP_FIELD		0x00000001
61498af18c5Smrg#define XVMC_BOTTOM_FIELD	0x00000002
61598af18c5Smrg#define XVMC_FRAME_PICTURE	(XVMC_TOP_FIELD | XVMC_BOTTOM_FIELD)
61698af18c5Smrg
61798af18c5Smrg#define XVMC_SECOND_FIELD       0x00000004
61898af18c5Smrg
61998af18c5SmrgStatus XvMCRenderSurface(
62098af18c5Smrg    Display *display,
62198af18c5Smrg    XvMCContext *context,
62298af18c5Smrg    unsigned int picture_structure,
62398af18c5Smrg    Surface *target_surface,
62498af18c5Smrg    Surface *past_surface,
62598af18c5Smrg    Surface *future_surface,
62698af18c5Smrg    unsigned int flags,
62798af18c5Smrg    unsigned int num_macroblocks,
62898af18c5Smrg    unsigned int first_macroblock,
62998af18c5Smrg    XvMCMacroBlockArray *macroblock_array,
63098af18c5Smrg    XvMCBlockArray *blocks
63198af18c5Smrg);
63298af18c5Smrg
63398af18c5Smrg    This function renders the macroblocks passed to it.  It will not
63442941e3bSmrg    return until it has read all of the macroblocks, however, rendering
63598af18c5Smrg    will usually not be completed by that time.  The return of this
63698af18c5Smrg    function means it is safe to touch the blocks and macroblock_array.
63740613eb2Smrg    To synchronize rendering see the section on synchronization below.
63898af18c5Smrg
63998af18c5Smrg    display - The connection to the server.
64098af18c5Smrg
64198af18c5Smrg    context - The context used to render.
64298af18c5Smrg
64398af18c5Smrg    target_surface -
64498af18c5Smrg    past_surface -
64598af18c5Smrg    furture_surface -
64698af18c5Smrg
64742941e3bSmrg        The target_surface is required.  If the future and past
64898af18c5Smrg      surfaces are NULL, the target_surface is an "Intra" frame.
64998af18c5Smrg
65098af18c5Smrg      	If the past surface is provided but not the future surface,
65198af18c5Smrg      the target_surface is a "Predicted Inter" frame.
65298af18c5Smrg
65398af18c5Smrg	If both past and future surfaces are provided, the
65498af18c5Smrg      target_surface is a "Bidirectionally-predicted Inter" frame.
65598af18c5Smrg
65698af18c5Smrg        Specifying a future surface without a past surface results
65798af18c5Smrg      in a BadMatch.
65898af18c5Smrg
65998af18c5Smrg      All surfaces must belong to the same context.
66098af18c5Smrg
66198af18c5Smrg    picture_structure - XVMC_TOP_FIELD, XVMC_BOTTOM_FIELD or
66298af18c5Smrg                        XVMC_FRAME_PICTURE.
66398af18c5Smrg
66498af18c5Smrg
66598af18c5Smrg    flags -  Flags may include:
66698af18c5Smrg
66798af18c5Smrg            XVMC_SECOND_FIELD - For field pictures this indicates whether
66842941e3bSmrg                                the current field (top or bottom) is first
66998af18c5Smrg                                or second in the sequence.
67098af18c5Smrg
67198af18c5Smrg    num_macroblocks -  The number of XvMCMacroBlock structures to execute in
67298af18c5Smrg                       the macroblock_array.
67398af18c5Smrg
67498af18c5Smrg    first_macroblock - The index of the first XvMCMacroBlock to process in the
67598af18c5Smrg                       macroblock_array.
67698af18c5Smrg
67798af18c5Smrg    blocks - The array of XvMCBlocks to be referenced by the XvMCMacroBlocks.
67898af18c5Smrg             The data in the individual blocks are in raster scan order and
67998af18c5Smrg             should be clamped to the limits specific to the acceleration
68098af18c5Smrg             level.  For motion compensation level acceleration this is 8
68198af18c5Smrg             bits for Intra and 9 bits for non-Intra data.  At the IDCT level
68298af18c5Smrg             this is 12 bits.
68398af18c5Smrg
68498af18c5Smrg  Errors:
68598af18c5Smrg
68698af18c5Smrg        XvMCBadContext - The context is not valid.
68742941e3bSmrg
68842941e3bSmrg        XvMCBadSurface - Any of the surfaces are not valid.
68998af18c5Smrg
69098af18c5Smrg	BadMatch - Any of the surfaces do not belong to the specified
69198af18c5Smrg                   context or a future surface was specified without
69298af18c5Smrg                   a past surface.
69398af18c5Smrg
69498af18c5Smrg        BadValue - Unrecognized data for the picture_structure.
69598af18c5Smrg
69698af18c5Smrg
69798af18c5Smrg/***********************************************************************/
69898af18c5Smrg
69998af18c5Smrg     DISPLAYING THE SURFACE
70098af18c5Smrg
70198af18c5Smrg/***********************************************************************/
70298af18c5Smrg
70398af18c5Smrg
70498af18c5SmrgStatus
70598af18c5SmrgXvMCPutSurface(
70698af18c5Smrg  Display *display,
70798af18c5Smrg  XvMCSurface *surface,
70898af18c5Smrg  Drawable draw,
70942941e3bSmrg  short srcx,
71042941e3bSmrg  short srcy,
71142941e3bSmrg  unsigned short srcw,
71298af18c5Smrg  unsigned short srch,
71398af18c5Smrg  short destx,
71498af18c5Smrg  short desty,
71598af18c5Smrg  unsigned short destw,
71698af18c5Smrg  unsigned short desth,
71798af18c5Smrg  int flags
71898af18c5Smrg);
71998af18c5Smrg
72098af18c5Smrg   Display the rectangle from the source defined by srcx/y/w/h scaled
72198af18c5Smrg to destw by desth and placed at (destx, desty) on the given drawable.
72242941e3bSmrg This function is not guaranteed to be pipelined with previous rendering
72398af18c5Smrg commands and may display the surface immediately.  Therefore, the client
72498af18c5Smrg must query that the surface has finished rendering before calling this
72598af18c5Smrg function.
72698af18c5Smrg
72798af18c5Smrg    display - The connection to the server.
72898af18c5Smrg
72998af18c5Smrg    surface - The surface to copy/overlay from.
73098af18c5Smrg
73142941e3bSmrg    draw - The drawable to copy/overlay the video on.
73298af18c5Smrg
73398af18c5Smrg    srcx -
73498af18c5Smrg    srcy -
73598af18c5Smrg    srcw -
73698af18c5Smrg    srch -  The rectangle in the source area from the surface that is
73798af18c5Smrg            to be displayed.
73898af18c5Smrg
73998af18c5Smrg    destx -
74098af18c5Smrg    desty -
74198af18c5Smrg    destw -
74242941e3bSmrg    desth -  The rectangle in the destination drawable where the scaled
74342941e3bSmrg             source rectangle should be displayed.
74498af18c5Smrg
74598af18c5Smrg    flags - this indicates the field to be displayed and can be XVMC_TOP_FIELD,
74698af18c5Smrg            XVMC_BOTTOM_FIELD or XVMC_FRAME_PICTURE.  XVMC_FRAME_PICTURE
74798af18c5Smrg            displays both fields (weave).
74898af18c5Smrg
74998af18c5Smrg   Errors:
75098af18c5Smrg
75198af18c5Smrg       XvMCBadSurface - The surface is not valid.
75298af18c5Smrg
75398af18c5Smrg       BadDrawable -  The drawable does not exist.
75498af18c5Smrg
75598af18c5Smrg
75698af18c5SmrgStatus XvMCHideSurface(Display *display, XvMCSurface *surface)
75798af18c5Smrg
75898af18c5Smrg   Stops display of a surface.  This is only needed if the surface is an
75998af18c5Smrg   overlaid surface as indicated in the XvMCSurfaceInfo - it is a no-op
76042941e3bSmrg   otherwise.
76198af18c5Smrg
76298af18c5Smrg     display - The connection to the server.
76342941e3bSmrg
76498af18c5Smrg     surface - The surface to be hidden.
76542941e3bSmrg
76698af18c5Smrg      Errors:
76742941e3bSmrg
76898af18c5Smrg	  XvMCBadSurface - The surface is not valid.
76998af18c5Smrg
77098af18c5Smrg
77198af18c5Smrg/***********************************************************************/
77298af18c5Smrg
77398af18c5Smrg     COMPOSITING THE SUBPICTURE
77498af18c5Smrg
77598af18c5Smrg/***********************************************************************/
77698af18c5Smrg
77798af18c5Smrg
77898af18c5SmrgXvImageFormatValues * XvMCListSubpictureTypes (
77998af18c5Smrg  Display * display,
78098af18c5Smrg  XvPortID port,
78198af18c5Smrg  int surface_type_id,
78298af18c5Smrg  int *count_return
78398af18c5Smrg)
78498af18c5Smrg
78598af18c5Smrg  Returns an array of XvImageFormatValues supported by the surface_type_id
78698af18c5Smrg  describing the surface. The surface_type_id is acquired from the
78798af18c5Smrg  XvMCSurfaceInfo.  This list should be freed with XFree().
78898af18c5Smrg
78998af18c5Smrg   display - Specifies the connection to the X-server.
79098af18c5Smrg
79198af18c5Smrg   port - Specifies the port we are interested in.
79242941e3bSmrg
79342941e3bSmrg   surface_type_id - Specifies the surface type for which we want to
79442941e3bSmrg                     query the supported subpicture types.
79542941e3bSmrg
79698af18c5Smrg   count_return - the size of the returned array.
79798af18c5Smrg
79898af18c5Smrg   Errors:
79998af18c5Smrg
80098af18c5Smrg      BadPort -  The port doesn't exist.
80142941e3bSmrg
80298af18c5Smrg      BadAlloc - There are insufficient resources to complete this request.
80342941e3bSmrg
80442941e3bSmrg      BadMatch - The surface type is not supported on that port.
80542941e3bSmrg
80698af18c5Smrg
80798af18c5Smrgtypedef struct {
80898af18c5Smrg  XID subpicture_id;
80998af18c5Smrg  XID context_id;
81098af18c5Smrg  int xvimage_id;
81198af18c5Smrg  unsigned short width;
81298af18c5Smrg  unsigned short height;
81398af18c5Smrg  int num_palette_entries;
81498af18c5Smrg  int entry_bytes;
81598af18c5Smrg  char component_order[4];
81698af18c5Smrg  void *privData;    /* private to the library */
81798af18c5Smrg} XvMCSubpicture;
81898af18c5Smrg
81942941e3bSmrg
82098af18c5Smrg   subpicture_id - An XID associated with this subpicture.
82198af18c5Smrg
82298af18c5Smrg   context_id - The XID of the context this subpicture was created for.
82398af18c5Smrg
82498af18c5Smrg   xvimage_id - The id descriptor of the XvImage format that may be used
82598af18c5Smrg                with this subpicture.
82698af18c5Smrg
82798af18c5Smrg   width -
82898af18c5Smrg   height - The dimensions of the subpicture.
82998af18c5Smrg
83098af18c5Smrg   num_palette_entries - For paletted formats only.  This is the number
83198af18c5Smrg                         of palette entries.  It is zero for XvImages
83298af18c5Smrg                         without palettes.
83342941e3bSmrg
83498af18c5Smrg   entry_bytes -  Each component is one byte and entry_bytes indicates
83598af18c5Smrg                  the number of components in each entry (eg. 3 for
83642941e3bSmrg                  YUV palette entries).  This field is zero when
83742941e3bSmrg                  palettes are not used.
83898af18c5Smrg
83998af18c5Smrg   component_order - Is an array of ascii characters describing the order
84098af18c5Smrg                     of the components within the bytes.  Only entry_bytes
84142941e3bSmrg                     characters of the string are used.
84298af18c5Smrg
84398af18c5SmrgStatus
84498af18c5SmrgXvMCCreateSubpicture (
84542941e3bSmrg   Display *display,
84698af18c5Smrg   XvMCContext *context,
84742941e3bSmrg   XvMCSubpicture *subpicture,
84898af18c5Smrg   unsigned short width,
84998af18c5Smrg   unsigned short height,
85098af18c5Smrg   int xvimage_id
85198af18c5Smrg)
85298af18c5Smrg
85398af18c5Smrg   This creates a subpicture by filling out the XvMCSubpicture structure
85498af18c5Smrg   passed to it and returning Success.
85598af18c5Smrg
85698af18c5Smrg    display -  Specifies the connection to the X-Server.
85742941e3bSmrg
85898af18c5Smrg    context -  The context to create the subpicture for.
85998af18c5Smrg
86042941e3bSmrg    subpicture - Pre-allocated XvMCSubpicture structure to be filled
86198af18c5Smrg                 out by this function.
86298af18c5Smrg
86398af18c5Smrg    width -
86498af18c5Smrg    height -  The dimensions of the subpicture.
86542941e3bSmrg
86698af18c5Smrg    xvimage_id - The id describing the XvImage format.
86798af18c5Smrg
86898af18c5Smrg
86998af18c5Smrg    Errors:
87098af18c5Smrg
87198af18c5Smrg      BadAlloc - There are insufficient resources to complete this request.
87298af18c5Smrg
87398af18c5Smrg      XvMCBadContext - The specified context does not exist.
87498af18c5Smrg
87598af18c5Smrg      BadMatch - The XvImage format id specified is not supported by
87642941e3bSmrg                 the context.
87798af18c5Smrg
87898af18c5Smrg      BadValue - If the size requested is larger than the max size reported
87998af18c5Smrg                 in the XvMCSurfaceInfo.
88098af18c5Smrg
88198af18c5Smrg
88298af18c5SmrgStatus
88398af18c5SmrgXvMCClearSubpicture (
88498af18c5Smrg  Display *display,
88598af18c5Smrg  XvMCSubpicture *subpicture,
88698af18c5Smrg  short x,
88798af18c5Smrg  short y,
88898af18c5Smrg  unsigned short width,
88998af18c5Smrg  unsigned short height,
89098af18c5Smrg  unsigned int color
89198af18c5Smrg)
89298af18c5Smrg
89398af18c5Smrg    Clear the area of the given subpicture to "color".
89498af18c5Smrg
89598af18c5Smrg    display - The connection to the server.
89698af18c5Smrg
89798af18c5Smrg    subpicture - The subpicture to clear.
89898af18c5Smrg
89998af18c5Smrg    x -
90098af18c5Smrg    y -
90198af18c5Smrg    width -
90298af18c5Smrg    height -  The rectangle in the subpicture to be cleared.
90398af18c5Smrg
90442941e3bSmrg    color -  The data to fill the rectangle with.
90598af18c5Smrg
90698af18c5Smrg    Errors:
90798af18c5Smrg
90898af18c5Smrg       XvMCBadSubpicture - The subpicture is invalid.
90998af18c5Smrg
91098af18c5SmrgStatus
91198af18c5SmrgXvMCCompositeSubpicture (
91298af18c5Smrg   Display *display,
91398af18c5Smrg   XvMCSubpicture *subpicture,
91498af18c5Smrg   XvImage *image,
91598af18c5Smrg   short srcx,
91698af18c5Smrg   short srcy,
91798af18c5Smrg   unsigned short width,
91898af18c5Smrg   unsigned short height,
91998af18c5Smrg   short dstx,
92098af18c5Smrg   short dsty
92198af18c5Smrg)
92298af18c5Smrg
92342941e3bSmrg    Copies the XvImage to the XvMCSubpicture.
92498af18c5Smrg
92598af18c5Smrg    display -  The connection to the server.
92698af18c5Smrg
92742941e3bSmrg    subpicture -  The subpicture used as the destination of the copy.
92898af18c5Smrg
92942941e3bSmrg    image -  The XvImage to be used as the source of the copy.
93042941e3bSmrg             XvImages should be of the shared memory variety for
93198af18c5Smrg             indirect contexts.
93298af18c5Smrg
93398af18c5Smrg    srcx -
93498af18c5Smrg    srcy -
93598af18c5Smrg    width -
93698af18c5Smrg    height -  The rectangle from the image to be composited.
93798af18c5Smrg
93898af18c5Smrg    dstx -
93998af18c5Smrg    dsty -  The location in the subpicture where the source rectangle
94042941e3bSmrg            should be composited.
94198af18c5Smrg
94298af18c5Smrg    Errors:
94398af18c5Smrg
94498af18c5Smrg       XvMCBadSubpicture - The subpicture is invalid.
94598af18c5Smrg
94698af18c5Smrg       BadMatch -  The subpicture does not support the type of XvImage
94798af18c5Smrg                   passed to this function.
94898af18c5Smrg
94998af18c5SmrgStatus
95098af18c5SmrgXvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture)
95198af18c5Smrg
95298af18c5Smrg   Destroys the specified subpicture.
95398af18c5Smrg
95498af18c5Smrg   display - Specifies the connection to the X-server.
95598af18c5Smrg
95698af18c5Smrg   subpicture - The subpicture to be destroyed.
95798af18c5Smrg
95898af18c5Smrg   Errors:
95942941e3bSmrg
96098af18c5Smrg      XvMCBadSubpicture -  The subpicture specified does not exist.
96198af18c5Smrg
96298af18c5Smrg
96398af18c5SmrgStatus
96498af18c5SmrgXvMCSetSubpicturePalette (
96542941e3bSmrg  Display *display,
96642941e3bSmrg  XvMCSubpicture *subpicture,
96798af18c5Smrg  unsigned char *palette
96898af18c5Smrg)
96998af18c5Smrg
97098af18c5Smrg   Set the subpicture's palette.  This applies to paletted subpictures
97142941e3bSmrg   only.
97298af18c5Smrg
97398af18c5Smrg    display -  The connection to the server.
97498af18c5Smrg
97598af18c5Smrg    subpicture - The subpicture on which to change the palette.
97698af18c5Smrg
97798af18c5Smrg    palette -  A pointer to an array holding the palette data.  The
97842941e3bSmrg               size of this array is
97998af18c5Smrg
98098af18c5Smrg                   num_palette_entries * entry_bytes
98198af18c5Smrg
98298af18c5Smrg               in size.  The order of the components in the palette
98398af18c5Smrg	       is described by the component_order in the XvMCSubpicture
98442941e3bSmrg               structure.
98598af18c5Smrg
98698af18c5Smrg    Errors:
98798af18c5Smrg
98898af18c5Smrg      XvMCBadSubpicture -  The subpicture specified does not exist.
98942941e3bSmrg
99098af18c5Smrg      BadMatch -  The specified subpicture does not use palettes.
99198af18c5Smrg
99298af18c5Smrg
99398af18c5SmrgStatus
99498af18c5SmrgXvMCBlendSubpicture (
99598af18c5Smrg   Display *display,
99698af18c5Smrg   XvMCSurface *target_surface,
99798af18c5Smrg   XvMCSubpicture *subpicture,
99898af18c5Smrg   short subx,
99998af18c5Smrg   short suby,
100098af18c5Smrg   unsigned short subw,
100198af18c5Smrg   unsigned short subh,
100298af18c5Smrg   short surfx,
100398af18c5Smrg   short surfy,
100498af18c5Smrg   unsigned short surfw,
100598af18c5Smrg   unsigned short surfh
100698af18c5Smrg)
100798af18c5Smrg
100898af18c5SmrgStatus
100998af18c5SmrgXvMCBlendSubpicture2 (
101098af18c5Smrg   Display *display,
101198af18c5Smrg   XvMCSurface *source_surface,
101298af18c5Smrg   XvMCSurface *target_surface,
101398af18c5Smrg   XvMCSubpicture *subpicture,
101498af18c5Smrg   short subx,
101598af18c5Smrg   short suby,
101698af18c5Smrg   unsigned short subw,
101798af18c5Smrg   unsigned short subh,
101898af18c5Smrg   short surfx,
101998af18c5Smrg   short surfy,
102098af18c5Smrg   unsigned short surfw,
102198af18c5Smrg   unsigned short surfh
102298af18c5Smrg)
102398af18c5Smrg
102498af18c5Smrg   The behavior of these two functions is different depending on whether
102598af18c5Smrgor not the XVMC_BACKEND_SUBPICTURE flag is set in the XvMCSurfaceInfo.
102698af18c5Smrg
102798af18c5Smrg XVMC_BACKEND_SUBPICTURE set:
102898af18c5Smrg
102998af18c5Smrg    XvMCBlendSubpicture associates the subpicture with the target_surface.
103098af18c5Smrg  Both will be displayed at the next call to XvMCPutSurface.  Additional
103198af18c5Smrg  blends before the call to XvMCPutSurface simply overrides the association.
103298af18c5Smrg  Both the target_surface and subpicture will query XVMC_DISPLAYING from
103398af18c5Smrg  the call to XvMCPutSurface until they are no longer displaying.  It is
103498af18c5Smrg  safe to associate the subpicture and target_surface before rendering has
103598af18c5Smrg  completed (while they still query XVMC_RENDERING) but it is not safe to
103642941e3bSmrg  call XvMCPutSurface at that time.
103798af18c5Smrg
103898af18c5Smrg    XvMCBlendSubpicture2 copies the source_surface to the target_surface
103998af18c5Smrg  and associates the subpicture with the target_surface.  This essentially
104098af18c5Smrg  calls XvMCBlendSubpicture on the target_surface after the copy.  Both
104198af18c5Smrg  the subpicture and target_surface will query XVMC_DISPLAYING from the
104298af18c5Smrg  call to XvMCPutSurface until they are no longer displaying.  The
104398af18c5Smrg  source_surface will not query XVMC_DISPLAYING as a result of this function.
104498af18c5Smrg  The copy is pipelined with the rendering and will cause XVMC_RENDERING
104598af18c5Smrg  to be queried until the copy is done.
104698af18c5Smrg
104798af18c5Smrg
104898af18c5Smrg XVMC_BACKEND_SUBPICTURE not set ("frontend" behavior):
104998af18c5Smrg
105098af18c5Smrg    XvMCBlendSubpicture is a no-op in this case.
105198af18c5Smrg
105298af18c5Smrg    XvMCBlendSubpicture2 blends the source_surface and subpicture and
105398af18c5Smrg  puts it in the target_surface.  This does not effect the status of
105498af18c5Smrg  the source surface but will cause the target_surface to query
105598af18c5Smrg  XVMC_RENDERING until the blend is completed.
105698af18c5Smrg
105798af18c5Smrg
105898af18c5Smrg  display - The connection to the server.
105998af18c5Smrg
106098af18c5Smrg  subpicture - The subpicture to be blended into the video.
106198af18c5Smrg
106298af18c5Smrg  target_surface - The surface to be displayed with the blended subpicture.
106398af18c5Smrg
106498af18c5Smrg  source_surface - Source surface prior to blending.
106598af18c5Smrg
106698af18c5Smrg  subx -
106798af18c5Smrg  suby -
106898af18c5Smrg  subw -
106998af18c5Smrg  subh -  The rectangle from the subpicture to be blended.
107098af18c5Smrg
107198af18c5Smrg  surfx -
107298af18c5Smrg  surfy -
107398af18c5Smrg  surfw -
107498af18c5Smrg  surfh - The rectangle in the XvMCSurface to blend the subpicture rectangle
107598af18c5Smrg          into.  If XVMC_SUBPICTURE_INDEPENDENT_SCALING is not set in the
107642941e3bSmrg          XvMCSurfaceInfo subw must be equal to surfw and subh must be
107742941e3bSmrg          equal to surfh height or else a BadValue error occurs.
107898af18c5Smrg
107998af18c5Smrg   Errors:
108098af18c5Smrg
108198af18c5Smrg    XvMCBadSurface - Any of the surfaces are invalid.
108298af18c5Smrg
108398af18c5Smrg    XvMCBadSubpicture - The subpicture is invalid.
108498af18c5Smrg
108598af18c5Smrg    BadMatch - The subpicture or any of the surfaces do not belong to the
108698af18c5Smrg               same context.
108798af18c5Smrg
108898af18c5Smrg    BadValue - XVMC_SUBPICTURE_INDEPENDENT_SCALING is set and the source
108998af18c5Smrg               and destination rectangles are different sizes.
109098af18c5Smrg
109198af18c5Smrg
109298af18c5Smrg/***********************************************************************/
109398af18c5Smrg
109498af18c5Smrg     SURFACE SYNCHRONIZATION
109598af18c5Smrg
109698af18c5Smrg/***********************************************************************/
109798af18c5Smrg
109898af18c5Smrg
109998af18c5Smrg#define XVMC_RENDERING		0x00000001
110098af18c5Smrg#define XVMC_DISPLAYING		0x00000002
110198af18c5Smrg
110298af18c5SmrgStatus
110398af18c5SmrgXvMCSyncSurface (Display *display, XvMCSurface *surface)
110498af18c5Smrg
110598af18c5Smrg   This function blocks until all rendering requests on the surface
110642941e3bSmrg  have been completed.
110798af18c5Smrg
110898af18c5Smrg     display - The connection to the server.
110998af18c5Smrg
111098af18c5Smrg     surface - The surface to synchronize.
111198af18c5Smrg
111298af18c5Smrg     Errors:
111398af18c5Smrg
111498af18c5Smrg         XvMCBadSurface - The surface is not valid.
111598af18c5Smrg
111698af18c5Smrg
111798af18c5SmrgStatus
111898af18c5SmrgXvMCFlushSurface (Display *display, XvMCSurface *surface)
111942941e3bSmrg
112098af18c5Smrg   This function commits pending rendering requests to ensure that
112142941e3bSmrg  they will be completed in a finite amount of time.
112298af18c5Smrg
112340613eb2Smrg    display -  The connection to the server.
112498af18c5Smrg
112540613eb2Smrg    surface -  The surface whose rendering requests should be flushed.
112698af18c5Smrg
112798af18c5Smrg     Errors:
112898af18c5Smrg
112998af18c5Smrg         XvMCBadSurface - The surface is not valid.
113098af18c5Smrg
113198af18c5Smrg
113298af18c5SmrgStatus
113398af18c5SmrgXvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat)
113498af18c5Smrg
113598af18c5Smrg   display -  The connection to the server.
113642941e3bSmrg
113740613eb2Smrg   surface -  The surface whose status is being queried.
113898af18c5Smrg
113998af18c5Smrg   stat -  May be any of the following OR'd together:
114098af18c5Smrg
114198af18c5Smrg   XVMC_RENDERING - The last XvMCRenderSurface request has not completed
114298af18c5Smrg                    yet.
114398af18c5Smrg
114498af18c5Smrg   XVMC_DISPLAYING - The surface is currently being displayed or a
114598af18c5Smrg                     display is pending (ie. it is not safe to render
114698af18c5Smrg                     to it).
114798af18c5Smrg
114898af18c5Smrg    Errors:
114998af18c5Smrg
115098af18c5Smrg         XvMCBadSurface - The surface is not valid.
115198af18c5Smrg
115298af18c5Smrg
115398af18c5Smrg/***********************************************************************/
115498af18c5Smrg
115598af18c5Smrg     SUBPICTURE SYNCHRONIZATION
115698af18c5Smrg
115798af18c5Smrg/***********************************************************************/
115898af18c5Smrg
115998af18c5Smrg
116098af18c5Smrg
116198af18c5SmrgStatus
116298af18c5SmrgXvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture)
116342941e3bSmrg
116498af18c5Smrg   This function blocks until all composite/clear requests on the supicture
116598af18c5Smrg  have been completed.
116698af18c5Smrg
116798af18c5Smrg     display - The connection to the server.
116898af18c5Smrg
116998af18c5Smrg     subpicture -  The subpicture to synchronize.
117098af18c5Smrg
117198af18c5Smrg     Errors:
117298af18c5Smrg
117398af18c5Smrg         XvMCBadSubpicture - The subpicture is not valid.
117498af18c5Smrg
117598af18c5Smrg
117698af18c5SmrgStatus
117798af18c5SmrgXvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture)
117842941e3bSmrg
117998af18c5Smrg   This function commits pending composite/clear requests to ensure that
118042941e3bSmrg  they will be completed in a finite amount of time.
118198af18c5Smrg
118298af18c5Smrg    display - The connection to the server.
118398af18c5Smrg
118440613eb2Smrg    subpicture - The subpicture whose compositing should be flushed.
118598af18c5Smrg
118698af18c5Smrg     Errors:
118798af18c5Smrg
118898af18c5Smrg         XvMCBadSubpicture - The surface is not valid.
118998af18c5Smrg
119098af18c5Smrg
119198af18c5SmrgStatus
119298af18c5SmrgXvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat)
119398af18c5Smrg
119498af18c5Smrg    display - The connection to the server.
119598af18c5Smrg
119640613eb2Smrg    subpic - The subpicture whose status is being queried.
119798af18c5Smrg
119898af18c5Smrg    stat - may be any of the following OR'd together:
119998af18c5Smrg
120042941e3bSmrg   XVMC_RENDERING - The last XvMCCompositeSubpicture or XvMCClearSubpicture
120198af18c5Smrg                    request has not completed yet.
120298af18c5Smrg
120398af18c5Smrg   XVMC_DISPLAYING - The subpicture is currently being displayed or a
120498af18c5Smrg                     display is pending (ie. it is not safe to render
120598af18c5Smrg                     to it).
120698af18c5Smrg
120798af18c5Smrg     Errors:
120898af18c5Smrg
120998af18c5Smrg         XvMCBadSubpicture - The surface is not valid.
121098af18c5Smrg
121198af18c5Smrg/********************************************************************/
121298af18c5Smrg
121398af18c5Smrg     ATTRIBUTES
121498af18c5Smrg
121598af18c5Smrg/********************************************************************/
121698af18c5Smrg
121798af18c5Smrg   Context specific attribute functions are provided.  These are
121842941e3bSmrgsimilar to their Xv Counterparts XvQueryPortAttributes, XvSetPortAttribute
121998af18c5Smrgand XvGetPortAttribute but their state is specific to the context.
122098af18c5Smrg
122198af18c5SmrgXvAttribute *
122298af18c5SmrgXvMCQueryAttributes (
122398af18c5Smrg    Display *display,
122498af18c5Smrg    XvMCContext *context,
122598af18c5Smrg    int *number
122698af18c5Smrg)
122798af18c5Smrg
122898af18c5Smrg    An array of XvAttributes of size "number" is returned by this function.
122998af18c5Smrg  If there are no attributes, NULL is returned and number is set to 0.
123098af18c5Smrg  The array may be freed with XFree().
123198af18c5Smrg
123298af18c5Smrg    display - The connection to the server.
123398af18c5Smrg
123440613eb2Smrg    context - The context whose attributes we are querying.
123598af18c5Smrg
123698af18c5Smrg    number - The returned number of recognized atoms.
123798af18c5Smrg
123898af18c5Smrg    Errors:
123998af18c5Smrg
124098af18c5Smrg	XvMCBadContext - The context is invalid.
124198af18c5Smrg
124298af18c5SmrgStatus
124398af18c5SmrgXvMCSetAttribute (
124498af18c5Smrg    Display *display,
124542941e3bSmrg    XvMCContext *context,
124642941e3bSmrg    Atom attribute,
124798af18c5Smrg    int value
124898af18c5Smrg)
124998af18c5Smrg
125098af18c5Smrg    This function sets a context-specific attribute and returns Success
125198af18c5Smrg  if no error has occurred.
125298af18c5Smrg
125398af18c5Smrg    display - The connection to the server.
125498af18c5Smrg
125598af18c5Smrg    context - The context for which the attribute change is to go into effect.
125698af18c5Smrg
125798af18c5Smrg    attribute - The X Atom of the attribute to be changed.
125898af18c5Smrg
125998af18c5Smrg    value -  The new value of the attribute.
126098af18c5Smrg
126198af18c5Smrg    Errors:
126298af18c5Smrg
126398af18c5Smrg	XvMCBadContext - The context is not valid.
126498af18c5Smrg
126598af18c5Smrg	BadValue - An invalid value was specified.
126698af18c5Smrg
126798af18c5Smrg	BadMatch - This attribute is not defined for this context.
126898af18c5Smrg
126998af18c5SmrgStatus
127098af18c5SmrgXvMCGetAttribute (
127198af18c5Smrg    Display *display,
127242941e3bSmrg    XvMCContext *context,
127342941e3bSmrg    Atom attribute,
127498af18c5Smrg    int *value
127598af18c5Smrg)
127698af18c5Smrg
127798af18c5Smrg    This function queries a context-specific attribute and return
127898af18c5Smrg  Success and the value if no error has occurred.
127998af18c5Smrg
128098af18c5Smrg    display - The connection to the server.
128198af18c5Smrg
128240613eb2Smrg    context - The context whose attribute we are querying.
128398af18c5Smrg
128498af18c5Smrg    attribute - The X Atom of the attribute to be retrieved.
128598af18c5Smrg
128642941e3bSmrg    value -  The returned attribute value.
128798af18c5Smrg
128898af18c5Smrg    Errors:
128998af18c5Smrg
129098af18c5Smrg        XvMCBadContext - The context is not valid.
129198af18c5Smrg
129298af18c5Smrg        BadMatch - This attribute is not defined for this context.
129398af18c5Smrg
1294