vpar_blocks.h 8.59 KB
Newer Older
1 2 3
/*****************************************************************************
 * vpar_blocks.h : video parser blocks management
 *****************************************************************************
4
 * Copyright (C) 1999, 2000 VideoLAN
5
 * $Id: vpar_blocks.h,v 1.33 2001/01/21 01:36:25 massiot Exp $
6
 *
7 8 9
 * Authors: Christophe Massiot <massiot@via.ecp.fr>
 *          Jean-Marc Dressler <polux@via.ecp.fr>
 *          Stphane Borel <stef@via.ecp.fr>
10 11 12 13 14
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
15
 * 
16 17
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
20
 *
21 22 23
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24 25 26
 *****************************************************************************/

/*****************************************************************************
27 28 29 30
 * Requires:
 *  "config.h"
 *  "common.h"
 *  "mtime.h"
31
 *  "threads.h"
32 33 34 35 36 37 38
 *  "input.h"
 *  "video.h"
 *  "video_output.h"
 *  "decoder_fifo.h"
 *  "video_fifo.h"
 *****************************************************************************/

39
/*****************************************************************************
40 41
 * macroblock_t : information on a macroblock passed to the video_decoder
 *                thread
42 43 44
 *****************************************************************************/
typedef struct macroblock_s
{
45 46
    picture_t *             p_picture;          /* current frame in progress */

47
    int                     i_mb_type;                    /* macroblock type */
48
    int                     i_coded_block_pattern;
49 50 51
                                                 /* which blocks are coded ? */
    int                     i_chroma_nb_blocks;         /* number of blocks for
                                                         * chroma components */
52

53
    /* IDCT information */
54
    dctelem_t               ppi_blocks[12][64];                    /* blocks */
55 56
    void ( * pf_idct[12] )  ( struct vdec_thread_s *,
                              dctelem_t*, int );     /* sparse IDCT or not ? */
57 58
    int                     pi_sparse_pos[12];             /* position of the
                                                            * non-NULL coeff */
59 60 61

    /* Motion compensation information */
    f_motion_t              pf_motion;    /* function to use for motion comp */
62 63 64 65 66 67 68
    picture_t *             p_backward;          /* backward reference frame */
    picture_t *             p_forward;            /* forward reference frame */
    int                     ppi_field_select[2][2];      /* field to use to
                                                          * form predictions */
    int                     pppi_motion_vectors[2][2][2];  /* motion vectors */
    int                     ppi_dmv[2][2];    /* differential motion vectors */
                            /* coordinates of the block in the picture */
69
    int                     i_l_x, i_c_x;
70 71
    int                     i_motion_l_y;
    int                     i_motion_c_y;
72
    int                     i_l_stride;         /* number of yuv_data_t to
73 74 75 76 77 78 79 80
                                                 * ignore when changing line */
    int                     i_c_stride;                  /* idem, for chroma */
    boolean_t               b_P_second;  /* Second field of a P picture ?
                                          * (used to determine the predicting
                                          * frame)                           */
    boolean_t               b_motion_field;  /* Field we are predicting
                                              * (top field or bottom field) */

81
    /* AddBlock information */
82
    yuv_data_t *            p_data[12];              /* pointer to the position
83
                                                      * in the final picture */
84
    int                     i_addb_l_stride, i_addb_c_stride;
85
                                 /* nb of coeffs to jump when changing lines */
86 87 88
} macroblock_t;

/*****************************************************************************
89
 * macroblock_parsing_t : macroblock context & predictors
90 91 92
 *****************************************************************************/
typedef struct
{
93 94 95 96
    unsigned char       i_quantizer_scale;        /* scale of the quantization
                                                   * matrices                */
    int                 pi_dc_dct_pred[3];          /* ISO/IEC 13818-2 7.2.1 */
    int                 pppi_pmv[2][2][2];  /* Motion vect predictors, 7.6.3 */
97
    int                 i_motion_dir;/* Used for the next skipped macroblock */
98 99 100 101 102 103 104 105

    /* Context used to optimize block parsing */
    int                 i_motion_type, i_mv_count, i_mv_format;
    boolean_t           b_dmv, b_dct_type;

    /* Coordinates of the upper-left pixel of the macroblock, in lum and
     * chroma */
    int                 i_l_x, i_l_y, i_c_x, i_c_y;
106 107
} macroblock_parsing_t;

108 109 110
/*****************************************************************************
 * lookup_t : entry type for lookup tables                                   *
 *****************************************************************************/
111 112 113 114 115 116
typedef struct lookup_s
{
    int    i_value;
    int    i_length;
} lookup_t;

117
/*****************************************************************************
118
 * ac_lookup_t : special entry type for lookup tables about ac coefficients
119
 *****************************************************************************/
120 121
typedef struct dct_lookup_s
{
122 123 124
    char   i_run;
    char   i_level;
    char   i_length;
125 126
} dct_lookup_t;

127 128 129 130 131 132 133 134 135
/*****************************************************************************
 * Standard codes
 *****************************************************************************/
/* Macroblock types */
#define MB_INTRA                        1
#define MB_PATTERN                      2
#define MB_MOTION_BACKWARD              4
#define MB_MOTION_FORWARD               8
#define MB_QUANT                        16
136

137 138 139 140 141
/* Motion types */
#define MOTION_FIELD                    1
#define MOTION_FRAME                    2
#define MOTION_16X8                     2
#define MOTION_DMV                      3
142

143
/* Macroblock Address Increment types */
144 145 146 147 148
#define MB_ADDRINC_ESCAPE               8
#define MB_ADDRINC_STUFFING             15

/* Error constant for lookup tables */
#define MB_ERROR                        (-1)
149

150
/* Scan */
151 152
#define SCAN_ZIGZAG                     0
#define SCAN_ALT                        1
153

154
/* Constant for block decoding */
155 156
#define DCT_EOB                         64
#define DCT_ESCAPE                      65
157 158 159 160

/*****************************************************************************
 * Constants
 *****************************************************************************/
161 162
extern u8       pi_default_intra_quant[64];
extern u8       pi_default_nonintra_quant[64];
163 164
extern u8       pi_scan[2][64];

165 166 167
/*****************************************************************************
 * Prototypes
 *****************************************************************************/
168
void vpar_InitCrop( struct vpar_thread_s* p_vpar );
169 170 171 172 173
void vpar_InitMbAddrInc( struct vpar_thread_s * p_vpar );
void vpar_InitPMBType( struct vpar_thread_s * p_vpar );
void vpar_InitBMBType( struct vpar_thread_s * p_vpar );
void vpar_InitCodedPattern( struct vpar_thread_s * p_vpar );
void vpar_InitDCTTables( struct vpar_thread_s * p_vpar );
174
void vpar_InitScanTable( struct vpar_thread_s * p_vpar );
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199

typedef void (*f_picture_data_t)( struct vpar_thread_s * p_vpar,
                                  int i_mb_base );
#define PROTO_PICD( FUNCNAME )                                              \
void FUNCNAME( struct vpar_thread_s * p_vpar, int i_mb_base );

PROTO_PICD( vpar_PictureDataGENERIC )
#if (VPAR_OPTIM_LEVEL > 0)
PROTO_PICD( vpar_PictureData1I )
PROTO_PICD( vpar_PictureData1P )
PROTO_PICD( vpar_PictureData1B )
PROTO_PICD( vpar_PictureData1D )
PROTO_PICD( vpar_PictureData2IF )
PROTO_PICD( vpar_PictureData2PF )
PROTO_PICD( vpar_PictureData2BF )
#endif
#if (VPAR_OPTIM_LEVEL > 1)
PROTO_PICD( vpar_PictureData2IT )
PROTO_PICD( vpar_PictureData2PT )
PROTO_PICD( vpar_PictureData2BT )
PROTO_PICD( vpar_PictureData2IB )
PROTO_PICD( vpar_PictureData2PB )
PROTO_PICD( vpar_PictureData2BB )
#endif