190b17f1bSmrg/*****************************************************************************
290b17f1bSmrg * VLD Nonstandard XvMC extension.
390b17f1bSmrg *
490b17f1bSmrg * Copyright (c) 2004 The Unichrome Project. All rights reserved.
590b17f1bSmrg *
690b17f1bSmrg * Permission is hereby granted, free of charge, to any person obtaining a
790b17f1bSmrg * copy of this software and associated documentation files (the "Software"),
890b17f1bSmrg * to deal in the Software without restriction, including without limitation
990b17f1bSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1090b17f1bSmrg * and/or sell copies of the Software, and to permit persons to whom the
1190b17f1bSmrg * Software is furnished to do so, subject to the following conditions:
1290b17f1bSmrg *
1390b17f1bSmrg * The above copyright notice and this permission notice shall be included in
1490b17f1bSmrg * all copies or substantial portions of the Software.
1590b17f1bSmrg *
1690b17f1bSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1790b17f1bSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1890b17f1bSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1990b17f1bSmrg * AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2090b17f1bSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2190b17f1bSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2290b17f1bSmrg * DEALINGS IN THE SOFTWARE.
2390b17f1bSmrg *
2490b17f1bSmrg * Author: Thomas Hellstr�m, 2004.
2590b17f1bSmrg */
2690b17f1bSmrg
2790b17f1bSmrg#ifndef _VLDXVMC_H
2890b17f1bSmrg#define _VLDXVMC_H
2990b17f1bSmrg
3090b17f1bSmrg#include <X11/Xlib.h>
3190b17f1bSmrg#include <X11/extensions/XvMC.h>
3290b17f1bSmrg#include <X11/extensions/XvMClib.h>
3390b17f1bSmrg
3490b17f1bSmrg/*
3590b17f1bSmrg * New "Motion compensation type".
3690b17f1bSmrg */
3790b17f1bSmrg
3890b17f1bSmrg#define XVMC_VLD 0x0020000
3990b17f1bSmrg
4090b17f1bSmrg/*
4190b17f1bSmrg * Below Flags to be passed in the XvMCMpegControl structure 'flag' field.
4290b17f1bSmrg */
4390b17f1bSmrg
4490b17f1bSmrg#define XVMC_PROGRESSIVE_SEQUENCE 0x00000010
4590b17f1bSmrg
4690b17f1bSmrg/*
4790b17f1bSmrg * Zig-Zag Scan / Alternative Scan.
4890b17f1bSmrg */
4990b17f1bSmrg
5090b17f1bSmrg#define XVMC_ZIG_ZAG_SCAN         0x00000000
5190b17f1bSmrg#define XVMC_ALTERNATE_SCAN       0x00000100
5290b17f1bSmrg
5390b17f1bSmrg/*
5490b17f1bSmrg * Frame DCT and frame prediction are used. /
5590b17f1bSmrg * Field prediction
5690b17f1bSmrg */
5790b17f1bSmrg
5890b17f1bSmrg#define XVMC_PRED_DCT_FRAME       0x00000040
5990b17f1bSmrg#define XVMC_PRED_DCT_FIELD       0x00000000
6090b17f1bSmrg
6190b17f1bSmrg/*
6290b17f1bSmrg * Top / Bottom field first
6390b17f1bSmrg */
6490b17f1bSmrg
6590b17f1bSmrg#define XVMC_TOP_FIELD_FIRST      0x00000080
6690b17f1bSmrg#define XVMC_BOTTOM_FIELD_FIRST   0x00000000
6790b17f1bSmrg
6890b17f1bSmrg/*
6990b17f1bSmrg * Motion vectors coded in intra macroblocks
7090b17f1bSmrg */
7190b17f1bSmrg
7290b17f1bSmrg#define XVMC_CONCEALMENT_MOTION_VECTORS 0x00000200
7390b17f1bSmrg
7490b17f1bSmrg/*
7590b17f1bSmrg * Which of two mappings between quantiser_scale_code
7690b17f1bSmrg * and quantiser_scale shall apply.
7790b17f1bSmrg */
7890b17f1bSmrg
7990b17f1bSmrg#define XVMC_Q_SCALE_TYPE         0x00000400
8090b17f1bSmrg
8190b17f1bSmrg/*
8290b17f1bSmrg * Intra VLC Format: Bit = 0,  Bit = 1
8390b17f1bSmrg * Intra blocks      B-14      B-15
8490b17f1bSmrg * Non-intra blocks  B-14      B-14
8590b17f1bSmrg */
8690b17f1bSmrg#define XVMC_INTRA_VLC_FORMAT     0x00000800
8790b17f1bSmrg
8890b17f1bSmrg/*
8990b17f1bSmrg * Also XVMC_SECOND_FIELD should be set in flags if active.
9090b17f1bSmrg */
9190b17f1bSmrg
9290b17f1bSmrg#define XVMC_I_PICTURE 1
9390b17f1bSmrg#define XVMC_P_PICTURE 2
9490b17f1bSmrg#define XVMC_B_PICTURE 3
9590b17f1bSmrg
9690b17f1bSmrgtypedef struct _XvMCMpegControl
9790b17f1bSmrg{
9890b17f1bSmrg    unsigned BVMV_range,	       /* Backward vertical motion vector range */
9990b17f1bSmrg        BHMV_range,		       /* Backward horizontal motion vector range */
10090b17f1bSmrg        FVMV_range,		       /* Forward vertical motion vector range */
10190b17f1bSmrg        FHMV_range,		       /* Forward horizontal motion vector range */
10290b17f1bSmrg        picture_structure,	       /* XVMC_TOP_FIELD, XVMC_BOTTOM_FIELD,
10390b17f1bSmrg				        *  XVMC_FRAME_PICTURE
10490b17f1bSmrg				        */
10590b17f1bSmrg        intra_dc_precision,	       /* 0x00 - 0x03 corresponds to 8 to 11 bits prec. */
10690b17f1bSmrg        picture_coding_type,	       /* XVMC_X_PICTURE */
10790b17f1bSmrg        mpeg_coding,		       /* XVMC_MPEG_2 */
10890b17f1bSmrg        flags;			       /* See above */
10990b17f1bSmrg} XvMCMpegControl;
11090b17f1bSmrg
11190b17f1bSmrg/*
11290b17f1bSmrg * The following function is called BEFORE starting sending slices to the
11390b17f1bSmrg * lib. It grabs the decoder hardware and prepares it for coming slices.
11490b17f1bSmrg * The function XvMCSyncSurface will release the hardware for other contexts
11590b17f1bSmrg * in addition to it's current functionality.
11690b17f1bSmrg */
11790b17f1bSmrg
11890b17f1bSmrgextern Status XvMCBeginSurface(Display * display,
11990b17f1bSmrg    XvMCContext * context,
12090b17f1bSmrg    XvMCSurface * target_surface,
12190b17f1bSmrg    XvMCSurface * past_surface,
12290b17f1bSmrg    XvMCSurface * future_surface, const XvMCMpegControl * control);
12390b17f1bSmrg
12490b17f1bSmrg/*
12590b17f1bSmrg * The quantizer matrix structure. This should be filled in by the user and
12690b17f1bSmrg * uploaded whenever a change is needed. The lib initializes with
12790b17f1bSmrg * default matrices and will automatically load the hardware with new matrices
12890b17f1bSmrg * on decoder context switches. To load data, set the corresponding load flag
12990b17f1bSmrg * to true and fill in the values. The VIA MPEG2 engine only uses the
13090b17f1bSmrg * intra_quantiser_matrix and the non_intra_quantiser_matrix. RFC: Are
13190b17f1bSmrg * the other fields needed for future compatibility?
13290b17f1bSmrg */
13390b17f1bSmrg
13490b17f1bSmrgtypedef struct _XvMCQMatrix
13590b17f1bSmrg{
13690b17f1bSmrg    int load_intra_quantiser_matrix;
13790b17f1bSmrg    int load_non_intra_quantiser_matrix;
13890b17f1bSmrg    int load_chroma_intra_quantiser_matrix;
13990b17f1bSmrg    int load_chroma_non_intra_quantiser_matrix;
14090b17f1bSmrg    unsigned char intra_quantiser_matrix[64];
14190b17f1bSmrg    unsigned char non_intra_quantiser_matrix[64];
14290b17f1bSmrg    unsigned char chroma_intra_quantiser_matrix[64];
14390b17f1bSmrg    unsigned char chroma_non_intra_quantiser_matrix[64];
14490b17f1bSmrg} XvMCQMatrix;
14590b17f1bSmrg
14690b17f1bSmrg/*
14790b17f1bSmrg * Upload a XvMCQMatrix structure to the clientlib.
14890b17f1bSmrg * The hardware will start using it the next XvMCBeginSurface.
14990b17f1bSmrg */
15090b17f1bSmrg
15190b17f1bSmrgextern Status XvMCLoadQMatrix(Display * display, XvMCContext * context,
15290b17f1bSmrg    const XvMCQMatrix * qmx);
15390b17f1bSmrg
15490b17f1bSmrg/*
15590b17f1bSmrg * Put a slice to the decoder. The hardware will start processing it
15690b17f1bSmrg * immediately.
15790b17f1bSmrg */
15890b17f1bSmrg
15990b17f1bSmrgextern Status XvMCPutSlice(Display * display, XvMCContext * context,
16090b17f1bSmrg    char *slice, int nBytes);
16190b17f1bSmrg/*
16290b17f1bSmrg * Put a slice without the slice start code to the decoder.
16390b17f1bSmrg * The hardware will start processing it
16490b17f1bSmrg * immediately. This function is for client optimization.
16590b17f1bSmrg * XvMCPutSlice(display,context,slice,nBytes) is equivalent to
16690b17f1bSmrg * XvMCPutSlice2(display,context,slice+4,nBytes-4,slice[3]);
16790b17f1bSmrg */
16890b17f1bSmrg
16990b17f1bSmrgextern Status XvMCPutSlice2(Display * display, XvMCContext * context,
17090b17f1bSmrg    char *slice, int nBytes, int sliceCode);
17190b17f1bSmrg
17290b17f1bSmrg/*
17390b17f1bSmrg * Debug the XvMCControl structure. For convenience only.
17490b17f1bSmrg */
17590b17f1bSmrg
17690b17f1bSmrgextern void debugControl(const XvMCMpegControl * control);
17790b17f1bSmrg
17890b17f1bSmrg#endif
179