1 /*****************************************************************************
2 * vpar_blocks.h : video parser blocks management
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: vpar_blocks.h,v 1.33 2001/01/21 01:36:25 massiot Exp $
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * Jean-Marc Dressler <polux@via.ecp.fr>
9 * Stéphane Borel <stef@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
37 *****************************************************************************/
39 /*****************************************************************************
40 * macroblock_t : information on a macroblock passed to the video_decoder
42 *****************************************************************************/
43 typedef struct macroblock_s
45 picture_t * p_picture; /* current frame in progress */
47 int i_mb_type; /* macroblock type */
48 int i_coded_block_pattern;
49 /* which blocks are coded ? */
50 int i_chroma_nb_blocks; /* number of blocks for
51 * chroma components */
53 /* IDCT information */
54 dctelem_t ppi_blocks[12][64]; /* blocks */
55 void ( * pf_idct[12] ) ( struct vdec_thread_s *,
56 dctelem_t*, int ); /* sparse IDCT or not ? */
57 int pi_sparse_pos[12]; /* position of the
60 /* Motion compensation information */
61 f_motion_t pf_motion; /* function to use for motion comp */
62 picture_t * p_backward; /* backward reference frame */
63 picture_t * p_forward; /* forward reference frame */
64 int ppi_field_select[2][2]; /* field to use to
66 int pppi_motion_vectors[2][2][2]; /* motion vectors */
67 int ppi_dmv[2][2]; /* differential motion vectors */
68 /* coordinates of the block in the picture */
72 int i_l_stride; /* number of yuv_data_t to
73 * ignore when changing line */
74 int i_c_stride; /* idem, for chroma */
75 boolean_t b_P_second; /* Second field of a P picture ?
76 * (used to determine the predicting
78 boolean_t b_motion_field; /* Field we are predicting
79 * (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 */
88 /*****************************************************************************
89 * macroblock_parsing_t : macroblock context & predictors
90 *****************************************************************************/
93 unsigned char i_quantizer_scale; /* scale of the quantization
95 int pi_dc_dct_pred[3]; /* ISO/IEC 13818-2 7.2.1 */
96 int pppi_pmv[2][2][2]; /* Motion vect predictors, 7.6.3 */
97 int i_motion_dir;/* Used for the next skipped macroblock */
99 /* Context used to optimize block parsing */
100 int i_motion_type, i_mv_count, i_mv_format;
101 boolean_t b_dmv, b_dct_type;
103 /* Coordinates of the upper-left pixel of the macroblock, in lum and
105 int i_l_x, i_l_y, i_c_x, i_c_y;
106 } macroblock_parsing_t;
108 /*****************************************************************************
109 * lookup_t : entry type for lookup tables *
110 *****************************************************************************/
111 typedef struct lookup_s
117 /*****************************************************************************
118 * ac_lookup_t : special entry type for lookup tables about ac coefficients
119 *****************************************************************************/
120 typedef struct dct_lookup_s
127 /*****************************************************************************
129 *****************************************************************************/
130 /* Macroblock types */
133 #define MB_MOTION_BACKWARD 4
134 #define MB_MOTION_FORWARD 8
138 #define MOTION_FIELD 1
139 #define MOTION_FRAME 2
140 #define MOTION_16X8 2
143 /* Macroblock Address Increment types */
144 #define MB_ADDRINC_ESCAPE 8
145 #define MB_ADDRINC_STUFFING 15
147 /* Error constant for lookup tables */
148 #define MB_ERROR (-1)
151 #define SCAN_ZIGZAG 0
154 /* Constant for block decoding */
156 #define DCT_ESCAPE 65
158 /*****************************************************************************
160 *****************************************************************************/
161 extern u8 pi_default_intra_quant[64];
162 extern u8 pi_default_nonintra_quant[64];
163 extern u8 pi_scan[2][64];
165 /*****************************************************************************
167 *****************************************************************************/
168 void vpar_InitCrop( struct vpar_thread_s* p_vpar );
169 void vpar_InitMbAddrInc( struct vpar_thread_s * p_vpar );
170 void vpar_InitPMBType( struct vpar_thread_s * p_vpar );
171 void vpar_InitBMBType( struct vpar_thread_s * p_vpar );
172 void vpar_InitCodedPattern( struct vpar_thread_s * p_vpar );
173 void vpar_InitDCTTables( struct vpar_thread_s * p_vpar );
174 void vpar_InitScanTable( struct vpar_thread_s * p_vpar );
176 typedef void (*f_picture_data_t)( struct vpar_thread_s * p_vpar,
178 #define PROTO_PICD( FUNCNAME ) \
179 void FUNCNAME( struct vpar_thread_s * p_vpar, int i_mb_base );
181 PROTO_PICD( vpar_PictureDataGENERIC )
182 #if (VPAR_OPTIM_LEVEL > 0)
183 PROTO_PICD( vpar_PictureData1I )
184 PROTO_PICD( vpar_PictureData1P )
185 PROTO_PICD( vpar_PictureData1B )
186 PROTO_PICD( vpar_PictureData1D )
187 PROTO_PICD( vpar_PictureData2IF )
188 PROTO_PICD( vpar_PictureData2PF )
189 PROTO_PICD( vpar_PictureData2BF )
191 #if (VPAR_OPTIM_LEVEL > 1)
192 PROTO_PICD( vpar_PictureData2IT )
193 PROTO_PICD( vpar_PictureData2PT )
194 PROTO_PICD( vpar_PictureData2BT )
195 PROTO_PICD( vpar_PictureData2IB )
196 PROTO_PICD( vpar_PictureData2PB )
197 PROTO_PICD( vpar_PictureData2BB )